[banshee] Revert "Mtp: Ignore mount/unmount events to fix device load (bgo#729438)"



commit 6b6302daccc1d4c6b97f78b0d084d4a6b48407f9
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Thu May 15 17:30:53 2014 +0200

    Revert "Mtp: Ignore mount/unmount events to fix device load (bgo#729438)"
    
    This reverts commit 0eb6554ff08efd209fac79d41e43fb5bc52c7b98
    because it broke MassStorage device load for some kind of
    devices.

 .../Banshee.Hardware.Gio/LowLevel/Manager.cs       |   54 +++++++++-----------
 .../Banshee.Dap.MassStorage/MassStorageSource.cs   |    7 +--
 2 files changed, 26 insertions(+), 35 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/Manager.cs 
b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/Manager.cs
index 42efeaa..f635b93 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/Manager.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/LowLevel/Manager.cs
@@ -3,10 +3,8 @@
 //
 // Author:
 //   Alex Launi <alex launi gmail com>
-//   Nicholas Little <arealityfarbetween googlemail com>
 //
 // Copyright (c) 2010 Alex Launi
-// Copyright (c) 2014 Nicholas Little
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -59,7 +57,6 @@ namespace Banshee.Hardware.Gio
             monitor = VolumeMonitor.Default;
             monitor.MountAdded += HandleMonitorMountAdded;
             monitor.MountRemoved += HandleMonitorMountRemoved;
-            monitor.VolumeAdded += HandleMonitorVolumeAdded;
             monitor.VolumeRemoved += HandleMonitorVolumeRemoved;
             volume_device_map= new Dictionary<IntPtr, GUdev.Device> ();
         }
@@ -74,22 +71,38 @@ namespace Banshee.Hardware.Gio
 
         void HandleMonitorMountAdded (object o, MountAddedArgs args)
         {
-            Hyena.Log.Debug ("(Ignored) MountAdded event received");
-        }
+            // Manually get the mount as gio-sharp translates it to the wrong managed object
+            // TODO: check if this workaround is still needed
+            var mount = GLib.MountAdapter.GetObject ((GLib.Object) args.Args [0]);
+            if (mount.Volume == null)
+                return;
 
-        void HandleMonitorMountRemoved (object o, MountRemovedArgs args)
-        {
-            Hyena.Log.Debug ("(Ignored) MountRemoved event received");
+            var device = GudevDeviceFromGioMount (mount);
+            if (device == null) {
+                Hyena.Log.Debug (string.Format ("Tried to mount {0}/{1} with no matching udev device", 
mount.Volume.Name, mount.Volume.Uuid));
+                return;
+            }
+
+            volume_device_map [mount.Volume.Handle] = device;
+            var h = DeviceAdded;
+            if (h != null) {
+                var v = new RawVolume (mount.Volume,
+                                          this,
+                                          new GioVolumeMetadataSource (mount.Volume),
+                                          new UdevMetadataSource (device));
+                h (this, new MountArgs (HardwareManager.Resolve (new Device (v))));
+            }
         }
 
-        private void HandleMonitorVolumeAdded (object o, VolumeAddedArgs args)
+        void HandleMonitorMountRemoved (object o, MountRemovedArgs args)
         {
-            var volume = GLib.VolumeAdapter.GetObject ((GLib.Object) args.Args [0]);
-            if (volume == null) {
+            // Manually get the mount as gio-sharp translates it to the wrong managed object
+            var mount = GLib.MountAdapter.GetObject ((GLib.Object) args.Args [0]);
+            if (mount.Volume == null) {
                 return;
             }
 
-            VolumeAdded (volume);
+            VolumeRemoved (mount.Volume);
         }
 
         void HandleMonitorVolumeRemoved (object o, VolumeRemovedArgs args)
@@ -102,23 +115,6 @@ namespace Banshee.Hardware.Gio
             VolumeRemoved (volume);
         }
 
-        private void VolumeAdded (GLib.IVolume volume)
-        {
-            var device = GudevDeviceFromGioVolume (volume);
-            volume_device_map [volume.Handle] = device;
-            var h = DeviceAdded;
-            if (h != null) {
-                if (device == null) {
-                    Hyena.Log.Debug (string.Format ("Tried to mount {0}/{1} with no matching udev device", 
volume.Name, volume.Uuid));
-                    return;
-                }
-                var v = new RawVolume (volume,
-                    this,
-                    new GioVolumeMetadataSource (volume),
-                    new UdevMetadataSource (device));
-                h (this, new MountArgs (HardwareManager.Resolve (new Device (v))));
-            }
-        }
 
         void VolumeRemoved (GLib.IVolume volume)
         {
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs 
b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
index 4e8ab6d..3c54f36 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
@@ -63,15 +63,10 @@ namespace Banshee.Dap.MassStorage
             base.DeviceInitialize (device);
 
             volume = device as IVolume;
-
-            if (volume == null || (usb_device = volume.ResolveRootUsbDevice ()) == null) {
+            if (volume == null || !volume.IsMounted || (usb_device = volume.ResolveRootUsbDevice ()) == 
null) {
                 throw new InvalidDeviceException ();
             }
 
-            if (volume.CanMount) {
-                volume.Mount ();
-            }
-
             ms_device = DeviceMapper.Map (this);
             try {
                 if (ms_device.ShouldIgnoreDevice () || !ms_device.LoadDeviceConfiguration ()) {


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