summaryrefslogtreecommitdiff
path: root/plugins/PluginUpdater/src/Utils.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-08-02 14:10:10 +0000
committerRobert Pösel <robyer@seznam.cz>2013-08-02 14:10:10 +0000
commit0d29ccd59beb6b7493aaa1a14ef7f6c40b5174df (patch)
tree09e14fe31c400c97649b1250a3bc277114342b5b /plugins/PluginUpdater/src/Utils.cpp
parent0517871b91bd2e567a8fe294344225ec9247a632 (diff)
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
Diffstat (limited to 'plugins/PluginUpdater/src/Utils.cpp')
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp19
1 files changed, 12 insertions, 7 deletions
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);
}
}