Changeset View
Changeset View
Standalone View
Standalone View
src/ui_interface.h
// Copyright (c) 2010 Satoshi Nakamoto | // Copyright (c) 2010 Satoshi Nakamoto | ||||
// Copyright (c) 2012-2016 The Bitcoin Core developers | // Copyright (c) 2012-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_UI_INTERFACE_H | #ifndef BITCOIN_UI_INTERFACE_H | ||||
#define BITCOIN_UI_INTERFACE_H | #define BITCOIN_UI_INTERFACE_H | ||||
#include <boost/signals2/last_value.hpp> | |||||
#include <boost/signals2/signal.hpp> | |||||
#include <cstdint> | #include <cstdint> | ||||
#include <functional> | |||||
#include <memory> | #include <memory> | ||||
#include <string> | #include <string> | ||||
class CWallet; | class CWallet; | ||||
class CBlockIndex; | class CBlockIndex; | ||||
namespace boost { | |||||
namespace signals2 { | |||||
class connection; | |||||
} | |||||
} // namespace boost | |||||
/** General change type (added, updated, removed). */ | /** General change type (added, updated, removed). */ | ||||
enum ChangeType { CT_NEW, CT_UPDATED, CT_DELETED }; | enum ChangeType { CT_NEW, CT_UPDATED, CT_DELETED }; | ||||
/** Signals for UI communication. */ | /** Signals for UI communication. */ | ||||
class CClientUIInterface { | class CClientUIInterface { | ||||
public: | public: | ||||
/** Flags for CClientUIInterface::ThreadSafeMessageBox */ | /** Flags for CClientUIInterface::ThreadSafeMessageBox */ | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | enum MessageBoxFlags { | ||||
SECURE = 0x40000000U, | SECURE = 0x40000000U, | ||||
/** Predefined combinations for certain default usage cases */ | /** Predefined combinations for certain default usage cases */ | ||||
MSG_INFORMATION = ICON_INFORMATION, | MSG_INFORMATION = ICON_INFORMATION, | ||||
MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL), | MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL), | ||||
MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL) | MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL) | ||||
}; | }; | ||||
#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, args...) \ | |||||
rtype signal_name(args); \ | |||||
using signal_name##Sig = rtype(args); \ | |||||
boost::signals2::connection signal_name##_connect( \ | |||||
std::function<signal_name##Sig> fn); \ | |||||
void signal_name##_disconnect(std::function<signal_name##Sig> fn); | |||||
/** Show message box. */ | /** Show message box. */ | ||||
boost::signals2::signal<bool(const std::string &message, | ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, | ||||
const std::string &caption, | const std::string &message, | ||||
unsigned int style), | const std::string &caption, unsigned int style); | ||||
boost::signals2::last_value<bool>> | |||||
ThreadSafeMessageBox; | |||||
/** | /** | ||||
* If possible, ask the user a question. If not, falls back to | * If possible, ask the user a question. If not, falls back to | ||||
* ThreadSafeMessageBox(noninteractive_message, caption, style) and returns | * ThreadSafeMessageBox(noninteractive_message, caption, style) and returns | ||||
* false. | * false. | ||||
*/ | */ | ||||
boost::signals2::signal<bool(const std::string &message, | ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, | ||||
const std::string &message, | |||||
const std::string &noninteractive_message, | const std::string &noninteractive_message, | ||||
const std::string &caption, | const std::string &caption, unsigned int style); | ||||
unsigned int style), | |||||
boost::signals2::last_value<bool>> | |||||
ThreadSafeQuestion; | |||||
/** Progress message during initialization. */ | /** Progress message during initialization. */ | ||||
boost::signals2::signal<void(const std::string &message)> InitMessage; | ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string &message); | ||||
/** Number of network connections changed. */ | /** Number of network connections changed. */ | ||||
boost::signals2::signal<void(int newNumConnections)> | |||||
NotifyNumConnectionsChanged; | ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, | ||||
int newNumConnections); | |||||
/** Network activity state changed. */ | /** Network activity state changed. */ | ||||
boost::signals2::signal<void(bool networkActive)> | ADD_SIGNALS_DECL_WRAPPER(NotifyNetworkActiveChanged, void, | ||||
NotifyNetworkActiveChanged; | bool networkActive); | ||||
/** | /** | ||||
* Status bar alerts changed. | * Status bar alerts changed. | ||||
*/ | */ | ||||
boost::signals2::signal<void()> NotifyAlertChanged; | ADD_SIGNALS_DECL_WRAPPER(NotifyAlertChanged, void, ); | ||||
/** A wallet has been loaded. */ | /** A wallet has been loaded. */ | ||||
boost::signals2::signal<void(std::shared_ptr<CWallet> wallet)> LoadWallet; | ADD_SIGNALS_DECL_WRAPPER(LoadWallet, void, std::shared_ptr<CWallet> wallet); | ||||
/** | /** | ||||
* Show progress e.g. for verifychain. | * Show progress e.g. for verifychain. | ||||
* resume_possible indicates shutting down now will result in the current | * resume_possible indicates shutting down now will result in the current | ||||
* progress action resuming upon restart. | * progress action resuming upon restart. | ||||
*/ | */ | ||||
boost::signals2::signal<void(const std::string &title, int nProgress, | ADD_SIGNALS_DECL_WRAPPER(ShowProgress, void, const std::string &title, | ||||
bool resume_possible)> | int nProgress, bool resume_possible); | ||||
ShowProgress; | |||||
/** New block has been accepted */ | /** New block has been accepted */ | ||||
boost::signals2::signal<void(bool, const CBlockIndex *)> NotifyBlockTip; | ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, bool, const CBlockIndex *); | ||||
/** Best header has changed */ | /** Best header has changed */ | ||||
boost::signals2::signal<void(bool, const CBlockIndex *)> NotifyHeaderTip; | ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, bool, const CBlockIndex *); | ||||
/** Banlist did change. */ | /** Banlist did change. */ | ||||
boost::signals2::signal<void()> BannedListChanged; | ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void); | ||||
}; | }; | ||||
/** Show warning message **/ | /** Show warning message **/ | ||||
void InitWarning(const std::string &str); | void InitWarning(const std::string &str); | ||||
/** Show error message **/ | /** Show error message **/ | ||||
bool InitError(const std::string &str); | bool InitError(const std::string &str); | ||||
std::string AmountHighWarn(const std::string &optname); | std::string AmountHighWarn(const std::string &optname); | ||||
std::string AmountErrMsg(const char *const optname, | std::string AmountErrMsg(const char *const optname, | ||||
const std::string &strValue); | const std::string &strValue); | ||||
extern CClientUIInterface uiInterface; | extern CClientUIInterface uiInterface; | ||||
#endif // BITCOIN_UI_INTERFACE_H | #endif // BITCOIN_UI_INTERFACE_H |