summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2010-04-09 12:18:13 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2010-04-09 12:19:02 +0100
commita6fd8dfa89b9efd078c4cd0d12530a2a521ad6d4 (patch)
tree73de9f451c299fdf698b3590745b2a6d5d684388
parent3abc79447d1ebd3a2ea805c13af18b2b3b3c64bd (diff)
im channel: call Close on the channel if switchboard fails due to disconnectionchannel-while-disconnecting
Fixes: fd.o#27544 Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--butterfly/channel/im.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/butterfly/channel/im.py b/butterfly/channel/im.py
index 2f63d4e..a7ec947 100644
--- a/butterfly/channel/im.py
+++ b/butterfly/channel/im.py
@@ -51,7 +51,22 @@ class ButterflyImChannel(ButterflyTextChannel):
if conversation is None:
if contact.presence != papyon.Presence.OFFLINE:
client = conn.msn_client
- conversation = papyon.Conversation(client, [contact])
+ try:
+ conversation = papyon.Conversation(client, [contact])
+ except AssertionError, e:
+ if conn.GetStatus() != telepathy.CONNECTION_STATUS_CONNECTED:
+ logger.warning('Could not create switchboard due to offline connection')
+
+ # We need to remove the channel from the bus and make sure
+ # it is closed and removed from connection/channel manager.
+ # We could do this by ourselves now, but the channel is only added
+ # to said managers when this constructor returns, so let's call
+ # Close in an idle.
+ gobject.idle_add(self.Close)
+
+ else:
+ logger.exception('Failed to create switchboard')
+ raise
self._conversation = conversation
if self._conversation: