From f43cfc59f5a300a040b19d36f090e4f4816fcbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Fri, 2 Aug 2013 15:07:20 +0000 Subject: PluginUpdater: one fix git-svn-id: http://svn.miranda-ng.org/main/trunk@5551 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/PluginUpdater/src/Utils.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'plugins/PluginUpdater/src/Utils.cpp') diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 2b57022b51..7d6d8c754d 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -376,20 +376,29 @@ void CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHig DoCheck(true); } -void InitTimer(bool lastSuccess) +void InitTimer(int type) { 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); + switch (type) { + case 0: // default, plan next check relative to last check + { + 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 + interval -= (now - was) * 1000; + if (interval <= 0) + interval = 1000; // no last update or too far in the past -> do it now + break; + } + case 1: // options changed, use set interval from now + break; + case 2: // failed last check, check again in two hours + interval = 1000 * 60 * 60 * 2; + break; + } _int64 qwDueTime = -10000i64 * interval; -- cgit v1.2.3