[telepathy-python/master] Add an initial implementation of EnsureChannel.

Jonny Lamb jonny.lamb at collabora.co.uk
Thu Jul 16 01:49:31 PDT 2009


Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
 src/server/channelmanager.py |    3 +++
 src/server/conn.py           |   17 +++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/server/channelmanager.py b/src/server/channelmanager.py
index 27a14be..901246e 100644
--- a/src/server/channelmanager.py
+++ b/src/server/channelmanager.py
@@ -63,6 +63,9 @@ class ChannelManager(object):
         if type not in self._requestable_channel_classes:
             raise NotImplemented('Unknown channel type "%s"' % type)
 
+        if self.channel_exists(props):
+            return self._channels[type][handle]
+
         channel = self._requestable_channel_classes[type](
             props, **args)
 
diff --git a/src/server/conn.py b/src/server/conn.py
index 84af503..db37d73 100644
--- a/src/server/conn.py
+++ b/src/server/conn.py
@@ -489,6 +489,23 @@ class ConnectionInterfaceRequests(
         # CreateChannel MUST return *before* NewChannels is emitted.
         self.signal_new_channels([channel])
 
+    @dbus.service.method(CONNECTION_INTERFACE_REQUESTS,
+        in_signature='a{sv}', out_signature='boa{sv}',
+        async_callbacks=('_success', '_error'))
+    def EnsureChannel(self, request, _success, _error):
+        yours = True
+        if self._channel_manager.channel_exists(request):
+            yours = False
+
+        type, handle_type, handle = self._check_basic_properties(request)
+        props = self._validate_handle(request)
+
+        channel = self._channel_manager.channel_for_props(props, signal=False)
+
+        _success(yours, channel._object_path, props)
+
+        self.signal_new_channels([channel])
+
 from telepathy._generated.Connection_Interface_Presence \
         import ConnectionInterfacePresence
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list