summaryrefslogtreecommitdiff
path: root/plugins/PluginUpdater/src
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2016-06-12 12:47:19 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2016-06-12 12:47:19 +0000
commit66c723f6dce584a64b04e79518c6675796ad0960 (patch)
tree9ae32601bff51944b149818ca8e9a12c1efec5de /plugins/PluginUpdater/src
parenta19e90b8eba21b88a146c531cae16b7f1219b2b5 (diff)
PluginUpdater:
- Old Miranda*.exe is removed after the next update, because we need UAC priviledges for that, and a prompt on startup seems to be too annoying - It doesn't seem safe to me to do ANYTHING after MS_SYSTEM_RESTART has been called - fixed enabling/disabling "Convert to" checkbox in options dialog git-svn-id: http://svn.miranda-ng.org/main/trunk@16955 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PluginUpdater/src')
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp40
-rw-r--r--plugins/PluginUpdater/src/Options.cpp30
-rw-r--r--plugins/PluginUpdater/src/PluginUpdater.cpp5
3 files changed, 36 insertions, 39 deletions
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index b3c5a07954..169fec9fbe 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -135,37 +135,49 @@ static void ApplyUpdates(void *param)
if (opts.bBackup)
CallService(MS_AB_BACKUP);
+ if (opts.bChangePlatform) {
+ TCHAR mirandaPath[MAX_PATH];
+ GetModuleFileName(NULL, mirandaPath, _countof(mirandaPath));
+ db_set_ts(NULL, MODNAME, "OldBin", mirandaPath);
+
+ opts.bChangePlatform = 0;
+ db_unset(NULL, MODNAME, DB_SETTING_CHANGEPLATFORM);
+ }
+ else {
+ ptrT oldbin(db_get_tsa(NULL, MODNAME, "OldBin"));
+ if (oldbin) {
+ SafeDeleteFile(oldbin);
+ db_unset(NULL, MODNAME, "OldBin");
+ }
+ }
+
+ if (opts.bForceRedownload) {
+ opts.bForceRedownload = 0;
+ db_unset(NULL, MODNAME, DB_SETTING_REDOWNLOAD);
+ }
+
// 5) Prepare Restart
int rc = MessageBox(hDlg, TranslateT("Update complete. Press Yes to restart Miranda now or No to postpone a restart until the exit."), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION);
PostMessage(hDlg, WM_CLOSE, 0, 0);
- if (rc == IDYES)
+ if (rc == IDYES) {
#if MIRANDA_VER >= 0x0A00
+ BOOL bRestartCurrentProfile = db_get_b(NULL, MODNAME, "RestartCurrentProfile", 1) ? 1 : 0;
if (opts.bChangePlatform) {
TCHAR mirstartpath[MAX_PATH];
+
#ifdef _WIN64
mir_sntprintf(mirstartpath, _T("%s\\miranda32.exe"), tszMirandaPath);
#else
mir_sntprintf(mirstartpath, _T("%s\\miranda64.exe"), tszMirandaPath);
#endif
- CallServiceSync(MS_SYSTEM_RESTART, db_get_b(NULL, MODNAME, "RestartCurrentProfile", 1) ? 1 : 0, (LPARAM)mirstartpath);
+ CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile, (LPARAM)mirstartpath);
}
else
- CallServiceSync(MS_SYSTEM_RESTART, db_get_b(NULL, MODNAME, "RestartCurrentProfile", 1) ? 1 : 0, 0);
+ CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile);
#else
CallFunctionAsync(RestartMe, 0);
#endif
-
- if (opts.bChangePlatform) {
- TCHAR mirandaPath[MAX_PATH];
- GetModuleFileName(NULL, mirandaPath, _countof(mirandaPath));
- db_set_ts(NULL, MODNAME, "OldBin", mirandaPath);
}
-
- opts.bForceRedownload = false;
- db_unset(NULL, MODNAME, DB_SETTING_REDOWNLOAD);
-
- opts.bChangePlatform = false;
- db_unset(NULL, MODNAME, DB_SETTING_CHANGEPLATFORM);
}
static void ResizeVert(HWND hDlg, int yy)
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp
index 03e1b5cb0f..4586df734a 100644
--- a/plugins/PluginUpdater/src/Options.cpp
+++ b/plugins/PluginUpdater/src/Options.cpp
@@ -24,9 +24,7 @@ POPUP_OPTIONS PopupOptions = {0};
static int GetBits(HWND hwndDlg)
{
- if (IsDlgButtonChecked(hwndDlg, IDC_CHANGE_PLATFORM))
- return DEFAULT_OPP_BITS;
- return DEFAULT_BITS;
+ return IsDlgButtonChecked(hwndDlg, IDC_CHANGE_PLATFORM) ? DEFAULT_OPP_BITS : DEFAULT_BITS;
}
static int GetUpdateMode()
@@ -58,22 +56,13 @@ TCHAR* GetDefaultUrl()
TCHAR url[MAX_PATH];
switch (GetUpdateMode()) {
case UPDATE_MODE_STABLE:
- if (opts.bChangePlatform)
- mir_sntprintf(url, _T(DEFAULT_UPDATE_URL), DEFAULT_OPP_BITS);
- else
- mir_sntprintf(url, _T(DEFAULT_UPDATE_URL), DEFAULT_BITS);
+ mir_sntprintf(url, _T(DEFAULT_UPDATE_URL), opts.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS);
return mir_tstrdup(url);
case UPDATE_MODE_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);
+ mir_sntprintf(url, _T(DEFAULT_UPDATE_URL_TRUNK), opts.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS);
return mir_tstrdup(url);
case UPDATE_MODE_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);
+ mir_sntprintf(url, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS), opts.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS);
return mir_tstrdup(url);
default:
return db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL);
@@ -149,6 +138,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar
default:
CheckDlgButton(hwndDlg, IDC_CUSTOM, BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), FALSE);
ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL));
if (url == NULL)
@@ -156,9 +146,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar
SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url);
}
-#ifdef _WIN64
- SetDlgItemText(hwndDlg, IDC_CHANGE_PLATFORM, TranslateT("Change platform to x86"));
-#else
+#ifndef _WIN64
SetDlgItemText(hwndDlg, IDC_CHANGE_PLATFORM, TranslateT("Change platform to x64"));
{
BOOL bIsWow64 = FALSE;
@@ -167,8 +155,6 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar
ShowWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), SW_HIDE);
}
#endif
- if (IsDlgButtonChecked(hwndDlg, IDC_CUSTOM))
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), FALSE);
return TRUE;
case WM_COMMAND:
@@ -193,6 +179,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar
break;
case IDC_TRUNK_SYMBOLS:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
mir_sntprintf(defurl, _T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS), GetBits(hwndDlg));
SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
@@ -200,6 +187,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar
break;
case IDC_TRUNK:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
mir_sntprintf(defurl, _T(DEFAULT_UPDATE_URL_TRUNK), GetBits(hwndDlg));
SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
@@ -207,6 +195,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar
break;
case IDC_STABLE:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
mir_sntprintf(defurl, _T(DEFAULT_UPDATE_URL), GetBits(hwndDlg));
SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
@@ -214,6 +203,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar
break;
case IDC_CUSTOM:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
{
ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL));
diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp
index b58d7a8e78..74554870cd 100644
--- a/plugins/PluginUpdater/src/PluginUpdater.cpp
+++ b/plugins/PluginUpdater/src/PluginUpdater.cpp
@@ -70,11 +70,6 @@ extern "C" __declspec(dllexport) int Load(void)
InitServices();
#endif
- ptrT oldbin(db_get_tsa(NULL, MODNAME, "OldBin"));
- if (oldbin) {
- SafeDeleteFile(oldbin);
- db_unset(NULL, MODNAME, "OldBin");
- }
db_set_b(NULL, MODNAME, DB_SETTING_NEED_RESTART, 0);
DWORD dwLen = GetTempPath(_countof(g_tszTempPath), g_tszTempPath);