[banshee] [Dap] Prioritize the different DAP addins
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Dap] Prioritize the different DAP addins
- Date: Fri, 13 Aug 2010 22:51:15 +0000 (UTC)
commit 8f88f623f80266ac4ef454714b088426126aed1f
Author: Alan McGovern <alan mcgovern gmail com>
Date: Sun Jul 18 16:16:04 2010 -0700
[Dap] Prioritize the different DAP addins
We can now better handle the case where a device can potentially be
loaded by two addins but one addin gives a much better experience.
.../Banshee.Dap.MassStorage.addin.xml | 2 +-
src/Dap/Banshee.Dap/Banshee.Dap.addin.xml | 2 +-
src/Dap/Banshee.Dap/Banshee.Dap.csproj | 1 +
src/Dap/Banshee.Dap/Banshee.Dap/DapPriorityNode.cs | 48 ++++++++++++++++++++
src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs | 12 +++--
src/Dap/Banshee.Dap/Makefile.am | 1 +
6 files changed, 60 insertions(+), 6 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage.addin.xml b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage.addin.xml
index 35566be..24b2f07 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage.addin.xml
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage.addin.xml
@@ -16,7 +16,7 @@
</Dependencies>
<Extension path="/Banshee/Dap/DeviceClass">
- <DeviceClass class="Banshee.Dap.MassStorage.MassStorageSource"/>
+ <DeviceClass class="Banshee.Dap.MassStorage.MassStorageSource" priority="-10"/>
</Extension>
<ExtensionPoint path="/Banshee/Dap/MassStorage/Device">
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.addin.xml b/src/Dap/Banshee.Dap/Banshee.Dap.addin.xml
index c02a83f..e8790b8 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.addin.xml
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.addin.xml
@@ -19,7 +19,7 @@
</Extension>
<ExtensionPoint path="/Banshee/Dap/DeviceClass">
- <ExtensionNode name="DeviceClass"/>
+ <ExtensionNode name="DeviceClass" type="Banshee.Dap.DapPriorityNode"/>
</ExtensionPoint>
</Addin>
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.csproj b/src/Dap/Banshee.Dap/Banshee.Dap.csproj
index 6a22637..e86783f 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.csproj
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.csproj
@@ -108,6 +108,7 @@
<Compile Include="Banshee.Dap\IPurchasedMusicSource.cs" />
<Compile Include="Banshee.Dap.Gui\PurchasedMusicActions.cs" />
<Compile Include="Banshee.Dap.Gui\LibrarySyncOptions.cs" />
+ <Compile Include="Banshee.Dap\DapPriorityNode.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Banshee.Dap.addin.xml">
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapPriorityNode.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapPriorityNode.cs
new file mode 100644
index 0000000..edd2f77
--- /dev/null
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapPriorityNode.cs
@@ -0,0 +1,48 @@
+//
+// DapPriorityNode.cs
+//
+// Author:
+// Alan McGovern <amcgovern novell com>
+//
+// Copyright (c) 2010 Alan McGovern
+//
+// 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 Banshee.Dap {
+
+ public class DapPriorityNode : TypeExtensionNode {
+
+ [NodeAttribute]
+ string priority;
+
+ public int Priority {
+ get { return string.IsNullOrEmpty (priority) ? 0 : int.Parse (priority); }
+ }
+
+ public DapPriorityNode ()
+ {
+
+ }
+ }
+}
+
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
index 9b1de00..543ff99 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
@@ -48,7 +48,7 @@ namespace Banshee.Dap
{
private Dictionary<string, DapSource> sources;
private List<DeviceCommand> unhandled_device_commands;
- private List<TypeExtensionNode> supported_dap_types;
+ private List<DapPriorityNode> supported_dap_types;
private bool initialized;
private object sync = new object ();
@@ -63,7 +63,7 @@ namespace Banshee.Dap
return;
sources = new Dictionary<string, DapSource> ();
- supported_dap_types = new List<TypeExtensionNode> ();
+ supported_dap_types = new List<DapPriorityNode> ();
AddinManager.AddExtensionNodeHandler ("/Banshee/Dap/DeviceClass", OnExtensionChanged);
@@ -83,11 +83,15 @@ namespace Banshee.Dap
private void OnExtensionChanged (object o, ExtensionNodeEventArgs args)
{
lock (sync) {
- TypeExtensionNode node = (TypeExtensionNode)args.ExtensionNode;
+ var node = (DapPriorityNode)args.ExtensionNode;
+ if (!node.Type.IsSubclassOf (typeof (DapSource)))
+ return;
if (args.Change == ExtensionChange.Add) {
Log.DebugFormat ("Dap support extension loaded: {0}", node.Addin.Id);
+
supported_dap_types.Add (node);
+ supported_dap_types.Sort ((left, right) => right.Priority.CompareTo (left.Priority));
if (initialized) {
// See if any existing devices are handled by this new DAP support
@@ -96,7 +100,7 @@ namespace Banshee.Dap
}
}
} else if (args.Change == ExtensionChange.Remove) {
- supported_dap_types.Remove (node);
+ supported_dap_types.Remove ((DapPriorityNode) args.ExtensionNode);
Queue<DapSource> to_remove = new Queue<DapSource> ();
foreach (DapSource source in sources.Values) {
diff --git a/src/Dap/Banshee.Dap/Makefile.am b/src/Dap/Banshee.Dap/Makefile.am
index ebb4383..864be76 100644
--- a/src/Dap/Banshee.Dap/Makefile.am
+++ b/src/Dap/Banshee.Dap/Makefile.am
@@ -12,6 +12,7 @@ SOURCES = \
Banshee.Dap.Gui/LibrarySyncOptions.cs \
Banshee.Dap.Gui/PurchasedMusicActions.cs \
Banshee.Dap/DapLibrarySync.cs \
+ Banshee.Dap/DapPriorityNode.cs \
Banshee.Dap/DapService.cs \
Banshee.Dap/DapSource.cs \
Banshee.Dap/DapSync.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]