Anoncoin  0.9.4
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) 2013-2015 The Anoncoin Core developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #include "noui.h"
8 
9 #include "ui_interface.h"
10 #include "util.h"
11 
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  std::string strCaption;
18  // Check for usage of predefined caption
19  switch (style) {
21  strCaption += _("Error");
22  break;
24  strCaption += _("Warning");
25  break;
27  strCaption += _("Information");
28  break;
29  default:
30  strCaption += caption; // Use supplied caption (can be empty)
31  }
32 
33  LogPrintf("%s: %s\n", strCaption, message);
34  fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
35  return false;
36 }
37 
38 #ifdef ENABLE_I2PSAM
39 static bool noui_ThreadSafeShowGeneratedI2PAddress(const std::string& caption, const std::string& pub, const std::string& priv, const std::string& b32, const std::string& configFileName)
40 {
41  std::string msg = _("\nIf you want to use a permanent I2P-address you have to set options in the configuration file:\nYour Config file is: ");
42  msg += configFileName;
43 
44  msg += _("\nThis is your Address + private key (save this text in the configuration file and keep it secret):\n");
45  msg += priv;
46 
47  msg += _("\n\nThis is your Address (you can make it public):\n");
48  msg += pub;
49 
50  msg += _("\n\nYour Short base32-address:\n");
51  msg += b32;
52  msg += "\n\n";
53 
54  printf("%s: %s\n", caption.c_str(), msg.c_str());
55  LogPrintf("%s: %s\n", caption.c_str(), msg.c_str());
56  return false;
57 }
58 #endif // ENABLE_I2PSAM
59 
60 static void noui_InitMessage(const std::string &message)
61 {
62  LogPrintf("init message: %s\n", message);
63 }
64 
66 {
67  // Connect anoncoind signal handlers
68  uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
69  uiInterface.InitMessage.connect(noui_InitMessage);
70 #ifdef ENABLE_I2PSAM
71  uiInterface.ThreadSafeShowGeneratedI2PAddress.connect(noui_ThreadSafeShowGeneratedI2PAddress);
72 #endif
73 }
CClientUIInterface uiInterface
Definition: util.cpp:100
void noui_connect()
Definition: noui.cpp:65
#define LogPrintf(...)
Definition: util.h:118
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Definition: ui_interface.h:125
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:81
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
Definition: ui_interface.h:84
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:75