aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-06-18 18:42:13 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-07 15:18:35 +0200
commit42c405ad2340c11c769643ab8aee5e6ab118d2a1 (patch)
tree6fa28271ee08848e20815586c7551f7fe9223ba6 /src
parent33c75fd9aaafe12a518900d72685b5360f567638 (diff)
downloadbitcoin-42c405ad2340c11c769643ab8aee5e6ab118d2a1.tar.xz
temp patch for qtui
Diffstat (limited to 'src')
-rw-r--r--src/bitcoinrpc.cpp (renamed from src/rpc.cpp)10
-rw-r--r--src/bitcoinrpc.h (renamed from src/rpc.h)0
-rw-r--r--src/headers.h4
-rw-r--r--src/init.cpp9
-rw-r--r--src/net.h1
-rw-r--r--src/qtui.h48
-rw-r--r--src/util.cpp10
-rw-r--r--src/util.h10
-rw-r--r--src/wallet.cpp4
9 files changed, 72 insertions, 24 deletions
diff --git a/src/rpc.cpp b/src/bitcoinrpc.cpp
index 6f951b7431..0493c6a08f 100644
--- a/src/rpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -13,7 +13,7 @@
#include <boost/iostreams/stream.hpp>
#include <boost/algorithm/string.hpp>
#ifdef USE_SSL
-#include <boost/asio/ssl.hpp>
+#include <boost/asio/ssl.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> SSLStream;
@@ -46,13 +46,13 @@ Object JSONRPCError(int code, const string& message)
}
-void PrintConsole(const char* format, ...)
+void PrintConsole(const std::string &format, ...)
{
char buffer[50000];
int limit = sizeof(buffer);
va_list arg_ptr;
va_start(arg_ptr, format);
- int ret = _vsnprintf(buffer, limit, format, arg_ptr);
+ int ret = _vsnprintf(buffer, limit, format.c_str(), arg_ptr);
va_end(arg_ptr);
if (ret < 0 || ret >= limit)
{
@@ -843,7 +843,7 @@ Value sendmany(const Array& params, bool fHelp)
CScript scriptPubKey;
if (!scriptPubKey.SetBitcoinAddress(strAddress))
throw JSONRPCError(-5, string("Invalid bitcoin address:")+strAddress);
- int64 nAmount = AmountFromValue(s.value_);
+ int64 nAmount = AmountFromValue(s.value_);
totalAmount += nAmount;
vecSend.push_back(make_pair(scriptPubKey, nAmount));
@@ -1161,7 +1161,7 @@ Value listtransactions(const Array& params, bool fHelp)
}
// ret is now newest to oldest
}
-
+
// Make sure we return only last nCount items (sends-to-self might give us an extra):
if (ret.size() > nCount)
{
diff --git a/src/rpc.h b/src/bitcoinrpc.h
index 48a7b8a8a6..48a7b8a8a6 100644
--- a/src/rpc.h
+++ b/src/bitcoinrpc.h
diff --git a/src/headers.h b/src/headers.h
index d1844eb24e..02dba30ae2 100644
--- a/src/headers.h
+++ b/src/headers.h
@@ -98,8 +98,12 @@
#include "uibase.h"
#include "ui.h"
#else
+#ifdef QT_GUI
+#include "qtui.h"
+#else
#include "noui.h"
#endif
+#endif
#ifdef GUI
#include "xpm/addressbook16.xpm"
diff --git a/src/init.cpp b/src/init.cpp
index 635799ccf9..adbfa18c6a 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -3,7 +3,7 @@
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include "headers.h"
#include "db.h"
-#include "rpc.h"
+#include "bitcoinrpc.h"
#include "net.h"
#include "init.h"
#include "strlcpy.h"
@@ -79,7 +79,7 @@ void HandleSIGTERM(int)
//
// Start
//
-#ifndef GUI
+#if !defined(QT_GUI) && !defined(GUI)
int main(int argc, char* argv[])
{
bool fRet = false;
@@ -239,10 +239,9 @@ bool AppInit2(int argc, char* argv[])
fServer = GetBoolArg("-server");
/* force fServer when running without GUI */
-#ifndef GUI
+#if !defined(QT_GUI) && !defined(GUI)
fServer = true;
#endif
-
fPrintToConsole = GetBoolArg("-printtoconsole");
fPrintToDebugger = GetBoolArg("-printtodebugger");
@@ -545,7 +544,7 @@ bool AppInit2(int argc, char* argv[])
SetStartOnSystemStartup(true);
#endif
-#ifndef GUI
+#if !defined(QT_GUI) && !defined(GUI)
while (1)
Sleep(5000);
#endif
diff --git a/src/net.h b/src/net.h
index afa264b723..8f21de8dc9 100644
--- a/src/net.h
+++ b/src/net.h
@@ -6,6 +6,7 @@
#include <deque>
#include <boost/array.hpp>
+#include <boost/foreach.hpp>
#include <openssl/rand.h>
#ifndef __WXMSW__
diff --git a/src/qtui.h b/src/qtui.h
new file mode 100644
index 0000000000..a3b9eb0148
--- /dev/null
+++ b/src/qtui.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2010 Satoshi Nakamoto
+// Distributed under the MIT/X11 software license, see the accompanying
+// file license.txt or http://www.opensource.org/licenses/mit-license.php.
+#ifndef BITCOIN_EXTERNUI_H
+#define BITCOIN_EXTERNUI_H
+
+#include <string>
+#include <boost/function/function0.hpp>
+#include "wallet.h"
+
+typedef void wxWindow;
+#define wxYES 0x00000002
+#define wxOK 0x00000004
+#define wxNO 0x00000008
+#define wxYES_NO (wxYES|wxNO)
+#define wxCANCEL 0x00000010
+#define wxAPPLY 0x00000020
+#define wxCLOSE 0x00000040
+#define wxOK_DEFAULT 0x00000000
+#define wxYES_DEFAULT 0x00000000
+#define wxNO_DEFAULT 0x00000080
+#define wxCANCEL_DEFAULT 0x80000000
+#define wxICON_EXCLAMATION 0x00000100
+#define wxICON_HAND 0x00000200
+#define wxICON_WARNING wxICON_EXCLAMATION
+#define wxICON_ERROR wxICON_HAND
+#define wxICON_QUESTION 0x00000400
+#define wxICON_INFORMATION 0x00000800
+#define wxICON_STOP wxICON_HAND
+#define wxICON_ASTERISK wxICON_INFORMATION
+#define wxICON_MASK (0x00000100|0x00000200|0x00000400|0x00000800)
+#define wxFORWARD 0x00001000
+#define wxBACKWARD 0x00002000
+#define wxRESET 0x00004000
+#define wxHELP 0x00008000
+#define wxMORE 0x00010000
+#define wxSETUP 0x00020000
+
+extern int MyMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
+#define wxMessageBox MyMessageBox
+extern int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
+extern bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent);
+extern void CalledSetStatusBar(const std::string& strText, int nField);
+extern void UIThreadCall(boost::function0<void> fn);
+extern void MainFrameRepaint();
+extern std::string _(const char* psz);
+
+#endif
diff --git a/src/util.cpp b/src/util.cpp
index 479c601ee5..3d89f6a829 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -263,8 +263,7 @@ int my_snprintf(char* buffer, size_t limit, const char* format, ...)
return ret;
}
-
-string strprintf(const char* format, ...)
+string strprintf(const std::string &format, ...)
{
char buffer[50000];
char* p = buffer;
@@ -274,7 +273,7 @@ string strprintf(const char* format, ...)
{
va_list arg_ptr;
va_start(arg_ptr, format);
- ret = _vsnprintf(p, limit, format, arg_ptr);
+ ret = _vsnprintf(p, limit, format.c_str(), arg_ptr);
va_end(arg_ptr);
if (ret >= 0 && ret < limit)
break;
@@ -291,14 +290,13 @@ string strprintf(const char* format, ...)
return str;
}
-
-bool error(const char* format, ...)
+bool error(const std::string &format, ...)
{
char buffer[50000];
int limit = sizeof(buffer);
va_list arg_ptr;
va_start(arg_ptr, format);
- int ret = _vsnprintf(buffer, limit, format, arg_ptr);
+ int ret = _vsnprintf(buffer, limit, format.c_str(), arg_ptr);
va_end(arg_ptr);
if (ret < 0 || ret >= limit)
{
diff --git a/src/util.h b/src/util.h
index e7110570c6..4c1e74b7da 100644
--- a/src/util.h
+++ b/src/util.h
@@ -64,7 +64,7 @@ typedef unsigned long long uint64;
#endif
// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
-#define PAIRTYPE(t1, t2) pair<t1, t2>
+#define PAIRTYPE(t1, t2) std::pair<t1, t2>
// Used to bypass the rule against non-const reference to temporary
// where it makes sense with wrappers such as CFlatData or CTxDB
@@ -139,8 +139,7 @@ inline int myclosesocket(SOCKET& hSocket)
return ret;
}
#define closesocket(s) myclosesocket(s)
-
-#ifndef GUI
+#if !defined(QT_GUI) && !defined(GUI)
inline const char* _(const char* psz)
{
return psz;
@@ -155,7 +154,6 @@ inline const char* _(const char* psz)
-
extern std::map<std::string, std::string> mapArgs;
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug;
@@ -176,8 +174,8 @@ void RandAddSeed();
void RandAddSeedPerfmon();
int OutputDebugStringF(const char* pszFormat, ...);
int my_snprintf(char* buffer, size_t limit, const char* format, ...);
-std::string strprintf(const char* format, ...);
-bool error(const char* format, ...);
+std::string strprintf(const std::string &format, ...);
+bool error(const std::string &format, ...);
void LogException(std::exception* pex, const char* pszThread);
void PrintException(std::exception* pex, const char* pszThread);
void PrintExceptionContinue(std::exception* pex, const char* pszThread);
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 6ef75ef27f..5b88f387c7 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -91,7 +91,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn)
if (fInsertedNew || fUpdated)
if (!wtx.WriteToDisk())
return false;
-
+#ifndef QT_GUI
// If default receiving address gets used, replace it with a new one
CScript scriptDefaultKey;
scriptDefaultKey.SetBitcoinAddress(vchDefaultKey);
@@ -100,7 +100,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn)
if (txout.scriptPubKey == scriptDefaultKey)
SetDefaultKey(GetKeyFromKeyPool());
}
-
+#endif
// Notify UI
vWalletUpdated.push_back(hash);