handle connection failure when we create a new account. Fixes #1725

This commit is contained in:
Yann Leboulanger 2006-03-26 12:30:29 +00:00
parent 297f97a606
commit 7d3cee66ca
1 changed files with 6 additions and 3 deletions

View File

@ -87,6 +87,7 @@ class Connection(ConnectionHandlers):
gajim.config.set('usegpg', False) gajim.config.set('usegpg', False)
self.on_connect_success = None self.on_connect_success = None
self.on_connect_failure = None
self.retrycount = 0 self.retrycount = 0
self.jids_for_auto_auth = [] # list of jid to auto-authorize self.jids_for_auto_auth = [] # list of jid to auto-authorize
@ -320,9 +321,9 @@ class Connection(ConnectionHandlers):
secure = self._secure) secure = self._secure)
return return
else: else:
self._connect_failure(None) self.on_connect_failure()
def _connect_failure(self, con_type): def _connect_failure(self, con_type = None):
if not con_type: if not con_type:
# we are not retrying, and not conecting # we are not retrying, and not conecting
if not self.retrycount and self.connected != 0: if not self.retrycount and self.connected != 0:
@ -482,6 +483,7 @@ class Connection(ConnectionHandlers):
def connect_and_auth(self): def connect_and_auth(self):
self.on_connect_success = self._connect_success self.on_connect_success = self._connect_success
self.on_connect_failure = self._connect_failure
self.connect() self.connect()
def connect_and_init(self, show, msg, signed): def connect_and_init(self, show, msg, signed):
@ -734,9 +736,10 @@ class Connection(ConnectionHandlers):
self.new_account_info = config self.new_account_info = config
self.name = name self.name = name
self.on_connect_success = self._on_new_account self.on_connect_success = self._on_new_account
self.on_connect_failure = self._on_new_account
self.connect(config) self.connect(config)
def _on_new_account(self,con, con_type): def _on_new_account(self, con = None, con_type = None):
if not con_type: if not con_type:
self.dispatch('ACC_NOT_OK', self.dispatch('ACC_NOT_OK',
(_('Could not connect to "%s"') % self._hostname)) (_('Could not connect to "%s"') % self._hostname))