Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
noui.cpp
Go to the documentation of this file.
1// Copyright (c) 2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#include <noui.h>
7
8#include <logging.h>
9#include <node/ui_interface.h>
10#include <util/translation.h>
11
12#include <boost/signals2/connection.hpp>
13#include <boost/signals2/signal.hpp>
14
16boost::signals2::connection noui_ThreadSafeMessageBoxConn;
17boost::signals2::connection noui_ThreadSafeQuestionConn;
18boost::signals2::connection noui_InitMessageConn;
19
21 const std::string &caption, unsigned int style) {
23 style &= ~CClientUIInterface::SECURE;
24
25 std::string strCaption;
26 switch (style) {
28 strCaption = "Error: ";
29 break;
31 strCaption = "Warning: ";
32 break;
34 strCaption = "Information: ";
35 break;
36 default:
37 // Use supplied caption (can be empty)
38 strCaption = caption + ": ";
39 }
40
41 if (!fSecure) {
42 LogPrintf("%s%s\n", strCaption, message.original);
43 }
44 tfm::format(std::cerr, "%s%s\n", strCaption, message.original);
45 return false;
46}
47
49 const bilingual_str & /* ignored interactive message */,
50 const std::string &message, const std::string &caption,
51 unsigned int style) {
53}
54
55void noui_InitMessage(const std::string &message) {
56 LogPrintf("init message: %s\n", message);
57}
58
61 uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
63 uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
65}
66
68 const std::string &caption,
69 unsigned int style) {
70 LogPrintf("%s: %s\n", caption, message.original);
71 return false;
72}
73
75 const bilingual_str & /* ignored interactive message */,
76 const std::string &message, const std::string &caption,
77 unsigned int style) {
78 LogPrintf("%s: %s\n", caption, message);
79 return false;
80}
81
82void noui_InitMessageRedirect(const std::string &message) {
83 LogPrintf("init message: %s\n", message);
84}
85
97
100 noui_ThreadSafeQuestionConn.disconnect();
101 noui_InitMessageConn.disconnect();
102 noui_connect();
103}
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
@ SECURE
Do not print contents of message to debug log.
#define LogPrintf(...)
Definition logging.h:207
void format(std::ostream &out, const char *fmt, const Args &...args)
Format list of arguments to the stream according to given format string.
bool noui_ThreadSafeQuestionRedirect(const bilingual_str &, const std::string &message, const std::string &caption, unsigned int style)
Definition noui.cpp:74
bool noui_ThreadSafeQuestion(const bilingual_str &, const std::string &message, const std::string &caption, unsigned int style)
Non-GUI handler, which logs and prints questions.
Definition noui.cpp:48
void noui_InitMessageRedirect(const std::string &message)
Definition noui.cpp:82
bool noui_ThreadSafeMessageBoxRedirect(const bilingual_str &message, const std::string &caption, unsigned int style)
Definition noui.cpp:67
void noui_test_redirect()
Redirect all bitcoind signal handlers to LogPrintf.
Definition noui.cpp:86
void noui_InitMessage(const std::string &message)
Non-GUI handler, which only logs a message.
Definition noui.cpp:55
void noui_reconnect()
Reconnects the regular Non-GUI handlers after having used noui_test_redirect.
Definition noui.cpp:98
boost::signals2::connection noui_ThreadSafeMessageBoxConn
Store connections so we can disconnect them when suppressing output.
Definition noui.cpp:16
boost::signals2::connection noui_InitMessageConn
Definition noui.cpp:18
boost::signals2::connection noui_ThreadSafeQuestionConn
Definition noui.cpp:17
bool noui_ThreadSafeMessageBox(const bilingual_str &message, const std::string &caption, unsigned int style)
Non-GUI handler, which logs and prints messages.
Definition noui.cpp:20
void noui_connect()
Connect all bitcoind signal handlers.
Definition noui.cpp:59
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
Bilingual messages:
Definition translation.h:17
std::string original
Definition translation.h:18
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition translation.h:36
CClientUIInterface uiInterface