conduit r1918 - in trunk: . conduit tools/eog-plugin tools/nautilus-extension tools/totem-plugin



Author: jstowers
Date: Sat Feb 28 10:40:51 2009
New Revision: 1918
URL: http://svn.gnome.org/viewvc/conduit?rev=1918&view=rev

Log:
2009-02-27  John Stowers  <john stowers gmail com>

	* conduit/libconduit.py:
	* tools/eog-plugin/conduit.py:
	* tools/nautilus-extension/conduit.py:
	* tools/totem-plugin/conduit.py: Store all plugin
	config data in XDG_CONFIG_HOME, and be more robust when
	conduit is started and stopped per session



Modified:
   trunk/ChangeLog
   trunk/conduit/libconduit.py
   trunk/tools/eog-plugin/conduit.py
   trunk/tools/nautilus-extension/conduit.py
   trunk/tools/totem-plugin/conduit.py

Modified: trunk/conduit/libconduit.py
==============================================================================
--- trunk/conduit/libconduit.py	(original)
+++ trunk/conduit/libconduit.py	Sat Feb 28 10:40:51 2009
@@ -1,8 +1,10 @@
-import os
+import os.path
 import gobject
 import gtk
 import dbus, dbus.glib
 
+PLUGIN_CONFIG_DIR = os.environ.get("XDG_CONFIG_HOME", os.path.join(os.environ['HOME'], ".config", "conduit", "plugin-config"))
+
 APPLICATION_DBUS_IFACE="org.conduit.Application"
 CONDUIT_DBUS_IFACE="org.conduit.Conduit"
 EXPORTER_DBUS_IFACE="org.conduit.Exporter"
@@ -14,7 +16,7 @@
 
 class ConduitWrapper:
 
-    CONFIG_PATH='~/.conduit/test-plugin'
+    CONFIG_NAME="test-plugin"
     NAME_IDX=0
     URI_IDX=1
     STATUS_IDX=2
@@ -46,6 +48,14 @@
                         dbus_interface=CONDUIT_DBUS_IFACE
                         )
 
+        self.config_path = os.path.join(PLUGIN_CONFIG_DIR, self.CONFIG_NAME)
+        if not os.path.exists(self.config_path):
+            self._debug("Creating config dir: %s" % self.config_path)
+            try:
+                os.makedirs(self.config_path)
+            except OSError:
+                pass
+
     def _debug(self, msg):
         if self.debug:
             print "LCW: ", msg
@@ -55,14 +65,12 @@
         Gets the latest configuration for a given
         dataprovider
         """
-        config_path = os.path.expanduser(self.CONFIG_PATH)
         xml = None
-
         try:
-            if not os.path.exists(os.path.join(config_path, self.name)):
+            if not os.path.exists(os.path.join(self.config_path, self.name)):
                 return
 
-            f = open(os.path.join(config_path, self.name), 'r')
+            f = open(os.path.join(self.config_path, self.name), 'r')
             xml = f.read()
             f.close()
         except OSError, e:
@@ -76,13 +84,8 @@
         """
         Saves the configuration XML from a given dataprovider again
         """
-        config_path = os.path.expanduser(self.CONFIG_PATH)
-
         try:
-            if not os.path.exists(config_path):
-                os.mkdir(config_path)
-
-            f = open(os.path.join(config_path, self.name), 'w')
+            f = open(os.path.join(self.config_path, self.name), 'w')
             f.write(xml)
             f.close()
         except OSError, e:
@@ -107,7 +110,8 @@
             self.conduit.Sync(dbus_interface=CONDUIT_DBUS_IFACE)
 
     def _configure_error_handler(self, error):
-        pass
+        self._debug("CONFIGURE ERROR: %s" % error)
+        self.store.set_value(self._get_rowref(), self.STATUS_IDX, "aborted")
 
     def _on_sync_started(self):
         self.store.set_value(self._get_rowref(), self.STATUS_IDX, "uploading")
@@ -324,6 +328,9 @@
             self._debug("Starting conduit via DBus activation")
             self.dbus_iface.StartServiceByName(APPLICATION_DBUS_IFACE, 0)
             return False
+        else:
+            #not running, not started
+            return False
 
     def sync(self):
         if self.connected():

Modified: trunk/tools/eog-plugin/conduit.py
==============================================================================
--- trunk/tools/eog-plugin/conduit.py	(original)
+++ trunk/tools/eog-plugin/conduit.py	Sat Feb 28 10:40:51 2009
@@ -24,7 +24,7 @@
 
 class EogConduitWrapper(libconduit.ConduitWrapper):
 
-    CONFIG_PATH='~/.conduit/eog-plugin'
+    CONFIG_NAME="eog-plugin"
 
     def add_rowref(self):
         #store the rowref in the store with the icon conduit gave us
@@ -47,7 +47,7 @@
                                         debug=self.debug
                                         )
         self.conduit.connect("conduit-started", self._on_conduit_started)
-        self.running = self.conduit.connect_to_conduit(startConduit=True)
+        self.running = self.conduit.connect_to_conduit(startConduit=False)
 
         #dictionary holding items that are set sensitive or not when
         #conduit is started/stopped

Modified: trunk/tools/nautilus-extension/conduit.py
==============================================================================
--- trunk/tools/nautilus-extension/conduit.py	(original)
+++ trunk/tools/nautilus-extension/conduit.py	Sat Feb 28 10:40:51 2009
@@ -38,7 +38,6 @@
 DEBUG = True
 FOLDER_TWOWAY = "FolderTwoWay"
 FOLDER_TWOWAY_CONFIG = "<configuration><folder type='string'>%s</folder><folderGroupName type='string'>Home</folderGroupName><includeHidden type='bool'>False</includeHidden></configuration>"
-CONFIG_PATH = '~/.conduit/nautilus-extension'
 SUPPORTED_SINKS = {
     "FlickrTwoWay"      :   "Upload to Flickr",
     "PicasaTwoWay"      :   "Upload to Picasa",
@@ -59,6 +58,13 @@
         self.conduitApp = conduitApplication
         self.conduit = None
 
+        self.config_path = os.path.join(libconduit.PLUGIN_CONFIG_DIR, "nautilus-extension")
+        if not os.path.exists(self.config_path):
+            try:
+                os.makedirs(self.config_path)
+            except OSError:
+                pass
+
     def activate_cb(self, menu, folder):
         """
         This is the callback method that can be attached to the
@@ -120,12 +126,10 @@
         Gets the latest configuration for a given
         dataprovider
         """
-        config_path = os.path.expanduser(CONFIG_PATH)
-
-        if not os.path.exists(os.path.join(config_path, sink_name)):
+        if not os.path.exists(os.path.join(self.config_path, sink_name)):
            return
 
-        f = open(os.path.join(config_path, sink_name), 'r')
+        f = open(os.path.join(self.config_path, sink_name), 'r')
         xml = f.read ()
         f.close()
 
@@ -135,12 +139,7 @@
         """
         Saves the configuration xml from a given dataprovider again
         """
-        config_path = os.path.expanduser(CONFIG_PATH)
-
-        if not os.path.exists(config_path):
-           os.mkdir(config_path)
-
-        f = open(os.path.join(config_path, sink_name), 'w')
+        f = open(os.path.join(self.config_path, sink_name), 'w')
         f.write(xml)
         f.close()
         
@@ -163,10 +162,8 @@
         self.conduit.Sync(dbus_interface=libconduit.CONDUIT_DBUS_IFACE)
 
     def _configure_error_handler(self, error):
-        """
-        Nothing to do anymore
-        """
-        pass
+        print "CONFIGURE ERROR: %s" % error
+        self.ss.DeleteConduit(self.conduit, dbus_interface=libconduit.SYNCSET_DBUS_IFACE)
 
 class ConduitExtension(nautilus.MenuProvider):
     """

Modified: trunk/tools/totem-plugin/conduit.py
==============================================================================
--- trunk/tools/totem-plugin/conduit.py	(original)
+++ trunk/tools/totem-plugin/conduit.py	Sat Feb 28 10:40:51 2009
@@ -18,7 +18,7 @@
 
 class TotemConduitWrapper(libconduit.ConduitWrapper):
 
-    CONFIG_PATH='~/.conduit/totem-plugin'
+    CONFIG_NAME="totem-plugin"
 
     def add_rowref(self):
         #store the rowref in the store with the icon conduit gave us



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