From c86b6d591733abcbe53dbb0b70c868dd2d94e28b Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Thu, 09 Jun 2011 14:53:18 +0000 Subject: Fix invitations from a non sugar client (empathy), part of OLPC #10814 This differentiates between sugar and non sugar invitations using the handle type. For non-sugar invitations we use the activity id to determine which activity to join. Signed-off-by: Simon Schampijer Acked-By: Sascha Silbe --- diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py index 35082cc..5156725 100644 --- a/src/sugar/activity/activity.py +++ b/src/sugar/activity/activity.py @@ -68,6 +68,7 @@ from telepathy.interfaces import CHANNEL, \ CLIENT, \ CLIENT_HANDLER from telepathy.constants import CONNECTION_HANDLE_TYPE_CONTACT +from telepathy.constants import CONNECTION_HANDLE_TYPE_ROOM from sugar import util from sugar.presence import presenceservice @@ -389,17 +390,22 @@ class Activity(Window, gtk.Container): else: logging.debug('Unknown share scope %r', share_scope) - def __got_channel_cb(self, wait_loop, connection_path, channel_path): + def __got_channel_cb(self, wait_loop, connection_path, channel_path, + handle_type): logging.debug('Activity.__got_channel_cb') - connection_name = connection_path.replace('/', '.')[1:] + pservice = presenceservice.get_instance() - bus = dbus.SessionBus() - channel = bus.get_object(connection_name, channel_path) - room_handle = channel.Get(CHANNEL, 'TargetHandle') + if handle_type == CONNECTION_HANDLE_TYPE_ROOM: + connection_name = connection_path.replace('/', '.')[1:] + bus = dbus.SessionBus() + channel = bus.get_object(connection_name, channel_path) + room_handle = channel.Get(CHANNEL, 'TargetHandle') + mesh_instance = pservice.get_activity_by_handle(connection_path, + room_handle) + else: + mesh_instance = pservice.get_activity(self._activity_id, + warn_if_none=False) - pservice = presenceservice.get_instance() - mesh_instance = pservice.get_activity_by_handle(connection_path, - room_handle) self._set_up_sharing(mesh_instance, SCOPE_PRIVATE) wait_loop.quit() @@ -945,8 +951,11 @@ class _ClientHandler(dbus.service.Object, DBusProperties): account, connection, channels, requests_satisfied, user_action_time, handler_info) try: - for channel in channels: - self._got_channel_cb(connection, channel[0]) + for object_path, properties in channels: + channel_type = properties[CHANNEL + '.ChannelType'] + handle_type = properties[CHANNEL + '.TargetHandleType'] + if channel_type == CHANNEL_TYPE_TEXT: + self._got_channel_cb(connection, object_path, handle_type) except Exception, e: logging.exception(e) -- cgit v0.9.1