From 77b0ee42f97d9f3f42d09e40ad79ddccac300974 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Sat, 13 Nov 2010 07:19:40 +0000 Subject: Fixes for update issues git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@560 4f64403b-2f21-0410-a795-97e2b3489a10 --- updater/scan.cpp | 2 +- updater/services.cpp | 88 +++++++++++++++++++++++++++++++++------------------- updater/updater.dsp | 2 +- updater/xmldata.cpp | 48 +++++++++++++++------------- 4 files changed, 84 insertions(+), 56 deletions(-) diff --git a/updater/scan.cpp b/updater/scan.cpp index 21e9311..8b43d8a 100644 --- a/updater/scan.cpp +++ b/updater/scan.cpp @@ -284,7 +284,7 @@ bool RearrangeDllsWorker(char *shortName, StrList &filenames, TCHAR *basedir) // disable any new plugins (i.e. not installed before) that somehome got into the // dowloaded archives (e.g. loadavatars comes with loadavatarsw - installing both is not good!) - char *temp_str = mir_t2a(fileName); + char *temp_str = _strlwr(mir_t2a(fileName)); disabled_val = DBGetContactSettingByte(0, "PluginDisable", temp_str, 255); if (disabled_val == 255) { // assume this means setting not in db (should be 1 or 0) DBWriteContactSettingByte(0, "PluginDisable", temp_str, 1); diff --git a/updater/services.cpp b/updater/services.cpp index 49b3c91..43b86c8 100644 --- a/updater/services.cpp +++ b/updater/services.cpp @@ -99,7 +99,7 @@ bool DownloadUpdates(UpdateList &todo, FilenameMap *map, bool dlls_only) { 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 || todo[index].cat == MC_UNKNOWN) @@ -117,7 +117,7 @@ bool DownloadUpdates(UpdateList &todo, FilenameMap *map, bool dlls_only) { } } - if(use_popup == false && hwndProgress == 0) + if (!use_popup && hwndProgress == 0) { RemoveFolder(options.temp_folder); break; // user closed progress window - cancel @@ -201,9 +201,12 @@ void CheckForUpdatesWorker(void *param) { FilenameMap fn_map(5, CompareFileNameStruct); - if(use_popup) { + if (use_popup) + { ShowPopup(0, TranslateT("Checking for Updates"), _T(""), POPFLAG_SAVEHWND, -1); - } else { + } + else + { CreateProgressWindow(); PostMessage(hwndProgress, WM_SETTEXT, 0, (LPARAM)TranslateT("Progress - Checking for updates...")); @@ -214,14 +217,16 @@ void CheckForUpdatesWorker(void *param) { EnterCriticalSection(&list_cs); - if(options.use_xml_backend) + if (options.use_xml_backend) { - if (UpdateXMLData(MC_PLUGINS)) {// prevent double error messages (in some cases) + if (UpdateXMLData(MC_PLUGINS)) // prevent double error messages (in some cases) + { // iterate through the registered plugins if (!use_popup) PostMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Scanning plugins folder"), 0); ScanPlugins(&fn_map, &update_list); - if (UpdateXMLData(MC_LOCALIZATION)) { + if (UpdateXMLData(MC_LOCALIZATION)) + { if (!use_popup) PostMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Scanning language packs"), 0); ScanLangpacks(&fn_map, &update_list); } @@ -242,11 +247,15 @@ void CheckForUpdatesWorker(void *param) { UpdateList todo; - for(index = 0; index < count; index++) { - if(update_list2[index].update_options.enabled) { + for(index = 0; index < count; index++) + { + if(update_list2[index].update_options.enabled) + { mir_sntprintf(msg, SIZEOF(msg), TranslateT("Checking plugin: %s"), (temp_str = GetTString(update_list2[index].update.szComponentName))); mir_free(temp_str); - } else { + } + else + { mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), (temp_str = GetTString(update_list2[index].update.szComponentName))); mir_free(temp_str); } @@ -257,23 +266,26 @@ void CheckForUpdatesWorker(void *param) { } //else if(hwndPop) // disabled - just annoying //ChangePopupText(hwndPop, msg); - if(update_list2[index].update_options.enabled) { + if (update_list2[index].update_options.enabled) + { char *nv; bool beta; - if(nv = UpdateRequired(update_list2[index], &beta)) { + if (nv = UpdateRequired(update_list2[index], &beta)) + { todo.insert(new UpdateInternal(update_list2[index])); todo[todo.getCount()-1].newVersion = nv; todo[todo.getCount()-1].update_options.use_beta = beta; } } - if(use_popup == false && hwndProgress == 0) { + if (!use_popup && hwndProgress == NULL) + { RemoveFolder(options.temp_folder); break; // user closed progress window - cancel } } - if(!use_popup && hwndProgress) ProgressWindowDone(); - if(hwndPop) PostMessage(hwndPop, WMU_CLOSEPOP, 0, 0); + if (!use_popup && hwndProgress) ProgressWindowDone(); + if (hwndPop) PostMessage(hwndPop, WMU_CLOSEPOP, 0 , 0); if(options.use_xml_backend) { FreeXMLData(MC_PLUGINS); @@ -282,16 +294,23 @@ void CheckForUpdatesWorker(void *param) { bool restore_status = true; - if(todo.getCount()) { + if (todo.getCount()) + { int cd_ret = CD_OK; - if(confirm) { - if(use_popup) { + if (confirm) + { + if (use_popup) + { ShowPopup(0, TranslateT("Updates Available"), TranslateT("Updated Miranda components detected.\nClick here to install."), POPFLAG_SAVEHWND, -1); DWORD ret; - while((ret = WaitForSingleObject(hEventPop, 200)) == WAIT_TIMEOUT && !Miranda_Terminated()); - if(!pop_cancelled && ret == WAIT_OBJECT_0 && !Miranda_Terminated()) { + while ((ret = WaitForSingleObject(hEventPop, 200)) == WAIT_TIMEOUT && !Miranda_Terminated()); + + if (!pop_cancelled && ret == WAIT_OBJECT_0 && !Miranda_Terminated()) + { cd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMUPDATES), GetDesktopWindow(), DlgProcConfirm, (LPARAM)&todo); - } else { + } + else + { if(hwndOptions) PostMessage(hwndOptions, WMU_DONECHECKING, 0, 0); RestoreStatus(); for(int i=0; igetCount(); ++i) + { + UpdateInternal &ui = (*update_list)[i]; + if (ui.file_id != -1 && strcmp(ui.update.szComponentName, name) == 0) + return ui.file_id; + } + } + // ignore case in name int id = -1; char *version = NULL; ezxml_t root = ezxml_get(doc[cat], "channel", 0, "item", -1); - while (root) { + while (root) + { const char* title = ezxml_txt(ezxml_child(root, "title")); - if (_stricmp(title, name) == 0) { + if (_stricmp(title, name) == 0) + { const char* subcategory = ezxml_txt(ezxml_child(root, "subcategory")); - if (strcmp(subcategory, "Archived")) { + if (strcmp(subcategory, "Archived")) + { int id1 = atoi(ezxml_txt(ezxml_child(root, "id"))); if (id1) { @@ -450,19 +464,6 @@ int FindFileID(const char *name, const Category cat, UpdateList *update_list) { root = ezxml_next(root); } - if(id == -1 && update_list) - { - // couldn't find it in xml file - check if a plugin gave us a file id for a different shortName - for (int i = 0; i < update_list->getCount(); ++i) - { - if ((*update_list)[i].file_id != -1 && strcmp((*update_list)[i].update.szComponentName, name) == 0) - { - id = (*update_list)[i].file_id; - break; - } - } - } - return id; } @@ -470,18 +471,21 @@ void UpdateFLIDs(UpdateList &update_list) { for (int i = 0; i < update_list.getCount(); ++i) { - if(update_list[i].file_id == -1 && update_list[i].update.szUpdateURL && strcmp(update_list[i].update.szUpdateURL, UPDATER_AUTOREGISTER) == 0) { + if(update_list[i].file_id == -1 && update_list[i].update.szUpdateURL && strcmp(update_list[i].update.szUpdateURL, UPDATER_AUTOREGISTER) == 0) + { int file_id = FindFileID(update_list[i].update.szComponentName, MC_PLUGINS, 0); - if(file_id == -1) + if (file_id == -1) file_id = FindFileID(update_list[i].update.szComponentName, MC_LOCALIZATION, 0); - if(file_id != -1) { + if (file_id != -1) + { update_list[i].file_id = file_id; char *buff = (char *)safe_alloc((int)strlen(MIM_DOWNLOAD_URL_PREFIX) + 9); sprintf(buff, MIM_DOWNLOAD_URL_PREFIX "%d", file_id); update_list[i].update.szUpdateURL = buff; update_list[i].shortName = safe_strdup(update_list[i].update.szComponentName); - if(update_list[i].update.szBetaVersionURL) { + if(update_list[i].update.szBetaVersionURL) + { update_list[i].update_options.fixed = false; LoadUpdateOptions(update_list[i].update.szComponentName, &update_list[i].update_options); } -- cgit v1.2.3