Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-05-23 17:39:24 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-05-24 17:55:31 (GMT)
commit3c2bdfc3468f2b4b1787971c7bfe82c740b96991 (patch)
tree3eaf65884d6e0348c750e1e24e0d4db3bdfe09a2
parent3444acae8f28e0778b7c22f31985effb1d7b8bb4 (diff)
services/presence/server_plugin: implement _new_channel_cb asynchronously
-rw-r--r--services/presence/server_plugin.py56
1 files changed, 42 insertions, 14 deletions
diff --git a/services/presence/server_plugin.py b/services/presence/server_plugin.py
index 49280e3..2871df8 100644
--- a/services/presence/server_plugin.py
+++ b/services/presence/server_plugin.py
@@ -905,24 +905,52 @@ class ServerPlugin(gobject.GObject):
_logger.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):
+ def _new_channel_cb(self, object_path, channel_type, handle_type, handle,
+ suppress_handler):
"""Handle creation of a new channel
"""
- if handle_type == CONNECTION_HANDLE_TYPE_ROOM and channel_type == CHANNEL_TYPE_TEXT:
- channel = Channel(self._conn._dbus_object._named_service, object_path)
+ if (handle_type == CONNECTION_HANDLE_TYPE_ROOM and
+ channel_type == CHANNEL_TYPE_TEXT):
+ def ready(channel):
- # hack
- channel._valid_interfaces.add(CHANNEL_INTERFACE_GROUP)
-
- current, local_pending, remote_pending = channel[CHANNEL_INTERFACE_GROUP].GetAllMembers()
-
- if local_pending:
- for act_id, act_handle in self._activities.items():
+ for act_id, act_handle in self._activities.iteritems():
if handle == act_handle:
- self.emit("activity-invitation", act_id)
-
- elif handle_type == CONNECTION_HANDLE_TYPE_CONTACT and \
- channel_type in [CHANNEL_TYPE_TEXT, CHANNEL_TYPE_STREAMED_MEDIA]:
+ break
+ else:
+ return
+
+ def members_changed(message, added, removed, local_pending,
+ remote_pending, actor, reason):
+ # FIXME: if contacts were added, who don't have this
+ # activity in their PEP node for whatever reason, then
+ # emit buddy-activities-changed for them (otherwise they
+ # could be in an activity while pretending they weren't,
+ # which would be crazy)
+ pass
+
+ def got_all_members(current, local_pending, remote_pending):
+ if local_pending:
+ for act_id, act_handle in self._activities.iteritems():
+ if handle == act_handle:
+ self.emit('activity-invitation', act_id)
+ def got_all_members_err(e):
+ logger.debug('Unable to get channel members for %s:',
+ object_path, exc_info=1)
+
+ # hook the MembersChanged signal so we get told when people
+ # join/leave
+ group = channel[CHANNEL_INTERFACE_GROUP]
+ group.connect_to_signal('MembersChanged', members_changed)
+ group.GetAllMembers(reply_handler=got_all_members,
+ error_handler=got_all_members_err)
+
+ # we throw away the channel as soon as ready() finishes
+ Channel(self._conn.service_name, object_path,
+ ready_handler=ready)
+
+ elif (handle_type == CONNECTION_HANDLE_TYPE_CONTACT and
+ channel_type in (CHANNEL_TYPE_TEXT,
+ CHANNEL_TYPE_STREAMED_MEDIA)):
self.emit("private-invitation", object_path)
def update_activity_properties(self, act_id):