when we receive an empty vcard, we send an empty vcard to the interface so that it knows it arrived

This commit is contained in:
Yann Leboulanger 2005-11-28 16:26:19 +00:00
parent b3d80edfb9
commit 258c0541e0
2 changed files with 23 additions and 4 deletions

View File

@ -21,6 +21,7 @@
# kind of events we can wait for an answer
VCARD_PUBLISHED = 'vcard_published'
VCARD_ARRIVED = 'vcard_arrived'
import sys
import sha
@ -1423,6 +1424,16 @@ class Connection:
self.to_be_sent.append(p)
elif iq_obj.getType() == 'error':
self.dispatch('VCARD_NOT_PUBLISHED', ())
elif self.awaiting_answers[id][0] == VCARD_ARRIVED:
# If vcard is empty, we send to the interface an empty vcard so that
# it knows it arrived
if not iq_obj.getTag('vCard'):
jid = self.awaiting_answers[id][1]
our_jid = gajim.get_jid_from_account(self.name)
if not jid or jid == our_jid:
self.dispatch('MYVCARD', {'jid': our_jid})
else:
self.dispatch('VCARD', {'jid': jid})
del self.awaiting_answers[id]
def _event_dispatcher(self, realm, event, data):
@ -2064,6 +2075,10 @@ class Connection:
if jid:
iq.setTo(jid)
iq.setTag(common.xmpp.NS_VCARD + ' vCard')
id = self.connection.getAnID()
iq.setID(id)
self.awaiting_answers[id] = (VCARD_ARRIVED, jid)
self.to_be_sent.append(iq)
#('VCARD', {entry1: data, entry2: {entry21: data, ...}, ...})

View File

@ -265,7 +265,7 @@ class Interface:
self.roster.on_status_changed(account, status)
if account in self.show_vcard_when_connect:
jid = gajim.get_jid_from_account(account)
if not self.instances[account]['infos'].has_key('vcard'):
if not self.instances[account]['infos'].has_key(jid):
self.instances[account]['infos'][jid] = \
vcard.VcardWindow(jid, account, True)
gajim.connections[account].request_vcard(jid)
@ -651,13 +651,16 @@ class Interface:
# ('VCARD', account, data)
'''vcard holds the vcard data'''
jid = vcard['jid']
resource = vcard['resource']
resource = ''
if vcard.has_key('resource'):
resource = vcard['resource']
# vcard window
win = None
if self.instances[account]['infos'].has_key(jid):
win = self.instances[account]['infos'][jid]
elif self.instances[account]['infos'].has_key(jid + '/' + resource):
elif resource and self.instances[account]['infos'].has_key(
jid + '/' + resource):
win = self.instances[account]['infos'][jid + '/' + resource]
if win:
win.set_values(vcard)
@ -666,7 +669,8 @@ class Interface:
win = None
if self.instances[account]['chats'].has_key(jid):
win = self.instances[account]['chats'][jid]
elif self.instances[account]['chats'].has_key(jid + '/' + resource):
elif resource and self.instances[account]['chats'].has_key(
jid + '/' + resource):
win = self.instances[account]['chats'][jid + '/' + resource]
if win:
# FIXME: this will be removed when we have the thread working