コード例 #1
0
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) 
		{
			int file_id = FindFileID(update_list[i].update.szComponentName, MC_PLUGINS, 0);
			if (file_id == -1)
				file_id = FindFileID(update_list[i].update.szComponentName, MC_LOCALIZATION, 0);
			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) 
				{
					update_list[i].update_options.fixed = false;
					LoadUpdateOptions(update_list[i].update.szComponentName, &update_list[i].update_options);
				}
			}
		}
	}
}
コード例 #2
0
ファイル: services.cpp プロジェクト: TonyAlloa/miranda-dev
INT_PTR Register(WPARAM wParam, LPARAM lParam) {

	Update *update = (Update *)lParam;
	UpdateInternal update_internal = {0};

	// remove registered plugin if already there
	EnterCriticalSection(&list_cs);
	int i = FindFileInList(update->szComponentName);
	if (i >= 0) update_list.remove(i);
	LeaveCriticalSection(&list_cs);

	if(update->szComponentName == 0 || update->pbVersion == 0)
		return 1;
	if(update->szVersionURL == 0 && (update->szUpdateURL == 0 || strcmp(update->szUpdateURL, UPDATER_AUTOREGISTER) != 0) && update->szBetaVersionURL == 0) // both betas and normal updates disabled - complain
		return 1;

	update_internal.cat = MC_UNKNOWN;

	// duplicate all the data...sigh
	update_internal.update.szComponentName = safe_strdup(update->szComponentName);

	if(update->szVersionURL) update_internal.update.szVersionURL = safe_strdup(update->szVersionURL);
	if(update->szUpdateURL) update_internal.update.szUpdateURL = safe_strdup(update->szUpdateURL);

	// if revision update url is from the fl, and we can find the file_id, use xml data if available
	// otherwise set this to -1 to check url's specified
	if(update_internal.update.szUpdateURL)
		update_internal.file_id = CheckForFileID(update_internal.update.szUpdateURL, update_internal.update.szVersionURL, update_internal.update.szComponentName);
	else
		update_internal.file_id = -1;
	
	if(update_internal.file_id != -1) { // ensure correct format for file listing version string search data
		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 = (int)strlen(buff);

		update_internal.shortName = safe_strdup(update->szComponentName);
	} else {
		if(update->pbVersionPrefix) update_internal.update.pbVersionPrefix = safe_bytedup(update->pbVersionPrefix, update->cpbVersionPrefix);
		update_internal.update.cpbVersionPrefix = update->cpbVersionPrefix;
	}

	// leave beta alone
	if(update->szBetaVersionURL) update_internal.update.szBetaVersionURL = safe_strdup(update->szBetaVersionURL);
	if(update->pbBetaVersionPrefix) update_internal.update.pbBetaVersionPrefix = safe_bytedup(update->pbBetaVersionPrefix, update->cpbBetaVersionPrefix);
	update_internal.update.cpbBetaVersionPrefix = update->cpbBetaVersionPrefix;
	if(update->szBetaUpdateURL) update_internal.update.szBetaUpdateURL = safe_strdup(update->szBetaUpdateURL);

	update_internal.update.pbVersion = safe_bytedup(update->pbVersion, update->cpbVersion);
	update_internal.update.cpbVersion = update->cpbVersion;

	if(update->cbSize > UPDATE_V1_SIZE && update->szBetaChangelogURL) 
		update_internal.update.szBetaChangelogURL = safe_strdup(update->szBetaChangelogURL);

	update_internal.update_options.fixed = (update->szVersionURL == 0 || strcmp(update->szUpdateURL, UPDATER_AUTOREGISTER) == 0 || update->szBetaVersionURL == 0); // set 'fixed' flag
	update_internal.update_options.use_beta = (update->szVersionURL == 0 || strcmp(update->szUpdateURL, UPDATER_AUTOREGISTER) == 0);
	LoadUpdateOptions(update_internal.update.szComponentName, &update_internal.update_options);

	EnterCriticalSection(&list_cs);
	update_list.insert(new UpdateInternal(update_internal));
	LeaveCriticalSection(&list_cs);

	//if(strcmp(update_internal.update.szComponentName, "My Details") == 0) {
	//	MessageBox(0, "My Details registered", "msg", MB_OK);
	//}

	return 0;
}
コード例 #3
0
ファイル: services.cpp プロジェクト: TonyAlloa/miranda-dev
bool RegisterForFileListing(int file_id, const char *fl_name, DWORD version, bool auto_register, const Category cat) 
{
	// 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);
	int i = FindFileInList(fl_name);
	if (i >= 0 && !auto_register)
		update_list.remove(i);
	else if (i >= 0)
	{
		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[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[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[i].update.szUpdateURL = buff;
			update_list[i].shortName = safe_strdup(update_list[i].update.szComponentName);

			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;
	}
	LeaveCriticalSection(&list_cs);

	UpdateInternal update_internal = {0};
	char version_str[16];
	char *buff;

	update_internal.cat = cat;
	update_internal.shortName = safe_strdup(fl_name);

	update_internal.update.szComponentName = safe_strdup(fl_name);
	update_internal.update.pbVersion = (BYTE *)safe_strdup(CreateVersionString(version, 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);
	update_internal.update.szUpdateURL = buff;

	///////// only used when not using the xml backend ////////////	
	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 = (int)strlen(buff);

	buff = (char *)safe_alloc(strlen(MIM_VIEW_URL_PREFIX) + 9);
	sprintf(buff, MIM_VIEW_URL_PREFIX "%d", file_id);
	update_internal.update.szVersionURL = buff;
	///////////////////////////////////////////////////////////////

	// same as register, except for fileID
	update_internal.file_id = file_id;
	update_internal.auto_register = auto_register;
	update_internal.update_options.fixed = true;
	update_internal.update_options.use_beta = false;

	LoadUpdateOptions(update_internal.update.szComponentName, &update_internal.update_options);

	EnterCriticalSection(&list_cs);
	update_list.insert(new UpdateInternal(update_internal));
	LeaveCriticalSection(&list_cs);

	return true;
}