aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-05-19 09:35:26 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2012-05-20 10:44:50 +0200
commit239c11d0dd4287e74286c40fb338aea85f4b1996 (patch)
tree4ad01e70d94768977f25a0129255ec3c84635f2e /src
parent0832c0d1669a3504b7ec21d583aecc79f84e8506 (diff)
Make testcases build, prevent windows symbol collision
Diffstat (limited to 'src')
-rw-r--r--src/bitcoinrpc.cpp4
-rw-r--r--src/init.cpp55
-rw-r--r--src/init.h1
-rw-r--r--src/main.cpp2
-rw-r--r--src/makefile.linux-mingw3
-rw-r--r--src/makefile.mingw3
-rw-r--r--src/makefile.osx3
-rw-r--r--src/makefile.unix3
-rw-r--r--src/noui.cpp35
-rw-r--r--src/qt/bitcoin.cpp2
-rw-r--r--src/test/test_bitcoin.cpp4
-rw-r--r--src/ui_interface.h66
-rw-r--r--src/util.cpp2
13 files changed, 103 insertions, 80 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index cc4d85cbbe..6c51bad6db 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -2630,7 +2630,7 @@ void ThreadRPCServer2(void* parg)
strWhatAmI.c_str(),
GetConfigFile().string().c_str(),
EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str()),
- _("Error"), MF_OK | MF_MODAL);
+ _("Error"), CClientUIInterface::OK | CClientUIInterface::MODAL);
uiInterface.QueueShutdown();
return;
}
@@ -2651,7 +2651,7 @@ void ThreadRPCServer2(void* parg)
catch(boost::system::system_error &e)
{
uiInterface.ThreadSafeMessageBox(strprintf(_("An error occured while setting up the RPC port %i for listening: %s"), endpoint.port(), e.what()),
- _("Error"), MF_OK | MF_MODAL);
+ _("Error"), CClientUIInterface::OK | CClientUIInterface::MODAL);
uiInterface.QueueShutdown();
return;
}
diff --git a/src/init.cpp b/src/init.cpp
index 096f289640..e0c0c893aa 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -91,41 +91,6 @@ void HandleSIGTERM(int)
// Start
//
#if !defined(QT_GUI)
-static int noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style)
-{
- printf("%s: %s\n", caption.c_str(), message.c_str());
- fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
- return 4;
-}
-
-static bool noui_ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption)
-{
- return true;
-}
-
-static void noui_QueueShutdown()
-{
- // Without UI, Shutdown can simply be started in a new thread
- CreateThread(Shutdown, NULL);
-}
-
-int main(int argc, char* argv[])
-{
- bool fRet = false;
-
- // Connect bitcoind signal handlers
- uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
- uiInterface.ThreadSafeAskFee.connect(noui_ThreadSafeAskFee);
- uiInterface.QueueShutdown.connect(noui_QueueShutdown);
-
- fRet = AppInit(argc, argv);
-
- if (fRet && fDaemon)
- return 0;
-
- return 1;
-}
-
bool AppInit(int argc, char* argv[])
{
bool fRet = false;
@@ -181,17 +146,33 @@ bool AppInit(int argc, char* argv[])
Shutdown(NULL);
return fRet;
}
+
+extern void noui_connect();
+int main(int argc, char* argv[])
+{
+ bool fRet = false;
+
+ // Connect bitcoind signal handlers
+ noui_connect();
+
+ fRet = AppInit(argc, argv);
+
+ if (fRet && fDaemon)
+ return 0;
+
+ return 1;
+}
#endif
bool static InitError(const std::string &str)
{
- uiInterface.ThreadSafeMessageBox(str, _("Bitcoin"), MF_OK|MF_MODAL);
+ uiInterface.ThreadSafeMessageBox(str, _("Bitcoin"), CClientUIInterface::OK | CClientUIInterface::MODAL);
return false;
}
bool static InitWarning(const std::string &str)
{
- uiInterface.ThreadSafeMessageBox(str, _("Bitcoin"), MF_OK | MF_ICON_EXCLAMATION | MF_MODAL);
+ uiInterface.ThreadSafeMessageBox(str, _("Bitcoin"), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
return true;
}
diff --git a/src/init.h b/src/init.h
index 9a8f98cce9..970527c7ce 100644
--- a/src/init.h
+++ b/src/init.h
@@ -10,7 +10,6 @@
extern CWallet* pwalletMain;
void Shutdown(void* parg);
-bool AppInit(int argc, char* argv[]);
bool AppInit2();
std::string HelpMessage();
diff --git a/src/main.cpp b/src/main.cpp
index 8410b9af4a..e62331debf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1858,7 +1858,7 @@ bool CheckDiskSpace(uint64 nAdditionalBytes)
string strMessage = _("Warning: Disk space is low");
strMiscWarning = strMessage;
printf("*** %s\n", strMessage.c_str());
- uiInterface.ThreadSafeMessageBox(strMessage, "Bitcoin", MF_OK | MF_ICON_EXCLAMATION | MF_MODAL);
+ uiInterface.ThreadSafeMessageBox(strMessage, "Bitcoin", CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
uiInterface.QueueShutdown();
return false;
}
diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw
index 1e9dd687f3..61b38a663e 100644
--- a/src/makefile.linux-mingw
+++ b/src/makefile.linux-mingw
@@ -64,7 +64,8 @@ OBJS= \
obj/sync.o \
obj/util.o \
obj/wallet.o \
- obj/walletdb.o
+ obj/walletdb.o \
+ obj/noui.o
all: bitcoind.exe
diff --git a/src/makefile.mingw b/src/makefile.mingw
index fdd4f4635d..47bf8d5304 100644
--- a/src/makefile.mingw
+++ b/src/makefile.mingw
@@ -61,7 +61,8 @@ OBJS= \
obj/sync.o \
obj/util.o \
obj/wallet.o \
- obj/walletdb.o
+ obj/walletdb.o \
+ obj/noui.o
all: bitcoind.exe
diff --git a/src/makefile.osx b/src/makefile.osx
index d6433a6983..227756f274 100644
--- a/src/makefile.osx
+++ b/src/makefile.osx
@@ -88,7 +88,8 @@ OBJS= \
obj/sync.o \
obj/util.o \
obj/wallet.o \
- obj/walletdb.o
+ obj/walletdb.o \
+ obj/noui.o
ifdef USE_UPNP
DEFS += -DUSE_UPNP=$(USE_UPNP)
diff --git a/src/makefile.unix b/src/makefile.unix
index ec6609f991..04e17866e5 100644
--- a/src/makefile.unix
+++ b/src/makefile.unix
@@ -108,7 +108,8 @@ OBJS= \
obj/sync.o \
obj/util.o \
obj/wallet.o \
- obj/walletdb.o
+ obj/walletdb.o \
+ obj/noui.o
all: bitcoind
diff --git a/src/noui.cpp b/src/noui.cpp
new file mode 100644
index 0000000000..57f53b1c0d
--- /dev/null
+++ b/src/noui.cpp
@@ -0,0 +1,35 @@
+// Copyright (c) 2010 Satoshi Nakamoto
+// Copyright (c) 2009-2012 The Bitcoin developers
+// Distributed under the MIT/X11 software license, see the accompanying
+// file license.txt or http://www.opensource.org/licenses/mit-license.php.
+#include "ui_interface.h"
+#include "init.h"
+#include "bitcoinrpc.h"
+
+#include <string>
+
+static int noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style)
+{
+ printf("%s: %s\n", caption.c_str(), message.c_str());
+ fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
+ return 4;
+}
+
+static bool noui_ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption)
+{
+ return true;
+}
+
+static void noui_QueueShutdown()
+{
+ // Without UI, Shutdown can simply be started in a new thread
+ CreateThread(Shutdown, NULL);
+}
+
+void noui_connect()
+{
+ // Connect bitcoind signal handlers
+ uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
+ uiInterface.ThreadSafeAskFee.connect(noui_ThreadSafeAskFee);
+ uiInterface.QueueShutdown.connect(noui_QueueShutdown);
+}
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index c5592b28df..07bdee0886 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -42,7 +42,7 @@ static void ThreadSafeMessageBox(const std::string& message, const std::string&
// Message from network thread
if(guiref)
{
- bool modal = (style & MF_MODAL);
+ bool modal = (style & CClientUIInterface::MODAL);
// in case of modal message, use blocking connection to wait for user to click OK
QMetaObject::invokeMethod(guiref, "error",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp
index 7ff7545ab4..bf597c9b73 100644
--- a/src/test/test_bitcoin.cpp
+++ b/src/test/test_bitcoin.cpp
@@ -5,11 +5,15 @@
#include "wallet.h"
CWallet* pwalletMain;
+CClientUIInterface uiInterface;
extern bool fPrintToConsole;
+extern void noui_connect();
+
struct TestingSetup {
TestingSetup() {
fPrintToConsole = true; // don't want to write to debug.log file
+ noui_connect();
pwalletMain = new CWallet();
RegisterWallet(pwalletMain);
}
diff --git a/src/ui_interface.h b/src/ui_interface.h
index 954a781005..711a56d5ec 100644
--- a/src/ui_interface.h
+++ b/src/ui_interface.h
@@ -13,39 +13,6 @@ class CBasicKeyStore;
class CWallet;
class uint256;
-/** Flags for CClientUIInterface::ThreadSafeMessageBox */
-enum MessageBoxFlags
-{
- MF_YES = 0x00000002,
- MF_OK = 0x00000004,
- MF_NO = 0x00000008,
- MF_YES_NO = (MF_YES|MF_NO),
- MF_CANCEL = 0x00000010,
- MF_APPLY = 0x00000020,
- MF_CLOSE = 0x00000040,
- MF_OK_DEFAULT = 0x00000000,
- MF_YES_DEFAULT = 0x00000000,
- MF_NO_DEFAULT = 0x00000080,
- MF_CANCEL_DEFAULT = 0x80000000,
- MF_ICON_EXCLAMATION = 0x00000100,
- MF_ICON_HAND = 0x00000200,
- MF_ICON_WARNING = MF_ICON_EXCLAMATION,
- MF_ICON_ERROR = MF_ICON_HAND,
- MF_ICON_QUESTION = 0x00000400,
- MF_ICON_INFORMATION = 0x00000800,
- MF_ICON_STOP = MF_ICON_HAND,
- MF_ICON_ASTERISK = MF_ICON_INFORMATION,
- MF_ICON_MASK = (0x00000100|0x00000200|0x00000400|0x00000800),
- MF_FORWARD = 0x00001000,
- MF_BACKWARD = 0x00002000,
- MF_RESET = 0x00004000,
- MF_HELP = 0x00008000,
- MF_MORE = 0x00010000,
- MF_SETUP = 0x00020000,
-// Force blocking, modal message box dialog (not just OS notification)
- MF_MODAL = 0x00040000
-};
-
/** General change type (added, updated, removed). */
enum ChangeType
{
@@ -58,6 +25,39 @@ enum ChangeType
class CClientUIInterface
{
public:
+ /** Flags for CClientUIInterface::ThreadSafeMessageBox */
+ enum MessageBoxFlags
+ {
+ YES = 0x00000002,
+ OK = 0x00000004,
+ NO = 0x00000008,
+ YES_NO = (YES|NO),
+ CANCEL = 0x00000010,
+ APPLY = 0x00000020,
+ CLOSE = 0x00000040,
+ OK_DEFAULT = 0x00000000,
+ YES_DEFAULT = 0x00000000,
+ NO_DEFAULT = 0x00000080,
+ CANCEL_DEFAULT = 0x80000000,
+ ICON_EXCLAMATION = 0x00000100,
+ ICON_HAND = 0x00000200,
+ ICON_WARNING = ICON_EXCLAMATION,
+ ICON_ERROR = ICON_HAND,
+ ICON_QUESTION = 0x00000400,
+ ICON_INFORMATION = 0x00000800,
+ ICON_STOP = ICON_HAND,
+ ICON_ASTERISK = ICON_INFORMATION,
+ ICON_MASK = (0x00000100|0x00000200|0x00000400|0x00000800),
+ FORWARD = 0x00001000,
+ BACKWARD = 0x00002000,
+ RESET = 0x00004000,
+ HELP = 0x00008000,
+ MORE = 0x00010000,
+ SETUP = 0x00020000,
+ // Force blocking, modal message box dialog (not just OS notification)
+ MODAL = 0x00040000
+ };
+
/** Show message box. */
boost::signals2::signal<void (const std::string& message, const std::string& caption, int style)> ThreadSafeMessageBox;
diff --git a/src/util.cpp b/src/util.cpp
index a9b65ed941..108f33b78e 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -1000,7 +1000,7 @@ void AddTimeData(const CNetAddr& ip, int64 nTime)
string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly.");
strMiscWarning = strMessage;
printf("*** %s\n", strMessage.c_str());
- uiInterface.ThreadSafeMessageBox(strMessage+" ", string("Bitcoin"), MF_OK | MF_ICON_EXCLAMATION);
+ uiInterface.ThreadSafeMessageBox(strMessage+" ", string("Bitcoin"), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION);
}
}
}