Bitcoin Core 32.99.0
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-present 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 <node/interface_ui.h>
9#include <util/btcsignals.h>
10#include <util/log.h>
11#include <util/translation.h>
12
13#include <string>
14
19
20void noui_ThreadSafeMessageBox(const bilingual_str& message, unsigned int style)
21{
23 style &= ~CClientUIInterface::SECURE;
24
25 std::string strCaption;
26 switch (style) {
28 strCaption = "Error: ";
29 if (!fSecure) LogError("%s\n", message.original);
30 break;
32 strCaption = "Warning: ";
33 if (!fSecure) LogWarning("%s\n", message.original);
34 break;
36 strCaption = "Information: ";
37 if (!fSecure) LogInfo("%s\n", message.original);
38 break;
39 default:
40 if (!fSecure) LogInfo("%s%s\n", strCaption, message.original);
41 }
42
43 tfm::format(std::cerr, "%s%s\n", strCaption, message.original);
44}
45
46bool noui_ThreadSafeQuestion(const bilingual_str& /* ignored interactive message */, const std::string& message, unsigned int style)
47{
49 return false; // Answer the question with false in the noui context
50}
51
52void noui_InitMessage(const std::string& message)
53{
54 LogInfo("init message: %s", message);
55}
56
63
64void noui_ThreadSafeMessageBoxRedirect(const bilingual_str& message, unsigned int style)
65{
66 LogInfo("%s", message.original);
67}
68
69bool noui_ThreadSafeQuestionRedirect(const bilingual_str& /* ignored interactive message */, const std::string& message, unsigned int style)
70{
71 LogInfo("%s", message);
72 return false;
73}
74
75void noui_InitMessageRedirect(const std::string& message)
76{
77 LogInfo("init message: %s", message);
78}
79
89
btcsignals::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
btcsignals::signal< bool(const bilingual_str &message, const std::string &noninteractive_message, unsigned int style), btcsignals::any_of > ThreadSafeQuestion
If possible, ask the user a question.
btcsignals::signal< void(const bilingual_str &message, unsigned int style)> ThreadSafeMessageBox
Show message box.
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
@ SECURE
Do not print contents of message to debug log.
void disconnect()
If a callback is associated with this connection, prevent it from being called in the future.
Definition btcsignals.h:100
connection connect(Callable &&func) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Definition btcsignals.h:236
CClientUIInterface uiInterface
#define LogWarning(...)
Definition log.h:137
#define LogInfo(...)
Definition log.h:136
#define LogError(...)
Definition log.h:138
void format(std::ostream &out, FormatStringCheck< sizeof...(Args)> fmt, const Args &... args)
Format list of arguments to the stream according to given format string.
btcsignals::connection noui_InitMessageConn
Definition noui.cpp:18
bool noui_ThreadSafeQuestion(const bilingual_str &, const std::string &message, unsigned int style)
Non-GUI handler, which logs and prints questions.
Definition noui.cpp:46
btcsignals::connection noui_ThreadSafeMessageBoxConn
Store connections so we can disconnect them when suppressing output.
Definition noui.cpp:16
btcsignals::connection noui_ThreadSafeQuestionConn
Definition noui.cpp:17
void noui_InitMessageRedirect(const std::string &message)
Definition noui.cpp:75
void noui_ThreadSafeMessageBox(const bilingual_str &message, unsigned int style)
Non-GUI handler, which logs and prints messages.
Definition noui.cpp:20
bool noui_ThreadSafeQuestionRedirect(const bilingual_str &, const std::string &message, unsigned int style)
Definition noui.cpp:69
void noui_test_redirect()
Redirect all bitcoind signal handlers to LogInfo.
Definition noui.cpp:80
void noui_InitMessage(const std::string &message)
Non-GUI handler, which only logs a message.
Definition noui.cpp:52
void noui_reconnect()
Reconnects the regular Non-GUI handlers after having used noui_test_redirect.
Definition noui.cpp:90
void noui_ThreadSafeMessageBoxRedirect(const bilingual_str &message, unsigned int style)
Definition noui.cpp:64
void noui_connect()
Connect all bitcoind signal handlers.
Definition noui.cpp:57
Bilingual messages:
Definition translation.h:24
std::string original
Definition translation.h:25
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition translation.h:82
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82