2012-05-19 09:35:26 +02:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
2014-12-17 02:47:57 +01:00
|
|
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 16:02:28 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2012-11-05 08:04:21 +01:00
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "noui.h"
|
|
|
|
|
2012-05-19 09:35:26 +02:00
|
|
|
#include "ui_interface.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "util.h"
|
2012-05-19 09:35:26 +02:00
|
|
|
|
Split up util.cpp/h
Split up util.cpp/h into:
- string utilities (hex, base32, base64): no internal dependencies, no dependency on boost (apart from foreach)
- money utilities (parsesmoney, formatmoney)
- time utilities (gettime*, sleep, format date):
- and the rest (logging, argument parsing, config file parsing)
The latter is basically the environment and OS handling,
and is stripped of all utility functions, so we may want to
rename it to something else than util.cpp/h for clarity (Matt suggested
osinterface).
Breaks dependency of sha256.cpp on all the things pulled in by util.
2014-08-21 16:11:09 +02:00
|
|
|
#include <cstdio>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <stdint.h>
|
2012-05-19 09:35:26 +02:00
|
|
|
#include <string>
|
|
|
|
|
2013-02-16 17:58:45 +01:00
|
|
|
static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
|
2012-05-19 09:35:26 +02:00
|
|
|
{
|
2014-10-17 01:16:29 +02:00
|
|
|
bool fSecure = style & CClientUIInterface::SECURE;
|
|
|
|
style &= ~CClientUIInterface::SECURE;
|
|
|
|
|
2012-11-05 08:04:21 +01:00
|
|
|
std::string strCaption;
|
|
|
|
// Check for usage of predefined caption
|
|
|
|
switch (style) {
|
|
|
|
case CClientUIInterface::MSG_ERROR:
|
|
|
|
strCaption += _("Error");
|
|
|
|
break;
|
|
|
|
case CClientUIInterface::MSG_WARNING:
|
|
|
|
strCaption += _("Warning");
|
|
|
|
break;
|
|
|
|
case CClientUIInterface::MSG_INFORMATION:
|
|
|
|
strCaption += _("Information");
|
|
|
|
break;
|
|
|
|
default:
|
2013-01-02 15:09:24 +01:00
|
|
|
strCaption += caption; // Use supplied caption (can be empty)
|
2012-11-05 08:04:21 +01:00
|
|
|
}
|
|
|
|
|
2014-10-17 01:16:29 +02:00
|
|
|
if (!fSecure)
|
|
|
|
LogPrintf("%s: %s\n", strCaption, message);
|
2012-11-05 08:04:21 +01:00
|
|
|
fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
|
2013-02-16 17:58:45 +01:00
|
|
|
return false;
|
2012-05-19 09:35:26 +02:00
|
|
|
}
|
|
|
|
|
2014-09-19 19:21:46 +02:00
|
|
|
static void noui_InitMessage(const std::string& message)
|
2013-01-11 22:57:22 +01:00
|
|
|
{
|
2014-01-16 16:15:27 +01:00
|
|
|
LogPrintf("init message: %s\n", message);
|
2013-01-11 22:57:22 +01:00
|
|
|
}
|
|
|
|
|
2012-05-19 09:35:26 +02:00
|
|
|
void noui_connect()
|
|
|
|
{
|
|
|
|
// Connect bitcoind signal handlers
|
|
|
|
uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
|
2013-01-11 22:57:22 +01:00
|
|
|
uiInterface.InitMessage.connect(noui_InitMessage);
|
2012-05-19 09:35:26 +02:00
|
|
|
}
|