diff options
-rw-r--r-- | updater/services.cpp | 77 | ||||
-rw-r--r-- | updater/socket.cpp | 56 |
2 files changed, 88 insertions, 45 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;
}
diff --git a/updater/socket.cpp b/updater/socket.cpp index 6ce31f2..745d187 100644 --- a/updater/socket.cpp +++ b/updater/socket.cpp @@ -277,62 +277,82 @@ char *CheckVersionURL(char *url, BYTE *pbPrefixBytes, int cpbPrefixBytes, BYTE * return ret;
}
-char *UpdateRequired(UpdateInternal &update_internal, bool *beta) {
+char *UpdateRequired(UpdateInternal &update_internal, bool *beta)
+{
// determine whether update is required
const char *ret = NULL;
char *ret_beta = NULL;
- if(options.use_xml_backend && update_internal.file_id != -1) {
- if(update_internal.cat == MC_UNKNOWN) {
- if(XMLDataAvailable(MC_PLUGINS)
- && (ret = FindVersion(update_internal.file_id, update_internal.update.pbVersion, update_internal.update.cpbVersion, MC_PLUGINS)))
+ if (options.use_xml_backend && update_internal.file_id != -1)
+ {
+ if( update_internal.cat == MC_UNKNOWN)
+ {
+ if (XMLDataAvailable(MC_PLUGINS) &&
+ (ret = FindVersion(update_internal.file_id, update_internal.update.pbVersion, update_internal.update.cpbVersion, MC_PLUGINS)))
{
update_internal.cat = MC_PLUGINS;
- if(strcmp(ret, "same") == 0) {
+ if(strcmp(ret, "same") == 0)
+ {
ret = 0;
}
- } else if(XMLDataAvailable(MC_LOCALIZATION)
- && (ret = FindVersion(update_internal.file_id, update_internal.update.pbVersion, update_internal.update.cpbVersion, MC_LOCALIZATION)))
+ }
+ else if (XMLDataAvailable(MC_LOCALIZATION) &&
+ (ret = FindVersion(update_internal.file_id, update_internal.update.pbVersion, update_internal.update.cpbVersion, MC_LOCALIZATION)))
{
update_internal.cat = MC_LOCALIZATION;
- if(strcmp(ret, "same") == 0) {
+ if (strcmp(ret, "same") == 0)
+ {
ret = 0;
}
}
- } else {
+ }
+ else
+ {
ret = FindVersion(update_internal.file_id, update_internal.update.pbVersion, update_internal.update.cpbVersion, update_internal.cat);
- if(ret && strcmp(ret, "same") == 0) {
+ if(ret && strcmp(ret, "same") == 0)
+ {
ret = 0;
}
}
- } else {
+ }
+ else
+ {
ret = CheckVersionURL(update_internal.update.szVersionURL, update_internal.update.pbVersionPrefix,
update_internal.update.cpbVersionPrefix, update_internal.update.pbVersion, update_internal.update.cpbVersion);
}
- if(update_internal.update_options.use_beta) {
+ if (update_internal.update_options.use_beta)
+ {
ret_beta = CheckVersionURL(update_internal.update.szBetaVersionURL, update_internal.update.pbBetaVersionPrefix,
update_internal.update.cpbBetaVersionPrefix, update_internal.update.pbVersion, update_internal.update.cpbVersion);
}
- if(ret && !ret_beta) {
+ if(ret && !ret_beta)
+ {
if(beta) *beta = false;
return _strdup(ret);
- } else if(!ret && ret_beta) {
+ }
+ else if(!ret && ret_beta)
+ {
if(beta) *beta = true;
return ret_beta;
- } else if(ret && ret_beta) {
+ }
+ else if (ret && ret_beta)
+ {
// find highest version of ret and ret_beta
DWORD vRet, vRetBeta;
VersionFromString(ret, &vRet);
VersionFromString(ret_beta, &vRetBeta);
- if(vRetBeta > vRet) {
+ if (vRetBeta > vRet)
+ {
if(beta) *beta = true;
return ret_beta;
- } else {
+ }
+ else
+ {
free(ret_beta);
if(beta) *beta = false;
return _strdup(ret);
|