From e1294a11c3cbc725bb2379f474d7e4f3d58facdb Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 29 Nov 2006 14:28:48 +0000 Subject: removed option to change temp folder (dangerous) - no always located at /updates git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@68 4f64403b-2f21-0410-a795-97e2b3489a10 --- updater/options.cpp | 85 +++++++++++++++-------------------------------------- 1 file changed, 23 insertions(+), 62 deletions(-) (limited to 'updater/options.cpp') diff --git a/updater/options.cpp b/updater/options.cpp index 87b3fb6..f1f3077 100644 --- a/updater/options.cpp +++ b/updater/options.cpp @@ -8,7 +8,7 @@ HWND hwndOptions = 0; HANDLE hMainMenuItemRestart, hMainMenuItemUpdateAndExit; -HANDLE hTempPath = 0, hBackupPath = 0, hDataPath = 0, hArchivePath = 0; +HANDLE hBackupPath = 0, hDataPath = 0, hArchivePath = 0; void add_restart_menu_item() { CLISTMENUITEM menu = {0}; @@ -366,7 +366,6 @@ static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); - SetDlgItemText(hwndDlg, IDC_ED_UPDATES, options.temp_folder); SetDlgItemText(hwndDlg, IDC_ED_DATA, options.data_folder); SetDlgItemText(hwndDlg, IDC_ED_BACKUPS, options.backup_folder); SetDlgItemText(hwndDlg, IDC_ED_ZIPS, options.zip_folder); @@ -375,7 +374,6 @@ static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_COMMAND: if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { switch( LOWORD( wParam )) { - case IDC_ED_UPDATES: case IDC_ED_DATA: case IDC_ED_BACKUPS: case IDC_ED_ZIPS: @@ -391,7 +389,7 @@ static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM bi.hwndOwner = hwndDlg; bi.pidlRoot = 0; bi.pszDisplayName = folder_buff; - bi.lpszTitle = TranslateT("Select Updates Folder"); + bi.lpszTitle = TranslateT("Select Folder"); bi.ulFlags = 0; bi.lpfn = 0; bi.lParam = 0; @@ -402,10 +400,6 @@ static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM CoTaskMemFree((void *)pidl); switch( LOWORD( wParam )) { - case IDC_BTN_BRUPDATES: - SetDlgItemText(hwndDlg, IDC_ED_UPDATES, folder_buff); - SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); - break; case IDC_BTN_BRDATA: SetDlgItemText(hwndDlg, IDC_ED_DATA, folder_buff); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); @@ -427,17 +421,13 @@ static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return FALSE; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) { - GetDlgItemText(hwndDlg, IDC_ED_UPDATES, options.temp_folder, MAX_PATH); - - - if(!FolderIsEmpty(options.temp_folder)) { - MessageBox(hwndDlg, TranslateT("The folder you have chosen for temporary files is not empty.\nALL FILES in this folder will be REMOVED during the update process."), TranslateT("Updater Warning"), MB_ICONWARNING | MB_OK); - } - GetDlgItemText(hwndDlg, IDC_ED_DATA, options.data_folder, MAX_PATH); GetDlgItemText(hwndDlg, IDC_ED_BACKUPS, options.backup_folder, MAX_PATH); GetDlgItemText(hwndDlg, IDC_ED_ZIPS, options.zip_folder, MAX_PATH); + _tcscpy(options.temp_folder, options.data_folder); + _tcscat(options.temp_folder, _T("\\updates")); + SaveOptions(); return TRUE; @@ -512,13 +502,6 @@ int FoldersPathChanged(WPARAM wParam, LPARAM lParam) { fgd.cbSize = sizeof(fgd); fgd.nMaxPathSize = MAX_PATH; - fgd.szPathT = options.temp_folder; - CallService(MS_FOLDERS_GET_PATH, (WPARAM)hTempPath, (WPARAM)&fgd); - - if(!FolderIsEmpty(options.temp_folder)) { - MessageBox(0, TranslateT("The folder you have chosen for temporary files is not empty.\nALL FILES in this folder will be REMOVED during the update process."), TranslateT("Updater Warning"), MB_ICONWARNING | MB_OK); - } - fgd.szPathT = options.backup_folder; CallService(MS_FOLDERS_GET_PATH, (WPARAM)hBackupPath, (WPARAM)&fgd); @@ -528,6 +511,9 @@ int FoldersPathChanged(WPARAM wParam, LPARAM lParam) { fgd.szPathT = options.zip_folder; CallService(MS_FOLDERS_GET_PATH, (WPARAM)hArchivePath, (WPARAM)&fgd); + _tcscpy(options.temp_folder, options.data_folder); + _tcscat(options.temp_folder, _T("\\updates")); + return 0; } @@ -560,28 +546,22 @@ void LoadOptions() { #endif strncpy(fd.szSection, Translate("Updates"), 64); - strncpy(fd.szName, Translate("Temporary Files"), 64); - fd.szFormatT = _T(MIRANDA_PATH) _T("\\updater\\temp"); - hTempPath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); + strncpy(fd.szName, Translate("Backups"), 64); + fd.szFormatT = _T(MIRANDA_PATH) _T("\\updater\\backups"); + hBackupPath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); - if(hTempPath) { - strncpy(fd.szName, Translate("Backups"), 64); - fd.szFormatT = _T(MIRANDA_PATH) _T("\\updater\\backups"); - hBackupPath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); + strncpy(fd.szName, Translate("Data"), 64); + fd.szFormatT = _T(MIRANDA_PATH) _T("\\updater\\data"); + hDataPath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); - strncpy(fd.szName, Translate("Data"), 64); - fd.szFormatT = _T(MIRANDA_PATH) _T("\\updater\\data"); - hDataPath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); + strncpy(fd.szName, Translate("Saved Archives"), 64); + fd.szFormatT = _T(MIRANDA_PATH) _T("\\updater\\archives"); + hArchivePath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); - strncpy(fd.szName, Translate("Saved Archives"), 64); - fd.szFormatT = _T(MIRANDA_PATH) _T("\\updater\\archives"); - hArchivePath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); + HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged); + FoldersPathChanged(0, 0); - HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged); - FoldersPathChanged(0, 0); - - return; - } + return; } TCHAR mir_path[MAX_PATH]; @@ -594,21 +574,6 @@ void LoadOptions() { } DBVARIANT dbv; - if(!DBGetString(0, MODULE, "TempFolder", &dbv)) { - if(_tcslen(dbv.ptszVal) >= 2 && dbv.ptszVal[1] == _T(':')) // detect an absolute path? - _tcsncpy(options.temp_folder, dbv.ptszVal, MAX_PATH); - else { - _tcscpy(options.temp_folder, mir_path); - _tcscat(options.temp_folder, dbv.ptszVal); - } - DBFreeVariant(&dbv); - } else { - - _tcscpy(options.temp_folder, mir_path); - _tcscat(options.temp_folder, _T("\\Updater")); - _tcscat(options.temp_folder, _T("\\Temp")); - } - if(!DBGetString(0, MODULE, "BackupFolder", &dbv)) { if(_tcslen(dbv.ptszVal) >= 2 && dbv.ptszVal[1] == _T(':')) // detect an absolute path? _tcsncpy(options.backup_folder, dbv.ptszVal, MAX_PATH); @@ -653,6 +618,9 @@ void LoadOptions() { _tcscat(options.zip_folder, _T("\\Updater")); _tcscat(options.zip_folder, _T("\\Archives")); } + + _tcscpy(options.temp_folder, options.data_folder); + _tcscat(options.temp_folder, _T("\\updates")); } void SaveOptions() { @@ -682,13 +650,6 @@ void SaveOptions() { unsigned int mp_len = _tcslen(mir_path); // remove mir_path from the front of folder names, so that profile can be moved - if(_tcslen(options.temp_folder) > mp_len && _tcsncmp(options.temp_folder, mir_path, mp_len) == 0) { - p = options.temp_folder + mp_len; - DBWriteString(0, MODULE, "TempFolder", p); - } else { - DBWriteString(0, MODULE, "TempFolder", options.temp_folder); - } - if(_tcslen(options.backup_folder) > mp_len && _tcsncmp(options.backup_folder, mir_path, mp_len) == 0) { p = options.backup_folder + mp_len; DBWriteString(0, MODULE, "BackupFolder", p); -- cgit v1.2.3