+ private void OnCheckFinished(object sender, bool updaterequired)
+ {
+
+ Log.InfoFormat("Upgrade check finished. Need Upgrade: {0}", updaterequired);
+ if (_manualUpgradeCheck)
+ {
+ _manualUpgradeCheck = false;
+ if (!updaterequired)
+ //Sparkle raises events on a background thread
+ Execute.OnUIThread(()=>
+ ShowBalloonFor(new Notification{Title="Pithos+ is up to date",Message="You have the latest Pithos+ version. No update is required"}));
+ }
+ }
+
+ private void OnUpgradeDetected(object sender, UpdateDetectedEventArgs e)
+ {
+ Log.InfoFormat("Update detected {0}",e.LatestVersion);
+ }
+
+ public void CheckForUpgrade()
+ {
+ ShowBalloonFor(new Notification{Title="Checking for upgrades",Message="Contacting the server to retrieve the latest Pithos+ version."});
+ _sparkle.StopLoop();
+ _sparkle.updateDetected -= OnUpgradeDetected;
+ _sparkle.checkLoopFinished -= OnCheckFinished;
+ _sparkle.Dispose();
+
+ _manualUpgradeCheck = true;
+ InitializeSparkle();
+ _sparkle.StartLoop(true,true,Settings.UpdateCheckInterval);
+ }
+
+ private void InitializeSparkle()
+ {
+ _sparkle = new Sparkle(Settings.UpdateUrl);
+ _sparkle.updateDetected += OnUpgradeDetected;
+ _sparkle.checkLoopFinished += OnCheckFinished;
+ _sparkle.ShowDiagnosticWindow = Settings.UpdateDiagnostics;
+ }