[conduit] RemovableDeviceFactory now support gio



commit 68de37fd5e5da9b5c0a77d43b7fb593ea649921a
Author: John Stowers <john stowers gmail com>
Date:   Wed Sep 22 15:46:04 2010 +1200

    RemovableDeviceFactory now support gio

 conduit/modules/FileModule/FileModule.py |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/conduit/modules/FileModule/FileModule.py b/conduit/modules/FileModule/FileModule.py
index 854ed9c..03446b5 100644
--- a/conduit/modules/FileModule/FileModule.py
+++ b/conduit/modules/FileModule/FileModule.py
@@ -160,6 +160,7 @@ class RemovableDeviceFactory(SimpleFactory.SimpleFactory):
         SimpleFactory.SimpleFactory.__init__(self, **kwargs)
         self._volumes = {}
         self._categories = {}
+
         self._vm = gio.volume_monitor_get()
         self._vm.connect("mount-added",self._volume_mounted_cb)
         self._vm.connect("mount-removed",self._volume_unmounted_cb)
@@ -168,14 +169,18 @@ class RemovableDeviceFactory(SimpleFactory.SimpleFactory):
         #The volume uuid is not always present, so use the mounted root URI instead
         return gmount.get_root().get_uri()
 
+    def _inspect_and_add_volume(self, device_udi, gmount):
+        #Checks for preconfigured conduits, calls item_added as needed
+        mount = gmount.get_root().get_uri()
+        label = gmount.get_name()
+        self._check_preconfigured(device_udi, mount, label)
+        self.item_added(device_udi, mount=mount, label=label)
+
     def _volume_mounted_cb(self, monitor, gmount):
         device_udi = self._get_mount_udi(gmount)
         log.info("Volume mounted, %s" % device_udi)
         if device_udi:
-            mount = gmount.get_root().get_uri()
-            label = gmount.get_name()
-            self._check_preconfigured(device_udi, mount, label)
-            self.item_added(device_udi, mount=mount, label=label)
+            self._inspect_and_add_volume(device_udi, gmount)
 
     def _volume_unmounted_cb(self, monitor, gmount):
         device_udi = self._get_mount_udi(gmount)
@@ -227,12 +232,10 @@ class RemovableDeviceFactory(SimpleFactory.SimpleFactory):
         """
         Called after initialised to detect already connected volumes
         """
-        for m in self._vm.get_mounts():
-            device_udi = self._get_mount_udi(mount)
+        for gmount in self._vm.get_mounts():
+            device_udi = self._get_mount_udi(gmount)
             if device_udi:
-                mount,label = volumes[device_udi]
-                self._check_preconfigured(device_udi, mount, label)
-                self.item_added(device_udi, mount=mount, label=label)
+                self._inspect_and_add_volume(device_udi, gmount)
 
     def emit_added(self, klass, initargs, category):
         """



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