[Telepathy-commits] [telepathy-pinocchio/master] compare against the correct channel handle type in _channel_get_or_create()

Travis Reitter travis.reitter at collabora.co.uk
Fri Aug 15 11:06:28 PDT 2008


---
 pinocchio/connection/__init__.py |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/pinocchio/connection/__init__.py b/pinocchio/connection/__init__.py
index 9c03720..0ae88cf 100644
--- a/pinocchio/connection/__init__.py
+++ b/pinocchio/connection/__init__.py
@@ -233,7 +233,6 @@ class Connection(tp.server.Connection,
         self.check_connected()
 
         channel = None
-        channel_match = None
 
         # TODO: support handle_type == 0 && handle == 0
 
@@ -241,27 +240,24 @@ class Connection(tp.server.Connection,
             if channel_type == channel_existing.GetChannelType():
                 handle_obj = None
                 channel_handle_obj = None
-                # the spec claims GetHandle returns (handle_type, handle)
-                # (presumably as ints), but the Python bindings seem to return a
-                # single Handle object
-                channel_handle = channel_existing.GetHandle()
 
+                channel_handle_type, channel_handle_obj = \
+                                                    channel_existing.GetHandle()
+
+                # this would be a bit simpler, but we have to factor in the
+                # given handle and handle_type
                 if (handle_type, handle) in self._handles.keys():
                     handle_obj = self._handles[handle_type, handle]
 
-                chan_handle_type = tp.constants.HANDLE_TYPE_LIST
-                if (chan_handle_type, channel_handle) in self._handles.keys():
-                    channel_handle_obj = self._handles[chan_handle_type,
-                                                       channel_handle]
-
                 if handle_obj and channel_handle_obj:
-                    if handle_obj.get_name() == channel_handle_obj.get_name():
-                        channel_match = channel_existing
+                    handle_name =  handle_obj.get_name()
+                    channel_name = channel_handle_obj.get_name()
 
+                    if     handle_name == channel_name \
+                       and handle_type == channel_handle_type:
+                        channel = channel_existing
 
-        if channel_match:
-            channel = channel_match
-        else:
+        if not channel:
             channel = self._manager.channel_new(self, channel_type, handle_type,
                                                 handle, suppress_handler)
 
-- 
1.5.6.3




More information about the Telepathy-commits mailing list