Plenty of HACKs to get my code to work with Requests
[theonering] / src / channel_manager.py
index 4f289dd..18b682e 100644 (file)
@@ -4,6 +4,7 @@ import dbus
 import telepathy
 
 import channel
+import util.misc as util_misc
 
 
 _moduleLogger = logging.getLogger("channel_manager")
@@ -23,7 +24,7 @@ class TelepathyChannelManager(object):
                for channel_type in self._requestable_channel_classes:
                        for chan in self._channels[channel_type].values():
                                try:
-                                       _moduleLogger.info("Closing %s %s" % (channel_type, chan._object_path))
+                                       _moduleLogger.debug("Closing %s %s" % (channel_type, chan._object_path))
                                        chan.Close()
                                except Exception:
                                        _moduleLogger.exception("Shutting down %r" % (chan, ))
@@ -69,6 +70,7 @@ class TelepathyChannelManager(object):
                        self._conn.add_channels([chan], signal=signal)
                elif hasattr(self._conn, "add_channel"):
                        # HACK Older python-telepathy
+                       self._conn.NewChannels([(chan._object_path, chan.get_props())])
                        self._conn.add_channel(chan, handle, suppress_handler)
                else:
                        raise RuntimeError("Uhh, what just happened with the connection")
@@ -131,22 +133,27 @@ class ChannelManager(TelepathyChannelManager):
                )
 
        def _get_list_channel(self, props):
-               _, surpress_handler, handle = self._get_type_requested_handle(props)
+               _, surpress_handler, h = self._get_type_requested_handle(props)
 
                _moduleLogger.debug('New contact list channel')
-               chan = channel.contact_list.create_contact_list_channel(self._conn, self, props, handle)
+               chan = channel.contact_list.create_contact_list_channel(self._conn, self, props, h)
                return chan
 
        def _get_text_channel(self, props):
-               _, surpress_handler, handle = self._get_type_requested_handle(props)
+               _, surpress_handler, h = self._get_type_requested_handle(props)
 
-               _moduleLogger.debug('New text channel')
-               chan = channel.text.TextChannel(self._conn, self, props, handle)
+               accountNumber = util_misc.strip_number(self._conn.session.backend.get_account_number())
+               if h.phoneNumber == accountNumber:
+                       _moduleLogger.debug('New Debug channel')
+                       chan = channel.debug_prompt.DebugPromptChannel(self._conn, self, props, h)
+               else:
+                       _moduleLogger.debug('New text channel')
+                       chan = channel.text.TextChannel(self._conn, self, props, h)
                return chan
 
        def _get_media_channel(self, props):
-               _, surpress_handler, handle = self._get_type_requested_handle(props)
+               _, surpress_handler, h = self._get_type_requested_handle(props)
 
                _moduleLogger.debug('New media channel')
-               chan = channel.call.CallChannel(self._conn, self, props, handle)
+               chan = channel.call.CallChannel(self._conn, self, props, h)
                return chan