Browse Source

Make testcases build, prevent windows symbol collision

pull/1/head
Wladimir J. van der Laan 10 years ago
parent
commit
239c11d0dd
  1. 4
      src/bitcoinrpc.cpp
  2. 55
      src/init.cpp
  3. 1
      src/init.h
  4. 2
      src/main.cpp
  5. 3
      src/makefile.linux-mingw
  6. 3
      src/makefile.mingw
  7. 3
      src/makefile.osx
  8. 3
      src/makefile.unix
  9. 35
      src/noui.cpp
  10. 2
      src/qt/bitcoin.cpp
  11. 4
      src/test/test_bitcoin.cpp
  12. 66
      src/ui_interface.h
  13. 2
      src/util.cpp

4
src/bitcoinrpc.cpp

@ -2630,7 +2630,7 @@ void ThreadRPCServer2(void* parg) @@ -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) @@ -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;
}

55
src/init.cpp

@ -91,41 +91,6 @@ void HandleSIGTERM(int) @@ -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[]) @@ -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;
}

1
src/init.h

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
extern CWallet* pwalletMain;
void Shutdown(void* parg);
bool AppInit(int argc, char* argv[]);
bool AppInit2();
std::string HelpMessage();

2
src/main.cpp

@ -1858,7 +1858,7 @@ bool CheckDiskSpace(uint64 nAdditionalBytes) @@ -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;
}

3
src/makefile.linux-mingw

@ -64,7 +64,8 @@ OBJS= \ @@ -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

3
src/makefile.mingw

@ -61,7 +61,8 @@ OBJS= \ @@ -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

3
src/makefile.osx vendored

@ -88,7 +88,8 @@ OBJS= \ @@ -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)

3
src/makefile.unix

@ -108,7 +108,8 @@ OBJS= \ @@ -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

35
src/noui.cpp

@ -0,0 +1,35 @@ @@ -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);
}

2
src/qt/bitcoin.cpp

@ -42,7 +42,7 @@ static void ThreadSafeMessageBox(const std::string& message, const std::string& @@ -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,

4
src/test/test_bitcoin.cpp

@ -5,11 +5,15 @@ @@ -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);
}

66
src/ui_interface.h

@ -13,39 +13,6 @@ class CBasicKeyStore; @@ -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 @@ -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;

2
src/util.cpp

@ -1000,7 +1000,7 @@ void AddTimeData(const CNetAddr& ip, int64 nTime) @@ -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);
}
}
}

Loading…
Cancel
Save