[Sugar-devel] [PATCH sugar-toolkit] Handle DBUS tubes in the activity telepathy client, part of OLPC #10738

Simon Schampijer simon at schampijer.de
Mon May 23 07:17:47 EDT 2011


This adds the handling of DBUS tube channels to the
'HandlerChannelFilter' in activity's telepathy client.

Signed-off-by: Simon Schampijer <simon at laptop.org>
---
 src/sugar/activity/activity.py |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py
index 35082cc..09ba3cc 100644
--- a/src/sugar/activity/activity.py
+++ b/src/sugar/activity/activity.py
@@ -65,9 +65,11 @@ import cjson
 from telepathy.server import DBusProperties
 from telepathy.interfaces import CHANNEL, \
                                  CHANNEL_TYPE_TEXT, \
+                                 CHANNEL_TYPE_DBUS_TUBE, \
                                  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
@@ -368,6 +370,7 @@ class Activity(Window, gtk.Container):
             # There's already an instance on the mesh, join it
             logging.debug('*** Act %s joining existing mesh instance %r',
                           self._activity_id, mesh_instance)
+            self._client_handler = _ClientHandler(self.get_bundle_id(), None)
             self.shared_activity = mesh_instance
             self.shared_activity.connect('notify::private',
                                          self.__privacy_changed_cb)
@@ -927,15 +930,22 @@ class _ClientHandler(dbus.service.Object, DBusProperties):
           })
 
     def __get_filters_cb(self):
-        logging.debug('__get_filters_cb')
-        filters = {
+        filter_text = {
             CHANNEL + '.ChannelType': CHANNEL_TYPE_TEXT,
             CHANNEL + '.TargetHandleType': CONNECTION_HANDLE_TYPE_CONTACT,
             }
-        filter_dict = dbus.Dictionary(filters, signature='sv')
-        logging.debug('__get_filters_cb %r', dbus.Array([filter_dict],
-                                                        signature='a{sv}'))
-        return dbus.Array([filter_dict], signature='a{sv}')
+        filter_dict = dbus.Dictionary(filter_text, signature='sv')
+        filters = dbus.Array([filter_dict], signature='a{sv}')
+
+        filter_tube = {
+            CHANNEL + '.ChannelType': CHANNEL_TYPE_DBUS_TUBE,
+            CHANNEL + '.TargetHandleType': CONNECTION_HANDLE_TYPE_ROOM,
+            }
+        filter_dict = dbus.Dictionary(filter_tube, signature='sv')
+        filters.append(filter_dict)
+
+        logging.debug('__get_filters_cb Activity filters=%r', filters)
+        return filters
 
     @dbus.service.method(dbus_interface=CLIENT_HANDLER,
                          in_signature='ooa(oa{sv})aota{sv}', out_signature='')
@@ -945,8 +955,12 @@ 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 and \
+                   handle_type == CONNECTION_HANDLE_TYPE_ROOM:
+                    self._got_channel_cb(connection, object_path)
         except Exception, e:
             logging.exception(e)
 
-- 
1.7.4



More information about the Sugar-devel mailing list