PRCYCoin  2.0.0.7rc1
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-2018 The PIVX developers
5 // Copyright (c) 2018-2020 The DAPS Project developers
6 // Distributed under the MIT/X11 software license, see the accompanying
7 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
8 
9 #include "noui.h"
10 
11 #include "guiinterface.h"
12 #include "util.h"
13 
14 #include <cstdio>
15 #include <stdint.h>
16 #include <string>
17 
18 static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
19 {
20  bool fSecure = style & CClientUIInterface::SECURE;
21  style &= ~CClientUIInterface::SECURE;
22 
23  std::string strCaption;
24  // Check for usage of predefined caption
25  switch (style) {
27  strCaption += _("Error");
28  break;
30  strCaption += _("Warning");
31  break;
33  strCaption += _("Information");
34  break;
35  default:
36  strCaption += caption; // Use supplied caption (can be empty)
37  }
38 
39  if (!fSecure)
40  LogPrintf("%s: %s\n", strCaption, message);
41  fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
42  return false;
43 }
44 
45 static void noui_InitMessage(const std::string& message)
46 {
47  LogPrintf("init message: %s\n", message);
48 }
49 
51 {
52  // Connect prcycoind signal handlers
53  uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
54  uiInterface.InitMessage.connect(noui_InitMessage);
55 }
CClientUIInterface::MSG_INFORMATION
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
Definition: guiinterface.h:74
CClientUIInterface
Signals for UI communication.
Definition: guiinterface.h:28
uiInterface
CClientUIInterface uiInterface
Definition: init.cpp:101
guiinterface.h
noui_connect
void noui_connect()
Definition: noui.cpp:50
CClientUIInterface::InitMessage
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
Definition: guiinterface.h:83
_
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
Definition: guiinterface.h:119
CClientUIInterface::SECURE
@ SECURE
Do not print contents of message to debug log.
Definition: guiinterface.h:71
CClientUIInterface::ThreadSafeMessageBox
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:80
CClientUIInterface::MSG_WARNING
@ MSG_WARNING
Definition: guiinterface.h:75
LogPrintf
#define LogPrintf(...)
Definition: logging.h:147
CClientUIInterface::MSG_ERROR
@ MSG_ERROR
Definition: guiinterface.h:76
noui.h
util.h