diff options
author | Lluis Sanchez Gual <lluis@novell.com> | 2011-04-13 13:14:22 +0400 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@novell.com> | 2011-04-13 13:14:22 +0400 |
commit | c3a3b2e047f4303c8fae92e16e5f36b1e03be3ba (patch) | |
tree | fe4356df231426636678d9cff4af2ca7c4e0d75e /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater | |
parent | 5133068655b651ddeed4fafe71a039a87fc1933b (diff) |
Add support for conditional update alerts
Updates now have a rank: Important, Normal and Minor. Important
updates are shown in the updater dialog. Normal updates are notified
in the status bar. Minor updates are not notified (but shown in the
add-in manager).
Alerts can also be conditional, based on the presence of 'update
tags'.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater')
3 files changed, 128 insertions, 2 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateRank.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateRank.cs new file mode 100644 index 0000000000..5abdd25336 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateRank.cs @@ -0,0 +1,37 @@ +// +// UpdateRank.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; + +namespace MonoDevelop.Ide.Updater +{ + enum UpdateRank + { + Important, + Normal, + Minor + } +} + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateService.cs index d1f6f32228..db6eff4042 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateService.cs @@ -48,6 +48,7 @@ namespace MonoDevelop.Ide.Updater const string updateLevelKey = "AppUpdate.UpdateLevel"; static UpdateInfo[] updateInfos; + static List<string> tags = new List<string> (); static UpdateInfo[] LoadUpdateInfos () { @@ -75,6 +76,25 @@ namespace MonoDevelop.Ide.Updater static UpdateService () { updateInfos = LoadUpdateInfos (); + AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/UpdateTags", OnTagExtensionChanged); + } + + static void OnTagExtensionChanged (object sender, ExtensionNodeEventArgs args) + { + if (args.Change == ExtensionChange.Add) + tags.Add (args.ExtensionNode.Id); + else + tags.Remove (args.ExtensionNode.Id); + } + + public static void AddUpdateTag (string tag) + { + tags.Add (tag); + } + + public static void RemoteUpdateTag (string tag) + { + tags.Remove (tag); } public static bool CanUpdate { @@ -288,8 +308,8 @@ namespace MonoDevelop.Ide.Updater FilterOldVersions (list); foreach (var ventry in list) { var entry = ventry; - string notify = entry.Addin.Properties.GetPropertyValue ("NotifyUpdate").ToLower (); - if (notify != "yes" && notify != "true") + UpdateRank rank = GetUpdateRank (entry.Addin.Properties.GetPropertyValue ("UpdateRank")); + if (rank != UpdateRank.Important) continue; string sdate = entry.Addin.Properties.GetPropertyValue ("ReleaseDate"); DateTime date; @@ -394,5 +414,39 @@ namespace MonoDevelop.Ide.Updater }); return monitor.AsyncOperation; } + + /// <summary> + /// Parses an update rank string + /// </summary> + /// <returns> + /// The update rank + /// </returns> + /// <param name='updateRankString'> + /// Update rank string. + /// </param> + /// <remarks> + /// This method parses an update rank string. If the rank is conditioned to an update tag, it will + /// check the presence of the tag + /// </remarks> + internal static UpdateRank GetUpdateRank (string updateRankString) + { + string slevel = null; + foreach (string cond in updateRankString.Split (new char[] {' '}, StringSplitOptions.RemoveEmptyEntries)) { + int i = cond.IndexOf (':'); + if (i == -1) { + slevel = cond; + break; + } + if (tags.Contains (cond.Substring (0, i))) { + slevel = cond.Substring (i+1); + break; + } + } + UpdateRank level; + if (slevel != null && Enum.TryParse<UpdateRank> (slevel, out level)) + return level; + else + return UpdateRank.Normal; + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateTagExtensionNode.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateTagExtensionNode.cs new file mode 100644 index 0000000000..be461f0922 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Updater/UpdateTagExtensionNode.cs @@ -0,0 +1,35 @@ +// +// UpdateTagExtensionNode.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Mono.Addins; + +namespace MonoDevelop.Ide.Updater +{ + class UpdateTagExtensionNode: ExtensionNode + { + } +} + |