示例#1
0
void DeinitServices() {
	UnhookEvent(hEventPreShutDown);
	UnhookEvent(hEventServicesModulesLoaded);
	UnhookEvent(hEventServicesModulesLoaded2);

	if(daily_timer_id) KillTimer(0, daily_timer_id);

	DestroyHookableEvent(hStartupDone);

	for(int i = 0; i < NUM_SERVICES; i++)
		if(hService[i])
			DestroyServiceFunction(hService[i]);

	DeleteCriticalSection(&list_cs);
	update_list.destroy();
}
示例#2
0
// returns true if any downloaded dll is active
bool DownloadUpdates(UpdateList &todo, FilenameMap *map, bool dlls_only) {

	bool dll_enabled_or_langpack = false;

	bool use_popup = options.popup_notify && ArePopupsEnabled();
	
	// iterate through the updates we need to check

	if (use_popup) 
	{
		ShowPopup(0, TranslateT("Downloading Updates"), _T(""), POPFLAG_SAVEHWND, -1);
	} 
	else 
	{
		CreateProgressWindow();

		SendMessage(hwndProgress, WM_SETTEXT, 0, (LPARAM)TranslateT("Progress - Downloading updates..."));
		SendMessage(hwndProgress, WMU_SETMESSAGE, (WPARAM)TranslateT("Downloading"), 0);
	}

	TCHAR msg[512];
	TCHAR *temp_str;
	bool a_download_succeeded = false;

	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(dbv.pszVal && strcmp(dbv.pszVal, todo[index].newVersion) == 0)
				download = false;
			else
				DBDeleteContactSetting(0, "Updater", stored_setting);
			DBFreeVariant(&dbv);
		}

		if(download) 
		{
			mir_sntprintf(msg, SIZEOF(msg), TranslateT("Downloading plugin: %s"), (temp_str = GetTString(todo[index].update.szComponentName)));
			mir_free(temp_str);
		} 
		else 
		{
			mir_sntprintf(msg, SIZEOF(msg), TranslateT("Skipping plugin: %s"), (temp_str = GetTString(todo[index].update.szComponentName)));
			mir_free(temp_str);
		}

		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) 
		{
			bool got_file = false;
			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) 
			{
				a_download_succeeded = true;
				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)
                        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 
				{
					dll_enabled_or_langpack = true;
				}
			}
		}

		if (!use_popup && hwndProgress == 0)
		{
			RemoveFolder(options.temp_folder);
			break; // user closed progress window - cancel
		}
	}
	

	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(!a_download_succeeded) 
	{
		for(int i = 0; i < todo.getCount(); ++i)
			free(todo[i].newVersion);
		todo.destroy();
	}

	return dll_enabled_or_langpack;
}