[Sugar-devel] [PATCH sugar-toolkit v2] presence: use RoomConfig1 to configure channel properties (#3629)
Daniel Drake
dsd at laptop.org
Tue Jul 3 18:21:54 EDT 2012
This code was still using regular Telepathy properties to
set important configuration such as Anonymous=False.
However, as of Telepathy specification 0.24.0, these properties have
gone away.
http://telepathy.freedesktop.org/spec/Channel_Type_Text.html
Changed in 0.24.0. This interface used to have a bunch of clunky
Telepathy.Properties. They have been removed in favour of D-Bus
properties on the Room2, Subject2 and RoomConfig1 interfaces.
Switch to using RoomConfig1 (where available) to set this
configuration. The invite-restricted flag is no longer available and
actually seems to have been removed a long while back.
Fixes sharing of activities over gabble on new platforms such
as Fedora 17.
Signed-off-by: Daniel Drake <dsd at laptop.org>
---
src/sugar/presence/activity.py | 61 ++++++++++++++++++++++++++++++++++------
1 file changed, 53 insertions(+), 8 deletions(-)
v2: incorporate review comments from Sascha Silbe.
diff --git a/src/sugar/presence/activity.py b/src/sugar/presence/activity.py
index 750a73c..3f0f1df 100644
--- a/src/sugar/presence/activity.py
+++ b/src/sugar/presence/activity.py
@@ -43,6 +43,8 @@ from sugar.presence.buddy import Buddy
CONN_INTERFACE_ACTIVITY_PROPERTIES = 'org.laptop.Telepathy.ActivityProperties'
CONN_INTERFACE_BUDDY_INFO = 'org.laptop.Telepathy.BuddyInfo'
+CONN_INTERFACE_ROOM_CONFIG = \
+ 'org.freedesktop.Telepathy.Channel.Interface.RoomConfig1'
_logger = logging.getLogger('sugar.presence.activity')
@@ -674,14 +676,57 @@ class _JoinCommand(_BaseCommand):
else:
self_handle = self._global_self_handle
- if self_handle in added:
- if PROPERTIES_INTERFACE not in self.text_channel:
- self._finished = True
- self.emit('finished', None)
- else:
- self.text_channel[PROPERTIES_INTERFACE].ListProperties(
- reply_handler=self.__list_properties_cb,
- error_handler=self.__error_handler_cb)
+ if self_handle not in added:
+ return
+
+ # Use RoomConfig1 to configure the text channel. If this
+ # doesn't exist, fall-back on old-style PROPERTIES_INTERFACE.
+ if CONN_INTERFACE_ROOM_CONFIG in self.text_channel:
+ self.__update_room_config()
+ elif PROPERTIES_INTERFACE in self.text_channel:
+ self.text_channel[PROPERTIES_INTERFACE].ListProperties(
+ reply_handler=self.__list_properties_cb,
+ error_handler=self.__error_handler_cb)
+ else:
+ # FIXME: when does this codepath get hit?
+ # It could be related to no property configuration being available
+ # in the selected backend, or it could be called at some stage
+ # of the protocol when properties aren't available yet.
+ self._finished = True
+ self.emit('finished', None)
+
+ def __update_room_config(self):
+ # FIXME: invite-only ought to be set on private activities; but
+ # since only the owner can change invite-only, that would break
+ # activity scope changes.
+ props = {
+ # otherwise buddy resolution breaks
+ 'Anonymous': False,
+ # anyone who knows about the channel can join
+ 'InviteOnly': False,
+ # vanish when there are no members
+ 'Persistent': False,
+ # don't appear in server room lists
+ 'Private': True,
+ }
+ room_cfg = self.text_channel[CONN_INTERFACE_ROOM_CONFIG]
+ room_cfg.UpdateConfiguration(props,
+ reply_handler=self.__room_cfg_updated_cb,
+ error_handler=self.__room_cfg_error_cb)
+
+ def __room_cfg_updated_cb(self):
+ self._finished = True
+ self.emit('finished', None)
+
+ def __room_cfg_error_cb(self, error):
+ # If RoomConfig update fails, it's probably because we don't have
+ # permission (e.g. we are not the session initiator). Thats OK -
+ # ignore the failure and carry on.
+ if (error.get_dbus_name() !=
+ 'org.freedesktop.Telepathy.Error.PermissionDenied'):
+ logging.error("Error setting room configuration: %s", error)
+ self._finished = True
+ self.emit('finished', None)
def __list_properties_cb(self, prop_specs):
# FIXME: invite-only ought to be set on private activities; but
--
1.7.10.4
More information about the Sugar-devel
mailing list