2016-04-19 16:10:39 +02:00
|
|
|
// Copyright (c) 2010-2016 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <ui_interface.h>
|
2016-04-19 16:10:39 +02:00
|
|
|
|
2020-05-08 18:17:47 +02:00
|
|
|
#include <util/translation.h>
|
|
|
|
|
2018-08-13 21:01:07 +02:00
|
|
|
#include <boost/signals2/last_value.hpp>
|
|
|
|
#include <boost/signals2/signal.hpp>
|
|
|
|
|
2016-04-19 16:10:39 +02:00
|
|
|
CClientUIInterface uiInterface;
|
|
|
|
|
2018-08-13 21:01:07 +02:00
|
|
|
struct UISignals {
|
|
|
|
boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::last_value<bool>> ThreadSafeMessageBox;
|
|
|
|
boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::last_value<bool>> ThreadSafeQuestion;
|
|
|
|
boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage;
|
|
|
|
boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged;
|
|
|
|
boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged;
|
|
|
|
boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
|
|
|
|
boost::signals2::signal<CClientUIInterface::LoadWalletSig> LoadWallet;
|
|
|
|
boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
|
|
|
|
boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
|
2021-08-10 21:41:00 +02:00
|
|
|
boost::signals2::signal<CClientUIInterface::NotifyChainLockSig> NotifyChainLock;
|
2018-08-13 21:01:07 +02:00
|
|
|
boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
|
|
|
|
boost::signals2::signal<CClientUIInterface::NotifyMasternodeListChangedSig> NotifyMasternodeListChanged;
|
|
|
|
boost::signals2::signal<CClientUIInterface::NotifyAdditionalDataSyncProgressChangedSig> NotifyAdditionalDataSyncProgressChanged;
|
|
|
|
boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
|
2019-05-26 11:01:58 +02:00
|
|
|
};
|
|
|
|
static UISignals g_ui_signals;
|
2018-08-13 21:01:07 +02:00
|
|
|
|
|
|
|
#define ADD_SIGNALS_IMPL_WRAPPER(signal_name) \
|
|
|
|
boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
|
|
|
|
{ \
|
|
|
|
return g_ui_signals.signal_name.connect(fn); \
|
|
|
|
}
|
|
|
|
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(InitMessage);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(LoadWallet);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(ShowProgress);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
|
2021-08-10 21:41:00 +02:00
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyChainLock);
|
2018-08-13 21:01:07 +02:00
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyMasternodeListChanged);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(NotifyAdditionalDataSyncProgressChanged);
|
|
|
|
ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
|
|
|
|
|
2020-05-08 18:17:47 +02:00
|
|
|
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style); }
|
|
|
|
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& 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); }
|
2018-08-13 21:01:07 +02:00
|
|
|
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
|
|
|
|
void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
|
|
|
|
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
|
|
|
|
void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }
|
2021-11-14 11:02:37 +01:00
|
|
|
void CClientUIInterface::LoadWallet(std::unique_ptr<interfaces::Wallet>& wallet) { return g_ui_signals.LoadWallet(wallet); }
|
2018-08-13 21:01:07 +02:00
|
|
|
void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); }
|
|
|
|
void CClientUIInterface::NotifyBlockTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(b, i); }
|
2021-08-10 21:41:00 +02:00
|
|
|
void CClientUIInterface::NotifyChainLock(const std::string& bestChainLockHash, int bestChainLockHeight) { return g_ui_signals.NotifyChainLock(bestChainLockHash, bestChainLockHeight); }
|
2018-08-13 21:01:07 +02:00
|
|
|
void CClientUIInterface::NotifyHeaderTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyHeaderTip(b, i); }
|
|
|
|
void CClientUIInterface::NotifyMasternodeListChanged(const CDeterministicMNList& list) { return g_ui_signals.NotifyMasternodeListChanged(list); }
|
|
|
|
void CClientUIInterface::NotifyAdditionalDataSyncProgressChanged(double nSyncProgress) { return g_ui_signals.NotifyAdditionalDataSyncProgressChanged(nSyncProgress); }
|
|
|
|
void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }
|
|
|
|
|
2020-05-08 18:17:47 +02:00
|
|
|
bool InitError(const bilingual_str& str)
|
2016-04-19 16:10:39 +02:00
|
|
|
{
|
|
|
|
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitWarning(const std::string& str)
|
|
|
|
{
|
2020-05-08 18:17:47 +02:00
|
|
|
uiInterface.ThreadSafeMessageBox(Untranslated(str), "", CClientUIInterface::MSG_WARNING);
|
2016-04-19 16:10:39 +02:00
|
|
|
}
|