handle disconnection while insecure connetion dialog is opened. fixes #4138

This commit is contained in:
Yann Leboulanger 2008-07-30 15:43:53 +00:00
parent 5a16f09b3e
commit 673052f1b8
3 changed files with 17 additions and 3 deletions

View File

@ -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:
# vim: se ts=3:

View File

@ -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:
# vim: se ts=3:

View File

@ -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)