Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar

master
Marco Pesenti Gritti 18 years ago
commit 72c511ba61

@ -102,7 +102,7 @@ class Buddy(DBusGObject):
return None
if not self._activities.has_key(self._current_activity):
return None
return self._activities[self._current_activity]
return self._current_activity
elif pspec.name == "valid":
return self._valid
elif pspec.name == "owner":
@ -336,7 +336,8 @@ class Owner(Buddy):
def _cur_activity_changed_cb(self, activity_id):
if not self._activities.has_key(activity_id):
return
# This activity is local-only
activity_id = None
props = {'current-activity': activity_id}
self.set_properties(props)

@ -216,10 +216,6 @@ class PresenceService(dbus.service.Object):
if not activity.get_joined_buddies():
self._remove_activity(activity)
# current activity
if len(activities) > 0:
buddy.set_properties({'current-activity':activities[0]})
def _activity_invitation(self, tp, act_id):
activity = self._activities.get(act_id)
if activity:

@ -238,6 +238,7 @@ class ServerPlugin(gobject.GObject):
self._conn[CONN_INTERFACE_BUDDY_INFO].connect_to_signal('PropertiesChanged', self._buddy_properties_changed_cb)
self._conn[CONN_INTERFACE_BUDDY_INFO].connect_to_signal('ActivitiesChanged', self._buddy_activities_changed_cb)
self._conn[CONN_INTERFACE_BUDDY_INFO].connect_to_signal('CurrentActivityChanged', self._buddy_current_activity_changed_cb)
self._conn[CONN_INTERFACE_AVATARS].connect_to_signal('AvatarUpdated', self._avatar_updated_cb)
@ -316,8 +317,25 @@ class ServerPlugin(gobject.GObject):
self._conn[CONN_INTERFACE_BUDDY_INFO].SetActivities(self._joined_activities)
cur_activity = self._owner.props.current_activity
cur_activity_handle = 0
if not cur_activity:
cur_activity = ""
else:
cur_activity_handle = self._get_handle_for_activity(cur_activity)
if not cur_activity_handle:
# dont advertise a current activity that's not shared
cur_activity = ""
self._conn[CONN_INTERFACE_BUDDY_INFO].SetCurrentActivity(cur_activity, cur_activity_handle)
self._upload_avatar()
def _get_handle_for_activity(self, activity_id):
for (act, handle) in self._joined_activities:
if activity_id == act:
return handle
return None
def _status_changed_cb(self, state, reason):
if state == CONNECTION_STATUS_CONNECTING:
print 'connecting: %r' % reason
@ -455,6 +473,18 @@ class ServerPlugin(gobject.GObject):
activities_id = map(lambda x: x[0], activities)
self.emit("buddy-activities-changed", handle, activities_id)
def _buddy_current_activity_changed_cb(self, handle, activity, channel):
if handle == self._conn[CONN_INTERFACE].GetSelfHandle():
# ignore network events for Owner current activity changes since those
# are handled locally
return
if not len(activity) or not util.validate_activity_id(activity):
activity = None
prop = {'current-activity': activity}
logging.debug("Handle %s: current activity now %s" % (handle, activity))
self._buddy_properties_changed_cb(handle, prop)
def _new_channel_cb(self, object_path, channel_type, handle_type, handle, suppress_handler):
if handle_type == CONNECTION_HANDLE_TYPE_ROOM and channel_type == CHANNEL_TYPE_TEXT:
channel = Channel(self._conn._dbus_object._named_service, object_path)

Loading…
Cancel
Save