From 673052f1b8669d2552781693a8692c680f326b1f Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 30 Jul 2008 15:43:53 +0000 Subject: [PATCH] handle disconnection while insecure connetion dialog is opened. fixes #4138 --- src/common/connection.py | 10 ++++++++-- src/common/xmpp/transports_nb.py | 3 ++- src/gajim.py | 7 +++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index a64b7ed3f..4a440f249 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -154,6 +154,8 @@ class Connection(ConnectionHandlers): self.activity = {} # Do we continue connection when we get roster (send presence,get vcard..) self.continue_connect_info = None + # Do we auto accept insecure connection + self.connection_auto_accepted = False # To know the groupchat jid associated with a sranza ID. Useful to # request vcard or os info... to a real JID but act as if it comes from # the fake jid @@ -617,9 +619,11 @@ class Connection(ConnectionHandlers): 'warn_when_plaintext_connection'): self.dispatch('PLAIN_CONNECTION', (con,)) return True + con.RegisterDisconnectHandler(self._on_disconnected) if _con_type in ('tls', 'ssl') and not hasattr(con.Connection, '_sslContext') and gajim.config.get_per('accounts', self.name, - 'warn_when_insecure_ssl_connection'): + 'warn_when_insecure_ssl_connection') and \ + not self.connection_auto_accepted: # Pyopenssl is not used self.dispatch('INSECURE_SSL_CONNECTION', (con, _con_type)) return True @@ -627,8 +631,10 @@ class Connection(ConnectionHandlers): def connection_accepted(self, con, con_type): self.hosts = [] + self.connection_auto_accepted = False self.connected_hostname = self._current_host['host'] self.on_connect_failure = None + con.UnregisterDisconnectHandler(self._on_disconnected) con.RegisterDisconnectHandler(self._disconnectedReconnCB) log.debug('Connected to server %s:%s with %s' % ( self._current_host['host'], self._current_host['port'], con_type)) @@ -1745,4 +1751,4 @@ class Connection(ConnectionHandlers): # END Connection -# vim: se ts=3: \ No newline at end of file +# vim: se ts=3: diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py index ff6ef2b85..3287054bb 100644 --- a/src/common/xmpp/transports_nb.py +++ b/src/common/xmpp/transports_nb.py @@ -476,6 +476,7 @@ class NonBlockingTcp(PlugIn, IdleObject): if errnum != 0: self.DEBUG(errtxt, 'error') log.error("Connection to %s lost: %s [%d]", self.getName(), errtxt, errnum) + self._owner.disconnected() self.printed_error = True if not errors_only and self.state >= 0: self.pollend(retry=True) @@ -1115,4 +1116,4 @@ class NBSOCKS5PROXYsocket(NonBlockingTcp): ''' Overwrites DEBUG tag to allow debug output be presented as "CONNECTproxy".''' return self._owner.DEBUG(DBG_CONNECT_PROXY, text, severity) -# vim: se ts=3: \ No newline at end of file +# vim: se ts=3: diff --git a/src/gajim.py b/src/gajim.py index 637d16832..4f203b9fb 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -2037,6 +2037,13 @@ class Interface: if is_checked[1]: gajim.config.set_per('accounts', account, 'warn_when_insecure_ssl_connection', False) + if gajim.connections[account].connected == 0: + # We have been disconnecting (too long time since window is opened) + # re-connect with auto-accept + gajim.connections[account].connection_auto_accepted = True + show, msg = gajim.connections[account].continue_connect_info[:2] + self.roster.send_status(account, show, msg) + return gajim.connections[account].connection_accepted(data[0], data[1]) def on_cancel(): gajim.connections[account].disconnect(on_purpose=True)