[Pkg-sugar-commit] [sugar-toolkit-gtk3] 33/37: presence: use RoomConfig1 to configure channel properties (#3629)

Jonas Smedegaard dr at jones.dk
Sat Apr 18 17:19:57 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag v0.96.5
in repository sugar-toolkit-gtk3.

commit 8df855fd0e59956a3c2a22841eddb5c877fae748
Author: Daniel Drake <dsd at laptop.org>
Date:   Wed Jul 4 15:22:36 2012 -0600

    presence: use RoomConfig1 to configure channel properties (#3629)
    
    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>
    Acked-by: Sascha Silbe <silbe at activitycentral.com>
---
 src/sugar3/presence/activity.py | 61 +++++++++++++++++++++++++++++++++++------
 1 file changed, 53 insertions(+), 8 deletions(-)

diff --git a/src/sugar3/presence/activity.py b/src/sugar3/presence/activity.py
index 615df4b..6f35973 100644
--- a/src/sugar3/presence/activity.py
+++ b/src/sugar3/presence/activity.py
@@ -43,6 +43,8 @@ from sugar3.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('sugar3.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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-sugar/sugar-toolkit-gtk3.git



More information about the pkg-sugar-commit mailing list