1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2012 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef BITCOIN_UI_INTERFACE_H
6 #define BITCOIN_UI_INTERFACE_H
9 #include <boost/signals2/signal.hpp>
10 #include <boost/signals2/last_value.hpp>
18 /** General change type (added, updated, removed). */
26 /** Signals for UI communication. */
27 class CClientUIInterface
30 /** Flags for CClientUIInterface::ThreadSafeMessageBox */
40 OK_DEFAULT = 0x00000000,
41 YES_DEFAULT = 0x00000000,
42 NO_DEFAULT = 0x00000080,
43 CANCEL_DEFAULT = 0x80000000,
44 ICON_EXCLAMATION = 0x00000100,
45 ICON_HAND = 0x00000200,
46 ICON_WARNING = ICON_EXCLAMATION,
47 ICON_ERROR = ICON_HAND,
48 ICON_QUESTION = 0x00000400,
49 ICON_INFORMATION = 0x00000800,
50 ICON_STOP = ICON_HAND,
51 ICON_ASTERISK = ICON_INFORMATION,
52 ICON_MASK = (0x00000100|0x00000200|0x00000400|0x00000800),
54 BACKWARD = 0x00002000,
59 // Force blocking, modal message box dialog (not just OS notification)
62 /** Predefined combinations for certain default usage cases */
63 MSG_INFORMATION = ICON_INFORMATION,
64 MSG_WARNING = (ICON_WARNING | OK | MODAL),
65 MSG_ERROR = (ICON_ERROR | OK | MODAL)
69 /** Show message box. */
70 boost::signals2::signal<void (const std::string& message, const std::string& caption, int style)> ThreadSafeMessageBox;
72 /** Ask the user whether they want to pay a fee or not. */
73 boost::signals2::signal<bool (int64_t nFeeRequired, const std::string& strCaption), boost::signals2::last_value<bool> > ThreadSafeAskFee;
75 /** Handle a URL passed at the command line. */
76 boost::signals2::signal<void (const std::string& strURI)> ThreadSafeHandleURI;
78 /** Progress message during initialization. */
79 boost::signals2::signal<void (const std::string &message)> InitMessage;
81 /** Initiate client shutdown. */
82 boost::signals2::signal<void ()> QueueShutdown;
84 /** Translate a message to the native language of the user. */
85 boost::signals2::signal<std::string (const char* psz)> Translate;
87 /** Block chain changed. */
88 boost::signals2::signal<void ()> NotifyBlocksChanged;
90 /** Number of network connections changed. */
91 boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
94 * New, updated or cancelled alert.
95 * @note called with lock cs_mapAlerts held.
97 boost::signals2::signal<void (const uint256 &hash, ChangeType status)> NotifyAlertChanged;
100 extern CClientUIInterface uiInterface;
103 * Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
104 * If no translation slot is registered, nothing is returned, and simply return the input.
106 inline std::string _(const char* psz)
108 boost::optional<std::string> rv = uiInterface.Translate(psz);
109 return rv ? (*rv) : psz;