diff --git a/shell/PresenceService/Buddy.py b/shell/PresenceService/Buddy.py index ae223c23..238e0d49 100644 --- a/shell/PresenceService/Buddy.py +++ b/shell/PresenceService/Buddy.py @@ -44,6 +44,11 @@ class BuddyDBusHelper(dbus.service.Object): def LeftActivity(self, object_path): pass + @dbus.service.signal(BUDDY_DBUS_INTERFACE, + signature="as") + def PropertyChanged(self, prop_list): + pass + @dbus.service.method(BUDDY_DBUS_INTERFACE, in_signature="", out_signature="ay") def getIcon(self): @@ -73,7 +78,9 @@ class BuddyDBusHelper(dbus.service.Object): def getProperties(self): props = {} props['name'] = self._parent.get_name() - props['ip4_address'] = self._parent.get_address() + addr = self._parent.get_address() + if addr: + props['ip4_address'] = addr props['owner'] = self._parent.is_owner() color = self._parent.get_color() if color: @@ -174,6 +181,8 @@ class Buddy(object): print 'Requesting buddy icon %s' % self._nick_name self._request_buddy_icon(service) self._color = service.get_one_property('color') + if self._color: + self._dbus_helper.PropertyChanged(['color']) if self._valid: self._dbus_helper.ServiceAppeared(service.object_path()) @@ -290,8 +299,9 @@ class Owner(Buddy): # service added to the Owner determines the owner's address source_addr = service.get_source_address() if self._address is None: - if source_addr in self._ps.is_local_ip_address(source_addr): + if self._ps.is_local_ip_address(source_addr): self._address = source_addr + self._dbus_helper.PropertyChanged(['ip4_address']) return Buddy.add_service(self, service) def is_owner(self): diff --git a/shell/PresenceService/PresenceService.py b/shell/PresenceService/PresenceService.py index a650a5fc..56b54a32 100644 --- a/shell/PresenceService/PresenceService.py +++ b/shell/PresenceService/PresenceService.py @@ -266,6 +266,7 @@ class PresenceService(object): owner_nick = env.get_nick_name() objid = self._get_next_object_id() self._owner = Buddy.Owner(self, self._bus_name, objid, owner_nick) + self._buddies[owner_nick] = self._owner self._started = False diff --git a/shell/session/Session.py b/shell/session/Session.py index ef76c58c..e240fad0 100644 --- a/shell/session/Session.py +++ b/shell/session/Session.py @@ -41,6 +41,13 @@ class MatchboxProcess(Process): def get_name(self): return 'Matchbox' +class DBusMonitorProcess(Process): + def __init__(self): + Process.__init__(self, "dbus-monitor --session") + + def get_name(self): + return 'dbus-monitor' + class Session: """Takes care of running the shell and all the sugar processes""" @@ -64,6 +71,10 @@ class Session: process = DbusProcess() process.start() + if 0: + dbm = DBusMonitorProcess() + dbm.start() + console = ConsoleWindow() logger.start('Shell', console) diff --git a/sugar/presence/Buddy.py b/sugar/presence/Buddy.py index dc5427d7..7d4f9ac0 100644 --- a/sugar/presence/Buddy.py +++ b/sugar/presence/Buddy.py @@ -14,6 +14,8 @@ class Buddy(gobject.GObject): 'joined-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), 'left-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + 'property-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])) } @@ -34,9 +36,7 @@ class Buddy(gobject.GObject): self._buddy.connect_to_signal('JoinedActivity', self._joined_activity_cb) self._buddy.connect_to_signal('LeftActivity', self._left_activity_cb) self._buddy.connect_to_signal('PropertyChanged', self._property_changed_cb) - self._properties = self._buddy.getProperties() - if not self._properties.has_key('color'): - self._properties['color'] = "#deadbe" + self._property_changed_cb([]) def object_path(self): return self._object_path @@ -78,6 +78,8 @@ class Buddy(gobject.GObject): def _handle_property_changed_signal(self, prop_list): self._properties = self._buddy.getProperties() + self.emit('property-changed', prop_list) + return False def _property_changed_cb(self, prop_list): gobject.idle_add(self._handle_property_changed_signal, prop_list)