[mono/monodevelop] 94e25c4a: Bug 2577 - Updater is visible but does nothing when implementation not found

"Therzok ([email protected])" <[email protected]> Sun, 24 Nov 2013 17:14:10 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <000001428b1aad07-414f49b9-a7e4-4606-9a4f-4545b3904e65-000000@email.amazonses.com>
   Branch: refs/heads/bug2577
     Home: https://github.com/mono/monodevelop
  Compare: https://github.com/mono/monodevelop/commit/94e25c4a02d2

   Commit: 94e25c4a02d23790390324fdc8eb1e49027e28c9
   Author: Therzok <[email protected]> (Therzok)
     Date: 2013-11-24 17:12:50 GMT
      URL: https://github.com/mono/monodevelop/commit/94e25c4a02d23790390324fdc8eb1e49027e28c9

Bug 2577 - Updater is visible but does nothing when implementation not found

Note: this is a hack, I couldn't find a way to determine if we have an
IDE updater.

Changed paths:
  M main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateCheckHandler.cs
  M main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateService.cs

Modified: main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateCheckHandler.cs
===================================================================
@@ -49,6 +49,11 @@ protected override void Run ()
 		{
 			UpdateService.CheckForUpdates ();
 		}
+
+		protected override void Update (CommandInfo info)
+		{
+			info.Visible = UpdateService.HasRegisteredIDEUpdaters;
+		}
 	}
 }
 

Modified: main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateService.cs
===================================================================
@@ -36,6 +36,7 @@ namespace MonoDevelop.Ide.Updater
 	public static class UpdateService
 	{
 		static readonly TimeSpan AutoUpdateSpan = TimeSpan.FromDays (3);
+		static readonly string updaterPath = "/MonoDevelop/Ide/Updater/UpdateHandlers";
 
 		static UpdateService ()
 		{
@@ -47,6 +48,14 @@ static void ScheduleUpdateRun ()
 		{
 			new Timer (_ => CheckForUpdates (true), null, AutoUpdateSpan, AutoUpdateSpan);
 		}
+
+		public static bool HasRegisteredIDEUpdaters {
+			get {
+				var handlers = AddinManager.GetExtensionObjects (updaterPath);
+				// Do not include Addin Updater in this.
+				return handlers.Length > 1;
+			}
+		}
 		
 		public static bool AutoCheckForUpdates {
 			get {
@@ -132,13 +141,11 @@ static void CheckForUpdates (bool automatic)
 		{
 			PropertyService.Set ("MonoDevelop.Ide.AddinUpdater.LastCheck", DateTime.Now);
 			PropertyService.SaveProperties ();
-			var handlers = AddinManager.GetExtensionObjects ("/MonoDevelop/Ide/Updater/UpdateHandlers");
+			var handlers = AddinManager.GetExtensionObjects (updaterPath);
 			
 			IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetBackgroundProgressMonitor ("Looking for updates", "md-software-update"); 
 
-			Thread t = new Thread (delegate () {
-				CheckUpdates (mon, handlers, automatic);
-			});
+			Thread t = new Thread (() => CheckUpdates (mon, handlers, automatic));
 			t.Name = "Addin updater";
 			t.Start ();
 		}


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches