summaryrefslogtreecommitdiff
path: root/updater/services.cpp
diff options
context:
space:
mode:
author(no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10>2010-02-21 23:00:56 +0000
committer(no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10>2010-02-21 23:00:56 +0000
commit8f5a7b54eb953bbfc877ec915e26b3a95ec28d00 (patch)
tree827e40ab3528e10afd6fcb44f7ed5db0d7eed519 /updater/services.cpp
parentb130e8caa16961f597ae4ac6984a6aa00de7b6c7 (diff)
New updater with 3x reduced footprint and fully W7 and x64 compatible
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@476 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'updater/services.cpp')
-rw-r--r--updater/services.cpp223
1 files changed, 112 insertions, 111 deletions
diff --git a/updater/services.cpp b/updater/services.cpp
index c0a7fae..4b232b1 100644
--- a/updater/services.cpp
+++ b/updater/services.cpp
@@ -12,19 +12,21 @@ HANDLE hStartupDone = 0;
bool checking = false;
-HANDLE hUpdateThread = 0;
-
#define NUM_SERVICES 13
HANDLE hService[NUM_SERVICES] = {0};
+int CompareFileNameStruct(const FileNameStruct *p1, const FileNameStruct *p2)
+{
+ return p1->file_id - p2->file_id;
+}
+
VOID CALLBACK CheckTimerProcDaily(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
if(options.check_daily)
CallService(MS_UPDATE_CHECKFORUPDATES, (WPARAM)(is_idle && options.no_conf_idle), 0);
}
-
// returns true if any downloaded dll is active
-bool DownloadUpdates(UpdateList *todo, FilenameMap *map, bool dlls_only) {
+bool DownloadUpdates(UpdateList &todo, FilenameMap *map, bool dlls_only) {
bool dll_enabled_or_langpack = false;
@@ -42,19 +44,18 @@ bool DownloadUpdates(UpdateList *todo, FilenameMap *map, bool dlls_only) {
}
- int count = todo->size(), index = 0;
TCHAR msg[512];
TCHAR *temp_str;
bool a_download_succeeded = false;
- for(todo->reset(); todo->current(); todo->next(), 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, 256, "DisabledVer%s", todo->current()->update.szComponentName);
+ mir_snprintf(stored_setting, SIZEOF(stored_setting), "DisabledVer%s", todo[index].update.szComponentName);
DBVARIANT dbv;
- bool download = todo->current()->update_options.enabled;
+ bool download = todo[index].update_options.enabled;
if(!DBGetContactSetting(0, "Updater", stored_setting, &dbv)) {
- if(dbv.pszVal && strcmp(dbv.pszVal, todo->current()->newVersion) == 0)
+ if(dbv.pszVal && strcmp(dbv.pszVal, todo[index].newVersion) == 0)
download = false;
else
DBDeleteContactSetting(0, "Updater", stored_setting);
@@ -62,36 +63,37 @@ bool DownloadUpdates(UpdateList *todo, FilenameMap *map, bool dlls_only) {
}
if(download) {
- _stprintf(msg, TranslateT("Downloading plugin: %s"), TranslateTS(temp_str = GetTString(todo->current()->update.szComponentName)));
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Downloading plugin: %s"), TranslateTS(temp_str = GetTString(todo[index].update.szComponentName)));
free(temp_str);
} else {
- _stprintf(msg, TranslateT("Skipping plugin: %s"), TranslateTS(temp_str = GetTString(todo->current()->update.szComponentName)));
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), TranslateTS(temp_str = GetTString(todo[index].update.szComponentName)));
free(temp_str);
}
if(!use_popup) {
PostMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)msg, 0);
- PostMessage(hwndProgress, WMU_SETPROGRESS, (WPARAM)(int)(index * 100.0 / count), 0);
+ PostMessage(hwndProgress, WMU_SETPROGRESS, (WPARAM)(int)(index * 100.0 / todo.getCount()), 0);
} //else if(hwndPop) // disabled - just annoying
//ChangePopupText(hwndPop, msg);
if(download) {
bool got_file = false;
- if(todo->current()->update_options.use_beta) {
+ if(todo[index].update_options.use_beta) {
// download from i->update.szBetaUpdateURL to temp folder
- got_file = GetFile(todo->current()->update.szBetaUpdateURL, options.temp_folder, todo->current()->update.szComponentName, todo->current()->newVersion, dlls_only);
+ got_file = GetFile(todo[index].update.szBetaUpdateURL, options.temp_folder, todo[index].update.szComponentName, todo[index].newVersion, dlls_only);
} else {
- got_file = GetFile(todo->current()->update.szUpdateURL, options.temp_folder, todo->current()->update.szComponentName, todo->current()->newVersion, dlls_only);
+ got_file = GetFile(todo[index].update.szUpdateURL, options.temp_folder, todo[index].update.szComponentName, todo[index].newVersion, dlls_only);
}
if(got_file) {
a_download_succeeded = true;
- if(todo->current()->file_id != -1) {
- if(todo->current()->cat == MC_PLUGINS)
- dll_enabled_or_langpack |= RearrangeDlls(todo->current()->shortName, (*map)[todo->current()->file_id]);
- else if(todo->current()->cat == MC_LOCALIZATION) {
- RearrangeLangpacks(todo->current()->shortName, (*map)[todo->current()->file_id]);
+ if(todo[index].file_id != -1) {
+ FileNameStruct* fns = map->find((FileNameStruct*)&todo[index].file_id);
+ if(todo[index].cat == MC_PLUGINS)
+ dll_enabled_or_langpack |= RearrangeDlls(todo[index].shortName, fns->list);
+ else if(todo[index].cat == MC_LOCALIZATION) {
+ RearrangeLangpacks(todo[index].shortName, fns->list);
dll_enabled_or_langpack = true;
}
} else {
@@ -113,22 +115,22 @@ bool DownloadUpdates(UpdateList *todo, FilenameMap *map, bool dlls_only) {
if(hwndPop) SendMessage(hwndPop, WMU_CLOSEPOP, 0, 0);
if(!a_download_succeeded) {
- for(todo->reset(); todo->current(); todo->next())
- free(todo->current()->newVersion);
- todo->clear();
+ for(int i = 0; i < todo.getCount(); ++i)
+ free(todo[i].newVersion);
+ todo.destroy();
}
return dll_enabled_or_langpack;
}
-void __stdcall sttNotifyStartup( DWORD_PTR dwParam ) {
+void __stdcall sttNotifyStartup( void* dwParam ) {
NotifyEventHooks(hStartupDone, 0, 0);
}
void RestoreStatus() {
//NotifyEventHooks(hStartupDone, 0, 0);
// do this in a seperate thread, in case we're called from an event hook to prevent double-lock on core hook critical section (csHooks)
- QueueUserAPC(sttNotifyStartup, mainThread, 0);
+ CallFunctionAsync(sttNotifyStartup, NULL);
if(options.start_offline) {
// restore global status - only works on startup since we remove the SavedGlobalStatus parameter
@@ -155,10 +157,9 @@ bool WriteLastCheckTime() {
return true;
}
-//DWORD CALLBACK CheckForUpdatesWorker(LPVOID param) {
-unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
+void CheckForUpdatesWorker(void *param) {
- if(checking) return 1;
+ if (checking) return;
/*
// this check doesn't work on some systems - not sure which or why
if(!(GetSystemMetrics(SM_NETWORK) & 1)) {
@@ -181,7 +182,7 @@ unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
bool use_popup = options.popup_notify && ArePopupsEnabled();
- FilenameMap fn_map;
+ FilenameMap fn_map(5, CompareFileNameStruct);
if(use_popup) {
ShowPopup(0, TranslateT("Checking for Updates"), _T(""), POPFLAG_SAVEHWND, -1);
@@ -196,7 +197,8 @@ unsigned int CALLBACK 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)
// iterate through the registered plugins
if(!use_popup) PostMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Scanning plugins folder"), 0);
@@ -217,18 +219,18 @@ unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
UpdateList update_list2(update_list);
LeaveCriticalSection(&list_cs);
- int count = update_list2.size(), index = 0;
+ int count = update_list2.getCount(), index = 0;
TCHAR msg[512];
TCHAR *temp_str;
UpdateList todo;
- for(update_list2.reset(); update_list2.current(); update_list2.next(), index++) {
- if(update_list2.current()->update_options.enabled) {
- _stprintf(msg, TranslateT("Checking plugin: %s"), TranslateTS(temp_str = GetTString(update_list2.current()->update.szComponentName)));
+ for(index = 0; index < count; index++) {
+ if(update_list2[index].update_options.enabled) {
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Checking plugin: %s"), TranslateTS(temp_str = GetTString(update_list2[index].update.szComponentName)));
free(temp_str);
} else {
- _stprintf(msg, TranslateT("Skipping plugin: %s"), TranslateTS(temp_str = GetTString(update_list2.current()->update.szComponentName)));
+ mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), TranslateTS(temp_str = GetTString(update_list2[index].update.szComponentName)));
free(temp_str);
}
@@ -238,13 +240,13 @@ unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
} //else if(hwndPop) // disabled - just annoying
//ChangePopupText(hwndPop, msg);
- if(update_list2.current()->update_options.enabled) {
+ if(update_list2[index].update_options.enabled) {
char *nv;
bool beta;
- if(nv = UpdateRequired(update_list2.current(), &beta)) {
- todo.push_back(*update_list2.current());
- todo.back().newVersion = nv;
- todo.back().update_options.use_beta = 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) {
@@ -263,7 +265,7 @@ unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
bool restore_status = true;
- if(todo.size()) {
+ if(todo.getCount()) {
int cd_ret = CD_OK;
if(confirm) {
if(use_popup) {
@@ -275,10 +277,12 @@ unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
} else {
if(hwndOptions) PostMessage(hwndOptions, WMU_DONECHECKING, 0, 0);
RestoreStatus();
- for(todo.reset(); todo.current(); todo.next())
- free(todo.current()->newVersion);
+ for(int i=0; i<todo.getCount(); ++i)
+ free(todo[i].newVersion);
checking = false;
- return 1;
+ Netlib_CloseHandle(hNetlibHttp);
+ hNetlibHttp = NULL;
+ return;
}
} else
cd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMUPDATES), GetDesktopWindow(), DlgProcConfirm, (LPARAM)&todo);
@@ -296,14 +300,16 @@ unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
ShowError(TranslateT("Could not create backup folder"));
if(hwndOptions) PostMessage(hwndOptions, WMU_DONECHECKING, 0, 0);
RestoreStatus();
- for(todo.reset(); todo.current(); todo.next())
- free(todo.current()->newVersion);
+ for(int i=0; i<todo.getCount(); ++i)
+ free(todo[i].newVersion);
checking = false;
- return 1;
+ Netlib_CloseHandle(hNetlibHttp);
+ hNetlibHttp = NULL;
+ return;
}
- bool dll_enabled_or_langpack = DownloadUpdates(&todo, &fn_map, confirm ? false : options.auto_dll_only);
- if(todo.size() && !no_install) {
+ 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) {
// we're not doing an 'update and shutdown', and we're not updating any active dlls...so just install
@@ -333,8 +339,8 @@ unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
}
}
- for(todo.reset(); todo.current(); todo.next())
- free(todo.current()->newVersion);
+ for(int i=0; i<todo.getCount(); ++i)
+ free(todo[i].newVersion);
} else if(!restart) {
HWND hWndMiranda = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
@@ -346,8 +352,8 @@ unsigned int CALLBACK CheckForUpdatesWorker(void *param) {
if(hwndOptions) PostMessage(hwndOptions, WMU_DONECHECKING, 0, 0);
RestoreStatus();
}
-
- return 0;
+ Netlib_CloseHandle(hNetlibHttp);
+ hNetlibHttp = NULL;
}
INT_PTR Restart(WPARAM wParam, LPARAM lParam) {
@@ -367,9 +373,7 @@ INT_PTR CheckForUpdates(WPARAM wParam, LPARAM lParam) {
DWORD param = ((wParam ? 1 : 0) | (lParam ? 2 : 0));
- if(hUpdateThread) CloseHandle(hUpdateThread);
- //hUpdateThread = CreateThread(0, 0, CheckForUpdatesWorker, (void *)param, 0, 0);
- hUpdateThread = (HANDLE)_beginthreadex(0, 0, CheckForUpdatesWorker, (void *)param, 0, 0);
+ mir_forkthread(CheckForUpdatesWorker, (void*)param);
NLog("CheckForUpdates service called");
return 0;
@@ -379,8 +383,8 @@ INT_PTR EnumerateUpdates(WPARAM wParam, LPARAM lParam) {
UpdateEnumerateFunc func = (UpdateEnumerateFunc)wParam;
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- func(update_list.current()->update.szComponentName, &(update_list.current()->update_options), lParam);
+ for(int i=0; i<update_list.getCount(); ++i) {
+ func(update_list[i].update.szComponentName, &(update_list[i].update_options), lParam);
}
LeaveCriticalSection(&list_cs);
@@ -414,15 +418,15 @@ INT_PTR SetUpdateOptions(WPARAM wParam, LPARAM lParam) {
bool found = false;
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- if(strcmp(update_list.current()->update.szComponentName, szComponentName) == 0
- || _tcscmp(TranslateTS(temp1 = GetTString(update_list.current()->update.szComponentName)), (TCHAR *)szComponentName) == 0) // when set via options, szComponentName is translated and potentially already converted to unicode
+ for (int i=0; i<update_list.getCount(); ++i) {
+ if(strcmp(update_list[i].update.szComponentName, szComponentName) == 0
+ || _tcscmp(TranslateTS(temp1 = GetTString(update_list[i].update.szComponentName)), (TCHAR *)szComponentName) == 0) // when set via options, szComponentName is translated and potentially already converted to unicode
{
found = true;
- update_list.current()->update_options = *uo;
- SaveUpdateOptions(update_list.current()->update.szComponentName, &update_list.current()->update_options);
- if(update_list.current()->file_id == -1 && !uo->use_beta) {
- update_list.current()->file_id = CheckForFileID(update_list.current()->update.szUpdateURL, update_list.current()->update.szVersionURL, update_list.current()->update.szComponentName);
+ update_list[i].update_options = *uo;
+ SaveUpdateOptions(update_list[i].update.szComponentName, &update_list[i].update_options);
+ if(update_list[i].file_id == -1 && !uo->use_beta) {
+ update_list[i].file_id = CheckForFileID(update_list[i].update.szUpdateURL, update_list[i].update.szVersionURL, update_list[i].update.szComponentName);
}
break;
}
@@ -441,12 +445,12 @@ INT_PTR GetUpdateOptions(WPARAM wParam, LPARAM lParam) {
bool found = false;
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- if(strcmp(update_list.current()->update.szComponentName, szComponentName) == 0
- || _tcscmp(TranslateTS(temp1 = GetTString(update_list.current()->update.szComponentName)), (TCHAR *)szComponentName) == 0) // when set via options, szComponentName is translated and potentially already converted to unicode
+ for (int i=0; i<update_list.getCount(); ++i) {
+ if(strcmp(update_list[i].update.szComponentName, szComponentName) == 0
+ || _tcscmp(TranslateTS(temp1 = GetTString(update_list[i].update.szComponentName)), (TCHAR *)szComponentName) == 0) // when set via options, szComponentName is translated and potentially already converted to unicode
{
found = true;
- *uo = update_list.current()->update_options;
+ *uo = update_list[i].update_options;
break;
}
}
@@ -463,8 +467,8 @@ bool RegisterForFileListing(int file_id, PLUGININFO *pluginInfo, bool auto_regis
bool IsRegistered(int file_id) {
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- if(update_list.current()->file_id == file_id) {
+ for (int i=0; i<update_list.getCount(); ++i) {
+ if(update_list[i].file_id == file_id) {
LeaveCriticalSection(&list_cs);
return true; // plugin already registered
}
@@ -478,31 +482,31 @@ bool RegisterForFileListing(int file_id, const char *fl_name, DWORD version, boo
// allow multiple registration of same plugin only if new plugin not automatically registered
// if multiple registration of an auto registered plugin occurs, use newest file id and version
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- if(strcmp(update_list.current()->update.szComponentName, fl_name) == 0) {
+ for(int i=0; i<update_list.getCount(); ++i) {
+ if(strcmp(update_list[i].update.szComponentName, fl_name) == 0) {
if(!auto_register) {
- update_list.erase();
+ update_list.remove(i);
break;
}
- if(update_list.current()->auto_register) {
- update_list.current()->file_id = file_id; // in case plugin file id changes (i.e. scan from xml data will overwrite settings read from db on startup)
+ if(update_list[i].auto_register) {
+ update_list[i].file_id = file_id; // in case plugin file id changes (i.e. scan from xml data will overwrite settings read from db on startup)
char version_str[16];
- update_list.current()->update.pbVersion = (BYTE *)safe_strdup(CreateVersionString(version, version_str));
- update_list.current()->update.cpbVersion = strlen(version_str);
+ update_list[i].update.pbVersion = (BYTE *)safe_strdup(CreateVersionString(version, version_str));
+ update_list[i].update.cpbVersion = (int)strlen(version_str);
}
LeaveCriticalSection(&list_cs);
// plugin already registered - set file id if AUTOREGISTER
- if(update_list.current()->update.szUpdateURL && strcmp(update_list.current()->update.szUpdateURL, UPDATER_AUTOREGISTER) == 0) {
- update_list.current()->file_id = file_id;
+ if(update_list[i].update.szUpdateURL && strcmp(update_list[i].update.szUpdateURL, UPDATER_AUTOREGISTER) == 0) {
+ update_list[i].file_id = file_id;
char *buff = (char *)safe_alloc(strlen(MIM_DOWNLOAD_URL_PREFIX) + 9);
sprintf(buff, MIM_DOWNLOAD_URL_PREFIX "%d", file_id);
- update_list.current()->update.szUpdateURL = buff;
- update_list.current()->shortName = safe_strdup(update_list.current()->update.szComponentName);
+ update_list[i].update.szUpdateURL = buff;
+ update_list[i].shortName = safe_strdup(update_list[i].update.szComponentName);
- if(update_list.current()->update.szBetaVersionURL) {
- update_list.current()->update_options.fixed = false;
- LoadUpdateOptions(update_list.current()->update.szComponentName, &update_list.current()->update_options);
+ if(update_list[i].update.szBetaVersionURL) {
+ update_list[i].update_options.fixed = false;
+ LoadUpdateOptions(update_list[i].update.szComponentName, &update_list[i].update_options);
}
}
return false;
@@ -519,7 +523,7 @@ bool RegisterForFileListing(int file_id, const char *fl_name, DWORD version, boo
update_internal.update.szComponentName = safe_strdup(fl_name);
update_internal.update.pbVersion = (BYTE *)safe_strdup(CreateVersionString(version, version_str));
- update_internal.update.cpbVersion = strlen(version_str);
+ update_internal.update.cpbVersion = (int)strlen(version_str);
buff = (char *)safe_alloc(strlen(MIM_DOWNLOAD_URL_PREFIX) + 9);
sprintf(buff, MIM_DOWNLOAD_URL_PREFIX "%d", file_id);
@@ -529,7 +533,7 @@ bool RegisterForFileListing(int file_id, const char *fl_name, DWORD version, boo
buff = (char *)safe_alloc(strlen("class=\"fileNameHeader\">") + strlen(fl_name) + 2);
sprintf(buff, "class=\"fileNameHeader\">%s ", fl_name);
update_internal.update.pbVersionPrefix = (BYTE *)buff;
- update_internal.update.cpbVersionPrefix = strlen(buff);
+ update_internal.update.cpbVersionPrefix = (int)strlen(buff);
buff = (char *)safe_alloc(strlen(MIM_VIEW_URL_PREFIX) + 9);
sprintf(buff, MIM_VIEW_URL_PREFIX "%d", file_id);
@@ -545,7 +549,7 @@ bool RegisterForFileListing(int file_id, const char *fl_name, DWORD version, boo
LoadUpdateOptions(update_internal.update.szComponentName, &update_internal.update_options);
EnterCriticalSection(&list_cs);
- update_list.push_back(update_internal);
+ update_list.insert(new UpdateInternal(update_internal));
LeaveCriticalSection(&list_cs);
return true;
@@ -611,9 +615,9 @@ INT_PTR Register(WPARAM wParam, LPARAM lParam) {
// remove registered plugin if already there
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- if(strcmp(update_list.current()->update.szComponentName, update->szComponentName) == 0) {
- update_list.erase();
+ for(int i=0; i<update_list.getCount(); ++i) {
+ if(strcmp(update_list[i].update.szComponentName, update->szComponentName) == 0) {
+ update_list.remove(i--);
break;
}
}
@@ -643,7 +647,7 @@ INT_PTR Register(WPARAM wParam, LPARAM lParam) {
char *buff = (char *)safe_alloc(strlen("class=\"fileNameHeader\">") + strlen(update->szComponentName) + 2);
sprintf(buff, "class=\"fileNameHeader\">%s ", update->szComponentName);
update_internal.update.pbVersionPrefix = (BYTE *)buff;
- update_internal.update.cpbVersionPrefix = strlen(buff);
+ update_internal.update.cpbVersionPrefix = (int)strlen(buff);
update_internal.shortName = safe_strdup(update->szComponentName);
} else {
@@ -668,7 +672,7 @@ INT_PTR Register(WPARAM wParam, LPARAM lParam) {
LoadUpdateOptions(update_internal.update.szComponentName, &update_internal.update_options);
EnterCriticalSection(&list_cs);
- update_list.push_back(update_internal);
+ update_list.insert(new UpdateInternal(update_internal));
LeaveCriticalSection(&list_cs);
//if(strcmp(update_internal.update.szComponentName, "My Details") == 0) {
@@ -684,9 +688,9 @@ INT_PTR RegisterFL(WPARAM wParam, LPARAM lParam) {
// remove registered plugin if already there
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- if(strcmp(update_list.current()->update.szComponentName, pluginInfo->shortName) == 0) {
- update_list.erase();
+ for(int i=0; i<update_list.getCount(); ++i) {
+ if(strcmp(update_list[i].update.szComponentName, pluginInfo->shortName) == 0) {
+ update_list.remove(i);
break;
}
}
@@ -702,9 +706,9 @@ INT_PTR Unregister(WPARAM wParam, LPARAM lParam) {
// remove registered plugin if found
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- if(strcmp(update_list.current()->update.szComponentName, szComponentName) == 0) {
- update_list.erase();
+ for(int i=0; i<update_list.getCount(); ++i) {
+ if(strcmp(update_list[i].update.szComponentName, szComponentName) == 0) {
+ update_list.remove(i);
break;
}
}
@@ -774,26 +778,28 @@ INT_PTR EnableStatusControl(WPARAM wParam, LPARAM lParam) {
INT_PTR IsUpdateSupported(WPARAM wParam, LPARAM lParam) {
char *szComponentName = (char *)lParam;
+ bool res = false;
EnterCriticalSection(&list_cs);
- for(update_list.reset(); update_list.current(); update_list.next()) {
- if(strcmp(update_list.current()->update.szComponentName, szComponentName) == 0) {
- return TRUE;
+ for(int i=0; i<update_list.getCount(); ++i) {
+ if(strcmp(update_list[i].update.szComponentName, szComponentName) == 0) {
+ res = true;
+ break;
}
}
LeaveCriticalSection(&list_cs);
- return FALSE;
+ return res;
}
int ServicesPreShutdown(WPARAM wParam, LPARAM lParam) {
+ Netlib_Shutdown(hNetlibHttp);
KillProgressWindowThread();
return 0;
}
HANDLE hEventPreShutDown, hEventServicesModulesLoaded;
void InitServices() {
- InitAlternateShortNameMap();
-
+
InitializeCriticalSection(&list_cs);
int i = 0;
@@ -829,11 +835,6 @@ void DeinitServices() {
if(daily_timer_id) KillTimer(0, daily_timer_id);
- if(hUpdateThread) {
- WaitForSingleObject(hUpdateThread, INFINITE);
- CloseHandle(hUpdateThread);
- }
-
DestroyHookableEvent(hStartupDone);
for(int i = 0; i < NUM_SERVICES; i++)
@@ -841,7 +842,7 @@ void DeinitServices() {
DestroyServiceFunction(hService[i]);
DeleteCriticalSection(&list_cs);
- update_list.clear();
+ update_list.destroy();
}