What changed
Bitcoin v0.2.0 → v0.2.2
Release commit message: all builds are now with wxWidgets-2.9.0, we are now using UTF-8, added support for language translation file locale/<lang>/LC_MESSAGES/bitcoin.mo -- version 0.2.2
Full source: v0.2.0. Previous diff: v0.1.5 → v0.2.0. Next: v0.2.2 → v0.2.4.
- bignum.h modified · +34 −7
- build-msw.txt modified · +36 −11
- build-unix.txt modified · +22 −13
- db.cpp modified · +10 −30
- db.h modified · +8 −45
- headers.h modified · +12 −8
- irc.cpp modified · +2 −3
- irc.h modified · +3 −3
- license.txt modified · +1 −1
- main.cpp modified · +178 −97
- main.h modified · +33 −4
- makefile removed · +0 −81
- makefile.mingw added · +86 −0
- makefile.unix modified · +16 −27
- makefile.vc modified · +37 −30
- market.cpp removed · +0 −264
- market.h removed · +0 −182
- net.cpp modified · +12 −30
- net.h modified · +4 −9
- rpc.cpp added · +642 −1
- rpc.h added · +6 −0
- script.cpp modified · +15 −8
- script.h modified · +42 −2
- serialize.h modified · +13 −9
- ui.cpp modified · +469 −1319
- ui.h modified · +11 −147
- uibase.cpp modified · +105 −893
- uibase.h modified · +17 −290
- uint256.h modified · +9 −5
- util.cpp modified · +80 −4
- util.h modified · +30 −91
bignum.h (modified)
1--- v0.2.0/bignum.h2+++ v0.2.2/bignum.h3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -62,12 +62,6 @@10 BN_clear_free(this);11 throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");12 }13- }14-15- explicit CBigNum(const std::string& str)16- {17- BN_init(this);18- SetHex(str);19 }20 21 CBigNum& operator=(const CBigNum& b)22@@ -309,6 +303,37 @@23 *this = 0 - *this;24 }25 26+ std::string ToString(int nBase=10) const27+ {28+ CAutoBN_CTX pctx;29+ CBigNum bnBase = nBase;30+ CBigNum bn0 = 0;31+ string str;32+ CBigNum bn = *this;33+ BN_set_negative(&bn, false);34+ CBigNum dv;35+ CBigNum rem;36+ if (BN_cmp(&bn, &bn0) == 0)37+ return "0";38+ while (BN_cmp(&bn, &bn0) > 0)39+ {40+ if (!BN_div(&dv, &rem, &bn, &bnBase, pctx))41+ throw bignum_error("CBigNum::ToString() : BN_div failed");42+ bn = dv;43+ unsigned int c = rem.getulong();44+ str += "0123456789abcdef"[c];45+ }46+ if (BN_is_negative(this))47+ str += "-";48+ reverse(str.begin(), str.end());49+ return str;50+ }51+52+ std::string GetHex() const53+ {54+ return ToString(16);55+ }56+57 unsigned int GetSerializeSize(int nType=0, int nVersion=VERSION) const58 {59 return ::GetSerializeSize(getvch(), nType, nVersion);60@@ -376,6 +401,7 @@61 62 CBigNum& operator>>=(unsigned int shift)63 {64+ // Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number65 if (!BN_rshift(this, this, shift))66 throw bignum_error("CBigNum:operator>>= : BN_rshift failed");67 return *this;68@@ -485,6 +511,7 @@69 inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)70 {71 CBigNum r;72+ // Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number73 if (!BN_rshift(&r, &a, shift))74 throw bignum_error("CBigNum:operator>> : BN_rshift failed");75 return r;
build-msw.txt (modified)
1--- v0.2.0/build-msw.txt2+++ v0.2.2/build-msw.txt3@@ -1,6 +1,6 @@4 Bitcoin v0.2.0 BETA5 6-Copyright (c) 2009 Satoshi Nakamoto7+Copyright (c) 2009-2010 Satoshi Nakamoto8 Distributed under the MIT/X11 software license, see the accompanying9 file license.txt or http://www.opensource.org/licenses/mit-license.php.10 This product includes software developed by the OpenSSL Project for use in11@@ -13,20 +13,27 @@12 13 Compilers Supported14 -------------------15-MinGW GCC16-Microsoft Visual C++ 6.0 SP617+MinGW GCC (recommended)18+19+MSVC 6.0 SP6: You'll need Boost version 1.34 because they dropped support20+for MSVC 6.0 after that. However, they didn't add Asio until 1.35.21+You should still be able to build with MSVC 6.0 by adding Asio to 1.34 by22+unpacking boost_asio_*.zip into the boost directory:23+http://sourceforge.net/projects/asio/files/asio24+25+MSVC 8.0 (2005) SP1 has been tested. Note: MSVC 7.0 and up have a habit of26+linking to runtime DLLs that are not installed on XP by default.27 28 29 Dependencies30 ------------31 Libraries you need to download separately and build:32 33- default path download34-wxWidgets \wxwidgets http://www.wxwidgets.org/downloads/35- or prebuilt: http://wxpack.sourceforge.net36-OpenSSL \openssl http://www.openssl.org/source/37-Berkeley DB \db http://www.oracle.com/technology/software/products/berkeley-db/index.html38-Boost \boost http://www.boost.org/users/download/39+ default path download40+wxWidgets-2.9 \wxwidgets http://www.wxwidgets.org/downloads/41+OpenSSL \openssl http://www.openssl.org/source/42+Berkeley DB \db http://www.oracle.com/technology/software/products/berkeley-db/index.html43+Boost \boost http://www.boost.org/users/download/44 45 Their licenses:46 wxWidgets LGPL 2.1 with very liberal exceptions47@@ -36,10 +43,10 @@48 49 Versions used in this release:50 MinGW GCC 3.4.551-wxWidgets 2.8.952+wxWidgets 2.9.053 OpenSSL 0.9.8k54 Berkeley DB 4.7.25.NC55-Boost 1.34.156+Boost 1.42.157 58 59 Notes60@@ -50,6 +57,14 @@61 62 The release is built with GCC and then "strip bitcoin.exe" to strip the debug63 symbols, which reduces the executable size by about 90%.64+65+66+wxWidgets67+---------68+cd \wxwidgets\build\msw69+make -f makefile.gcc70+ or71+nmake -f makefile.vc72 73 74 OpenSSL75@@ -90,3 +105,13 @@76 sh ../dist/configure --enable-mingw --enable-cxx77 make78 79+80+Boost81+-----82+download bjam.exe from83+http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=7294184+cd \boost85+bjam toolset=gcc --build-type=complete stage86+ or87+bjam toolset=msvc --build-type=complete stage88+
build-unix.txt (modified)
1--- v0.2.0/build-unix.txt2+++ v0.2.2/build-unix.txt3@@ -1,6 +1,6 @@4 Bitcoin v0.2.0 BETA5 6-Copyright (c) 2009 Satoshi Nakamoto7+Copyright (c) 2009-2010 Satoshi Nakamoto8 Distributed under the MIT/X11 software license, see the accompanying9 file license.txt or http://www.opensource.org/licenses/mit-license.php.10 This product includes software developed by the OpenSSL Project for use in11@@ -13,15 +13,22 @@12 13 Dependencies14 ------------15-apt-get install build-essential16-apt-get install libgtk2.0-dev17-apt-get install libssl-dev18-apt-get install libdb4.7-dev19-apt-get install libdb4.7++-dev20-apt-get install libboost-dev21+sudo apt-get install build-essential22+sudo apt-get install libgtk2.0-dev23+sudo apt-get install libssl-dev24+sudo apt-get install libdb4.7-dev25+sudo apt-get install libdb4.7++-dev26+sudo apt-get install libboost-dev27+28+We're now using wxWidgets 2.9, which uses UTF-8.29+30+There isn't currently a debian package of wxWidgets we can use. The 2.831+packages for Karmic are UTF-16 unicode and won't work for us, and we've had32+trouble building 2.8 on 64-bit.33 34 You need to download wxWidgets from http://www.wxwidgets.org/downloads/35-and build it yourself.36+and build it yourself. See the build instructions and configure parameters37+below.38 39 Licenses of statically linked libraries:40 wxWidgets LGPL 2.1 with very liberal exceptions41@@ -31,9 +38,9 @@42 Versions used in this release:43 GCC 4.3.344 OpenSSL 0.9.8k45-wxWidgets 2.8.946+wxWidgets 2.9.047 Berkeley DB 4.7.25.NC48-Boost 1.40.049+Boost 1.38.050 51 52 Notes53@@ -48,12 +55,14 @@54 55 wxWidgets56 ---------57-cd /usr/local/wxWidgets-2.8.958+cd /usr/local59+tar -xzvf wxWidgets-2.9.0.tar.gz60+cd /usr/local/wxWidgets-2.9.061 mkdir buildgtk62 cd buildgtk63 ../configure --with-gtk --enable-debug --disable-shared --enable-monolithic64 make65-su66+sudo su67 make install68 ldconfig69 70@@ -61,7 +70,7 @@71 Boost72 -----73 If you want to build Boost yourself,74-cd /usr/local/boost_1_40_075+cd /usr/local/boost_1_42_076 su77 ./bootstrap.sh78 ./bjam install
db.cpp (modified)
1--- v0.2.0/db.cpp2+++ v0.2.2/db.cpp3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -134,8 +134,6 @@10 11 CRITICAL_BLOCK(cs_db)12 --mapFileUseCount[strFile];13-14- RandAddSeed();15 }16 17 void CloseDb(const string& strFile)18@@ -456,7 +454,7 @@19 CAddress addr(psz, NODE_NETWORK);20 addr.nTime = 0; // so it won't relay unless successfully connected21 if (addr.IsValid())22- AddAddress(*this, addr);23+ AddAddress(addr);24 }25 }26 catch (...) { }27@@ -510,27 +508,6 @@28 29 30 //31-// CReviewDB32-//33-34-bool CReviewDB::ReadReviews(uint256 hash, vector<CReview>& vReviews)35-{36- vReviews.size(); // msvc workaround, just need to do anything with vReviews37- return Read(make_pair(string("reviews"), hash), vReviews);38-}39-40-bool CReviewDB::WriteReviews(uint256 hash, const vector<CReview>& vReviews)41-{42- return Write(make_pair(string("reviews"), hash), vReviews);43-}44-45-46-47-48-49-50-51-//52 // CWalletDB53 //54 55@@ -595,14 +572,17 @@56 // wtx.hashBlock.ToString().substr(0,16).c_str(),57 // wtx.mapValue["message"].c_str());58 }59- else if (strType == "key")60+ else if (strType == "key" || strType == "wkey")61 {62 vector<unsigned char> vchPubKey;63 ssKey >> vchPubKey;64- CPrivKey vchPrivKey;65- ssValue >> vchPrivKey;66-67- mapKeys[vchPubKey] = vchPrivKey;68+ CWalletKey wkey;69+ if (strType == "key")70+ ssValue >> wkey.vchPrivKey;71+ else72+ ssValue >> wkey;73+74+ mapKeys[vchPubKey] = wkey.vchPrivKey;75 mapPubKeys[Hash160(vchPubKey)] = vchPubKey;76 }77 else if (strType == "defaultkey")
db.h (modified)
1--- v0.2.0/db.h2+++ v0.2.2/db.h3@@ -1,8 +1,7 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9-#include <db_cxx.h>10 class CTransaction;11 class CTxIndex;12 class CDiskBlockIndex;13@@ -14,6 +13,7 @@14 class CWalletTx;15 16 extern map<string, string> mapAddressBook;17+extern CCriticalSection cs_mapAddressBook;18 extern bool fClient;19 20 21@@ -285,45 +285,6 @@22 23 24 25-class CReviewDB : public CDB26-{27-public:28- CReviewDB(const char* pszMode="r+") : CDB("reviews.dat", pszMode) { }29-private:30- CReviewDB(const CReviewDB&);31- void operator=(const CReviewDB&);32-public:33- bool ReadUser(uint256 hash, CUser& user)34- {35- return Read(make_pair(string("user"), hash), user);36- }37-38- bool WriteUser(uint256 hash, const CUser& user)39- {40- return Write(make_pair(string("user"), hash), user);41- }42-43- bool ReadReviews(uint256 hash, vector<CReview>& vReviews);44- bool WriteReviews(uint256 hash, const vector<CReview>& vReviews);45-};46-47-48-49-50-51-class CMarketDB : public CDB52-{53-public:54- CMarketDB(const char* pszMode="r+") : CDB("market.dat", pszMode) { }55-private:56- CMarketDB(const CMarketDB&);57- void operator=(const CMarketDB&);58-};59-60-61-62-63-64 class CAddrDB : public CDB65 {66 public:67@@ -359,15 +320,17 @@68 69 bool WriteName(const string& strAddress, const string& strName)70 {71- nWalletDBUpdated++;72- mapAddressBook[strAddress] = strName;73+ CRITICAL_BLOCK(cs_mapAddressBook)74+ mapAddressBook[strAddress] = strName;75+ nWalletDBUpdated++;76 return Write(make_pair(string("name"), strAddress), strName);77 }78 79 bool EraseName(const string& strAddress)80 {81- nWalletDBUpdated++;82- mapAddressBook.erase(strAddress);83+ CRITICAL_BLOCK(cs_mapAddressBook)84+ mapAddressBook.erase(strAddress);85+ nWalletDBUpdated++;86 return Erase(make_pair(string("name"), strAddress));87 }88
headers.h (modified)
1--- v0.2.0/headers.h2+++ v0.2.2/headers.h3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -29,15 +29,15 @@10 #include <openssl/rand.h>11 #include <openssl/sha.h>12 #include <openssl/ripemd.h>13+#include <db_cxx.h>14 #include <stdio.h>15 #include <stdlib.h>16 #include <math.h>17 #include <limits.h>18 #include <float.h>19 #include <assert.h>20-#include <malloc.h>21 #include <memory>22-#define BOUNDSCHECK 123+#include <iostream>24 #include <sstream>25 #include <string>26 #include <vector>27@@ -55,6 +55,8 @@28 #include <boost/array.hpp>29 #include <boost/bind.hpp>30 #include <boost/function.hpp>31+#include <boost/filesystem.hpp>32+#include <boost/algorithm/string.hpp>33 34 #ifdef __WXMSW__35 #include <windows.h>36@@ -64,6 +66,7 @@37 #include <shlwapi.h>38 #include <io.h>39 #include <process.h>40+#include <malloc.h>41 #else42 #include <sys/time.h>43 #include <sys/resource.h>44@@ -74,15 +77,15 @@45 #include <errno.h>46 #include <net/if.h>47 #include <ifaddrs.h>48-#include <boost/filesystem.hpp>49-#include <boost/algorithm/string.hpp>50 #endif51+#ifdef __BSD__52+#include <netinet/in.h>53+#endif54+55 56 #pragma hdrstop57 using namespace std;58 using namespace boost;59-60-61 62 #include "strlcpy.h"63 #include "serialize.h"64@@ -96,7 +99,7 @@65 #include "net.h"66 #include "irc.h"67 #include "main.h"68-#include "market.h"69+#include "rpc.h"70 #include "uibase.h"71 #include "ui.h"72 73@@ -110,4 +113,5 @@74 #include "xpm/send16.xpm"75 #include "xpm/send16noshadow.xpm"76 #include "xpm/send20.xpm"77+#include "xpm/about.xpm"78
irc.cpp (modified)
1--- v0.2.0/irc.cpp2+++ v0.2.2/irc.cpp3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -265,8 +265,7 @@10 if (DecodeAddress(pszName, addr))11 {12 addr.nTime = GetAdjustedTime() - 51 * 60;13- CAddrDB addrdb;14- if (AddAddress(addrdb, addr))15+ if (AddAddress(addr))16 printf("IRC got new address\n");17 nGotIRCAddresses++;18 }
irc.h (modified)
1--- v0.2.0/irc.h2+++ v0.2.2/irc.h3@@ -1,9 +1,9 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9-extern bool RecvLine(SOCKET hSocket, string& strLine);10-extern void ThreadIRCSeed(void* parg);11+bool RecvLine(SOCKET hSocket, string& strLine);12+void ThreadIRCSeed(void* parg);13 14 extern int nGotIRCAddresses;15
license.txt (modified)
1--- v0.2.0/license.txt2+++ v0.2.2/license.txt3@@ -1,4 +1,4 @@4-Copyright (c) 2009 Satoshi Nakamoto5+Copyright (c) 2009-2010 Satoshi Nakamoto6 7 Permission is hereby granted, free of charge, to any person obtaining a copy8 of this software and associated documentation files (the "Software"), to deal
main.cpp (modified)
1--- v0.2.0/main.cpp2+++ v0.2.2/main.cpp3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -26,6 +26,7 @@10 int nBestHeight = -1;11 uint256 hashBestChain = 0;12 CBlockIndex* pindexBest = NULL;13+int64 nTimeBestReceived = 0;14 15 map<uint256, CBlock*> mapOrphanBlocks;16 multimap<uint256, CBlock*> mapOrphanBlocksByPrev;17@@ -44,6 +45,9 @@18 19 map<uint256, int> mapRequestCount;20 CCriticalSection cs_mapRequestCount;21+22+map<string, string> mapAddressBook;23+CCriticalSection cs_mapAddressBook;24 25 // Settings26 int fGenerateBitcoins = false;27@@ -168,6 +172,27 @@28 return true;29 }30 31+void WalletUpdateSpent(const COutPoint& prevout)32+{33+ // Anytime a signature is successfully verified, it's proof the outpoint is spent.34+ // Update the wallet spent flag if it doesn't know due to wallet.dat being35+ // restored from backup or the user making copies of wallet.dat.36+ CRITICAL_BLOCK(cs_mapWallet)37+ {38+ map<uint256, CWalletTx>::iterator mi = mapWallet.find(prevout.hash);39+ if (mi != mapWallet.end())40+ {41+ CWalletTx& wtx = (*mi).second;42+ if (!wtx.fSpent && wtx.vout[prevout.n].IsMine())43+ {44+ printf("WalletUpdateSpent found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());45+ wtx.fSpent = true;46+ wtx.WriteToDisk();47+ vWalletUpdated.push_back(prevout.hash);48+ }49+ }50+ }51+}52 53 54 55@@ -552,7 +577,7 @@56 57 58 59-int CMerkleTx::GetDepthInMainChain() const60+int CMerkleTx::GetDepthInMainChain(int& nHeightRet) const61 {62 if (hashBlock == 0 || nIndex == -1)63 return 0;64@@ -573,6 +598,7 @@65 fMerkleVerified = true;66 }67 68+ nHeightRet = pindex->nHeight;69 return pindexBest->nHeight - pindex->nHeight + 1;70 }71 72@@ -622,15 +648,44 @@73 74 void ReacceptWalletTransactions()75 {76- // Reaccept any txes of ours that aren't already in a block77 CTxDB txdb("r");78 CRITICAL_BLOCK(cs_mapWallet)79 {80 foreach(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)81 {82 CWalletTx& wtx = item.second;83- if (!wtx.IsCoinBase() && !txdb.ContainsTx(wtx.GetHash()))84- wtx.AcceptWalletTransaction(txdb, false);85+ if (wtx.fSpent && wtx.IsCoinBase())86+ continue;87+88+ CTxIndex txindex;89+ if (txdb.ReadTxIndex(wtx.GetHash(), txindex))90+ {91+ // Update fSpent if a tx got spent somewhere else by a copy of wallet.dat92+ if (!wtx.fSpent)93+ {94+ if (txindex.vSpent.size() != wtx.vout.size())95+ {96+ printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %d != wtx.vout.size() %d\n", txindex.vSpent.size(), wtx.vout.size());97+ continue;98+ }99+ for (int i = 0; i < txindex.vSpent.size(); i++)100+ {101+ if (!txindex.vSpent[i].IsNull() && wtx.vout[i].IsMine())102+ {103+ printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());104+ wtx.fSpent = true;105+ wtx.WriteToDisk();106+ break;107+ }108+ }109+ }110+ }111+ else112+ {113+ // Reaccept any txes of ours that aren't already in a block114+ if (!wtx.IsCoinBase())115+ wtx.AcceptWalletTransaction(txdb, false);116+ }117 }118 }119 }120@@ -658,15 +713,20 @@121 }122 }123 124-void RelayWalletTransactions()125-{126- static int64 nLastTime;127- if (GetTime() - nLastTime < 10 * 60)128+void ResendWalletTransactions()129+{130+ // Do this infrequently and randomly to avoid giving away131+ // that these are our transactions.132+ static int64 nNextTime;133+ if (GetTime() < nNextTime)134 return;135- nLastTime = GetTime();136+ bool fFirst = (nNextTime == 0);137+ nNextTime = GetTime() + GetRand(120 * 60);138+ if (fFirst)139+ return;140 141 // Rebroadcast any of our txes that aren't in a block yet142- printf("RelayWalletTransactions()\n");143+ printf("ResendWalletTransactions()\n");144 CTxDB txdb("r");145 CRITICAL_BLOCK(cs_mapWallet)146 {147@@ -675,7 +735,10 @@148 foreach(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)149 {150 CWalletTx& wtx = item.second;151- mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));152+ // Don't rebroadcast until it's had plenty of time that153+ // it should have gotten in already by now.154+ if (nTimeBestReceived - wtx.nTimeReceived > 60 * 60)155+ mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));156 }157 foreach(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)158 {159@@ -1169,10 +1232,11 @@160 }161 }162 163- // New best link164+ // New best block165 hashBestChain = hash;166 pindexBest = pindexNew;167 nBestHeight = pindexBest->nHeight;168+ nTimeBestReceived = GetTime();169 nTransactionsUpdated++;170 printf("AddToBlockIndex: new best=%s height=%d\n", hashBestChain.ToString().substr(0,16).c_str(), nBestHeight);171 }172@@ -1182,9 +1246,6 @@173 174 if (pindexNew == pindexBest)175 {176- // Relay wallet transactions that haven't gotten in yet177- RelayWalletTransactions();178-179 // Notify UI to display prev block's coinbase if it was ours180 static uint256 hashPrevBestCoinBase;181 CRITICAL_BLOCK(cs_mapWallet)182@@ -1399,27 +1460,13 @@183 184 bool CheckDiskSpace(int64 nAdditionalBytes)185 {186-#ifdef __WXMSW__187- uint64 nFreeBytesAvailable = 0; // bytes available to caller188- uint64 nTotalNumberOfBytes = 0; // bytes on disk189- uint64 nTotalNumberOfFreeBytes = 0; // free bytes on disk190- if (!GetDiskFreeSpaceEx(GetDataDir().c_str(),191- (PULARGE_INTEGER)&nFreeBytesAvailable,192- (PULARGE_INTEGER)&nTotalNumberOfBytes,193- (PULARGE_INTEGER)&nTotalNumberOfFreeBytes))194- {195- printf("ERROR: GetDiskFreeSpaceEx() failed\n");196- return true;197- }198-#else199 uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available;200-#endif201 202 // Check for 15MB because database could create another 10MB log file at any time203 if (nFreeBytesAvailable < (int64)15000000 + nAdditionalBytes)204 {205 fShutdown = true;206- ThreadSafeMessageBox("Warning: Your disk space is low ", "Bitcoin", wxOK | wxICON_EXCLAMATION);207+ ThreadSafeMessageBox(_("Warning: Disk space is low "), "Bitcoin", wxOK | wxICON_EXCLAMATION);208 CreateThread(Shutdown, NULL);209 return false;210 }211@@ -1509,7 +1556,9 @@212 txNew.vout.resize(1);213 txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));214 txNew.vout[0].nValue = 50 * COIN;215- txNew.vout[0].scriptPubKey = CScript() << CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << OP_CHECKSIG;216+ CBigNum bnPubKey;217+ bnPubKey.SetHex("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704");218+ txNew.vout[0].scriptPubKey = CScript() << bnPubKey << OP_CHECKSIG;219 CBlock block;220 block.vtx.push_back(txNew);221 block.hashPrevBlock = 0;222@@ -1643,10 +1692,8 @@223 {224 switch (inv.type)225 {226- case MSG_TX: return mapTransactions.count(inv.hash) || txdb.ContainsTx(inv.hash);227- case MSG_BLOCK: return mapBlockIndex.count(inv.hash) || mapOrphanBlocks.count(inv.hash);228- case MSG_REVIEW: return true;229- case MSG_PRODUCT: return mapProducts.count(inv.hash);230+ case MSG_TX: return mapTransactions.count(inv.hash) || txdb.ContainsTx(inv.hash);231+ case MSG_BLOCK: return mapBlockIndex.count(inv.hash) || mapOrphanBlocks.count(inv.hash);232 }233 // Don't know what it is, just say we already got one234 return true;235@@ -1733,6 +1780,11 @@236 {237 // Allow exceptions from underlength message on vRecv238 printf("ProcessMessage(%s, %d bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand.c_str(), nMessageSize, e.what());239+ }240+ else if (strstr(e.what(), ": size too large"))241+ {242+ // Allow exceptions from overlong size243+ printf("ProcessMessage(%s, %d bytes) : Exception '%s' caught\n", strCommand.c_str(), nMessageSize, e.what());244 }245 else246 {247@@ -1840,7 +1892,6 @@248 return error("message addr size() = %d", vAddr.size());249 250 // Store the new addresses251- CAddrDB addrdb;252 foreach(CAddress& addr, vAddr)253 {254 if (fShutdown)255@@ -1848,7 +1899,7 @@256 addr.nTime = GetAdjustedTime() - 2 * 60 * 60;257 if (pfrom->fGetAddr)258 addr.nTime -= 5 * 24 * 60 * 60;259- AddAddress(addrdb, addr, false);260+ AddAddress(addr, false);261 pfrom->AddAddressKnown(addr);262 if (!pfrom->fGetAddr && addr.IsRoutable())263 {264@@ -2041,24 +2092,6 @@265 }266 267 268- else if (strCommand == "review")269- {270- CDataStream vMsg(vRecv);271- CReview review;272- vRecv >> review;273-274- CInv inv(MSG_REVIEW, review.GetHash());275- pfrom->AddInventoryKnown(inv);276-277- if (review.AcceptReview())278- {279- // Relay the original message as-is in case it's a higher version than we know how to parse280- RelayMessage(inv, vMsg);281- mapAlreadyAskedFor.erase(inv);282- }283- }284-285-286 else if (strCommand == "block")287 {288 auto_ptr<CBlock> pblock(new CBlock);289@@ -2194,7 +2227,7 @@290 return true;291 292 // Keep-alive ping293- if (pto->nLastSend && GetTime() - pto->nLastSend > 12 * 60 && pto->vSend.empty())294+ if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSend.empty())295 pto->PushMessage("ping");296 297 // Address refresh broadcast298@@ -2216,60 +2249,81 @@299 }300 }301 302+ // Delay tx inv messages to protect privacy,303+ // trickle them out to a few nodes at a time.304+ bool fSendTxInv = false;305+ if (GetTimeMillis() - pto->nLastSentTxInv > 1800 + GetRand(200))306+ {307+ pto->nLastSentTxInv = GetTimeMillis();308+ fSendTxInv = true;309+ }310+311+ // Resend wallet transactions that haven't gotten in a block yet312+ ResendWalletTransactions();313+314 315 //316 // Message: addr317 //318- vector<CAddress> vAddrToSend;319- vAddrToSend.reserve(pto->vAddrToSend.size());320+ vector<CAddress> vAddr;321+ vAddr.reserve(pto->vAddrToSend.size());322 foreach(const CAddress& addr, pto->vAddrToSend)323 {324 // returns true if wasn't already contained in the set325 if (pto->setAddrKnown.insert(addr).second)326 {327- vAddrToSend.push_back(addr);328- if (vAddrToSend.size() >= 1000)329+ vAddr.push_back(addr);330+ if (vAddr.size() >= 1000)331 {332- pto->PushMessage("addr", vAddrToSend);333- vAddrToSend.clear();334+ pto->PushMessage("addr", vAddr);335+ vAddr.clear();336 }337 }338 }339 pto->vAddrToSend.clear();340- if (!vAddrToSend.empty())341- pto->PushMessage("addr", vAddrToSend);342+ if (!vAddr.empty())343+ pto->PushMessage("addr", vAddr);344 345 346 //347 // Message: inventory348 //349- vector<CInv> vInventoryToSend;350+ vector<CInv> vInv;351+ vector<CInv> vInvWait;352 CRITICAL_BLOCK(pto->cs_inventory)353 {354- vInventoryToSend.reserve(pto->vInventoryToSend.size());355+ vInv.reserve(pto->vInventoryToSend.size());356+ vInvWait.reserve(pto->vInventoryToSend.size());357 foreach(const CInv& inv, pto->vInventoryToSend)358 {359+ // delay txes360+ if (!fSendTxInv && inv.type == MSG_TX)361+ {362+ vInvWait.push_back(inv);363+ continue;364+ }365+366 // returns true if wasn't already contained in the set367 if (pto->setInventoryKnown.insert(inv).second)368 {369- vInventoryToSend.push_back(inv);370- if (vInventoryToSend.size() >= 1000)371+ vInv.push_back(inv);372+ if (vInv.size() >= 1000)373 {374- pto->PushMessage("inv", vInventoryToSend);375- vInventoryToSend.clear();376+ pto->PushMessage("inv", vInv);377+ vInv.clear();378 }379 }380 }381- pto->vInventoryToSend.clear();382- }383- if (!vInventoryToSend.empty())384- pto->PushMessage("inv", vInventoryToSend);385+ pto->vInventoryToSend = vInvWait;386+ }387+ if (!vInv.empty())388+ pto->PushMessage("inv", vInv);389 390 391 //392 // Message: getdata393 //394- vector<CInv> vAskFor;395+ vector<CInv> vGetData;396 int64 nNow = GetTime() * 1000000;397 CTxDB txdb("r");398 while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)399@@ -2278,17 +2332,17 @@400 if (!AlreadyHave(txdb, inv))401 {402 printf("sending getdata: %s\n", inv.ToString().c_str());403- vAskFor.push_back(inv);404- if (vAskFor.size() >= 1000)405+ vGetData.push_back(inv);406+ if (vGetData.size() >= 1000)407 {408- pto->PushMessage("getdata", vAskFor);409- vAskFor.clear();410+ pto->PushMessage("getdata", vGetData);411+ vGetData.clear();412 }413 }414 pto->mapAskFor.erase(pto->mapAskFor.begin());415 }416- if (!vAskFor.empty())417- pto->PushMessage("getdata", vAskFor);418+ if (!vGetData.empty())419+ pto->PushMessage("getdata", vGetData);420 421 }422 return true;423@@ -2351,7 +2405,6 @@424 vnThreadsRunning[3]--;425 PrintException(NULL, "ThreadBitcoinMiner()");426 }427-428 printf("ThreadBitcoinMiner exiting, %d threads remaining\n", vnThreadsRunning[3]);429 }430 431@@ -2788,6 +2841,13 @@432 // Fill a vout back to self with any change433 if (nValueIn > nTotalValue)434 {435+ // Note: We use a new key here to keep it from being obvious which side is the change.436+ // The drawback is that by not reusing a previous key, the change may be lost if a437+ // backup is restored, if the backup doesn't have the new private key for the change.438+ // If we reused the old key, it would be possible to add code to look for and439+ // rediscover unknown transactions that were written with keys of ours to recover440+ // post-backup change.441+442 // New private key443 if (keyRet.IsNull())444 keyRet.MakeNewKey();445@@ -2839,9 +2899,13 @@446 CRITICAL_BLOCK(cs_main)447 CRITICAL_BLOCK(cs_mapWallet)448 {449- //// todo: eventually should make this transactional, never want to add a450+ //// old: eventually should make this transactional, never want to add a451 //// transaction without marking spent transactions, although the risk of452 //// interruption during this step is remote.453+ //// update: This matters even less now that fSpent can get corrected454+ //// when transactions are seen in VerifySignature. The remote chance of455+ //// unmarked fSpent will be handled by that. Don't need to make this456+ //// transactional. Pls delete this comment block later.457 458 // This is only to keep the database open to defeat the auto-flush for the459 // duration of this scope. This is the only place where this optimization460@@ -2874,7 +2938,7 @@461 462 463 464-bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew)465+string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew)466 {467 CRITICAL_BLOCK(cs_main)468 {469@@ -2884,16 +2948,16 @@470 {471 string strError;472 if (nValue + nFeeRequired > GetBalance())473- strError = strprintf("Error: This is an oversized transaction that requires a transaction fee of %s ", FormatMoney(nFeeRequired).c_str());474+ strError = strprintf(_("Error: This is an oversized transaction that requires a transaction fee of %s "), FormatMoney(nFeeRequired).c_str());475 else476- strError = "Error: Transaction creation failed ";477- wxMessageBox(strError, "Sending...");478- return error("SendMoney() : %s", strError.c_str());479+ strError = _("Error: Transaction creation failed ");480+ printf("SendMoney() : %s", strError.c_str());481+ return strError;482 }483 if (!CommitTransactionSpent(wtxNew, key))484 {485- wxMessageBox("Error finalizing transaction ", "Sending...");486- return error("SendMoney() : Error finalizing transaction");487+ printf("SendMoney() : Error finalizing transaction");488+ return _("Error finalizing transaction");489 }490 491 // Track how many getdata requests our transaction gets492@@ -2906,13 +2970,30 @@493 if (!wtxNew.AcceptTransaction())494 {495 // This must not fail. The transaction has already been signed and recorded.496- throw runtime_error("SendMoney() : wtxNew.AcceptTransaction() failed\n");497- wxMessageBox("Error: Transaction not valid ", "Sending...");498- return error("SendMoney() : Error: Transaction not valid");499+ printf("SendMoney() : Error: Transaction not valid");500+ return _("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");501 }502 wtxNew.RelayWalletTransaction();503 }504 MainFrameRepaint();505- return true;506-}507-508+ return "";509+}510+511+512+513+string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew)514+{515+ // Check amount516+ if (nValue <= 0)517+ return _("Invalid amount");518+ if (nValue + nTransactionFee > GetBalance())519+ return _("You don't have enough money");520+521+ // Parse bitcoin address522+ CScript scriptPubKey;523+ if (!scriptPubKey.SetBitcoinAddress(strAddress))524+ return _("Invalid bitcoin address");525+526+ return SendMoney(scriptPubKey, nValue, wtxNew);527+}528+
main.h (modified)
1--- v0.2.0/main.h2+++ v0.2.2/main.h3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -36,6 +36,8 @@10 extern unsigned int nTransactionsUpdated;11 extern map<uint256, int> mapRequestCount;12 extern CCriticalSection cs_mapRequestCount;13+extern map<string, string> mapAddressBook;14+extern CCriticalSection cs_mapAddressBook;15 16 // Settings17 extern int fGenerateBitcoins;18@@ -56,8 +58,8 @@19 bool AddKey(const CKey& key);20 vector<unsigned char> GenerateNewKey();21 bool AddToWallet(const CWalletTx& wtxIn);22+void WalletUpdateSpent(const COutPoint& prevout);23 void ReacceptWalletTransactions();24-void RelayWalletTransactions();25 bool LoadBlockIndex(bool fAllowNew=true);26 void PrintBlockTree();27 bool ProcessMessages(CNode* pfrom);28@@ -66,7 +68,8 @@29 int64 GetBalance();30 bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CKey& keyRet, int64& nFeeRequiredRet);31 bool CommitTransactionSpent(const CWalletTx& wtxNew, const CKey& key);32-bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew);33+string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew);34+string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew);35 void GenerateBitcoins(bool fGenerate);36 void ThreadBitcoinMiner(void* parg);37 void BitcoinMiner();38@@ -679,7 +682,8 @@39 40 41 int SetMerkleBranch(const CBlock* pblock=NULL);42- int GetDepthInMainChain() const;43+ int GetDepthInMainChain(int& nHeightRet) const;44+ int GetDepthInMainChain() const { int nHeight; return GetDepthInMainChain(nHeight); }45 bool IsInMainChain() const { return GetDepthInMainChain() > 0; }46 int GetBlocksToMaturity() const;47 bool AcceptTransaction(CTxDB& txdb, bool fCheckInputs=true);48@@ -1370,6 +1374,31 @@49 50 51 52+//53+// Private key that includes an expiration date in case it never gets used.54+//55+class CWalletKey56+{57+public:58+ CPrivKey vchPrivKey;59+ int64 nTimeCreated;60+ int64 nTimeExpires;61+62+ CWalletKey(int64 nTimeExpiresIn=0)63+ {64+ nTimeCreated = (nTimeExpiresIn ? GetTime() : 0);65+ nTimeExpires = nTimeExpiresIn;66+ }67+68+ IMPLEMENT_SERIALIZE69+ (70+ if (!(nType & SER_GETHASH))71+ READWRITE(nVersion);72+ READWRITE(vchPrivKey);73+ READWRITE(nTimeCreated);74+ READWRITE(nTimeExpires);75+ )76+};77 78 79
makefile (removed)
1--- v0.2.0/makefile2+++ /dev/null3@@ -1,82 +1 @@4-# Copyright (c) 2009 Satoshi Nakamoto5-# Distributed under the MIT/X11 software license, see the accompanying6-# file license.txt or http://www.opensource.org/licenses/mit-license.php.7 8-9-ifneq "$(BUILD)" "debug"10-ifneq "$(BUILD)" "release"11-BUILD=debug12-endif13-endif14-ifeq "$(BUILD)" "debug"15-D=d16-DEBUGFLAGS=-g -D__WXDEBUG__17-endif18-19-20-21-INCLUDEPATHS=-I"/boost" -I"/db/build_unix" -I"/openssl/include" -I"/wxwidgets/lib/vc_lib/mswd" -I"/wxwidgets/include"22-LIBPATHS=-L"/db/build_unix" -L"/openssl/out" -L"/wxwidgets/lib/gcc_lib"23-LIBS= \24- -l db_cxx \25- -l eay32 \26- -l wxmsw28$(D)_richtext -l wxmsw28$(D)_html -l wxmsw28$(D)_core -l wxmsw28$(D)_adv -l wxbase28$(D) -l wxtiff$(D) -l wxjpeg$(D) -l wxpng$(D) -l wxzlib$(D) -l wxregex$(D) -l wxexpat$(D) \27- -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi28-WXDEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH29-CFLAGS=-mthreads -O0 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)30-HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h31-32-33-34-all: bitcoin.exe35-36-37-headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h38- g++ -c $(CFLAGS) -o $@ $<39-40-obj/util.o: util.cpp $(HEADERS)41- g++ -c $(CFLAGS) -o $@ $<42-43-obj/script.o: script.cpp $(HEADERS)44- g++ -c $(CFLAGS) -o $@ $<45-46-obj/db.o: db.cpp $(HEADERS) market.h47- g++ -c $(CFLAGS) -o $@ $<48-49-obj/net.o: net.cpp $(HEADERS) net.h50- g++ -c $(CFLAGS) -o $@ $<51-52-obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h53- g++ -c $(CFLAGS) -o $@ $<54-55-obj/market.o: market.cpp $(HEADERS) market.h56- g++ -c $(CFLAGS) -o $@ $<57-58-obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h59- g++ -c $(CFLAGS) -o $@ $<60-61-obj/uibase.o: uibase.cpp uibase.h62- g++ -c $(CFLAGS) -o $@ $<63-64-obj/sha.o: sha.cpp sha.h65- g++ -c $(CFLAGS) -O3 -o $@ $<66-67-obj/irc.o: irc.cpp $(HEADERS)68- g++ -c $(CFLAGS) -o $@ $<69-70-obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp71- windres $(WXDEFS) $(INCLUDEPATHS) -o $@ -i $<72-73-74-75-OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \76- obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ui_res.o77-78-bitcoin.exe: headers.h.gch $(OBJS)79- -kill /f bitcoin.exe80- g++ $(CFLAGS) -mwindows -Wl,--subsystem,windows -o $@ $(LIBPATHS) $(OBJS) $(LIBS)81-82-clean:83- -del /Q obj\*84- -del /Q headers.h.gch85-
makefile.mingw (added)
1--- /dev/null2+++ v0.2.2/makefile.mingw3@@ -1 +1,87 @@4+# Copyright (c) 2009-2010 Satoshi Nakamoto5+# Distributed under the MIT/X11 software license, see the accompanying6+# file license.txt or http://www.opensource.org/licenses/mit-license.php.7 8+9+# for wxWidgets-2.8.x, search and replace "mswud"->"mswd" and "29u"->"28"10+11+INCLUDEPATHS= \12+ -I"/boost" \13+ -I"/db/build_unix" \14+ -I"/openssl/include" \15+ -I"/wxwidgets/lib/gcc_lib/mswud" \16+ -I"/wxwidgets/include"17+18+LIBPATHS= \19+ -L"/boost/stage/lib" \20+ -L"/db/build_unix" \21+ -L"/openssl/out" \22+ -L"/wxwidgets/lib/gcc_lib"23+24+LIBS= \25+ -l libboost_system-mgw34-mt-d -l libboost_filesystem-mgw34-mt-d \26+ -l db_cxx \27+ -l eay32 \28+ -l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd \29+ -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi30+31+WXDEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH32+DEBUGFLAGS=-g -D__WXDEBUG__33+CFLAGS=-mthreads -O0 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)34+HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h35+36+37+38+all: bitcoin.exe39+40+41+headers.h.gch: headers.h $(HEADERS)42+ g++ -c $(CFLAGS) -o $@ $<43+44+obj/util.o: util.cpp $(HEADERS)45+ g++ -c $(CFLAGS) -o $@ $<46+47+obj/script.o: script.cpp $(HEADERS)48+ g++ -c $(CFLAGS) -o $@ $<49+50+obj/db.o: db.cpp $(HEADERS)51+ g++ -c $(CFLAGS) -o $@ $<52+53+obj/net.o: net.cpp $(HEADERS)54+ g++ -c $(CFLAGS) -o $@ $<55+56+obj/main.o: main.cpp $(HEADERS) sha.h57+ g++ -c $(CFLAGS) -o $@ $<58+59+obj/ui.o: ui.cpp $(HEADERS)60+ g++ -c $(CFLAGS) -o $@ $<61+62+obj/uibase.o: uibase.cpp uibase.h63+ g++ -c $(CFLAGS) -o $@ $<64+65+obj/sha.o: sha.cpp sha.h66+ g++ -c $(CFLAGS) -O3 -o $@ $<67+68+obj/irc.o: irc.cpp $(HEADERS)69+ g++ -c $(CFLAGS) -o $@ $<70+71+obj/rpc.o: rpc.cpp $(HEADERS)72+ g++ -c $(CFLAGS) -o $@ $<73+74+obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp75+ windres $(WXDEFS) $(INCLUDEPATHS) -o $@ -i $<76+77+78+79+OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \80+ obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/rpc.o \81+ obj/ui_res.o82+83+bitcoin.exe: headers.h.gch $(OBJS)84+ -kill /f bitcoin.exe85+ g++ $(CFLAGS) -mwindows -Wl,--subsystem,windows -o $@ $(LIBPATHS) $(OBJS) $(LIBS)86+87+clean:88+ -del /Q obj\*89+ -del /Q headers.h.gch90+
makefile.unix (modified)
1--- v0.2.0/makefile.unix2+++ v0.2.2/makefile.unix3@@ -1,24 +1,13 @@4-# Copyright (c) 2009 Satoshi Nakamoto5+# Copyright (c) 2009-2010 Satoshi Nakamoto6 # Distributed under the MIT/X11 software license, see the accompanying7 # file license.txt or http://www.opensource.org/licenses/mit-license.php.8-9-10-ifneq "$(BUILD)" "debug"11-ifneq "$(BUILD)" "release"12-BUILD=debug13-endif14-endif15-ifeq "$(BUILD)" "debug"16-D=d17-DEBUGFLAGS=-g -D__WXDEBUG__18-endif19 20 21 22 INCLUDEPATHS= \23 -I"/usr/include" \24- -I"/usr/local/include/wx-2.8" \25- -I"/usr/local/lib/wx/include/gtk2-ansi-debug-static-2.8"26+ -I"/usr/local/include/wx-2.9" \27+ -I"/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9"28 29 LIBPATHS= \30 -L"/usr/lib" \31@@ -26,23 +15,24 @@32 33 LIBS= \34 -Wl,-Bstatic \35- -l boost_system -l boost_filesystem \36+ -l boost_system-mt -l boost_filesystem-mt \37 -l db_cxx \38- -l wx_gtk2$(D)-2.8 \39+ -l wx_gtk2ud-2.9 \40 -Wl,-Bdynamic \41 -l crypto \42 -l gtk-x11-2.0 -l gthread-2.0 -l SM43 44 WXDEFS=-D__WXGTK__ -DNOPCH45+DEBUGFLAGS=-g -D__WXDEBUG__46 CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)47-HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h48+HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h49 50 51 52 all: bitcoin53 54 55-headers.h.gch: headers.h $(HEADERS) net.h irc.h market.h uibase.h ui.h56+headers.h.gch: headers.h $(HEADERS)57 g++ -c $(CFLAGS) -o $@ $<58 59 obj/util.o: util.cpp $(HEADERS)60@@ -51,19 +41,16 @@61 obj/script.o: script.cpp $(HEADERS)62 g++ -c $(CFLAGS) -o $@ $<63 64-obj/db.o: db.cpp $(HEADERS) market.h65+obj/db.o: db.cpp $(HEADERS)66 g++ -c $(CFLAGS) -o $@ $<67 68-obj/net.o: net.cpp $(HEADERS) net.h69+obj/net.o: net.cpp $(HEADERS)70 g++ -c $(CFLAGS) -o $@ $<71 72-obj/main.o: main.cpp $(HEADERS) net.h market.h sha.h73+obj/main.o: main.cpp $(HEADERS) sha.h74 g++ -c $(CFLAGS) -o $@ $<75 76-obj/market.o: market.cpp $(HEADERS) market.h77- g++ -c $(CFLAGS) -o $@ $<78-79-obj/ui.o: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h80+obj/ui.o: ui.cpp $(HEADERS)81 g++ -c $(CFLAGS) -o $@ $<82 83 obj/uibase.o: uibase.cpp uibase.h84@@ -75,11 +62,13 @@85 obj/irc.o: irc.cpp $(HEADERS)86 g++ -c $(CFLAGS) -o $@ $<87 88+obj/rpc.o: rpc.cpp $(HEADERS)89+ g++ -c $(CFLAGS) -o $@ $<90 91 92 93-OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \94- obj/ui.o obj/uibase.o obj/sha.o obj/irc.o95+OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \96+ obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/rpc.o97 98 bitcoin: headers.h.gch $(OBJS)99 g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS)
makefile.vc (modified)
1--- v0.2.0/makefile.vc2+++ v0.2.2/makefile.vc3@@ -1,28 +1,34 @@4-# Copyright (c) 2009 Satoshi Nakamoto5+# Copyright (c) 2009-2010 Satoshi Nakamoto6 # Distributed under the MIT/X11 software license, see the accompanying7 # file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9 10-!IF "$(BUILD)" != "debug" && "$(BUILD)" != "release"11-BUILD=debug12-!ENDIF13-!IF "$(BUILD)" == "debug"14-D=d15+# for wxWidgets-2.8.x, search and replace "mswud"->"mswd" and "29u"->"28"16+17+INCLUDEPATHS= \18+ /I"/boost" \19+ /I"/db/build_windows" \20+ /I"/openssl/include" \21+ /I"/wxwidgets/lib/vc_lib/mswud" \22+ /I"/wxwidgets/include"23+24+LIBPATHS= \25+ /LIBPATH:"/boost/stage/lib" \26+ /LIBPATH:"/db/build_windows/debug" \27+ /LIBPATH:"/openssl/out" \28+ /LIBPATH:"/wxwidgets/lib/vc_lib"29+30+LIBS= \31+ libboost_system-vc80-mt-gd.lib libboost_filesystem-vc80-mt-gd.lib \32+ libdb47sd.lib \33+ libeay32.lib \34+ wxmsw29ud_html.lib wxmsw29ud_core.lib wxmsw29ud_adv.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib \35+ kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib36+37+WXDEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH38 DEBUGFLAGS=/Zi /Od /D__WXDEBUG__39-!ENDIF40-41-42-43-INCLUDEPATHS=/I"/boost" /I"/db/build_windows" /I"/openssl/include" /I"/wxwidgets/lib/vc_lib/mswd" /I"/wxwidgets/include"44-LIBPATHS=/LIBPATH:"/db/build_windows/$(BUILD)" /LIBPATH:"/openssl/out" /LIBPATH:"/wxwidgets/lib/vc_lib"45-LIBS= \46- libdb47s$(D).lib \47- libeay32.lib \48- wxmsw28$(D)_richtext.lib wxmsw28$(D)_html.lib wxmsw28$(D)_core.lib wxmsw28$(D)_adv.lib wxbase28$(D).lib wxtiff$(D).lib wxjpeg$(D).lib wxpng$(D).lib wxzlib$(D).lib wxregex$(D).lib wxexpat$(D).lib \49- kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib50-WXDEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH51-CFLAGS=/c /nologo /Ob0 /MD$(D) /EHsc /GR /Zm300 /YX /Fpobj/headers.pch $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)52-HEADERS=headers.h util.h main.h serialize.h uint256.h key.h bignum.h script.h db.h base58.h53+CFLAGS=/c /nologo /Ob0 /MDd /EHsc /GR /Zm300 $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)54+HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h55 56 57 58@@ -35,28 +41,28 @@59 obj\script.obj: script.cpp $(HEADERS)60 cl $(CFLAGS) /Fo$@ %s61 62-obj\db.obj: db.cpp $(HEADERS) market.h63+obj\db.obj: db.cpp $(HEADERS)64 cl $(CFLAGS) /Fo$@ %s65 66-obj\net.obj: net.cpp $(HEADERS) net.h67+obj\net.obj: net.cpp $(HEADERS)68 cl $(CFLAGS) /Fo$@ %s69 70-obj\main.obj: main.cpp $(HEADERS) net.h market.h71+obj\main.obj: main.cpp $(HEADERS) sha.h72 cl $(CFLAGS) /Fo$@ %s73 74-obj\market.obj: market.cpp $(HEADERS) market.h75- cl $(CFLAGS) /Fo$@ %s76-77-obj\ui.obj: ui.cpp $(HEADERS) net.h uibase.h ui.h market.h78+obj\ui.obj: ui.cpp $(HEADERS)79 cl $(CFLAGS) /Fo$@ %s80 81 obj\uibase.obj: uibase.cpp uibase.h82 cl $(CFLAGS) /Fo$@ %s83 84-obj\sha.obj: sha.cpp sha.h85+obj\sha.obj: sha.cpp sha.h86 cl $(CFLAGS) /O2 /Fo$@ %s87 88 obj\irc.obj: irc.cpp $(HEADERS)89+ cl $(CFLAGS) /Fo$@ %s90+91+obj\rpc.obj: rpc.cpp $(HEADERS)92 cl $(CFLAGS) /Fo$@ %s93 94 obj\ui.res: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp95@@ -64,8 +70,9 @@96 97 98 99-OBJS=obj\util.obj obj\script.obj obj\db.obj obj\net.obj obj\main.obj obj\market.obj \100- obj\ui.obj obj\uibase.obj obj\sha.obj obj\irc.obj obj\ui.res101+OBJS=obj\util.obj obj\script.obj obj\db.obj obj\net.obj obj\main.obj \102+ obj\ui.obj obj\uibase.obj obj\sha.obj obj\irc.obj obj\rpc.obj \103+ obj\ui.res104 105 bitcoin.exe: $(OBJS)106 -kill /f bitcoin.exe & sleep 1
market.cpp (removed)
1--- v0.2.0/market.cpp2+++ /dev/null3@@ -1,265 +1 @@4-// Copyright (c) 2009 Satoshi Nakamoto5-// Distributed under the MIT/X11 software license, see the accompanying6-// file license.txt or http://www.opensource.org/licenses/mit-license.php.7 8-#include "headers.h"9-10-11-12-13-14-15-16-17-18-19-//20-// Global state variables21-//22-23-//// later figure out how these are persisted24-map<uint256, CProduct> mapMyProducts;25-26-27-28-29-map<uint256, CProduct> mapProducts;30-CCriticalSection cs_mapProducts;31-32-bool AdvertInsert(const CProduct& product)33-{34- uint256 hash = product.GetHash();35- bool fNew = false;36- bool fUpdated = false;37-38- CRITICAL_BLOCK(cs_mapProducts)39- {40- // Insert or find existing product41- pair<map<uint256, CProduct>::iterator, bool> item = mapProducts.insert(make_pair(hash, product));42- CProduct* pproduct = &(*(item.first)).second;43- fNew = item.second;44-45- // Update if newer46- if (product.nSequence > pproduct->nSequence)47- {48- *pproduct = product;49- fUpdated = true;50- }51- }52-53- //if (fNew)54- // NotifyProductAdded(hash);55- //else if (fUpdated)56- // NotifyProductUpdated(hash);57-58- return (fNew || fUpdated);59-}60-61-void AdvertErase(const CProduct& product)62-{63- uint256 hash = product.GetHash();64- CRITICAL_BLOCK(cs_mapProducts)65- mapProducts.erase(hash);66- //NotifyProductDeleted(hash);67-}68-69-70-71-72-73-74-75-76-77-78-79-80-81-82-83-84-85-86-87-template<typename T>88-unsigned int Union(T& v1, T& v2)89-{90- // v1 = v1 union v291- // v1 and v2 must be sorted92- // returns the number of elements added to v193-94- ///// need to check that this is equivalent, then delete this comment95- //vector<unsigned short> vUnion(v1.size() + v2.size());96- //vUnion.erase(set_union(v1.begin(), v1.end(),97- // v2.begin(), v2.end(),98- // vUnion.begin()),99- // vUnion.end());100-101- T vUnion;102- vUnion.reserve(v1.size() + v2.size());103- set_union(v1.begin(), v1.end(),104- v2.begin(), v2.end(),105- back_inserter(vUnion));106- unsigned int nAdded = vUnion.size() - v1.size();107- if (nAdded > 0)108- v1 = vUnion;109- return nAdded;110-}111-112-void CUser::AddAtom(unsigned short nAtom, bool fOrigin)113-{114- // Ignore duplicates115- if (binary_search(vAtomsIn.begin(), vAtomsIn.end(), nAtom) ||116- find(vAtomsNew.begin(), vAtomsNew.end(), nAtom) != vAtomsNew.end())117- return;118-119- //// instead of zero atom, should change to free atom that propagates,120- //// limited to lower than a certain value like 5 so conflicts quickly121- // The zero atom never propagates,122- // new atoms always propagate through the user that created them123- if (nAtom == 0 || fOrigin)124- {125- vector<unsigned short> vTmp(1, nAtom);126- Union(vAtomsIn, vTmp);127- if (fOrigin)128- vAtomsOut.push_back(nAtom);129- return;130- }131-132- vAtomsNew.push_back(nAtom);133-134- if (vAtomsNew.size() >= nFlowthroughRate || vAtomsOut.empty())135- {136- // Select atom to flow through to vAtomsOut137- vAtomsOut.push_back(vAtomsNew[GetRand(vAtomsNew.size())]);138-139- // Merge vAtomsNew into vAtomsIn140- sort(vAtomsNew.begin(), vAtomsNew.end());141- Union(vAtomsIn, vAtomsNew);142- vAtomsNew.clear();143- }144-}145-146-bool AddAtomsAndPropagate(uint256 hashUserStart, const vector<unsigned short>& vAtoms, bool fOrigin)147-{148- CReviewDB reviewdb;149- map<uint256, vector<unsigned short> > pmapPropagate[2];150- pmapPropagate[0][hashUserStart] = vAtoms;151-152- for (int side = 0; !pmapPropagate[side].empty(); side = 1 - side)153- {154- map<uint256, vector<unsigned short> >& mapFrom = pmapPropagate[side];155- map<uint256, vector<unsigned short> >& mapTo = pmapPropagate[1 - side];156-157- for (map<uint256, vector<unsigned short> >::iterator mi = mapFrom.begin(); mi != mapFrom.end(); ++mi)158- {159- const uint256& hashUser = (*mi).first;160- const vector<unsigned short>& vReceived = (*mi).second;161-162- ///// this would be a lot easier on the database if it put the new atom at the beginning of the list,163- ///// so the change would be right next to the vector size.164-165- // Read user166- CUser user;167- reviewdb.ReadUser(hashUser, user);168- unsigned int nIn = user.vAtomsIn.size();169- unsigned int nNew = user.vAtomsNew.size();170- unsigned int nOut = user.vAtomsOut.size();171-172- // Add atoms received173- foreach(unsigned short nAtom, vReceived)174- user.AddAtom(nAtom, fOrigin);175- fOrigin = false;176-177- // Don't bother writing to disk if no changes178- if (user.vAtomsIn.size() == nIn && user.vAtomsNew.size() == nNew)179- continue;180-181- // Propagate182- if (user.vAtomsOut.size() > nOut)183- foreach(const uint256& hash, user.vLinksOut)184- mapTo[hash].insert(mapTo[hash].end(), user.vAtomsOut.begin() + nOut, user.vAtomsOut.end());185-186- // Write back187- if (!reviewdb.WriteUser(hashUser, user))188- return false;189- }190- mapFrom.clear();191- }192- return true;193-}194-195-196-197-198-199-200-bool CReview::AcceptReview()201-{202- // Timestamp203- nTime = GetTime();204-205- // Check signature206- if (!CKey::Verify(vchPubKeyFrom, GetSigHash(), vchSig))207- return false;208-209- CReviewDB reviewdb;210-211- // Add review text to recipient212- vector<CReview> vReviews;213- reviewdb.ReadReviews(hashTo, vReviews);214- vReviews.push_back(*this);215- if (!reviewdb.WriteReviews(hashTo, vReviews))216- return false;217-218- // Add link from sender219- CUser user;220- uint256 hashFrom = Hash(vchPubKeyFrom.begin(), vchPubKeyFrom.end());221- reviewdb.ReadUser(hashFrom, user);222- user.vLinksOut.push_back(hashTo);223- if (!reviewdb.WriteUser(hashFrom, user))224- return false;225-226- reviewdb.Close();227-228- // Propagate atoms to recipient229- vector<unsigned short> vZeroAtom(1, 0);230- if (!AddAtomsAndPropagate(hashTo, user.vAtomsOut.size() ? user.vAtomsOut : vZeroAtom, false))231- return false;232-233- return true;234-}235-236-237-238-239-240-bool CProduct::CheckSignature()241-{242- return (CKey::Verify(vchPubKeyFrom, GetSigHash(), vchSig));243-}244-245-bool CProduct::CheckProduct()246-{247- if (!CheckSignature())248- return false;249-250- // Make sure it's a summary product251- if (!mapDetails.empty() || !vOrderForm.empty())252- return false;253-254- // Look up seller's atom count255- CReviewDB reviewdb("r");256- CUser user;257- reviewdb.ReadUser(GetUserHash(), user);258- nAtoms = user.GetAtomCount();259- reviewdb.Close();260-261- ////// delme, this is now done by AdvertInsert262- //// Store to memory263- //CRITICAL_BLOCK(cs_mapProducts)264- // mapProducts[GetHash()] = *this;265-266- return true;267-}268-
market.h (removed)
1--- v0.2.0/market.h2+++ /dev/null3@@ -1,183 +1 @@4-// Copyright (c) 2009 Satoshi Nakamoto5-// Distributed under the MIT/X11 software license, see the accompanying6-// file license.txt or http://www.opensource.org/licenses/mit-license.php.7 8-class CUser;9-class CReview;10-class CProduct;11-12-static const unsigned int nFlowthroughRate = 2;13-14-15-16-17-bool AdvertInsert(const CProduct& product);18-void AdvertErase(const CProduct& product);19-bool AddAtomsAndPropagate(uint256 hashUserStart, const vector<unsigned short>& vAtoms, bool fOrigin);20-21-22-23-24-25-26-27-28-class CUser29-{30-public:31- vector<unsigned short> vAtomsIn;32- vector<unsigned short> vAtomsNew;33- vector<unsigned short> vAtomsOut;34- vector<uint256> vLinksOut;35-36- CUser()37- {38- }39-40- IMPLEMENT_SERIALIZE41- (42- if (!(nType & SER_GETHASH))43- READWRITE(nVersion);44- READWRITE(vAtomsIn);45- READWRITE(vAtomsNew);46- READWRITE(vAtomsOut);47- READWRITE(vLinksOut);48- )49-50- void SetNull()51- {52- vAtomsIn.clear();53- vAtomsNew.clear();54- vAtomsOut.clear();55- vLinksOut.clear();56- }57-58- uint256 GetHash() const { return SerializeHash(*this); }59-60-61- int GetAtomCount() const62- {63- return (vAtomsIn.size() + vAtomsNew.size());64- }65-66- void AddAtom(unsigned short nAtom, bool fOrigin);67-};68-69-70-71-72-73-74-75-class CReview76-{77-public:78- int nVersion;79- uint256 hashTo;80- map<string, string> mapValue;81- vector<unsigned char> vchPubKeyFrom;82- vector<unsigned char> vchSig;83-84- // memory only85- unsigned int nTime;86- int nAtoms;87-88-89- CReview()90- {91- nVersion = 1;92- hashTo = 0;93- nTime = 0;94- nAtoms = 0;95- }96-97- IMPLEMENT_SERIALIZE98- (99- READWRITE(this->nVersion);100- nVersion = this->nVersion;101- if (!(nType & SER_DISK))102- READWRITE(hashTo);103- READWRITE(mapValue);104- READWRITE(vchPubKeyFrom);105- if (!(nType & SER_GETHASH))106- READWRITE(vchSig);107- )108-109- uint256 GetHash() const { return SerializeHash(*this); }110- uint256 GetSigHash() const { return SerializeHash(*this, SER_GETHASH|SER_SKIPSIG); }111- uint256 GetUserHash() const { return Hash(vchPubKeyFrom.begin(), vchPubKeyFrom.end()); }112-113-114- bool AcceptReview();115-};116-117-118-119-120-121-122-123-class CProduct124-{125-public:126- int nVersion;127- CAddress addr;128- map<string, string> mapValue;129- map<string, string> mapDetails;130- vector<pair<string, string> > vOrderForm;131- unsigned int nSequence;132- vector<unsigned char> vchPubKeyFrom;133- vector<unsigned char> vchSig;134-135- // disk only136- int nAtoms;137-138- // memory only139- set<unsigned int> setSources;140-141- CProduct()142- {143- nVersion = 1;144- nAtoms = 0;145- nSequence = 0;146- }147-148- IMPLEMENT_SERIALIZE149- (150- READWRITE(this->nVersion);151- nVersion = this->nVersion;152- READWRITE(addr);153- READWRITE(mapValue);154- if (!(nType & SER_GETHASH))155- {156- READWRITE(mapDetails);157- READWRITE(vOrderForm);158- READWRITE(nSequence);159- }160- READWRITE(vchPubKeyFrom);161- if (!(nType & SER_GETHASH))162- READWRITE(vchSig);163- if (nType & SER_DISK)164- READWRITE(nAtoms);165- )166-167- uint256 GetHash() const { return SerializeHash(*this); }168- uint256 GetSigHash() const { return SerializeHash(*this, SER_GETHASH|SER_SKIPSIG); }169- uint256 GetUserHash() const { return Hash(vchPubKeyFrom.begin(), vchPubKeyFrom.end()); }170-171-172- bool CheckSignature();173- bool CheckProduct();174-};175-176-177-178-179-180-181-182-183-extern map<uint256, CProduct> mapProducts;184-extern CCriticalSection cs_mapProducts;185-extern map<uint256, CProduct> mapMyProducts;186-
net.cpp (modified)
1--- v0.2.0/net.cpp2+++ v0.2.2/net.cpp3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -223,7 +223,7 @@10 11 12 13-bool AddAddress(CAddrDB& addrdb, CAddress addr, bool fCurrentlyOnline)14+bool AddAddress(CAddress addr, bool fCurrentlyOnline)15 {16 if (!addr.IsRoutable())17 return false;18@@ -239,7 +239,7 @@19 // New address20 printf("AddAddress(%s)\n", addr.ToStringLog().c_str());21 mapAddresses.insert(make_pair(addr.GetKey(), addr));22- addrdb.WriteAddress(addr);23+ CAddrDB().WriteAddress(addr);24 return true;25 }26 else27@@ -260,7 +260,7 @@28 fUpdated = true;29 }30 if (fUpdated)31- addrdb.WriteAddress(addrFound);32+ CAddrDB().WriteAddress(addrFound);33 }34 }35 return false;36@@ -381,11 +381,6 @@37 foreach(CNode* pnode, vNodes)38 if (pnode != this)39 pnode->PushMessage("sub-cancel", nChannel);40-41- // Clear memory, no longer subscribed42- if (nChannel == MSG_PRODUCT)43- CRITICAL_BLOCK(cs_mapProducts)44- mapProducts.clear();45 }46 }47 48@@ -497,10 +492,6 @@49 // All of a nodes broadcasts and subscriptions are automatically torn down50 // when it goes down, so a node has to stay up to keep its broadcast going.51 52- CRITICAL_BLOCK(cs_mapProducts)53- for (map<uint256, CProduct>::iterator mi = mapProducts.begin(); mi != mapProducts.end();)54- AdvertRemoveSource(this, MSG_PRODUCT, 0, (*(mi++)).second);55-56 // Cancel subscriptions57 for (unsigned int nChannel = 0; nChannel < vfSubscribe.size(); nChannel++)58 if (vfSubscribe[nChannel])59@@ -522,7 +513,6 @@60 void ThreadSocketHandler(void* parg)61 {62 IMPLEMENT_RANDOMIZE_STACK(ThreadSocketHandler(parg));63-64 try65 {66 vnThreadsRunning[0]++;67@@ -536,7 +526,6 @@68 vnThreadsRunning[0]--;69 throw; // support pthread_cancel()70 }71-72 printf("ThreadSocketHandler exiting\n");73 }74 75@@ -657,11 +646,7 @@76 if (FD_ISSET(hListenSocket, &fdsetRecv))77 {78 struct sockaddr_in sockaddr;79-#ifdef __WXMSW__80- int len = sizeof(sockaddr);81-#else82 socklen_t len = sizeof(sockaddr);83-#endif84 SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len);85 CAddress addr(sockaddr);86 if (hSocket == INVALID_SOCKET)87@@ -816,7 +801,6 @@88 void ThreadOpenConnections(void* parg)89 {90 IMPLEMENT_RANDOMIZE_STACK(ThreadOpenConnections(parg));91-92 try93 {94 vnThreadsRunning[1]++;95@@ -830,7 +814,6 @@96 vnThreadsRunning[1]--;97 PrintException(NULL, "ThreadOpenConnections()");98 }99-100 printf("ThreadOpenConnections exiting\n");101 }102 103@@ -881,11 +864,11 @@104 vnThreadsRunning[1]--;105 Sleep(500);106 const int nMaxConnections = 15;107- while (vNodes.size() >= nMaxConnections || vNodes.size() >= mapAddresses.size())108- {109+ while (vNodes.size() >= nMaxConnections)110+ {111+ Sleep(2000);112 if (fShutdown)113 return;114- Sleep(2000);115 }116 vnThreadsRunning[1]++;117 if (fShutdown)118@@ -928,7 +911,7 @@119 // 30 days 27 hours120 // 90 days 46 hours121 // 365 days 93 hours122- int64 nDelay = (int64)(3600.0 * sqrt(fabs(nSinceLastSeen) / 3600.0) + nRandomizer);123+ int64 nDelay = (int64)(3600.0 * sqrt(fabs((double)nSinceLastSeen) / 3600.0) + nRandomizer);124 125 // Fast reconnect for one hour after last seen126 if (nSinceLastSeen < 60 * 60)127@@ -1016,7 +999,6 @@128 void ThreadMessageHandler(void* parg)129 {130 IMPLEMENT_RANDOMIZE_STACK(ThreadMessageHandler(parg));131-132 try133 {134 vnThreadsRunning[2]++;135@@ -1030,7 +1012,6 @@136 vnThreadsRunning[2]--;137 PrintException(NULL, "ThreadMessageHandler()");138 }139-140 printf("ThreadMessageHandler exiting\n");141 }142 143@@ -1038,7 +1019,7 @@144 {145 printf("ThreadMessageHandler started\n");146 SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);147- loop148+ while (!fShutdown)149 {150 // Poll the connected nodes for messages151 vector<CNode*> vNodesCopy;152@@ -1329,7 +1310,7 @@153 fShutdown = true;154 nTransactionsUpdated++;155 int64 nStart = GetTime();156- while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0)157+ while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0)158 {159 if (GetTime() - nStart > 20)160 break;161@@ -1339,7 +1320,8 @@162 if (vnThreadsRunning[1] > 0) printf("ThreadOpenConnections still running\n");163 if (vnThreadsRunning[2] > 0) printf("ThreadMessageHandler still running\n");164 if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n");165- while (vnThreadsRunning[2] > 0)166+ if (vnThreadsRunning[4] > 0) printf("ThreadRPCServer still running\n");167+ while (vnThreadsRunning[2] > 0 || vnThreadsRunning[4] > 0)168 Sleep(20);169 Sleep(50);170
net.h (modified)
1--- v0.2.0/net.h2+++ v0.2.2/net.h3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -23,7 +23,7 @@10 11 bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet);12 bool GetMyExternalIP(unsigned int& ipRet);13-bool AddAddress(CAddrDB& addrdb, CAddress addr, bool fCurrentlyOnline=true);14+bool AddAddress(CAddress addr, bool fCurrentlyOnline=true);15 void AddressCurrentlyConnected(const CAddress& addr);16 CNode* FindNode(unsigned int ip);17 CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);18@@ -341,9 +341,6 @@19 {20 MSG_TX = 1,21 MSG_BLOCK,22- MSG_REVIEW,23- MSG_PRODUCT,24- MSG_TABLE,25 };26 27 static const char* ppszTypeName[] =28@@ -351,9 +348,6 @@29 "ERROR",30 "tx",31 "block",32- "review",33- "product",34- "table",35 };36 37 class CInv38@@ -518,6 +512,7 @@39 vector<CInv> vInventoryToSend;40 CCriticalSection cs_inventory;41 multimap<int64, CInv> mapAskFor;42+ int64 nLastSentTxInv;43 44 // publish and subscription45 vector<char> vfSubscribe;46@@ -627,7 +622,7 @@47 // We're using mapAskFor as a priority queue,48 // the key is the earliest time the request can be sent49 int64& nRequestTime = mapAlreadyAskedFor[inv];50- printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);51+ printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);52 53 // Make sure not to reuse time indexes to keep things in the same order54 int64 nNow = (GetTime() - 1) * 1000000;
rpc.cpp (added)
1--- /dev/null2+++ v0.2.2/rpc.cpp3@@ -1 +1,642 @@4-5+// Copyright (c) 2010 Satoshi Nakamoto6+// Distributed under the MIT/X11 software license, see the accompanying7+// file license.txt or http://www.opensource.org/licenses/mit-license.php.8+9+#include "headers.h"10+#undef printf11+#include <boost/asio.hpp>12+#include "json/json_spirit_reader_template.h"13+#include "json/json_spirit_writer_template.h"14+#include "json/json_spirit_utils.h"15+#define printf OutputDebugStringF16+// MinGW 3.4.5 gets "fatal error: had to relocate PCH" if the json headers are17+// precompiled in headers.h. The problem might be when the pch file goes over18+// a certain size around 145MB. If we need access to json_spirit outside this19+// file, we could use the compiled json_spirit option.20+21+using boost::asio::ip::tcp;22+using namespace json_spirit;23+24+void ThreadRPCServer2(void* parg);25+26+27+28+29+30+31+32+///33+/// Note: I'm not finished designing this interface, it's still subject to change.34+///35+36+37+38+Value stop(const Array& params)39+{40+ if (params.size() != 0)41+ throw runtime_error(42+ "stop (no parameters)\n"43+ "Stop bitcoin server.");44+45+ // Shutdown will take long enough that the response should get back46+ CreateThread(Shutdown, NULL);47+ return "bitcoin server stopping";48+}49+50+51+Value getblockcount(const Array& params)52+{53+ if (params.size() != 0)54+ throw runtime_error(55+ "getblockcount (no parameters)\n"56+ "Returns the number of blocks in the longest block chain.");57+58+ return nBestHeight + 1;59+}60+61+62+Value getblocknumber(const Array& params)63+{64+ if (params.size() != 0)65+ throw runtime_error(66+ "getblocknumber (no parameters)\n"67+ "Returns the block number of the latest block in the longest block chain.");68+69+ return nBestHeight;70+}71+72+73+Value getdifficulty(const Array& params)74+{75+ if (params.size() != 0)76+ throw runtime_error(77+ "getdifficulty (no parameters)\n"78+ "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");79+80+ if (pindexBest == NULL)81+ throw runtime_error("block chain not loaded");82+83+ // Floating point number that is a multiple of the minimum difficulty,84+ // minimum difficulty = 1.0.85+ int nShift = 256 - 32 - 31; // to fit in a uint86+ double dMinimum = (CBigNum().SetCompact(bnProofOfWorkLimit.GetCompact()) >> nShift).getuint();87+ double dCurrently = (CBigNum().SetCompact(pindexBest->nBits) >> nShift).getuint();88+ return dMinimum / dCurrently;89+}90+91+92+Value getnewaddress(const Array& params)93+{94+ if (params.size() > 1)95+ throw runtime_error(96+ "getnewaddress [label]\n"97+ "Returns a new bitcoin address for receiving payments. "98+ "If [label] is specified (recommended), it is added to the address book "99+ "so payments received with the address will be labeled.");100+101+ // Parse the label first so we don't generate a key if there's an error102+ string strLabel;103+ if (params.size() > 0)104+ strLabel = params[0].get_str();105+106+ // Generate a new key that is added to wallet107+ string strAddress = PubKeyToAddress(GenerateNewKey());108+109+ if (params.size() > 0)110+ SetAddressBookName(strAddress, strLabel);111+ return strAddress;112+}113+114+115+Value sendtoaddress(const Array& params)116+{117+ if (params.size() < 2 || params.size() > 4)118+ throw runtime_error(119+ "sendtoaddress <bitcoinaddress> <amount> [comment] [comment-to]\n"120+ "<amount> is a real and is rounded to the nearest 0.01");121+122+ string strAddress = params[0].get_str();123+124+ // Amount125+ if (params[1].get_real() <= 0.0 || params[1].get_real() > 21000000.0)126+ throw runtime_error("Invalid amount");127+ int64 nAmount = roundint64(params[1].get_real() * 100.00) * CENT;128+129+ // Wallet comments130+ CWalletTx wtx;131+ if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty())132+ wtx.mapValue["message"] = params[2].get_str();133+ if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())134+ wtx.mapValue["to"] = params[3].get_str();135+136+ string strError = SendMoneyToBitcoinAddress(strAddress, nAmount, wtx);137+ if (strError != "")138+ throw runtime_error(strError);139+ return "sent";140+}141+142+143+Value listtransactions(const Array& params)144+{145+ if (params.size() > 2)146+ throw runtime_error(147+ "listtransactions [count=10] [includegenerated=false]\n"148+ "Returns up to [count] most recent transactions.");149+150+ int64 nCount = 10;151+ if (params.size() > 0)152+ nCount = params[0].get_int64();153+ bool fGenerated = false;154+ if (params.size() > 1)155+ fGenerated = params[1].get_bool();156+157+ Array ret;158+ //// not finished159+ ret.push_back("not implemented yet");160+ return ret;161+}162+163+164+Value getamountreceived(const Array& params)165+{166+ if (params.size() < 1 || params.size() > 2)167+ throw runtime_error(168+ "getamountreceived <bitcoinaddress> [minconf=1]\n"169+ "Returns the total amount received by <bitcoinaddress> in transactions with at least [minconf] confirmations.");170+171+ // Bitcoin address172+ string strAddress = params[0].get_str();173+ CScript scriptPubKey;174+ if (!scriptPubKey.SetBitcoinAddress(strAddress))175+ throw runtime_error("Invalid bitcoin address");176+177+ // Minimum confirmations178+ int nMinDepth = 1;179+ if (params.size() > 1)180+ nMinDepth = params[1].get_int();181+182+ // Tally183+ int64 nAmount = 0;184+ CRITICAL_BLOCK(cs_mapWallet)185+ {186+ for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)187+ {188+ const CWalletTx& wtx = (*it).second;189+ if (wtx.IsCoinBase() || !wtx.IsFinal())190+ continue;191+192+ foreach(const CTxOut& txout, wtx.vout)193+ if (txout.scriptPubKey == scriptPubKey)194+ if (wtx.GetDepthInMainChain() >= nMinDepth)195+ nAmount += txout.nValue;196+ }197+ }198+199+ return (double)nAmount / (double)COIN;200+}201+202+203+struct tallyitem204+{205+ int64 nAmount;206+ int nConf;207+ tallyitem()208+ {209+ nAmount = 0;210+ nConf = INT_MAX;211+ }212+};213+214+Value getallreceived(const Array& params)215+{216+ if (params.size() > 1)217+ throw runtime_error(218+ "getallreceived [minconf=1]\n"219+ "[minconf] is the minimum number of confirmations before payments are included.\n"220+ "Returns an array of objects containing:\n"221+ " \"address\" : bitcoin address\n"222+ " \"amount\" : total amount received by the address\n"223+ " \"conf\" : number of confirmations\n"224+ " \"label\" : the label set for this address when it was created by getnewaddress");225+226+ // Minimum confirmations227+ int nMinDepth = 1;228+ if (params.size() > 0)229+ nMinDepth = params[0].get_int();230+231+ // Tally232+ map<uint160, tallyitem> mapTally;233+ CRITICAL_BLOCK(cs_mapWallet)234+ {235+ for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)236+ {237+ const CWalletTx& wtx = (*it).second;238+ if (wtx.IsCoinBase() || !wtx.IsFinal())239+ continue;240+241+ int nDepth = wtx.GetDepthInMainChain();242+ if (nDepth >= nMinDepth)243+ {244+ foreach(const CTxOut& txout, wtx.vout)245+ {246+ uint160 hash160 = txout.scriptPubKey.GetBitcoinAddressHash160();247+ if (hash160 == 0 || !mapPubKeys.count(hash160))248+ continue;249+250+ tallyitem& item = mapTally[hash160];251+ item.nAmount += txout.nValue;252+ item.nConf = min(item.nConf, nDepth);253+ }254+ }255+ }256+ }257+258+ // Reply259+ Array ret;260+ CRITICAL_BLOCK(cs_mapAddressBook)261+ {262+ for (map<uint160, tallyitem>::iterator it = mapTally.begin(); it != mapTally.end(); ++it)263+ {264+ string strAddress = Hash160ToAddress((*it).first);265+ string strLabel;266+ map<string, string>::iterator mi = mapAddressBook.find(strAddress);267+ if (mi != mapAddressBook.end())268+ strLabel = (*mi).second;269+270+ Object obj;271+ obj.push_back(Pair("address", strAddress));272+ obj.push_back(Pair("amount", (double)(*it).second.nAmount / (double)COIN));273+ obj.push_back(Pair("conf", (*it).second.nConf));274+ obj.push_back(Pair("label", strLabel));275+ ret.push_back(obj);276+ }277+ }278+ return ret;279+}280+281+282+283+284+285+286+287+//288+// Call Table289+//290+291+typedef Value(*rpcfn_type)(const Array& params);292+pair<string, rpcfn_type> pCallTable[] =293+{294+ make_pair("stop", &stop),295+ make_pair("getblockcount", &getblockcount),296+ make_pair("getblocknumber", &getblocknumber),297+ make_pair("getdifficulty", &getdifficulty),298+ make_pair("getnewaddress", &getnewaddress),299+ make_pair("sendtoaddress", &sendtoaddress),300+ make_pair("listtransactions", &listtransactions),301+ make_pair("getamountreceived", &getamountreceived),302+ make_pair("getallreceived", &getallreceived),303+};304+map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));305+306+307+308+309+//310+// HTTP protocol311+//312+// This ain't Apache. We're just using HTTP header for the length field313+// and to be compatible with other JSON-RPC implementations.314+//315+316+string HTTPPost(const string& strMsg)317+{318+ return strprintf(319+ "POST / HTTP/1.1\r\n"320+ "User-Agent: json-rpc/1.0\r\n"321+ "Host: 127.0.0.1\r\n"322+ "Content-Type: application/json\r\n"323+ "Content-Length: %d\r\n"324+ "Accept: application/json\r\n"325+ "\r\n"326+ "%s",327+ strMsg.size(),328+ strMsg.c_str());329+}330+331+string HTTPReply(const string& strMsg, int nStatus=200)332+{333+ string strStatus;334+ if (nStatus == 200) strStatus = "OK";335+ if (nStatus == 500) strStatus = "Internal Server Error";336+ return strprintf(337+ "HTTP/1.1 %d %s\r\n"338+ "Connection: close\r\n"339+ "Content-Length: %d\r\n"340+ "Content-Type: application/json\r\n"341+ "Date: Sat, 08 Jul 2006 12:04:08 GMT\r\n"342+ "Server: json-rpc/1.0\r\n"343+ "\r\n"344+ "%s",345+ nStatus,346+ strStatus.c_str(),347+ strMsg.size(),348+ strMsg.c_str());349+}350+351+int ReadHTTPHeader(tcp::iostream& stream)352+{353+ int nLen = 0;354+ loop355+ {356+ string str;357+ std::getline(stream, str);358+ if (str.empty() || str == "\r")359+ break;360+ if (str.substr(0,15) == "Content-Length:")361+ nLen = atoi(str.substr(15));362+ }363+ return nLen;364+}365+366+inline string ReadHTTP(tcp::iostream& stream)367+{368+ // Read header369+ int nLen = ReadHTTPHeader(stream);370+ if (nLen <= 0)371+ return string();372+373+ // Read message374+ vector<char> vch(nLen);375+ stream.read(&vch[0], nLen);376+ return string(vch.begin(), vch.end());377+}378+379+380+381+//382+// JSON-RPC protocol383+//384+// http://json-rpc.org/wiki/specification385+// http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx386+//387+388+string JSONRPCRequest(const string& strMethod, const Array& params, const Value& id)389+{390+ Object request;391+ request.push_back(Pair("method", strMethod));392+ request.push_back(Pair("params", params));393+ request.push_back(Pair("id", id));394+ return write_string(Value(request), false) + "\n";395+}396+397+string JSONRPCReply(const Value& result, const Value& error, const Value& id)398+{399+ Object reply;400+ if (error.type() != null_type)401+ reply.push_back(Pair("result", Value::null));402+ else403+ reply.push_back(Pair("result", result));404+ reply.push_back(Pair("error", error));405+ reply.push_back(Pair("id", id));406+ return write_string(Value(reply), false) + "\n";407+}408+409+410+411+412+void ThreadRPCServer(void* parg)413+{414+ IMPLEMENT_RANDOMIZE_STACK(ThreadRPCServer(parg));415+ try416+ {417+ vnThreadsRunning[4]++;418+ ThreadRPCServer2(parg);419+ vnThreadsRunning[4]--;420+ }421+ catch (std::exception& e) {422+ vnThreadsRunning[4]--;423+ PrintException(&e, "ThreadRPCServer()");424+ } catch (...) {425+ vnThreadsRunning[4]--;426+ PrintException(NULL, "ThreadRPCServer()");427+ }428+ printf("ThreadRPCServer exiting\n");429+}430+431+void ThreadRPCServer2(void* parg)432+{433+ printf("ThreadRPCServer started\n");434+435+ // Bind to loopback 127.0.0.1 so the socket can only be accessed locally436+ boost::asio::io_service io_service;437+ tcp::endpoint endpoint(boost::asio::ip::address_v4::loopback(), 8332);438+ tcp::acceptor acceptor(io_service, endpoint);439+440+ loop441+ {442+ // Accept connection443+ tcp::iostream stream;444+ tcp::endpoint peer;445+ vnThreadsRunning[4]--;446+ acceptor.accept(*stream.rdbuf(), peer);447+ vnThreadsRunning[4]++;448+ if (fShutdown)449+ return;450+451+ // Shouldn't be possible for anyone else to connect, but just in case452+ if (peer.address().to_string() != "127.0.0.1")453+ continue;454+455+ // Receive request456+ string strRequest = ReadHTTP(stream);457+ printf("ThreadRPCServer request=%s", strRequest.c_str());458+459+ // Handle multiple invocations per request460+ string::iterator begin = strRequest.begin();461+ while (skipspaces(begin), begin != strRequest.end())462+ {463+ string::iterator prev = begin;464+ Value id;465+ try466+ {467+ // Parse request468+ Value valRequest;469+ if (!read_range(begin, strRequest.end(), valRequest))470+ throw runtime_error("Parse error.");471+ const Object& request = valRequest.get_obj();472+ if (find_value(request, "method").type() != str_type ||473+ find_value(request, "params").type() != array_type)474+ throw runtime_error("Invalid request.");475+476+ string strMethod = find_value(request, "method").get_str();477+ const Array& params = find_value(request, "params").get_array();478+ id = find_value(request, "id");479+480+ // Execute481+ map<string, rpcfn_type>::iterator mi = mapCallTable.find(strMethod);482+ if (mi == mapCallTable.end())483+ throw runtime_error("Method not found.");484+ Value result = (*(*mi).second)(params);485+486+ // Send reply487+ string strReply = JSONRPCReply(result, Value::null, id);488+ stream << HTTPReply(strReply, 200) << std::flush;489+ }490+ catch (std::exception& e)491+ {492+ // Send error reply493+ string strReply = JSONRPCReply(Value::null, e.what(), id);494+ stream << HTTPReply(strReply, 500) << std::flush;495+ }496+ if (begin == prev)497+ break;498+ }499+ }500+}501+502+503+504+505+Value CallRPC(const string& strMethod, const Array& params)506+{507+ // Connect to localhost508+ tcp::iostream stream("127.0.0.1", "8332");509+ if (stream.fail())510+ throw runtime_error("couldn't connect to server");511+512+ // Send request513+ string strRequest = JSONRPCRequest(strMethod, params, 1);514+ stream << HTTPPost(strRequest) << std::flush;515+516+ // Receive reply517+ string strReply = ReadHTTP(stream);518+ if (strReply.empty())519+ throw runtime_error("no response from server");520+521+ // Parse reply522+ Value valReply;523+ if (!read_string(strReply, valReply))524+ throw runtime_error("couldn't parse reply from server");525+ const Object& reply = valReply.get_obj();526+ if (reply.empty())527+ throw runtime_error("expected reply to have result, error and id properties");528+529+ const Value& result = find_value(reply, "result");530+ const Value& error = find_value(reply, "error");531+ const Value& id = find_value(reply, "id");532+533+ if (error.type() == str_type)534+ throw runtime_error(error.get_str());535+ else if (error.type() != null_type)536+ throw runtime_error(write_string(error, false));537+ return result;538+}539+540+541+542+543+template<typename T>544+void ConvertTo(Value& value)545+{546+ if (value.type() == str_type)547+ {548+ // reinterpret string as unquoted json value549+ Value value2;550+ if (!read_string(value.get_str(), value2))551+ throw runtime_error("type mismatch");552+ value = value2.get_value<T>();553+ }554+ else555+ {556+ value = value.get_value<T>();557+ }558+}559+560+int CommandLineRPC(int argc, char *argv[])561+{562+ try563+ {564+ // Check that method exists565+ if (argc < 2)566+ throw runtime_error("too few parameters");567+ string strMethod = argv[1];568+ if (!mapCallTable.count(strMethod))569+ throw runtime_error(strprintf("unknown command: %s", strMethod.c_str()));570+571+ // Parameters default to strings572+ Array params;573+ for (int i = 2; i < argc; i++)574+ params.push_back(argv[i]);575+576+ // Special case other types577+ int n = params.size();578+ if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);579+ if (strMethod == "listtransactions" && n > 0) ConvertTo<boost::int64_t>(params[0]);580+ if (strMethod == "listtransactions" && n > 1) ConvertTo<bool>(params[1]);581+ if (strMethod == "getamountreceived" && n > 1) ConvertTo<boost::int64_t>(params[1]);582+ if (strMethod == "getallreceived" && n > 0) ConvertTo<boost::int64_t>(params[0]);583+584+ // Execute585+ Value result = CallRPC(strMethod, params);586+587+ // Print result588+ string strResult = (result.type() == str_type ? result.get_str() : write_string(result, true));589+ if (result.type() != null_type)590+ {591+ if (fWindows)592+ // Windows GUI apps can't print to command line,593+ // so for now settle for a message box yuck594+ wxMessageBox(strResult.c_str(), "Bitcoin", wxOK);595+ else596+ fprintf(stdout, "%s\n", strResult.c_str());597+ }598+ return 0;599+ }600+ catch (std::exception& e) {601+ if (fWindows)602+ wxMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);603+ else604+ fprintf(stderr, "error: %s\n", e.what());605+ } catch (...) {606+ PrintException(NULL, "CommandLineRPC()");607+ }608+ return 1;609+}610+611+612+613+614+#ifdef TEST615+int main(int argc, char *argv[])616+{617+#ifdef _MSC_VER618+ // Turn off microsoft heap dump noise619+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);620+ _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));621+#endif622+ setbuf(stdin, NULL);623+ setbuf(stdout, NULL);624+ setbuf(stderr, NULL);625+626+ try627+ {628+ if (argc >= 2 && string(argv[1]) == "-server")629+ {630+ printf("server ready\n");631+ ThreadRPCServer(NULL);632+ }633+ else634+ {635+ return CommandLineRPC(argc, argv);636+ }637+ }638+ catch (std::exception& e) {639+ PrintException(&e, "main()");640+ } catch (...) {641+ PrintException(NULL, "main()");642+ }643+ return 0;644+}645+#endif646+
rpc.h (added)
1--- /dev/null2+++ v0.2.2/rpc.h3@@ -1 +1,7 @@4+// Copyright (c) 2010 Satoshi Nakamoto5+// Distributed under the MIT/X11 software license, see the accompanying6+// file license.txt or http://www.opensource.org/licenses/mit-license.php.7 8+void ThreadRPCServer(void* parg);9+int CommandLineRPC(int argc, char *argv[]);10+
script.cpp (modified)
1--- v0.2.0/script.cpp2+++ v0.2.2/script.cpp3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -660,7 +660,7 @@10 if (stack.size() < 1)11 return false;12 valtype& vch = stacktop(-1);13- valtype vchHash(opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160 ? 20 : 32);14+ valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32);15 if (opcode == OP_RIPEMD160)16 RIPEMD160(&vch[0], vch.size(), &vchHash[0]);17 else if (opcode == OP_SHA1)18@@ -753,9 +753,9 @@19 CScript scriptCode(pbegincodehash, pend);20 21 // Drop the signatures, since there's no way for a signature to sign itself22- for (int i = 0; i < nSigsCount; i++)23- {24- valtype& vchSig = stacktop(-isig-i);25+ for (int k = 0; k < nSigsCount; k++)26+ {27+ valtype& vchSig = stacktop(-isig-k);28 scriptCode.FindAndDelete(CScript(vchSig));29 }30 31@@ -909,7 +909,6 @@32 33 34 35-36 bool Solver(const CScript& scriptPubKey, vector<pair<opcodetype, valtype> >& vSolutionRet)37 {38 // Templates39@@ -919,7 +918,7 @@40 // Standard tx, sender provides pubkey, receiver adds signature41 vTemplates.push_back(CScript() << OP_PUBKEY << OP_CHECKSIG);42 43- // Short account number tx, sender provides hash of pubkey, receiver provides signature and pubkey44+ // Bitcoin address tx, sender provides hash of pubkey, receiver provides signature and pubkey45 vTemplates.push_back(CScript() << OP_DUP << OP_HASH160 << OP_PUBKEYHASH << OP_EQUALVERIFY << OP_CHECKSIG);46 }47 48@@ -1123,6 +1122,14 @@49 if (txin.prevout.hash != txFrom.GetHash())50 return false;51 52- return EvalScript(txin.scriptSig + CScript(OP_CODESEPARATOR) + txout.scriptPubKey, txTo, nIn, nHashType);53+ if (!EvalScript(txin.scriptSig + CScript(OP_CODESEPARATOR) + txout.scriptPubKey, txTo, nIn, nHashType))54+ return false;55+56+ // Anytime a signature is successfully verified, it's proof the outpoint is spent,57+ // so lets update the wallet spent flag if it doesn't know due to wallet.dat being58+ // restored from backup or the user making copies of wallet.dat.59+ WalletUpdateSpent(txin.prevout);60+61+ return true;62 }63
script.h (modified)
1--- v0.2.0/script.h2+++ v0.2.2/script.h3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -472,7 +472,7 @@10 11 bool GetOp(iterator& pc, opcodetype& opcodeRet, vector<unsigned char>& vchRet)12 {13- // This is why people hate C++14+ // Wrapper so it can be called with either iterator or const_iterator15 const_iterator pc2 = pc;16 bool fRet = GetOp(pc2, opcodeRet, vchRet);17 pc = begin() + (pc2 - begin());18@@ -551,6 +551,46 @@19 }20 21 22+ uint160 GetBitcoinAddressHash160() const23+ {24+ opcodetype opcode;25+ vector<unsigned char> vch;26+ CScript::const_iterator pc = begin();27+ if (!GetOp(pc, opcode, vch) || opcode != OP_DUP) return 0;28+ if (!GetOp(pc, opcode, vch) || opcode != OP_HASH160) return 0;29+ if (!GetOp(pc, opcode, vch) || vch.size() != sizeof(uint160)) return 0;30+ uint160 hash160 = uint160(vch);31+ if (!GetOp(pc, opcode, vch) || opcode != OP_EQUALVERIFY) return 0;32+ if (!GetOp(pc, opcode, vch) || opcode != OP_CHECKSIG) return 0;33+ if (pc != end()) return 0;34+ return hash160;35+ }36+37+ string GetBitcoinAddress() const38+ {39+ uint160 hash160 = GetBitcoinAddressHash160();40+ if (hash160 == 0)41+ return "";42+ return Hash160ToAddress(hash160);43+ }44+45+ void SetBitcoinAddress(const uint160& hash160)46+ {47+ this->clear();48+ *this << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;49+ }50+51+ bool SetBitcoinAddress(const string& strAddress)52+ {53+ this->clear();54+ uint160 hash160;55+ if (!AddressToHash160(strAddress, hash160))56+ return false;57+ SetBitcoinAddress(hash160);58+ return true;59+ }60+61+62 void PrintHex() const63 {64 printf("CScript(%s)\n", HexStr(begin(), end()).c_str());
serialize.h (modified)
1--- v0.2.0/serialize.h2+++ v0.2.2/serialize.h3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -19,8 +19,8 @@10 class CDataStream;11 class CAutoFile;12 13-static const int VERSION = 200;14-static const char* pszSubVer = " rc2";15+static const int VERSION = 202;16+static const char* pszSubVer = ".0";17 18 19 20@@ -194,28 +194,32 @@21 {22 unsigned char chSize;23 READDATA(is, chSize);24+ uint64 nSizeRet = 0;25 if (chSize < UCHAR_MAX-2)26 {27- return chSize;28+ nSizeRet = chSize;29 }30 else if (chSize == UCHAR_MAX-2)31 {32 unsigned short nSize;33 READDATA(is, nSize);34- return nSize;35+ nSizeRet = nSize;36 }37 else if (chSize == UCHAR_MAX-1)38 {39 unsigned int nSize;40 READDATA(is, nSize);41- return nSize;42+ nSizeRet = nSize;43 }44 else45 {46 uint64 nSize;47 READDATA(is, nSize);48- return nSize;49- }50+ nSizeRet = nSize;51+ }52+ if (nSizeRet > (uint64)INT_MAX)53+ throw std::ios_base::failure("ReadCompactSize() : size too large");54+ return nSizeRet;55 }56 57 58@@ -460,7 +464,7 @@59 unsigned int i = 0;60 while (i < nSize)61 {62- unsigned int blk = min(nSize - i, 1 + 4999999 / sizeof(T));63+ unsigned int blk = min(nSize - i, (unsigned int)(1 + 4999999 / sizeof(T)));64 v.resize(i + blk);65 is.read((char*)&v[i], blk * sizeof(T));66 i += blk;
ui.cpp (modified)
1--- v0.2.0/ui.cpp2+++ v0.2.2/ui.cpp3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -7,23 +7,15 @@10 #include <crtdbg.h>11 #endif12 13-void ThreadRequestProductDetails(void* parg);14-void ThreadRandSendTest(void* parg);15 bool GetStartOnSystemStartup();16 void SetStartOnSystemStartup(bool fAutoStart);17 18 19 20 DEFINE_EVENT_TYPE(wxEVT_UITHREADCALL)21-DEFINE_EVENT_TYPE(wxEVT_REPLY1)22-DEFINE_EVENT_TYPE(wxEVT_REPLY2)23-DEFINE_EVENT_TYPE(wxEVT_REPLY3)24 25 CMainFrame* pframeMain = NULL;26 CMyTaskBarIcon* ptaskbaricon = NULL;27-map<string, string> mapAddressBook;28-bool fRandSendTest = false;29-void RandSend();30 extern int g_isPainting;31 bool fClosedToTray = false;32 33@@ -134,7 +126,6 @@34 return -1;35 }36 37-38 string HtmlEscape(const char* psz, bool fMultiLine=false)39 {40 int len = 0;41@@ -170,18 +161,6 @@42 return HtmlEscape(str.c_str(), fMultiLine);43 }44 45-void AddToMyProducts(CProduct product)46-{47- CProduct& productInsert = mapMyProducts[product.GetHash()];48- productInsert = product;49- InsertLine(pframeMain->m_listCtrlProductsSent, &productInsert,50- product.mapValue["category"],51- product.mapValue["title"].substr(0, 100),52- product.mapValue["description"].substr(0, 100),53- product.mapValue["price"],54- "");55-}56-57 void CalledMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y, int* pnRet, bool* pfDone)58 {59 *pnRet = wxMessageBox(message, caption, style, parent, x, y);60@@ -190,6 +169,12 @@61 62 int ThreadSafeMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y)63 {64+ if (fDaemon)65+ {66+ printf("wxMessageBox %s: %s\n", caption.c_str(), message.c_str());67+ return wxOK;68+ }69+70 #ifdef __WXMSW__71 return wxMessageBox(message, caption, style, parent, x, y);72 #else73@@ -211,90 +196,6 @@74 75 76 77-78-79-80-81-82-83-84-//////////////////////////////////////////////////////////////////////////////85-//86-// Custom events87-//88-// If this code gets used again, it should be replaced with something like UIThreadCall89-90-set<void*> setCallbackAvailable;91-CCriticalSection cs_setCallbackAvailable;92-93-void AddCallbackAvailable(void* p)94-{95- CRITICAL_BLOCK(cs_setCallbackAvailable)96- setCallbackAvailable.insert(p);97-}98-99-void RemoveCallbackAvailable(void* p)100-{101- CRITICAL_BLOCK(cs_setCallbackAvailable)102- setCallbackAvailable.erase(p);103-}104-105-bool IsCallbackAvailable(void* p)106-{107- CRITICAL_BLOCK(cs_setCallbackAvailable)108- return setCallbackAvailable.count(p);109- return false;110-}111-112-template<typename T>113-void AddPendingCustomEvent(wxEvtHandler* pevthandler, int nEventID, const T pbeginIn, const T pendIn)114-{115- if (!pevthandler)116- return;117-118- const char* pbegin = (pendIn != pbeginIn) ? &pbeginIn[0] : NULL;119- const char* pend = pbegin + (pendIn - pbeginIn) * sizeof(pbeginIn[0]);120- wxCommandEvent event(nEventID);121- wxString strData(wxChar(0), (pend - pbegin) / sizeof(wxChar) + 1);122- memcpy(&strData[0], pbegin, pend - pbegin);123- event.SetString(strData);124- event.SetInt(pend - pbegin);125-126- pevthandler->AddPendingEvent(event);127-}128-129-template<class T>130-void AddPendingCustomEvent(wxEvtHandler* pevthandler, int nEventID, const T& obj)131-{132- CDataStream ss;133- ss << obj;134- AddPendingCustomEvent(pevthandler, nEventID, ss.begin(), ss.end());135-}136-137-void AddPendingReplyEvent1(void* pevthandler, CDataStream& vRecv)138-{139- if (IsCallbackAvailable(pevthandler))140- AddPendingCustomEvent((wxEvtHandler*)pevthandler, wxEVT_REPLY1, vRecv.begin(), vRecv.end());141-}142-143-void AddPendingReplyEvent2(void* pevthandler, CDataStream& vRecv)144-{145- if (IsCallbackAvailable(pevthandler))146- AddPendingCustomEvent((wxEvtHandler*)pevthandler, wxEVT_REPLY2, vRecv.begin(), vRecv.end());147-}148-149-void AddPendingReplyEvent3(void* pevthandler, CDataStream& vRecv)150-{151- if (IsCallbackAvailable(pevthandler))152- AddPendingCustomEvent((wxEvtHandler*)pevthandler, wxEVT_REPLY3, vRecv.begin(), vRecv.end());153-}154-155-CDataStream GetStreamFromEvent(const wxCommandEvent& event)156-{157- wxString strData = event.GetString();158- const char* pszBegin = strData.c_str();159- return CDataStream(pszBegin, pszBegin + event.GetInt(), SER_NETWORK);160-}161 162 163 164@@ -328,13 +229,12 @@165 m_staticTextBalance->SetSize(140, 17);166 // & underlines don't work on the toolbar buttons on gtk167 m_toolBar->ClearTools();168- m_toolBar->AddTool(wxID_BUTTONSEND, "Send Coins", wxBitmap(send20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);169- m_toolBar->AddTool(wxID_BUTTONRECEIVE, "Address Book", wxBitmap(addressbook20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);170+ m_toolBar->AddTool(wxID_BUTTONSEND, _("Send Coins"), wxBitmap(send20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);171+ m_toolBar->AddTool(wxID_BUTTONRECEIVE, _("Address Book"), wxBitmap(addressbook20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);172 m_toolBar->Realize();173 // resize to fit ubuntu's huge default font174- dResize = 1.19;175- SetSize(dResize * GetSize().GetWidth(), 1.1 * GetSize().GetHeight());176 dResize = 1.20;177+ SetSize((dResize + 0.02) * GetSize().GetWidth(), 1.09 * GetSize().GetHeight());178 #endif179 m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " ");180 m_listCtrl->SetFocus();181@@ -344,31 +244,13 @@182 int nDateWidth = DateTimeStr(1229413914).size() * 6 + 8;183 if (!strstr(DateTimeStr(1229413914).c_str(), "2008"))184 nDateWidth += 12;185- m_listCtrl->InsertColumn(0, "", wxLIST_FORMAT_LEFT, dResize * 0);186- m_listCtrl->InsertColumn(1, "", wxLIST_FORMAT_LEFT, dResize * 0);187- m_listCtrl->InsertColumn(2, "Status", wxLIST_FORMAT_LEFT, dResize * 90);188- m_listCtrl->InsertColumn(3, "Date", wxLIST_FORMAT_LEFT, dResize * nDateWidth);189- m_listCtrl->InsertColumn(4, "Description", wxLIST_FORMAT_LEFT, dResize * 409 - nDateWidth);190- m_listCtrl->InsertColumn(5, "Debit", wxLIST_FORMAT_RIGHT, dResize * 79);191- m_listCtrl->InsertColumn(6, "Credit", wxLIST_FORMAT_RIGHT, dResize * 79);192-193- //m_listCtrlProductsSent->InsertColumn(0, "Category", wxLIST_FORMAT_LEFT, 100);194- //m_listCtrlProductsSent->InsertColumn(1, "Title", wxLIST_FORMAT_LEFT, 100);195- //m_listCtrlProductsSent->InsertColumn(2, "Description", wxLIST_FORMAT_LEFT, 100);196- //m_listCtrlProductsSent->InsertColumn(3, "Price", wxLIST_FORMAT_LEFT, 100);197- //m_listCtrlProductsSent->InsertColumn(4, "", wxLIST_FORMAT_LEFT, 100);198-199- //m_listCtrlOrdersSent->InsertColumn(0, "Time", wxLIST_FORMAT_LEFT, 100);200- //m_listCtrlOrdersSent->InsertColumn(1, "Price", wxLIST_FORMAT_LEFT, 100);201- //m_listCtrlOrdersSent->InsertColumn(2, "", wxLIST_FORMAT_LEFT, 100);202- //m_listCtrlOrdersSent->InsertColumn(3, "", wxLIST_FORMAT_LEFT, 100);203- //m_listCtrlOrdersSent->InsertColumn(4, "", wxLIST_FORMAT_LEFT, 100);204-205- //m_listCtrlOrdersReceived->InsertColumn(0, "Time", wxLIST_FORMAT_LEFT, 100);206- //m_listCtrlOrdersReceived->InsertColumn(1, "Price", wxLIST_FORMAT_LEFT, 100);207- //m_listCtrlOrdersReceived->InsertColumn(2, "Payment Status", wxLIST_FORMAT_LEFT, 100);208- //m_listCtrlOrdersReceived->InsertColumn(3, "", wxLIST_FORMAT_LEFT, 100);209- //m_listCtrlOrdersReceived->InsertColumn(4, "", wxLIST_FORMAT_LEFT, 100);210+ m_listCtrl->InsertColumn(0, "", wxLIST_FORMAT_LEFT, dResize * 0);211+ m_listCtrl->InsertColumn(1, "", wxLIST_FORMAT_LEFT, dResize * 0);212+ m_listCtrl->InsertColumn(2, _("Status"), wxLIST_FORMAT_LEFT, dResize * 110);213+ m_listCtrl->InsertColumn(3, _("Date"), wxLIST_FORMAT_LEFT, dResize * nDateWidth);214+ m_listCtrl->InsertColumn(4, _("Description"), wxLIST_FORMAT_LEFT, dResize * 409 - nDateWidth);215+ m_listCtrl->InsertColumn(5, _("Debit"), wxLIST_FORMAT_RIGHT, dResize * 79);216+ m_listCtrl->InsertColumn(6, _("Credit"), wxLIST_FORMAT_RIGHT, dResize * 79);217 218 // Init status bar219 int pnWidths[3] = { -100, 88, 290 };220@@ -421,7 +303,7 @@221 StopNode();222 DBFlush(true);223 CreateThread(ExitTimeout, NULL);224- Sleep(10);225+ Sleep(50);226 printf("Bitcoin exiting\n\n");227 fExit = true;228 exit(0);229@@ -455,6 +337,8 @@230 {231 // Hide the task bar button when minimized.232 // Event is sent when the frame is minimized or restored.233+ // wxWidgets 2.8.9 doesn't have IsIconized() so there's no way234+ // to get rid of the deprecated warning. Just ignore it.235 if (!event.Iconized())236 fClosedToTray = false;237 #ifndef __WXMSW__238@@ -507,33 +391,34 @@239 240 void CMainFrame::InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5, const wxString& str6)241 {242- string str0 = strSort;243- long nData = *(long*)&hashKey;244+ strSort = " " + strSort; // leading space to workaround wx2.9.0 ubuntu 9.10 bug245+ long nData = *(long*)&hashKey; // where first char of hidden column is displayed246 247 // Find item248 if (!fNew && nIndex == -1)249 {250+ string strHash = " " + hashKey.ToString();251 while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)252- if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString())253+ if (GetItemText(m_listCtrl, nIndex, 1) == strHash)254 break;255 }256 257 // fNew is for blind insert, only use if you're sure it's new258 if (fNew || nIndex == -1)259 {260- nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), str0);261+ nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), strSort);262 }263 else264 {265 // If sort key changed, must delete and reinsert to make it relocate266- if (GetItemText(m_listCtrl, nIndex, 0) != str0)267+ if (GetItemText(m_listCtrl, nIndex, 0) != strSort)268 {269 m_listCtrl->DeleteItem(nIndex);270- nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), str0);271- }272- }273-274- m_listCtrl->SetItem(nIndex, 1, hashKey.ToString());275+ nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), strSort);276+ }277+ }278+279+ m_listCtrl->SetItem(nIndex, 1, " " + hashKey.ToString());280 m_listCtrl->SetItem(nIndex, 2, str2);281 m_listCtrl->SetItem(nIndex, 3, str3);282 m_listCtrl->SetItem(nIndex, 4, str4);283@@ -548,8 +433,9 @@284 285 // Find item286 int nIndex = -1;287+ string strHash = " " + hashKey.ToString();288 while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)289- if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString())290+ if (GetItemText(m_listCtrl, nIndex, 1) == strHash)291 break;292 293 if (nIndex != -1)294@@ -564,19 +450,19 @@295 if (!wtx.IsFinal())296 {297 if (wtx.nLockTime < 500000000)298- return strprintf("Open for %d blocks", nBestHeight - wtx.nLockTime);299+ return strprintf(_("Open for %d blocks"), nBestHeight - wtx.nLockTime);300 else301- return strprintf("Open until %s", DateTimeStr(wtx.nLockTime).c_str());302+ return strprintf(_("Open until %s"), DateTimeStr(wtx.nLockTime).c_str());303 }304 else305 {306 int nDepth = wtx.GetDepthInMainChain();307 if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)308- return strprintf("%d/offline?", nDepth);309+ return strprintf(_("%d/offline?"), nDepth);310 else if (nDepth < 6)311- return strprintf("%d/unconfirmed", nDepth);312+ return strprintf(_("%d/unconfirmed"), nDepth);313 else314- return strprintf("%d blocks", nDepth);315+ return strprintf(_("%d confirmations"), nDepth);316 }317 }318 319@@ -661,7 +547,7 @@320 if (wtx.IsCoinBase())321 {322 // Coinbase323- strDescription = "Generated";324+ strDescription = _("Generated");325 if (nCredit == 0)326 {327 int64 nUnmatured = 0;328@@ -669,15 +555,15 @@329 nUnmatured += txout.GetCredit();330 if (wtx.IsInMainChain())331 {332- strDescription = strprintf("Generated (%s matures in %d more blocks)", FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());333+ strDescription = strprintf(_("Generated (%s matures in %d more blocks)"), FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());334 335 // Check if the block was requested by anyone336 if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)337- strDescription = "Generated - Warning: This block was not received by any other nodes and will probably not be accepted!";338+ strDescription = _("Generated - Warning: This block was not received by any other nodes and will probably not be accepted!");339 }340 else341 {342- strDescription = "Generated (not accepted)";343+ strDescription = _("Generated (not accepted)");344 }345 }346 }347@@ -685,7 +571,7 @@348 {349 // Online transaction350 if (!mapValue["from"].empty())351- strDescription += "From: " + mapValue["from"];352+ strDescription += _("From: ") + mapValue["from"];353 if (!mapValue["message"].empty())354 {355 if (!strDescription.empty())356@@ -703,19 +589,22 @@357 vector<unsigned char> vchPubKey;358 if (ExtractPubKey(txout.scriptPubKey, true, vchPubKey))359 {360- string strAddress = PubKeyToAddress(vchPubKey);361- if (mapAddressBook.count(strAddress))362+ CRITICAL_BLOCK(cs_mapAddressBook)363 {364- //strDescription += "Received payment to ";365- //strDescription += "Received with address ";366- strDescription += "From: unknown, To: ";367- strDescription += strAddress;368- /// The labeling feature is just too confusing, so I hid it369- /// by putting it at the end where it runs off the screen.370- /// It can still be seen by widening the column, or in the371- /// details dialog.372- if (!mapAddressBook[strAddress].empty())373- strDescription += " (" + mapAddressBook[strAddress] + ")";374+ string strAddress = PubKeyToAddress(vchPubKey);375+ if (mapAddressBook.count(strAddress))376+ {377+ //strDescription += _("Received payment to ");378+ //strDescription += _("Received with address ");379+ strDescription += _("From: unknown, To: ");380+ strDescription += strAddress;381+ /// The labeling feature is just too confusing, so I hid it382+ /// by putting it at the end where it runs off the screen.383+ /// It can still be seen by widening the column, or in the384+ /// details dialog.385+ if (!mapAddressBook[strAddress].empty())386+ strDescription += " (" + mapAddressBook[strAddress] + ")";387+ }388 }389 }390 break;391@@ -747,7 +636,7 @@392 InsertLine(fNew, nIndex, hash, strSort,393 strStatus,394 nTime ? DateTimeStr(nTime) : "",395- "Payment to yourself",396+ _("Payment to yourself"),397 "",398 "");399 /// issue: can't tell which is the payment and which is the change anymore400@@ -781,9 +670,10 @@401 strAddress = Hash160ToAddress(hash160);402 }403 404- string strDescription = "To: ";405- if (mapAddressBook.count(strAddress) && !mapAddressBook[strAddress].empty())406- strDescription += mapAddressBook[strAddress] + " ";407+ string strDescription = _("To: ");408+ CRITICAL_BLOCK(cs_mapAddressBook)409+ if (mapAddressBook.count(strAddress) && !mapAddressBook[strAddress].empty())410+ strDescription += mapAddressBook[strAddress] + " ";411 strDescription += strAddress;412 if (!mapValue["message"].empty())413 {414@@ -982,7 +872,7 @@415 printf("DelayedRepaint\n");416 wxPaintEvent event;417 pframeMain->fRefresh = true;418- pframeMain->AddPendingEvent(event);419+ pframeMain->GetEventHandler()->AddPendingEvent(event);420 }421 }422 Sleep(nRepaintInterval);423@@ -1007,7 +897,7 @@424 printf("MainFrameRepaint\n");425 wxPaintEvent event;426 pframeMain->fRefresh = true;427- pframeMain->AddPendingEvent(event);428+ pframeMain->GetEventHandler()->AddPendingEvent(event);429 }430 }431 432@@ -1070,12 +960,12 @@433 // Update status bar434 string strGen = "";435 if (fGenerateBitcoins)436- strGen = " Generating";437+ strGen = _(" Generating");438 if (fGenerateBitcoins && vNodes.empty())439- strGen = "(not connected)";440+ strGen = _("(not connected)");441 m_statusBar->SetStatusText(strGen, 1);442 443- string strStatus = strprintf(" %d connections %d blocks %d transactions", vNodes.size(), nBestHeight + 1, nTransactionCount);444+ string strStatus = strprintf(_(" %d connections %d blocks %d transactions"), vNodes.size(), nBestHeight + 1, nTransactionCount);445 m_statusBar->SetStatusText(strStatus, 2);446 447 if (fDebug && GetTime() - nThreadSocketHandlerHeartbeat > 60)448@@ -1196,16 +1086,6 @@449 event.Skip();450 }451 452-void CMainFrame::OnButtonCopy(wxCommandEvent& event)453-{454- // Copy address box to clipboard455- if (wxTheClipboard->Open())456- {457- wxTheClipboard->SetData(new wxTextDataObject(m_textCtrlAddress->GetValue()));458- wxTheClipboard->Close();459- }460-}461-462 void CMainFrame::OnButtonChange(wxCommandEvent& event)463 {464 CYourAddressDialog dialog(this, string(m_textCtrlAddress->GetValue()));465@@ -1224,7 +1104,17 @@466 }467 }468 469-void CMainFrame::OnListItemActivatedAllTransactions(wxListEvent& event)470+void CMainFrame::OnButtonCopy(wxCommandEvent& event)471+{472+ // Copy address box to clipboard473+ if (wxTheClipboard->Open())474+ {475+ wxTheClipboard->SetData(new wxTextDataObject(m_textCtrlAddress->GetValue()));476+ wxTheClipboard->Close();477+ }478+}479+480+void CMainFrame::OnListItemActivated(wxListEvent& event)481 {482 uint256 hash((string)GetItemText(m_listCtrl, event.GetIndex(), 1));483 CWalletTx wtx;484@@ -1233,7 +1123,7 @@485 map<uint256, CWalletTx>::iterator mi = mapWallet.find(hash);486 if (mi == mapWallet.end())487 {488- printf("CMainFrame::OnListItemActivatedAllTransactions() : tx not found in mapWallet\n");489+ printf("CMainFrame::OnListItemActivated() : tx not found in mapWallet\n");490 return;491 }492 wtx = (*mi).second;493@@ -1244,28 +1134,6 @@494 //pdialog->Show();495 }496 497-void CMainFrame::OnListItemActivatedProductsSent(wxListEvent& event)498-{499- CProduct& product = *(CProduct*)event.GetItem().GetData();500- CEditProductDialog* pdialog = new CEditProductDialog(this);501- pdialog->SetProduct(product);502- pdialog->Show();503-}504-505-void CMainFrame::OnListItemActivatedOrdersSent(wxListEvent& event)506-{507- CWalletTx& order = *(CWalletTx*)event.GetItem().GetData();508- CViewOrderDialog* pdialog = new CViewOrderDialog(this, order, false);509- pdialog->Show();510-}511-512-void CMainFrame::OnListItemActivatedOrdersReceived(wxListEvent& event)513-{514- CWalletTx& order = *(CWalletTx*)event.GetItem().GetData();515- CViewOrderDialog* pdialog = new CViewOrderDialog(this, order, true);516- pdialog->Show();517-}518-519 520 521 522@@ -1279,238 +1147,243 @@523 524 CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetailsDialogBase(parent)525 {526- string strHTML;527- strHTML.reserve(4000);528- strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";529-530- int64 nTime = wtx.GetTxTime();531- int64 nCredit = wtx.GetCredit();532- int64 nDebit = wtx.GetDebit();533- int64 nNet = nCredit - nDebit;534-535-536-537- strHTML += "<b>Status:</b> " + FormatTxStatus(wtx);538- int nRequests = wtx.GetRequestCount();539- if (nRequests != -1)540- {541- if (nRequests == 0)542- strHTML += ", has not been successfully broadcast yet";543- else if (nRequests == 1)544- strHTML += strprintf(", broadcast through %d node", nRequests);545+ CRITICAL_BLOCK(cs_mapAddressBook)546+ {547+ string strHTML;548+ strHTML.reserve(4000);549+ strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";550+551+ int64 nTime = wtx.GetTxTime();552+ int64 nCredit = wtx.GetCredit();553+ int64 nDebit = wtx.GetDebit();554+ int64 nNet = nCredit - nDebit;555+556+557+558+ strHTML += _("<b>Status:</b> ") + FormatTxStatus(wtx);559+ int nRequests = wtx.GetRequestCount();560+ if (nRequests != -1)561+ {562+ if (nRequests == 0)563+ strHTML += _(", has not been successfully broadcast yet");564+ else if (nRequests == 1)565+ strHTML += strprintf(_(", broadcast through %d node"), nRequests);566+ else567+ strHTML += strprintf(_(", broadcast through %d nodes"), nRequests);568+ }569+ strHTML += "<br>";570+571+ strHTML += _("<b>Date:</b> ") + (nTime ? DateTimeStr(nTime) : "") + "<br>";572+573+574+ //575+ // From576+ //577+ if (wtx.IsCoinBase())578+ {579+ strHTML += _("<b>Source:</b> Generated<br>");580+ }581+ else if (!wtx.mapValue["from"].empty())582+ {583+ // Online transaction584+ if (!wtx.mapValue["from"].empty())585+ strHTML += _("<b>From:</b> ") + HtmlEscape(wtx.mapValue["from"]) + "<br>";586+ }587 else588- strHTML += strprintf(", broadcast through %d nodes", nRequests);589- }590- strHTML += "<br>";591-592- strHTML += "<b>Date:</b> " + (nTime ? DateTimeStr(nTime) : "") + "<br>";593-594-595- //596- // From597- //598- if (wtx.IsCoinBase())599- {600- strHTML += "<b>Source:</b> Generated<br>";601- }602- else if (!wtx.mapValue["from"].empty())603- {604- // Online transaction605- if (!wtx.mapValue["from"].empty())606- strHTML += "<b>From:</b> " + HtmlEscape(wtx.mapValue["from"]) + "<br>";607- }608- else609- {610- // Offline transaction611- if (nNet > 0)612- {613+ {614+ // Offline transaction615+ if (nNet > 0)616+ {617+ // Credit618+ foreach(const CTxOut& txout, wtx.vout)619+ {620+ if (txout.IsMine())621+ {622+ vector<unsigned char> vchPubKey;623+ if (ExtractPubKey(txout.scriptPubKey, true, vchPubKey))624+ {625+ string strAddress = PubKeyToAddress(vchPubKey);626+ if (mapAddressBook.count(strAddress))627+ {628+ strHTML += string() + _("<b>From:</b> ") + _("unknown") + "<br>";629+ strHTML += _("<b>To:</b> ");630+ strHTML += HtmlEscape(strAddress);631+ if (!mapAddressBook[strAddress].empty())632+ strHTML += _(" (yours, label: ") + mapAddressBook[strAddress] + ")";633+ else634+ strHTML += _(" (yours)");635+ strHTML += "<br>";636+ }637+ }638+ break;639+ }640+ }641+ }642+ }643+644+645+ //646+ // To647+ //648+ string strAddress;649+ if (!wtx.mapValue["to"].empty())650+ {651+ // Online transaction652+ strAddress = wtx.mapValue["to"];653+ strHTML += _("<b>To:</b> ");654+ if (mapAddressBook.count(strAddress) && !mapAddressBook[strAddress].empty())655+ strHTML += mapAddressBook[strAddress] + " ";656+ strHTML += HtmlEscape(strAddress) + "<br>";657+ }658+659+660+ //661+ // Amount662+ //663+ if (wtx.IsCoinBase() && nCredit == 0)664+ {665+ //666+ // Coinbase667+ //668+ int64 nUnmatured = 0;669+ foreach(const CTxOut& txout, wtx.vout)670+ nUnmatured += txout.GetCredit();671+ strHTML += _("<b>Credit:</b> ");672+ if (wtx.IsInMainChain())673+ strHTML += strprintf(_("(%s matures in %d more blocks)"), FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());674+ else675+ strHTML += _("(not accepted)");676+ strHTML += "<br>";677+ }678+ else if (nNet > 0)679+ {680+ //681 // Credit682+ //683+ strHTML += _("<b>Credit:</b> ") + FormatMoney(nNet) + "<br>";684+ }685+ else686+ {687+ bool fAllFromMe = true;688+ foreach(const CTxIn& txin, wtx.vin)689+ fAllFromMe = fAllFromMe && txin.IsMine();690+691+ bool fAllToMe = true;692 foreach(const CTxOut& txout, wtx.vout)693+ fAllToMe = fAllToMe && txout.IsMine();694+695+ if (fAllFromMe)696 {697- if (txout.IsMine())698+ //699+ // Debit700+ //701+ foreach(const CTxOut& txout, wtx.vout)702 {703- vector<unsigned char> vchPubKey;704- if (ExtractPubKey(txout.scriptPubKey, true, vchPubKey))705+ if (txout.IsMine())706+ continue;707+708+ if (wtx.mapValue["to"].empty())709 {710- string strAddress = PubKeyToAddress(vchPubKey);711- if (mapAddressBook.count(strAddress))712+ // Offline transaction713+ uint160 hash160;714+ if (ExtractHash160(txout.scriptPubKey, hash160))715 {716- strHTML += "<b>From:</b> unknown<br>";717- strHTML += "<b>To:</b> ";718- strHTML += HtmlEscape(strAddress);719- if (!mapAddressBook[strAddress].empty())720- strHTML += " (yours, label: " + mapAddressBook[strAddress] + ")";721- else722- strHTML += " (yours)";723+ string strAddress = Hash160ToAddress(hash160);724+ strHTML += _("<b>To:</b> ");725+ if (mapAddressBook.count(strAddress) && !mapAddressBook[strAddress].empty())726+ strHTML += mapAddressBook[strAddress] + " ";727+ strHTML += strAddress;728 strHTML += "<br>";729 }730 }731- break;732+733+ strHTML += _("<b>Debit:</b> ") + FormatMoney(-txout.nValue) + "<br>";734 }735+736+ if (fAllToMe)737+ {738+ // Payment to self739+ /// issue: can't tell which is the payment and which is the change anymore740+ //int64 nValue = wtx.vout[0].nValue;741+ //strHTML += _("<b>Debit:</b> ") + FormatMoney(-nValue) + "<br>";742+ //strHTML += _("<b>Credit:</b> ") + FormatMoney(nValue) + "<br>";743+ }744+745+ int64 nTxFee = nDebit - wtx.GetValueOut();746+ if (nTxFee > 0)747+ strHTML += _("<b>Transaction fee:</b> ") + FormatMoney(-nTxFee) + "<br>";748 }749- }750- }751-752-753- //754- // To755- //756- string strAddress;757- if (!wtx.mapValue["to"].empty())758- {759- // Online transaction760- strAddress = wtx.mapValue["to"];761- strHTML += "<b>To:</b> ";762- if (mapAddressBook.count(strAddress) && !mapAddressBook[strAddress].empty())763- strHTML += mapAddressBook[strAddress] + " ";764- strHTML += HtmlEscape(strAddress) + "<br>";765- }766-767-768- //769- // Amount770- //771- if (wtx.IsCoinBase() && nCredit == 0)772- {773+ else774+ {775+ //776+ // Mixed debit transaction777+ //778+ foreach(const CTxIn& txin, wtx.vin)779+ if (txin.IsMine())780+ strHTML += _("<b>Debit:</b> ") + FormatMoney(-txin.GetDebit()) + "<br>";781+ foreach(const CTxOut& txout, wtx.vout)782+ if (txout.IsMine())783+ strHTML += _("<b>Credit:</b> ") + FormatMoney(txout.GetCredit()) + "<br>";784+ }785+ }786+787+ strHTML += _("<b>Net amount:</b> ") + FormatMoney(nNet, true) + "<br>";788+789+790 //791- // Coinbase792+ // Message793 //794- int64 nUnmatured = 0;795- foreach(const CTxOut& txout, wtx.vout)796- nUnmatured += txout.GetCredit();797- if (wtx.IsInMainChain())798- strHTML += strprintf("<b>Credit:</b> (%s matures in %d more blocks)<br>", FormatMoney(nUnmatured).c_str(), wtx.GetBlocksToMaturity());799- else800- strHTML += "<b>Credit:</b> (not accepted)<br>";801- }802- else if (nNet > 0)803- {804+ if (!wtx.mapValue["message"].empty())805+ strHTML += string() + "<br><b>" + _("Message:") + "</b><br>" + HtmlEscape(wtx.mapValue["message"], true) + "<br>";806+807+ if (wtx.IsCoinBase())808+ strHTML += string() + "<br>" + _("Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "<br>";809+810+811 //812- // Credit813+ // Debug view814 //815- strHTML += "<b>Credit:</b> " + FormatMoney(nNet) + "<br>";816- }817- else818- {819- bool fAllFromMe = true;820- foreach(const CTxIn& txin, wtx.vin)821- fAllFromMe = fAllFromMe && txin.IsMine();822-823- bool fAllToMe = true;824- foreach(const CTxOut& txout, wtx.vout)825- fAllToMe = fAllToMe && txout.IsMine();826-827- if (fAllFromMe)828- {829- //830- // Debit831- //832- foreach(const CTxOut& txout, wtx.vout)833- {834- if (txout.IsMine())835- continue;836-837- if (wtx.mapValue["to"].empty())838- {839- // Offline transaction840- uint160 hash160;841- if (ExtractHash160(txout.scriptPubKey, hash160))842- {843- string strAddress = Hash160ToAddress(hash160);844- strHTML += "<b>To:</b> ";845- if (mapAddressBook.count(strAddress) && !mapAddressBook[strAddress].empty())846- strHTML += mapAddressBook[strAddress] + " ";847- strHTML += strAddress;848- strHTML += "<br>";849- }850- }851-852- strHTML += "<b>Debit:</b> " + FormatMoney(-txout.nValue) + "<br>";853- }854-855- if (fAllToMe)856- {857- // Payment to self858- /// issue: can't tell which is the payment and which is the change anymore859- //int64 nValue = wtx.vout[0].nValue;860- //strHTML += "<b>Debit:</b> " + FormatMoney(-nValue) + "<br>";861- //strHTML += "<b>Credit:</b> " + FormatMoney(nValue) + "<br>";862- }863-864- int64 nTxFee = nDebit - wtx.GetValueOut();865- if (nTxFee > 0)866- strHTML += "<b>Transaction fee:</b> " + FormatMoney(-nTxFee) + "<br>";867- }868- else869- {870- //871- // Mixed debit transaction872- //873+ if (fDebug)874+ {875+ strHTML += "<hr><br>debug print<br><br>";876 foreach(const CTxIn& txin, wtx.vin)877 if (txin.IsMine())878 strHTML += "<b>Debit:</b> " + FormatMoney(-txin.GetDebit()) + "<br>";879 foreach(const CTxOut& txout, wtx.vout)880 if (txout.IsMine())881 strHTML += "<b>Credit:</b> " + FormatMoney(txout.GetCredit()) + "<br>";882- }883- }884-885- strHTML += "<b>Net amount:</b> " + FormatMoney(nNet, true) + "<br>";886-887-888- //889- // Message890- //891- if (!wtx.mapValue["message"].empty())892- strHTML += "<br><b>Message:</b><br>" + HtmlEscape(wtx.mapValue["message"], true) + "<br>";893-894- if (wtx.IsCoinBase())895- strHTML += "<br>Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.<br>";896-897-898- //899- // Debug view900- //901- if (fDebug)902- {903- strHTML += "<hr><br>debug print<br><br>";904- foreach(const CTxIn& txin, wtx.vin)905- if (txin.IsMine())906- strHTML += "<b>Debit:</b> " + FormatMoney(-txin.GetDebit()) + "<br>";907- foreach(const CTxOut& txout, wtx.vout)908- if (txout.IsMine())909- strHTML += "<b>Credit:</b> " + FormatMoney(txout.GetCredit()) + "<br>";910-911- strHTML += "<b>Inputs:</b><br>";912- CRITICAL_BLOCK(cs_mapWallet)913- {914- foreach(const CTxIn& txin, wtx.vin)915+916+ strHTML += "<b>Inputs:</b><br>";917+ CRITICAL_BLOCK(cs_mapWallet)918 {919- COutPoint prevout = txin.prevout;920- map<uint256, CWalletTx>::iterator mi = mapWallet.find(prevout.hash);921- if (mi != mapWallet.end())922+ foreach(const CTxIn& txin, wtx.vin)923 {924- const CWalletTx& prev = (*mi).second;925- if (prevout.n < prev.vout.size())926+ COutPoint prevout = txin.prevout;927+ map<uint256, CWalletTx>::iterator mi = mapWallet.find(prevout.hash);928+ if (mi != mapWallet.end())929 {930- strHTML += HtmlEscape(prev.ToString(), true);931- strHTML += " " + FormatTxStatus(prev) + ", ";932- strHTML = strHTML + "IsMine=" + (prev.vout[prevout.n].IsMine() ? "true" : "false") + "<br>";933+ const CWalletTx& prev = (*mi).second;934+ if (prevout.n < prev.vout.size())935+ {936+ strHTML += HtmlEscape(prev.ToString(), true);937+ strHTML += " " + FormatTxStatus(prev) + ", ";938+ strHTML = strHTML + "IsMine=" + (prev.vout[prevout.n].IsMine() ? "true" : "false") + "<br>";939+ }940 }941 }942 }943- }944-945- strHTML += "<br><hr><br><b>Transaction:</b><br>";946- strHTML += HtmlEscape(wtx.ToString(), true);947- }948-949-950-951- strHTML += "</font></html>";952- string(strHTML.begin(), strHTML.end()).swap(strHTML);953- m_htmlWin->SetPage(strHTML);954- m_buttonOK->SetFocus();955+956+ strHTML += "<br><hr><br><b>Transaction:</b><br>";957+ strHTML += HtmlEscape(wtx.ToString(), true);958+ }959+960+961+962+ strHTML += "</font></html>";963+ string(strHTML.begin(), strHTML.end()).swap(strHTML);964+ m_htmlWin->SetPage(strHTML);965+ m_buttonOK->SetFocus();966+ }967 }968 969 void CTxDetailsDialog::OnButtonOK(wxCommandEvent& event)970@@ -1531,12 +1404,12 @@971 COptionsDialog::COptionsDialog(wxWindow* parent) : COptionsDialogBase(parent)972 {973 // Set up list box of page choices974- m_listBox->Append("Main");975- //m_listBox->Append("Test 2");976+ m_listBox->Append(_("Main"));977+ //m_listBox->Append(_("Test 2"));978 m_listBox->SetSelection(0);979 SelectPage(0);980 #ifndef __WXMSW__981- m_checkBoxMinimizeOnClose->SetLabel("&Minimize on close");982+ m_checkBoxMinimizeOnClose->SetLabel(_("&Minimize on close"));983 m_checkBoxStartOnSystemStartup->Enable(false); // not implemented yet984 #endif985 986@@ -1688,15 +1561,25 @@987 988 CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent)989 {990- m_staticTextVersion->SetLabel(strprintf("version 0.%d.%d beta", VERSION/100, VERSION%100));991-992- // Workaround until upgrade to wxWidgets supporting UTF-8993+ m_staticTextVersion->SetLabel(strprintf(_("version 0.%d.%d beta"), VERSION/100, VERSION%100));994+995+ // Change (c) into UTF-8 or ANSI copyright symbol996 wxString str = m_staticTextMain->GetLabel();997- if (str.Find('Â') != wxNOT_FOUND)998- str.Remove(str.Find('Â'), 1);999+#if wxUSE_UNICODE1000+ str.Replace("(c)", wxString::FromUTF8("\xC2\xA9"));1001+#else1002+ str.Replace("(c)", "\xA9");1003+#endif1004 m_staticTextMain->SetLabel(str);1005 #ifndef __WXMSW__1006- SetSize(510, 380);1007+ // Resize on Linux to make the window fit the text.1008+ // The text was wrapped manually rather than using the Wrap setting because1009+ // the wrap would be too small on Linux and it can't be changed at this point.1010+ wxFont fontTmp = m_staticTextMain->GetFont();1011+ if (fontTmp.GetPointSize() > 8);1012+ fontTmp.SetPointSize(8);1013+ m_staticTextMain->SetFont(fontTmp);1014+ SetSize(GetSize().GetWidth() + 44, GetSize().GetHeight() + 10);1015 #endif1016 }1017 1018@@ -1729,7 +1612,7 @@1019 if (fontTmp.GetPointSize() > 9);1020 fontTmp.SetPointSize(9);1021 m_staticTextInstructions->SetFont(fontTmp);1022- SetSize(725, wxDefaultCoord);1023+ SetSize(725, 380);1024 #endif1025 1026 // Set Icon1027@@ -1763,8 +1646,8 @@1028 {1029 strFromSave = m_textCtrlFrom->GetValue();1030 strMessageSave = m_textCtrlMessage->GetValue();1031- m_textCtrlFrom->SetValue("Will appear as \"From: Unknown\"");1032- m_textCtrlMessage->SetValue("Can't include a message when sending to a Bitcoin address");1033+ m_textCtrlFrom->SetValue(_("Will appear as \"From: Unknown\""));1034+ m_textCtrlMessage->SetValue(_("Can't include a message when sending to a Bitcoin address"));1035 }1036 else if (fEnable && !fEnabledPrev)1037 {1038@@ -1816,17 +1699,17 @@1039 int64 nValue = 0;1040 if (!ParseMoney(m_textCtrlAmount->GetValue(), nValue) || nValue <= 0)1041 {1042- wxMessageBox("Error in amount ", "Send Coins");1043+ wxMessageBox(_("Error in amount "), _("Send Coins"));1044 return;1045 }1046 if (nValue > GetBalance())1047 {1048- wxMessageBox("Amount exceeds your balance ", "Send Coins");1049+ wxMessageBox(_("Amount exceeds your balance "), _("Send Coins"));1050 return;1051 }1052 if (nValue + nTransactionFee > GetBalance())1053 {1054- wxMessageBox(string("Total exceeds your balance when the ") + FormatMoney(nTransactionFee) + " transaction fee is included ", "Send Coins");1055+ wxMessageBox(string(_("Total exceeds your balance when the ")) + FormatMoney(nTransactionFee) + _(" transaction fee is included "), _("Send Coins"));1056 return;1057 }1058 1059@@ -1840,10 +1723,11 @@1060 CScript scriptPubKey;1061 scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;1062 1063- if (!SendMoney(scriptPubKey, nValue, wtx))1064- return;1065-1066- wxMessageBox("Payment sent ", "Sending...");1067+ string strError = SendMoney(scriptPubKey, nValue, wtx);1068+ if (strError != "")1069+ wxMessageBox(strError + " ", _("Sending..."));1070+ else1071+ wxMessageBox(_("Payment sent "), _("Sending..."));1072 }1073 else1074 {1075@@ -1851,7 +1735,7 @@1076 CAddress addr(strAddress);1077 if (!addr.IsValid())1078 {1079- wxMessageBox("Invalid address ", "Send Coins");1080+ wxMessageBox(_("Invalid address "), _("Send Coins"));1081 return;1082 }1083 1084@@ -1866,8 +1750,9 @@1085 return;1086 }1087 1088- if (!mapAddressBook.count(strAddress))1089- SetAddressBookName(strAddress, "");1090+ CRITICAL_BLOCK(cs_mapAddressBook)1091+ if (!mapAddressBook.count(strAddress))1092+ SetAddressBookName(strAddress, "");1093 1094 EndModal(true);1095 }1096@@ -1901,10 +1786,10 @@1097 fUIDone = false;1098 fWorkDone = false;1099 #ifndef __WXMSW__1100- SetSize(1.2 * GetSize().GetWidth(), 1.05 * GetSize().GetHeight());1101+ SetSize(1.2 * GetSize().GetWidth(), 1.08 * GetSize().GetHeight());1102 #endif1103 1104- SetTitle(strprintf("Sending %s to %s", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str()));1105+ SetTitle(strprintf(_("Sending %s to %s"), FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str()));1106 m_textCtrlStatus->SetValue("");1107 1108 CreateThread(SendingDialogStartTransfer, this);1109@@ -1976,13 +1861,13 @@1110 }1111 if (fAbort && fCanCancel && IsShown())1112 {1113- strcpy(pszStatus, "CANCELLED");1114+ strcpy(pszStatus, _("CANCELLED"));1115 m_buttonOK->Enable(true);1116 m_buttonOK->SetFocus();1117 m_buttonCancel->Enable(false);1118- m_buttonCancel->SetLabel("Cancelled");1119+ m_buttonCancel->SetLabel(_("Cancelled"));1120 Close();1121- wxMessageBox("Transfer cancelled ", "Sending...", wxOK, this);1122+ wxMessageBox(_("Transfer cancelled "), _("Sending..."), wxOK, this);1123 }1124 event.Skip();1125 }1126@@ -1997,7 +1882,7 @@1127 {1128 Refresh();1129 wxPaintEvent event;1130- AddPendingEvent(event);1131+ GetEventHandler()->AddPendingEvent(event);1132 }1133 1134 bool CSendingDialog::Status()1135@@ -2010,7 +1895,7 @@1136 if (fAbort && fCanCancel)1137 {1138 memset(pszStatus, 0, 10);1139- strcpy(pszStatus, "CANCELLED");1140+ strcpy(pszStatus, _("CANCELLED"));1141 Repaint();1142 fWorkDone = true;1143 return false;1144@@ -2036,7 +1921,7 @@1145 {1146 fCanCancel = false;1147 fWorkDone = true;1148- Status(string("Error: ") + str);1149+ Status(string(_("Error: ")) + str);1150 return false;1151 }1152 1153@@ -2050,22 +1935,22 @@1154 // Make sure we have enough money1155 if (nPrice + nTransactionFee > GetBalance())1156 {1157- Error("You don't have enough money");1158+ Error(_("You don't have enough money"));1159 return;1160 }1161 1162 // We may have connected already for product details1163- if (!Status("Connecting..."))1164+ if (!Status(_("Connecting...")))1165 return;1166 CNode* pnode = ConnectNode(addr, 15 * 60);1167 if (!pnode)1168 {1169- Error("Unable to connect");1170+ Error(_("Unable to connect"));1171 return;1172 }1173 1174 // Send order to seller, with response going to OnReply2 via event handler1175- if (!Status("Requesting public key..."))1176+ if (!Status(_("Requesting public key...")))1177 return;1178 pnode->PushRequest("checkorder", wtx, SendingDialogOnReply2, this);1179 }1180@@ -2077,7 +1962,7 @@1181 1182 void CSendingDialog::OnReply2(CDataStream& vRecv)1183 {1184- if (!Status("Received public key..."))1185+ if (!Status(_("Received public key...")))1186 return;1187 1188 CScript scriptPubKey;1189@@ -2089,7 +1974,7 @@1190 {1191 string strMessage;1192 vRecv >> strMessage;1193- Error("Transfer was not accepted");1194+ Error(_("Transfer was not accepted"));1195 //// todo: enlarge the window and enable a hidden white box to put seller's message1196 return;1197 }1198@@ -2098,7 +1983,7 @@1199 catch (...)1200 {1201 //// what do we want to do about this?1202- Error("Invalid response received");1203+ Error(_("Invalid response received"));1204 return;1205 }1206 1207@@ -2113,11 +1998,11 @@1208 CRITICAL_BLOCK(cs_main)1209 {1210 // Pay1211- if (!Status("Creating transaction..."))1212+ if (!Status(_("Creating transaction...")))1213 return;1214 if (nPrice + nTransactionFee > GetBalance())1215 {1216- Error("You don't have enough money");1217+ Error(_("You don't have enough money"));1218 return;1219 }1220 CKey key;1221@@ -2125,9 +2010,9 @@1222 if (!CreateTransaction(scriptPubKey, nPrice, wtx, key, nFeeRequired))1223 {1224 if (nPrice + nFeeRequired > GetBalance())1225- Error(strprintf("This is an oversized transaction that requires a transaction fee of %s", FormatMoney(nFeeRequired).c_str()));1226+ Error(strprintf(_("This is an oversized transaction that requires a transaction fee of %s"), FormatMoney(nFeeRequired).c_str()));1227 else1228- Error("Transaction creation failed");1229+ Error(_("Transaction creation failed"));1230 return;1231 }1232 1233@@ -2135,7 +2020,7 @@1234 CNode* pnode = ConnectNode(addr, 2 * 60 * 60);1235 if (!pnode)1236 {1237- Error("Lost connection, transaction cancelled");1238+ Error(_("Lost connection, transaction cancelled"));1239 return;1240 }1241 1242@@ -2151,13 +2036,13 @@1243 return;1244 fCanCancel = false;1245 }1246- if (!Status("Sending payment..."))1247+ if (!Status(_("Sending payment...")))1248 return;1249 1250 // Commit1251 if (!CommitTransactionSpent(wtx, key))1252 {1253- Error("Error finalizing payment");1254+ Error(_("Error finalizing payment"));1255 return;1256 }1257 1258@@ -2169,7 +2054,7 @@1259 printf("ERROR: CSendingDialog : wtxNew.AcceptTransaction() %s failed\n", wtx.GetHash().ToString().c_str());1260 wtx.RelayWalletTransaction();1261 1262- Status("Waiting for confirmation...");1263+ Status(_("Waiting for confirmation..."));1264 MainFrameRepaint();1265 }1266 }1267@@ -2187,22 +2072,22 @@1268 vRecv >> nRet;1269 if (nRet > 0)1270 {1271- Error("The payment was sent, but the recipient was unable to verify it.\n"1272- "The transaction is recorded and will credit to the recipient,\n"1273- "but the comment information will be blank.");1274+ Error(_("The payment was sent, but the recipient was unable to verify it.\n"1275+ "The transaction is recorded and will credit to the recipient,\n"1276+ "but the comment information will be blank."));1277 return;1278 }1279 }1280 catch (...)1281 {1282 //// what do we want to do about this?1283- Error("Payment was sent, but an invalid response was received");1284+ Error(_("Payment was sent, but an invalid response was received"));1285 return;1286 }1287 1288 fSuccess = true;1289 fWorkDone = true;1290- Status("Payment completed");1291+ Status(_("Payment completed"));1292 }1293 1294 1295@@ -2218,12 +2103,13 @@1296 CYourAddressDialog::CYourAddressDialog(wxWindow* parent, const string& strInitSelected) : CYourAddressDialogBase(parent)1297 {1298 // Init column headers1299- m_listCtrl->InsertColumn(0, "Label", wxLIST_FORMAT_LEFT, 200);1300- m_listCtrl->InsertColumn(1, "Bitcoin Address", wxLIST_FORMAT_LEFT, 350);1301+ m_listCtrl->InsertColumn(0, _("Label"), wxLIST_FORMAT_LEFT, 200);1302+ m_listCtrl->InsertColumn(1, _("Bitcoin Address"), wxLIST_FORMAT_LEFT, 350);1303 m_listCtrl->SetFocus();1304 1305 // Fill listctrl with address book data1306 CRITICAL_BLOCK(cs_mapKeys)1307+ CRITICAL_BLOCK(cs_mapAddressBook)1308 {1309 foreach(const PAIRTYPE(string, string)& item, mapAddressBook)1310 {1311@@ -2278,7 +2164,7 @@1312 return;1313 string strName = (string)m_listCtrl->GetItemText(nIndex);1314 string strAddress = (string)GetItemText(m_listCtrl, nIndex, 1);1315- CGetTextFromUserDialog dialog(this, "Edit Address Label", "New Label", strName);1316+ CGetTextFromUserDialog dialog(this, _("Edit Address Label"), _("New Label"), strName);1317 if (!dialog.ShowModal())1318 return;1319 strName = dialog.GetValue();1320@@ -2292,7 +2178,7 @@1321 void CYourAddressDialog::OnButtonNew(wxCommandEvent& event)1322 {1323 // Ask name1324- CGetTextFromUserDialog dialog(this, "New Bitcoin Address", "Label", "");1325+ CGetTextFromUserDialog dialog(this, _("New Bitcoin Address"), _("Label"), "");1326 if (!dialog.ShowModal())1327 return;1328 string strName = dialog.GetValue();1329@@ -2352,8 +2238,8 @@1330 m_buttonCancel->Show(false);1331 1332 // Init column headers1333- m_listCtrl->InsertColumn(0, "Name", wxLIST_FORMAT_LEFT, 200);1334- m_listCtrl->InsertColumn(1, "Address", wxLIST_FORMAT_LEFT, 350);1335+ m_listCtrl->InsertColumn(0, _("Name"), wxLIST_FORMAT_LEFT, 200);1336+ m_listCtrl->InsertColumn(1, _("Address"), wxLIST_FORMAT_LEFT, 350);1337 m_listCtrl->SetFocus();1338 1339 // Set Icon1340@@ -2363,6 +2249,7 @@1341 1342 // Fill listctrl with address book data1343 CRITICAL_BLOCK(cs_mapKeys)1344+ CRITICAL_BLOCK(cs_mapAddressBook)1345 {1346 foreach(const PAIRTYPE(string, string)& item, mapAddressBook)1347 {1348@@ -2422,7 +2309,7 @@1349 uint160 hash160;1350 bool fMine = (AddressToHash160(strAddress, hash160) && mapPubKeys.count(hash160));1351 if (fMine)1352- wxMessageBox("This is one of your own addresses for receiving payments and cannot be entered in the address book. ", strTitle);1353+ wxMessageBox(_("This is one of your own addresses for receiving payments and cannot be entered in the address book. "), strTitle);1354 return fMine;1355 }1356 1357@@ -2437,13 +2324,13 @@1358 string strAddressOrg = strAddress;1359 do1360 {1361- CGetTextFromUserDialog dialog(this, "Edit Address", "Name", strName, "Address", strAddress);1362+ CGetTextFromUserDialog dialog(this, _("Edit Address"), _("Name"), strName, _("Address"), strAddress);1363 if (!dialog.ShowModal())1364 return;1365 strName = dialog.GetValue1();1366 strAddress = dialog.GetValue2();1367 }1368- while (CheckIfMine(strAddress, "Edit Address"));1369+ while (CheckIfMine(strAddress, _("Edit Address")));1370 1371 // Change name1372 if (strAddress != strAddressOrg)1373@@ -2461,13 +2348,13 @@1374 string strAddress;1375 do1376 {1377- CGetTextFromUserDialog dialog(this, "New Address", "Name", strName, "Address", strAddress);1378+ CGetTextFromUserDialog dialog(this, _("New Address"), _("Name"), strName, _("Address"), strAddress);1379 if (!dialog.ShowModal())1380 return;1381 strName = dialog.GetValue1();1382 strAddress = dialog.GetValue2();1383 }1384- while (CheckIfMine(strAddress, "New Address"));1385+ while (CheckIfMine(strAddress, _("New Address")));1386 1387 // Add to list and select it1388 SetAddressBookName(strAddress, strName);1389@@ -2518,788 +2405,6 @@1390 // Close1391 EndModal(0);1392 }1393-1394-1395-1396-1397-1398-1399-//////////////////////////////////////////////////////////////////////////////1400-//1401-// CProductsDialog1402-//1403-1404-bool CompareIntStringPairBestFirst(const pair<int, string>& item1, const pair<int, string>& item2)1405-{1406- return (item1.first > item2.first);1407-}1408-1409-CProductsDialog::CProductsDialog(wxWindow* parent) : CProductsDialogBase(parent)1410-{1411- // Init column headers1412- m_listCtrl->InsertColumn(0, "Title", wxLIST_FORMAT_LEFT, 200);1413- m_listCtrl->InsertColumn(1, "Price", wxLIST_FORMAT_LEFT, 80);1414- m_listCtrl->InsertColumn(2, "Seller", wxLIST_FORMAT_LEFT, 80);1415- m_listCtrl->InsertColumn(3, "Stars", wxLIST_FORMAT_LEFT, 50);1416- m_listCtrl->InsertColumn(4, "Power", wxLIST_FORMAT_LEFT, 50);1417-1418- // Tally top categories1419- map<string, int> mapTopCategories;1420- CRITICAL_BLOCK(cs_mapProducts)1421- for (map<uint256, CProduct>::iterator mi = mapProducts.begin(); mi != mapProducts.end(); ++mi)1422- mapTopCategories[(*mi).second.mapValue["category"]]++;1423-1424- // Sort top categories1425- vector<pair<int, string> > vTopCategories;1426- for (map<string, int>::iterator mi = mapTopCategories.begin(); mi != mapTopCategories.end(); ++mi)1427- vTopCategories.push_back(make_pair((*mi).second, (*mi).first));1428- sort(vTopCategories.begin(), vTopCategories.end(), CompareIntStringPairBestFirst);1429-1430- // Fill categories combo box1431- int nLimit = 250;1432- for (vector<pair<int, string> >::iterator it = vTopCategories.begin(); it != vTopCategories.end() && nLimit-- > 0; ++it)1433- m_comboBoxCategory->Append((*it).second);1434-1435- // Fill window with initial search1436- //wxCommandEvent event;1437- //OnButtonSearch(event);1438-}1439-1440-void CProductsDialog::OnCombobox(wxCommandEvent& event)1441-{1442- OnButtonSearch(event);1443-}1444-1445-bool CompareProductsBestFirst(const CProduct* p1, const CProduct* p2)1446-{1447- return (p1->nAtoms > p2->nAtoms);1448-}1449-1450-void CProductsDialog::OnButtonSearch(wxCommandEvent& event)1451-{1452- string strCategory = (string)m_comboBoxCategory->GetValue();1453- string strSearch = (string)m_textCtrlSearch->GetValue();1454-1455- // Search products1456- vector<CProduct*> vProductsFound;1457- CRITICAL_BLOCK(cs_mapProducts)1458- {1459- for (map<uint256, CProduct>::iterator mi = mapProducts.begin(); mi != mapProducts.end(); ++mi)1460- {1461- CProduct& product = (*mi).second;1462- if (product.mapValue["category"].find(strCategory) != -1)1463- {1464- if (product.mapValue["title"].find(strSearch) != -1 ||1465- product.mapValue["description"].find(strSearch) != -1 ||1466- product.mapValue["seller"].find(strSearch) != -1)1467- {1468- vProductsFound.push_back(&product);1469- }1470- }1471- }1472- }1473-1474- // Sort1475- sort(vProductsFound.begin(), vProductsFound.end(), CompareProductsBestFirst);1476-1477- // Display1478- foreach(CProduct* pproduct, vProductsFound)1479- {1480- InsertLine(m_listCtrl,1481- pproduct->mapValue["title"],1482- pproduct->mapValue["price"],1483- pproduct->mapValue["seller"],1484- pproduct->mapValue["stars"],1485- itostr(pproduct->nAtoms));1486- }1487-}1488-1489-void CProductsDialog::OnListItemActivated(wxListEvent& event)1490-{1491- // Doubleclick opens product1492- CViewProductDialog* pdialog = new CViewProductDialog(this, m_vProduct[event.GetIndex()]);1493- pdialog->Show();1494-}1495-1496-1497-1498-1499-1500-1501-1502-//////////////////////////////////////////////////////////////////////////////1503-//1504-// CEditProductDialog1505-//1506-1507-CEditProductDialog::CEditProductDialog(wxWindow* parent) : CEditProductDialogBase(parent)1508-{1509- m_textCtrlLabel[0 ] = m_textCtrlLabel0;1510- m_textCtrlLabel[1 ] = m_textCtrlLabel1;1511- m_textCtrlLabel[2 ] = m_textCtrlLabel2;1512- m_textCtrlLabel[3 ] = m_textCtrlLabel3;1513- m_textCtrlLabel[4 ] = m_textCtrlLabel4;1514- m_textCtrlLabel[5 ] = m_textCtrlLabel5;1515- m_textCtrlLabel[6 ] = m_textCtrlLabel6;1516- m_textCtrlLabel[7 ] = m_textCtrlLabel7;1517- m_textCtrlLabel[8 ] = m_textCtrlLabel8;1518- m_textCtrlLabel[9 ] = m_textCtrlLabel9;1519- m_textCtrlLabel[10] = m_textCtrlLabel10;1520- m_textCtrlLabel[11] = m_textCtrlLabel11;1521- m_textCtrlLabel[12] = m_textCtrlLabel12;1522- m_textCtrlLabel[13] = m_textCtrlLabel13;1523- m_textCtrlLabel[14] = m_textCtrlLabel14;1524- m_textCtrlLabel[15] = m_textCtrlLabel15;1525- m_textCtrlLabel[16] = m_textCtrlLabel16;1526- m_textCtrlLabel[17] = m_textCtrlLabel17;1527- m_textCtrlLabel[18] = m_textCtrlLabel18;1528- m_textCtrlLabel[19] = m_textCtrlLabel19;1529-1530- m_textCtrlField[0 ] = m_textCtrlField0;1531- m_textCtrlField[1 ] = m_textCtrlField1;1532- m_textCtrlField[2 ] = m_textCtrlField2;1533- m_textCtrlField[3 ] = m_textCtrlField3;1534- m_textCtrlField[4 ] = m_textCtrlField4;1535- m_textCtrlField[5 ] = m_textCtrlField5;1536- m_textCtrlField[6 ] = m_textCtrlField6;1537- m_textCtrlField[7 ] = m_textCtrlField7;1538- m_textCtrlField[8 ] = m_textCtrlField8;1539- m_textCtrlField[9 ] = m_textCtrlField9;1540- m_textCtrlField[10] = m_textCtrlField10;1541- m_textCtrlField[11] = m_textCtrlField11;1542- m_textCtrlField[12] = m_textCtrlField12;1543- m_textCtrlField[13] = m_textCtrlField13;1544- m_textCtrlField[14] = m_textCtrlField14;1545- m_textCtrlField[15] = m_textCtrlField15;1546- m_textCtrlField[16] = m_textCtrlField16;1547- m_textCtrlField[17] = m_textCtrlField17;1548- m_textCtrlField[18] = m_textCtrlField18;1549- m_textCtrlField[19] = m_textCtrlField19;1550-1551- m_buttonDel[0 ] = m_buttonDel0;1552- m_buttonDel[1 ] = m_buttonDel1;1553- m_buttonDel[2 ] = m_buttonDel2;1554- m_buttonDel[3 ] = m_buttonDel3;1555- m_buttonDel[4 ] = m_buttonDel4;1556- m_buttonDel[5 ] = m_buttonDel5;1557- m_buttonDel[6 ] = m_buttonDel6;1558- m_buttonDel[7 ] = m_buttonDel7;1559- m_buttonDel[8 ] = m_buttonDel8;1560- m_buttonDel[9 ] = m_buttonDel9;1561- m_buttonDel[10] = m_buttonDel10;1562- m_buttonDel[11] = m_buttonDel11;1563- m_buttonDel[12] = m_buttonDel12;1564- m_buttonDel[13] = m_buttonDel13;1565- m_buttonDel[14] = m_buttonDel14;1566- m_buttonDel[15] = m_buttonDel15;1567- m_buttonDel[16] = m_buttonDel16;1568- m_buttonDel[17] = m_buttonDel17;1569- m_buttonDel[18] = m_buttonDel18;1570- m_buttonDel[19] = m_buttonDel19;1571-1572- for (int i = 1; i < FIELDS_MAX; i++)1573- ShowLine(i, false);1574-1575- LayoutAll();1576-}1577-1578-void CEditProductDialog::LayoutAll()1579-{1580- m_scrolledWindow->Layout();1581- m_scrolledWindow->GetSizer()->Fit(m_scrolledWindow);1582- this->Layout();1583-}1584-1585-void CEditProductDialog::ShowLine(int i, bool fShow)1586-{1587- m_textCtrlLabel[i]->Show(fShow);1588- m_textCtrlField[i]->Show(fShow);1589- m_buttonDel[i]->Show(fShow);1590-}1591-1592-void CEditProductDialog::OnButtonDel0(wxCommandEvent& event) { OnButtonDel(event, 0); }1593-void CEditProductDialog::OnButtonDel1(wxCommandEvent& event) { OnButtonDel(event, 1); }1594-void CEditProductDialog::OnButtonDel2(wxCommandEvent& event) { OnButtonDel(event, 2); }1595-void CEditProductDialog::OnButtonDel3(wxCommandEvent& event) { OnButtonDel(event, 3); }1596-void CEditProductDialog::OnButtonDel4(wxCommandEvent& event) { OnButtonDel(event, 4); }1597-void CEditProductDialog::OnButtonDel5(wxCommandEvent& event) { OnButtonDel(event, 5); }1598-void CEditProductDialog::OnButtonDel6(wxCommandEvent& event) { OnButtonDel(event, 6); }1599-void CEditProductDialog::OnButtonDel7(wxCommandEvent& event) { OnButtonDel(event, 7); }1600-void CEditProductDialog::OnButtonDel8(wxCommandEvent& event) { OnButtonDel(event, 8); }1601-void CEditProductDialog::OnButtonDel9(wxCommandEvent& event) { OnButtonDel(event, 9); }1602-void CEditProductDialog::OnButtonDel10(wxCommandEvent& event) { OnButtonDel(event, 10); }1603-void CEditProductDialog::OnButtonDel11(wxCommandEvent& event) { OnButtonDel(event, 11); }1604-void CEditProductDialog::OnButtonDel12(wxCommandEvent& event) { OnButtonDel(event, 12); }1605-void CEditProductDialog::OnButtonDel13(wxCommandEvent& event) { OnButtonDel(event, 13); }1606-void CEditProductDialog::OnButtonDel14(wxCommandEvent& event) { OnButtonDel(event, 14); }1607-void CEditProductDialog::OnButtonDel15(wxCommandEvent& event) { OnButtonDel(event, 15); }1608-void CEditProductDialog::OnButtonDel16(wxCommandEvent& event) { OnButtonDel(event, 16); }1609-void CEditProductDialog::OnButtonDel17(wxCommandEvent& event) { OnButtonDel(event, 17); }1610-void CEditProductDialog::OnButtonDel18(wxCommandEvent& event) { OnButtonDel(event, 18); }1611-void CEditProductDialog::OnButtonDel19(wxCommandEvent& event) { OnButtonDel(event, 19); }1612-1613-void CEditProductDialog::OnButtonDel(wxCommandEvent& event, int n)1614-{1615- Freeze();1616- int x, y;1617- m_scrolledWindow->GetViewStart(&x, &y);1618- int i;1619- for (i = n; i < FIELDS_MAX-1; i++)1620- {1621- m_textCtrlLabel[i]->SetValue(m_textCtrlLabel[i+1]->GetValue());1622- m_textCtrlField[i]->SetValue(m_textCtrlField[i+1]->GetValue());1623- if (!m_buttonDel[i+1]->IsShown())1624- break;1625- }1626- m_textCtrlLabel[i]->SetValue("");1627- m_textCtrlField[i]->SetValue("");1628- ShowLine(i, false);1629- m_buttonAddField->Enable(true);1630- LayoutAll();1631- m_scrolledWindow->Scroll(0, y);1632- Thaw();1633-}1634-1635-void CEditProductDialog::OnButtonAddField(wxCommandEvent& event)1636-{1637- for (int i = 0; i < FIELDS_MAX; i++)1638- {1639- if (!m_buttonDel[i]->IsShown())1640- {1641- Freeze();1642- ShowLine(i, true);1643- if (i == FIELDS_MAX-1)1644- m_buttonAddField->Enable(false);1645- LayoutAll();1646- m_scrolledWindow->Scroll(0, 99999);1647- Thaw();1648- break;1649- }1650- }1651-}1652-1653-void CEditProductDialog::OnButtonSend(wxCommandEvent& event)1654-{1655- CProduct product;1656- GetProduct(product);1657-1658- // Sign the detailed product1659- product.vchPubKeyFrom = keyUser.GetPubKey();1660- if (!keyUser.Sign(product.GetSigHash(), product.vchSig))1661- {1662- wxMessageBox("Error digitally signing the product ");1663- return;1664- }1665-1666- // Save detailed product1667- AddToMyProducts(product);1668-1669- // Strip down to summary product1670- product.mapDetails.clear();1671- product.vOrderForm.clear();1672-1673- // Sign the summary product1674- if (!keyUser.Sign(product.GetSigHash(), product.vchSig))1675- {1676- wxMessageBox("Error digitally signing the product ");1677- return;1678- }1679-1680- // Verify1681- if (!product.CheckProduct())1682- {1683- wxMessageBox("Errors found in product ");1684- return;1685- }1686-1687- // Broadcast1688- AdvertStartPublish(pnodeLocalHost, MSG_PRODUCT, 0, product);1689-1690- Destroy();1691-}1692-1693-void CEditProductDialog::OnButtonPreview(wxCommandEvent& event)1694-{1695- CProduct product;1696- GetProduct(product);1697- CViewProductDialog* pdialog = new CViewProductDialog(this, product);1698- pdialog->Show();1699-}1700-1701-void CEditProductDialog::OnButtonCancel(wxCommandEvent& event)1702-{1703- Destroy();1704-}1705-1706-void CEditProductDialog::SetProduct(const CProduct& productIn)1707-{1708- CProduct product = productIn;1709-1710- m_comboBoxCategory->SetValue(product.mapValue["category"]);1711- m_textCtrlTitle->SetValue(product.mapValue["title"]);1712- m_textCtrlPrice->SetValue(product.mapValue["price"]);1713- m_textCtrlDescription->SetValue(product.mapValue["description"]);1714- m_textCtrlInstructions->SetValue(product.mapValue["instructions"]);1715-1716- for (int i = 0; i < FIELDS_MAX; i++)1717- {1718- bool fUsed = i < product.vOrderForm.size();1719- m_buttonDel[i]->Show(fUsed);1720- m_textCtrlLabel[i]->Show(fUsed);1721- m_textCtrlField[i]->Show(fUsed);1722- if (!fUsed)1723- continue;1724-1725- m_textCtrlLabel[i]->SetValue(product.vOrderForm[i].first);1726- string strControl = product.vOrderForm[i].second;1727- if (strControl.substr(0, 5) == "text=")1728- m_textCtrlField[i]->SetValue("");1729- else if (strControl.substr(0, 7) == "choice=")1730- m_textCtrlField[i]->SetValue(strControl.substr(7));1731- else1732- m_textCtrlField[i]->SetValue(strControl);1733- }1734-}1735-1736-void CEditProductDialog::GetProduct(CProduct& product)1737-{1738- // map<string, string> mapValue;1739- // vector<pair<string, string> > vOrderForm;1740-1741- product.mapValue["category"] = m_comboBoxCategory->GetValue().Trim();1742- product.mapValue["title"] = m_textCtrlTitle->GetValue().Trim();1743- product.mapValue["price"] = m_textCtrlPrice->GetValue().Trim();1744- product.mapValue["description"] = m_textCtrlDescription->GetValue().Trim();1745- product.mapValue["instructions"] = m_textCtrlInstructions->GetValue().Trim();1746-1747- for (int i = 0; i < FIELDS_MAX; i++)1748- {1749- if (m_buttonDel[i]->IsShown())1750- {1751- string strLabel = (string)m_textCtrlLabel[i]->GetValue().Trim();1752- string strControl = (string)m_textCtrlField[i]->GetValue();1753- if (strControl.empty())1754- strControl = "text=";1755- else1756- strControl = "choice=" + strControl;1757- product.vOrderForm.push_back(make_pair(strLabel, strControl));1758- }1759- }1760-}1761-1762-1763-1764-1765-1766-1767-1768-//////////////////////////////////////////////////////////////////////////////1769-//1770-// CViewProductDialog1771-//1772-1773-CViewProductDialog::CViewProductDialog(wxWindow* parent, const CProduct& productIn) : CViewProductDialogBase(parent)1774-{1775- Connect(wxEVT_REPLY1, wxCommandEventHandler(CViewProductDialog::OnReply1), NULL, this);1776- AddCallbackAvailable(GetEventHandler());1777-1778- // Fill display with product summary while waiting for details1779- product = productIn;1780- UpdateProductDisplay(false);1781-1782- m_buttonBack->Enable(false);1783- m_buttonNext->Enable(!product.vOrderForm.empty());1784- m_htmlWinReviews->Show(true);1785- m_scrolledWindow->Show(false);1786- this->Layout();1787-1788- // Request details from seller1789- CreateThread(ThreadRequestProductDetails, new pair<CProduct, wxEvtHandler*>(product, GetEventHandler()));1790-}1791-1792-CViewProductDialog::~CViewProductDialog()1793-{1794- RemoveCallbackAvailable(GetEventHandler());1795-}1796-1797-void ThreadRequestProductDetails(void* parg)1798-{1799- // Extract parameters1800- pair<CProduct, wxEvtHandler*>* pitem = (pair<CProduct, wxEvtHandler*>*)parg;1801- CProduct product = pitem->first;1802- wxEvtHandler* pevthandler = pitem->second;1803- delete pitem;1804-1805- // Connect to seller1806- CNode* pnode = ConnectNode(product.addr, 5 * 60);1807- if (!pnode)1808- {1809- CDataStream ssEmpty;1810- AddPendingReplyEvent1(pevthandler, ssEmpty);1811- return;1812- }1813-1814- // Request detailed product, with response going to OnReply1 via dialog's event handler1815- pnode->PushRequest("getdetails", product.GetHash(), AddPendingReplyEvent1, (void*)pevthandler);1816-}1817-1818-void CViewProductDialog::OnReply1(wxCommandEvent& event)1819-{1820- CDataStream ss = GetStreamFromEvent(event);1821- if (ss.empty())1822- {1823- product.mapValue["description"] = "-- CAN'T CONNECT TO SELLER --\n";1824- UpdateProductDisplay(true);1825- return;1826- }1827-1828- int nRet;1829- CProduct product2;1830- try1831- {1832- ss >> nRet;1833- if (nRet > 0)1834- throw false;1835- ss >> product2;1836- if (product2.GetHash() != product.GetHash())1837- throw false;1838- if (!product2.CheckSignature())1839- throw false;1840- }1841- catch (...)1842- {1843- product.mapValue["description"] = "-- INVALID RESPONSE --\n";1844- UpdateProductDisplay(true);1845- return;1846- }1847-1848- product = product2;1849- UpdateProductDisplay(true);1850-}1851-1852-bool CompareReviewsBestFirst(const CReview* p1, const CReview* p2)1853-{1854- return (p1->nAtoms > p2->nAtoms);1855-}1856-1857-void CViewProductDialog::UpdateProductDisplay(bool fDetails)1858-{1859- // Product and reviews1860- string strHTML;1861- strHTML.reserve(4000);1862- strHTML += "<html>\n"1863- "<head>\n"1864- "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n"1865- "</head>\n"1866- "<body>\n";1867- strHTML += "<b>Category:</b> " + HtmlEscape(product.mapValue["category"]) + "<br>\n";1868- strHTML += "<b>Title:</b> " + HtmlEscape(product.mapValue["title"]) + "<br>\n";1869- strHTML += "<b>Price:</b> " + HtmlEscape(product.mapValue["price"]) + "<br>\n";1870-1871- if (!fDetails)1872- strHTML += "<b>Loading details...</b><br>\n<br>\n";1873- else1874- strHTML += HtmlEscape(product.mapValue["description"], true) + "<br>\n<br>\n";1875-1876- strHTML += "<b>Reviews:</b><br>\n<br>\n";1877-1878- if (!product.vchPubKeyFrom.empty())1879- {1880- CReviewDB reviewdb("r");1881-1882- // Get reviews1883- vector<CReview> vReviews;1884- reviewdb.ReadReviews(product.GetUserHash(), vReviews);1885-1886- // Get reviewer's number of atoms1887- vector<CReview*> vSortedReviews;1888- vSortedReviews.reserve(vReviews.size());1889- for (vector<CReview>::reverse_iterator it = vReviews.rbegin(); it != vReviews.rend(); ++it)1890- {1891- CReview& review = *it;1892- CUser user;1893- reviewdb.ReadUser(review.GetUserHash(), user);1894- review.nAtoms = user.GetAtomCount();1895- vSortedReviews.push_back(&review);1896- }1897-1898- reviewdb.Close();1899-1900- // Sort1901- stable_sort(vSortedReviews.begin(), vSortedReviews.end(), CompareReviewsBestFirst);1902-1903- // Format reviews1904- foreach(CReview* preview, vSortedReviews)1905- {1906- CReview& review = *preview;1907- int nStars = atoi(review.mapValue["stars"].c_str());1908- if (nStars < 1 || nStars > 5)1909- continue;1910-1911- strHTML += "<b>" + itostr(nStars) + (nStars == 1 ? " star" : " stars") + "</b>";1912- strHTML += " ";1913- strHTML += DateStr(atoi64(review.mapValue["date"])) + "<br>\n";1914- strHTML += HtmlEscape(review.mapValue["review"], true);1915- strHTML += "<br>\n<br>\n";1916- }1917- }1918-1919- strHTML += "</body>\n</html>\n";1920-1921- // Shrink capacity to fit1922- string(strHTML.begin(), strHTML.end()).swap(strHTML);1923-1924- m_htmlWinReviews->SetPage(strHTML);1925-1926- ///// need to find some other indicator to use so can allow empty order form1927- if (product.vOrderForm.empty())1928- return;1929-1930- // Order form1931- m_staticTextInstructions->SetLabel(product.mapValue["instructions"]);1932- for (int i = 0; i < FIELDS_MAX; i++)1933- {1934- m_staticTextLabel[i] = NULL;1935- m_textCtrlField[i] = NULL;1936- m_choiceField[i] = NULL;1937- }1938-1939- // Construct flexgridsizer1940- wxBoxSizer* bSizer21 = (wxBoxSizer*)m_scrolledWindow->GetSizer();1941- wxFlexGridSizer* fgSizer;1942- fgSizer = new wxFlexGridSizer(0, 2, 0, 0);1943- fgSizer->AddGrowableCol(1);1944- fgSizer->SetFlexibleDirection(wxBOTH);1945- fgSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);1946-1947- // Construct order form fields1948- wxWindow* windowLast = NULL;1949- for (int i = 0; i < product.vOrderForm.size(); i++)1950- {1951- string strLabel = product.vOrderForm[i].first;1952- string strControl = product.vOrderForm[i].second;1953-1954- if (strLabel.size() < 20)1955- strLabel.insert(strLabel.begin(), 20 - strLabel.size(), ' ');1956-1957- m_staticTextLabel[i] = new wxStaticText(m_scrolledWindow, wxID_ANY, strLabel, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);1958- m_staticTextLabel[i]->Wrap(-1);1959- fgSizer->Add(m_staticTextLabel[i], 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5);1960-1961- if (strControl.substr(0, 5) == "text=")1962- {1963- m_textCtrlField[i] = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);1964- fgSizer->Add(m_textCtrlField[i], 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5);1965- windowLast = m_textCtrlField[i];1966- }1967- else if (strControl.substr(0, 7) == "choice=")1968- {1969- vector<string> vChoices;1970- ParseString(strControl.substr(7), ',', vChoices);1971-1972- wxArrayString arraystring;1973- foreach(const string& str, vChoices)1974- arraystring.Add(str);1975-1976- m_choiceField[i] = new wxChoice(m_scrolledWindow, wxID_ANY, wxDefaultPosition, wxDefaultSize, arraystring, 0);1977- fgSizer->Add(m_choiceField[i], 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);1978- windowLast = m_choiceField[i];1979- }1980- else1981- {1982- m_textCtrlField[i] = new wxTextCtrl(m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);1983- fgSizer->Add(m_textCtrlField[i], 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5);1984- m_staticTextLabel[i]->Show(false);1985- m_textCtrlField[i]->Show(false);1986- }1987- }1988-1989- // Insert after instructions and before submit/cancel buttons1990- bSizer21->Insert(2, fgSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5);1991- m_scrolledWindow->Layout();1992- bSizer21->Fit(m_scrolledWindow);1993- this->Layout();1994-1995- // Fixup the tab order1996- m_buttonSubmitForm->MoveAfterInTabOrder(windowLast);1997- m_buttonCancelForm->MoveAfterInTabOrder(m_buttonSubmitForm);1998- //m_buttonBack->MoveAfterInTabOrder(m_buttonCancelForm);1999- //m_buttonNext->MoveAfterInTabOrder(m_buttonBack);2000- //m_buttonCancel->MoveAfterInTabOrder(m_buttonNext);2001- this->Layout();2002-}2003-2004-void CViewProductDialog::GetOrder(CWalletTx& wtx)2005-{2006- wtx.SetNull();2007- for (int i = 0; i < product.vOrderForm.size(); i++)2008- {2009- string strValue;2010- if (m_textCtrlField[i])2011- strValue = m_textCtrlField[i]->GetValue().Trim();2012- else2013- strValue = m_choiceField[i]->GetStringSelection();2014- wtx.vOrderForm.push_back(make_pair(m_staticTextLabel[i]->GetLabel(), strValue));2015- }2016-}2017-2018-void CViewProductDialog::OnButtonSubmitForm(wxCommandEvent& event)2019-{2020- m_buttonSubmitForm->Enable(false);2021- m_buttonCancelForm->Enable(false);2022-2023- CWalletTx wtx;2024- GetOrder(wtx);2025-2026- CSendingDialog* pdialog = new CSendingDialog(this, product.addr, atoi64(product.mapValue["price"]), wtx);2027- if (!pdialog->ShowModal())2028- {2029- m_buttonSubmitForm->Enable(true);2030- m_buttonCancelForm->Enable(true);2031- return;2032- }2033-}2034-2035-void CViewProductDialog::OnButtonCancelForm(wxCommandEvent& event)2036-{2037- Destroy();2038-}2039-2040-void CViewProductDialog::OnButtonBack(wxCommandEvent& event)2041-{2042- Freeze();2043- m_htmlWinReviews->Show(true);2044- m_scrolledWindow->Show(false);2045- m_buttonBack->Enable(false);2046- m_buttonNext->Enable(!product.vOrderForm.empty());2047- this->Layout();2048- Thaw();2049-}2050-2051-void CViewProductDialog::OnButtonNext(wxCommandEvent& event)2052-{2053- if (!product.vOrderForm.empty())2054- {2055- Freeze();2056- m_htmlWinReviews->Show(false);2057- m_scrolledWindow->Show(true);2058- m_buttonBack->Enable(true);2059- m_buttonNext->Enable(false);2060- this->Layout();2061- Thaw();2062- }2063-}2064-2065-void CViewProductDialog::OnButtonCancel(wxCommandEvent& event)2066-{2067- Destroy();2068-}2069-2070-2071-2072-2073-2074-2075-2076-//////////////////////////////////////////////////////////////////////////////2077-//2078-// CViewOrderDialog2079-//2080-2081-CViewOrderDialog::CViewOrderDialog(wxWindow* parent, CWalletTx order, bool fReceived) : CViewOrderDialogBase(parent)2082-{2083- int64 nPrice = (fReceived ? order.GetCredit() : order.GetDebit());2084-2085- string strHTML;2086- strHTML.reserve(4000);2087- strHTML += "<html>\n"2088- "<head>\n"2089- "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n"2090- "</head>\n"2091- "<body>\n";2092- strHTML += "<b>Time:</b> " + HtmlEscape(DateTimeStr(order.nTimeReceived)) + "<br>\n";2093- strHTML += "<b>Price:</b> " + HtmlEscape(FormatMoney(nPrice)) + "<br>\n";2094- strHTML += "<b>Status:</b> " + HtmlEscape(FormatTxStatus(order)) + "<br>\n";2095-2096- strHTML += "<table>\n";2097- for (int i = 0; i < order.vOrderForm.size(); i++)2098- {2099- strHTML += " <tr><td><b>" + HtmlEscape(order.vOrderForm[i].first) + ":</b></td>";2100- strHTML += "<td>" + HtmlEscape(order.vOrderForm[i].second) + "</td></tr>\n";2101- }2102- strHTML += "</table>\n";2103-2104- strHTML += "</body>\n</html>\n";2105-2106- // Shrink capacity to fit2107- // (strings are ref counted, so it may live on in SetPage)2108- string(strHTML.begin(), strHTML.end()).swap(strHTML);2109-2110- m_htmlWin->SetPage(strHTML);2111-}2112-2113-void CViewOrderDialog::OnButtonOK(wxCommandEvent& event)2114-{2115- Destroy();2116-}2117-2118-2119-2120-2121-2122-2123-2124-//////////////////////////////////////////////////////////////////////////////2125-//2126-// CEditReviewDialog2127-//2128-2129-CEditReviewDialog::CEditReviewDialog(wxWindow* parent) : CEditReviewDialogBase(parent)2130-{2131-}2132-2133-void CEditReviewDialog::OnButtonSubmit(wxCommandEvent& event)2134-{2135- if (m_choiceStars->GetSelection() == -1)2136- {2137- wxMessageBox("Please select a rating ");2138- return;2139- }2140-2141- CReview review;2142- GetReview(review);2143-2144- // Sign the review2145- review.vchPubKeyFrom = keyUser.GetPubKey();2146- if (!keyUser.Sign(review.GetSigHash(), review.vchSig))2147- {2148- wxMessageBox("Unable to digitally sign the review ");2149- return;2150- }2151-2152- // Broadcast2153- if (!review.AcceptReview())2154- {2155- wxMessageBox("Save failed ");2156- return;2157- }2158- RelayMessage(CInv(MSG_REVIEW, review.GetHash()), review);2159-2160- Destroy();2161-}2162-2163-void CEditReviewDialog::OnButtonCancel(wxCommandEvent& event)2164-{2165- Destroy();2166-}2167-2168-void CEditReviewDialog::GetReview(CReview& review)2169-{2170- review.mapValue["time"] = i64tostr(GetAdjustedTime());2171- review.mapValue["stars"] = itostr(m_choiceStars->GetSelection()+1);2172- review.mapValue["review"] = m_textCtrlReview->GetValue();2173-}2174-2175 2176 2177 2178@@ -3333,11 +2438,11 @@2179 static char pszPrevTip[200];2180 if (fShow)2181 {2182- string strTooltip = "Bitcoin";2183+ string strTooltip = _("Bitcoin");2184 if (fGenerateBitcoins)2185- strTooltip = "Bitcoin - Generating";2186+ strTooltip = _("Bitcoin - Generating");2187 if (fGenerateBitcoins && vNodes.empty())2188- strTooltip = "Bitcoin - (not connected)";2189+ strTooltip = _("Bitcoin - (not connected)");2190 2191 // Optimization, only update when changed, using char array to be reentrant2192 if (strncmp(pszPrevTip, strTooltip.c_str(), sizeof(pszPrevTip)-1) != 0)2193@@ -3376,14 +2481,14 @@2194 {2195 // Since it's modal, get the main window to do it2196 wxCommandEvent event2(wxEVT_COMMAND_MENU_SELECTED, wxID_MENUOPTIONSOPTIONS);2197- pframeMain->AddPendingEvent(event2);2198+ pframeMain->GetEventHandler()->AddPendingEvent(event2);2199 }2200 2201 void CMyTaskBarIcon::Restore()2202 {2203 pframeMain->Show();2204 wxIconizeEvent event(0, false);2205- pframeMain->AddPendingEvent(event);2206+ pframeMain->GetEventHandler()->AddPendingEvent(event);2207 pframeMain->Iconize(false);2208 pframeMain->Raise();2209 }2210@@ -3412,12 +2517,12 @@2211 wxMenu* CMyTaskBarIcon::CreatePopupMenu()2212 {2213 wxMenu* pmenu = new wxMenu;2214- pmenu->Append(ID_TASKBAR_RESTORE, "&Open Bitcoin");2215- pmenu->Append(ID_TASKBAR_OPTIONS, "O&ptions...");2216- pmenu->AppendCheckItem(ID_TASKBAR_GENERATE, "&Generate Coins")->Check(fGenerateBitcoins);2217+ pmenu->Append(ID_TASKBAR_RESTORE, _("&Open Bitcoin"));2218+ pmenu->Append(ID_TASKBAR_OPTIONS, _("O&ptions..."));2219+ pmenu->AppendCheckItem(ID_TASKBAR_GENERATE, _("&Generate Coins"))->Check(fGenerateBitcoins);2220 #ifndef __WXMAC_OSX__ // Mac has built-in quit menu2221 pmenu->AppendSeparator();2222- pmenu->Append(ID_TASKBAR_EXIT, "E&xit");2223+ pmenu->Append(ID_TASKBAR_EXIT, _("E&xit"));2224 #endif2225 return pmenu;2226 }2227@@ -3439,7 +2544,9 @@2228 // Define a new application2229 class CMyApp: public wxApp2230 {2231- public:2232+public:2233+ wxLocale m_locale;2234+2235 CMyApp(){};2236 ~CMyApp(){};2237 bool OnInit();2238@@ -3481,9 +2588,9 @@2239 bool CMyApp::OnInit2()2240 {2241 #ifdef _MSC_VER2242- // Turn off microsoft heap dump noise for now2243+ // Turn off microsoft heap dump noise2244 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);2245- _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));2246+ _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));2247 #endif2248 #if defined(__WXMSW__) && defined(__WXDEBUG__)2249 // Disable malfunctioning wxWidgets debug assertion2250@@ -3496,40 +2603,69 @@2251 SetAppName("bitcoin");2252 umask(077);2253 #endif2254+#ifdef __WXMSW__2255+#if wxUSE_UNICODE2256+ // Hack to set wxConvLibc codepage to UTF-8 on Windows,2257+ // may break if wxMBConv_win32 implementation in strconv.cpp changes.2258+ class wxMBConv_win32 : public wxMBConv2259+ {2260+ public:2261+ long m_CodePage;2262+ size_t m_minMBCharWidth;2263+ };2264+ if (((wxMBConv_win32*)&wxConvLibc)->m_CodePage == CP_ACP)2265+ ((wxMBConv_win32*)&wxConvLibc)->m_CodePage = CP_UTF8;2266+#endif2267+#endif2268+2269+ // Load locale/<lang>/LC_MESSAGES/bitcoin.mo language file2270+ m_locale.Init(wxLANGUAGE_DEFAULT, 0);2271+ m_locale.AddCatalogLookupPathPrefix("locale");2272+ if (!fWindows)2273+ {2274+ m_locale.AddCatalogLookupPathPrefix("/usr/share/locale");2275+ m_locale.AddCatalogLookupPathPrefix("/usr/local/share/locale");2276+ }2277+ m_locale.AddCatalog("wxstd"); // wxWidgets standard translations, if any2278+ m_locale.AddCatalog("bitcoin");2279 2280 //2281 // Parameters2282 //2283+ if (argc > 1 && argv[1][0] != '-' && argv[1][0] != '/')2284+ {2285+ int ret = CommandLineRPC(argc, argv);2286+ exit(ret);2287+ }2288+2289 ParseParameters(argc, argv);2290 if (mapArgs.count("-?") || mapArgs.count("--help"))2291 {2292-#ifdef __WXMSW__2293- string strUsage =2294- "Usage: bitcoin [options]\t\t\t\t\t\t\n"2295- "Options:\n"2296- " -gen\t\t Generate coins\n"2297- " -gen=0\t\t Don't generate coins\n"2298- " -min\t\t Start minimized\n"2299- " -datadir=<dir>\t Specify data directory\n"2300- " -proxy=<ip:port>\t Connect through socks4 proxy\n"2301- " -addnode=<ip>\t Add a node to connect to\n"2302- " -connect=<ip>\t Connect only to the specified node\n"2303- " -?\t\t This help message\n";2304- wxMessageBox(strUsage, "Bitcoin", wxOK);2305-#else2306- string strUsage =2307- "Usage: bitcoin [options]\n"2308- "Options:\n"2309- " -gen Generate coins\n"2310- " -gen=0 Don't generate coins\n"2311- " -min Start minimized\n"2312- " -datadir=<dir> Specify data directory\n"2313- " -proxy=<ip:port> Connect through socks4 proxy\n"2314- " -addnode=<ip> Add a node to connect to\n"2315- " -connect=<ip> Connect only to the specified node\n"2316- " -? This help message\n";2317- fprintf(stderr, "%s", strUsage.c_str());2318-#endif2319+ wxString strUsage = string() +2320+ _("Usage: bitcoin [options]") + "\t\t\t\t\t\t\n" +2321+ _("Options:\n") +2322+ " -gen \t\t " + _("Generate coins\n") +2323+ " -gen=0 \t\t " + _("Don't generate coins\n") +2324+ " -min \t\t " + _("Start minimized\n") +2325+ " -datadir=<dir> \t " + _("Specify data directory\n") +2326+ " -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") +2327+ " -addnode=<ip> \t " + _("Add a node to connect to\n") +2328+ " -connect=<ip> \t " + _("Connect only to the specified node\n") +2329+ " -? \t\t " + _("This help message\n");2330+2331+ if (fWindows)2332+ {2333+ // Remove spaces, the tabs make the columns line up in the message box2334+ for (int i = 0; i < 50; i++)2335+ strUsage.Replace(" \t", "\t");2336+ wxMessageBox(strUsage, "Bitcoin", wxOK);2337+ }2338+ else2339+ {2340+ // Remove tabs2341+ strUsage.Replace("\t", "");2342+ fprintf(stderr, "%s", ((string)strUsage).c_str());2343+ }2344 return false;2345 }2346 2347@@ -3541,11 +2677,20 @@2348 2349 if (mapArgs.count("-printtodebugger"))2350 fPrintToDebugger = true;2351+2352+ if (mapArgs.count("-daemon") || mapArgs.count("-d"))2353+ {2354+ fDaemon = true;2355+ /// todo: need to fork2356+ /// should it fork after the bind/single instance stuff?2357+ }2358 2359 if (!fDebug && !pszSetDataDir[0])2360 ShrinkDebugFile();2361 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");2362- printf("Bitcoin version %d%s, OS version %s\n", VERSION, pszSubVer, wxGetOsDescription().mb_str());2363+ printf("Bitcoin version 0.%d.%d%s beta, OS version %s\n", VERSION/100, VERSION%100, pszSubVer, ((string)wxGetOsDescription()).c_str());2364+ printf("System default language is %d %s\n", m_locale.GetSystemLanguage(), ((string)m_locale.GetSysName()).c_str());2365+ printf("Language file %s (%s)\n", (string("locale/") + (string)m_locale.GetCanonicalName() + "/LC_MESSAGES/bitcoin.mo").c_str(), ((string)m_locale.GetLocale()).c_str());2366 2367 if (mapArgs.count("-loadblockindextest"))2368 {2369@@ -3575,7 +2720,7 @@2370 {2371 // TODO: find out how to do this in Linux, or replace with wxWidgets commands2372 // Show the previous instance and exit2373- HWND hwndPrev = FindWindow("wxWindowClassNR", "Bitcoin");2374+ HWND hwndPrev = FindWindowA("wxWindowClassNR", "Bitcoin");2375 if (hwndPrev)2376 {2377 if (IsIconic(hwndPrev))2378@@ -3616,19 +2761,19 @@2379 printf("Loading addresses...\n");2380 nStart = GetTimeMillis();2381 if (!LoadAddresses())2382- strErrors += "Error loading addr.dat \n";2383+ strErrors += _("Error loading addr.dat \n");2384 printf(" addresses %15"PRI64d"ms\n", GetTimeMillis() - nStart);2385 2386 printf("Loading block index...\n");2387 nStart = GetTimeMillis();2388 if (!LoadBlockIndex())2389- strErrors += "Error loading blkindex.dat \n";2390+ strErrors += _("Error loading blkindex.dat \n");2391 printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);2392 2393 printf("Loading wallet...\n");2394 nStart = GetTimeMillis();2395 if (!LoadWallet(fFirstRun))2396- strErrors += "Error loading wallet.dat \n";2397+ strErrors += _("Error loading wallet.dat \n");2398 printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);2399 2400 printf("Done loading\n");2401@@ -3696,36 +2841,38 @@2402 addrProxy = CAddress(mapArgs["-proxy"]);2403 if (!addrProxy.IsValid())2404 {2405- wxMessageBox("Invalid -proxy address", "Bitcoin");2406+ wxMessageBox(_("Invalid -proxy address"), "Bitcoin");2407 return false;2408 }2409 }2410 2411 if (mapArgs.count("-addnode"))2412 {2413- CAddrDB addrdb;2414 foreach(string strAddr, mapMultiArgs["-addnode"])2415 {2416 CAddress addr(strAddr, NODE_NETWORK);2417 addr.nTime = 0; // so it won't relay unless successfully connected2418 if (addr.IsValid())2419- AddAddress(addrdb, addr);2420+ AddAddress(addr);2421 }2422 }2423 2424 //2425 // Create the main frame window2426 //2427- pframeMain = new CMainFrame(NULL);2428- if (mapArgs.count("-min"))2429- pframeMain->Iconize(true);2430- pframeMain->Show(true); // have to show first to get taskbar button to hide2431- if (fMinimizeToTray && pframeMain->IsIconized())2432- fClosedToTray = true;2433- pframeMain->Show(!fClosedToTray);2434- ptaskbaricon->Show(fMinimizeToTray || fClosedToTray);2435-2436- CreateThread(ThreadDelayedRepaint, NULL);2437+ if (!fDaemon)2438+ {2439+ pframeMain = new CMainFrame(NULL);2440+ if (mapArgs.count("-min"))2441+ pframeMain->Iconize(true);2442+ pframeMain->Show(true); // have to show first to get taskbar button to hide2443+ if (fMinimizeToTray && pframeMain->IsIconized())2444+ fClosedToTray = true;2445+ pframeMain->Show(!fClosedToTray);2446+ ptaskbaricon->Show(fMinimizeToTray || fClosedToTray);2447+2448+ CreateThread(ThreadDelayedRepaint, NULL);2449+ }2450 2451 if (!CheckDiskSpace())2452 return false;2453@@ -3734,6 +2881,9 @@2454 2455 if (!CreateThread(StartNode, NULL))2456 wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin");2457+2458+ if (mapArgs.count("-server") || fDaemon)2459+ CreateThread(ThreadRPCServer, NULL);2460 2461 if (fFirstRun)2462 SetStartOnSystemStartup(true);2463@@ -3826,7 +2976,7 @@2464 2465 void CMyApp::OnFatalException()2466 {2467- wxMessageBox("Program has crashed and will terminate. ", "Bitcoin", wxOK | wxICON_ERROR);2468+ wxMessageBox(_("Program has crashed and will terminate. "), "Bitcoin", wxOK | wxICON_ERROR);2469 }2470 2471 2472@@ -3841,7 +2991,7 @@2473 char pszPath[MAX_PATH+100] = "";2474 2475 // SHGetSpecialFolderPath is not usually available on NT 4.02476- HMODULE hShell32 = LoadLibrary("shell32.dll");2477+ HMODULE hShell32 = LoadLibraryA("shell32.dll");2478 if (hShell32)2479 {2480 PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =2481@@ -3896,7 +3046,7 @@2482 if (SUCCEEDED(hres))2483 {2484 // Get the current executable path2485- char pszExePath[MAX_PATH];2486+ TCHAR pszExePath[MAX_PATH];2487 GetModuleFileName(NULL, pszExePath, sizeof(pszExePath));2488 2489 // Set the path to the shortcut target
ui.h (modified)
1--- v0.2.0/ui.h2+++ v0.2.2/ui.h3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -6,12 +6,6 @@10 11 12 DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)13-DECLARE_EVENT_TYPE(wxEVT_REPLY1, -1)14-DECLARE_EVENT_TYPE(wxEVT_REPLY2, -1)15-DECLARE_EVENT_TYPE(wxEVT_REPLY3, -1)16-17-18-19 20 extern map<string, string> mapArgs;21 22@@ -22,12 +16,12 @@23 24 25 26-extern void HandleCtrlA(wxKeyEvent& event);27-extern string FormatTxStatus(const CWalletTx& wtx);28-extern void UIThreadCall(boost::function0<void>);29-extern void MainFrameRepaint();30-extern void Shutdown(void* parg);31-extern int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);32+void HandleCtrlA(wxKeyEvent& event);33+string FormatTxStatus(const CWalletTx& wtx);34+void UIThreadCall(boost::function0<void>);35+void MainFrameRepaint();36+void Shutdown(void* parg);37+int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);38 39 40 41@@ -57,10 +51,10 @@42 void OnButtonAddressBook(wxCommandEvent& event);43 void OnSetFocusAddress(wxFocusEvent& event);44 void OnMouseEventsAddress(wxMouseEvent& event);45+ void OnButtonChange(wxCommandEvent& event);46 void OnButtonCopy(wxCommandEvent& event);47- void OnButtonChange(wxCommandEvent& event);48 void OnListColBeginDrag(wxListEvent& event);49- void OnListItemActivatedAllTransactions(wxListEvent& event);50+ void OnListItemActivated(wxListEvent& event);51 void OnListItemActivatedProductsSent(wxListEvent& event);52 void OnListItemActivatedOrdersSent(wxListEvent& event);53 void OnListItemActivatedOrdersReceived(wxListEvent& event);54@@ -259,138 +253,6 @@55 bool fSending;56 wxString GetAddress();57 bool CheckIfMine(const string& strAddress, const string& strTitle);58-};59-60-61-62-class CProductsDialog : public CProductsDialogBase63-{64-protected:65- // Event handlers66- void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }67- void OnCombobox(wxCommandEvent& event);68- void OnButtonSearch(wxCommandEvent& event);69- void OnListItemActivated(wxListEvent& event);70-71-public:72- /** Constructor */73- CProductsDialog(wxWindow* parent);74-75- // Custom76- vector<CProduct> m_vProduct;77-};78-79-80-81-class CEditProductDialog : public CEditProductDialogBase82-{83-protected:84- // Event handlers85- void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }86- void OnButtonDel0(wxCommandEvent& event);87- void OnButtonDel1(wxCommandEvent& event);88- void OnButtonDel2(wxCommandEvent& event);89- void OnButtonDel3(wxCommandEvent& event);90- void OnButtonDel4(wxCommandEvent& event);91- void OnButtonDel5(wxCommandEvent& event);92- void OnButtonDel6(wxCommandEvent& event);93- void OnButtonDel7(wxCommandEvent& event);94- void OnButtonDel8(wxCommandEvent& event);95- void OnButtonDel9(wxCommandEvent& event);96- void OnButtonDel10(wxCommandEvent& event);97- void OnButtonDel11(wxCommandEvent& event);98- void OnButtonDel12(wxCommandEvent& event);99- void OnButtonDel13(wxCommandEvent& event);100- void OnButtonDel14(wxCommandEvent& event);101- void OnButtonDel15(wxCommandEvent& event);102- void OnButtonDel16(wxCommandEvent& event);103- void OnButtonDel17(wxCommandEvent& event);104- void OnButtonDel18(wxCommandEvent& event);105- void OnButtonDel19(wxCommandEvent& event);106- void OnButtonAddField(wxCommandEvent& event);107- void OnButtonSend(wxCommandEvent& event);108- void OnButtonPreview(wxCommandEvent& event);109- void OnButtonCancel(wxCommandEvent& event);110-111-public:112- /** Constructor */113- CEditProductDialog(wxWindow* parent);114-115- // Custom116- enum { FIELDS_MAX = 20 };117- wxTextCtrl* m_textCtrlLabel[FIELDS_MAX];118- wxTextCtrl* m_textCtrlField[FIELDS_MAX];119- wxButton* m_buttonDel[FIELDS_MAX];120-121- void LayoutAll();122- void ShowLine(int i, bool fShow=true);123- void OnButtonDel(wxCommandEvent& event, int n);124- void SetProduct(const CProduct& productIn);125- void GetProduct(CProduct& product);126-127-};128-129-130-131-class CViewProductDialog : public CViewProductDialogBase132-{133-protected:134- // Event handlers135- void OnButtonSubmitForm(wxCommandEvent& event);136- void OnButtonCancelForm(wxCommandEvent& event);137- void OnButtonBack(wxCommandEvent& event);138- void OnButtonNext(wxCommandEvent& event);139- void OnButtonCancel(wxCommandEvent& event);140-141-public:142- /** Constructor */143- CViewProductDialog(wxWindow* parent, const CProduct& productIn);144- ~CViewProductDialog();145-146- // Custom147- CProduct product;148- enum { FIELDS_MAX = 20 };149- wxStaticText* m_staticTextLabel[FIELDS_MAX];150- wxTextCtrl* m_textCtrlField[FIELDS_MAX];151- wxChoice* m_choiceField[FIELDS_MAX];152-153- void GetOrder(CWalletTx& order);154- void UpdateProductDisplay(bool fDetails);155- void OnReply1(wxCommandEvent& event);156-};157-158-159-160-class CViewOrderDialog : public CViewOrderDialogBase161-{162-protected:163- // Event handlers164- void OnButtonOK(wxCommandEvent& event);165-166-public:167- /** Constructor */168- CViewOrderDialog(wxWindow* parent, CWalletTx order, bool fReceived);169-170- // Custom171- bool fReceived;172-};173-174-175-176-class CEditReviewDialog : public CEditReviewDialogBase177-{178-protected:179- // Event handlers180- void OnKeyDown(wxKeyEvent& event) { HandleCtrlA(event); }181- void OnButtonSubmit(wxCommandEvent& event);182- void OnButtonCancel(wxCommandEvent& event);183-184-public:185- /** Constructor */186- CEditReviewDialog(wxWindow* parent);187-188- // Custom189- void GetReview(CReview& review);190 };191 192 193@@ -430,6 +292,8 @@194 m_textCtrl2->SetValue(strValue2);195 SetSize(wxDefaultCoord, 180);196 }197+ if (!fWindows)198+ SetSize(1.14 * GetSize().GetWidth(), 1.14 * GetSize().GetHeight());199 }200 201 // Custom
uibase.cpp (modified)
1--- v0.2.0/uibase.cpp2+++ v0.2.2/uibase.cpp3@@ -7,6 +7,7 @@4 5 #include "uibase.h"6 7+#include "xpm/about.xpm"8 #include "xpm/addressbook20.xpm"9 #include "xpm/check.xpm"10 #include "xpm/send20.xpm"11@@ -23,39 +24,39 @@12 13 m_menuFile = new wxMenu();14 wxMenuItem* m_menuFileExit;15- m_menuFileExit = new wxMenuItem( m_menuFile, wxID_ANY, wxString( wxT("E&xit") ) , wxEmptyString, wxITEM_NORMAL );16+ m_menuFileExit = new wxMenuItem( m_menuFile, wxID_ANY, wxString( _("E&xit") ) , wxEmptyString, wxITEM_NORMAL );17 m_menuFile->Append( m_menuFileExit );18 19- m_menubar->Append( m_menuFile, wxT("&File") );20+ m_menubar->Append( m_menuFile, _("&File") );21 22 m_menuView = new wxMenu();23 wxMenuItem* m_menuViewShowGenerated;24- m_menuViewShowGenerated = new wxMenuItem( m_menuView, wxID_VIEWSHOWGENERATED, wxString( wxT("&Show Generated Coins") ) , wxEmptyString, wxITEM_CHECK );25+ m_menuViewShowGenerated = new wxMenuItem( m_menuView, wxID_VIEWSHOWGENERATED, wxString( _("&Show Generated Coins") ) , wxEmptyString, wxITEM_CHECK );26 m_menuView->Append( m_menuViewShowGenerated );27 28- m_menubar->Append( m_menuView, wxT("&View") );29+ m_menubar->Append( m_menuView, _("&View") );30 31 m_menuOptions = new wxMenu();32 wxMenuItem* m_menuOptionsGenerateBitcoins;33- m_menuOptionsGenerateBitcoins = new wxMenuItem( m_menuOptions, wxID_OPTIONSGENERATEBITCOINS, wxString( wxT("&Generate Coins") ) , wxEmptyString, wxITEM_CHECK );34+ m_menuOptionsGenerateBitcoins = new wxMenuItem( m_menuOptions, wxID_OPTIONSGENERATEBITCOINS, wxString( _("&Generate Coins") ) , wxEmptyString, wxITEM_CHECK );35 m_menuOptions->Append( m_menuOptionsGenerateBitcoins );36 37 wxMenuItem* m_menuOptionsChangeYourAddress;38- m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( wxT("&Change Your Address...") ) , wxEmptyString, wxITEM_NORMAL );39+ m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Change Your Address...") ) , wxEmptyString, wxITEM_NORMAL );40 m_menuOptions->Append( m_menuOptionsChangeYourAddress );41 42 wxMenuItem* m_menuOptionsOptions;43- m_menuOptionsOptions = new wxMenuItem( m_menuOptions, wxID_MENUOPTIONSOPTIONS, wxString( wxT("&Options...") ) , wxEmptyString, wxITEM_NORMAL );44+ m_menuOptionsOptions = new wxMenuItem( m_menuOptions, wxID_MENUOPTIONSOPTIONS, wxString( _("&Options...") ) , wxEmptyString, wxITEM_NORMAL );45 m_menuOptions->Append( m_menuOptionsOptions );46 47- m_menubar->Append( m_menuOptions, wxT("&Options") );48+ m_menubar->Append( m_menuOptions, _("&Options") );49 50 m_menuHelp = new wxMenu();51 wxMenuItem* m_menuHelpAbout;52- m_menuHelpAbout = new wxMenuItem( m_menuHelp, wxID_ANY, wxString( wxT("&About...") ) , wxEmptyString, wxITEM_NORMAL );53+ m_menuHelpAbout = new wxMenuItem( m_menuHelp, wxID_ANY, wxString( _("&About...") ) , wxEmptyString, wxITEM_NORMAL );54 m_menuHelp->Append( m_menuHelpAbout );55 56- m_menubar->Append( m_menuHelp, wxT("&Help") );57+ m_menubar->Append( m_menuHelp, _("&Help") );58 59 this->SetMenuBar( m_menubar );60 61@@ -64,8 +65,8 @@62 m_toolBar->SetToolSeparation( 1 );63 m_toolBar->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );64 65- m_toolBar->AddTool( wxID_BUTTONSEND, wxT("&Send Coins"), wxBitmap( send20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );66- m_toolBar->AddTool( wxID_BUTTONRECEIVE, wxT("&Address Book"), wxBitmap( addressbook20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );67+ m_toolBar->AddTool( wxID_BUTTONSEND, _("&Send Coins"), wxBitmap( send20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );68+ m_toolBar->AddTool( wxID_BUTTONRECEIVE, _("&Address Book"), wxBitmap( addressbook20_xpm ), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString );69 m_toolBar->Realize();70 71 m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );72@@ -80,7 +81,7 @@73 wxBoxSizer* bSizer85;74 bSizer85 = new wxBoxSizer( wxHORIZONTAL );75 76- m_staticText32 = new wxStaticText( this, wxID_ANY, wxT("Your Bitcoin Address:"), wxDefaultPosition, wxDefaultSize, 0 );77+ m_staticText32 = new wxStaticText( this, wxID_ANY, _("Your Bitcoin Address:"), wxDefaultPosition, wxDefaultSize, 0 );78 m_staticText32->Wrap( -1 );79 bSizer85->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );80 81@@ -89,13 +90,13 @@82 83 bSizer85->Add( m_textCtrlAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );84 85- m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, wxT(" &Copy to Clipboard "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );86+ m_buttonNew = new wxButton( this, wxID_BUTTONCHANGE, _("&New..."), wxDefaultPosition, wxDefaultSize, 0 );87+ m_buttonNew->Hide();88+ 89+ bSizer85->Add( m_buttonNew, 0, wxRIGHT, 5 );90+ 91+ m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, _(" &Copy to Clipboard "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );92 bSizer85->Add( m_buttonCopy, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );93- 94- m_button91 = new wxButton( this, wxID_BUTTONCHANGE, wxT("C&hange..."), wxDefaultPosition, wxDefaultSize, 0 );95- m_button91->Hide();96- 97- bSizer85->Add( m_button91, 0, wxRIGHT, 5 );98 99 100 bSizer85->Add( 0, 0, 0, wxEXPAND, 5 );101@@ -109,7 +110,7 @@102 wxBoxSizer* bSizer66;103 bSizer66 = new wxBoxSizer( wxHORIZONTAL );104 105- m_staticText41 = new wxStaticText( m_panel14, wxID_ANY, wxT("Balance:"), wxDefaultPosition, wxSize( -1,15 ), 0 );106+ m_staticText41 = new wxStaticText( m_panel14, wxID_ANY, _("Balance:"), wxDefaultPosition, wxSize( -1,15 ), 0 );107 m_staticText41->Wrap( -1 );108 bSizer66->Add( m_staticText41, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );109 110@@ -128,7 +129,7 @@111 112 bSizer3->Add( 0, 0, 0, wxEXPAND, 5 );113 114- wxString m_choiceFilterChoices[] = { wxT(" All"), wxT(" Sent"), wxT(" Received"), wxT(" In Progress") };115+ wxString m_choiceFilterChoices[] = { _(" All"), _(" Sent"), _(" Received"), _(" In Progress") };116 int m_choiceFilterNChoices = sizeof( m_choiceFilterChoices ) / sizeof( wxString );117 m_choiceFilter = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxSize( 110,-1 ), m_choiceFilterNChoices, m_choiceFilterChoices, 0 );118 m_choiceFilter->SetSelection( 0 );119@@ -138,81 +139,8 @@120 121 bSizer2->Add( bSizer3, 0, wxEXPAND, 5 );122 123- m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );124- m_panel7 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );125- wxBoxSizer* bSizer157;126- bSizer157 = new wxBoxSizer( wxVERTICAL );127- 128- m_listCtrl = new wxListCtrl( m_panel7, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxVSCROLL );129- bSizer157->Add( m_listCtrl, 1, wxEXPAND|wxALL, 5 );130- 131- m_panel7->SetSizer( bSizer157 );132- m_panel7->Layout();133- bSizer157->Fit( m_panel7 );134- m_notebook->AddPage( m_panel7, wxT("All Transactions"), false );135- 136- bSizer2->Add( m_notebook, 1, wxEXPAND, 5 );137- 138- wxBoxSizer* bSizer_TabsForFutureUse;139- bSizer_TabsForFutureUse = new wxBoxSizer( wxVERTICAL );140- 141- m_panel9 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );142- m_panel9->Hide();143- 144- wxBoxSizer* bSizer159;145- bSizer159 = new wxBoxSizer( wxVERTICAL );146- 147- m_listCtrlEscrows = new wxListCtrl( m_panel9, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );148- bSizer159->Add( m_listCtrlEscrows, 1, wxALL|wxEXPAND, 5 );149- 150- m_panel9->SetSizer( bSizer159 );151- m_panel9->Layout();152- bSizer159->Fit( m_panel9 );153- bSizer_TabsForFutureUse->Add( m_panel9, 1, wxEXPAND | wxALL, 5 );154- 155- m_panel8 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );156- m_panel8->Hide();157- 158- wxBoxSizer* bSizer158;159- bSizer158 = new wxBoxSizer( wxVERTICAL );160- 161- m_listCtrlOrdersSent = new wxListCtrl( m_panel8, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );162- bSizer158->Add( m_listCtrlOrdersSent, 1, wxALL|wxEXPAND, 5 );163- 164- m_panel8->SetSizer( bSizer158 );165- m_panel8->Layout();166- bSizer158->Fit( m_panel8 );167- bSizer_TabsForFutureUse->Add( m_panel8, 1, wxEXPAND | wxALL, 5 );168- 169- m_panel10 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );170- m_panel10->Hide();171- 172- wxBoxSizer* bSizer160;173- bSizer160 = new wxBoxSizer( wxVERTICAL );174- 175- m_listCtrlProductsSent = new wxListCtrl( m_panel10, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );176- bSizer160->Add( m_listCtrlProductsSent, 1, wxALL|wxEXPAND, 5 );177- 178- m_panel10->SetSizer( bSizer160 );179- m_panel10->Layout();180- bSizer160->Fit( m_panel10 );181- bSizer_TabsForFutureUse->Add( m_panel10, 1, wxEXPAND | wxALL, 5 );182- 183- m_panel11 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );184- m_panel11->Hide();185- 186- wxBoxSizer* bSizer161;187- bSizer161 = new wxBoxSizer( wxVERTICAL );188- 189- m_listCtrlOrdersReceived = new wxListCtrl( m_panel11, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );190- bSizer161->Add( m_listCtrlOrdersReceived, 1, wxALL|wxEXPAND, 5 );191- 192- m_panel11->SetSizer( bSizer161 );193- m_panel11->Layout();194- bSizer161->Fit( m_panel11 );195- bSizer_TabsForFutureUse->Add( m_panel11, 1, wxEXPAND | wxALL, 5 );196- 197- bSizer2->Add( bSizer_TabsForFutureUse, 1, wxEXPAND, 5 );198+ m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxVSCROLL );199+ bSizer2->Add( m_listCtrl, 1, wxEXPAND, 5 );200 201 this->SetSizer( bSizer2 );202 this->Layout();203@@ -260,14 +188,11 @@204 m_textCtrlAddress->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );205 m_textCtrlAddress->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );206 m_textCtrlAddress->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( CMainFrameBase::OnSetFocusAddress ), NULL, this );207+ m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );208 m_buttonCopy->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonCopy ), NULL, this );209- m_button91->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );210 m_listCtrl->Connect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );211- m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedAllTransactions ), NULL, this );212+ m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );213 m_listCtrl->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );214- m_listCtrlOrdersSent->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedOrdersSent ), NULL, this );215- m_listCtrlProductsSent->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedProductsSent ), NULL, this );216- m_listCtrlOrdersReceived->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedOrdersReceived ), NULL, this );217 }218 219 CMainFrameBase::~CMainFrameBase()220@@ -315,14 +240,11 @@221 m_textCtrlAddress->Disconnect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );222 m_textCtrlAddress->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );223 m_textCtrlAddress->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( CMainFrameBase::OnSetFocusAddress ), NULL, this );224+ m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );225 m_buttonCopy->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonCopy ), NULL, this );226- m_button91->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );227 m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );228- m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedAllTransactions ), NULL, this );229+ m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );230 m_listCtrl->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );231- m_listCtrlOrdersSent->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedOrdersSent ), NULL, this );232- m_listCtrlProductsSent->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedProductsSent ), NULL, this );233- m_listCtrlOrdersReceived->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivatedOrdersReceived ), NULL, this );234 }235 236 CTxDetailsDialogBase::CTxDetailsDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )237@@ -343,7 +265,7 @@238 wxBoxSizer* bSizer65;239 bSizer65 = new wxBoxSizer( wxHORIZONTAL );240 241- m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );242+ m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );243 bSizer65->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );244 245 bSizer64->Add( bSizer65, 0, wxALIGN_RIGHT, 5 );246@@ -386,7 +308,7 @@247 248 bSizer69->Add( 0, 16, 0, wxEXPAND, 5 );249 250- m_staticText32 = new wxStaticText( m_panelMain, wxID_ANY, wxT("Optional transaction fee you give to the nodes that process your transactions."), wxDefaultPosition, wxDefaultSize, 0 );251+ m_staticText32 = new wxStaticText( m_panelMain, wxID_ANY, _("Optional transaction fee you give to the nodes that process your transactions."), wxDefaultPosition, wxDefaultSize, 0 );252 m_staticText32->Wrap( -1 );253 m_staticText32->Hide();254 255@@ -395,7 +317,7 @@256 wxBoxSizer* bSizer56;257 bSizer56 = new wxBoxSizer( wxHORIZONTAL );258 259- m_staticText31 = new wxStaticText( m_panelMain, wxID_ANY, wxT("Transaction fee:"), wxDefaultPosition, wxDefaultSize, 0 );260+ m_staticText31 = new wxStaticText( m_panelMain, wxID_ANY, _("Transaction fee:"), wxDefaultPosition, wxDefaultSize, 0 );261 m_staticText31->Wrap( -1 );262 m_staticText31->Hide();263 264@@ -411,35 +333,35 @@265 wxBoxSizer* bSizer71;266 bSizer71 = new wxBoxSizer( wxHORIZONTAL );267 268- m_checkBoxLimitProcessors = new wxCheckBox( m_panelMain, wxID_ANY, wxT("&Limit coin generation to"), wxDefaultPosition, wxDefaultSize, 0 );269+ m_checkBoxLimitProcessors = new wxCheckBox( m_panelMain, wxID_ANY, _("&Limit coin generation to"), wxDefaultPosition, wxDefaultSize, 0 );270 271 bSizer71->Add( m_checkBoxLimitProcessors, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );272 273 m_spinCtrlLimitProcessors = new wxSpinCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 48,-1 ), wxSP_ARROW_KEYS, 1, 999, 1 );274 bSizer71->Add( m_spinCtrlLimitProcessors, 0, wxALIGN_CENTER_VERTICAL, 5 );275 276- m_staticText35 = new wxStaticText( m_panelMain, wxID_ANY, wxT("processors"), wxDefaultPosition, wxDefaultSize, 0 );277+ m_staticText35 = new wxStaticText( m_panelMain, wxID_ANY, _("processors"), wxDefaultPosition, wxDefaultSize, 0 );278 m_staticText35->Wrap( -1 );279 bSizer71->Add( m_staticText35, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );280 281 bSizer69->Add( bSizer71, 0, 0, 5 );282 283- m_checkBoxStartOnSystemStartup = new wxCheckBox( m_panelMain, wxID_ANY, wxT("&Start Bitcoin on system startup"), wxDefaultPosition, wxDefaultSize, 0 );284+ m_checkBoxStartOnSystemStartup = new wxCheckBox( m_panelMain, wxID_ANY, _("&Start Bitcoin on system startup"), wxDefaultPosition, wxDefaultSize, 0 );285 286 bSizer69->Add( m_checkBoxStartOnSystemStartup, 0, wxALL, 5 );287 288- m_checkBoxMinimizeToTray = new wxCheckBox( m_panelMain, wxID_ANY, wxT("&Minimize to the tray instead of the taskbar"), wxDefaultPosition, wxDefaultSize, 0 );289+ m_checkBoxMinimizeToTray = new wxCheckBox( m_panelMain, wxID_ANY, _("&Minimize to the tray instead of the taskbar"), wxDefaultPosition, wxDefaultSize, 0 );290 291 bSizer69->Add( m_checkBoxMinimizeToTray, 0, wxALL, 5 );292 293- m_checkBoxMinimizeOnClose = new wxCheckBox( m_panelMain, wxID_ANY, wxT("M&inimize to the tray on close"), wxDefaultPosition, wxDefaultSize, 0 );294+ m_checkBoxMinimizeOnClose = new wxCheckBox( m_panelMain, wxID_ANY, _("M&inimize to the tray on close"), wxDefaultPosition, wxDefaultSize, 0 );295 296 bSizer69->Add( m_checkBoxMinimizeOnClose, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );297 298 wxBoxSizer* bSizer102;299 bSizer102 = new wxBoxSizer( wxHORIZONTAL );300 301- m_checkBoxUseProxy = new wxCheckBox( m_panelMain, wxID_ANY, wxT("&Connect through socks4 proxy: "), wxDefaultPosition, wxDefaultSize, 0 );302+ m_checkBoxUseProxy = new wxCheckBox( m_panelMain, wxID_ANY, _("&Connect through socks4 proxy: "), wxDefaultPosition, wxDefaultSize, 0 );303 304 bSizer102->Add( m_checkBoxUseProxy, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );305 306@@ -451,7 +373,7 @@307 308 bSizer103->Add( 18, 0, 0, 0, 5 );309 310- m_staticTextProxyIP = new wxStaticText( m_panelMain, wxID_ANY, wxT("Proxy &IP:"), wxDefaultPosition, wxDefaultSize, 0 );311+ m_staticTextProxyIP = new wxStaticText( m_panelMain, wxID_ANY, _("Proxy &IP:"), wxDefaultPosition, wxDefaultSize, 0 );312 m_staticTextProxyIP->Wrap( -1 );313 bSizer103->Add( m_staticTextProxyIP, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );314 315@@ -459,7 +381,7 @@316 m_textCtrlProxyIP->SetMaxLength( 15 ); 317 bSizer103->Add( m_textCtrlProxyIP, 0, wxALIGN_CENTER_VERTICAL, 5 );318 319- m_staticTextProxyPort = new wxStaticText( m_panelMain, wxID_ANY, wxT(" &Port:"), wxDefaultPosition, wxDefaultSize, 0 );320+ m_staticTextProxyPort = new wxStaticText( m_panelMain, wxID_ANY, _(" &Port:"), wxDefaultPosition, wxDefaultSize, 0 );321 m_staticTextProxyPort->Wrap( -1 );322 bSizer103->Add( m_staticTextProxyPort, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );323 324@@ -481,21 +403,13 @@325 326 bSizer64->Add( 0, 16, 0, wxEXPAND, 5 );327 328- m_staticText321 = new wxStaticText( m_panelTest2, wxID_ANY, wxT("Test panel 2 for future expansion"), wxDefaultPosition, wxDefaultSize, 0 );329+ m_staticText321 = new wxStaticText( m_panelTest2, wxID_ANY, _("// [don't translate] Test panel 2 for future expansion"), wxDefaultPosition, wxDefaultSize, 0 );330 m_staticText321->Wrap( -1 );331 bSizer64->Add( m_staticText321, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );332 333- m_staticText69 = new wxStaticText( m_panelTest2, wxID_ANY, wxT("Let's not start multiple pages until the first page is filled up"), wxDefaultPosition, wxDefaultSize, 0 );334+ m_staticText69 = new wxStaticText( m_panelTest2, wxID_ANY, _("// [don't translate] Let's not start multiple pages until the first page is filled up"), wxDefaultPosition, wxDefaultSize, 0 );335 m_staticText69->Wrap( -1 );336 bSizer64->Add( m_staticText69, 0, wxALL, 5 );337- 338- m_staticText70 = new wxStaticText( m_panelTest2, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );339- m_staticText70->Wrap( -1 );340- bSizer64->Add( m_staticText70, 0, wxALL, 5 );341- 342- m_staticText71 = new wxStaticText( m_panelTest2, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );343- m_staticText71->Wrap( -1 );344- bSizer64->Add( m_staticText71, 0, wxALL, 5 );345 346 m_panelTest2->SetSizer( bSizer64 );347 m_panelTest2->Layout();348@@ -512,13 +426,13 @@349 wxBoxSizer* bSizer58;350 bSizer58 = new wxBoxSizer( wxHORIZONTAL );351 352- m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );353+ m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );354 bSizer58->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );355 356- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );357+ m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );358 bSizer58->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );359 360- m_buttonApply = new wxButton( this, wxID_APPLY, wxT("&Apply"), wxDefaultPosition, wxSize( -1,-1 ), 0 );361+ m_buttonApply = new wxButton( this, wxID_APPLY, _("&Apply"), wxDefaultPosition, wxSize( -1,-1 ), 0 );362 bSizer58->Add( m_buttonApply, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );363 364 bSizer55->Add( bSizer58, 0, wxALIGN_RIGHT, 5 );365@@ -558,49 +472,52 @@366 {367 this->SetSizeHints( wxDefaultSize, wxDefaultSize );368 369+ wxBoxSizer* bSizer63;370+ bSizer63 = new wxBoxSizer( wxHORIZONTAL );371+ 372+ m_bitmap = new wxStaticBitmap( this, wxID_ANY, wxBitmap( about_xpm ), wxDefaultPosition, wxDefaultSize, 0 );373+ bSizer63->Add( m_bitmap, 0, 0, 5 );374+ 375 wxBoxSizer* bSizer60;376 bSizer60 = new wxBoxSizer( wxVERTICAL );377 378 wxBoxSizer* bSizer62;379 bSizer62 = new wxBoxSizer( wxHORIZONTAL );380 381- 382- bSizer62->Add( 60, 0, 0, wxEXPAND, 5 );383- 384- wxBoxSizer* bSizer63;385- bSizer63 = new wxBoxSizer( wxVERTICAL );386- 387- 388- bSizer63->Add( 0, 50, 0, wxEXPAND, 5 );389+ wxBoxSizer* bSizer631;390+ bSizer631 = new wxBoxSizer( wxVERTICAL );391+ 392+ 393+ bSizer631->Add( 0, 65, 0, wxEXPAND, 5 );394 395 wxBoxSizer* bSizer64;396 bSizer64 = new wxBoxSizer( wxHORIZONTAL );397 398- m_staticText40 = new wxStaticText( this, wxID_ANY, wxT("Bitcoin "), wxDefaultPosition, wxDefaultSize, 0 );399+ m_staticText40 = new wxStaticText( this, wxID_ANY, _("Bitcoin "), wxDefaultPosition, wxDefaultSize, 0 );400 m_staticText40->Wrap( -1 );401 m_staticText40->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) );402 403 bSizer64->Add( m_staticText40, 0, wxALIGN_BOTTOM|wxTOP|wxBOTTOM|wxLEFT, 5 );404 405- m_staticTextVersion = new wxStaticText( this, wxID_ANY, wxT("version"), wxDefaultPosition, wxDefaultSize, 0 );406+ m_staticTextVersion = new wxStaticText( this, wxID_ANY, _("version"), wxDefaultPosition, wxDefaultSize, 0 );407 m_staticTextVersion->Wrap( -1 );408 m_staticTextVersion->SetFont( wxFont( 10, 74, 90, 90, false, wxT("Tahoma") ) );409 410 bSizer64->Add( m_staticTextVersion, 0, wxALIGN_BOTTOM|wxTOP|wxBOTTOM|wxRIGHT, 5 );411 412- bSizer63->Add( bSizer64, 0, wxEXPAND, 5 );413- 414- 415- bSizer63->Add( 0, 4, 0, wxEXPAND, 5 );416- 417- m_staticTextMain = new wxStaticText( this, wxID_ANY, wxT("Copyright © 2009 Satoshi Nakamoto.\n\nThis is experimental software. Do not rely on it for actual financial transactions.\n\nDistributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 );418- m_staticTextMain->Wrap( 400 );419- bSizer63->Add( m_staticTextMain, 0, wxALL, 5 );420- 421- 422- bSizer63->Add( 0, 0, 1, wxEXPAND, 5 );423- 424- bSizer62->Add( bSizer63, 1, wxEXPAND, 5 );425+ bSizer631->Add( bSizer64, 0, wxEXPAND, 5 );426+ 427+ 428+ bSizer631->Add( 0, 4, 0, wxEXPAND, 5 );429+ 430+ m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Satoshi Nakamoto.\n\nThis is experimental software. Do not rely on it for actual financial transactions.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 );431+ m_staticTextMain->Wrap( -1 );432+ bSizer631->Add( m_staticTextMain, 0, wxALL, 5 );433+ 434+ 435+ bSizer631->Add( 0, 0, 1, wxEXPAND, 5 );436+ 437+ bSizer62->Add( bSizer631, 1, wxEXPAND, 5 );438 439 bSizer60->Add( bSizer62, 1, wxEXPAND, 5 );440 441@@ -610,12 +527,14 @@442 443 bSizer61->Add( 0, 0, 1, wxEXPAND, 5 );444 445- m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );446+ m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );447 bSizer61->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );448 449- bSizer60->Add( bSizer61, 0, wxALIGN_RIGHT|wxEXPAND, 5 );450- 451- this->SetSizer( bSizer60 );452+ bSizer60->Add( bSizer61, 0, wxALIGN_RIGHT|wxEXPAND|wxRIGHT, 5 );453+ 454+ bSizer63->Add( bSizer60, 1, wxEXPAND|wxLEFT, 5 );455+ 456+ this->SetSizer( bSizer63 );457 this->Layout();458 459 // Connect Events460@@ -639,7 +558,7 @@461 bSizer21->Add( 0, 5, 0, wxEXPAND, 5 );462 463 wxFlexGridSizer* fgSizer1;464- fgSizer1 = new wxFlexGridSizer( 3, 2, 0, 0 );465+ fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 );466 fgSizer1->AddGrowableCol( 1 );467 fgSizer1->SetFlexibleDirection( wxBOTH );468 fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );469@@ -647,7 +566,7 @@470 471 fgSizer1->Add( 0, 0, 0, wxEXPAND, 5 );472 473- m_staticTextInstructions = new wxStaticText( this, wxID_ANY, wxT("Enter the recipient's IP address (e.g. 123.45.6.7) for online transfer with comments and confirmation, \nor Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) if recipient is not online."), wxDefaultPosition, wxDefaultSize, 0 );474+ m_staticTextInstructions = new wxStaticText( this, wxID_ANY, _("Enter the recipient's IP address (e.g. 123.45.6.7) for online transfer with comments and confirmation, \nor Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) if recipient is not online."), wxDefaultPosition, wxDefaultSize, 0 );475 m_staticTextInstructions->Wrap( -1 );476 fgSizer1->Add( m_staticTextInstructions, 0, wxTOP|wxRIGHT|wxLEFT, 5 );477 478@@ -661,7 +580,7 @@479 m_bitmapCheckMark = new wxStaticBitmap( this, wxID_ANY, wxBitmap( check_xpm ), wxDefaultPosition, wxSize( 16,16 ), 0 );480 bSizer47->Add( m_bitmapCheckMark, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );481 482- m_staticText36 = new wxStaticText( this, wxID_ANY, wxT("Pay &To:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );483+ m_staticText36 = new wxStaticText( this, wxID_ANY, _("Pay &To:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );484 m_staticText36->Wrap( -1 );485 bSizer47->Add( m_staticText36, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );486 487@@ -676,17 +595,17 @@488 wxBoxSizer* bSizer66;489 bSizer66 = new wxBoxSizer( wxHORIZONTAL );490 491- m_buttonPaste = new wxButton( this, wxID_BUTTONPASTE, wxT("&Paste"), wxDefaultPosition, wxSize( -1,-1 ), wxBU_EXACTFIT );492+ m_buttonPaste = new wxButton( this, wxID_BUTTONPASTE, _("&Paste"), wxDefaultPosition, wxSize( -1,-1 ), wxBU_EXACTFIT );493 bSizer66->Add( m_buttonPaste, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND, 5 );494 495- m_buttonAddress = new wxButton( this, wxID_BUTTONADDRESSBOOK, wxT(" Address &Book..."), wxDefaultPosition, wxDefaultSize, 0 );496+ m_buttonAddress = new wxButton( this, wxID_BUTTONADDRESSBOOK, _(" Address &Book..."), wxDefaultPosition, wxDefaultSize, 0 );497 bSizer66->Add( m_buttonAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND, 5 );498 499 bSizer19->Add( bSizer66, 0, wxALIGN_CENTER_VERTICAL, 5 );500 501 fgSizer1->Add( bSizer19, 1, wxEXPAND|wxRIGHT, 5 );502 503- m_staticText19 = new wxStaticText( this, wxID_ANY, wxT("&Amount:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );504+ m_staticText19 = new wxStaticText( this, wxID_ANY, _("&Amount:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );505 m_staticText19->Wrap( -1 );506 fgSizer1->Add( m_staticText19, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxALIGN_RIGHT, 5 );507 508@@ -696,13 +615,13 @@509 510 fgSizer1->Add( m_textCtrlAmount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );511 512- m_staticText20 = new wxStaticText( this, wxID_ANY, wxT("T&ransfer:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );513+ m_staticText20 = new wxStaticText( this, wxID_ANY, _("T&ransfer:"), wxDefaultPosition, wxSize( -1,-1 ), wxALIGN_RIGHT );514 m_staticText20->Wrap( -1 );515 m_staticText20->Hide();516 517 fgSizer1->Add( m_staticText20, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );518 519- wxString m_choiceTransferTypeChoices[] = { wxT(" Standard") };520+ wxString m_choiceTransferTypeChoices[] = { _(" Standard") };521 int m_choiceTransferTypeNChoices = sizeof( m_choiceTransferTypeChoices ) / sizeof( wxString );522 m_choiceTransferType = new wxChoice( this, wxID_CHOICETRANSFERTYPE, wxDefaultPosition, wxDefaultSize, m_choiceTransferTypeNChoices, m_choiceTransferTypeChoices, 0 );523 m_choiceTransferType->SetSelection( 0 );524@@ -724,7 +643,7 @@525 wxBoxSizer* bSizer681;526 bSizer681 = new wxBoxSizer( wxVERTICAL );527 528- m_staticTextFrom = new wxStaticText( this, wxID_ANY, wxT("&From:"), wxDefaultPosition, wxDefaultSize, 0 );529+ m_staticTextFrom = new wxStaticText( this, wxID_ANY, _("&From:"), wxDefaultPosition, wxDefaultSize, 0 );530 m_staticTextFrom->Wrap( -1 );531 bSizer681->Add( m_staticTextFrom, 0, wxBOTTOM|wxLEFT, 5 );532 533@@ -741,7 +660,7 @@534 wxBoxSizer* bSizer68;535 bSizer68 = new wxBoxSizer( wxVERTICAL );536 537- m_staticTextMessage = new wxStaticText( this, wxID_ANY, wxT("&Message:"), wxDefaultPosition, wxDefaultSize, 0 );538+ m_staticTextMessage = new wxStaticText( this, wxID_ANY, _("&Message:"), wxDefaultPosition, wxDefaultSize, 0 );539 m_staticTextMessage->Wrap( -1 );540 bSizer68->Add( m_staticTextMessage, 0, wxTOP|wxBOTTOM|wxLEFT, 5 );541 542@@ -758,12 +677,12 @@543 544 bSizer23->Add( 0, 0, 1, wxEXPAND, 5 );545 546- m_buttonSend = new wxButton( this, wxID_BUTTONSEND, wxT("&Send"), wxDefaultPosition, wxSize( -1,-1 ), 0 );547+ m_buttonSend = new wxButton( this, wxID_BUTTONSEND, _("&Send"), wxDefaultPosition, wxSize( -1,-1 ), 0 );548 m_buttonSend->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );549 550 bSizer23->Add( m_buttonSend, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );551 552- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );553+ m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );554 bSizer23->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );555 556 bSizer21->Add( bSizer23, 0, wxEXPAND, 5 );557@@ -810,7 +729,7 @@558 m_staticTextSending->Wrap( -1 );559 bSizer68->Add( m_staticTextSending, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 8 );560 561- m_textCtrlStatus = new wxTextCtrl( this, wxID_ANY, wxT("\n\nConnecting..."), wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE|wxTE_NO_VSCROLL|wxTE_READONLY|wxNO_BORDER );562+ m_textCtrlStatus = new wxTextCtrl( this, wxID_ANY, _("\n\nConnecting..."), wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE|wxTE_NO_VSCROLL|wxTE_READONLY|wxNO_BORDER );563 m_textCtrlStatus->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );564 565 bSizer68->Add( m_textCtrlStatus, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 );566@@ -821,12 +740,12 @@567 568 bSizer69->Add( 0, 0, 1, wxEXPAND, 5 );569 570- m_buttonOK = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );571+ m_buttonOK = new wxButton( this, wxID_ANY, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );572 m_buttonOK->Enable( false );573 574 bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );575 576- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );577+ m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );578 bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );579 580 bSizer68->Add( bSizer69, 0, wxEXPAND, 5 );581@@ -860,7 +779,7 @@582 583 bSizer68->Add( 0, 5, 0, wxEXPAND, 5 );584 585- m_staticText45 = new wxStaticText( this, wxID_ANY, wxT("These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window."), wxDefaultPosition, wxDefaultSize, 0 );586+ m_staticText45 = new wxStaticText( this, wxID_ANY, _("These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window."), wxDefaultPosition, wxDefaultSize, 0 );587 m_staticText45->Wrap( 590 );588 bSizer68->Add( m_staticText45, 0, wxALL, 5 );589 590@@ -873,19 +792,19 @@591 592 bSizer69->Add( 0, 0, 1, wxEXPAND, 5 );593 594- m_buttonRename = new wxButton( this, wxID_BUTTONRENAME, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );595+ m_buttonRename = new wxButton( this, wxID_BUTTONRENAME, _("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );596 bSizer69->Add( m_buttonRename, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );597 598- m_buttonNew = new wxButton( this, wxID_BUTTONNEW, wxT(" &New Address... "), wxDefaultPosition, wxSize( -1,-1 ), 0 );599+ m_buttonNew = new wxButton( this, wxID_BUTTONNEW, _(" &New Address... "), wxDefaultPosition, wxSize( -1,-1 ), 0 );600 bSizer69->Add( m_buttonNew, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );601 602- m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, wxT(" &Copy to Clipboard "), wxDefaultPosition, wxSize( -1,-1 ), 0 );603+ m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, _(" &Copy to Clipboard "), wxDefaultPosition, wxSize( -1,-1 ), 0 );604 bSizer69->Add( m_buttonCopy, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );605 606- m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );607+ m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );608 bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );609 610- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );611+ m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );612 m_buttonCancel->Hide();613 614 bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );615@@ -931,7 +850,7 @@616 617 bSizer68->Add( 0, 5, 0, wxEXPAND, 5 );618 619- m_staticText55 = new wxStaticText( this, wxID_ANY, wxT("Bitcoin Address"), wxDefaultPosition, wxDefaultSize, 0 );620+ m_staticText55 = new wxStaticText( this, wxID_ANY, _("Bitcoin Address"), wxDefaultPosition, wxDefaultSize, 0 );621 m_staticText55->Wrap( -1 );622 m_staticText55->Hide();623 624@@ -946,19 +865,19 @@625 626 bSizer69->Add( 0, 0, 1, wxEXPAND, 5 );627 628- m_buttonEdit = new wxButton( this, wxID_BUTTONEDIT, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );629+ m_buttonEdit = new wxButton( this, wxID_BUTTONEDIT, _("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );630 bSizer69->Add( m_buttonEdit, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );631 632- m_buttonNew = new wxButton( this, wxID_BUTTONNEW, wxT(" &New Address... "), wxDefaultPosition, wxDefaultSize, 0 );633+ m_buttonNew = new wxButton( this, wxID_BUTTONNEW, _(" &New Address... "), wxDefaultPosition, wxDefaultSize, 0 );634 bSizer69->Add( m_buttonNew, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );635 636- m_buttonDelete = new wxButton( this, wxID_BUTTONDELETE, wxT("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );637+ m_buttonDelete = new wxButton( this, wxID_BUTTONDELETE, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );638 bSizer69->Add( m_buttonDelete, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );639 640- m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );641+ m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );642 bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );643 644- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );645+ m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );646 bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );647 648 bSizer68->Add( bSizer69, 0, wxEXPAND, 5 );649@@ -992,713 +911,6 @@650 m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCancel ), NULL, this );651 }652 653-CProductsDialogBase::CProductsDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )654-{655- this->SetSizeHints( wxDefaultSize, wxDefaultSize );656- 657- wxBoxSizer* bSizer22;658- bSizer22 = new wxBoxSizer( wxVERTICAL );659- 660- wxBoxSizer* bSizer23;661- bSizer23 = new wxBoxSizer( wxHORIZONTAL );662- 663- m_comboBoxCategory = new wxComboBox( this, wxID_ANY, wxT("(Any Category)"), wxDefaultPosition, wxSize( 150,-1 ), 0, NULL, 0 );664- m_comboBoxCategory->Append( wxT("(Any Category)") );665- bSizer23->Add( m_comboBoxCategory, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );666- 667- m_textCtrlSearch = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );668- bSizer23->Add( m_textCtrlSearch, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 );669- 670- m_buttonSearch = new wxButton( this, wxID_ANY, wxT("&Search"), wxDefaultPosition, wxDefaultSize, 0 );671- bSizer23->Add( m_buttonSearch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );672- 673- bSizer22->Add( bSizer23, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );674- 675- m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT );676- bSizer22->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );677- 678- this->SetSizer( bSizer22 );679- this->Layout();680- 681- // Connect Events682- m_comboBoxCategory->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( CProductsDialogBase::OnCombobox ), NULL, this );683- m_textCtrlSearch->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CProductsDialogBase::OnKeyDown ), NULL, this );684- m_buttonSearch->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CProductsDialogBase::OnButtonSearch ), NULL, this );685- m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CProductsDialogBase::OnListItemActivated ), NULL, this );686-}687-688-CProductsDialogBase::~CProductsDialogBase()689-{690- // Disconnect Events691- m_comboBoxCategory->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( CProductsDialogBase::OnCombobox ), NULL, this );692- m_textCtrlSearch->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CProductsDialogBase::OnKeyDown ), NULL, this );693- m_buttonSearch->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CProductsDialogBase::OnButtonSearch ), NULL, this );694- m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CProductsDialogBase::OnListItemActivated ), NULL, this );695-}696-697-CEditProductDialogBase::CEditProductDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )698-{699- this->SetSizeHints( wxDefaultSize, wxDefaultSize );700- this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );701- 702- wxBoxSizer* bSizer20;703- bSizer20 = new wxBoxSizer( wxVERTICAL );704- 705- m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL );706- m_scrolledWindow->SetScrollRate( 5, 5 );707- m_scrolledWindow->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );708- 709- wxBoxSizer* bSizer21;710- bSizer21 = new wxBoxSizer( wxVERTICAL );711- 712- wxFlexGridSizer* fgSizer8;713- fgSizer8 = new wxFlexGridSizer( 0, 2, 0, 0 );714- fgSizer8->AddGrowableCol( 1 );715- fgSizer8->SetFlexibleDirection( wxBOTH );716- fgSizer8->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );717- 718- m_staticText106 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Category"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );719- m_staticText106->Wrap( -1 );720- fgSizer8->Add( m_staticText106, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );721- 722- m_comboBoxCategory = new wxComboBox( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); 723- m_comboBoxCategory->SetMinSize( wxSize( 180,-1 ) );724- 725- fgSizer8->Add( m_comboBoxCategory, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );726- 727- m_staticText108 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Title"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );728- m_staticText108->Wrap( -1 );729- fgSizer8->Add( m_staticText108, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );730- 731- m_textCtrlTitle = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );732- fgSizer8->Add( m_textCtrlTitle, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );733- 734- m_staticText107 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Price"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );735- m_staticText107->Wrap( -1 );736- fgSizer8->Add( m_staticText107, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 );737- 738- m_textCtrlPrice = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );739- m_textCtrlPrice->SetMinSize( wxSize( 105,-1 ) );740- 741- fgSizer8->Add( m_textCtrlPrice, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );742- 743- bSizer21->Add( fgSizer8, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );744- 745- m_staticText22 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Page 1: Description"), wxDefaultPosition, wxDefaultSize, 0 );746- m_staticText22->Wrap( -1 );747- bSizer21->Add( m_staticText22, 0, wxTOP|wxRIGHT|wxLEFT, 5 );748- 749- m_textCtrlDescription = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );750- m_textCtrlDescription->SetMinSize( wxSize( -1,170 ) );751- 752- bSizer21->Add( m_textCtrlDescription, 0, wxALL|wxEXPAND, 5 );753- 754- m_staticText23 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Page 2: Order Form"), wxDefaultPosition, wxDefaultSize, 0 );755- m_staticText23->Wrap( -1 );756- bSizer21->Add( m_staticText23, 0, wxTOP|wxRIGHT|wxLEFT, 5 );757- 758- m_textCtrlInstructions = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );759- m_textCtrlInstructions->SetMinSize( wxSize( -1,120 ) );760- 761- bSizer21->Add( m_textCtrlInstructions, 0, wxEXPAND|wxALL, 5 );762- 763- fgSizer5 = new wxFlexGridSizer( 0, 3, 0, 0 );764- fgSizer5->AddGrowableCol( 1 );765- fgSizer5->SetFlexibleDirection( wxBOTH );766- fgSizer5->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );767- 768- m_staticText24 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Label"), wxDefaultPosition, wxDefaultSize, 0 );769- m_staticText24->Wrap( -1 );770- fgSizer5->Add( m_staticText24, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );771- 772- m_staticText25 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Comma separated list of choices, or leave blank for text field"), wxDefaultPosition, wxDefaultSize, 0 );773- m_staticText25->Wrap( -1 );774- fgSizer5->Add( m_staticText25, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 );775- 776- 777- fgSizer5->Add( 0, 0, 1, wxEXPAND, 5 );778- 779- m_textCtrlLabel0 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );780- m_textCtrlLabel0->SetMinSize( wxSize( 150,-1 ) );781- 782- fgSizer5->Add( m_textCtrlLabel0, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );783- 784- m_textCtrlField0 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );785- fgSizer5->Add( m_textCtrlField0, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );786- 787- m_buttonDel0 = new wxButton( m_scrolledWindow, wxID_DEL0, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );788- fgSizer5->Add( m_buttonDel0, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );789- 790- m_textCtrlLabel1 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );791- m_textCtrlLabel1->SetMinSize( wxSize( 150,-1 ) );792- 793- fgSizer5->Add( m_textCtrlLabel1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );794- 795- m_textCtrlField1 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );796- fgSizer5->Add( m_textCtrlField1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );797- 798- m_buttonDel1 = new wxButton( m_scrolledWindow, wxID_DEL1, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );799- fgSizer5->Add( m_buttonDel1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );800- 801- m_textCtrlLabel2 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );802- m_textCtrlLabel2->SetMinSize( wxSize( 150,-1 ) );803- 804- fgSizer5->Add( m_textCtrlLabel2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );805- 806- m_textCtrlField2 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );807- fgSizer5->Add( m_textCtrlField2, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );808- 809- m_buttonDel2 = new wxButton( m_scrolledWindow, wxID_DEL2, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );810- fgSizer5->Add( m_buttonDel2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );811- 812- m_textCtrlLabel3 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );813- m_textCtrlLabel3->SetMinSize( wxSize( 150,-1 ) );814- 815- fgSizer5->Add( m_textCtrlLabel3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );816- 817- m_textCtrlField3 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );818- fgSizer5->Add( m_textCtrlField3, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );819- 820- m_buttonDel3 = new wxButton( m_scrolledWindow, wxID_DEL3, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );821- fgSizer5->Add( m_buttonDel3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );822- 823- m_textCtrlLabel4 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );824- m_textCtrlLabel4->SetMinSize( wxSize( 150,-1 ) );825- 826- fgSizer5->Add( m_textCtrlLabel4, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );827- 828- m_textCtrlField4 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );829- fgSizer5->Add( m_textCtrlField4, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );830- 831- m_buttonDel4 = new wxButton( m_scrolledWindow, wxID_DEL4, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );832- fgSizer5->Add( m_buttonDel4, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );833- 834- m_textCtrlLabel5 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );835- m_textCtrlLabel5->SetMinSize( wxSize( 150,-1 ) );836- 837- fgSizer5->Add( m_textCtrlLabel5, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );838- 839- m_textCtrlField5 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );840- fgSizer5->Add( m_textCtrlField5, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );841- 842- m_buttonDel5 = new wxButton( m_scrolledWindow, wxID_DEL5, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );843- fgSizer5->Add( m_buttonDel5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );844- 845- m_textCtrlLabel6 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );846- m_textCtrlLabel6->SetMinSize( wxSize( 150,-1 ) );847- 848- fgSizer5->Add( m_textCtrlLabel6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );849- 850- m_textCtrlField6 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );851- fgSizer5->Add( m_textCtrlField6, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );852- 853- m_buttonDel6 = new wxButton( m_scrolledWindow, wxID_DEL6, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );854- fgSizer5->Add( m_buttonDel6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );855- 856- m_textCtrlLabel7 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );857- m_textCtrlLabel7->SetMinSize( wxSize( 150,-1 ) );858- 859- fgSizer5->Add( m_textCtrlLabel7, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );860- 861- m_textCtrlField7 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );862- fgSizer5->Add( m_textCtrlField7, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );863- 864- m_buttonDel7 = new wxButton( m_scrolledWindow, wxID_DEL7, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );865- fgSizer5->Add( m_buttonDel7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );866- 867- m_textCtrlLabel8 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );868- m_textCtrlLabel8->SetMinSize( wxSize( 150,-1 ) );869- 870- fgSizer5->Add( m_textCtrlLabel8, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );871- 872- m_textCtrlField8 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );873- fgSizer5->Add( m_textCtrlField8, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );874- 875- m_buttonDel8 = new wxButton( m_scrolledWindow, wxID_DEL8, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );876- fgSizer5->Add( m_buttonDel8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );877- 878- m_textCtrlLabel9 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );879- m_textCtrlLabel9->SetMinSize( wxSize( 150,-1 ) );880- 881- fgSizer5->Add( m_textCtrlLabel9, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );882- 883- m_textCtrlField9 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );884- fgSizer5->Add( m_textCtrlField9, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );885- 886- m_buttonDel9 = new wxButton( m_scrolledWindow, wxID_DEL9, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );887- fgSizer5->Add( m_buttonDel9, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );888- 889- m_textCtrlLabel10 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );890- m_textCtrlLabel10->SetMinSize( wxSize( 150,-1 ) );891- 892- fgSizer5->Add( m_textCtrlLabel10, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );893- 894- m_textCtrlField10 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );895- fgSizer5->Add( m_textCtrlField10, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );896- 897- m_buttonDel10 = new wxButton( m_scrolledWindow, wxID_DEL10, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );898- fgSizer5->Add( m_buttonDel10, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );899- 900- m_textCtrlLabel11 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );901- m_textCtrlLabel11->SetMinSize( wxSize( 150,-1 ) );902- 903- fgSizer5->Add( m_textCtrlLabel11, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );904- 905- m_textCtrlField11 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );906- fgSizer5->Add( m_textCtrlField11, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );907- 908- m_buttonDel11 = new wxButton( m_scrolledWindow, wxID_DEL11, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );909- fgSizer5->Add( m_buttonDel11, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );910- 911- m_textCtrlLabel12 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );912- m_textCtrlLabel12->SetMinSize( wxSize( 150,-1 ) );913- 914- fgSizer5->Add( m_textCtrlLabel12, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );915- 916- m_textCtrlField12 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );917- fgSizer5->Add( m_textCtrlField12, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );918- 919- m_buttonDel12 = new wxButton( m_scrolledWindow, wxID_DEL12, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );920- fgSizer5->Add( m_buttonDel12, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );921- 922- m_textCtrlLabel13 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );923- m_textCtrlLabel13->SetMinSize( wxSize( 150,-1 ) );924- 925- fgSizer5->Add( m_textCtrlLabel13, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );926- 927- m_textCtrlField13 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );928- fgSizer5->Add( m_textCtrlField13, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );929- 930- m_buttonDel13 = new wxButton( m_scrolledWindow, wxID_DEL13, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );931- fgSizer5->Add( m_buttonDel13, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );932- 933- m_textCtrlLabel14 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );934- m_textCtrlLabel14->SetMinSize( wxSize( 150,-1 ) );935- 936- fgSizer5->Add( m_textCtrlLabel14, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );937- 938- m_textCtrlField14 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );939- fgSizer5->Add( m_textCtrlField14, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );940- 941- m_buttonDel14 = new wxButton( m_scrolledWindow, wxID_DEL14, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );942- fgSizer5->Add( m_buttonDel14, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );943- 944- m_textCtrlLabel15 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );945- m_textCtrlLabel15->SetMinSize( wxSize( 150,-1 ) );946- 947- fgSizer5->Add( m_textCtrlLabel15, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );948- 949- m_textCtrlField15 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );950- fgSizer5->Add( m_textCtrlField15, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );951- 952- m_buttonDel15 = new wxButton( m_scrolledWindow, wxID_DEL15, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );953- fgSizer5->Add( m_buttonDel15, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );954- 955- m_textCtrlLabel16 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );956- m_textCtrlLabel16->SetMinSize( wxSize( 150,-1 ) );957- 958- fgSizer5->Add( m_textCtrlLabel16, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );959- 960- m_textCtrlField16 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );961- fgSizer5->Add( m_textCtrlField16, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );962- 963- m_buttonDel16 = new wxButton( m_scrolledWindow, wxID_DEL16, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );964- fgSizer5->Add( m_buttonDel16, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );965- 966- m_textCtrlLabel17 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );967- m_textCtrlLabel17->SetMinSize( wxSize( 150,-1 ) );968- 969- fgSizer5->Add( m_textCtrlLabel17, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );970- 971- m_textCtrlField17 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );972- fgSizer5->Add( m_textCtrlField17, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );973- 974- m_buttonDel17 = new wxButton( m_scrolledWindow, wxID_DEL17, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );975- fgSizer5->Add( m_buttonDel17, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );976- 977- m_textCtrlLabel18 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );978- m_textCtrlLabel18->SetMinSize( wxSize( 150,-1 ) );979- 980- fgSizer5->Add( m_textCtrlLabel18, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );981- 982- m_textCtrlField18 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );983- fgSizer5->Add( m_textCtrlField18, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );984- 985- m_buttonDel18 = new wxButton( m_scrolledWindow, wxID_DEL18, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );986- fgSizer5->Add( m_buttonDel18, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );987- 988- m_textCtrlLabel19 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );989- m_textCtrlLabel19->SetMinSize( wxSize( 150,-1 ) );990- 991- fgSizer5->Add( m_textCtrlLabel19, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );992- 993- m_textCtrlField19 = new wxTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );994- fgSizer5->Add( m_textCtrlField19, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );995- 996- m_buttonDel19 = new wxButton( m_scrolledWindow, wxID_DEL19, wxT("Delete"), wxDefaultPosition, wxSize( 60,20 ), 0 );997- fgSizer5->Add( m_buttonDel19, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );998- 999- bSizer21->Add( fgSizer5, 0, wxEXPAND, 5 );1000- 1001- wxBoxSizer* bSizer25;1002- bSizer25 = new wxBoxSizer( wxHORIZONTAL );1003- 1004- m_buttonAddField = new wxButton( m_scrolledWindow, wxID_ANY, wxT("&Add Field"), wxDefaultPosition, wxDefaultSize, 0 );1005- bSizer25->Add( m_buttonAddField, 0, wxALL, 5 );1006- 1007- bSizer21->Add( bSizer25, 0, wxALIGN_CENTER_HORIZONTAL, 5 );1008- 1009- m_scrolledWindow->SetSizer( bSizer21 );1010- m_scrolledWindow->Layout();1011- bSizer21->Fit( m_scrolledWindow );1012- bSizer20->Add( m_scrolledWindow, 1, wxEXPAND|wxALL, 5 );1013- 1014- wxBoxSizer* bSizer26;1015- bSizer26 = new wxBoxSizer( wxHORIZONTAL );1016- 1017- m_buttonOK = new wxButton( this, wxID_BUTTONSEND, wxT("&Send"), wxDefaultPosition, wxDefaultSize, 0 );1018- bSizer26->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1019- 1020- m_buttonPreview = new wxButton( this, wxID_BUTTONPREVIEW, wxT("&Preview"), wxDefaultPosition, wxDefaultSize, 0 );1021- bSizer26->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1022- 1023- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );1024- bSizer26->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1025- 1026- bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 );1027- 1028- this->SetSizer( bSizer20 );1029- this->Layout();1030- 1031- // Connect Events1032- m_textCtrlTitle->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1033- m_textCtrlPrice->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1034- m_textCtrlDescription->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1035- m_textCtrlInstructions->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1036- m_textCtrlLabel0->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1037- m_textCtrlField0->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1038- m_buttonDel0->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel0 ), NULL, this );1039- m_textCtrlLabel1->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1040- m_textCtrlField1->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1041- m_buttonDel1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel1 ), NULL, this );1042- m_textCtrlLabel2->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1043- m_textCtrlField2->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1044- m_buttonDel2->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel2 ), NULL, this );1045- m_textCtrlLabel3->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1046- m_textCtrlField3->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1047- m_buttonDel3->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel3 ), NULL, this );1048- m_textCtrlLabel4->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1049- m_textCtrlField4->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1050- m_buttonDel4->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel4 ), NULL, this );1051- m_textCtrlLabel5->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1052- m_textCtrlField5->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1053- m_buttonDel5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel5 ), NULL, this );1054- m_textCtrlLabel6->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1055- m_textCtrlField6->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1056- m_buttonDel6->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel6 ), NULL, this );1057- m_textCtrlLabel7->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1058- m_textCtrlField7->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1059- m_buttonDel7->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel7 ), NULL, this );1060- m_textCtrlLabel8->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1061- m_textCtrlField8->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1062- m_buttonDel8->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel8 ), NULL, this );1063- m_textCtrlLabel9->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1064- m_textCtrlField9->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1065- m_buttonDel9->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel9 ), NULL, this );1066- m_textCtrlLabel10->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1067- m_textCtrlField10->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1068- m_buttonDel10->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel10 ), NULL, this );1069- m_textCtrlLabel11->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1070- m_textCtrlField11->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1071- m_buttonDel11->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel11 ), NULL, this );1072- m_textCtrlLabel12->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1073- m_textCtrlField12->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1074- m_buttonDel12->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel12 ), NULL, this );1075- m_textCtrlLabel13->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1076- m_textCtrlField13->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1077- m_buttonDel13->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel13 ), NULL, this );1078- m_textCtrlLabel14->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1079- m_textCtrlField14->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1080- m_buttonDel14->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel14 ), NULL, this );1081- m_textCtrlLabel15->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1082- m_textCtrlField15->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1083- m_buttonDel15->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel15 ), NULL, this );1084- m_textCtrlLabel16->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1085- m_textCtrlField16->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1086- m_buttonDel16->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel16 ), NULL, this );1087- m_textCtrlLabel17->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1088- m_textCtrlField17->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1089- m_buttonDel17->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel17 ), NULL, this );1090- m_textCtrlLabel18->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1091- m_textCtrlField18->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1092- m_buttonDel18->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel18 ), NULL, this );1093- m_textCtrlLabel19->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1094- m_textCtrlField19->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1095- m_buttonDel19->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel19 ), NULL, this );1096- m_buttonAddField->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonAddField ), NULL, this );1097- m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonSend ), NULL, this );1098- m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonPreview ), NULL, this );1099- m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonCancel ), NULL, this );1100-}1101-1102-CEditProductDialogBase::~CEditProductDialogBase()1103-{1104- // Disconnect Events1105- m_textCtrlTitle->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1106- m_textCtrlPrice->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1107- m_textCtrlDescription->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1108- m_textCtrlInstructions->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1109- m_textCtrlLabel0->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1110- m_textCtrlField0->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1111- m_buttonDel0->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel0 ), NULL, this );1112- m_textCtrlLabel1->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1113- m_textCtrlField1->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1114- m_buttonDel1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel1 ), NULL, this );1115- m_textCtrlLabel2->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1116- m_textCtrlField2->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1117- m_buttonDel2->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel2 ), NULL, this );1118- m_textCtrlLabel3->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1119- m_textCtrlField3->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1120- m_buttonDel3->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel3 ), NULL, this );1121- m_textCtrlLabel4->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1122- m_textCtrlField4->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1123- m_buttonDel4->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel4 ), NULL, this );1124- m_textCtrlLabel5->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1125- m_textCtrlField5->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1126- m_buttonDel5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel5 ), NULL, this );1127- m_textCtrlLabel6->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1128- m_textCtrlField6->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1129- m_buttonDel6->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel6 ), NULL, this );1130- m_textCtrlLabel7->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1131- m_textCtrlField7->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1132- m_buttonDel7->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel7 ), NULL, this );1133- m_textCtrlLabel8->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1134- m_textCtrlField8->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1135- m_buttonDel8->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel8 ), NULL, this );1136- m_textCtrlLabel9->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1137- m_textCtrlField9->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1138- m_buttonDel9->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel9 ), NULL, this );1139- m_textCtrlLabel10->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1140- m_textCtrlField10->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1141- m_buttonDel10->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel10 ), NULL, this );1142- m_textCtrlLabel11->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1143- m_textCtrlField11->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1144- m_buttonDel11->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel11 ), NULL, this );1145- m_textCtrlLabel12->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1146- m_textCtrlField12->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1147- m_buttonDel12->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel12 ), NULL, this );1148- m_textCtrlLabel13->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1149- m_textCtrlField13->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1150- m_buttonDel13->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel13 ), NULL, this );1151- m_textCtrlLabel14->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1152- m_textCtrlField14->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1153- m_buttonDel14->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel14 ), NULL, this );1154- m_textCtrlLabel15->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1155- m_textCtrlField15->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1156- m_buttonDel15->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel15 ), NULL, this );1157- m_textCtrlLabel16->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1158- m_textCtrlField16->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1159- m_buttonDel16->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel16 ), NULL, this );1160- m_textCtrlLabel17->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1161- m_textCtrlField17->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1162- m_buttonDel17->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel17 ), NULL, this );1163- m_textCtrlLabel18->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1164- m_textCtrlField18->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1165- m_buttonDel18->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel18 ), NULL, this );1166- m_textCtrlLabel19->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1167- m_textCtrlField19->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditProductDialogBase::OnKeyDown ), NULL, this );1168- m_buttonDel19->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonDel19 ), NULL, this );1169- m_buttonAddField->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonAddField ), NULL, this );1170- m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonSend ), NULL, this );1171- m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonPreview ), NULL, this );1172- m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditProductDialogBase::OnButtonCancel ), NULL, this );1173-}1174-1175-CViewProductDialogBase::CViewProductDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )1176-{1177- this->SetSizeHints( wxDefaultSize, wxDefaultSize );1178- this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );1179- 1180- wxBoxSizer* bSizer20;1181- bSizer20 = new wxBoxSizer( wxVERTICAL );1182- 1183- wxBoxSizer* bSizer116;1184- bSizer116 = new wxBoxSizer( wxHORIZONTAL );1185- 1186- m_htmlWinReviews = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );1187- m_htmlWinReviews->Hide();1188- 1189- bSizer116->Add( m_htmlWinReviews, 1, wxALL|wxEXPAND, 5 );1190- 1191- m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTAB_TRAVERSAL|wxVSCROLL );1192- m_scrolledWindow->SetScrollRate( 5, 5 );1193- m_scrolledWindow->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );1194- 1195- wxBoxSizer* bSizer21;1196- bSizer21 = new wxBoxSizer( wxVERTICAL );1197- 1198- m_richTextHeading = new wxRichTextCtrl( m_scrolledWindow, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,50 ), wxTE_READONLY|wxNO_BORDER );1199- bSizer21->Add( m_richTextHeading, 0, wxEXPAND, 5 );1200- 1201- m_staticTextInstructions = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT("Order Form instructions here\nmultiple lines\n1\n2\n3\n4\n5\n6"), wxDefaultPosition, wxDefaultSize, 0 );1202- m_staticTextInstructions->Wrap( -1 );1203- bSizer21->Add( m_staticTextInstructions, 0, wxALL|wxEXPAND, 5 );1204- 1205- wxBoxSizer* bSizer25;1206- bSizer25 = new wxBoxSizer( wxHORIZONTAL );1207- 1208- m_buttonSubmitForm = new wxButton( m_scrolledWindow, wxID_BUTTONSAMPLE, wxT("&Submit"), wxDefaultPosition, wxDefaultSize, 0 );1209- bSizer25->Add( m_buttonSubmitForm, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1210- 1211- m_buttonCancelForm = new wxButton( m_scrolledWindow, wxID_CANCEL2, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );1212- bSizer25->Add( m_buttonCancelForm, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1213- 1214- bSizer21->Add( bSizer25, 0, wxALIGN_CENTER_HORIZONTAL, 5 );1215- 1216- m_scrolledWindow->SetSizer( bSizer21 );1217- m_scrolledWindow->Layout();1218- bSizer21->Fit( m_scrolledWindow );1219- bSizer116->Add( m_scrolledWindow, 1, wxEXPAND|wxALL, 5 );1220- 1221- bSizer20->Add( bSizer116, 1, wxEXPAND, 5 );1222- 1223- wxBoxSizer* bSizer26;1224- bSizer26 = new wxBoxSizer( wxHORIZONTAL );1225- 1226- m_buttonBack = new wxButton( this, wxID_BUTTONBACK, wxT("< &Back "), wxDefaultPosition, wxDefaultSize, 0 );1227- m_buttonBack->Enable( false );1228- 1229- bSizer26->Add( m_buttonBack, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1230- 1231- m_buttonNext = new wxButton( this, wxID_BUTTONNEXT, wxT(" &Next >"), wxDefaultPosition, wxDefaultSize, 0 );1232- bSizer26->Add( m_buttonNext, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1233- 1234- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );1235- bSizer26->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1236- 1237- bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 );1238- 1239- this->SetSizer( bSizer20 );1240- this->Layout();1241- 1242- // Connect Events1243- m_buttonSubmitForm->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonSubmitForm ), NULL, this );1244- m_buttonCancelForm->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonCancelForm ), NULL, this );1245- m_buttonBack->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonBack ), NULL, this );1246- m_buttonNext->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonNext ), NULL, this );1247- m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonCancel ), NULL, this );1248-}1249-1250-CViewProductDialogBase::~CViewProductDialogBase()1251-{1252- // Disconnect Events1253- m_buttonSubmitForm->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonSubmitForm ), NULL, this );1254- m_buttonCancelForm->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonCancelForm ), NULL, this );1255- m_buttonBack->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonBack ), NULL, this );1256- m_buttonNext->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonNext ), NULL, this );1257- m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewProductDialogBase::OnButtonCancel ), NULL, this );1258-}1259-1260-CViewOrderDialogBase::CViewOrderDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )1261-{1262- this->SetSizeHints( wxDefaultSize, wxDefaultSize );1263- this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );1264- 1265- wxBoxSizer* bSizer20;1266- bSizer20 = new wxBoxSizer( wxVERTICAL );1267- 1268- wxBoxSizer* bSizer116;1269- bSizer116 = new wxBoxSizer( wxHORIZONTAL );1270- 1271- m_htmlWin = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );1272- bSizer116->Add( m_htmlWin, 1, wxALL|wxEXPAND, 5 );1273- 1274- bSizer20->Add( bSizer116, 1, wxEXPAND, 5 );1275- 1276- wxBoxSizer* bSizer26;1277- bSizer26 = new wxBoxSizer( wxHORIZONTAL );1278- 1279- m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );1280- bSizer26->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1281- 1282- bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 );1283- 1284- this->SetSizer( bSizer20 );1285- this->Layout();1286- 1287- // Connect Events1288- m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewOrderDialogBase::OnButtonOK ), NULL, this );1289-}1290-1291-CViewOrderDialogBase::~CViewOrderDialogBase()1292-{1293- // Disconnect Events1294- m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CViewOrderDialogBase::OnButtonOK ), NULL, this );1295-}1296-1297-CEditReviewDialogBase::CEditReviewDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )1298-{1299- this->SetSizeHints( wxDefaultSize, wxDefaultSize );1300- this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );1301- 1302- wxBoxSizer* bSizer112;1303- bSizer112 = new wxBoxSizer( wxVERTICAL );1304- 1305- 1306- bSizer112->Add( 0, 3, 0, 0, 5 );1307- 1308- m_staticTextSeller = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );1309- m_staticTextSeller->Wrap( -1 );1310- bSizer112->Add( m_staticTextSeller, 0, wxALL|wxEXPAND, 5 );1311- 1312- 1313- bSizer112->Add( 0, 3, 0, 0, 5 );1314- 1315- m_staticText110 = new wxStaticText( this, wxID_ANY, wxT("Rating"), wxDefaultPosition, wxDefaultSize, 0 );1316- m_staticText110->Wrap( -1 );1317- bSizer112->Add( m_staticText110, 0, wxTOP|wxRIGHT|wxLEFT, 5 );1318- 1319- wxString m_choiceStarsChoices[] = { wxT(" 1 star"), wxT(" 2 stars"), wxT(" 3 stars"), wxT(" 4 stars"), wxT(" 5 stars") };1320- int m_choiceStarsNChoices = sizeof( m_choiceStarsChoices ) / sizeof( wxString );1321- m_choiceStars = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceStarsNChoices, m_choiceStarsChoices, 0 );1322- m_choiceStars->SetSelection( 0 );1323- bSizer112->Add( m_choiceStars, 0, wxALL, 5 );1324- 1325- m_staticText43 = new wxStaticText( this, wxID_ANY, wxT("Review"), wxDefaultPosition, wxDefaultSize, 0 );1326- m_staticText43->Wrap( -1 );1327- bSizer112->Add( m_staticText43, 0, wxTOP|wxRIGHT|wxLEFT, 5 );1328- 1329- m_textCtrlReview = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );1330- bSizer112->Add( m_textCtrlReview, 1, wxALL|wxEXPAND, 5 );1331- 1332- wxBoxSizer* bSizer113;1333- bSizer113 = new wxBoxSizer( wxHORIZONTAL );1334- 1335- m_buttonSubmit = new wxButton( this, wxID_SUBMIT, wxT("&Submit"), wxDefaultPosition, wxDefaultSize, 0 );1336- bSizer113->Add( m_buttonSubmit, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1337- 1338- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );1339- bSizer113->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1340- 1341- bSizer112->Add( bSizer113, 0, wxALIGN_RIGHT, 5 );1342- 1343- this->SetSizer( bSizer112 );1344- this->Layout();1345- 1346- // Connect Events1347- m_textCtrlReview->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditReviewDialogBase::OnKeyDown ), NULL, this );1348- m_buttonSubmit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditReviewDialogBase::OnButtonSubmit ), NULL, this );1349- m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditReviewDialogBase::OnButtonCancel ), NULL, this );1350-}1351-1352-CEditReviewDialogBase::~CEditReviewDialogBase()1353-{1354- // Disconnect Events1355- m_textCtrlReview->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( CEditReviewDialogBase::OnKeyDown ), NULL, this );1356- m_buttonSubmit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditReviewDialogBase::OnButtonSubmit ), NULL, this );1357- m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CEditReviewDialogBase::OnButtonCancel ), NULL, this );1358-}1359-1360 CGetTextFromUserDialogBase::CGetTextFromUserDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )1361 {1362 this->SetSizeHints( wxDefaultSize, wxDefaultSize );1363@@ -1741,10 +953,10 @@1364 1365 bSizer80->Add( 0, 0, 1, wxEXPAND, 5 );1366 1367- m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1368+ m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );1369 bSizer80->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1370 1371- m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );1372+ m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );1373 bSizer80->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );1374 1375 bSizer79->Add( bSizer80, 0, wxEXPAND, 5 );
uibase.h (modified)
1--- v0.2.0/uibase.h2+++ v0.2.2/uibase.h3@@ -7,6 +7,8 @@4 5 #ifndef __uibase__6 #define __uibase__7+8+#include <wx/intl.h>9 10 #include <wx/string.h>11 #include <wx/bitmap.h>12@@ -26,7 +28,6 @@13 #include <wx/panel.h>14 #include <wx/choice.h>15 #include <wx/listctrl.h>16-#include <wx/notebook.h>17 #include <wx/frame.h>18 #include <wx/html/htmlwin.h>19 #include <wx/dialog.h>20@@ -35,8 +36,6 @@21 #include <wx/spinctrl.h>22 #include <wx/scrolwin.h>23 #include <wx/statbmp.h>24-#include <wx/combobox.h>25-#include <wx/richtext/richtextctrl.h>26 27 ///////////////////////////////////////////////////////////////////////////28 29@@ -47,8 +46,8 @@30 #define wxID_BUTTONSEND 100431 #define wxID_BUTTONRECEIVE 100532 #define wxID_TEXTCTRLADDRESS 100633-#define wxID_BUTTONCOPY 100734-#define wxID_BUTTONCHANGE 100835+#define wxID_BUTTONCHANGE 100736+#define wxID_BUTTONCOPY 100837 #define wxID_TRANSACTIONFEE 100938 #define wxID_PROXYIP 101039 #define wxID_PROXYPORT 101140@@ -62,33 +61,7 @@41 #define wxID_BUTTONNEW 101942 #define wxID_BUTTONEDIT 102043 #define wxID_BUTTONDELETE 102144-#define wxID_DEL0 102245-#define wxID_DEL1 102346-#define wxID_DEL2 102447-#define wxID_DEL3 102548-#define wxID_DEL4 102649-#define wxID_DEL5 102750-#define wxID_DEL6 102851-#define wxID_DEL7 102952-#define wxID_DEL8 103053-#define wxID_DEL9 103154-#define wxID_DEL10 103255-#define wxID_DEL11 103356-#define wxID_DEL12 103457-#define wxID_DEL13 103558-#define wxID_DEL14 103659-#define wxID_DEL15 103760-#define wxID_DEL16 103861-#define wxID_DEL17 103962-#define wxID_DEL18 104063-#define wxID_DEL19 104164-#define wxID_BUTTONPREVIEW 104265-#define wxID_BUTTONSAMPLE 104366-#define wxID_CANCEL2 104467-#define wxID_BUTTONBACK 104568-#define wxID_BUTTONNEXT 104669-#define wxID_SUBMIT 104770-#define wxID_TEXTCTRL 104871+#define wxID_TEXTCTRL 102272 73 ///////////////////////////////////////////////////////////////////////////////74 /// Class CMainFrameBase75@@ -107,20 +80,14 @@76 77 wxStaticText* m_staticText32;78 wxTextCtrl* m_textCtrlAddress;79+ wxButton* m_buttonNew;80 wxButton* m_buttonCopy;81- wxButton* m_button91;82 83 wxPanel* m_panel14;84 wxStaticText* m_staticText41;85 wxStaticText* m_staticTextBalance;86 87 wxChoice* m_choiceFilter;88- wxNotebook* m_notebook;89- wxPanel* m_panel7;90- wxPanel* m_panel9;91- wxPanel* m_panel8;92- wxPanel* m_panel10;93- wxPanel* m_panel11;94 95 // Virtual event handlers, overide them in your derived class96 virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }97@@ -141,24 +108,17 @@98 virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }99 virtual void OnMouseEventsAddress( wxMouseEvent& event ){ event.Skip(); }100 virtual void OnSetFocusAddress( wxFocusEvent& event ){ event.Skip(); }101+ virtual void OnButtonChange( wxCommandEvent& event ){ event.Skip(); }102 virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }103- virtual void OnButtonChange( wxCommandEvent& event ){ event.Skip(); }104 virtual void OnListColBeginDrag( wxListEvent& event ){ event.Skip(); }105- virtual void OnListItemActivatedAllTransactions( wxListEvent& event ){ event.Skip(); }106+ virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }107 virtual void OnPaintListCtrl( wxPaintEvent& event ){ event.Skip(); }108- virtual void OnListItemActivatedOrdersSent( wxListEvent& event ){ event.Skip(); }109- virtual void OnListItemActivatedProductsSent( wxListEvent& event ){ event.Skip(); }110- virtual void OnListItemActivatedOrdersReceived( wxListEvent& event ){ event.Skip(); }111 112 113 public:114 wxMenu* m_menuOptions;115 wxListCtrl* m_listCtrl;116- wxListCtrl* m_listCtrlEscrows;117- wxListCtrl* m_listCtrlOrdersSent;118- wxListCtrl* m_listCtrlProductsSent;119- wxListCtrl* m_listCtrlOrdersReceived;120- CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = wxT("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 705,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );121+ CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = _("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 712,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );122 ~CMainFrameBase();123 124 };125@@ -179,7 +139,7 @@126 127 128 public:129- CTxDetailsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Transaction Details"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 620,450 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );130+ CTxDetailsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Transaction Details"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 620,450 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );131 ~CTxDetailsDialogBase();132 133 };134@@ -215,8 +175,6 @@135 136 wxStaticText* m_staticText321;137 wxStaticText* m_staticText69;138- wxStaticText* m_staticText70;139- wxStaticText* m_staticText71;140 wxButton* m_buttonOK;141 wxButton* m_buttonCancel;142 wxButton* m_buttonApply;143@@ -234,7 +192,7 @@144 145 146 public:147- COptionsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 540,360 ), long style = wxDEFAULT_DIALOG_STYLE );148+ COptionsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 540,360 ), long style = wxDEFAULT_DIALOG_STYLE );149 ~COptionsDialogBase();150 151 };152@@ -247,7 +205,7 @@153 private:154 155 protected:156- 157+ wxStaticBitmap* m_bitmap;158 159 wxStaticText* m_staticText40;160 161@@ -262,7 +220,7 @@162 163 public:164 wxStaticText* m_staticTextVersion;165- CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 507,298 ), long style = wxDEFAULT_DIALOG_STYLE );166+ CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,329 ), long style = wxDEFAULT_DIALOG_STYLE );167 ~CAboutDialogBase();168 169 };170@@ -309,7 +267,7 @@171 172 173 public:174- CSendDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 675,312 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );175+ CSendDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 675,312 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );176 ~CSendDialogBase();177 178 };179@@ -336,7 +294,7 @@180 181 182 public:183- CSendingDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Sending..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 442,151 ), long style = wxDEFAULT_DIALOG_STYLE );184+ CSendingDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Sending..."), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 442,151 ), long style = wxDEFAULT_DIALOG_STYLE );185 ~CSendingDialogBase();186 187 };188@@ -372,7 +330,7 @@189 190 191 public:192- CYourAddressDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Your Bitcoin Addresses"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );193+ CYourAddressDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Your Bitcoin Addresses"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );194 ~CYourAddressDialogBase();195 196 };197@@ -408,239 +366,8 @@198 199 public:200 wxButton* m_buttonCancel;201- CAddressBookDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Address Book"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );202+ CAddressBookDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Address Book"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 610,390 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );203 ~CAddressBookDialogBase();204- 205-};206-207-///////////////////////////////////////////////////////////////////////////////208-/// Class CProductsDialogBase209-///////////////////////////////////////////////////////////////////////////////210-class CProductsDialogBase : public wxDialog 211-{212- private:213- 214- protected:215- wxComboBox* m_comboBoxCategory;216- wxTextCtrl* m_textCtrlSearch;217- wxButton* m_buttonSearch;218- wxListCtrl* m_listCtrl;219- 220- // Virtual event handlers, overide them in your derived class221- virtual void OnCombobox( wxCommandEvent& event ){ event.Skip(); }222- virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }223- virtual void OnButtonSearch( wxCommandEvent& event ){ event.Skip(); }224- virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }225- 226- 227- public:228- CProductsDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Marketplace"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 708,535 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );229- ~CProductsDialogBase();230- 231-};232-233-///////////////////////////////////////////////////////////////////////////////234-/// Class CEditProductDialogBase235-///////////////////////////////////////////////////////////////////////////////236-class CEditProductDialogBase : public wxFrame 237-{238- private:239- 240- protected:241- wxScrolledWindow* m_scrolledWindow;242- wxStaticText* m_staticText106;243- wxComboBox* m_comboBoxCategory;244- wxStaticText* m_staticText108;245- wxTextCtrl* m_textCtrlTitle;246- wxStaticText* m_staticText107;247- wxTextCtrl* m_textCtrlPrice;248- wxStaticText* m_staticText22;249- wxTextCtrl* m_textCtrlDescription;250- wxStaticText* m_staticText23;251- wxTextCtrl* m_textCtrlInstructions;252- wxStaticText* m_staticText24;253- wxStaticText* m_staticText25;254- 255- wxTextCtrl* m_textCtrlLabel0;256- wxTextCtrl* m_textCtrlField0;257- wxButton* m_buttonDel0;258- wxTextCtrl* m_textCtrlLabel1;259- wxTextCtrl* m_textCtrlField1;260- wxButton* m_buttonDel1;261- wxTextCtrl* m_textCtrlLabel2;262- wxTextCtrl* m_textCtrlField2;263- wxButton* m_buttonDel2;264- wxTextCtrl* m_textCtrlLabel3;265- wxTextCtrl* m_textCtrlField3;266- wxButton* m_buttonDel3;267- wxTextCtrl* m_textCtrlLabel4;268- wxTextCtrl* m_textCtrlField4;269- wxButton* m_buttonDel4;270- wxTextCtrl* m_textCtrlLabel5;271- wxTextCtrl* m_textCtrlField5;272- wxButton* m_buttonDel5;273- wxTextCtrl* m_textCtrlLabel6;274- wxTextCtrl* m_textCtrlField6;275- wxButton* m_buttonDel6;276- wxTextCtrl* m_textCtrlLabel7;277- wxTextCtrl* m_textCtrlField7;278- wxButton* m_buttonDel7;279- wxTextCtrl* m_textCtrlLabel8;280- wxTextCtrl* m_textCtrlField8;281- wxButton* m_buttonDel8;282- wxTextCtrl* m_textCtrlLabel9;283- wxTextCtrl* m_textCtrlField9;284- wxButton* m_buttonDel9;285- wxTextCtrl* m_textCtrlLabel10;286- wxTextCtrl* m_textCtrlField10;287- wxButton* m_buttonDel10;288- wxTextCtrl* m_textCtrlLabel11;289- wxTextCtrl* m_textCtrlField11;290- wxButton* m_buttonDel11;291- wxTextCtrl* m_textCtrlLabel12;292- wxTextCtrl* m_textCtrlField12;293- wxButton* m_buttonDel12;294- wxTextCtrl* m_textCtrlLabel13;295- wxTextCtrl* m_textCtrlField13;296- wxButton* m_buttonDel13;297- wxTextCtrl* m_textCtrlLabel14;298- wxTextCtrl* m_textCtrlField14;299- wxButton* m_buttonDel14;300- wxTextCtrl* m_textCtrlLabel15;301- wxTextCtrl* m_textCtrlField15;302- wxButton* m_buttonDel15;303- wxTextCtrl* m_textCtrlLabel16;304- wxTextCtrl* m_textCtrlField16;305- wxButton* m_buttonDel16;306- wxTextCtrl* m_textCtrlLabel17;307- wxTextCtrl* m_textCtrlField17;308- wxButton* m_buttonDel17;309- wxTextCtrl* m_textCtrlLabel18;310- wxTextCtrl* m_textCtrlField18;311- wxButton* m_buttonDel18;312- wxTextCtrl* m_textCtrlLabel19;313- wxTextCtrl* m_textCtrlField19;314- wxButton* m_buttonDel19;315- wxButton* m_buttonAddField;316- wxButton* m_buttonOK;317- wxButton* m_buttonPreview;318- wxButton* m_buttonCancel;319- 320- // Virtual event handlers, overide them in your derived class321- virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }322- virtual void OnButtonDel0( wxCommandEvent& event ){ event.Skip(); }323- virtual void OnButtonDel1( wxCommandEvent& event ){ event.Skip(); }324- virtual void OnButtonDel2( wxCommandEvent& event ){ event.Skip(); }325- virtual void OnButtonDel3( wxCommandEvent& event ){ event.Skip(); }326- virtual void OnButtonDel4( wxCommandEvent& event ){ event.Skip(); }327- virtual void OnButtonDel5( wxCommandEvent& event ){ event.Skip(); }328- virtual void OnButtonDel6( wxCommandEvent& event ){ event.Skip(); }329- virtual void OnButtonDel7( wxCommandEvent& event ){ event.Skip(); }330- virtual void OnButtonDel8( wxCommandEvent& event ){ event.Skip(); }331- virtual void OnButtonDel9( wxCommandEvent& event ){ event.Skip(); }332- virtual void OnButtonDel10( wxCommandEvent& event ){ event.Skip(); }333- virtual void OnButtonDel11( wxCommandEvent& event ){ event.Skip(); }334- virtual void OnButtonDel12( wxCommandEvent& event ){ event.Skip(); }335- virtual void OnButtonDel13( wxCommandEvent& event ){ event.Skip(); }336- virtual void OnButtonDel14( wxCommandEvent& event ){ event.Skip(); }337- virtual void OnButtonDel15( wxCommandEvent& event ){ event.Skip(); }338- virtual void OnButtonDel16( wxCommandEvent& event ){ event.Skip(); }339- virtual void OnButtonDel17( wxCommandEvent& event ){ event.Skip(); }340- virtual void OnButtonDel18( wxCommandEvent& event ){ event.Skip(); }341- virtual void OnButtonDel19( wxCommandEvent& event ){ event.Skip(); }342- virtual void OnButtonAddField( wxCommandEvent& event ){ event.Skip(); }343- virtual void OnButtonSend( wxCommandEvent& event ){ event.Skip(); }344- virtual void OnButtonPreview( wxCommandEvent& event ){ event.Skip(); }345- virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }346- 347- 348- public:349- wxFlexGridSizer* fgSizer5;350- CEditProductDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Edit Product"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 660,640 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );351- ~CEditProductDialogBase();352- 353-};354-355-///////////////////////////////////////////////////////////////////////////////356-/// Class CViewProductDialogBase357-///////////////////////////////////////////////////////////////////////////////358-class CViewProductDialogBase : public wxFrame 359-{360- private:361- 362- protected:363- wxHtmlWindow* m_htmlWinReviews;364- wxScrolledWindow* m_scrolledWindow;365- wxRichTextCtrl* m_richTextHeading;366- wxStaticText* m_staticTextInstructions;367- wxButton* m_buttonSubmitForm;368- wxButton* m_buttonCancelForm;369- wxButton* m_buttonBack;370- wxButton* m_buttonNext;371- wxButton* m_buttonCancel;372- 373- // Virtual event handlers, overide them in your derived class374- virtual void OnButtonSubmitForm( wxCommandEvent& event ){ event.Skip(); }375- virtual void OnButtonCancelForm( wxCommandEvent& event ){ event.Skip(); }376- virtual void OnButtonBack( wxCommandEvent& event ){ event.Skip(); }377- virtual void OnButtonNext( wxCommandEvent& event ){ event.Skip(); }378- virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }379- 380- 381- public:382- CViewProductDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Order Form"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 630,520 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );383- ~CViewProductDialogBase();384- 385-};386-387-///////////////////////////////////////////////////////////////////////////////388-/// Class CViewOrderDialogBase389-///////////////////////////////////////////////////////////////////////////////390-class CViewOrderDialogBase : public wxFrame 391-{392- private:393- 394- protected:395- wxHtmlWindow* m_htmlWin;396- wxButton* m_buttonOK;397- 398- // Virtual event handlers, overide them in your derived class399- virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }400- 401- 402- public:403- CViewOrderDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("View Order"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 630,520 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );404- ~CViewOrderDialogBase();405- 406-};407-408-///////////////////////////////////////////////////////////////////////////////409-/// Class CEditReviewDialogBase410-///////////////////////////////////////////////////////////////////////////////411-class CEditReviewDialogBase : public wxFrame 412-{413- private:414- 415- protected:416- 417- wxStaticText* m_staticTextSeller;418- 419- wxStaticText* m_staticText110;420- wxChoice* m_choiceStars;421- wxStaticText* m_staticText43;422- wxTextCtrl* m_textCtrlReview;423- wxButton* m_buttonSubmit;424- wxButton* m_buttonCancel;425- 426- // Virtual event handlers, overide them in your derived class427- virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }428- virtual void OnButtonSubmit( wxCommandEvent& event ){ event.Skip(); }429- virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }430- 431- 432- public:433- CEditReviewDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Enter Review"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 630,440 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );434- ~CEditReviewDialogBase();435 436 };437
uint256.h (modified)
1--- v0.2.0/uint256.h2+++ v0.2.2/uint256.h3@@ -299,19 +299,18 @@4 return string(psz, psz + sizeof(pn)*2);5 }6 7- void SetHex(const std::string& str)8+ void SetHex(const char* psz)9 {10 for (int i = 0; i < WIDTH; i++)11 pn[i] = 0;12 13- // skip 0x14- const char* psz = str.c_str();15+ // skip leading spaces16 while (isspace(*psz))17 psz++;18+19+ // skip 0x20 if (psz[0] == '0' && tolower(psz[1]) == 'x')21 psz += 2;22- while (isspace(*psz))23- psz++;24 25 // hex string to uint26 static char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };27@@ -332,6 +331,11 @@28 }29 }30 31+ void SetHex(const std::string& str)32+ {33+ SetHex(str.c_str());34+ }35+36 std::string ToString() const37 {38 return (GetHex());
util.cpp (modified)
1--- v0.2.0/util.cpp2+++ v0.2.2/util.cpp3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -8,10 +8,11 @@10 map<string, string> mapArgs;11 map<string, vector<string> > mapMultiArgs;12 bool fDebug = false;13+bool fPrintToConsole = false;14 bool fPrintToDebugger = false;15-bool fPrintToConsole = false;16 char pszSetDataDir[MAX_PATH] = "";17 bool fShutdown = false;18+bool fDaemon = false;19 20 21 22@@ -75,6 +76,8 @@23 24 void RandAddSeedPerfmon()25 {26+ RandAddSeed();27+28 // This can take up to 2 seconds, so only do it every 10 minutes29 static int64 nLastPerfmon;30 if (GetTime() < nLastPerfmon + 10 * 60)31@@ -87,7 +90,7 @@32 unsigned char pdata[250000];33 memset(pdata, 0, sizeof(pdata));34 unsigned long nSize = sizeof(pdata);35- long ret = RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);36+ long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);37 RegCloseKey(HKEY_PERFORMANCE_DATA);38 if (ret == ERROR_SUCCESS)39 {40@@ -129,6 +132,79 @@41 42 43 44+inline int OutputDebugStringF(const char* pszFormat, ...)45+{46+ int ret = 0;47+ if (fPrintToConsole || wxTheApp == NULL)48+ {49+ // print to console50+ va_list arg_ptr;51+ va_start(arg_ptr, pszFormat);52+ ret = vprintf(pszFormat, arg_ptr);53+ va_end(arg_ptr);54+ }55+ else56+ {57+ // print to debug.log58+ char pszFile[MAX_PATH+100];59+ GetDataDir(pszFile);60+ strlcat(pszFile, "/debug.log", sizeof(pszFile));61+ FILE* fileout = fopen(pszFile, "a");62+ if (fileout)63+ {64+ //// Debug print useful for profiling65+ //fprintf(fileout, " %"PRI64d" ", wxGetLocalTimeMillis().GetValue());66+ va_list arg_ptr;67+ va_start(arg_ptr, pszFormat);68+ ret = vfprintf(fileout, pszFormat, arg_ptr);69+ va_end(arg_ptr);70+ fclose(fileout);71+ }72+ }73+74+#ifdef __WXMSW__75+ if (fPrintToDebugger)76+ {77+ // accumulate a line at a time78+ static CCriticalSection cs_OutputDebugStringF;79+ CRITICAL_BLOCK(cs_OutputDebugStringF)80+ {81+ static char pszBuffer[50000];82+ static char* pend;83+ if (pend == NULL)84+ pend = pszBuffer;85+ va_list arg_ptr;86+ va_start(arg_ptr, pszFormat);87+ int limit = END(pszBuffer) - pend - 2;88+ int ret = _vsnprintf(pend, limit, pszFormat, arg_ptr);89+ va_end(arg_ptr);90+ if (ret < 0 || ret >= limit)91+ {92+ pend = END(pszBuffer) - 2;93+ *pend++ = '\n';94+ }95+ else96+ pend += ret;97+ *pend = '\0';98+ char* p1 = pszBuffer;99+ char* p2;100+ while (p2 = strchr(p1, '\n'))101+ {102+ p2++;103+ char c = *p2;104+ *p2 = '\0';105+ OutputDebugStringA(p1);106+ *p2 = c;107+ p1 = p2;108+ }109+ if (p1 != pszBuffer)110+ memmove(pszBuffer, p1, pend - p1 + 1);111+ pend -= (p1 - pszBuffer);112+ }113+ }114+#endif115+ return ret;116+}117 118 119 // Safer snprintf120@@ -365,7 +441,7 @@121 #ifdef __WXMSW__122 char pszModule[MAX_PATH];123 pszModule[0] = '\0';124- GetModuleFileName(NULL, pszModule, sizeof(pszModule));125+ GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));126 #else127 // might not be thread safe, uses wxString128 //const char* pszModule = wxStandardPaths::Get().GetExecutablePath().mb_str();
util.h (modified)
1--- v0.2.0/util.h2+++ v0.2.2/util.h3@@ -1,4 +1,4 @@4-// Copyright (c) 2009 Satoshi Nakamoto5+// Copyright (c) 2009-2010 Satoshi Nakamoto6 // Distributed under the MIT/X11 software license, see the accompanying7 // file license.txt or http://www.opensource.org/licenses/mit-license.php.8 9@@ -55,6 +55,7 @@10 }11 12 #ifdef __WXMSW__13+static const bool fWindows = true;14 #define MSG_NOSIGNAL 015 #define MSG_DONTWAIT 016 #ifndef UINT64_MAX17@@ -66,7 +67,10 @@18 #define S_IRUSR 040019 #define S_IWUSR 020020 #endif21-#else22+#define unlink _unlink23+typedef int socklen_t;24+#else25+static const bool fWindows = false;26 #define WSAGetLastError() errno27 #define WSAEWOULDBLOCK EWOULDBLOCK28 #define WSAEMSGSIZE EMSGSIZE29@@ -112,13 +116,15 @@30 extern map<string, string> mapArgs;31 extern map<string, vector<string> > mapMultiArgs;32 extern bool fDebug;33+extern bool fPrintToConsole;34 extern bool fPrintToDebugger;35-extern bool fPrintToConsole;36 extern char pszSetDataDir[MAX_PATH];37 extern bool fShutdown;38+extern bool fDaemon;39 40 void RandAddSeed();41 void RandAddSeedPerfmon();42+int OutputDebugStringF(const char* pszFormat, ...);43 int my_snprintf(char* buffer, size_t limit, const char* format, ...);44 string strprintf(const char* format, ...);45 bool error(const char* format, ...);46@@ -219,92 +225,6 @@47 48 49 50-inline int OutputDebugStringF(const char* pszFormat, ...)51-{52- int ret = 0;53-#ifdef __WXDEBUG__54- if (!fPrintToConsole)55- {56- // print to debug.log57- char pszFile[MAX_PATH+100];58- GetDataDir(pszFile);59- strlcat(pszFile, "/debug.log", sizeof(pszFile));60- FILE* fileout = fopen(pszFile, "a");61- if (fileout)62- {63- //// Debug print useful for profiling64- //fprintf(fileout, " %"PRI64d" ", wxGetLocalTimeMillis().GetValue());65- va_list arg_ptr;66- va_start(arg_ptr, pszFormat);67- ret = vfprintf(fileout, pszFormat, arg_ptr);68- va_end(arg_ptr);69- fclose(fileout);70- }71- }72-73-#ifdef __WXMSW__74- if (fPrintToDebugger)75- {76- // accumulate a line at a time77- static CCriticalSection cs_OutputDebugStringF;78- CRITICAL_BLOCK(cs_OutputDebugStringF)79- {80- static char pszBuffer[50000];81- static char* pend;82- if (pend == NULL)83- pend = pszBuffer;84- va_list arg_ptr;85- va_start(arg_ptr, pszFormat);86- int limit = END(pszBuffer) - pend - 2;87- int ret = _vsnprintf(pend, limit, pszFormat, arg_ptr);88- va_end(arg_ptr);89- if (ret < 0 || ret >= limit)90- {91- pend = END(pszBuffer) - 2;92- *pend++ = '\n';93- }94- else95- pend += ret;96- *pend = '\0';97- char* p1 = pszBuffer;98- char* p2;99- while (p2 = strchr(p1, '\n'))100- {101- p2++;102- char c = *p2;103- *p2 = '\0';104- OutputDebugString(p1);105- *p2 = c;106- p1 = p2;107- }108- if (p1 != pszBuffer)109- memmove(pszBuffer, p1, pend - p1 + 1);110- pend -= (p1 - pszBuffer);111- }112- }113-#endif114-#endif115-116- if (fPrintToConsole)117- {118- // print to console119- va_list arg_ptr;120- va_start(arg_ptr, pszFormat);121- ret = vprintf(pszFormat, arg_ptr);122- va_end(arg_ptr);123- }124- return ret;125-}126-127-128-129-130-131-132-133-134-135-136 inline string i64tostr(int64 n)137 {138 return strprintf("%"PRI64d, n);139@@ -341,6 +261,11 @@140 inline int roundint(double d)141 {142 return (int)(d > 0 ? d + 0.5 : d - 0.5);143+}144+145+inline int64 roundint64(double d)146+{147+ return (int64)(d > 0 ? d + 0.5 : d - 0.5);148 }149 150 template<typename T>151@@ -408,6 +333,19 @@152 return pszTime;153 }154 155+template<typename T>156+void skipspaces(T& it)157+{158+ while (isspace(*it))159+ ++it;160+}161+162+inline const char* wxGetTranslation(const char* psz)163+{164+ // Return translated UTF-8 const char*165+ return wxGetTranslation(wxString(psz, wxConvUTF8)).utf8_str();166+}167+168 169 170 171@@ -418,8 +356,9 @@172 inline void heapchk()173 {174 #ifdef __WXMSW__175- if (_heapchk() != _HEAPOK)176- DebugBreak();177+ /// for debugging178+ //if (_heapchk() != _HEAPOK)179+ // DebugBreak();180 #endif181 }182
