Bitcoin ABC 0.30.5
P2P Digital Currency
ui_interface.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2016 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 <node/ui_interface.h>
6
7#include <util/translation.h>
8
9#include <boost/signals2/optional_last_value.hpp>
10#include <boost/signals2/signal.hpp>
11
13
14struct UISignals {
15 boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig,
16 boost::signals2::optional_last_value<bool>>
18 boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig,
19 boost::signals2::optional_last_value<bool>>
21 boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
22 boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig>
24 boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig>
26 boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig>
28 boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
29 boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig>
31 boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig>
33 boost::signals2::signal<CClientUIInterface::BannedListChangedSig>
35};
37
38#define ADD_SIGNALS_IMPL_WRAPPER(signal_name) \
39 boost::signals2::connection CClientUIInterface::signal_name##_connect( \
40 std::function<signal_name##Sig> fn) { \
41 return g_ui_signals.signal_name.connect(fn); \
42 }
43
45ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion);
47ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged);
48ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged);
49ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged);
53ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
54
56 const std::string &caption,
57 unsigned int style) {
58 return g_ui_signals.ThreadSafeMessageBox(message, caption, style)
59 .value_or(false);
60}
61bool CClientUIInterface::ThreadSafeQuestion(
62 const bilingual_str &message, const std::string &non_interactive_message,
63 const std::string &caption, unsigned int style) {
64 return g_ui_signals
65 .ThreadSafeQuestion(message, non_interactive_message, caption, style)
66 .value_or(false);
67}
68void CClientUIInterface::InitMessage(const std::string &message) {
69 return g_ui_signals.InitMessage(message);
70}
71void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) {
72 return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections);
73}
74void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) {
75 return g_ui_signals.NotifyNetworkActiveChanged(networkActive);
76}
77void CClientUIInterface::NotifyAlertChanged() {
79}
80void CClientUIInterface::ShowProgress(const std::string &title, int nProgress,
81 bool resume_possible) {
82 return g_ui_signals.ShowProgress(title, nProgress, resume_possible);
83}
84void CClientUIInterface::NotifyBlockTip(SynchronizationState s,
85 const CBlockIndex *i) {
86 return g_ui_signals.NotifyBlockTip(s, i);
87}
89 int64_t timestamp, bool presync) {
90 return g_ui_signals.NotifyHeaderTip(s, height, timestamp, presync);
91}
92void CClientUIInterface::BannedListChanged() {
94}
95
96bool InitError(const bilingual_str &str) {
97 uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
98 return false;
99}
100
101void InitWarning(const bilingual_str &str) {
102 uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
103}
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const bilingual_str &message, const std::string &caption, unsigned int style)
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:25
Signals for UI communication.
Definition: ui_interface.h:24
static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress, bool resume_possible)
static void InitMessage(SplashScreen *splash, const std::string &message)
boost::signals2::signal< CClientUIInterface::BannedListChangedSig > BannedListChanged
boost::signals2::signal< CClientUIInterface::NotifyAlertChangedSig > NotifyAlertChanged
boost::signals2::signal< CClientUIInterface::NotifyHeaderTipSig > NotifyHeaderTip
boost::signals2::signal< CClientUIInterface::NotifyBlockTipSig > NotifyBlockTip
boost::signals2::signal< CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::optional_last_value< bool > > ThreadSafeQuestion
boost::signals2::signal< CClientUIInterface::InitMessageSig > InitMessage
boost::signals2::signal< CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::optional_last_value< bool > > ThreadSafeMessageBox
boost::signals2::signal< CClientUIInterface::NotifyNumConnectionsChangedSig > NotifyNumConnectionsChanged
boost::signals2::signal< CClientUIInterface::NotifyNetworkActiveChangedSig > NotifyNetworkActiveChanged
boost::signals2::signal< CClientUIInterface::ShowProgressSig > ShowProgress
Bilingual messages:
Definition: translation.h:17
static UISignals g_ui_signals
CClientUIInterface uiInterface
void InitWarning(const bilingual_str &str)
Show warning message.
#define ADD_SIGNALS_IMPL_WRAPPER(signal_name)
bool InitError(const bilingual_str &str)
Show error message.
static bool NotifyHeaderTip(Chainstate &chainstate) LOCKS_EXCLUDED(cs_main)
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:114