2011-06-05 16:03:29 +02:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
2012-06-25 06:28:29 +02:00
|
|
|
// Copyright (c) 2012 The Bitcoin developers
|
2011-06-05 16:03:29 +02:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
2012-05-18 16:02:28 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2012-04-04 13:19:30 +02:00
|
|
|
#ifndef BITCOIN_UI_INTERFACE_H
|
|
|
|
#define BITCOIN_UI_INTERFACE_H
|
2011-06-05 16:03:29 +02:00
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <stdint.h>
|
2011-06-05 16:03:29 +02:00
|
|
|
#include <string>
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
#include <boost/signals2/last_value.hpp>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <boost/signals2/signal.hpp>
|
2011-06-05 16:03:29 +02:00
|
|
|
|
2012-05-05 16:07:14 +02:00
|
|
|
class CBasicKeyStore;
|
|
|
|
class CWallet;
|
|
|
|
class uint256;
|
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
/** General change type (added, updated, removed). */
|
2012-05-05 16:07:14 +02:00
|
|
|
enum ChangeType
|
|
|
|
{
|
|
|
|
CT_NEW,
|
|
|
|
CT_UPDATED,
|
2014-06-27 03:31:05 +02:00
|
|
|
CT_DELETED,
|
|
|
|
CT_GOT_CONFLICT
|
2012-05-05 16:07:14 +02:00
|
|
|
};
|
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
/** Signals for UI communication. */
|
|
|
|
class CClientUIInterface
|
|
|
|
{
|
|
|
|
public:
|
2012-05-19 09:35:26 +02:00
|
|
|
/** Flags for CClientUIInterface::ThreadSafeMessageBox */
|
|
|
|
enum MessageBoxFlags
|
|
|
|
{
|
2012-11-05 08:04:21 +01:00
|
|
|
ICON_INFORMATION = 0,
|
|
|
|
ICON_WARNING = (1U << 0),
|
|
|
|
ICON_ERROR = (1U << 1),
|
|
|
|
/**
|
|
|
|
* Mask of all available icons in CClientUIInterface::MessageBoxFlags
|
|
|
|
* This needs to be updated, when icons are changed there!
|
|
|
|
*/
|
|
|
|
ICON_MASK = (ICON_INFORMATION | ICON_WARNING | ICON_ERROR),
|
|
|
|
|
|
|
|
/** These values are taken from qmessagebox.h "enum StandardButton" to be directly usable */
|
|
|
|
BTN_OK = 0x00000400U, // QMessageBox::Ok
|
|
|
|
BTN_YES = 0x00004000U, // QMessageBox::Yes
|
|
|
|
BTN_NO = 0x00010000U, // QMessageBox::No
|
|
|
|
BTN_ABORT = 0x00040000U, // QMessageBox::Abort
|
|
|
|
BTN_RETRY = 0x00080000U, // QMessageBox::Retry
|
|
|
|
BTN_IGNORE = 0x00100000U, // QMessageBox::Ignore
|
|
|
|
BTN_CLOSE = 0x00200000U, // QMessageBox::Close
|
|
|
|
BTN_CANCEL = 0x00400000U, // QMessageBox::Cancel
|
|
|
|
BTN_DISCARD = 0x00800000U, // QMessageBox::Discard
|
|
|
|
BTN_HELP = 0x01000000U, // QMessageBox::Help
|
|
|
|
BTN_APPLY = 0x02000000U, // QMessageBox::Apply
|
|
|
|
BTN_RESET = 0x04000000U, // QMessageBox::Reset
|
|
|
|
/**
|
|
|
|
* Mask of all available buttons in CClientUIInterface::MessageBoxFlags
|
|
|
|
* This needs to be updated, when buttons are changed there!
|
|
|
|
*/
|
|
|
|
BTN_MASK = (BTN_OK | BTN_YES | BTN_NO | BTN_ABORT | BTN_RETRY | BTN_IGNORE |
|
|
|
|
BTN_CLOSE | BTN_CANCEL | BTN_DISCARD | BTN_HELP | BTN_APPLY | BTN_RESET),
|
|
|
|
|
|
|
|
/** Force blocking, modal message box dialog (not just OS notification) */
|
|
|
|
MODAL = 0x10000000U,
|
2013-12-16 18:13:31 +01:00
|
|
|
/** Don't bring GUI to foreground. Use for messages during initialization */
|
|
|
|
NOSHOWGUI = 0x20000000U,
|
2012-11-05 08:04:21 +01:00
|
|
|
|
|
|
|
/** Predefined combinations for certain default usage cases */
|
2012-12-03 13:35:14 +01:00
|
|
|
MSG_INFORMATION = ICON_INFORMATION,
|
2012-11-05 08:04:21 +01:00
|
|
|
MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL),
|
|
|
|
MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL)
|
2012-05-19 09:35:26 +02:00
|
|
|
};
|
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
/** Show message box. */
|
2013-02-16 17:58:45 +01:00
|
|
|
boost::signals2::signal<bool (const std::string& message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeMessageBox;
|
2012-04-04 13:19:30 +02:00
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
/** Progress message during initialization. */
|
|
|
|
boost::signals2::signal<void (const std::string &message)> InitMessage;
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
/** Translate a message to the native language of the user. */
|
|
|
|
boost::signals2::signal<std::string (const char* psz)> Translate;
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
/** Block chain changed. */
|
|
|
|
boost::signals2::signal<void ()> NotifyBlocksChanged;
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2012-05-06 19:40:58 +02:00
|
|
|
/** Number of network connections changed. */
|
|
|
|
boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New, updated or cancelled alert.
|
|
|
|
* @note called with lock cs_mapAlerts held.
|
|
|
|
*/
|
|
|
|
boost::signals2::signal<void (const uint256 &hash, ChangeType status)> NotifyAlertChanged;
|
2014-03-19 00:26:14 +01:00
|
|
|
|
|
|
|
/** A wallet has been loaded. */
|
|
|
|
boost::signals2::signal<void (CWallet* wallet)> LoadWallet;
|
2014-05-23 18:04:09 +02:00
|
|
|
|
|
|
|
/** Show progress e.g. for verifychain */
|
|
|
|
boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
|
2012-05-06 19:40:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern CClientUIInterface uiInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
|
|
|
|
* If no translation slot is registered, nothing is returned, and simply return the input.
|
2012-05-05 16:07:14 +02:00
|
|
|
*/
|
2012-05-06 19:40:58 +02:00
|
|
|
inline std::string _(const char* psz)
|
|
|
|
{
|
|
|
|
boost::optional<std::string> rv = uiInterface.Translate(psz);
|
|
|
|
return rv ? (*rv) : psz;
|
|
|
|
}
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2011-06-05 16:03:29 +02:00
|
|
|
#endif
|