Example #1
0
static void GetList(void *)
{
	TCHAR tszTempPath[MAX_PATH];
	DWORD dwLen = GetTempPath(_countof(tszTempPath), tszTempPath);
	if (tszTempPath[dwLen-1] == '\\')
		tszTempPath[dwLen-1] = 0;

	ptrT updateUrl( GetDefaultUrl()), baseUrl;
	SERVLIST hashes(50, CompareHashes);
	if (!ParseHashes(updateUrl, baseUrl, hashes)) {
		hListThread = NULL;
		return;
	}

	FILELIST *UpdateFiles = new FILELIST(20);
	VARST dirname(_T("%miranda_path%"));

	for (int i=0; i < hashes.getCount(); i++) {
		ServListEntry &hash = hashes[i];

		TCHAR tszPath[MAX_PATH];
		mir_sntprintf(tszPath, _countof(tszPath), _T("%s\\%s"), dirname, hash.m_name);

		if (GetFileAttributes(tszPath) == INVALID_FILE_ATTRIBUTES) {
			FILEINFO *FileInfo = new FILEINFO;
			FileInfo->bDeleteOnly = FALSE;
			// copy the relative old name
			_tcsncpy(FileInfo->tszOldName, hash.m_name, _countof(FileInfo->tszOldName));
			_tcsncpy(FileInfo->tszNewName, hash.m_name, _countof(FileInfo->tszNewName));

			TCHAR tszFileName[MAX_PATH];
			_tcsncpy(tszFileName, _tcsrchr(tszPath, L'\\') + 1, _countof(tszFileName));
			TCHAR *tp = _tcschr(tszFileName, L'.'); *tp = 0;

			TCHAR tszRelFileName[MAX_PATH];
			_tcsncpy(tszRelFileName, hash.m_name, MAX_PATH);
			tp = _tcsrchr(tszRelFileName, L'.'); if (tp) *tp = 0;
			tp = _tcschr(tszRelFileName, L'\\'); if (tp) tp++; else tp = tszRelFileName;
			_tcslwr(tp);

			mir_sntprintf(FileInfo->File.tszDiskPath, _countof(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, tszFileName);
			mir_sntprintf(FileInfo->File.tszDownloadURL, _countof(FileInfo->File.tszDownloadURL), _T("%s/%s.zip"), baseUrl, tszRelFileName);
			for (tp = _tcschr(FileInfo->File.tszDownloadURL, '\\'); tp != 0; tp = _tcschr(tp, '\\'))
				*tp++ = '/';
			FileInfo->File.CRCsum = hash.m_crc;
			// Deselect all plugins by default
			FileInfo->bEnabled = false;
			UpdateFiles->insert(FileInfo);
		}
	}

	// Show dialog
	if (UpdateFiles->getCount() == 0) {
		ShowPopup(TranslateT("Plugin Updater"), TranslateT("List is empty."), POPUP_TYPE_INFO);
		delete UpdateFiles;
	}
	else CallFunctionAsync(LaunchListDialog, UpdateFiles);

	hListThread = NULL;
}
Example #2
0
static void GetList(void *)
{
	char szKey[64] = {0};
	
	TCHAR tszTempPath[MAX_PATH];
	DWORD dwLen = GetTempPath(SIZEOF(tszTempPath), tszTempPath);
	if (tszTempPath[dwLen-1] == '\\')
		tszTempPath[dwLen-1] = 0;

	ptrT updateUrl( GetDefaultUrl()), baseUrl;
	SERVLIST hashes(50, CompareHashes);
	if (!ParseHashes(updateUrl, baseUrl, hashes)) {
		hListThread = NULL;
		return;
	}

	FILELIST *UpdateFiles = new FILELIST(20);
	TCHAR *dirname = Utils_ReplaceVarsT(_T("%miranda_path%"));

	for (int i=0; i < hashes.getCount(); i++) {
		ServListEntry &hash = hashes[i];

		TCHAR tszPath[MAX_PATH];
		mir_sntprintf(tszPath, SIZEOF(tszPath), _T("%s\\%s"), dirname, hash.m_name);

		if (GetFileAttributes(tszPath) != DWORD(-1))
			continue;

		FILEINFO *FileInfo = new FILEINFO;
		FileInfo->bDeleteOnly = FALSE;
		_tcscpy(FileInfo->tszOldName, hash.m_name); // copy the relative old name
		_tcscpy(FileInfo->tszNewName, hash.m_name);

		TCHAR tszFileName[MAX_PATH];
		_tcscpy(tszFileName, _tcsrchr(tszPath, L'\\') + 1);
		TCHAR *tp = _tcschr(tszFileName, L'.'); *tp = 0;

		TCHAR tszRelFileName[MAX_PATH];
		_tcscpy(tszRelFileName, hash.m_name);
		tp = _tcsrchr(tszRelFileName, L'.'); if (tp) *tp = 0;
		tp = _tcschr(tszRelFileName, L'\\'); if (tp) tp++; else tp = tszRelFileName;
		_tcslwr(tp);

		mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, tszFileName);
		mir_sntprintf(FileInfo->File.tszDownloadURL, SIZEOF(FileInfo->File.tszDownloadURL), _T("%s/%s.zip"), baseUrl, tszRelFileName);
		for (tp = _tcschr(FileInfo->File.tszDownloadURL, '\\'); tp != 0; tp = _tcschr(tp, '\\'))
			*tp++ = '/';
		FileInfo->File.CRCsum = hash.m_crc;
		UpdateFiles->insert(FileInfo);
	}

	mir_free(dirname);

	// Show dialog
	if (UpdateFiles->getCount() == 0) {
		if (!opts.bSilent)
			ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("List is empty."), 2, 0);
		delete UpdateFiles;
	}
	else CallFunctionAsync(LaunchListDialog, UpdateFiles);

	hListThread = NULL;
}