From 0d29ccd59beb6b7493aaa1a14ef7f6c40b5174df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Fri, 2 Aug 2013 14:10:10 +0000 Subject: PluginUpdater: - Fixed checking intervals - "check every xx" is now relative to last check, not to miranda start - Small cleanup - Version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@5550 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/PluginUpdater/src/Utils.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'plugins/PluginUpdater/src/Utils.cpp') diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 00c6715a7c..2b57022b51 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -122,7 +122,6 @@ void LoadOptions() opts.bUpdateOnPeriod = db_get_b(NULL, MODNAME, "UpdateOnPeriod", DEFAULT_UPDATEONPERIOD); 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); } @@ -244,9 +243,6 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes) continue; *p++ = 0; - if ( !opts.bUpdateIcons && !_strnicmp(str, "icons\\", 6)) - continue; - _strlwr(p); int dwCrc32; @@ -377,22 +373,31 @@ LONG PeriodToMilliseconds(const int period, BYTE& periodMeasure) void CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue) { - DoCheck(1); + DoCheck(true); } -void InitTimer() +void InitTimer(bool lastSuccess) { CancelWaitableTimer(Timer); if (opts.bUpdateOnPeriod) { LONG interval = PeriodToMilliseconds(opts.Period, opts.bPeriodMeasure); + time_t now = time(NULL); + time_t was = db_get_dw(NULL, MODNAME, "LastUpdate", 0); + + interval -= (now - was) * 1000; + if (interval <= 0) + interval = 1000; // no last update or too far in the past -> do it now + else if (!lastSuccess) + interval = 1000 * 60 * 60; // failed last check, check again in one hour + _int64 qwDueTime = -10000i64 * interval; LARGE_INTEGER li = {0}; li.LowPart = (DWORD) ( qwDueTime & 0xFFFFFFFF ); li.HighPart = (LONG) ( qwDueTime >> 32 ); - SetWaitableTimer(Timer, &li, interval, TimerAPCProc, NULL, 0); + SetWaitableTimer(Timer, &li, 0, TimerAPCProc, NULL, 0); } } -- cgit v1.2.3