prevent traceback when connection is lost while waiting for user to accept plain connection or ssl certificate. Fixes #4285

This commit is contained in:
Yann Leboulanger 2008-09-05 18:24:51 +00:00
parent adaaf358f2
commit 238ee10039

View file

@ -638,6 +638,14 @@ class Connection(ConnectionHandlers):
return self.connection_accepted(con, con_type)
def connection_accepted(self, con, con_type):
if not con or not con.Connection:
self.disconnect(on_purpose=True)
self.dispatch('STATUS', 'offline')
self.dispatch('CONNECTION_LOST',
(_('Could not connect to account %s') % self.name,
_('Connection with account %s has been lost. Retry connecting.') % \
self.name))
return
self.hosts = []
self.connection_auto_accepted = False
self.connected_hostname = self._current_host['host']
@ -678,17 +686,19 @@ class Connection(ConnectionHandlers):
con.auth(name, self.password, self.server_resource, 1, self.__on_auth)
def ssl_certificate_accepted(self):
if not self.connection:
self.disconnect(on_purpose=True)
self.dispatch('STATUS', 'offline')
self.dispatch('CONNECTION_LOST',
(_('Could not connect to account %s') % self.name,
_('Connection with account %s has been lost. Retry connecting.') % \
self.name))
return
name = gajim.config.get_per('accounts', self.name, 'name')
self._register_handlers(self.connection, 'ssl')
self.connection.auth(name, self.password, self.server_resource, 1,
self.__on_auth)
def plain_connection_accepted(self):
name = gajim.config.get_per('accounts', self.name, 'name')
self._register_handlers(self.connection, 'tcp')
self.connection.auth(name, self.password, self.server_resource, 1,
self.__on_auth)
def _register_handlers(self, con, con_type):
self.peerhost = con.get_peerhost()
# notify the gui about con_type
@ -697,7 +707,7 @@ class Connection(ConnectionHandlers):
def __on_auth(self, con, auth):
if not con:
self.disconnect(on_purpose = True)
self.disconnect(on_purpose=True)
self.dispatch('STATUS', 'offline')
self.dispatch('CONNECTION_LOST',
(_('Could not connect to "%s"') % self._hostname,