conduit r1694 - in trunk: . conduit conduit/platform



Author: jstowers
Date: Fri Aug 29 23:38:42 2008
New Revision: 1694
URL: http://svn.gnome.org/viewvc/conduit?rev=1694&view=rev

Log:
	* conduit/Vfs.py:
	* conduit/platform/FileGio.py:
	* conduit/platform/FileGnomeVfs.py:
	* conduit/platform/FilePython.py:
	* conduit/platform/__init__.py: Move volume monitor into the FileImpl
	classes.


Modified:
   trunk/   (props changed)
   trunk/ChangeLog
   trunk/conduit/Vfs.py
   trunk/conduit/platform/FileGio.py
   trunk/conduit/platform/FileGnomeVfs.py
   trunk/conduit/platform/FilePython.py
   trunk/conduit/platform/__init__.py

Modified: trunk/conduit/Vfs.py
==============================================================================
--- trunk/conduit/Vfs.py	(original)
+++ trunk/conduit/Vfs.py	Fri Aug 29 23:38:42 2008
@@ -15,10 +15,11 @@
     import conduit.platform.FileGnomeVfs as FileImpl
 elif conduit.FILE_IMPL == "GIO":
     import conduit.platform.FileGio as FileImpl
+elif conduit.FILE_IMPL == "Python":
+    import conduit.platform.FilePython as FileImpl
 else:
     raise Exception("File Implementation %s Not Supported" % conduit.FILE_IMPL)
 
-
 #
 # URI Functions
 #
@@ -72,7 +73,7 @@
     
 def uri_open(uri):
     """
-    Opens a gnomevfs or xdg compatible uri.
+    Opens a xdg compatible uri.
     """
     uri = _ensure_type(uri)
     APP = "xdg-open"
@@ -285,41 +286,13 @@
             gnomevfs.monitor_cancel(self._monitor_folder_id)
             self._monitor_folder_id = None
 
-class VolumeMonitor(Singleton.Singleton, gobject.GObject):
-
-    __gsignals__ = {
-        "volume-mounted" :      (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
-            gobject.TYPE_STRING]),      #udi
-        "volume-unmounted" :    (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
-            gobject.TYPE_STRING])       #udi
-
-    }
-
-    def __init__(self):
-        gobject.GObject.__init__(self)
-        self._impl = gnomevfs.VolumeMonitor()
-        self._impl.connect("volume-mounted", self._mounted_unmounted_cb, "volume-mounted")
-        self._impl.connect("volume-unmounted", self._mounted_unmounted_cb, "volume-unmounted")
-
-    def _mounted_unmounted_cb(self, sender, volume, signalname):
-        self.emit(signalname, volume.get_hal_udi())
-
-    def get_mounted_volumes(self):
-        return [volume.get_hal_udi() for volume in self._impl.get_mounted_volumes()]
-
-    def volume_is_removable(self, path):
-        return self._impl.get_volume_for_path(path).is_user_visible()
-
-    def volume_get_fstype(self, path):
-        return self._impl.get_volume_for_path(path).get_filesystem_type()
-
-    def volume_get_root_uri(self, path):
-        return self._impl.get_volume_for_path(path).get_activation_uri()
+class VolumeMonitor(FileImpl.VolumeMonitor):
+    pass
 
 #
 # Scanner ThreadManager
 #
-class FolderScannerThreadManager(object):
+class FolderScannerThreadManager:
     """
     Manages many FolderScanner threads. This involves joining and cancelling
     said threads, and respecting a maximum num of concurrent threads limit

Modified: trunk/conduit/platform/FileGio.py
==============================================================================
--- trunk/conduit/platform/FileGio.py	(original)
+++ trunk/conduit/platform/FileGio.py	Fri Aug 29 23:38:42 2008
@@ -163,4 +163,7 @@
             log.warn("File transfer error: %s" % e)
             return False, None
 
+class VolumeMonitor(conduit.platform.VolumeMonitor):
+    pass
+
 

Modified: trunk/conduit/platform/FileGnomeVfs.py
==============================================================================
--- trunk/conduit/platform/FileGnomeVfs.py	(original)
+++ trunk/conduit/platform/FileGnomeVfs.py	Fri Aug 29 23:38:42 2008
@@ -4,6 +4,7 @@
     from gnome import gnomevfs # for maemo
 
 import conduit.platform
+import conduit.utils.Singleton as Singleton
 
 import logging
 log = logging.getLogger("platform.FileGnomeVfs")
@@ -223,7 +224,28 @@
             log.warn("File transfer error: %s" % e)
             return False, None
     
-    
+class VolumeMonitor(Singleton.Singleton, conduit.platform.VolumeMonitor):
+
+    def __init__(self):
+        conduit.platform.VolumeMonitor(self)
+        self._vm = gnomevfs.VolumeMonitor()
+        self._vm.connect("volume-mounted", self._mounted_unmounted_cb, "volume-mounted")
+        self._vm.connect("volume-unmounted", self._mounted_unmounted_cb, "volume-unmounted")
+
+    def _mounted_unmounted_cb(self, sender, volume, signalname):
+        self.emit(signalname, volume.get_hal_udi())
+
+    def get_mounted_volumes(self):
+        return [volume.get_hal_udi() for volume in self._vm.get_mounted_volumes()]
+
+    def volume_is_removable(self, path):
+        return self._vm.get_volume_for_path(path).is_user_visible()
+
+    def volume_get_fstype(self, path):
+        return self._vm.get_volume_for_path(path).get_filesystem_type()
+
+    def volume_get_root_uri(self, path):
+        return self._vm.get_volume_for_path(path).get_activation_uri()
     
 
 

Modified: trunk/conduit/platform/FilePython.py
==============================================================================
--- trunk/conduit/platform/FilePython.py	(original)
+++ trunk/conduit/platform/FilePython.py	Fri Aug 29 23:38:42 2008
@@ -12,6 +12,8 @@
     def __init__(self, URI):
         self._path = URI.split("file://")[-1]
 
-
 class FileTransferImpl(conduit.platform.FileTransfer):
     pass
+
+class VolumeMonitor(conduit.platform.VolumeMonitor):
+    pass

Modified: trunk/conduit/platform/__init__.py
==============================================================================
--- trunk/conduit/platform/__init__.py	(original)
+++ trunk/conduit/platform/__init__.py	Fri Aug 29 23:38:42 2008
@@ -1,9 +1,7 @@
 import gobject
 
 class File:
-
     SCHEMES = ()
-
     def __init__(self, URI):
         pass
         
@@ -68,8 +66,30 @@
     def transfer(self, cancel_func):
         raise NotImplementedError
 
-class Settings:
+class VolumeMonitor(gobject.GObject):
+    __gsignals__ = {
+        "volume-mounted" :      (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
+            gobject.TYPE_STRING]),      #udi
+        "volume-unmounted" :    (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
+            gobject.TYPE_STRING])       #udi
+
+    }
+    def __init__(self):
+        gobject.GObject.__init__(self)
+
+    def get_mounted_volumes(self):
+        return []
 
+    def volume_is_removable(self, path):
+        return False
+
+    def volume_get_fstype(self, path):
+        return None
+
+    def volume_get_root_uri(self, path):
+        return None
+
+class Settings:
     def __init__(self, defaults, changedCb):
         self._defaults = defaults
         self._changedCb = changedCb



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