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 "util.h" // for int64
10 #include <boost/signals2/signal.hpp>
11 #include <boost/signals2/last_value.hpp>
17 /** General change type (added, updated, removed). */
25 /** Signals for UI communication. */
26 class CClientUIInterface
29 /** Flags for CClientUIInterface::ThreadSafeMessageBox */
39 OK_DEFAULT = 0x00000000,
40 YES_DEFAULT = 0x00000000,
41 NO_DEFAULT = 0x00000080,
42 CANCEL_DEFAULT = 0x80000000,
43 ICON_EXCLAMATION = 0x00000100,
44 ICON_HAND = 0x00000200,
45 ICON_WARNING = ICON_EXCLAMATION,
46 ICON_ERROR = ICON_HAND,
47 ICON_QUESTION = 0x00000400,
48 ICON_INFORMATION = 0x00000800,
49 ICON_STOP = ICON_HAND,
50 ICON_ASTERISK = ICON_INFORMATION,
51 ICON_MASK = (0x00000100|0x00000200|0x00000400|0x00000800),
53 BACKWARD = 0x00002000,
58 // Force blocking, modal message box dialog (not just OS notification)
61 /** Predefined combinations for certain default usage cases */
62 MSG_INFORMATION = ICON_INFORMATION,
63 MSG_WARNING = (ICON_WARNING | OK | MODAL),
64 MSG_ERROR = (ICON_ERROR | OK | MODAL)
68 /** Show message box. */
69 boost::signals2::signal<void (const std::string& message, const std::string& caption, int style)> ThreadSafeMessageBox;
71 /** Ask the user whether they want to pay a fee or not. */
72 boost::signals2::signal<bool (int64 nFeeRequired, const std::string& strCaption), boost::signals2::last_value<bool> > ThreadSafeAskFee;
74 /** Handle a URL passed at the command line. */
75 boost::signals2::signal<void (const std::string& strURI)> ThreadSafeHandleURI;
77 /** Progress message during initialization. */
78 boost::signals2::signal<void (const std::string &message)> InitMessage;
80 /** Initiate client shutdown. */
81 boost::signals2::signal<void ()> QueueShutdown;
83 /** Translate a message to the native language of the user. */
84 boost::signals2::signal<std::string (const char* psz)> Translate;
86 /** Block chain changed. */
87 boost::signals2::signal<void ()> NotifyBlocksChanged;
89 /** Number of network connections changed. */
90 boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
93 * New, updated or cancelled alert.
94 * @note called with lock cs_mapAlerts held.
96 boost::signals2::signal<void (const uint256 &hash, ChangeType status)> NotifyAlertChanged;
99 extern CClientUIInterface uiInterface;
102 * Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
103 * If no translation slot is registered, nothing is returned, and simply return the input.
105 inline std::string _(const char* psz)
107 boost::optional<std::string> rv = uiInterface.Translate(psz);
108 return rv ? (*rv) : psz;