summaryrefslogtreecommitdiff
path: root/updater/services.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'updater/services.cpp')
-rw-r--r--updater/services.cpp77
1 files changed, 50 insertions, 27 deletions
diff --git a/updater/services.cpp b/updater/services.cpp
index 6ce12d6..76f39b2 100644
--- a/updater/services.cpp
+++ b/updater/services.cpp
@@ -34,9 +34,12 @@ bool DownloadUpdates(UpdateList &todo, FilenameMap *map, bool dlls_only) {
// iterate through the updates we need to check
- if(use_popup) {
+ if(use_popup)
+ {
ShowPopup(0, TranslateT("Downloading Updates"), _T(""), POPFLAG_SAVEHWND, -1);
- } else {
+ }
+ else
+ {
CreateProgressWindow();
PostMessage(hwndProgress, WM_SETTEXT, 0, (LPARAM)TranslateT("Progress - Downloading updates..."));
@@ -48,13 +51,15 @@ bool DownloadUpdates(UpdateList &todo, FilenameMap *map, bool dlls_only) {
TCHAR *temp_str;
bool a_download_succeeded = false;
- for (int index = 0; index < todo.getCount(); index++) {
+ for (int index = 0; index < todo.getCount(); index++)
+ {
// remember if the user has decided not to install this version
char stored_setting[256];
mir_snprintf(stored_setting, SIZEOF(stored_setting), "DisabledVer%s", todo[index].update.szComponentName);
DBVARIANT dbv;
bool download = todo[index].update_options.enabled;
- if(!DBGetContactSettingString(0, "Updater", stored_setting, &dbv)) {
+ if(!DBGetContactSettingString(0, "Updater", stored_setting, &dbv))
+ {
if(dbv.pszVal && strcmp(dbv.pszVal, todo[index].newVersion) == 0)
download = false;
else
@@ -62,59 +67,72 @@ bool DownloadUpdates(UpdateList &todo, FilenameMap *map, bool dlls_only) {
DBFreeVariant(&dbv);
}
- if(download) {
+ if(download)
+ {
mir_sntprintf(msg, SIZEOF(msg), TranslateT("Downloading plugin: %s"), (temp_str = GetTString(todo[index].update.szComponentName)));
mir_free(temp_str);
- } else {
+ }
+ else
+ {
mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), (temp_str = GetTString(todo[index].update.szComponentName)));
mir_free(temp_str);
}
- if(!use_popup) {
+ if (!use_popup)
+ {
SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)msg, 0);
PostMessage(hwndProgress, WMU_SETPROGRESS, (WPARAM)(int)(index * 100.0 / todo.getCount()), 0);
} //else if(hwndPop) // disabled - just annoying
//ChangePopupText(hwndPop, msg);
- if(download) {
+ if (download)
+ {
bool got_file = false;
- if(todo[index].update_options.use_beta) {
+ if(todo[index].update_options.use_beta)
+ {
// download from i->update.szBetaUpdateURL to temp folder
got_file = GetFile(todo[index].update.szBetaUpdateURL, options.temp_folder, todo[index].update.szComponentName, todo[index].newVersion, dlls_only);
} else {
got_file = GetFile(todo[index].update.szUpdateURL, options.temp_folder, todo[index].update.szComponentName, todo[index].newVersion, dlls_only);
}
- if(got_file) {
+ if(got_file)
+ {
a_download_succeeded = true;
- if(todo[index].file_id != -1) {
+ if(todo[index].file_id != -1)
+ {
FileNameStruct* fns = map->find((FileNameStruct*)&todo[index].file_id);
- if(todo[index].cat == MC_PLUGINS)
+ if (todo[index].cat == MC_PLUGINS || todo[index].cat == MC_UNKNOWN)
dll_enabled_or_langpack |= RearrangeDlls(todo[index].shortName, fns->list);
- else if(todo[index].cat == MC_LOCALIZATION) {
+ else if(todo[index].cat == MC_LOCALIZATION)
+ {
RearrangeLangpacks(todo[index].shortName, fns->list);
dll_enabled_or_langpack = true;
}
- } else {
+ }
+ else
+ {
dll_enabled_or_langpack = true;
}
}
}
- if(use_popup == false && hwndProgress == 0) {
+ if(use_popup == false && hwndProgress == 0)
+ {
RemoveFolder(options.temp_folder);
break; // user closed progress window - cancel
}
}
- if(!use_popup && hwndProgress) ProgressWindowDone();
+ if (!use_popup && hwndProgress) ProgressWindowDone();
// postmessage here causes a lockup on exit! bah popups!!
//if(hwndPop) PostMessage(hwndPop, WMU_CLOSEPOP, 0, 0);
- if(hwndPop) SendMessage(hwndPop, WMU_CLOSEPOP, 0, 0);
+ if (hwndPop) SendMessage(hwndPop, WMU_CLOSEPOP, 0, 0);
- if(!a_download_succeeded) {
+ if(!a_download_succeeded)
+ {
for(int i = 0; i < todo.getCount(); ++i)
free(todo[i].newVersion);
todo.destroy();
@@ -290,12 +308,13 @@ void CheckForUpdatesWorker(void *param) {
- if(!confirm || cd_ret == CD_CONFALL || cd_ret == CD_NOINSTALL || cd_ret == CD_OK) {
-
+ if(!confirm || cd_ret == CD_CONFALL || cd_ret == CD_NOINSTALL || cd_ret == CD_OK)
+ {
bool conf_all = (cd_ret == CD_CONFALL), no_install = (cd_ret == CD_NOINSTALL);
// ensure the backup folder exists (either create it or return non-zero signifying error)
- if(options.backup && !CreatePath(options.backup_folder)) {
+ if(options.backup && !CreatePath(options.backup_folder))
+ {
//MessageBox(0, Translate("Could not create backup folder"), Translate("Error"), MB_OK | MB_ICONERROR);
ShowError(TranslateT("Could not create backup folder"));
if(hwndOptions) PostMessage(hwndOptions, WMU_DONECHECKING, 0, 0);
@@ -309,9 +328,12 @@ void CheckForUpdatesWorker(void *param) {
}
bool dll_enabled_or_langpack = DownloadUpdates(todo, &fn_map, confirm ? false : options.auto_dll_only);
- if (todo.getCount() && !no_install) {
- if(!conf_all || DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIRMCOMPONENTS), GetDesktopWindow(), DlgProcConfirmComponents) == IDOK) {
- if(!dll_enabled_or_langpack && restart) {
+ if (todo.getCount() && !no_install)
+ {
+ if (!conf_all || DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIRMCOMPONENTS), GetDesktopWindow(), DlgProcConfirmComponents) == IDOK)
+ {
+ if (!dll_enabled_or_langpack && restart)
+ {
// we're not doing an 'update and shutdown', and we're not updating any active dlls...so just install
// get folders
@@ -320,18 +342,19 @@ void CheckForUpdatesWorker(void *param) {
GetModuleFileName(0, root_folder, MAX_PATH);
_tcscpy(plugins_folder, root_folder);
p = _tcsrchr(plugins_folder, '\\');
- if(p) *p = 0;
+ if (p) *p = 0;
_tcscat(plugins_folder, _T("\\Plugins"));
p = _tcsrchr(root_folder, _T('\\'));
- if(p) *p = 0;
+ if (p) *p = 0;
// move files
MoveFiles(0, options.temp_folder, plugins_folder, options.backup_folder, root_folder);
// rescan to get correct version numbers
ScanPlugins(0, 0);
- } else {
+ } else
+ {
if(ExternProcess(restart) == 0) // if restarting, don't restore status
restore_status = false;
}