]>
Commit | Line | Data |
---|---|---|
467c31ea | 1 | // Copyright (c) 2010 Satoshi Nakamoto |
f914f1a7 | 2 | // Copyright (c) 2012 The Bitcoin Core developers |
78253fcb | 3 | // Distributed under the MIT software license, see the accompanying |
3a25a2b9 | 4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
51ed9ec9 | 5 | |
5cccb13d WL |
6 | #ifndef BITCOIN_UI_INTERFACE_H |
7 | #define BITCOIN_UI_INTERFACE_H | |
467c31ea | 8 | |
51ed9ec9 | 9 | #include <stdint.h> |
467c31ea | 10 | #include <string> |
51ed9ec9 | 11 | |
ab1b288f | 12 | #include <boost/signals2/last_value.hpp> |
51ed9ec9 | 13 | #include <boost/signals2/signal.hpp> |
467c31ea | 14 | |
fe4a6550 WL |
15 | class CBasicKeyStore; |
16 | class CWallet; | |
17 | class uint256; | |
18 | ||
ab1b288f | 19 | /** General change type (added, updated, removed). */ |
fe4a6550 WL |
20 | enum ChangeType |
21 | { | |
22 | CT_NEW, | |
23 | CT_UPDATED, | |
3015e0bc | 24 | CT_DELETED |
fe4a6550 WL |
25 | }; |
26 | ||
ab1b288f WL |
27 | /** Signals for UI communication. */ |
28 | class CClientUIInterface | |
29 | { | |
30 | public: | |
239c11d0 WL |
31 | /** Flags for CClientUIInterface::ThreadSafeMessageBox */ |
32 | enum MessageBoxFlags | |
33 | { | |
5350ea41 PK |
34 | ICON_INFORMATION = 0, |
35 | ICON_WARNING = (1U << 0), | |
36 | ICON_ERROR = (1U << 1), | |
37 | /** | |
38 | * Mask of all available icons in CClientUIInterface::MessageBoxFlags | |
39 | * This needs to be updated, when icons are changed there! | |
40 | */ | |
41 | ICON_MASK = (ICON_INFORMATION | ICON_WARNING | ICON_ERROR), | |
42 | ||
43 | /** These values are taken from qmessagebox.h "enum StandardButton" to be directly usable */ | |
44 | BTN_OK = 0x00000400U, // QMessageBox::Ok | |
45 | BTN_YES = 0x00004000U, // QMessageBox::Yes | |
46 | BTN_NO = 0x00010000U, // QMessageBox::No | |
47 | BTN_ABORT = 0x00040000U, // QMessageBox::Abort | |
48 | BTN_RETRY = 0x00080000U, // QMessageBox::Retry | |
49 | BTN_IGNORE = 0x00100000U, // QMessageBox::Ignore | |
50 | BTN_CLOSE = 0x00200000U, // QMessageBox::Close | |
51 | BTN_CANCEL = 0x00400000U, // QMessageBox::Cancel | |
52 | BTN_DISCARD = 0x00800000U, // QMessageBox::Discard | |
53 | BTN_HELP = 0x01000000U, // QMessageBox::Help | |
54 | BTN_APPLY = 0x02000000U, // QMessageBox::Apply | |
55 | BTN_RESET = 0x04000000U, // QMessageBox::Reset | |
56 | /** | |
57 | * Mask of all available buttons in CClientUIInterface::MessageBoxFlags | |
58 | * This needs to be updated, when buttons are changed there! | |
59 | */ | |
60 | BTN_MASK = (BTN_OK | BTN_YES | BTN_NO | BTN_ABORT | BTN_RETRY | BTN_IGNORE | | |
61 | BTN_CLOSE | BTN_CANCEL | BTN_DISCARD | BTN_HELP | BTN_APPLY | BTN_RESET), | |
62 | ||
63 | /** Force blocking, modal message box dialog (not just OS notification) */ | |
64 | MODAL = 0x10000000U, | |
65 | ||
d4746d56 MF |
66 | /** Do not print contents of message to debug log */ |
67 | SECURE = 0x40000000U, | |
68 | ||
5350ea41 | 69 | /** Predefined combinations for certain default usage cases */ |
7f5a1b52 | 70 | MSG_INFORMATION = ICON_INFORMATION, |
5350ea41 PK |
71 | MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL), |
72 | MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL) | |
239c11d0 WL |
73 | }; |
74 | ||
ab1b288f | 75 | /** Show message box. */ |
f7f3a96b | 76 | boost::signals2::signal<bool (const std::string& message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeMessageBox; |
5cccb13d | 77 | |
5d66d0a1 PW |
78 | /** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */ |
79 | boost::signals2::signal<bool (const std::string& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeQuestion; | |
80 | ||
ab1b288f WL |
81 | /** Progress message during initialization. */ |
82 | boost::signals2::signal<void (const std::string &message)> InitMessage; | |
fe4a6550 | 83 | |
ab1b288f WL |
84 | /** Number of network connections changed. */ |
85 | boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged; | |
86 | ||
87 | /** | |
88 | * New, updated or cancelled alert. | |
89 | * @note called with lock cs_mapAlerts held. | |
90 | */ | |
91 | boost::signals2::signal<void (const uint256 &hash, ChangeType status)> NotifyAlertChanged; | |
39278369 CL |
92 | |
93 | /** A wallet has been loaded. */ | |
94 | boost::signals2::signal<void (CWallet* wallet)> LoadWallet; | |
06a91d96 CL |
95 | |
96 | /** Show progress e.g. for verifychain */ | |
97 | boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress; | |
c7b6117d JG |
98 | |
99 | /** New block has been accepted */ | |
100 | boost::signals2::signal<void (const uint256& hash)> NotifyBlockTip; | |
ab1b288f WL |
101 | }; |
102 | ||
103 | extern CClientUIInterface uiInterface; | |
104 | ||
093303a8 | 105 | #endif // BITCOIN_UI_INTERFACE_H |