BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
noui.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2018 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 <ui_interface.h>
9 #include <util.h>
10 
11 #include <cstdio>
12 #include <stdint.h>
13 #include <string>
14 
15 #include <boost/signals2/connection.hpp>
16 
17 bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
18 {
19  bool fSecure = style & CClientUIInterface::SECURE;
20  style &= ~CClientUIInterface::SECURE;
21 
22  std::string strCaption;
23  // Check for usage of predefined caption
24  switch (style) {
26  strCaption += _("Error");
27  break;
29  strCaption += _("Warning");
30  break;
32  strCaption += _("Information");
33  break;
34  default:
35  strCaption += caption; // Use supplied caption (can be empty)
36  }
37 
38  if (!fSecure)
39  LogPrintf("%s: %s\n", strCaption, message);
40  fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
41  return false;
42 }
43 
44 bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
45 {
46  return noui_ThreadSafeMessageBox(message, caption, style);
47 }
48 
49 void noui_InitMessage(const std::string& message)
50 {
51  LogPrintf("init message: %s\n", message);
52 }
53 
55 {
56  uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox);
57  uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion);
58  uiInterface.InitMessage_connect(noui_InitMessage);
59 }
bool noui_ThreadSafeQuestion(const std::string &, const std::string &message, const std::string &caption, unsigned int style)
Non-GUI handler, which logs and prints questions.
Definition: noui.cpp:44
Do not print contents of message to debug log.
Definition: ui_interface.h:70
void noui_connect()
Connect all bsha3d signal handlers.
Definition: noui.cpp:54
void noui_InitMessage(const std::string &message)
Non-GUI handler, which only logs a message.
Definition: noui.cpp:49
Signals for UI communication.
Definition: ui_interface.h:31
bool noui_ThreadSafeMessageBox(const std::string &message, const std::string &caption, unsigned int style)
Non-GUI handler, which logs and prints messages.
Definition: noui.cpp:17
CClientUIInterface uiInterface
std::string _(const char *psz)
Translation function.
Definition: util.h:50
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:73