Implement DumpWallet and ImportWallet calls from menu.
[novacoin.git] / src / ui_interface.h
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
7
8 #include <string>
9 #include "util.h" // for int64
10 #include <boost/signals2/signal.hpp>
11 #include <boost/signals2/last_value.hpp>
12
13 class CBasicKeyStore;
14 class CWallet;
15 class uint256;
16
17 /** General change type (added, updated, removed). */
18 enum ChangeType
19 {
20     CT_NEW,
21     CT_UPDATED,
22     CT_DELETED
23 };
24
25 /** Signals for UI communication. */
26 class CClientUIInterface
27 {
28 public:
29     /** Flags for CClientUIInterface::ThreadSafeMessageBox */
30     enum MessageBoxFlags
31     {
32         YES                   = 0x00000002,
33         OK                    = 0x00000004,
34         NO                    = 0x00000008,
35         YES_NO                = (YES|NO),
36         CANCEL                = 0x00000010,
37         APPLY                 = 0x00000020,
38         CLOSE                 = 0x00000040,
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),
52         FORWARD               = 0x00001000,
53         BACKWARD              = 0x00002000,
54         RESET                 = 0x00004000,
55         HELP                  = 0x00008000,
56         MORE                  = 0x00010000,
57         SETUP                 = 0x00020000,
58         // Force blocking, modal message box dialog (not just OS notification)
59         MODAL                 = 0x00040000,
60
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)
65
66     };
67
68     /** Show message box. */
69     boost::signals2::signal<void (const std::string& message, const std::string& caption, int style)> ThreadSafeMessageBox;
70
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;
73
74     /** Handle a URL passed at the command line. */
75     boost::signals2::signal<void (const std::string& strURI)> ThreadSafeHandleURI;
76
77     /** Progress message during initialization. */
78     boost::signals2::signal<void (const std::string &message)> InitMessage;
79
80     /** Initiate client shutdown. */
81     boost::signals2::signal<void ()> QueueShutdown;
82
83     /** Translate a message to the native language of the user. */
84     boost::signals2::signal<std::string (const char* psz)> Translate;
85
86     /** Block chain changed. */
87     boost::signals2::signal<void ()> NotifyBlocksChanged;
88
89     /** Number of network connections changed. */
90     boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
91
92     /**
93      * New, updated or cancelled alert.
94      * @note called with lock cs_mapAlerts held.
95      */
96     boost::signals2::signal<void (const uint256 &hash, ChangeType status)> NotifyAlertChanged;
97 };
98
99 extern CClientUIInterface uiInterface;
100
101 /**
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.
104  */
105 inline std::string _(const char* psz)
106 {
107     boost::optional<std::string> rv = uiInterface.Translate(psz);
108     return rv ? (*rv) : psz;
109 }
110
111 #endif