banshee r3820 - in trunk/banshee: . build build/m4/banshee src/Backends/Banshee.Hal/Banshee.HalBackend src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Hardware src/Dap src/Dap/Banshee.Dap.Ipod src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod src/Dap/Banshee.Dap/Banshee.Dap



Author: abock
Date: Thu Apr 24 18:59:49 2008
New Revision: 3820
URL: http://svn.gnome.org/viewvc/banshee?rev=3820&view=rev

Log:
2008-04-24  Aaron Bockover  <aaron cantank>

    * build/build.environment.mk:
    * build/build.rules.mk:
    * build/m4/banshee/dap-ipod.m4:
    * configure.ac: Build foo for iPod support

    * src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs: Do not
    check if info.category is storage since the capability query for block
    will validate the device, and info.category may not be storage for all
    storage devices (it could be portable_audio_player)

    * src/Core/Banshee.Services/Banshee.Hardware/IDevice.cs:
    * src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs: Added HAL
    method wrappers for properties that should only be used with extreme care;
    probably need to enforce how these are used. They're really just for
    proxying custom properties from custom IDevices; I'm not totally happy
    with this

    * src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs:
    * src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs:
    * src/Backends/Banshee.Hal/Banshee.HalBackend/HardwareManager.cs: Some
    cleanups, notes

    * src/Core/Banshee.Services/Banshee.Services.addin.xml:
    * src/Core/Banshee.Services/Banshee.Hardware/HardwareManager.cs:
    Implemented the ICustomDeviceProvider extension, pass all IDevice queries
    through the custom device providers to allow them to transform/replace
    a device with some custom device

    * src/Core/Banshee.Services/Banshee.Hardware/ICustomDeviceProvider.cs:
    The new interface for custom device providers

    * src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.addin.xml: iPod extension def

    * src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs: The beginning
    of the iPod DAP support; doesn't do anything yet

    * src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDevice.cs: A device
    that translates PodSleuth properties to the iPod device from ipod-sharp

    * src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDeviceProvider.cs:
    Custom device provider for taking an iPod storage device and transforming
    its iPod volume into a PodSleuthDevice



Added:
   trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/ICustomDeviceProvider.cs
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.addin.xml
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.mdp
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDevice.cs
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDeviceProvider.cs
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Makefile.am
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/build/build.environment.mk
   trunk/banshee/build/build.rules.mk
   trunk/banshee/build/m4/banshee/dap-ipod.m4
   trunk/banshee/configure.ac
   trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs
   trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs
   trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/HardwareManager.cs
   trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/HardwareManager.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IDevice.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Services.addin.xml
   trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
   trunk/banshee/src/Core/Banshee.Services/Makefile.am
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
   trunk/banshee/src/Dap/Dap.mds
   trunk/banshee/src/Dap/Makefile.am

Modified: trunk/banshee/build/build.environment.mk
==============================================================================
--- trunk/banshee/build/build.environment.mk	(original)
+++ trunk/banshee/build/build.environment.mk	Thu Apr 24 18:59:49 2008
@@ -21,6 +21,7 @@
 LINK_GNOME = $(GNOMESHARP_LIBS)
 LINK_DBUS = $(NDESK_DBUS_LIBS)
 LINK_TAGLIB = $(TAGLIB_SHARP_LIBS)
+LINK_IPOD = $(IPODSHARP_LIBS)
 
 LINK_MONO_ADDINS_DEPS = $(MONO_ADDINS_LIBS)
 LINK_MONO_ADDINS_SETUP_DEPS = $(MONO_ADDINS_SETUP_LIBS)
@@ -127,8 +128,9 @@
 REF_DAP = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_BANSHEE_THICKCLIENT_DEPS)
 LINK_DAP = -r:$(DIR_BIN)/Banshee.Dap.dll
 LINK_DAP_DEPS = $(REF_DAP) $(LINK_DAP)
-REF_DAP_MASS_STORAGE = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_DAP_DEPS)
-REF_DAP_MTP = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_DAP_DEPS) $(LINK_MTP_DEPS)
+REF_DAP_MASS_STORAGE = $(LINK_DAP_DEPS)
+REF_DAP_MTP = $(LINK_DAP_DEPS) $(LINK_MTP_DEPS)
+REF_DAP_IPOD = $(LINK_DAP_DEPS) $(LINK_IPOD)
 
 # Backends
 REF_BACKEND_GNOME = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_GCONF) $(LINK_GNOME)

Modified: trunk/banshee/build/build.rules.mk
==============================================================================
--- trunk/banshee/build/build.rules.mk	(original)
+++ trunk/banshee/build/build.rules.mk	Thu Apr 24 18:59:49 2008
@@ -50,6 +50,9 @@
 	@if [ -e $(notdir $  config) ]; then \
 		cp $(notdir $  config) $(top_builddir)/bin; \
 	fi;
+	@if [ ! -z "$(EXTRA_BUNDLE)" ]; then \
+		cp $(EXTRA_BUNDLE) $(top_builddir)/bin; \
+	fi;
 
 theme-icons: $(THEME_ICONS_SOURCE)
 	@$(INSTALL_ICONS) -il "$(BUILD_DATA_DIR)" "$(srcdir)" $(THEME_ICONS_RELATIVE)

Modified: trunk/banshee/build/m4/banshee/dap-ipod.m4
==============================================================================
--- trunk/banshee/build/m4/banshee/dap-ipod.m4	(original)
+++ trunk/banshee/build/m4/banshee/dap-ipod.m4	Thu Apr 24 18:59:49 2008
@@ -1,6 +1,6 @@
 AC_DEFUN([BANSHEE_CHECK_DAP_IPOD],
 [
-	IPODSHARP_REQUIRED=0.6.3
+	IPODSHARP_REQUIRED=0.8.0
 
 	AC_ARG_ENABLE(ipod, AC_HELP_STRING([--enable-ipod], 
 		[Enable iPod DAP support]), , enable_ipod="yes")
@@ -13,7 +13,10 @@
 		enable_ipodsharp="$enable_ipodsharp", enable_ipodsharp=no)
 
 	if test "x$enable_ipodsharp" = "xyes"; then
-		IPODSHARP_ASSEMBLIES="`$PKG_CONFIG --variable=Libraries ipod-sharp` `$PKG_CONFIG --variable=Libraries ipod-sharp-ui`"
+		asms="`$PKG_CONFIG --variable=Libraries ipod-sharp` `$PKG_CONFIG --variable=Libraries ipod-sharp-ui`"
+		for asm in $asms; do
+			IPODSHARP_ASSEMBLIES="$IPODSHARP_ASSEMBLIES $asm $asm.mdb"
+		done
 		AC_SUBST(IPODSHARP_ASSEMBLIES)
 		AC_SUBST(IPODSHARP_LIBS)
 	fi

Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac	(original)
+++ trunk/banshee/configure.ac	Thu Apr 24 18:59:49 2008
@@ -79,9 +79,7 @@
 
 dnl DAP support (each module is optional)
 BANSHEE_CHECK_DAP_MTP
-#BANSHEE_CHECK_DAP_IPOD
-#BANSHEE_CHECK_DAP_NJB
-#BANSHEE_CHECK_DAP_KARMA
+BANSHEE_CHECK_DAP_IPOD
 
 dnl DAAP support (optional)
 BANSHEE_CHECK_DAAP
@@ -150,6 +148,7 @@
 
 src/Dap/Makefile
 src/Dap/Banshee.Dap/Makefile
+src/Dap/Banshee.Dap.Ipod/Makefile
 src/Dap/Banshee.Dap.MassStorage/Makefile
 src/Dap/Banshee.Dap.Mtp/Makefile
 
@@ -180,6 +179,7 @@
     Digital Audio Player (DAP) Support:
       Mass Storage:    yes	(unstable)
       MTP:             ${enable_mtp_dap}	(unstable)
+      iPod:            ${enable_ipodsharp}	(unstable)
 
     DAAP Support:      ${enable_daap}	(unstable)
     Podcast Support:   ${enable_podcast}	(unstable)

Modified: trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/BlockDevice.cs	Thu Apr 24 18:59:49 2008
@@ -38,8 +38,7 @@
     {
         public static BlockDevice Resolve<T> (Hal.Manager manager, Hal.Device device) where T : IBlockDevice
         {
-            if (device["info.category"] == "storage" && device.QueryCapability ("block") && 
-                device.PropertyExists ("block.device")) {
+            if (device.QueryCapability ("block") && device.PropertyExists ("block.device")) {
                 if (typeof (T) == typeof (ICdromDevice)) {
                     return CdromDevice.Resolve (manager, device);
                 } else if (typeof (T) == typeof (IDiskDevice)) {

Modified: trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Device.cs	Thu Apr 24 18:59:49 2008
@@ -88,19 +88,54 @@
             }
         }
         
-        private static Stack<Hal.Device> CollectUsbDeviceStack(Hal.Device device)
+        public bool PropertyExists (string key)
         {
-            Stack<Hal.Device> device_stack = new Stack<Hal.Device>();
+            return device.PropertyExists (key);
+        }
+        
+        public string GetPropertyString (string key)
+        {
+            return device.GetPropertyString (key);
+        }
+        
+        public double GetPropertyDouble (string key)
+        {
+            return device.GetPropertyDouble (key);
+        }
+        
+        public bool GetPropertyBoolean (string key)
+        {
+            return device.GetPropertyBoolean (key);
+        }
+        
+        public int GetPropertyInteger (string key)
+        {
+            return device.GetPropertyInteger (key);
+        }
+        
+        public ulong GetPropertyUInt64 (string key)
+        {
+            return device.GetPropertyUInt64 (key);
+        }
+        
+        public string [] GetPropertyStringList (string key)
+        {
+            return device.GetPropertyStringList (key);
+        }
+        
+        private static Stack<Hal.Device> CollectUsbDeviceStack (Hal.Device device)
+        {
+            Stack<Hal.Device> device_stack = new Stack<Hal.Device> ();
             int usb_vendor_id = -1;
             int usb_product_id = -1;
 
             Hal.Device tmp_device = device;
 
-            while(tmp_device != null) {
-                // Skip the SCSI parents of the player volume if they are in the tree
-                if((tmp_device.PropertyExists("info.bus") && tmp_device["info.bus"] == "scsi") ||
+            while (tmp_device != null) {
+                // Skip the SCSI parents of the volume if they are in the tree
+                if ((tmp_device.PropertyExists("info.bus") && tmp_device["info.bus"] == "scsi") ||
                     (tmp_device.PropertyExists("info.category") && tmp_device["info.category"] == "scsi_host")) {
-                    device_stack.Push(tmp_device);
+                    device_stack.Push (tmp_device);
                     tmp_device = tmp_device.Parent;
                     continue;
                 }
@@ -110,31 +145,33 @@
                 int _usb_product_id = -1;
 
                 // Figure out the IDs if they exist
-                if(tmp_device.PropertyExists("usb.vendor_id") && tmp_device.PropertyExists("usb.product_id")) {
-                    _usb_vendor_id = tmp_device.GetPropertyInteger("usb.vendor_id");
-                    _usb_product_id = tmp_device.GetPropertyInteger("usb.product_id");
+                if (tmp_device.PropertyExists ("usb.vendor_id") && 
+                    tmp_device.PropertyExists ("usb.product_id")) {
+                    _usb_vendor_id = tmp_device.GetPropertyInteger ("usb.vendor_id");
+                    _usb_product_id = tmp_device.GetPropertyInteger ("usb.product_id");
                     have_usb_ids = true;
-                } else if(tmp_device.PropertyExists("usb_device.vendor_id") && tmp_device.PropertyExists("usb_device.product_id")) {
+                } else if (tmp_device.PropertyExists("usb_device.vendor_id") && 
+                    tmp_device.PropertyExists("usb_device.product_id")) {
                     _usb_vendor_id = tmp_device.GetPropertyInteger("usb_device.vendor_id");
                     _usb_product_id = tmp_device.GetPropertyInteger("usb_device.product_id");
                     have_usb_ids = true;
                 }
 
-                if(have_usb_ids) {
-                    if(usb_vendor_id == -1 && usb_product_id == -1) {
+                if (have_usb_ids) {
+                    if (usb_vendor_id == -1 && usb_product_id == -1) {
                         // We found the first raw USB device, remember it
                         usb_vendor_id = _usb_vendor_id;
                         usb_product_id = _usb_product_id;
-                    } else if(usb_vendor_id != _usb_vendor_id || usb_product_id != _usb_product_id) {
+                    } else if (usb_vendor_id != _usb_vendor_id || usb_product_id != _usb_product_id) {
                         // We are no longer looking at the device we care about (could now be at a hub or something)
                         break;
                     }
-                } else if(usb_vendor_id != -1 || usb_product_id != -1) {
+                } else if (usb_vendor_id != -1 || usb_product_id != -1) {
                     // We are no longer even looking at USB devices
                     break;
                 }
 
-                device_stack.Push(tmp_device);
+                device_stack.Push (tmp_device);
                 tmp_device = tmp_device.Parent;
             }
             

Modified: trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/HardwareManager.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/HardwareManager.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/HardwareManager.cs	Thu Apr 24 18:59:49 2008
@@ -97,15 +97,18 @@
 
         private IDevice Resolve (Hal.Device hal_device)
         {
-            if (!hal_device.QueryCapability ("block") && !hal_device.QueryCapability ("portable_audio_player"))
+            if (!hal_device.QueryCapability ("block") && !hal_device.QueryCapability ("portable_audio_player")) {
                 return null;
-
+            }
+            
             IDevice device = BlockDevice.Resolve<IBlockDevice> (manager, hal_device);
-            if (device == null)
+            if (device == null) {
                 device = Volume.Resolve (null, manager, hal_device);
-                if (device == null)
+                if (device == null) {
                     device = new Device (manager, hal_device);
-
+                }
+            }
+            
             return device;
         }
 

Modified: trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs
==============================================================================
--- trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs	(original)
+++ trunk/banshee/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs	Thu Apr 24 18:59:49 2008
@@ -105,6 +105,8 @@
                     return -1;
                 }
                 
+                // FIXME: maybe we should use UnixDriveInfo? Advantages?
+                
                 try {
                     Mono.Unix.Native.Statvfs statvfs_info;
                     if (Mono.Unix.Native.Syscall.statvfs (MountPoint, out statvfs_info) != -1) {

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/HardwareManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/HardwareManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/HardwareManager.cs	Thu Apr 24 18:59:49 2008
@@ -39,6 +39,7 @@
     public sealed class HardwareManager : IService, IHardwareManager
     {
         private IHardwareManager manager;
+        private List<ICustomDeviceProvider> custom_device_providers = new List<ICustomDeviceProvider> ();
         
         public event DeviceAddedHandler DeviceAdded {
             add { manager.DeviceAdded += value; }
@@ -69,6 +70,29 @@
             if (manager == null) {
                 throw new Exception ("No HardwareManager extensions could be loaded. Hardware support will be disabled.");
             }
+            
+            foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes ("/Banshee/Platform/HardwareDeviceProvider")) {
+                custom_device_providers.Add ((ICustomDeviceProvider)node.CreateInstance (typeof (ICustomDeviceProvider)));
+            }
+        }
+        
+        private T CastToCustomDevice<T> (T device) where T : class, IDevice
+        {
+            foreach (ICustomDeviceProvider provider in custom_device_providers) {
+                T new_device = provider.GetCustomDevice (device);
+                if (new_device != device && new_device is T) {
+                    return new_device;
+                }
+            }
+            
+            return device;
+        }
+        
+        private IEnumerable<T> CastToCustomDevice<T> (IEnumerable<T> devices) where T : class, IDevice
+        {
+            foreach (T device in devices) {
+                yield return CastToCustomDevice<T> (device);
+            }
         }
         
         public void Dispose ()
@@ -78,22 +102,22 @@
 
         public IEnumerable<IDevice> GetAllDevices ()
         {
-            return manager.GetAllDevices ();
+            return CastToCustomDevice<IDevice> (manager.GetAllDevices ());
         }
         
         public IEnumerable<IBlockDevice> GetAllBlockDevices ()
         {
-            return manager.GetAllBlockDevices ();
+            return CastToCustomDevice<IBlockDevice> (manager.GetAllBlockDevices ());
         }
         
         public IEnumerable<ICdromDevice> GetAllCdromDevices ()
         {
-            return manager.GetAllCdromDevices ();
+            return CastToCustomDevice<ICdromDevice> (manager.GetAllCdromDevices ());
         }
         
         public IEnumerable<IDiskDevice> GetAllDiskDevices ()
         {
-            return manager.GetAllDiskDevices ();
+            return CastToCustomDevice<IDiskDevice> (manager.GetAllDiskDevices ());
         }
         
         public void Test ()

Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/ICustomDeviceProvider.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/ICustomDeviceProvider.cs	Thu Apr 24 18:59:49 2008
@@ -0,0 +1,37 @@
+//
+// ICustomDeviceProvider.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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 Banshee.Hardware
+{
+    public interface ICustomDeviceProvider
+    {
+        T GetCustomDevice<T> (T device) where T : class, IDevice;
+    }
+}

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IDevice.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IDevice.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Hardware/IDevice.cs	Thu Apr 24 18:59:49 2008
@@ -39,5 +39,14 @@
         string Vendor { get; }
 
         IDeviceMediaCapabilities MediaCapabilities { get; }
+        
+        bool PropertyExists (string key);
+        
+        string GetPropertyString (string key);
+        double GetPropertyDouble (string key);
+        bool GetPropertyBoolean (string key);
+        int GetPropertyInteger (string key);
+        ulong GetPropertyUInt64 (string key);
+        string [] GetPropertyStringList (string key);
     }
 }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.addin.xml
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.addin.xml	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.addin.xml	Thu Apr 24 18:59:49 2008
@@ -36,5 +36,9 @@
   <ExtensionPoint path="/Banshee/Platform/HardwareManager">
     <ExtensionNode name="HardwareManager"/>
   </ExtensionPoint>
+  
+  <ExtensionPoint path="/Banshee/Platform/HardwareDeviceProvider">
+    <ExtensionNode name="HardwareDeviceProvider"/>
+  </ExtensionPoint>
 
 </Addin>

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	Thu Apr 24 18:59:49 2008
@@ -160,6 +160,7 @@
     <File name="Banshee.Preferences/SchemaPreference.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Library/LibraryLocationPreference.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Preferences/VoidPreference.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Hardware/ICustomDeviceProvider.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am	Thu Apr 24 18:59:49 2008
@@ -36,6 +36,7 @@
 	Banshee.Hardware/HardwareManager.cs \
 	Banshee.Hardware/IBlockDevice.cs \
 	Banshee.Hardware/ICdromDevice.cs \
+	Banshee.Hardware/ICustomDeviceProvider.cs \
 	Banshee.Hardware/IDevice.cs \
 	Banshee.Hardware/IDeviceMediaCapabilities.cs \
 	Banshee.Hardware/IDiscVolume.cs \

Added: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.addin.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.addin.xml	Thu Apr 24 18:59:49 2008
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin
+    id="Banshee.Dap.Ipod"
+    version="1.0"
+    compatVersion="1.0"
+    copyright="Â 2008 Novell Inc. Licensed under the MIT X11 license."
+    name="iPod Support"
+    category="Hardware"
+    description="Provides support for most iPod devices."
+    author="Aaron Bockover"
+    url="http://banshee-project.org/";
+    defaultEnabled="true">
+
+  <Dependencies>
+    <Addin id="Banshee.Services" version="1.0"/>
+    <Addin id="Banshee.Dap" version="1.0"/>
+  </Dependencies>
+
+  <Extension path="/Banshee/Dap/DeviceClass">
+    <DeviceClass class="Banshee.Dap.Ipod.IpodSource"/>
+  </Extension>
+  
+  <Extension path="/Banshee/Platform/HardwareDeviceProvider">
+    <HardwareDeviceProvider class="Banshee.Dap.Ipod.PodSleuthDeviceProvider"/>
+  </Extension>
+
+</Addin>

Added: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.mdp
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod.mdp	Thu Apr 24 18:59:49 2008
@@ -0,0 +1,32 @@
+<Project name="Banshee.Dap.Ipod" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+  <Configurations active="Debug">
+    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+      <Output directory="../../../bin" assemblyKeyFile="." assembly="Banshee.Dap.Ipod" />
+      <Build debugmode="True" target="Library" />
+      <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+  </Configurations>
+  <Contents>
+    <File name="Banshee.Dap.Ipod.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="Banshee.Dap.Ipod" subtype="Directory" buildaction="Compile" />
+    <File name="Banshee.Dap.Ipod/IpodSource.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Dap.Ipod/PodSleuthDeviceProvider.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Dap.Ipod/PodSleuthDevice.cs" subtype="Code" buildaction="Compile" />
+  </Contents>
+  <References>
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.Services" />
+    <ProjectReference type="Project" localcopy="True" refto="Hyena" />
+    <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  </References>
+  <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
+    <BuildFilesVar Sync="True" Name="SOURCES" />
+    <DeployFilesVar />
+    <ResourcesVar Sync="True" Name="RESOURCES" />
+    <OthersVar />
+    <GacRefVar />
+    <AsmRefVar />
+    <ProjectRefVar />
+  </MonoDevelop.Autotools.MakefileInfo>
+</Project>
\ No newline at end of file

Added: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs	Thu Apr 24 18:59:49 2008
@@ -0,0 +1,225 @@
+//
+// IpodSource.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2005-2008 Novell, Inc.
+//
+// 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 System.IO;
+
+using IPod;
+
+using Hyena;
+using Banshee.Base;
+using Banshee.Dap;
+using Banshee.Hardware;
+using Banshee.Collection.Database;
+
+namespace Banshee.Dap.Ipod
+{
+    public class IpodSource : DapSource
+    {
+        private PodSleuthDevice ipod_device;
+        
+        private string name_path;
+        internal string NamePath {
+            get { return name_path; }
+        }
+        
+        private bool database_supported;
+        internal bool DatabaseSupported {
+            get { return database_supported; }
+        }
+        
+#region Device Initialization        
+        
+        protected override bool Initialize (IDevice device)
+        {
+            ipod_device = device as PodSleuthDevice;
+            if (ipod_device == null) {
+                return false;
+            }
+        
+            if (!LoadIpod ()) {
+                return false;
+            }
+            
+            Initialize ();
+            return true;
+        }
+        
+        private bool LoadIpod ()
+        {
+            try {
+                name_path = Path.Combine (Path.GetDirectoryName (ipod_device.TrackDatabasePath), "BansheeIPodName");
+                
+                if (File.Exists (ipod_device.TrackDatabasePath)) { 
+                    ipod_device.LoadTrackDatabase ();
+                } else {
+                    int count = CountMusicFiles ();
+                    Log.DebugFormat ("Found {0} files in /iPod_Control/Music", count);
+                    if (CountMusicFiles () > 5) {
+                        throw new DatabaseReadException ("No database, but found a lot of music files");
+                    }
+                }
+                database_supported = true;
+            } catch (DatabaseReadException) {
+                ipod_device.LoadTrackDatabase (true);
+                database_supported = false;
+            } catch (Exception e) {
+                Log.Exception (e);
+                return false;
+            }
+            
+            return true;
+        }
+        
+        private int CountMusicFiles ()
+        {
+            try {
+                int file_count = 0;
+                
+                DirectoryInfo m_dir = new DirectoryInfo (Path.Combine (ipod_device.ControlPath, "Music"));
+                foreach (DirectoryInfo f_dir in m_dir.GetDirectories()) {
+                    file_count += f_dir.GetFiles().Length;
+                }
+                
+                return file_count;
+            } catch {
+                return 0;
+            }
+        }
+        
+#endregion
+        
+        private string name;
+        public override string Name {
+            get {
+                if (name != null) {
+                    return name;
+                }
+                
+                if (File.Exists (name_path)) {
+                    using (StreamReader reader = new StreamReader (name_path, System.Text.Encoding.Unicode)) {
+                        name = reader.ReadLine ();
+                    }
+                }
+                
+                if (String.IsNullOrEmpty (name)) {
+                    name = ipod_device.Name;
+                }
+                    
+                if (!String.IsNullOrEmpty (name)) {
+                    return name;
+                } else if (ipod_device.PropertyExists ("volume.label")) {
+                    name = ipod_device.GetPropertyString ("volume.label");
+                } else if (ipod_device.PropertyExists ("info.product")) {
+                    name = ipod_device.GetPropertyString ("info.product");
+                } else {
+                    name = ((IDevice)ipod_device).Name ?? "iPod";
+                }
+                
+                return name;
+            }
+        }
+        
+        public override void Import ()
+        {
+            Log.Information ("Import to Library is not implemented for iPods yet", true);
+        }
+
+        public override bool CanRename {
+            get { return !(IsAdding || IsDeleting || IsReadOnly); }
+        }
+
+        protected override void OnTracksDeleted ()
+        {
+            base.OnTracksDeleted ();
+        }
+
+        public override void Rename (string name)
+        {
+            if (!CanRename) {
+                return;
+            }
+        
+            try {
+                if (name_path != null) {
+                    Directory.CreateDirectory (Path.GetDirectoryName (name_path));
+                
+                    using (StreamWriter writer = new StreamWriter (File.Open (name_path, FileMode.Create), 
+                        System.Text.Encoding.Unicode)) {
+                        writer.Write (name);
+                    }
+                }
+            } catch (Exception e) {
+                Log.Exception (e);
+            }
+            
+            this.name = null;
+            ipod_device.Name = name;
+            base.Rename (name);
+        }
+
+        public override long BytesUsed {
+            get { return (long)ipod_device.VolumeInfo.SpaceUsed; }
+        }
+        
+        public override long BytesCapacity {
+            get { return (long)ipod_device.VolumeInfo.Size; }
+        }
+
+        public override bool IsReadOnly {
+            get { return ipod_device.IsReadOnly; }
+        }
+
+        protected override void AddTrackToDevice (DatabaseTrackInfo track, SafeUri fromUri)
+        {
+            if (track.PrimarySourceId == DbId) {
+                return;
+            }
+        }
+
+        /*private int OnUploadProgress (ulong sent, ulong total, IntPtr data)
+        {
+            AddTrackJob.DetailedProgress = (double) sent / (double) total;
+            return 0;
+        }*/
+
+        protected override void DeleteTrack (DatabaseTrackInfo track)
+        {
+        }
+
+        public override void Dispose ()
+        {
+            base.Dispose ();
+        }
+
+        protected override void Eject ()
+        {
+            Dispose ();
+        }
+    }
+}

Added: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDevice.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDevice.cs	Thu Apr 24 18:59:49 2008
@@ -0,0 +1,357 @@
+//
+// PodSleuthDevice.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2007-2008 Novell, Inc.
+//
+// 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 System.IO;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+using IPod;
+using Banshee.Hardware;
+
+namespace Banshee.Dap.Ipod
+{
+    public class PodSleuthDevice : IPod.Device, IVolume
+    {
+        internal const string PodsleuthPrefix = "org.podsleuth.ipod.";
+
+        private class _ProductionInfo : IPod.ProductionInfo
+        {
+            public _ProductionInfo (IVolume volume)
+            {
+                SerialNumber = volume.GetPropertyString (PodsleuthPrefix + "serial_number");
+                FactoryId = volume.GetPropertyString (PodsleuthPrefix + "production.factory_id");
+                Number = volume.GetPropertyInteger (PodsleuthPrefix + "production.number");
+                Week = volume.GetPropertyInteger (PodsleuthPrefix + "production.week");
+                Year = volume.GetPropertyInteger (PodsleuthPrefix + "production.year");
+            }
+        }
+        
+        private class _VolumeInfo : IPod.VolumeInfo
+        {
+            private IVolume volume;
+            
+            public _VolumeInfo (IVolume volume)
+            {
+                this.volume = volume;
+                
+                MountPoint = volume.GetPropertyString ("volume.mount_point");
+                Label = volume.GetPropertyString ("volume.label");
+                IsMountedReadOnly = volume.GetPropertyBoolean ("volume.is_mounted_read_only");
+                Uuid = volume.GetPropertyString ("volume.uuid");
+            }
+            
+            public override ulong Size {
+                get { return volume.Capacity; }
+            }
+        
+            public override ulong SpaceUsed {
+                get { return volume.Capacity - (ulong)volume.Available; }
+            }
+        }
+        
+        private class _ModelInfo : IPod.ModelInfo
+        {
+            public _ModelInfo (IVolume volume)
+            {
+                AdvertisedCapacity = GetVolumeSizeString (volume);
+                
+                IsUnknown = true;
+                if (volume.PropertyExists (PodsleuthPrefix + "is_unknown")) {
+                    IsUnknown = volume.GetPropertyBoolean (PodsleuthPrefix + "is_unknown");
+                }
+                
+                if (volume.PropertyExists (PodsleuthPrefix + "images.album_art_supported")) {
+                    AlbumArtSupported = volume.GetPropertyBoolean (PodsleuthPrefix + "images.album_art_supported");
+                }
+                
+                if (volume.PropertyExists (PodsleuthPrefix + "images.photos_supported")) {
+                    PhotosSupported = volume.GetPropertyBoolean (PodsleuthPrefix + "images.photos_supported");
+                }
+                
+                if (volume.PropertyExists (PodsleuthPrefix + "model.device_class")) {
+                    DeviceClass = volume.GetPropertyString (PodsleuthPrefix + "model.device_class");
+                }
+                
+                if (volume.PropertyExists (PodsleuthPrefix + "model.generation")) {
+                    Generation = volume.GetPropertyDouble (PodsleuthPrefix + "model.generation");
+                }
+                
+                if (volume.PropertyExists (PodsleuthPrefix + "model.shell_color")) {
+                    ShellColor = volume.GetPropertyString (PodsleuthPrefix + "model.shell_color");
+                }
+                
+                if (volume.PropertyExists ("info.icon_name")) {
+                    IconName = volume.GetPropertyString ("info.icon_name");
+                }
+                
+                if (volume.PropertyExists (PodsleuthPrefix + "capabilities")) {
+                    foreach (string capability in volume.GetPropertyStringList (PodsleuthPrefix + "capabilities")) {
+                        AddCapability (capability);
+                    }
+                }
+            }
+            
+            private static string GetVolumeSizeString (IVolume volume)
+            {
+                string format = "GiB";
+                double value = volume.GetPropertyUInt64 ("volume.size") / 1000.0 / 1000.0 / 1000.0;
+
+                if(value < 1.0) {
+                    format = "MiB";
+                    value *= 1000.0;
+                }
+
+                return String.Format ("{0} {1}", (int)Math.Round (value), format);
+            }
+        }
+        
+        private IVolume volume;
+        
+        private IPod.ProductionInfo production_info;
+        private IPod.VolumeInfo volume_info;
+        private IPod.ModelInfo model_info;
+        
+        public override IPod.ProductionInfo ProductionInfo {
+            get { return production_info; }
+        }
+        
+        public override IPod.VolumeInfo VolumeInfo {
+            get { return volume_info; }
+        }
+        
+        public override IPod.ModelInfo ModelInfo {
+            get { return model_info; }
+        }
+
+        internal PodSleuthDevice (IVolume volume) 
+        {
+            this.volume = volume;
+
+            volume_info = new _VolumeInfo (volume);
+            production_info = new _ProductionInfo (volume);
+            model_info = new _ModelInfo (volume);
+            
+            if (volume.PropertyExists (PodsleuthPrefix + "control_path")) {
+                string relative_control = volume.GetPropertyString (PodsleuthPrefix + "control_path");
+                if (relative_control[0] == Path.DirectorySeparatorChar) {
+                    relative_control = relative_control.Substring (1);
+                }
+                
+                ControlPath = Path.Combine(VolumeInfo.MountPoint, relative_control);
+            }
+            
+            ArtworkFormats = new ReadOnlyCollection<ArtworkFormat> (LoadArtworkFormats ());
+
+            if (volume.PropertyExists (PodsleuthPrefix + "firmware_version")) {
+                FirmwareVersion = volume.GetPropertyString (PodsleuthPrefix + "firmware_version");
+            }
+
+            if (volume.PropertyExists (PodsleuthPrefix + "firewire_id")) {
+                FirewireId = volume.GetPropertyString (PodsleuthPrefix + "firewire_id");
+            }
+            
+            RescanDisk ();
+        }
+        
+        public override void Eject ()
+        {
+            volume.Eject ();
+        }
+        
+        public override void RescanDisk () 
+        {
+        }
+
+        private List<ArtworkFormat> LoadArtworkFormats () 
+        {
+            List<ArtworkFormat> formats = new List<ArtworkFormat> ();
+
+            if (!ModelInfo.AlbumArtSupported) {
+                return formats;
+            }
+            
+            string [] formatList = volume.GetPropertyStringList (PodsleuthPrefix + "images.formats");
+
+            foreach (string formatStr in formatList) {
+                short correlationId, width, height, rotation;
+                ArtworkUsage usage;
+                int size;
+                PixelFormat pformat;
+
+                correlationId = width = height = rotation = size = 0;
+                usage = ArtworkUsage.Unknown;
+                pformat = PixelFormat.Unknown;
+
+                string[] pairs = formatStr.Split(',');
+                
+                foreach (string pair in pairs) {
+                    string[] splitPair = pair.Split('=');
+                    if (splitPair.Length != 2) {
+                        continue;
+                    }
+                    
+                    string value = splitPair[1];
+                    switch (splitPair[0]) {
+                        case "corr_id": correlationId = Int16.Parse (value); break;
+                        case "width": width = Int16.Parse (value); break;
+                        case "height": height = Int16.Parse (value); break;
+                        case "rotation": rotation = Int16.Parse (value); break;
+                        case "pixel_format":
+                            switch (value) {
+                                case "iyuv": pformat = PixelFormat.IYUV;  break;
+                                case "rgb565": pformat = PixelFormat.Rgb565;  break;
+                                case "rgb565be": pformat = PixelFormat.Rgb565BE; break;
+                                case "unknown": pformat = PixelFormat.Unknown; break;
+                            }
+                            break;
+                        case "image_type":
+                            switch (value) {
+                                case "photo": usage = ArtworkUsage.Photo; break;
+                                case "album": usage = ArtworkUsage.Cover; break;
+                                /* we don't support this right now
+                                   case "chapter": usage = ArtworkUsage.Chapter; break;
+                                */
+                            }
+                            break;
+                    }
+                }
+
+                if (pformat != PixelFormat.Unknown && usage != ArtworkUsage.Unknown) {
+                    formats.Add (new ArtworkFormat (usage, width, height, correlationId, size, pformat, rotation));
+                }
+            }
+
+            return formats;
+        }
+
+#region IVolume Wrapper
+
+        string IDevice.Name {
+            get { return volume.Name; }
+        }
+
+        public void Unmount ()
+        {
+            volume.Unmount ();
+        }
+        
+        public string Uuid {
+            get { return volume.Uuid; }
+        }
+        public string Product {
+            get { return volume.Product; }
+        }
+
+        public string Vendor {
+            get { return volume.Vendor; }
+        }
+
+        public IDeviceMediaCapabilities MediaCapabilities {
+            get { return volume.MediaCapabilities; }
+        }
+
+        public string DeviceNode {
+            get { return volume.DeviceNode; }
+        }
+
+        public string MountPoint {
+            get { return volume.MountPoint; }
+        }
+
+        public bool IsReadOnly {
+            get { return volume.IsReadOnly; }
+        }
+
+        public ulong Capacity {
+            get { return volume.Capacity; }
+        }
+
+        public long Available {
+            get { return volume.Available; }
+        }
+
+        public IBlockDevice Parent {
+            get { return volume.Parent; }
+        }
+
+        public bool ShouldIgnore {
+            get { return volume.ShouldIgnore; }
+        }
+
+        public string FileSystem {
+            get { return volume.FileSystem; }
+        }
+
+        public bool CanEject {
+            get { return volume.CanEject; }
+        }
+
+        public bool CanUnmount {
+            get { return volume.CanEject; }
+        }
+
+        public bool PropertyExists (string key)
+        {
+            return volume.PropertyExists (key);
+        }
+
+        public string GetPropertyString (string key)
+        {
+            return volume.GetPropertyString (key);
+        }
+
+        public double GetPropertyDouble (string key)
+        {
+            return volume.GetPropertyDouble (key);
+        }
+
+        public bool GetPropertyBoolean (string key)
+        {
+            return volume.GetPropertyBoolean (key);
+        }
+
+        public int GetPropertyInteger (string key)
+        {
+            return volume.GetPropertyInteger (key);
+        }
+
+        public ulong GetPropertyUInt64 (string key)
+        {
+            return volume.GetPropertyUInt64 (key);
+        }
+
+        public string[] GetPropertyStringList (string key)
+        {
+            return volume.GetPropertyStringList (key);
+        }
+        
+#endregion
+
+    }
+}

Added: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDeviceProvider.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDeviceProvider.cs	Thu Apr 24 18:59:49 2008
@@ -0,0 +1,59 @@
+//
+// PodSleuthDeviceProvider.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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 Banshee.Hardware;
+
+namespace Banshee.Dap.Ipod
+{
+    public class PodSleuthDeviceProvider : ICustomDeviceProvider
+    {
+        public T GetCustomDevice<T> (T device) where T : class, IDevice
+        {
+            IDiskDevice disk_device = device as IDiskDevice;
+            
+            if (disk_device == null || device.MediaCapabilities == null || !device.MediaCapabilities.IsType ("ipod")) {
+                return device;
+            }
+            
+            foreach (IVolume volume in disk_device.Volumes) {
+                if (volume.PropertyExists ("org.podsleuth.version")) {
+                    try {
+                        return (T)((IDevice)(new PodSleuthDevice (volume)));
+                    } catch (Exception e) {
+                        Hyena.Log.Exception (e);
+                        return device;
+                    }
+                }
+            }
+            
+            return device;
+        }
+    }
+}

Added: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Makefile.am	Thu Apr 24 18:59:49 2008
@@ -0,0 +1,15 @@
+ASSEMBLY = Banshee.Dap.Ipod
+TARGET = library
+LINK = $(REF_DAP_IPOD)
+
+SOURCES =  \
+	Banshee.Dap.Ipod/IpodSource.cs \
+	Banshee.Dap.Ipod/PodSleuthDevice.cs \
+	Banshee.Dap.Ipod/PodSleuthDeviceProvider.cs
+
+RESOURCES = Banshee.Dap.Ipod.addin.xml
+
+EXTRA_BUNDLE = $(IPODSHARP_ASSEMBLIES)
+
+include $(top_srcdir)/build/build.mk
+

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs	Thu Apr 24 18:59:49 2008
@@ -62,7 +62,8 @@
             ServiceManager.SourceManager.SourceRemoved += OnSourceRemoved;
         }
 
-        private void OnExtensionChanged (object o, ExtensionNodeEventArgs args) {
+        private void OnExtensionChanged (object o, ExtensionNodeEventArgs args) 
+        {
             TypeExtensionNode node = (TypeExtensionNode) args.ExtensionNode;
             if (args.Change == ExtensionChange.Add) {
                 Log.DebugFormat ("Dap support extension loaded: {0}", node.Addin.Id);

Modified: trunk/banshee/src/Dap/Dap.mds
==============================================================================
--- trunk/banshee/src/Dap/Dap.mds	(original)
+++ trunk/banshee/src/Dap/Dap.mds	Thu Apr 24 18:59:49 2008
@@ -4,16 +4,19 @@
       <Entry build="True" name="Banshee.Dap" configuration="Debug" />
       <Entry build="True" name="Banshee.Dap.MassStorage" configuration="Debug" />
       <Entry build="True" name="Banshee.Dap.Mtp" configuration="Debug" />
+      <Entry build="True" name="Banshee.Dap.Ipod" configuration="Debug" />
     </Configuration>
   </Configurations>
-  <StartMode startupentry="Banshee.DapCore" single="True">
+  <StartMode startupentry="Banshee.Dap.Ipod" single="True">
     <Execute type="None" entry="Banshee.Dap" />
     <Execute type="None" entry="Banshee.Dap.MassStorage" />
     <Execute type="None" entry="Banshee.Dap.Mtp" />
+    <Execute type="None" entry="Banshee.Dap.Ipod" />
   </StartMode>
   <Entries>
     <Entry filename="Banshee.Dap/Banshee.Dap.mdp" />
     <Entry filename="Banshee.Dap.MassStorage/Banshee.Dap.MassStorage.mdp" />
     <Entry filename="Banshee.Dap.Mtp/Banshee.Dap.Mtp.mdp" />
+    <Entry filename="Banshee.Dap.Ipod/Banshee.Dap.Ipod.mdp" />
   </Entries>
 </Combine>
\ No newline at end of file

Modified: trunk/banshee/src/Dap/Makefile.am
==============================================================================
--- trunk/banshee/src/Dap/Makefile.am	(original)
+++ trunk/banshee/src/Dap/Makefile.am	Thu Apr 24 18:59:49 2008
@@ -1,5 +1,6 @@
 SUBDIRS = \
 	Banshee.Dap \
+	Banshee.Dap.Ipod \
 	Banshee.Dap.MassStorage \
 	Banshee.Dap.Mtp
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]