Bitcoin Core  0.18.99
P2P Digital Currency
ui_interface.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2018 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <ui_interface.h>
6 
7 #include <boost/signals2/last_value.hpp>
8 #include <boost/signals2/signal.hpp>
9 
11 
12 struct UISignals {
13  boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::last_value<bool>> ThreadSafeMessageBox;
14  boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::last_value<bool>> ThreadSafeQuestion;
15  boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
16  boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
17  boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
18  boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
19  boost::signals2::signal<CClientUIInterface::LoadWalletSig> LoadWallet;
20  boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
21  boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
22  boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
23  boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
24 } g_ui_signals;
25 
26 #define ADD_SIGNALS_IMPL_WRAPPER(signal_name) \
27  boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
28  { \
29  return g_ui_signals.signal_name.connect(fn); \
30  }
31 
43 
44 bool CClientUIInterface::ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style); }
45 bool CClientUIInterface::ThreadSafeQuestion(const std::string& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style); }
46 void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
47 void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
48 void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
49 void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }
50 void CClientUIInterface::LoadWallet(std::unique_ptr<interfaces::Wallet>& wallet) { return g_ui_signals.LoadWallet(wallet); }
51 void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); }
52 void CClientUIInterface::NotifyBlockTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(b, i); }
53 void CClientUIInterface::NotifyHeaderTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyHeaderTip(b, i); }
54 void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }
55 
56 
57 bool InitError(const std::string& str)
58 {
59  uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
60  return false;
61 }
62 
63 void InitWarning(const std::string& str)
64 {
65  uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
66 }
boost::signals2::signal< CClientUIInterface::NotifyBlockTipSig > NotifyBlockTip
boost::signals2::signal< CClientUIInterface::LoadWalletSig > LoadWallet
boost::signals2::signal< CClientUIInterface::NotifyNumConnectionsChangedSig > NotifyNumConnectionsChanged
boost::signals2::signal< CClientUIInterface::InitMessageSig > InitMessage
boost::signals2::signal< CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::last_value< bool > > ThreadSafeMessageBox
std::shared_ptr< CWallet > LoadWallet(interfaces::Chain &chain, const std::string &name, std::string &error, std::string &warning)
Definition: dummywallet.cpp:72
boost::signals2::signal< CClientUIInterface::NotifyHeaderTipSig > NotifyHeaderTip
boost::signals2::signal< CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::last_value< bool > > ThreadSafeQuestion
Signals for UI communication.
Definition: ui_interface.h:34
boost::signals2::signal< CClientUIInterface::BannedListChangedSig > BannedListChanged
struct UISignals g_ui_signals
boost::signals2::signal< CClientUIInterface::NotifyAlertChangedSig > NotifyAlertChanged
bool InitError(const std::string &str)
Show error message.
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:139
boost::signals2::signal< CClientUIInterface::ShowProgressSig > ShowProgress
#define ADD_SIGNALS_IMPL_WRAPPER(signal_name)
boost::signals2::signal< CClientUIInterface::NotifyNetworkActiveChangedSig > NotifyNetworkActiveChanged
void InitWarning(const std::string &str)
Show warning message.
CClientUIInterface uiInterface