Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-07-02 11:43:08 (GMT)
committer Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-08-20 13:02:27 (GMT)
commit57be757f908c76742a60eb844104b10082d25403 (patch)
treefcf48bdfa7da068032a8b19cf6fd67352fea25e0
parent6848641ea7234543a7dc7451dd587845278540df (diff)
Emit owner property changes across the network
-rw-r--r--src/jarabe/model/buddy.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/jarabe/model/buddy.py b/src/jarabe/model/buddy.py
index e20f947..12ed229 100644
--- a/src/jarabe/model/buddy.py
+++ b/src/jarabe/model/buddy.py
@@ -22,8 +22,12 @@ import gconf
from sugar.presence import presenceservice
from sugar.graphics.xocolor import XoColor
+from jarabe.util.telepathy import connection_watcher
+
_NOT_PRESENT_COLOR = "#d5d5d5,#FFFFFF"
+CONNECTION_INTERFACE_BUDDY_INFO = 'org.laptop.Telepathy.BuddyInfo'
+
class BaseBuddyModel(gobject.GObject):
__gtype_name__ = 'SugarBaseBuddyModel'
@@ -94,6 +98,47 @@ class OwnerBuddyModel(BaseBuddyModel):
self.props.nick = client.get_string("/desktop/sugar/user/nick")
self.props.color = XoColor(client.get_string("/desktop/sugar/user/color"))
+ self.connect('notify::nick', self.__property_changed_cb)
+ self.connect('notify::color', self.__property_changed_cb)
+
+ logging.info('KILL_PS should set the properties before the connection'
+ 'is connected, if possible')
+ conn_watcher = connection_watcher.get_instance()
+ conn_watcher.connect('connection-added', self.__connection_added_cb)
+
+ self._sync_properties()
+
+ def __property_changed_cb(self, pspec):
+ self._sync_properties()
+
+ def _sync_properties(self):
+ conn_watcher = connection_watcher.get_instance()
+ for connection in conn_watcher.get_connections():
+ self._sync_properties_on_connection(connection)
+
+ def _sync_properties_on_connection(self, connection):
+ if CONNECTION_INTERFACE_BUDDY_INFO in connection:
+ properties = {}
+ if self.props.key is not None:
+ properties['key'] = self.props.key
+ if self.props.color is not None:
+ properties['color'] = self.props.color.to_string()
+
+ logging.debug('calling SetProperties with %r', properties)
+ connection[CONNECTION_INTERFACE_BUDDY_INFO].SetProperties(
+ properties,
+ reply_handler=self.__set_properties_cb,
+ error_handler=self.__error_handler_cb)
+
+ def __set_properties_cb(self):
+ logging.debug('__set_properties_cb')
+
+ def __error_handler_cb(self, error):
+ raise RuntimeError(error)
+
+ def __connection_added_cb(self, conn_watcher, connection):
+ self._sync_properties_on_connection(connection)
+
def is_owner(self):
return True