PIVX Core  5.6.99
P2P Digital Currency
noui.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Copyright (c) 2014-2015 The Dash developers
4 // Copyright (c) 2015-2021 The PIVX Core developers
5 // Distributed under the MIT/X11 software license, see the accompanying
6 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 
8 #include "noui.h"
9 
10 #include "guiinterface.h"
11 #include "util/system.h"
12 
13 #include <cstdio>
14 #include <stdint.h>
15 #include <string>
16 
17 static 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 static void noui_InitMessage(const std::string& message)
45 {
46  LogPrintf("init message: %s\n", message);
47 }
48 
50 {
51  // Connect pivxd signal handlers
52  uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
53  uiInterface.InitMessage.connect(noui_InitMessage);
54 }
Signals for UI communication.
Definition: guiinterface.h:32
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
Definition: guiinterface.h:77
@ SECURE
Do not print contents of message to debug log.
Definition: guiinterface.h:74
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
Definition: guiinterface.h:87
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: guiinterface.h:84
CClientUIInterface uiInterface
Definition: init.cpp:109
void noui_connect()
Definition: noui.cpp:49
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a Optional result.
Definition: system.h:65