diff options
| -rw-r--r-- | plugins/PluginUpdater/src/Common.h | 2 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 4 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 4 | ||||
| -rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 25 | 
4 files changed, 22 insertions, 13 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index 4caf660fcc..846d8b01ba 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -180,7 +180,7 @@ void  ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType)  void  __stdcall RestartMe(void*);
  void  __stdcall OpenPluginOptions(void*);
  BOOL  AllowUpdateOnStartup();
 -void  InitTimer(bool lastSuccess = true);
 +void  InitTimer(int type = 0);
  INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam);
  INT_PTR ShowListCommand(WPARAM wParam,LPARAM lParam);
 diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 8c2ff2bd45..197987898b 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -142,7 +142,7 @@ LBL_Exit:  	opts.bForceRedownload = false;
  	db_unset(NULL, MODNAME, "ForceRedownload");
 -	db_set_b(NULL, MODNAME, "RestartCount", 2);
 +	db_set_b(NULL, MODNAME, "RestartCount", 5);
  	CallFunctionAsync(RestartMe, 0);
  	goto LBL_Exit;
  }
 @@ -560,7 +560,7 @@ static void CheckUpdates(void *)  		}
  		else CallFunctionAsync(LaunchDialog, UpdateFiles);
  	}
 -	InitTimer(success);	
 +	InitTimer(success ? 0 : 2);	
  	hashes.destroy();
  	hCheckThread = NULL;
 diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index 1368f4cbbb..bc5be97382 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -142,14 +142,14 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA  				opts.bPeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE));
 -				InitTimer();
 -
  				db_set_b(NULL, MODNAME, "UpdateOnStartup", opts.bUpdateOnStartup);
  				db_set_b(NULL, MODNAME, "OnlyOnceADay", opts.bOnlyOnceADay);
  				db_set_b(NULL, MODNAME, "UpdateOnPeriod", opts.bUpdateOnPeriod);
  				db_set_b(NULL, MODNAME, "PeriodMeasure", opts.bPeriodMeasure);
  				db_set_dw(NULL, MODNAME, "Period", opts.Period);
 +				InitTimer(1);
 +
  				if ( IsDlgButtonChecked(hwndDlg, IDC_STABLE))
  					db_set_s(NULL, MODNAME, "UpdateURL", DEFAULT_UPDATE_URL);
  				else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK))
 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;
  | 
