[banshee] [Mtp] Fix device detection



commit fbbb4a81d5b82e7f909f9bccd326a49750d54e34
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Aug 13 17:19:52 2010 -0700

    [Mtp] Fix device detection
    
    Using the HAL hardware backend, it says the device is on bus 2, but
    libmtp thinks it's on bus 0, so the device wasn't getting recognized.
    For now, just compare the device_number; given two devices on two
    buses, this could get things screwed up, but the tradeoff is worth it.

 .../Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs   |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
index c4d08d0..525d687 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
@@ -91,20 +91,27 @@ namespace Banshee.Dap.Mtp
 
             IVolume volume = device as IVolume;
             foreach (var v in devices) {
-                if (v.BusNumber == busnum && v.DeviceNumber == devnum) {
-                    if (volume != null)
+                // Using the HAL hardware backend, HAL says the busnum is 2, but libmtp says it's 0, so disabling that check
+                //if (v.BusNumber == busnum && v.DeviceNumber == devnum) {
+                if (v.DeviceNumber == devnum) {
+                    // If gvfs-gphoto has it mounted, unmount it
+                    if (volume != null) {
                         volume.Unmount ();
+                    }
+
                     for (int i = 5; i > 0 && mtp_device == null; i--) {
                         try {
                             mtp_device = MtpDevice.Connect (v);
-                        } catch (Exception){
-                            Log.Debug (string.Format ("Failed to connect to mtp device. Trying {0} more times...", i - i));
-                        }
-                        if (mtp_device == null)
+                        } catch (Exception) {}
+
+                        if (mtp_device == null) {
+                            Log.DebugFormat ("Failed to connect to mtp device. Trying {0} more times...", i - 1);
                             Thread.Sleep (2000);
+                        }
                     }
                 }
             }
+
             if (mtp_device == null) {
                 throw new InvalidDeviceException ();
             }



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