diff options
author | Tomeu Vizoso <tomeu@sugarlabs.org> | 2010-03-18 16:15:08 (GMT) |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.co.uk> | 2010-08-20 13:02:26 (GMT) |
commit | 4b667b10a1e0072188f6e49b55c8ff3bf5e8bf59 (patch) | |
tree | 7dfb7033e20ffbe7f37a5180e908e129e4c3276a | |
parent | 37cf59593a84b9a7aee3e822eb3d99a9568ae470 (diff) |
Start of channel handling
-rw-r--r-- | bin/.gitignore | 2 | ||||
-rw-r--r-- | bin/Makefile.am | 3 | ||||
-rw-r--r-- | bin/sugar-dbus-launch-helper.in | 6 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/jarabe/model/neighborhood.py | 52 |
5 files changed, 56 insertions, 8 deletions
diff --git a/bin/.gitignore b/bin/.gitignore index 9e78b64..9b5ad73 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1 +1 @@ -sugar-shell-service +sugar-dbus-launch-helper diff --git a/bin/Makefile.am b/bin/Makefile.am index 05a9215..8a699dd 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -9,6 +9,7 @@ python_scripts = \ bin_SCRIPTS = \ sugar \ + sugar-dbus-launch-helper \ $(python_scripts) -EXTRA_DIST = $(python_scripts) sugar.in +EXTRA_DIST = $(python_scripts) sugar.in sugar-dbus-launch-helper.in diff --git a/bin/sugar-dbus-launch-helper.in b/bin/sugar-dbus-launch-helper.in new file mode 100644 index 0000000..fff85e1 --- /dev/null +++ b/bin/sugar-dbus-launch-helper.in @@ -0,0 +1,6 @@ +#!/bin/sh + +export SUGAR_SCALING=72 +export GTK2_RC_FILES="@prefix@/share/sugar/data/sugar-$SUGAR_SCALING.gtkrc" + +exec $@ diff --git a/configure.ac b/configure.ac index 238aacd..f846ef6 100644 --- a/configure.ac +++ b/configure.ac @@ -46,6 +46,7 @@ AM_GCONF_SOURCE_2 AC_CONFIG_FILES([ bin/Makefile bin/sugar +bin/sugar-dbus-launch-helper data/icons/Makefile data/Makefile data/sugar-emulator.desktop diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py index 832d55b..4e03257 100644 --- a/src/jarabe/model/neighborhood.py +++ b/src/jarabe/model/neighborhood.py @@ -29,13 +29,18 @@ from telepathy.interfaces import CONNECTION, \ CONNECTION_INTERFACE_SIMPLE_PRESENCE, \ CHANNEL_INTERFACE, \ CHANNEL_INTERFACE_GROUP, \ + CHANNEL_TYPE_TEXT, \ ACCOUNT_MANAGER, \ CHANNEL_DISPATCHER, \ + CHANNEL_DISPATCH_OPERATION, \ CHANNEL_REQUEST, \ CLIENT, \ - CLIENT_HANDLER + CLIENT_APPROVER, \ + CLIENT_HANDLER, \ + CLIENT_INTERFACE_REQUESTS from telepathy.constants import HANDLE_TYPE_LIST, \ - CONNECTION_PRESENCE_TYPE_OFFLINE + CONNECTION_PRESENCE_TYPE_OFFLINE, \ + CONNECTION_HANDLE_TYPE_CONTACT from telepathy.client import Connection, Channel from telepathy.server import DBusProperties @@ -73,7 +78,9 @@ class ActivityModel: class ClientHandler(dbus.service.Object, DBusProperties): def __init__(self): - self._interfaces = set([CLIENT, CLIENT_HANDLER, PROPERTIES_IFACE]) + self._interfaces = set([CLIENT, CLIENT_HANDLER, + CLIENT_INTERFACE_REQUESTS, PROPERTIES_IFACE, + CLIENT_APPROVER]) bus = dbus.Bus() bus_name = dbus.service.BusName(SUGAR_CLIENT_SERVICE, bus=bus) @@ -82,11 +89,26 @@ class ClientHandler(dbus.service.Object, DBusProperties): DBusProperties.__init__(self) self._implement_property_get(CLIENT, { - 'Interfaces': lambda: [CLIENT, CLIENT_HANDLER, PROPERTIES_IFACE], + 'Interfaces': lambda: list(self._interfaces), + }) + self._implement_property_get(CLIENT_HANDLER, { + 'HandlerChannelFilter': self.__get_filters_cb, + }) + self._implement_property_get(CLIENT_APPROVER, { + 'ApproverChannelFilter': self.__get_filters_cb, }) - self.got_channel = dispatch.Signal() + def __get_filters_cb(self): + logging.debug('__get_filters_cb') + filters = { + CHANNEL_INTERFACE + '.ChannelType' : CHANNEL_TYPE_TEXT, + CHANNEL_INTERFACE + '.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}') + @dbus.service.method(dbus_interface=CLIENT_HANDLER, in_signature='ooa(oa{sv})aota{sv}', out_signature='') def HandleChannels(self, account, connection, channels, requests_satisfied, @@ -97,6 +119,25 @@ class ClientHandler(dbus.service.Object, DBusProperties): self.got_channel.send(self, account=account, connection=connection, channel=channel) + @dbus.service.method(dbus_interface=CLIENT_INTERFACE_REQUESTS, + in_signature='oa{sv}', out_signature='') + def AddRequest(self, request, properties): + logging.debug('AddRequest\n%r\n%r', request, properties) + + @dbus.service.method(dbus_interface=CLIENT_APPROVER, + in_signature='a(oa{sv})oa{sv}', out_signature='') + def AddDispatchOperation(self, channels, dispatch_operation_path, properties): + logging.debug('AddDispatchOperation\n%r\n%r\n%r', channels, dispatch_operation_path, properties) + gobject.idle_add(self._dispatch_cb, dispatch_operation_path) + + def _dispatch_cb(self, dispatch_operation_path): + bus = dbus.Bus() + obj = bus.get_object(CHANNEL_DISPATCHER, dispatch_operation_path) + dispatch_operation = dbus.Interface(obj, CHANNEL_DISPATCH_OPERATION) + logging.debug('_dispatch_cb 1') + dispatch_operation.HandleWith('org.freedesktop.Telepathy.Client.org.laptop.Chat') + logging.debug('_dispatch_cb 2') + class Neighborhood(gobject.GObject): __gsignals__ = { 'activity-added': (gobject.SIGNAL_RUN_FIRST, @@ -143,7 +184,6 @@ class Neighborhood(gobject.GObject): 'org.freedesktop.Telepathy.Channel.TargetHandleType': HANDLE_TYPE_LIST, 'org.freedesktop.Telepathy.Channel.TargetID': 'subscribe', } - #import time; time.sleep(10) request_path = channel_dispatcher.EnsureChannel(account, properties, 0, SUGAR_CLIENT_SERVICE) obj = bus.get_object(CHANNEL_DISPATCHER_SERVICE, request_path) request = dbus.Interface(obj, CHANNEL_REQUEST) |