prevent TB when vcard is buggy

new event: ACC_NOT_OK when account creation failed
This commit is contained in:
Yann Leboulanger 2005-11-04 19:06:54 +00:00
parent f262486352
commit ca05945f63
1 changed files with 13 additions and 8 deletions

View File

@ -1392,7 +1392,7 @@ class Connection:
req['password'] = self.new_account_info['password'] req['password'] = self.new_account_info['password']
if not common.xmpp.features.register(self.connection, data[0], if not common.xmpp.features.register(self.connection, data[0],
req): req):
self.dispatch('ERROR', (_('Error:'), self.connection.lastErr)) self.dispatch('ACC_NOT_OK', (self.connection.lastErr))
return return
self.connected = 0 self.connected = 0
self.password = self.new_account_info['password'] self.password = self.new_account_info['password']
@ -1931,7 +1931,9 @@ class Connection:
return return
con, con_type = self.connect(config) con, con_type = self.connect(config)
if not con_type: if not con_type:
return None self.dispatch('ACC_NOT_OK',
(_('Could not connect to "%s"') % config['hostname']))
return
con.RegisterEventHandler(self._event_dispatcher) con.RegisterEventHandler(self._event_dispatcher)
self.new_account_info = config self.new_account_info = config
@ -1964,7 +1966,10 @@ class Connection:
c = f.read() c = f.read()
card = common.xmpp.Node(node = c) card = common.xmpp.Node(node = c)
vcard = self.node_to_dict(card) vcard = self.node_to_dict(card)
if vcard.has_key('PHOTO') and vcard['PHOTO'].has_key('SHA'): if vcard.has_key('PHOTO'):
if not isinstance(vcard['PHOTO'], dict):
del vcard['PHOTO']
elif vcard['PHOTO'].has_key('SHA'):
cached_sha = vcard['PHOTO']['SHA'] cached_sha = vcard['PHOTO']['SHA']
if self.vcard_shas.has_key(jid) and self.vcard_shas[jid] != \ if self.vcard_shas.has_key(jid) and self.vcard_shas[jid] != \
cached_sha: cached_sha: