Fabcoin Core  0.16.2
P2P Digital Currency
noui.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2017 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 static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
16 {
17  bool fSecure = style & CClientUIInterface::SECURE;
18  style &= ~CClientUIInterface::SECURE;
19 
20  std::string strCaption;
21  // Check for usage of predefined caption
22  switch (style) {
24  strCaption += _("Error");
25  break;
27  strCaption += _("Warning");
28  break;
30  strCaption += _("Information");
31  break;
32  default:
33  strCaption += caption; // Use supplied caption (can be empty)
34  }
35 
36  if (!fSecure)
37  LogPrintf("%s: %s\n", strCaption, message);
38  fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
39  return false;
40 }
41 
42 static bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
43 {
44  return noui_ThreadSafeMessageBox(message, caption, style);
45 }
46 
47 static void noui_InitMessage(const std::string& message)
48 {
49  LogPrintf("init message: %s\n", message);
50 }
51 
53 {
54  // Connect fabcoind signal handlers
55  uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
56  uiInterface.ThreadSafeQuestion.connect(noui_ThreadSafeQuestion);
57  uiInterface.InitMessage.connect(noui_InitMessage);
58 }
Do not print contents of message to debug log.
Definition: ui_interface.h:66
void noui_connect()
Definition: noui.cpp:52
Signals for UI communication.
Definition: ui_interface.h:27
#define LogPrintf(...)
Definition: util.h:153
boost::signals2::signal< bool(const std::string &message, const std::string &noninteractive_message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeQuestion
If possible, ask the user a question.
Definition: ui_interface.h:78
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
Definition: ui_interface.h:75
CClientUIInterface uiInterface
Definition: ui_interface.cpp:8
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Definition: util.h:71
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
Definition: ui_interface.h:81
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:69