diff options
-rw-r--r-- | butterfly/channel/im.py | 17 |
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: |