[banshee] [DAP] Ensure unmounted devices are not ignored.



commit 921de0bbc113a0f936c9dac9949fdedfd0b350d0
Author: Alan McGovern <alan mcgovern gmail com>
Date:   Fri Sep 17 20:34:06 2010 +0100

    [DAP] Ensure unmounted devices are not ignored.
    
    When an unmounted volume is detected, attempt to mount it so that it
    does not end up ignored by banshee. This allows banshee to detect and
    load unmounted idevices, mtp devices and mass storage devices.
    Fixes #488149.

 .../Banshee.Hardware.Gio/LowLevel/RawVolume.cs     |   11 ++++++++---
 .../Banshee.Gio/Banshee.Hardware.Gio/Volume.cs     |   12 ++++++++++++
 .../Banshee.Hal/Banshee.HalBackend/Volume.cs       |   10 ++++++++++
 .../Banshee.Services/Banshee.Hardware/IVolume.cs   |    4 ++++
 .../Banshee.Dap.AppleDevice/AppleDeviceSource.cs   |    5 +++++
 .../Banshee.Dap.Ipod/PodSleuthDevice.cs            |   13 +++++++++++++
 6 files changed, 52 insertions(+), 3 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawVolume.cs b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawVolume.cs
index a487d9a..666511d 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawVolume.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/RawVolume.cs
@@ -206,8 +206,12 @@ namespace Banshee.Hardware.Gio
 
         public void Mount ()
         {
-            if (CanMount)
-                Volume.Mount (MountMountFlags.None, null, null, null);
+            if (CanMount) {
+                ManualResetEvent handle = new ManualResetEvent (false);
+                Volume.Mount (MountMountFlags.None, null, null, delegate { handle.Set (); });
+                if (!handle.WaitOne (TimeSpan.FromSeconds (5)))
+                    Hyena.Log.Information ("Timed out trying to mount {0}", Name);
+            }
         }
 
         public void Unmount ()
@@ -215,7 +219,8 @@ namespace Banshee.Hardware.Gio
             if (CanUnmount) {
                 ManualResetEvent handle = new ManualResetEvent (false);
                 Volume.MountInstance.UnmountWithOperation (MountUnmountFlags.Force, null, null, delegate { handle.Set (); });
-                handle.WaitOne (TimeSpan.FromSeconds (5));
+                if (!handle.WaitOne (TimeSpan.FromSeconds (5)))
+                    Hyena.Log.Information ("Timed out trying to unmount {0}", Name);
             }
         }
 
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/Volume.cs b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/Volume.cs
index 50f3610..660457f 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/Volume.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/Volume.cs
@@ -51,6 +51,10 @@ namespace Banshee.Hardware.Gio
             get { return volume.MountPoint; }
         }
 
+        public bool IsMounted {
+            get { return volume.IsMounted; }
+        }
+        
         public bool IsReadOnly {
             get { return volume.IsReadOnly; }
         }
@@ -81,6 +85,9 @@ namespace Banshee.Hardware.Gio
             get { return volume.CanEject; }
         }
 
+        public bool CanMount {
+            get { return volume.CanMount; }
+        }
         public bool CanUnmount {
             get { return volume.CanUnmount; }
         }
@@ -96,6 +103,11 @@ namespace Banshee.Hardware.Gio
             volume.Eject ();
         }
 
+        public void Mount ()
+        {
+            volume.Mount ();
+        }
+
         public void Unmount ()
         {
             volume.Unmount ();
diff --git a/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs b/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs
index a196925..c69150a 100644
--- a/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs
+++ b/src/Backends/Banshee.Hal/Banshee.HalBackend/Volume.cs
@@ -157,10 +157,20 @@ namespace Banshee.HalBackend
             }
         }
 
+        public bool CanMount {
+            get { return Array.IndexOf <string>(method_names, "Mount") >= 0; }
+        }
+
         public bool CanUnmount {
             get { return Array.IndexOf<string> (method_names, "Unmount") >= 0; }
         }
 
+        public void Mount ()
+        {
+            if (CanMount && HalDevice.IsVolume)
+                HalDevice.Volume.Mount ();
+        }
+
         public void Unmount ()
         {
             if (CanUnmount && HalDevice.IsVolume) {
diff --git a/src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs b/src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs
index 4020a49..185d5b0 100644
--- a/src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs
+++ b/src/Core/Banshee.Services/Banshee.Hardware/IVolume.cs
@@ -34,6 +34,7 @@ namespace Banshee.Hardware
     {
         string DeviceNode { get; }
         string MountPoint { get; }
+        bool IsMounted { get; }
         bool IsReadOnly { get; }
         ulong Capacity { get; }
         long Available { get; }
@@ -45,6 +46,9 @@ namespace Banshee.Hardware
         bool CanEject { get; }
         void Eject ();
 
+        bool CanMount { get; }
+        void Mount ();
+
         bool CanUnmount { get; }
         void Unmount ();
     }
diff --git a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
index d3137bd..da3d3ef 100644
--- a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
+++ b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
@@ -66,6 +66,11 @@ namespace Banshee.Dap.AppleDevice
                 throw new InvalidDeviceException ();
             }
 
+            if (!Volume.IsMounted) {
+                Hyena.Log.Information ("Found potential unmounted iDevice, trying to mount it now");
+                Volume.Mount ();
+            }
+
             Device = new GPod.Device (Volume.MountPoint);
 
             if (GPod.ITDB.GetControlPath (Device) == null) {
diff --git a/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDevice.cs b/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDevice.cs
index 08140a2..ad380ff 100644
--- a/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDevice.cs
+++ b/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/PodSleuthDevice.cs
@@ -257,6 +257,11 @@ namespace Banshee.Dap.Ipod
             get { return volume.Name; }
         }
 
+        public void Mount ()
+        {
+            return volume.Mount ();
+        }
+
         public void Unmount ()
         {
             volume.Unmount ();
@@ -290,6 +295,10 @@ namespace Banshee.Dap.Ipod
             get { return volume.MountPoint; }
         }
 
+        public bool IsMounted {
+            get { return volume.IsMounted; }
+        }
+
         public bool IsReadOnly {
             get { return volume.IsReadOnly; }
         }
@@ -318,6 +327,10 @@ namespace Banshee.Dap.Ipod
             get { return volume.CanEject; }
         }
 
+        public bool CanMount {
+            get { return volume.CanMount; }
+        }
+        
         public bool CanUnmount {
             get { return volume.CanEject; }
         }



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