|
From: <arn...@us...> - 2006-09-04 14:04:11
|
Revision: 644
http://svn.sourceforge.net/dcplusplus/?rev=644&view=rev
Author: arnetheduck
Date: 2006-09-04 07:02:22 -0700 (Mon, 04 Sep 2006)
Log Message:
-----------
Configuration fixes, back to unicows
Modified Paths:
--------------
dcplusplus/trunk/DCPlusPlus.nsi
dcplusplus/trunk/changelog.txt
dcplusplus/trunk/client/AdcHub.cpp
dcplusplus/trunk/client/File.h
dcplusplus/trunk/client/SettingsManager.cpp
dcplusplus/trunk/client/ShareManager.cpp
dcplusplus/trunk/client/Util.cpp
dcplusplus/trunk/client/Util.h
dcplusplus/trunk/client/config.h
dcplusplus/trunk/windows/AppearancePage.cpp
dcplusplus/trunk/windows/MainFrm.cpp
dcplusplus/trunk/windows/WinUtil.cpp
dcplusplus/trunk/windows/WinUtil.h
dcplusplus/trunk/windows/main.cpp
Added Paths:
-----------
dcplusplus/trunk/dcppboot.xml
dcplusplus/trunk/release.cmd
dcplusplus/trunk/unicows.dll
dcplusplus/trunk/unicows.pdb
Removed Paths:
-------------
dcplusplus/trunk/opencow.dll
Modified: dcplusplus/trunk/DCPlusPlus.nsi
===================================================================
--- dcplusplus/trunk/DCPlusPlus.nsi 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/DCPlusPlus.nsi 2006-09-04 14:02:22 UTC (rev 644)
@@ -56,15 +56,15 @@
; Put file there
File "/oname=DCPlusPlus.exe" "App\DCPlusPlus.exe"
File "/oname=DCPlusPlus.chm" "App\DCPlusPlus.chm"
- File "/oname=opencow.dll" "app\opencow.dll"
+ File "unicows.dll"
File "ChangeLog.txt"
File "Example.xml"
File "License.txt"
File "License-GeoIP.txt"
File "Magnet.exe"
- ; Remove unicows so that opencow will be used instead
- Delete "$INSTDIR\unicows.dll"
- Delete "$INSTDIR\unicows.pdb"
+ File "dcppboot.xml"
+ ; Remove opencow just in case we're upgrading
+ Delete "$INSTDIR\opencow.dll"
; Get DCPlusplus version we just installed and store in $1
Push "DCPlusPlus.exe"
@@ -97,6 +97,7 @@
Section "Debug Information (recommended, helps finding bugs)"
SetOutPath $INSTDIR
File "/oname=DCPlusPlus.pdb" "App\DCPlusPlus.pdb"
+ File "unicows.pdb"
File "dbghelp.dll"
SectionEnd
@@ -127,7 +128,8 @@
Delete "$INSTDIR\License-GeoIP.txt"
Delete "$INSTDIR\License.txt"
Delete "$INSTDIR\ChangeLog.txt"
- Delete "$INSTDIR\opencow.dll"
+ Delete "$INSTDIR\unicows.dll"
+ Delete "$INSTDIR\unicows.pdb"
Delete "$INSTDIR\Example.xml"
Delete "$INSTDIR\Magnet.exe"
Delete "$INSTDIR\GeoIPCountryWhois.csv"
Modified: dcplusplus/trunk/changelog.txt
===================================================================
--- dcplusplus/trunk/changelog.txt 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/changelog.txt 2006-09-04 14:02:22 UTC (rev 644)
@@ -15,6 +15,8 @@
* [bug 1029] Fixed BSD compile issue (thanks steven sheehy)
* [bug 1031] Fixed a crash after closing hub window (thanks bigmuscle/pothead)
* [bug 1032] Fixed certificates help (thanks pothead)
+* Added possibility to store configuration files in separate directory
+* Switched back to unicows for w9x users, opencow was missing too many functions
-- 0.694 2006-07-10 --
* Fixed crash in certificates page
Modified: dcplusplus/trunk/client/AdcHub.cpp
===================================================================
--- dcplusplus/trunk/client/AdcHub.cpp 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/client/AdcHub.cpp 2006-09-04 14:02:22 UTC (rev 644)
@@ -343,7 +343,7 @@
if(!u)
return;
- int severity = Util::toInt(c.getParam(0).substr(0, 1));
+ //int severity = Util::toInt(c.getParam(0).substr(0, 1));
int code = Util::toInt(c.getParam(0).substr(1));
if(code == AdcCommand::ERROR_BAD_PASSWORD) {
Modified: dcplusplus/trunk/client/File.h
===================================================================
--- dcplusplus/trunk/client/File.h 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/client/File.h 2006-09-04 14:02:22 UTC (rev 644)
@@ -222,6 +222,10 @@
}
}
+ static bool isAbsolute(const string& path) {
+ return path.size() > 2 && (path[1] == ':' || path[0] == '/' || path[0] == '\\');
+ }
+
#else // _WIN32
enum {
@@ -395,6 +399,9 @@
}
}
+ static bool isAbsolute(const string& path) {
+ return path.size() > 1 && path[0] = '/';
+ }
#endif // _WIN32
Modified: dcplusplus/trunk/client/SettingsManager.cpp
===================================================================
--- dcplusplus/trunk/client/SettingsManager.cpp 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/client/SettingsManager.cpp 2006-09-04 14:02:22 UTC (rev 644)
@@ -84,6 +84,7 @@
SettingsManager::SettingsManager()
{
+
connectionSpeeds.push_back("0.005");
connectionSpeeds.push_back("0.01");
connectionSpeeds.push_back("0.02");
@@ -111,8 +112,8 @@
int64Settings[k] = 0;
}
- setDefault(DOWNLOAD_DIRECTORY, Util::getConfigPath() + "Downloads" PATH_SEPARATOR_STR);
- setDefault(TEMP_DOWNLOAD_DIRECTORY, Util::getConfigPath() + "Incomplete" PATH_SEPARATOR_STR);
+ setDefault(DOWNLOAD_DIRECTORY, Util::getConfigPath() + "Downloads" PATH_SEPARATOR_STR);
+ setDefault(TEMP_DOWNLOAD_DIRECTORY, Util::getConfigPath() + "Incomplete" PATH_SEPARATOR_STR);
setDefault(SLOTS, 1);
setDefault(TCP_PORT, 0);
setDefault(UDP_PORT, 0);
@@ -137,7 +138,7 @@
setDefault(HUBLIST_SERVERS, "http://www.hublist.org/PublicHubList.xml.bz2;http://dc.selwerd.nl/hublist.xml.bz2");
setDefault(DOWNLOAD_SLOTS, 3);
setDefault(MAX_DOWNLOAD_SPEED, 0);
- setDefault(LOG_DIRECTORY, Util::getConfigPath() + "Logs" PATH_SEPARATOR_STR);
+ setDefault(LOG_DIRECTORY, Util::getConfigPath() + "Logs" PATH_SEPARATOR_STR);
setDefault(LOG_UPLOADS, false);
setDefault(LOG_DOWNLOADS, false);
setDefault(LOG_PRIVATE_CHAT, false);
@@ -248,8 +249,8 @@
setDefault(OPEN_WAITING_USERS, false);
setDefault(OPEN_SYSTEM_LOG, true);
setDefault(TLS_TRUSTED_CERTIFICATES_PATH, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR);
- setDefault(TLS_PRIVATE_KEY_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.key");
- setDefault(TLS_CERTIFICATE_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.crt");
+ setDefault(TLS_PRIVATE_KEY_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.key");
+ setDefault(TLS_CERTIFICATE_FILE, Util::getConfigPath() + "Certificates" PATH_SEPARATOR_STR "client.crt");
setDefault(BOLD_FINISHED_DOWNLOADS, true);
setDefault(BOLD_FINISHED_UPLOADS, true);
setDefault(BOLD_QUEUE, true);
Modified: dcplusplus/trunk/client/ShareManager.cpp
===================================================================
--- dcplusplus/trunk/client/ShareManager.cpp 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/client/ShareManager.cpp 2006-09-04 14:02:22 UTC (rev 644)
@@ -74,14 +74,14 @@
if(hFind != INVALID_HANDLE_VALUE) {
do {
if(_tcslen(data.cFileName) > 13) // length of "files.xml.bz2"
- File::deleteFile(Util::getAppPath() + Text::fromT(data.cFileName));
+ File::deleteFile(Util::getConfigPath() + Text::fromT(data.cFileName));
} while(FindNextFile(hFind, &data));
FindClose(hFind);
}
#else
- DIR* dir = opendir(Util::getAppName().c_str());
+ DIR* dir = opendir(Util::getConfigPath().c_str());
if (dir) {
while (struct dirent* ent = readdir(dir)) {
if (fnmatch("files*.xml.bz2", ent->d_name, 0) == 0) {
Modified: dcplusplus/trunk/client/Util.cpp
===================================================================
--- dcplusplus/trunk/client/Util.cpp 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/client/Util.cpp 2006-09-04 14:02:22 UTC (rev 644)
@@ -27,8 +27,12 @@
#include "StringTokenizer.h"
#include "SettingsManager.h"
#include "version.h"
+#include "File.h"
+#include "SimpleXML.h"
-#ifndef _WIN32
+#ifdef _WIN32
+#include <ShlObj.h>
+#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -56,7 +60,9 @@
time_t Util::awayTime;
Util::CountryList Util::countries;
-string Util::appPath;
+string Util::configPath;
+string Util::systemPath;
+string Util::dataPath;
static void sgenrand(unsigned long seed);
@@ -79,22 +85,49 @@
#ifdef _WIN32
TCHAR buf[MAX_PATH+1];
- GetModuleFileName(NULL, buf, MAX_PATH);
- appPath = Text::fromT(buf);
- appPath.erase(appPath.rfind('\\') + 1);
+ ::GetModuleFileName(NULL, buf, MAX_PATH);
+ // System config path is DC++ executable path...
+ systemPath = Util::getFilePath(Text::fromT(buf));
+ configPath = systemPath;
+ dataPath = systemPath;
+#else
+ systemPath = "/etc/";
+ char* home = getenv("HOME");
+ configPath = home ? home + string("/.dc++/") : "/tmp/";
+#error dataPath = wherever linux should fetch data
+#endif
+
+ // Load boot settings
+ try {
+ SimpleXML boot;
+ boot.fromXML(File(systemPath + "dcppboot.xml", File::READ, File::OPEN).read());
+ boot.stepIn();
+
+ if(boot.findChild("ConfigPath")) {
+ StringMap params;
+#ifdef _WIN32
+ TCHAR path[MAX_PATH];
+
+ params["APPDATA"] = Text::fromT((::SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path), path));
+ params["PERSONAL"] = Text::fromT((::SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path), path));
+ configPath = Util::formatParams(boot.getChildData(), params, false);
+#else
+#error TODO - make env vars available perhaps?
+#endif
+ }
+ } catch(const Exception& ) {
+ // Unable to load boot settings...
+ }
+
+ if(!File::isAbsolute(configPath)) {
+ configPath = systemPath + configPath;
+ }
+
#if _MSC_VER == 1400
_set_invalid_parameter_handler(reinterpret_cast<_invalid_parameter_handler>(invalidParameterHandler));
#endif
-#else // _WIN32
- char* home = getenv("HOME");
- if (home) {
- appPath = Text::fromT(home);
- appPath += "/.dc++/";
- }
-#endif // _WIN32
-
try {
// This product includes GeoIP data created by MaxMind, available from http://maxmind.com/
// Updates at http://www.maxmind.com/app/geoip_country
@@ -138,42 +171,7 @@
}
}
-string Util::getConfigPath() {
#ifdef _WIN32
- return getAppPath();
-#else
- char* home = getenv("HOME");
- if (home) {
-#ifdef __APPLE__
-/// @todo Verify this for apple?
- return string(home) + "/Library/Application Support/Mac DC++/";
-#else
- return string(home) + "/.dc++/";
-#endif // __APPLE__
- }
- return emptyString;
-#endif // _WIN32
-}
-
-string Util::getDataPath() {
-#ifdef _WIN32
- return getAppPath();
-#else
- // This probably ought to be /usr/share/*...
- char* home = getenv("HOME");
- if (home) {
-#ifdef __APPLE__
- /// @todo Verify this for apple?
- return string(home) + "/Library/Application Support/Mac DC++/";
-#else
- return string(home) + "/.dc++/";
-#endif // __APPLE__
- }
- return emptyString;
-#endif // _WIN32
-}
-
-#ifdef _WIN32
static const char badChars[] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
@@ -925,4 +923,45 @@
i++;
}
return toDOS(tmp);
-}
\ No newline at end of file
+}
+
+string Util::getTimeString() {
+ char buf[64];
+ time_t _tt;
+ time(&_tt);
+ tm* _tm = localtime(&_tt);
+ if(_tm == NULL) {
+ strcpy(buf, "xx:xx:xx");
+ } else {
+ strftime(buf, 64, "%X", _tm);
+ }
+ return buf;
+}
+
+string Util::toAdcFile(const string& file) {
+ if(file == "files.xml.bz2" || file == "MyList.DcLst")
+ return file;
+
+ string ret;
+ ret.reserve(file.length() + 1);
+ ret += '/';
+ ret += file;
+ for(string::size_type i = 0; i < ret.length(); ++i) {
+ if(ret[i] == '\\') {
+ ret[i] = '/';
+ }
+ }
+ return ret;
+}
+string Util::toNmdcFile(const string& file) {
+ if(file.empty())
+ return Util::emptyString;
+
+ string ret(file.substr(1));
+ for(string::size_type i = 0; i < ret.length(); ++i) {
+ if(ret[i] == '/') {
+ ret[i] = '\\';
+ }
+ }
+ return ret;
+}
Modified: dcplusplus/trunk/client/Util.h
===================================================================
--- dcplusplus/trunk/client/Util.h 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/client/Util.h 2006-09-04 14:02:22 UTC (rev 644)
@@ -144,56 +144,26 @@
static void initialize();
- /**
- * Get the path to the application executable.
- * This is mainly intended for use on Windows.
- *
- * @return Path to executable file.
- */
- static string getAppPath() { return appPath; }
-
- static string getAppName() {
-#ifdef _WIN32
- TCHAR buf[MAX_PATH+1];
- DWORD x = GetModuleFileName(NULL, buf, MAX_PATH);
- return Text::wideToUtf8(wstring(buf, x));
-#else // _WIN32
- char buf[PATH_MAX + 1];
- int n;
- n = readlink("/proc/self/exe", buf, PATH_MAX);
- if (n == -1) {
- return emptyString;
- }
- buf[n] = '\0';
- return string(buf);
-#endif // _WIN32
- }
-
/** Path of temporary storage */
static string getTempPath() {
#ifdef _WIN32
TCHAR buf[MAX_PATH + 1];
DWORD x = GetTempPath(MAX_PATH, buf);
- return Text::wideToUtf8(wstring(buf, x));
+ return Text::fromT(tstring(buf, x));
#else
return "/tmp/";
#endif
}
- /** Path of resource directory */
- static string getDataPath();
-
/** Path of configuration files */
- static string getConfigPath();
+ static const string& getConfigPath() { return configPath; }
+ static const string& getDataPath() { return dataPath; }
+ static const string& getSystemPath() { return systemPath; }
/** Path of file lists */
- static string getListPath() {
- return getConfigPath() + "FileLists" PATH_SEPARATOR_STR;
- }
+ static string getListPath() { return getConfigPath() + "FileLists" PATH_SEPARATOR_STR; }
/** Notepad filename */
- static string getNotepadFile() {
- return getConfigPath() + "Notepad.txt";
- }
+ static string getNotepadFile() { return getConfigPath() + "Notepad.txt"; }
static string translateError(int aError) {
#ifdef _WIN32
@@ -270,55 +240,15 @@
static string validateFileName(string aFile);
static string cleanPathChars(string aNick);
- static string formatBytes(const string& aString) {
- return formatBytes(toInt64(aString));
- }
-
+ static string formatBytes(const string& aString) { return formatBytes(toInt64(aString)); }
static string formatMessage(const string& nick, const string& message);
static string toDOS(const string& tmp);
static string getShortTimeString(time_t t = time(NULL) );
- static string getTimeString() {
- char buf[64];
- time_t _tt;
- time(&_tt);
- tm* _tm = localtime(&_tt);
- if(_tm == NULL) {
- strcpy(buf, "xx:xx:xx");
- } else {
- strftime(buf, 64, "%X", _tm);
- }
- return buf;
- }
-
- static string toAdcFile(const string& file) {
- if(file == "files.xml.bz2" || file == "MyList.DcLst")
- return file;
-
- string ret;
- ret.reserve(file.length() + 1);
- ret += '/';
- ret += file;
- for(string::size_type i = 0; i < ret.length(); ++i) {
- if(ret[i] == '\\') {
- ret[i] = '/';
- }
- }
- return ret;
- }
- static string toNmdcFile(const string& file) {
- if(file.empty())
- return Util::emptyString;
-
- string ret(file.substr(1));
- for(string::size_type i = 0; i < ret.length(); ++i) {
- if(ret[i] == '/') {
- ret[i] = '\\';
- }
- }
- return ret;
- }
+ static string getTimeString();
+ static string toAdcFile(const string& file);
+ static string toNmdcFile(const string& file);
static string formatBytes(int64_t aBytes);
@@ -399,20 +329,12 @@
}
static string toString(long long val) {
char buf[32];
-#ifdef _MSC_VER
- snprintf(buf, sizeof(buf), "%I64d", val);
-#else
- snprintf(buf, sizeof(buf), "%lld", val);
-#endif
+ snprintf(buf, sizeof(buf), I64_FMT, val);
return buf;
}
static string toString(unsigned long long val) {
char buf[32];
-#ifdef _MSC_VER
- snprintf(buf, sizeof(buf), "%I64u", val);
-#else
- snprintf(buf, sizeof(buf), "%llu", val);
-#endif
+ snprintf(buf, sizeof(buf), U64_FMT, val);
return buf;
}
static string toString(double val) {
@@ -511,8 +433,13 @@
static double randd() { return ((double)rand()) / ((double)0xffffffff); }
private:
- static string appPath;
+ /** Per-user configuration */
+ static string configPath;
+ /** Global configuration */
+ static string systemPath;
+ /** Various resources (help files etc) */
static string dataPath;
+
static bool away;
static bool manualAway;
static string awayMsg;
Modified: dcplusplus/trunk/client/config.h
===================================================================
--- dcplusplus/trunk/client/config.h 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/client/config.h 2006-09-04 14:02:22 UTC (rev 644)
@@ -80,14 +80,18 @@
#define _LL(x) x##ll
#define _ULL(x) x##ull
#define I64_FMT "%I64d"
+#define U64_FMT "%I64d"
+
#elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8
#define _LL(x) x##l
#define _ULL(x) x##ul
#define I64_FMT "%ld"
+#define U64_FMT "%ld"
#else
#define _LL(x) x##ll
#define _ULL(x) x##ull
#define I64_FMT "%lld"
+#define U64_FMT "%lld"
#endif
#ifdef _WIN32
Added: dcplusplus/trunk/dcppboot.xml
===================================================================
--- dcplusplus/trunk/dcppboot.xml (rev 0)
+++ dcplusplus/trunk/dcppboot.xml 2006-09-04 14:02:22 UTC (rev 644)
@@ -0,0 +1,16 @@
+<Boot>
+ <!--
+ ConfigPath specifies where settings, queue and other runtime data should be saved.
+ Relative paths are relative to the DC++ executable.
+ You may use the following variables, which are interpreted on a per-user basis:
+
+ %[APPDATA] - Application data, typically c:\documents and settings\<username>\Application Data\
+ %[PERSONAL] - My documents
+
+ All % variables from strftime with the current time:
+ http://msdn.microsoft.com/library/en-us/vclib/html/_crt_strftime.2c_.wcsftime.asp
+
+ -->
+
+ <ConfigPath>.\</ConfigPath>
+</Boot>
Deleted: dcplusplus/trunk/opencow.dll
===================================================================
(Binary files differ)
Added: dcplusplus/trunk/release.cmd
===================================================================
--- dcplusplus/trunk/release.cmd (rev 0)
+++ dcplusplus/trunk/release.cmd 2006-09-04 14:02:22 UTC (rev 644)
@@ -0,0 +1,14 @@
+copy /b app\dcplusplus.exe .
+copy /b app\dcplusplus.chm .
+copy /b app\dcplusplus.pdb .
+"c:\program files\WinRAR\WinRAR" a -ep -m5 DCPlusPlus-%1.zip dcppboot.xml unicows.dll unicows.pdb dcplusplus.chm dcplusplus.exe dcplusplus.pdb dbghelp.dll changelog.txt Example.xml License.txt GeoIPCountryWhois.csv
+"c:\program files\WinRAR\WinRAR" a -m5 DCPlusPlus-%1-src.zip dcppboot.xml bootstrap makedefs.py Makefile.am configure.ac libunicows.lib unicows.dll unicows.pdb yassl\* yassl\certs\* yassl\include\openssl\* yassl\mySTL\* yassl\src\* yassl\include\* yassl\taocrypt\* yassl\taocrypt\src\* yassl\taocrypt\include\* stlport\.keep wtl\.keep help\* zlib\* bzip2\* client\* MakeDefs\* res\* windows\* changelog.txt Example.xml License.txt compile.txt GeoIPCountryWhois.csv *.dsp *.vcproj *.dsw *.sln *.rc extensions.txt doxyfile dcplusplus.nsi
+del dcplusplus.exe
+del dcplusplus.pdb
+del dcplusplus.chm
+makensis dcplusplus.nsi
+move dcplusplus.exe DCPlusPlus-%1.exe
+
+svn status
+pause
+svn copy . https://svn.sourceforge.net/svnroot/dcplusplus/dcplusplus/tags/dcplusplus-%1 -m "%1"
Added: dcplusplus/trunk/unicows.dll
===================================================================
(Binary files differ)
Property changes on: dcplusplus/trunk/unicows.dll
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: dcplusplus/trunk/unicows.pdb
===================================================================
(Binary files differ)
Property changes on: dcplusplus/trunk/unicows.pdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: dcplusplus/trunk/windows/AppearancePage.cpp
===================================================================
--- dcplusplus/trunk/windows/AppearancePage.cpp 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/windows/AppearancePage.cpp 2006-09-04 14:02:22 UTC (rev 644)
@@ -82,7 +82,7 @@
GetDlgItemText(IDC_LANGUAGE, buf, MAX_PATH);
tstring x = buf;
- if(WinUtil::browseFile(x, m_hWnd, false, Text::toT(Util::getAppPath()), types) == IDOK) {
+ if(WinUtil::browseFile(x, m_hWnd, false, Text::toT(Util::getDataPath()), types) == IDOK) {
SetDlgItemText(IDC_LANGUAGE, x.c_str());
}
return 0;
Modified: dcplusplus/trunk/windows/MainFrm.cpp
===================================================================
--- dcplusplus/trunk/windows/MainFrm.cpp 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/windows/MainFrm.cpp 2006-09-04 14:02:22 UTC (rev 644)
@@ -515,7 +515,7 @@
LRESULT MainFrame::onCopyData(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) {
tstring cmdLine = (LPCTSTR) (((COPYDATASTRUCT *)lParam)->lpData);
- parseCommandLine(Text::toT(Util::getAppName() + " ") + cmdLine);
+ parseCommandLine(Text::toT(WinUtil::getAppName() + " ") + cmdLine);
return true;
}
Modified: dcplusplus/trunk/windows/WinUtil.cpp
===================================================================
--- dcplusplus/trunk/windows/WinUtil.cpp 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/windows/WinUtil.cpp 2006-09-04 14:02:22 UTC (rev 644)
@@ -693,7 +693,7 @@
void WinUtil::registerDchubHandler() {
HKEY hk;
TCHAR Buf[512];
- tstring app = _T("\"") + Text::toT(Util::getAppName()) + _T("\" %1");
+ tstring app = _T("\"") + Text::toT(getAppName()) + _T("\" %1");
Buf[0] = 0;
if(::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("dchub\\Shell\\Open\\Command"), 0, KEY_WRITE | KEY_READ, &hk) == ERROR_SUCCESS) {
@@ -719,7 +719,7 @@
::RegCloseKey(hk);
::RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("dchub\\DefaultIcon"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL);
- app = Text::toT(Util::getAppName());
+ app = Text::toT(getAppName());
::RegSetValueEx(hk, _T(""), 0, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR) * (app.length() + 1));
::RegCloseKey(hk);
}
@@ -732,7 +732,7 @@
void WinUtil::registerADChubHandler() {
HKEY hk;
TCHAR Buf[512];
- tstring app = _T("\"") + Text::toT(Util::getAppName()) + _T("\" %1");
+ tstring app = _T("\"") + Text::toT(getAppName()) + _T("\" %1");
Buf[0] = 0;
if(::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("adc\\Shell\\Open\\Command"), 0, KEY_WRITE | KEY_READ, &hk) == ERROR_SUCCESS) {
@@ -758,7 +758,7 @@
::RegCloseKey(hk);
::RegCreateKeyEx(HKEY_CLASSES_ROOT, _T("adc\\DefaultIcon"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hk, NULL);
- app = Text::toT(Util::getAppName());
+ app = Text::toT(getAppName());
::RegSetValueEx(hk, _T(""), 0, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR) * (app.length() + 1));
::RegCloseKey(hk);
}
@@ -796,10 +796,10 @@
}
// check for the existence of magnet.exe
if(File::getSize(Text::fromT(magnetExe)) == -1) {
- magnetExe = Text::toT(Util::getAppPath() + "magnet.exe");
+ magnetExe = Text::toT(Util::getDataPath() + "magnet.exe");
if(File::getSize(Text::fromT(magnetExe)) == -1) {
// gracefully fall back to registering DC++ to handle magnets
- magnetExe = Text::toT(Util::getAppName());
+ magnetExe = Text::toT(getAppName());
haveMagnet = false;
} else {
// set Magnet\Location
@@ -839,10 +839,10 @@
::RegSetValueEx(hk, NULL, NULL, REG_SZ, (LPBYTE)CTSTRING(MAGNET_HANDLER_ROOT), sizeof(TCHAR) * (TSTRING(MAGNET_HANDLER_ROOT).size()+1));
::RegSetValueEx(hk, _T("Description"), NULL, REG_SZ, (LPBYTE)CTSTRING(MAGNET_HANDLER_DESC), sizeof(TCHAR) * (STRING(MAGNET_HANDLER_DESC).size()+1));
// set ShellExecute
- tstring app = Text::toT("\"" + Util::getAppName() + "\" %URL");
+ tstring app = Text::toT("\"" + getAppName() + "\" %URL");
::RegSetValueEx(hk, _T("ShellExecute"), NULL, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR) * (app.length()+1));
// set DefaultIcon
- app = Text::toT('"' + Util::getAppName() + '"');
+ app = Text::toT('"' + getAppName() + '"');
::RegSetValueEx(hk, _T("DefaultIcon"), NULL, REG_SZ, (LPBYTE)app.c_str(), sizeof(TCHAR)*(app.length()+1));
::RegCloseKey(hk);
Modified: dcplusplus/trunk/windows/WinUtil.h
===================================================================
--- dcplusplus/trunk/windows/WinUtil.h 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/windows/WinUtil.h 2006-09-04 14:02:22 UTC (rev 644)
@@ -195,6 +195,12 @@
static void init(HWND hWnd);
static void uninit();
+ static string getAppName() {
+ TCHAR buf[MAX_PATH+1];
+ DWORD x = GetModuleFileName(NULL, buf, MAX_PATH);
+ return Text::fromT(tstring(buf, x));
+ }
+
static void decodeFont(const tstring& setting, LOGFONT &dest);
static void addInitalDir(const User::Ptr& user, string dir) {
@@ -277,7 +283,7 @@
static tstring encodeFont(LOGFONT const& font);
static tstring getHelpFile() {
- return Text::toT(Util::getAppPath() + "DCPlusPlus.chm");
+ return Text::toT(Util::getDataPath() + "DCPlusPlus.chm");
}
static bool browseFile(tstring& target, HWND owner = NULL, bool save = true, const tstring& initialDir = Util::emptyStringW, const TCHAR* types = NULL, const TCHAR* defExt = NULL);
Modified: dcplusplus/trunk/windows/main.cpp
===================================================================
--- dcplusplus/trunk/windows/main.cpp 2006-08-31 07:46:12 UTC (rev 643)
+++ dcplusplus/trunk/windows/main.cpp 2006-09-04 14:02:22 UTC (rev 644)
@@ -67,7 +67,7 @@
#endif
// The release version loads the dll and pdb:s here...
- EXTENDEDTRACEINITIALIZE( Util::getAppPath().c_str() );
+ EXTENDEDTRACEINITIALIZE( Util::getDataPath().c_str() );
#endif
@@ -76,7 +76,7 @@
firstException = false;
}
- if(File::getSize(Util::getAppPath() + "DCPlusPlus.pdb") == -1) {
+ if(File::getSize(Util::getDataPath() + "DCPlusPlus.pdb") == -1) {
// No debug symbols, we're not interested...
::MessageBox(WinUtil::mainWnd, _T("DC++ has crashed and you don't have debug symbols installed. Hence, I can't find out why it crashed, so don't report this as a bug unless you find a solution..."), _T("DC++ has crashed"), MB_OK);
#ifndef _DEBUG
@@ -315,8 +315,8 @@
// For SHBrowseForFolder, UPnP
HRESULT hRes = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
#ifdef _DEBUG
- EXTENDEDTRACEINITIALIZE( Util::getAppPath().c_str() );
- //File::deleteFile(Util::getAppPath() + "exceptioninfo.txt");
+ EXTENDEDTRACEINITIALIZE( Util::getDataPath().c_str() );
+ //File::deleteFile(Util::getDataPath() + "exceptioninfo.txt");
#endif
SetUnhandledExceptionFilter(&DCUnhandledExceptionFilter);
@@ -330,7 +330,7 @@
ATLASSERT(SUCCEEDED(hRes));
try {
- File f(Util::getAppName(), File::READ, File::OPEN);
+ File f(WinUtil::getAppName(), File::READ, File::OPEN);
TigerTree tth(TigerTree::calcBlockSize(f.getSize(), 1));
size_t n = 0;
size_t n2 = DEBUG_BUFSIZE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|