summaryrefslogtreecommitdiff
path: root/updater/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'updater/options.cpp')
-rw-r--r--updater/options.cpp56
1 files changed, 25 insertions, 31 deletions
diff --git a/updater/options.cpp b/updater/options.cpp
index 5352bc9..a505345 100644
--- a/updater/options.cpp
+++ b/updater/options.cpp
@@ -303,11 +303,11 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
case 1:
if(((int)lvi.lParam & 4) == 4) {
- ((NMLVDISPINFO *)lParam)->item.pszText = (((int)lvi.lParam & 2) == 2 ? TranslateT("FORCED") : TranslateT("N/A"));
- ((NMLVDISPINFO *)lParam)->item.cchTextMax = _tcslen(((NMLVDISPINFO *)lParam)->item.pszText);
+ ((NMLVDISPINFO *)lParam)->item.pszText = ((lvi.lParam & 2) == 2 ? TranslateT("FORCED") : TranslateT("N/A"));
+ ((NMLVDISPINFO *)lParam)->item.cchTextMax = (int)_tcslen(((NMLVDISPINFO *)lParam)->item.pszText);
} else {
- ((NMLVDISPINFO *)lParam)->item.pszText = (((int)lvi.lParam & 2) == 2 ? TranslateT("TRUE") : TranslateT("FALSE"));
- ((NMLVDISPINFO *)lParam)->item.cchTextMax = _tcslen(((NMLVDISPINFO *)lParam)->item.pszText);
+ ((NMLVDISPINFO *)lParam)->item.pszText = ((lvi.lParam & 2) == 2 ? TranslateT("TRUE") : TranslateT("FALSE"));
+ ((NMLVDISPINFO *)lParam)->item.cchTextMax = (int)_tcslen(((NMLVDISPINFO *)lParam)->item.pszText);
}
break;
}
@@ -375,9 +375,10 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return FALSE;
}
-static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
-
- switch ( msg ) {
+static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch ( msg )
+ {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
@@ -454,13 +455,10 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int OptInit(WPARAM wParam,LPARAM lParam)
{
-#ifndef OPTIONPAGE_OLD_SIZE2
-#define OPTIONPAGE_OLD_SIZE2 60
-#endif
DWORD mirVir = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0);
OPTIONSDIALOGPAGE odp = { 0 };
- odp.cbSize = (mirVir >= 0x00060000 ? sizeof(odp) : OPTIONPAGE_OLD_SIZE2);
+ odp.cbSize = sizeof(odp);
odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
odp.position = -790000000;
odp.hInstance = hInst;
@@ -582,14 +580,11 @@ void LoadOptions() {
return;
}
- TCHAR mir_path[MAX_PATH];
- GetModuleFileName(0, mir_path, MAX_PATH);
- TCHAR *p = _tcsrchr(mir_path, _T('\\'));
- if(p) *p = 0;
- else {
- p = _tcsrchr(mir_path, _T('/'));
- if(p) *p = 0;
- }
+ REPLACEVARSDATA dat = {0};
+ dat.cbSize = sizeof(dat);
+ dat.dwFlags = RVF_TCHAR;
+
+ TCHAR* mir_path = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_userdata%"), (LPARAM)&dat);
DBVARIANT dbv;
if(!DBGetString(0, MODULE, "BackupFolder", &dbv)) {
@@ -607,7 +602,7 @@ void LoadOptions() {
_tcscat(options.backup_folder, _T("\\Backups"));
}
- if(!DBGetString(0, MODULE, "DataFolder", &dbv)) {
+ if(!DBGetString(0, MODULE, " DataFolder", &dbv)) {
if(_tcslen(dbv.ptszVal) >= 2 && dbv.ptszVal[1] == _T(':')) // detect an absolute path?
_tcsncpy(options.data_folder, dbv.ptszVal, MAX_PATH);
else {
@@ -639,6 +634,8 @@ void LoadOptions() {
_tcscpy(options.temp_folder, options.data_folder);
_tcscat(options.temp_folder, _T("\\updates"));
+
+ mir_free(mir_path);
}
void SaveOptions() {
@@ -657,38 +654,35 @@ void SaveOptions() {
DBWriteContactSettingByte(0, MODULE, "NoUnzip", (int)options.no_unzip);
DBWriteContactSettingByte(0, MODULE, "AutoDLLOnly", options.auto_dll_only ? 1 : 0);
- TCHAR mir_path[MAX_PATH];
- GetModuleFileName(0, mir_path, MAX_PATH);
- TCHAR *p = _tcsrchr(mir_path, _T('\\'));
- if(p) *p = 0;
- else {
- p = _tcsrchr(mir_path, _T('/'));
- if(p) *p = 0;
- }
+ REPLACEVARSDATA dat = {0};
+ dat.cbSize = sizeof(dat);
+ dat.dwFlags = RVF_TCHAR;
+ TCHAR* mir_path = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)_T("%miranda_userdata%"), (LPARAM)&dat);
size_t mp_len = _tcslen(mir_path);
// remove mir_path from the front of folder names, so that profile can be moved
if(_tcslen(options.backup_folder) > mp_len && _tcsncmp(options.backup_folder, mir_path, mp_len) == 0) {
- p = options.backup_folder + mp_len;
+ TCHAR *p = options.backup_folder + mp_len;
DBWriteString(0, MODULE, "BackupFolder", p);
} else {
DBWriteString(0, MODULE, "BackupFolder", options.backup_folder);
}
if(_tcslen(options.data_folder) > mp_len && _tcsncmp(options.data_folder, mir_path, mp_len) == 0) {
- p = options.data_folder + mp_len;
+ TCHAR *p = options.data_folder + mp_len;
DBWriteString(0, MODULE, "DataFolder", p);
} else {
DBWriteString(0, MODULE, "DataFolder", options.data_folder);
}
if(_tcslen(options.zip_folder) > mp_len && _tcsncmp(options.zip_folder, mir_path, mp_len) == 0) {
- p = options.zip_folder + mp_len;
+ TCHAR *p = options.zip_folder + mp_len;
DBWriteString(0, MODULE, "ZipFolder", p);
} else {
DBWriteString(0, MODULE, "ZipFolder", options.zip_folder);
}
+ mir_free(mir_path);
}