handle disconnection while insecure connetion dialog is opened. fixes #4138
This commit is contained in:
parent
5a16f09b3e
commit
673052f1b8
|
@ -154,6 +154,8 @@ class Connection(ConnectionHandlers):
|
||||||
self.activity = {}
|
self.activity = {}
|
||||||
# Do we continue connection when we get roster (send presence,get vcard..)
|
# Do we continue connection when we get roster (send presence,get vcard..)
|
||||||
self.continue_connect_info = None
|
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
|
# 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
|
# request vcard or os info... to a real JID but act as if it comes from
|
||||||
# the fake jid
|
# the fake jid
|
||||||
|
@ -617,9 +619,11 @@ class Connection(ConnectionHandlers):
|
||||||
'warn_when_plaintext_connection'):
|
'warn_when_plaintext_connection'):
|
||||||
self.dispatch('PLAIN_CONNECTION', (con,))
|
self.dispatch('PLAIN_CONNECTION', (con,))
|
||||||
return True
|
return True
|
||||||
|
con.RegisterDisconnectHandler(self._on_disconnected)
|
||||||
if _con_type in ('tls', 'ssl') and not hasattr(con.Connection,
|
if _con_type in ('tls', 'ssl') and not hasattr(con.Connection,
|
||||||
'_sslContext') and gajim.config.get_per('accounts', self.name,
|
'_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
|
# Pyopenssl is not used
|
||||||
self.dispatch('INSECURE_SSL_CONNECTION', (con, _con_type))
|
self.dispatch('INSECURE_SSL_CONNECTION', (con, _con_type))
|
||||||
return True
|
return True
|
||||||
|
@ -627,8 +631,10 @@ class Connection(ConnectionHandlers):
|
||||||
|
|
||||||
def connection_accepted(self, con, con_type):
|
def connection_accepted(self, con, con_type):
|
||||||
self.hosts = []
|
self.hosts = []
|
||||||
|
self.connection_auto_accepted = False
|
||||||
self.connected_hostname = self._current_host['host']
|
self.connected_hostname = self._current_host['host']
|
||||||
self.on_connect_failure = None
|
self.on_connect_failure = None
|
||||||
|
con.UnregisterDisconnectHandler(self._on_disconnected)
|
||||||
con.RegisterDisconnectHandler(self._disconnectedReconnCB)
|
con.RegisterDisconnectHandler(self._disconnectedReconnCB)
|
||||||
log.debug('Connected to server %s:%s with %s' % (
|
log.debug('Connected to server %s:%s with %s' % (
|
||||||
self._current_host['host'], self._current_host['port'], con_type))
|
self._current_host['host'], self._current_host['port'], con_type))
|
||||||
|
|
|
@ -476,6 +476,7 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
if errnum != 0:
|
if errnum != 0:
|
||||||
self.DEBUG(errtxt, 'error')
|
self.DEBUG(errtxt, 'error')
|
||||||
log.error("Connection to %s lost: %s [%d]", self.getName(), errtxt, errnum)
|
log.error("Connection to %s lost: %s [%d]", self.getName(), errtxt, errnum)
|
||||||
|
self._owner.disconnected()
|
||||||
self.printed_error = True
|
self.printed_error = True
|
||||||
if not errors_only and self.state >= 0:
|
if not errors_only and self.state >= 0:
|
||||||
self.pollend(retry=True)
|
self.pollend(retry=True)
|
||||||
|
|
|
@ -2037,6 +2037,13 @@ class Interface:
|
||||||
if is_checked[1]:
|
if is_checked[1]:
|
||||||
gajim.config.set_per('accounts', account,
|
gajim.config.set_per('accounts', account,
|
||||||
'warn_when_insecure_ssl_connection', False)
|
'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])
|
gajim.connections[account].connection_accepted(data[0], data[1])
|
||||||
def on_cancel():
|
def on_cancel():
|
||||||
gajim.connections[account].disconnect(on_purpose=True)
|
gajim.connections[account].disconnect(on_purpose=True)
|
||||||
|
|
Loading…
Reference in New Issue