[Sugar-devel] [PATCH sugar-toolkit] presence: use RoomConfig1 to configure channel properties (#3629)

Daniel Drake dsd at laptop.org
Mon Jul 2 16:13:03 EDT 2012


This code was still using regular Telepathy properties to
set important configuration such as Anonymous=False.

However, as of Telepathy-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 |   43 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 39 insertions(+), 4 deletions(-)

After review, an identical patch is needed for sugar-toolkit-gtk3.

diff --git a/src/sugar/presence/activity.py b/src/sugar/presence/activity.py
index 750a73c..5fc624c 100644
--- a/src/sugar/presence/activity.py
+++ b/src/sugar/presence/activity.py
@@ -43,6 +43,7 @@ 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')
 
@@ -675,13 +676,47 @@ class _JoinCommand(_BaseCommand):
             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:
+            # 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:
+                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.
+        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