#include <boost/function.hpp>\r
#include <boost/filesystem.hpp>\r
#include <boost/algorithm/string.hpp>\r
+#include <boost/interprocess/sync/interprocess_mutex.hpp>\r
+#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>\r
+#include <boost/date_time/gregorian/gregorian_types.hpp>\r
+#include <boost/date_time/posix_time/posix_time_types.hpp>\r
\r
#ifdef __WXMSW__\r
#include <windows.h>\r
\r
#include "headers.h"\r
\r
+extern string GetDefaultDataDir(); /// todo: delete this later, just used by debug test\r
+\r
\r
\r
\r
//\r
\r
#ifdef __WXMSW__\r
-typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);\r
-\r
-string MyGetSpecialFolderPath(int nFolder, bool fCreate)\r
-{\r
- char pszPath[MAX_PATH+100] = "";\r
-\r
- // SHGetSpecialFolderPath is not usually available on NT 4.0\r
- HMODULE hShell32 = LoadLibraryA("shell32.dll");\r
- if (hShell32)\r
- {\r
- PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =\r
- (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");\r
- if (pSHGetSpecialFolderPath)\r
- (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);\r
- FreeModule(hShell32);\r
- }\r
-\r
- // Backup option\r
- if (pszPath[0] == '\0')\r
- {\r
- if (nFolder == CSIDL_STARTUP)\r
- {\r
- strcpy(pszPath, getenv("USERPROFILE"));\r
- strcat(pszPath, "\\Start Menu\\Programs\\Startup");\r
- }\r
- else if (nFolder == CSIDL_APPDATA)\r
- {\r
- strcpy(pszPath, getenv("APPDATA"));\r
- }\r
- }\r
-\r
- return pszPath;\r
-}\r
-\r
string StartupShortcutPath()\r
{\r
return MyGetSpecialFolderPath(CSIDL_STARTUP, true) + "\\Bitcoin.lnk";\r
\r
bool GetStartOnSystemStartup()\r
{\r
- return wxFileExists(StartupShortcutPath());\r
+ return filesystem::exists(StartupShortcutPath().c_str());\r
}\r
\r
void SetStartOnSystemStartup(bool fAutoStart)\r
//\r
\r
// Define a new application\r
-class CMyApp: public wxApp\r
+class CMyApp : public wxApp\r
{\r
public:\r
wxLocale m_locale;\r
#ifdef __WXMSW__\r
if (str.size() >= 1 && str[0] == '/')\r
str[0] = '-';\r
- str = str.MakeLower();\r
+ char pszLower[MAX_PATH];\r
+ strlcpy(pszLower, str.c_str(), sizeof(pszLower));\r
+ strlwr(pszLower);\r
+ str = pszLower;\r
#endif\r
// haven't decided which argument to use for this yet\r
if (str == "-daemon" || str == "-d" || str == "start")\r
" -daemon \t " + _("Run in the background as a daemon and accept commands\n") +\r
" -? \t " + _("This help message\n");\r
\r
-\r
- if (fWindows && fGUI)\r
- {\r
- // Tabs make the columns line up in the message box\r
- wxMessageBox(strUsage, "Bitcoin", wxOK);\r
- }\r
- else\r
- {\r
- // Remove tabs\r
- strUsage.Replace("\t", "");\r
- fprintf(stderr, "%s", ((string)strUsage).c_str());\r
- }\r
+#if defined(__WXMSW__) && wxUSE_GUI\r
+ // Tabs make the columns line up in the message box\r
+ wxMessageBox(strUsage, "Bitcoin", wxOK);\r
+#else\r
+ // Remove tabs\r
+ strUsage.Replace("\t", "");\r
+ fprintf(stderr, "%s", ((string)strUsage).c_str());\r
+#endif\r
return false;\r
}\r
\r
printf("System default language is %d %s\n", m_locale.GetSystemLanguage(), ((string)m_locale.GetSysName()).c_str());\r
printf("Language file %s (%s)\n", (string("locale/") + (string)m_locale.GetCanonicalName() + "/LC_MESSAGES/bitcoin.mo").c_str(), ((string)m_locale.GetLocale()).c_str());\r
\r
+ /// debug - for now, just watching if these match\r
+ if (pszSetDataDir[0] == 0)\r
+ {\r
+ if (GetDefaultDataDir() != GetDataDir())\r
+ printf("**** GetDefaultDataDir() %s != %s\n", GetDefaultDataDir().c_str(), GetDataDir().c_str());\r
+ else\r
+ printf("OK GetDefaultDataDir() %s == %s\n", GetDefaultDataDir().c_str(), GetDataDir().c_str());\r
+ }\r
+\r
if (mapArgs.count("-loadblockindextest"))\r
{\r
CTxDB txdb("r");\r
msgid ""
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
"\n"
+"This is experimental software.\n"
+"\n"
"Distributed under the MIT/X11 software license, see the accompanying file \n"
"license.txt or http://www.opensource.org/licenses/mit-license.php.\n"
"\n"
msgstr ""
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
"\n"
+"Dies ist experimentelle Software.\n"
+"\n"
"Lizensiert unter der MIT/X11 Software-Lizenz. Beachten Sie die beiliegende\n"
"Datei license.txt oder http://www.opensource.org/licenses/mit-license.php.\n"
"\n"
msgid ""
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
"\n"
+"This is experimental software.\n"
+"\n"
"Distributed under the MIT/X11 software license, see the accompanying file \n"
"license.txt or http://www.opensource.org/licenses/mit-license.php.\n"
"\n"
msgstr ""
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
"\n"
+"Questo รจ un software sperimentale.\n"
+"\n"
"Distribuito sotto la licenza software MIT/X11, guarda il file license.txt\n"
"incluso oppure su http://www.opensource.org/licenses/mit-license.php.\n"
"\n"
msgid ""
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
"\n"
+"This is experimental software.\n"
+"\n"
"Distributed under the MIT/X11 software license, see the accompanying file \n"
"license.txt or http://www.opensource.org/licenses/mit-license.php.\n"
"\n"
msgstr ""
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
"\n"
+"Dit is experimentele software.\n"
+"\n"
"Gedistributeerd onder de MIT/X11 software licentie, see het bijbehorende bestand \n"
"license.txt of http://www.opensource.org/licenses/mit-license.php.\n"
"\n"
if (nFreeBytesAvailable < (int64)15000000 + nAdditionalBytes)\r
{\r
fShutdown = true;\r
+ printf("*** %s***\n", _("Warning: Disk space is low "));\r
+#if wxUSE_GUI\r
ThreadSafeMessageBox(_("Warning: Disk space is low "), "Bitcoin", wxOK | wxICON_EXCLAMATION);\r
+#endif\r
CreateThread(Shutdown, NULL);\r
return false;\r
}\r
if ((++tmp.block.nNonce & nMask) == 0)\r
{\r
// Meter hashes/sec\r
- static int64 nHashCounter;\r
- static int64 nLastTick;\r
- if (nLastTick == 0)\r
- nLastTick = GetTimeMillis();\r
+ static int64 nTimerStart;\r
+ static int nHashCounter;\r
+ if (nTimerStart == 0)\r
+ nTimerStart = GetTimeMillis();\r
else\r
- nHashCounter += nMask + 1;\r
- if (GetTimeMillis() - nLastTick > 4000)\r
+ nHashCounter++;\r
+ if (GetTimeMillis() - nTimerStart > 4000)\r
{\r
- double dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nLastTick);\r
- nLastTick = GetTimeMillis();\r
- nHashCounter = 0;\r
- string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0);\r
- UIThreadCall(bind(CalledSetStatusBar, strStatus, 0));\r
- static int64 nLogTime;\r
- if (GetTime() - nLogTime > 30 * 60)\r
+ static CCriticalSection cs;\r
+ CRITICAL_BLOCK(cs)\r
{\r
- nLogTime = GetTime();\r
- printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str());\r
- printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0);\r
+ if (GetTimeMillis() - nTimerStart > 4000)\r
+ {\r
+ double dHashesPerSec = 1000.0 * (nMask+1) * nHashCounter / (GetTimeMillis() - nTimerStart);\r
+ nTimerStart = GetTimeMillis();\r
+ nHashCounter = 0;\r
+ string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0);\r
+ UIThreadCall(bind(CalledSetStatusBar, strStatus, 0));\r
+ static int64 nLogTime;\r
+ if (GetTime() - nLogTime > 30 * 60)\r
+ {\r
+ nLogTime = GetTime();\r
+ printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str());\r
+ printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0);\r
+ }\r
+ }\r
}\r
}\r
\r
\r
\r
clean:\r
- -rm obj/*.o\r
- -rm obj/nogui/*.o\r
- -rm headers.h.gch\r
+ -rm -f obj/*.o\r
+ -rm -f obj/nogui/*.o\r
+ -rm -f headers.h.gch\r
string strResult = (result.type() == str_type ? result.get_str() : write_string(result, true));\r
if (result.type() != null_type)\r
{\r
- if (fWindows && fGUI)\r
- // Windows GUI apps can't print to command line,\r
- // so settle for a message box yuck\r
- MyMessageBox(strResult.c_str(), "Bitcoin", wxOK);\r
- else\r
- fprintf(stdout, "%s\n", strResult.c_str());\r
+#if defined(__WXMSW__) && wxUSE_GUI\r
+ // Windows GUI apps can't print to command line,\r
+ // so settle for a message box yuck\r
+ MyMessageBox(strResult.c_str(), "Bitcoin", wxOK);\r
+#else\r
+ fprintf(stdout, "%s\n", strResult.c_str());\r
+#endif\r
}\r
return 0;\r
}\r
catch (std::exception& e) {\r
- if (fWindows && fGUI)\r
- MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);\r
- else\r
- fprintf(stderr, "error: %s\n", e.what());\r
+#if defined(__WXMSW__) && wxUSE_GUI\r
+ MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);\r
+#else\r
+ fprintf(stderr, "error: %s\n", e.what());\r
+#endif\r
} catch (...) {\r
PrintException(NULL, "CommandLineRPC()");\r
}\r
class CAutoFile;\r
\r
static const int VERSION = 300;\r
-static const char* pszSubVer = "";\r
+static const char* pszSubVer = ".1";\r
\r
\r
\r
\r
bSizer631->Add( 0, 4, 0, wxEXPAND, 5 );\r
\r
- m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Satoshi Nakamoto.\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 );\r
+ m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Satoshi Nakamoto.\n\nThis is experimental software.\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 );\r
m_staticTextMain->Wrap( -1 );\r
bSizer631->Add( m_staticTextMain, 0, wxALL, 5 );\r
\r
\r
public:\r
wxStaticText* m_staticTextVersion;\r
- CAboutDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("About Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 532,315 ), long style = wxDEFAULT_DIALOG_STYLE );\r
+ 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 );\r
~CAboutDialogBase();\r
\r
};\r
<property name="minimum_size"></property>\r
<property name="name">CAboutDialogBase</property>\r
<property name="pos"></property>\r
- <property name="size">532,315</property>\r
+ <property name="size">532,329</property>\r
<property name="style">wxDEFAULT_DIALOG_STYLE</property>\r
<property name="subclass"></property>\r
<property name="title">About Bitcoin</property>\r
<property name="font"></property>\r
<property name="hidden">0</property>\r
<property name="id">wxID_ANY</property>\r
- <property name="label">Copyright (c) 2009-2010 Satoshi Nakamoto.

Distributed under the MIT/X11 software license, see the accompanying file 
license.txt or http://www.opensource.org/licenses/mit-license.php.

This 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).</property>\r
+ <property name="label">Copyright (c) 2009-2010 Satoshi Nakamoto.

This is experimental software.

Distributed under the MIT/X11 software license, see the accompanying file 
license.txt or http://www.opensource.org/licenses/mit-license.php.

This 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).</property>\r
<property name="maximum_size"></property>\r
<property name="minimum_size"></property>\r
<property name="name">m_staticTextMain</property>\r
\r
\r
// Init openssl library multithreading support\r
-static wxMutex** ppmutexOpenSSL;\r
+static boost::interprocess::interprocess_mutex** ppmutexOpenSSL;\r
void locking_callback(int mode, int i, const char* file, int line)\r
{\r
if (mode & CRYPTO_LOCK)\r
- ppmutexOpenSSL[i]->Lock();\r
+ ppmutexOpenSSL[i]->lock();\r
else\r
- ppmutexOpenSSL[i]->Unlock();\r
+ ppmutexOpenSSL[i]->unlock();\r
}\r
\r
// Init\r
CInit()\r
{\r
// Init openssl library multithreading support\r
- ppmutexOpenSSL = (wxMutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(wxMutex*));\r
+ ppmutexOpenSSL = (boost::interprocess::interprocess_mutex**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(boost::interprocess::interprocess_mutex*));\r
for (int i = 0; i < CRYPTO_num_locks(); i++)\r
- ppmutexOpenSSL[i] = new wxMutex();\r
+ ppmutexOpenSSL[i] = new boost::interprocess::interprocess_mutex();\r
CRYPTO_set_locking_callback(locking_callback);\r
\r
#ifdef __WXMSW__\r
if (fileout)\r
{\r
//// Debug print useful for profiling\r
- //fprintf(fileout, " %"PRI64d" ", wxGetLocalTimeMillis().GetValue());\r
+ //fprintf(fileout, " %"PRI64d" ", GetTimeMillis());\r
va_list arg_ptr;\r
va_start(arg_ptr, pszFormat);\r
ret = vfprintf(fileout, pszFormat, arg_ptr);\r
\r
\r
\r
+#ifdef __WXMSW__\r
+typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);\r
+\r
+string MyGetSpecialFolderPath(int nFolder, bool fCreate)\r
+{\r
+ char pszPath[MAX_PATH+100] = "";\r
+\r
+ // SHGetSpecialFolderPath isn't always available on old Windows versions\r
+ HMODULE hShell32 = LoadLibraryA("shell32.dll");\r
+ if (hShell32)\r
+ {\r
+ PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =\r
+ (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");\r
+ if (pSHGetSpecialFolderPath)\r
+ (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);\r
+ FreeModule(hShell32);\r
+ }\r
+\r
+ // Backup option\r
+ if (pszPath[0] == '\0')\r
+ {\r
+ if (nFolder == CSIDL_STARTUP)\r
+ {\r
+ strcpy(pszPath, getenv("USERPROFILE"));\r
+ strcat(pszPath, "\\Start Menu\\Programs\\Startup");\r
+ }\r
+ else if (nFolder == CSIDL_APPDATA)\r
+ {\r
+ strcpy(pszPath, getenv("APPDATA"));\r
+ }\r
+ }\r
+\r
+ return pszPath;\r
+}\r
+#endif\r
+\r
+string GetDefaultDataDir()\r
+{\r
+ // Windows: C:\Documents and Settings\username\Application Data\Appname\r
+ // Mac: ~/Library/Application Support/Appname\r
+ // Unix: ~/.appname\r
+#ifdef __WXMSW__\r
+ // Windows\r
+ return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin";\r
+#else\r
+ char* pszHome = getenv("HOME");\r
+ if (pszHome == NULL || strlen(pszHome) == 0)\r
+ pszHome = (char*)"/";\r
+ string strHome = pszHome;\r
+ if (strHome[strHome.size()-1] != '/')\r
+ strHome += '/';\r
+#ifdef __WXOSX__\r
+ // Mac\r
+ strHome += "Library/Application Support/";\r
+ _mkdir(strHome.c_str());\r
+ return strHome + "Bitcoin";\r
+#else\r
+ // Unix\r
+ return strHome + ".bitcoin";\r
+#endif\r
+#endif\r
+}\r
+\r
void GetDataDir(char* pszDir)\r
{\r
// pszDir must be at least MAX_PATH length.\r
{\r
// This can be called during exceptions by printf, so we cache the\r
// value so we don't have to do memory allocations after that.\r
- // wxStandardPaths::GetUserDataDir\r
- // Return the directory for the user-dependent application data files:\r
- // Unix: ~/.appname\r
- // Windows: C:\Documents and Settings\username\Application Data\appname\r
- // Mac: ~/Library/Application Support/appname\r
static char pszCachedDir[MAX_PATH];\r
if (pszCachedDir[0] == 0)\r
{\r
const char* wxGetTranslation(const char* psz);\r
int GetFilesize(FILE* file);\r
void GetDataDir(char* pszDirRet);\r
+#ifdef __WXMSW__\r
+string MyGetSpecialFolderPath(int nFolder, bool fCreate);\r
+#endif\r
string GetDataDir();\r
void ShrinkDebugFile();\r
uint64 GetRand(uint64 nMax);\r
bool TryEnter() { return TryEnterCriticalSection(&cs); }\r
#else\r
protected:\r
- wxMutex mutex;\r
+ boost::interprocess::interprocess_recursive_mutex mutex;\r
public:\r
- explicit CCriticalSection() : mutex(wxMUTEX_RECURSIVE) { }\r
+ explicit CCriticalSection() { }\r
~CCriticalSection() { }\r
- void Enter() { mutex.Lock(); }\r
- void Leave() { mutex.Unlock(); }\r
- bool TryEnter() { return mutex.TryLock() == wxMUTEX_NO_ERROR; }\r
+ void Enter() { mutex.lock(); }\r
+ void Leave() { mutex.unlock(); }\r
+ bool TryEnter() { return mutex.try_lock(); }\r
#endif\r
public:\r
const char* pszFile;\r
\r
inline int64 GetTimeMillis()\r
{\r
- return wxGetLocalTimeMillis().GetValue();\r
+ return (posix_time::ptime(posix_time::microsec_clock::universal_time()) -\r
+ posix_time::ptime(gregorian::date(1970,1,1))).total_milliseconds();\r
}\r
\r
inline string DateTimeStrFormat(const char* pszFormat, int64 nTime)\r
return hthread;\r
}\r
\r
-#define THREAD_PRIORITY_LOWEST PRIO_MIN\r
+#define THREAD_PRIORITY_LOWEST PRIO_MAX\r
#define THREAD_PRIORITY_BELOW_NORMAL 2\r
#define THREAD_PRIORITY_NORMAL 0\r
#define THREAD_PRIORITY_ABOVE_NORMAL 0\r