conduit r1587 - in trunk: . conduit/modules
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1587 - in trunk: . conduit/modules
- Date: Thu, 24 Jul 2008 06:25:33 +0000 (UTC)
Author: jstowers
Date: Thu Jul 24 06:25:33 2008
New Revision: 1587
URL: http://svn.gnome.org/viewvc/conduit?rev=1587&view=rev
Log:
* conduit/modules/SynceModule.py: You can now view, and create
sync partnerships from the preferences window.
Modified:
trunk/ (props changed)
trunk/ChangeLog
trunk/conduit/modules/SynceModule.py
Modified: trunk/conduit/modules/SynceModule.py
==============================================================================
--- trunk/conduit/modules/SynceModule.py (original)
+++ trunk/conduit/modules/SynceModule.py Thu Jul 24 06:25:33 2008
@@ -13,11 +13,9 @@
import logging
log = logging.getLogger("modules.SynCE")
-import os
import os.path
import traceback
import dbus
-import dbus.glib
import threading
import gobject
import array
@@ -49,8 +47,58 @@
class SynceFactory(HalFactory.HalFactory):
+ SUPPORTED_PARTNERSHIPS = ("Calendar", "Contacts", "Tasks")
+
+ def __init__(self, **kwargs):
+ HalFactory.HalFactory.__init__(self, **kwargs)
+ self._found = False
+ self._item_types = {}
+ self._partnerships = []
+
+ def _get_item_types_rx(self, item_types):
+ self._item_types = item_types
+
+ def _get_partnerships_rx(self, partnerships):
+ self._partnerships = partnerships
+
+ def _create_partnership_rx(self, guid):
+ print args
+
+ def _create_partnership_error(self, e):
+ log.warn("Failed to create partnership: %s" % e._dbus_error_name)
+
+ def _on_create_partnership_clicked(self, sender, mod):
+ #create partnerships for Contact, Calendar, Tasks
+ ids = [id for id, name in self._item_types.items() if str(name) in self.SUPPORTED_PARTNERSHIPS]
+ self.engine.CreatePartnership(
+ "Conduit", #partnership name
+ ids, #ids of those items to sync
+ reply_handler=self._create_partnership_rx,
+ error_handler=self._create_partnership_error
+ )
+
+ def _found_device(self):
+ self._found = True
+
+ #call async so we dont block at startup
+ #reply_handler will be called with the method's return values as arguments; or
+ #the error_handler
+ self.engine = dbus.Interface(
+ dbus.SessionBus().get_object('org.synce.SyncEngine', '/org/synce/SyncEngine'),
+ 'org.synce.SyncEngine'
+ )
+ self.engine.GetItemTypes(
+ reply_handler=self._get_item_types_rx,
+ error_handler=lambda *args: None
+ )
+ self.engine.GetPartnerships(
+ reply_handler=self._get_partnerships_rx,
+ error_handler=lambda *args: None
+ )
+
def is_interesting(self, device, props):
if props.has_key("sync.plugin") and props["sync.plugin"]=="synce":
+ self._found_device()
return True
return False
@@ -62,6 +110,54 @@
def get_dataproviders(self, udi, **kwargs):
return [SynceContactsTwoWay, SynceCalendarTwoWay, SynceTasksTwoWay]
+
+ def setup_configuration_widget(self):
+
+ if self._found:
+ import gtk
+ import socket
+
+ vbox = gtk.VBox(False,5)
+ mod = gtk.ListStore(
+ gobject.TYPE_PYOBJECT, #parnership id
+ gobject.TYPE_PYOBJECT, #parnership guid
+ str,str,str) #device name, pc name, items
+ treeview = gtk.TreeView(mod)
+
+ #Three colums: device name, pc name, items
+ index = 2
+ for name in ("Device", "Computer", "Items to Synchronize"):
+ col = gtk.TreeViewColumn(
+ name,
+ gtk.CellRendererText(),
+ text=index)
+ treeview.append_column(col)
+ index = index + 1
+ vbox.pack_start(treeview,True,True)
+
+ btn = gtk.Button(None,gtk.STOCK_ADD)
+ btn.set_label("Create Partnership")
+ btn.connect("clicked", self._on_create_partnership_clicked, mod)
+ vbox.pack_start(btn, False, False)
+
+ #add the existing partnerships
+ for id,guid,name,hostname,devicename,storetype,items in self._partnerships:
+ mod.append((
+ id,
+ guid,
+ str(devicename),
+ str(hostname),
+ ", ".join([str(self._item_types[item]) for item in items]))
+ )
+ #disable partnership if one exists
+ if str(hostname) == socket.gethostname():
+ btn.set_sensitive(False)
+
+ return vbox
+ return None
+
+ def save_configuration(self, ok):
+ pass
class SyncEngineWrapper(object):
"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]