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-08-11 17:35:12 (GMT)
committer Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-08-20 13:02:28 (GMT)
commitd4c93ab9f9123e67cf5b838b85cd3c588195352a (patch)
treeddd6672497963785ec11bf757f50c821df70113b
parentd7541d409a087f54e5267dc4c47fcab31fede709 (diff)
Set the owner properties before the connections are connected
-rw-r--r--src/jarabe/model/buddy.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/jarabe/model/buddy.py b/src/jarabe/model/buddy.py
index 249b1f5..fd8033e 100644
--- a/src/jarabe/model/buddy.py
+++ b/src/jarabe/model/buddy.py
@@ -19,6 +19,8 @@ import logging
import gobject
import gconf
import dbus
+from telepathy.client import Connection
+from telepathy.interfaces import CONNECTION
from sugar.presence import presenceservice
from sugar.graphics.xocolor import XoColor
@@ -107,8 +109,8 @@ class OwnerBuddyModel(BaseBuddyModel):
self.props.present = True
client = gconf.client_get_default()
- self.props.nick = client.get_string("/desktop/sugar/user/nick")
- self.props.color = XoColor(client.get_string("/desktop/sugar/user/color"))
+ self.props.nick = client.get_string('/desktop/sugar/user/nick')
+ self.props.color = XoColor(client.get_string('/desktop/sugar/user/color'))
self.props.key = get_profile().pubkey
@@ -116,12 +118,27 @@ class OwnerBuddyModel(BaseBuddyModel):
self.connect('notify::color', self.__property_changed_cb)
self.connect('notify::current-activity', self.__current_activity_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)
+ bus = dbus.SessionBus()
+ bus.add_signal_receiver(
+ self.__name_owner_changed_cb,
+ signal_name='NameOwnerChanged',
+ dbus_interface='org.freedesktop.DBus')
- self._sync_properties()
+ bus_object = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
+ for service in bus_object.ListNames(dbus_interface='org.freedesktop.DBus'):
+ if service.startswith('org.freedesktop.Telepathy.Connection.'):
+ path = '/%s' % service.replace('.', '/')
+ Connection(service, path, bus,
+ ready_handler=self.__connection_ready_cb)
+
+ def __connection_ready_cb(self, connection):
+ self._sync_properties_on_connection(connection)
+
+ def __name_owner_changed_cb(self, name, old, new):
+ if name.startswith(CONNECTION) and not old and new:
+ path = '/' + name.replace('.', '/')
+ connection = Connection(name, path,
+ ready_handler=self.__connection_ready_cb)
def __property_changed_cb(self, pspec):
self._sync_properties()
@@ -136,7 +153,7 @@ class OwnerBuddyModel(BaseBuddyModel):
activity_id = ''
room_handle = 0
- connection[CONNECTION_INTERFACE_BUDDY_INFO].SetCurrentProperty(
+ connection[CONNECTION_INTERFACE_BUDDY_INFO].SetCurrentActivity(
activity_id,
room_handle,
reply_handler=self.__set_current_activity_cb,