banshee r3095 - in branches/banshee/stable: . src/Core/Banshee.Base/Dap src/Dap/Banshee.Dap.Ipod src/Dap/Banshee.Dap.MassStorage src/Dap/Banshee.Dap.Mtp



Author: gburt
Date: Wed Jan 30 03:29:33 2008
New Revision: 3095
URL: http://svn.gnome.org/viewvc/banshee?rev=3095&view=rev

Log:
2008-01-29  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Base/Dap/Dap.cs: Add new IsPortableAudioPlayerType
	method that checks a Hal.Device for old and new indications it is a
	certain type.

	* src/Dap/Banshee.Dap.Ipod/IpodDap.cs:
	* src/Dap/Banshee.Dap.MassStorage/MassStorageDap.cs: 
	* src/Dap/Banshee.Dap.Mtp/MtpDap.cs: Use new method for type detection.


Modified:
   branches/banshee/stable/ChangeLog
   branches/banshee/stable/src/Core/Banshee.Base/Dap/Dap.cs
   branches/banshee/stable/src/Dap/Banshee.Dap.Ipod/IpodDap.cs
   branches/banshee/stable/src/Dap/Banshee.Dap.MassStorage/MassStorageDap.cs
   branches/banshee/stable/src/Dap/Banshee.Dap.Mtp/MtpDap.cs

Modified: branches/banshee/stable/src/Core/Banshee.Base/Dap/Dap.cs
==============================================================================
--- branches/banshee/stable/src/Core/Banshee.Base/Dap/Dap.cs	(original)
+++ branches/banshee/stable/src/Core/Banshee.Base/Dap/Dap.cs	Wed Jan 30 03:29:33 2008
@@ -712,5 +712,21 @@
         public abstract ulong StorageUsed { get; }
         public abstract bool IsReadOnly { get; }
         public abstract bool IsPlaybackSupported { get; }
+
+        // The second check (against 'type') is from an old HAL spec.
+        protected static bool IsPortableAudioPlayerType (Hal.Device device, string type)
+        {
+            if (device.PropertyExists ("portable_audio_player.type")) {
+                return device ["portable_audio_player.type"] == type;
+            } else {
+                if (device.PropertyExists ("portable_audio_player.access_method.protocols")) {
+                    return Array.IndexOf (
+                        device.GetPropertyStringList ("portable_audio_player.access_method.protocols"),
+                        type
+                    ) > 0;
+                }
+            }
+            return false;
+        }
     }
 }

Modified: branches/banshee/stable/src/Dap/Banshee.Dap.Ipod/IpodDap.cs
==============================================================================
--- branches/banshee/stable/src/Dap/Banshee.Dap.Ipod/IpodDap.cs	(original)
+++ branches/banshee/stable/src/Dap/Banshee.Dap.Ipod/IpodDap.cs	Wed Jan 30 03:29:33 2008
@@ -83,7 +83,7 @@
             if(!hal_device.PropertyExists("block.device") || 
                 !hal_device.PropertyExists("block.is_volume") ||
                 !hal_device.GetPropertyBoolean("block.is_volume") ||
-                hal_device.Parent["portable_audio_player.type"] != "ipod") {
+                !IsPortableAudioPlayerType (hal_device.Parent, "ipod")) {
                 return InitializeResult.Invalid;
             } else if(!hal_device.GetPropertyBoolean("volume.is_mounted")) {
                 return WaitForVolumeMount(hal_device);

Modified: branches/banshee/stable/src/Dap/Banshee.Dap.MassStorage/MassStorageDap.cs
==============================================================================
--- branches/banshee/stable/src/Dap/Banshee.Dap.MassStorage/MassStorageDap.cs	(original)
+++ branches/banshee/stable/src/Dap/Banshee.Dap.MassStorage/MassStorageDap.cs	Wed Jan 30 03:29:33 2008
@@ -69,6 +69,7 @@
         protected Hal.Device volume_device = null;
         protected Gnome.Vfs.Volume volume = null;
 
+
         public override InitializeResult Initialize(Hal.Device halDevice)
         {
             volume_device = halDevice;
@@ -89,7 +90,7 @@
                 return WaitForVolumeMount(volume_device);
             }
             
-            if(player_device["portable_audio_player.type"] == "ipod") {
+            if(IsPortableAudioPlayerType (player_device, "ipod")) {
                 if(File.Exists(IsAudioPlayerPath)) {
                     LogCore.Instance.PushInformation(
                         "Mass Storage Support Loading iPod",
@@ -108,8 +109,7 @@
             }
 
             // Detect player via HAL property or presence of .is_audo_player file in root
-            if(player_device["portable_audio_player.access_method"] != "storage" &&
-                !File.Exists(IsAudioPlayerPath)) {                
+            if(!IsMassStorage (player_device) && !File.Exists(IsAudioPlayerPath)) {
                 return InitializeResult.Invalid;
             }
 
@@ -804,5 +804,13 @@
             get { return Path.Combine(MountPoint, ".is_audio_player"); }
         }
 
+        protected static bool IsMassStorage (Hal.Device device)
+        {
+            if (device.PropertyExists ("portable_audio_player.access_method")) {
+                return device["portable_audio_player.access_method"] == "storage";
+            }
+
+            return IsPortableAudioPlayerType (device, "storage");
+        }
     }
 }

Modified: branches/banshee/stable/src/Dap/Banshee.Dap.Mtp/MtpDap.cs
==============================================================================
--- branches/banshee/stable/src/Dap/Banshee.Dap.Mtp/MtpDap.cs	(original)
+++ branches/banshee/stable/src/Dap/Banshee.Dap.Mtp/MtpDap.cs	Wed Jan 30 03:29:33 2008
@@ -84,10 +84,8 @@
 		{
             hal_device = halDevice;
 
-            // Make sure it's an MTP device.  The second check (against 'type') is an HAL spec.
-            if (!((hal_device.PropertyExists ("portable_audio_player.access_method.protocols") &&
-                    Array.IndexOf (hal_device.GetPropertyStringList ("portable_audio_player.access_method.protocols"), "mtp") != -1) ||
-                    hal_device["portable_audio_player.type"] == "mtp")) {
+            // Make sure it's an MTP device.
+            if (!IsPortableAudioPlayerType (hal_device, "mtp")) {
 				return InitializeResult.Invalid;
             }
 
@@ -609,5 +607,6 @@
 		public override bool IsPlaybackSupported {
 			get { return false; }
 		}
+
 	}
 }



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