From 9f78220f472a29bd96414b79fd368d0ad0de062d Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Fri, 15 Apr 2016 14:09:00 +0000 Subject: PluginUpdater: added ability to change platform. Note: old miranda*.exe you should delete manually git-svn-id: http://svn.miranda-ng.org/main/trunk@16660 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/PluginUpdater/src/DlgUpdate.cpp | 18 +++- plugins/PluginUpdater/src/Options.cpp | 152 +++++++++++++++++++++++++++++--- plugins/PluginUpdater/src/Utils.cpp | 1 + plugins/PluginUpdater/src/resource.h | 4 +- plugins/PluginUpdater/src/stdafx.h | 17 ++-- 5 files changed, 169 insertions(+), 23 deletions(-) (limited to 'plugins/PluginUpdater/src') diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 12dcbce55f..ca93241e54 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -131,6 +131,9 @@ static void ApplyUpdates(void *param) opts.bForceRedownload = false; db_unset(NULL, MODNAME, DB_SETTING_REDOWNLOAD); + opts.bChangePlatform = false; + db_unset(NULL, MODNAME, DB_SETTING_CHANGEPLATFORM); + db_set_b(NULL, MODNAME, DB_SETTING_RESTART_COUNT, 5); if (opts.bBackup) @@ -452,6 +455,9 @@ static void DlgUpdateSilent(void *param) opts.bForceRedownload = false; db_unset(NULL, MODNAME, DB_SETTING_REDOWNLOAD); + opts.bChangePlatform = false; + db_unset(NULL, MODNAME, DB_SETTING_CHANGEPLATFORM); + db_set_b(NULL, MODNAME, DB_SETTING_RESTART_COUNT, 5); db_set_b(NULL, MODNAME, DB_SETTING_NEED_RESTART, 1); @@ -622,15 +628,21 @@ static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, const TCHAR *tsz // calculate the current file's relative name and store it into tszNewName TCHAR tszNewName[MAX_PATH]; if (!CheckFileRename(ffd.cFileName, tszNewName)) { - if (level == 0) - _tcsncpy(tszNewName, ffd.cFileName, MAX_PATH); + if (level == 0) { + if (opts.bChangePlatform) { + if (!mir_tstrcmpi(ffd.cFileName, _T("miranda32.exe"))) + _tcsncpy_s(tszNewName, _T("miranda64.exe"), _TRUNCATE); + if (!mir_tstrcmpi(ffd.cFileName, _T("miranda64.exe"))) + _tcsncpy_s(tszNewName, _T("miranda32.exe"), _TRUNCATE); + } + } else mir_sntprintf(tszNewName, _T("%s\\%s"), tszFolder + cbBaseLen, ffd.cFileName); } TCHAR *ptszUrl; int MyCRC; - mir_sntprintf(tszBuf, _T("%s\\%s"), tszFolder, ffd.cFileName); + mir_sntprintf(tszBuf, _T("%s\\%s"), tszFolder, tszNewName); bool bDeleteOnly = (tszNewName[0] == 0); // this file is not marked for deletion diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index 64b2a9b2eb..ac21c2e356 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -30,7 +30,7 @@ int GetUpdateMode() if (UpdateMode == UPDATE_MODE_CUSTOM) { ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL)); if (url == NULL || !_tcslen(url)) { - // No url for custom mode, reset that setting so it will be determined automatically + // No url for custom mode, reset that setting so it will be determined automatically db_unset(NULL, MODNAME, DB_SETTING_UPDATE_MODE); UpdateMode = -1; } @@ -48,13 +48,26 @@ int GetUpdateMode() TCHAR* GetDefaultUrl() { + TCHAR url[MAX_PATH]; switch (GetUpdateMode()) { case UPDATE_MODE_STABLE: - return mir_tstrdup(_T(DEFAULT_UPDATE_URL)); + if (opts.bChangePlatform) + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL), DEFAULT_OPP_BITS); + else + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL), DEFAULT_BITS); + return mir_tstrdup(url); case UPDATE_MODE_TRUNK: - return mir_tstrdup(_T(DEFAULT_UPDATE_URL_TRUNK)); + if (opts.bChangePlatform) + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL_TRUNK), DEFAULT_OPP_BITS); + else + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL_TRUNK), DEFAULT_BITS); + return mir_tstrdup(url); case UPDATE_MODE_TRUNK_SYMBOLS: - return mir_tstrdup(_T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS)); + if (opts.bChangePlatform) + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS), DEFAULT_OPP_BITS); + else + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS), DEFAULT_BITS); + return mir_tstrdup(url); default: return db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL); } @@ -105,17 +118,21 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days")); ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), opts.bPeriodMeasure); + TCHAR url[MAX_PATH]; switch (GetUpdateMode()) { case UPDATE_MODE_STABLE: - SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL)); + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL), DEFAULT_BITS); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url); CheckDlgButton(hwndDlg, IDC_STABLE, BST_CHECKED); break; case UPDATE_MODE_TRUNK: - SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK)); + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL_TRUNK), DEFAULT_BITS); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url); CheckDlgButton(hwndDlg, IDC_TRUNK, BST_CHECKED); break; case UPDATE_MODE_TRUNK_SYMBOLS: - SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS)); + mir_sntprintf(url, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS), DEFAULT_BITS); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url); CheckDlgButton(hwndDlg, IDC_TRUNK_SYMBOLS, BST_CHECKED); break; default: @@ -127,10 +144,24 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar url = GetDefaultUrl(); SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url); } + + #ifdef _WIN64 + CheckDlgButton(hwndDlg, IDC_X64, BST_CHECKED); + #else + CheckDlgButton(hwndDlg, IDC_X86, BST_CHECKED); + #endif + if (opts.bChangePlatform) { + EnableWindow(GetDlgItem(hwndDlg, IDC_TRUNK_SYMBOLS), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_TRUNK), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_STABLE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOM), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE); + } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { + TCHAR defurl[MAX_PATH]; case IDC_UPDATEONSTARTUP: EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP)); // fall through @@ -152,17 +183,41 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar case IDC_TRUNK_SYMBOLS: EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE); - SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS)); + mir_sntprintf(defurl, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS), DEFAULT_BITS); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl); + #ifdef _WIN64 + CheckDlgButton(hwndDlg, IDC_X64, BST_CHECKED); + #else + CheckDlgButton(hwndDlg, IDC_X86, BST_CHECKED); + #endif + EnableWindow(GetDlgItem(hwndDlg, IDC_X64), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_X86), FALSE); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_TRUNK: EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE); - SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL_TRUNK)); + mir_sntprintf(defurl, _T(DEFAULT_UPDATE_URL_TRUNK), DEFAULT_BITS); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl); + #ifdef _WIN64 + CheckDlgButton(hwndDlg, IDC_X64, BST_CHECKED); + #else + CheckDlgButton(hwndDlg, IDC_X86, BST_CHECKED); + #endif + EnableWindow(GetDlgItem(hwndDlg, IDC_X64), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_X86), FALSE); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_STABLE: EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE); - SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL)); + mir_sntprintf(defurl, _T(DEFAULT_UPDATE_URL), DEFAULT_BITS); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl); + #ifdef _WIN64 + CheckDlgButton(hwndDlg, IDC_X64, BST_CHECKED); + #else + CheckDlgButton(hwndDlg, IDC_X86, BST_CHECKED); + #endif + EnableWindow(GetDlgItem(hwndDlg, IDC_X64), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_X86), FALSE); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_CUSTOM: @@ -173,6 +228,13 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar url = GetDefaultUrl(); SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url); } + #ifdef _WIN64 + CheckDlgButton(hwndDlg, IDC_X64, BST_CHECKED); + #else + CheckDlgButton(hwndDlg, IDC_X86, BST_CHECKED); + #endif + EnableWindow(GetDlgItem(hwndDlg, IDC_X64), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_X86), FALSE); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; @@ -187,6 +249,70 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; + case IDC_X86: + EnableWindow(GetDlgItem(hwndDlg, IDC_TRUNK_SYMBOLS), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_TRUNK), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_STABLE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOM), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE); + db_set_b(NULL, MODNAME, DB_SETTING_REDOWNLOAD, opts.bForceRedownload = 1); + db_set_b(NULL, MODNAME, DB_SETTING_CHANGEPLATFORM, opts.bChangePlatform = 1); + switch (GetUpdateMode()) { + case UPDATE_MODE_STABLE: + CheckDlgButton(hwndDlg, IDC_STABLE, BST_CHECKED); + break; + case UPDATE_MODE_TRUNK: + CheckDlgButton(hwndDlg, IDC_TRUNK, BST_CHECKED); + break; + case UPDATE_MODE_TRUNK_SYMBOLS: + CheckDlgButton(hwndDlg, IDC_TRUNK_SYMBOLS, BST_CHECKED); + break; + default: + CheckDlgButton(hwndDlg, IDC_CUSTOM, BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE); + + ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL)); + if (url == NULL) + url = GetDefaultUrl(); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url); + } + mir_sntprintf(defurl, _T(DEFAULT_UPDATE_URL_TRUNK), DEFAULT_OPP_BITS); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + + case IDC_X64: + EnableWindow(GetDlgItem(hwndDlg, IDC_TRUNK_SYMBOLS), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_TRUNK), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_STABLE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOM), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE); + db_set_b(NULL, MODNAME, DB_SETTING_REDOWNLOAD, opts.bForceRedownload = 1); + db_set_b(NULL, MODNAME, DB_SETTING_CHANGEPLATFORM, opts.bChangePlatform = 1); + switch (GetUpdateMode()) { + case UPDATE_MODE_STABLE: + CheckDlgButton(hwndDlg, IDC_STABLE, BST_CHECKED); + break; + case UPDATE_MODE_TRUNK: + CheckDlgButton(hwndDlg, IDC_TRUNK, BST_CHECKED); + break; + case UPDATE_MODE_TRUNK_SYMBOLS: + CheckDlgButton(hwndDlg, IDC_TRUNK_SYMBOLS, BST_CHECKED); + break; + default: + CheckDlgButton(hwndDlg, IDC_CUSTOM, BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE); + + ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL)); + if (url == NULL) + url = GetDefaultUrl(); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url); + } + mir_sntprintf(defurl, _T(DEFAULT_UPDATE_URL_TRUNK), DEFAULT_OPP_BITS); + SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_LINK_HOTKEY: { OPENOPTIONSDIALOG ood = {0}; @@ -220,12 +346,14 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar if ( IsDlgButtonChecked(hwndDlg, IDC_STABLE)) { db_set_b(NULL, MODNAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE); - opts.bForceRedownload = 0; + if (!opts.bChangePlatform) + opts.bForceRedownload = 0; db_unset(NULL, MODNAME, DB_SETTING_REDOWNLOAD); } else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK)) { db_set_b(NULL, MODNAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK); - opts.bForceRedownload = 0; + if (!opts.bChangePlatform) + opts.bForceRedownload = 0; db_unset(NULL, MODNAME, DB_SETTING_REDOWNLOAD); } else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) { diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 47e73a0e53..ca31724626 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -37,6 +37,7 @@ void LoadOptions() opts.bForceRedownload = db_get_b(NULL, MODNAME, DB_SETTING_REDOWNLOAD, 0); opts.bSilentMode = db_get_b(NULL, MODNAME, "SilentMode", 0); opts.bBackup = db_get_b(NULL, MODNAME, "Backup", 0); + opts.bChangePlatform = db_get_b(NULL, MODNAME, DB_SETTING_CHANGEPLATFORM, 0); } #if MIRANDA_VER >= 0x0A00 diff --git a/plugins/PluginUpdater/src/resource.h b/plugins/PluginUpdater/src/resource.h index d735fc5065..e92da5db28 100644 --- a/plugins/PluginUpdater/src/resource.h +++ b/plugins/PluginUpdater/src/resource.h @@ -50,6 +50,8 @@ #define IDC_SILENTMODE 1047 #define IDC_NEEDRESTARTLABEL 1048 #define IDC_BACKUP 1049 +#define IDC_X86 1050 +#define IDC_X64 1051 #define IDC_MSG_BOXES 40071 #define IDC_ERRORS 40072 #define IDC_INFO_MESSAGES 40073 @@ -69,7 +71,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 117 #define _APS_NEXT_COMMAND_VALUE 40075 -#define _APS_NEXT_CONTROL_VALUE 1050 +#define _APS_NEXT_CONTROL_VALUE 1052 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h index 5491dd325b..10ffc6576a 100644 --- a/plugins/PluginUpdater/src/stdafx.h +++ b/plugins/PluginUpdater/src/stdafx.h @@ -86,7 +86,7 @@ typedef OBJLIST FILELIST; extern struct PlugOptions { - BYTE bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bForceRedownload, bSilentMode, bBackup; + BYTE bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bForceRedownload, bSilentMode, bBackup, bChangePlatform; BOOL bSilent; BYTE bPeriodMeasure; @@ -104,14 +104,16 @@ extern struct PlugOptions #define DEFAULT_ONLYONCEADAY 1 #endif +#define DEFAULT_UPDATE_URL "http://miranda-ng.org/distr/stable/x%d" +#define DEFAULT_UPDATE_URL_TRUNK "http://miranda-ng.org/distr/x%d" +#define DEFAULT_UPDATE_URL_TRUNK_SYMBOLS "http://miranda-ng.org/distr/pdb_x%d" + #ifdef _WIN64 - #define DEFAULT_UPDATE_URL "http://miranda-ng.org/distr/stable/x64" - #define DEFAULT_UPDATE_URL_TRUNK "http://miranda-ng.org/distr/x64" - #define DEFAULT_UPDATE_URL_TRUNK_SYMBOLS "http://miranda-ng.org/distr/pdb_x64" + #define DEFAULT_BITS 64 + #define DEFAULT_OPP_BITS 32 #else - #define DEFAULT_UPDATE_URL "http://miranda-ng.org/distr/stable/x32" - #define DEFAULT_UPDATE_URL_TRUNK "http://miranda-ng.org/distr/x32" - #define DEFAULT_UPDATE_URL_TRUNK_SYMBOLS "http://miranda-ng.org/distr/pdb_x32" + #define DEFAULT_BITS 32 + #define DEFAULT_OPP_BITS 64 #endif #define PLUGIN_INFO_URL _T("http://miranda-ng.org/p/%s") @@ -133,6 +135,7 @@ extern struct PlugOptions #define DB_SETTING_RESTART_COUNT "RestartCount" #define DB_SETTING_LAST_UPDATE "LastUpdate" #define DB_SETTING_DONT_SWITCH_TO_STABLE "DontSwitchToStable" +#define DB_SETTING_CHANGEPLATFORM "ChangePlatform" #define DB_MODULE_FILES MODNAME "Files" #define MAX_RETRIES 3 -- cgit v1.2.3