diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-08-30 13:50:32 (GMT) |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-08-30 13:50:32 (GMT) |
commit | 261c13a25f9e965c2d8aaea37d8296155539fa9c (patch) | |
tree | 52e99ac8c7506e24c57dbaa2242fb38d749c8763 | |
parent | df55695e9a138a3fa1a9bc1e5509a4dbcb6e51a1 (diff) |
Change signature of ActivityInvitation signal to oos (activity, buddy, message)
-rw-r--r-- | src/presenceservice.py | 18 | ||||
-rw-r--r-- | src/telepathy_plugin.py | 39 |
2 files changed, 42 insertions, 15 deletions
diff --git a/src/presenceservice.py b/src/presenceservice.py index 5f81fcf..ef7c20b 100644 --- a/src/presenceservice.py +++ b/src/presenceservice.py @@ -539,14 +539,20 @@ class PresenceService(ExportedGObject): activity.buddy_apparently_left(buddy) - def _activity_invitation(self, tp, act_handle): + def _activity_invitation(self, tp, channel, act_handle, actor, message): activity = self._activities_by_handle[tp].get(act_handle) if activity is None: # FIXME: we should synthesize an activity somehow, for the case of - # an invite to a non-public room - pass + # an invite to a non-activity + _logger.debug('Invited to unknown activity: handle %u on %s, ' + 'ignoring', act_handle, tp) + elif actor == 0: + # don't know who invited us? not much we can do about that, then + _logger.debug('Invited to activity by unknown contact, ignoring') else: - self.ActivityInvitation(activity.object_path()) + buddy = self.map_handles_to_buddies(tp, channel, (actor,))[actor] + self.ActivityInvitation(activity.object_path(), + buddy.object_path(), message) def _private_invitation(self, tp, chan_path): conn = tp.get_connection() @@ -569,8 +575,8 @@ class PresenceService(ExportedGObject): def BuddyDisappeared(self, buddy): pass - @dbus.service.signal(PRESENCE_INTERFACE, signature="o") - def ActivityInvitation(self, activity): + @dbus.service.signal(PRESENCE_INTERFACE, signature="oos") + def ActivityInvitation(self, activity, buddy, message): pass @dbus.service.signal(PRESENCE_INTERFACE, signature="soo") diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py index a9ddfe0..f597476 100644 --- a/src/telepathy_plugin.py +++ b/src/telepathy_plugin.py @@ -27,6 +27,7 @@ from telepathy.constants import (CONNECTION_STATUS_DISCONNECTED, CONNECTION_STATUS_CONNECTING, CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED, CONNECTION_STATUS_REASON_NONE_SPECIFIED, + CHANNEL_GROUP_CHANGE_REASON_INVITED, HANDLE_TYPE_CONTACT, HANDLE_TYPE_ROOM, HANDLE_TYPE_LIST) from telepathy.interfaces import (CONN_INTERFACE, CHANNEL_TYPE_TEXT, CHANNEL_TYPE_STREAMED_MEDIA, CHANNEL_INTERFACE_GROUP, @@ -62,8 +63,11 @@ class TelepathyPlugin(gobject.GObject): 'activity-invitation': # We were invited to join an activity # args: + # activity room: Channel # activity room handle: int or long - (gobject.SIGNAL_RUN_FIRST, None, [object]), + # inviter contact handle: int or long + # message: unicode + (gobject.SIGNAL_RUN_FIRST, None, [object] * 4), 'private-invitation': # We were invited to join a chat or a media call # args: @@ -378,17 +382,34 @@ class TelepathyPlugin(gobject.GObject): """ if (handle_type == HANDLE_TYPE_ROOM and channel_type == CHANNEL_TYPE_TEXT): + def ready(channel): - def got_all_members(current, local_pending, remote_pending): - if local_pending: - self.emit('activity-invitation', handle) - def got_all_members_err(e): - _logger.debug('Unable to get channel members for %s:', - object_path, exc_info=1) + # workaround for odd behaviour of nested scopes + room_self = [] + + def got_lpwi(info): + for invitee, actor, reason, message in info: + if ((invitee == room_self[0] + or invitee == self.self_handle) + and reason == CHANNEL_GROUP_CHANGE_REASON_INVITED): + self.emit('activity-invitation', channel, handle, + actor, message) + def got_lpwi_err(e): + _logger.warning('Unable to get channel members for %s:', + object_path, exc_info=1) + + def got_self_handle(self_handle): + room_self.append(self_handle) + group.GetLocalPendingMembersWithInfo( + reply_handler=got_lpwi, + error_handler=got_lpwi_err) + def got_self_handle_err(e): + _logger.warning('Unable to get self-handle for %s:', + object_path, exc_info=1) group = channel[CHANNEL_INTERFACE_GROUP] - group.GetAllMembers(reply_handler=got_all_members, - error_handler=got_all_members_err) + group.GetSelfHandle(reply_handler=got_self_handle, + error_handler=got_self_handle_err) # we throw away the channel as soon as ready() finishes Channel(self._conn.service_name, object_path, |