From d5461e60cced301b7251e525f02b89c15198bbcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sat, 22 Jun 2013 21:49:33 +0000 Subject: PluginUpdater: - Don't notify unchecked files as updates when auto update check - Added new files source - development version with debug symbola - Some small improvements - Version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@5089 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/PluginUpdater/PluginUpdater_10.vcxproj | 2 ++ .../PluginUpdater/PluginUpdater_10.vcxproj.filters | 6 ++++++ plugins/PluginUpdater/res/Resource.rc | 18 +++++++++------- plugins/PluginUpdater/src/Common.h | 7 +++--- plugins/PluginUpdater/src/DlgUpdate.cpp | 25 +++++++++++++++------- plugins/PluginUpdater/src/Options.cpp | 13 ++++++++++- plugins/PluginUpdater/src/Utils.cpp | 8 ++++--- plugins/PluginUpdater/src/Version.h | 2 +- plugins/PluginUpdater/src/resource.h | 5 +++-- 9 files changed, 60 insertions(+), 26 deletions(-) diff --git a/plugins/PluginUpdater/PluginUpdater_10.vcxproj b/plugins/PluginUpdater/PluginUpdater_10.vcxproj index 17d47d8289..29035d8fae 100644 --- a/plugins/PluginUpdater/PluginUpdater_10.vcxproj +++ b/plugins/PluginUpdater/PluginUpdater_10.vcxproj @@ -231,7 +231,9 @@ + + diff --git a/plugins/PluginUpdater/PluginUpdater_10.vcxproj.filters b/plugins/PluginUpdater/PluginUpdater_10.vcxproj.filters index 2c656f6350..50f2cb5cb0 100644 --- a/plugins/PluginUpdater/PluginUpdater_10.vcxproj.filters +++ b/plugins/PluginUpdater/PluginUpdater_10.vcxproj.filters @@ -117,5 +117,11 @@ Resource Files + + Resource Files + + + Resource Files + \ No newline at end of file diff --git a/plugins/PluginUpdater/res/Resource.rc b/plugins/PluginUpdater/res/Resource.rc index df25b189e0..16a469c6e5 100644 --- a/plugins/PluginUpdater/res/Resource.rc +++ b/plugins/PluginUpdater/res/Resource.rc @@ -58,7 +58,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN END -IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 261, 181 +IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 261, 197 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 @@ -74,11 +74,12 @@ BEGIN CONTROL "",IDC_PERIODSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,92,56,10,15 COMBOBOX IDC_PERIODMEASURE,114,56,58,30,CBS_DROPDOWNLIST | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP CONTROL "Update icons",IDC_UPDATEICONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,198,10 - GROUPBOX "Files source",IDC_STATIC,1,93,253,82 + GROUPBOX "Files source",IDC_STATIC,1,93,253,96 CONTROL "Stable version",IDC_STABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,106,236,10 CONTROL "Development version (less stable)",IDC_TRUNK,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,121,236,10 - CONTROL "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,136,236,10 - EDITTEXT IDC_CUSTOMURL,11,150,234,16,ES_AUTOHSCROLL + CONTROL "Development version with debug symbols",IDC_TRUNK_SYMBOLS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,136,236,10 + CONTROL "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,11,151,236,10 + EDITTEXT IDC_CUSTOMURL,11,165,234,16,ES_AUTOHSCROLL END IDD_POPUP DIALOGEX 0, 0, 316, 182 @@ -148,18 +149,18 @@ END // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "..\\src\\resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -183,7 +184,7 @@ BEGIN IDD_OPT_UPDATENOTIFY, DIALOG BEGIN - BOTTOMMARGIN, 180 + BOTTOMMARGIN, 196 END IDD_LIST, DIALOG @@ -210,3 +211,4 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED + diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index 5628960b8c..9673cb8226 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -92,7 +92,7 @@ struct PopupDataText struct PlugOptions { - BYTE bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bUpdateIcons; + BYTE bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bUpdateIcons, bForceRedownload; BOOL bSilent, bDlgDld; BYTE bPeriodMeasure; @@ -106,8 +106,9 @@ struct PlugOptions #define DEFAULT_PERIOD 1 #define DEFAULT_PERIODMEASURE 1 -#define DEFAULT_UPDATE_URL "http://miranda-ng.org/distr/stable/x%platform%" -#define DEFAULT_UPDATE_URL_TRUNK "http://miranda-ng.org/distr/x%platform%" +#define DEFAULT_UPDATE_URL "http://miranda-ng.org/distr/stable/x%platform%" +#define DEFAULT_UPDATE_URL_TRUNK "http://miranda-ng.org/distr/x%platform%" +#define DEFAULT_UPDATE_URL_TRUNK_SYMBOLS "http://miranda-ng.now.im/pdb_x%platform%/" #define IDINFO 3 #define IDDOWNLOAD 4 diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 9c957d0f90..a82d8d368f 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -139,6 +139,9 @@ LBL_Exit: db_set_ts(NULL, "CList", "TitleText", _T("Miranda NG")); #endif + opts.bForceRedownload = false; + db_unset(NULL, MODNAME, "ForceRedownload"); + db_set_b(NULL, MODNAME, "RestartCount", 2); CallFunctionAsync(RestartMe, 0); goto LBL_Exit; @@ -414,11 +417,13 @@ static bool isValidExtension(const TCHAR *ptszFileName) return false; } -static void ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const TCHAR *tszBaseUrl, SERVLIST& hashes, OBJLIST *UpdateFiles) +static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const TCHAR *tszBaseUrl, SERVLIST& hashes, OBJLIST *UpdateFiles) { + int count = 0; + // skip updater's own folder if ( !_tcsicmp(tszFolder, tszRoot)) - return; + return count; TCHAR tszBuf[MAX_PATH]; mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\*"), tszFolder); @@ -426,7 +431,7 @@ static void ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, cons WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(tszBuf, &ffd); if (hFind == INVALID_HANDLE_VALUE) - return; + return count; do { if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { @@ -439,7 +444,7 @@ static void ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, cons mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName); if (0 != _tcsicmp(tszBuf, tszProfilePath)) - ScanFolder(tszBuf, cbBaseLen, level+1, tszBaseUrl, hashes, UpdateFiles); + count += ScanFolder(tszBuf, cbBaseLen, level+1, tszBaseUrl, hashes, UpdateFiles); continue; } @@ -483,7 +488,7 @@ static void ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, cons CalculateModuleHash(tszBuf, szMyHash); MyCRC = item->m_crc; - bHasNewVersion = strcmp(szMyHash, item->m_szHash) != 0; + bHasNewVersion = opts.bForceRedownload ? true : strcmp(szMyHash, item->m_szHash) != 0; } else { // file was marked for deletion, add it to the list anyway bHasNewVersion = true; @@ -517,11 +522,15 @@ static void ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, cons FileInfo->File.CRCsum = MyCRC; UpdateFiles->insert(FileInfo); + + if (!opts.bSilent || db_get_b(NULL, MODNAME "Files", StrToLower(_T2A(FileInfo->tszNewName)), true)) + count++; } // end compare versions } while (FindNextFile(hFind, &ffd) != 0); FindClose(hFind); + return count; } static void CheckUpdates(void *) @@ -536,13 +545,13 @@ static void CheckUpdates(void *) ptrT updateUrl( GetDefaultUrl()), baseUrl; SERVLIST hashes(50, CompareHashes); - if ( ParseHashes(updateUrl, baseUrl, hashes)) { + if (ParseHashes(updateUrl, baseUrl, hashes)) { FILELIST *UpdateFiles = new FILELIST(20); VARST dirname( _T("%miranda_path%")); - ScanFolder(dirname, lstrlen(dirname)+1, 0, baseUrl, hashes, UpdateFiles); + int count = ScanFolder(dirname, lstrlen(dirname)+1, 0, baseUrl, hashes, UpdateFiles); // Show dialog - if (UpdateFiles->getCount() == 0) { + if (count == 0) { if ( !opts.bSilent) ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("No updates found."), 2, 0); delete UpdateFiles; diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index 9f4d228139..56f3643ac1 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -70,6 +70,8 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA CheckDlgButton(hwndDlg, IDC_STABLE, TRUE); else if ( !strcmp(dbv.pszVal, DEFAULT_UPDATE_URL_TRUNK)) CheckDlgButton(hwndDlg, IDC_TRUNK, TRUE); + else if ( !strcmp(dbv.pszVal, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS)) + CheckDlgButton(hwndDlg, IDC_TRUNK_SYMBOLS, TRUE); else { CheckDlgButton(hwndDlg, IDC_CUSTOM, TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE); @@ -99,6 +101,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA } break; + case IDC_TRUNK_SYMBOLS: case IDC_TRUNK: case IDC_STABLE: case IDC_CUSTOM: @@ -159,7 +162,15 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL); else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK)) db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL_TRUNK); - else { + else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) { + ptrA oldUrl = db_get_sa(NULL, MODNAME, "UpdateURL"); + if (strcmp(oldUrl, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS)) { + opts.bForceRedownload = true; + db_set_b(NULL, MODNAME, "ForceRedownload", 1); + } + + db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL_TRUNK_SYMBOLS); + } else { char szUrl[100]; GetDlgItemTextA(hwndDlg, IDC_CUSTOMURL, szUrl, SIZEOF(szUrl)); db_set_s(NULL, MODNAME, "UpdateURL", szUrl); diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 0de79f2b10..040dc72319 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -122,6 +122,7 @@ void LoadOptions() opts.Period = db_get_dw(NULL, MODNAME, "Period", DEFAULT_PERIOD); opts.bPeriodMeasure = db_get_b(NULL, MODNAME, "PeriodMeasure", DEFAULT_PERIODMEASURE); opts.bUpdateIcons = db_get_b(NULL, MODNAME, "UpdateIcons", DEFAULT_UPDATEICONS); + opts.bForceRedownload = db_get_b(NULL, MODNAME, "ForceRedownload", 0); } ULONG crc32_table[256]; @@ -209,7 +210,8 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes) baseUrl = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)ptszUrl, (LPARAM)&dat); // Download version info - ShowPopup(NULL, TranslateT("Plugin Updater"), TranslateT("Downloading version info..."), 4, 0); + if (!opts.bSilent) + ShowPopup(NULL, TranslateT("Plugin Updater"), TranslateT("Checking new updates..."), 4, 0); FILEURL pFileUrl; mir_sntprintf(pFileUrl.tszDownloadURL, SIZEOF(pFileUrl.tszDownloadURL), _T("%s/hashes.zip"), baseUrl); @@ -219,8 +221,8 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes) BOOL ret = DownloadFile(pFileUrl.tszDownloadURL, pFileUrl.tszDiskPath, 0, nlc); Netlib_CloseHandle(nlc); - if (!ret) { - ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("An error occured while downloading the update."), 1, 0); + if (!ret && !opts.bSilent) { + ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("An error occured while checking new updates."), 1, 0); return false; } diff --git a/plugins/PluginUpdater/src/Version.h b/plugins/PluginUpdater/src/Version.h index f6ed8685b4..c32af45d56 100644 --- a/plugins/PluginUpdater/src/Version.h +++ b/plugins/PluginUpdater/src/Version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 1 -#define __BUILD_NUM 3 +#define __BUILD_NUM 4 #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM diff --git a/plugins/PluginUpdater/src/resource.h b/plugins/PluginUpdater/src/resource.h index df0fb846fe..20466bdc0c 100644 --- a/plugins/PluginUpdater/src/resource.h +++ b/plugins/PluginUpdater/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by e:\Projects\C++\MirandaNG\plugins\PluginUpdater\res\Resource.rc +// Used by D:\Development\Miranda NG\plugins\PluginUpdater\res\Resource.rc // #define IDI_MENU 101 #define IDD_UPDATE 102 @@ -60,7 +60,8 @@ #define IDC_CUSTOMURL 1042 #define IDC_STABLE 1043 #define IDC_TRUNK 1044 -#define IDC_CUSTOM 1045 +#define IDC_TRUNK_SYMBOLS 1045 +#define IDC_CUSTOM 1046 #define IDC_MSG_BOXES 40071 #define IDC_ERRORS 40072 #define IDC_INFO_MESSAGES 40073 -- cgit v1.2.3