diff --git a/src/common/connection.py b/src/common/connection.py index a6441c95b..55a978f36 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -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, ...}, ...}) diff --git a/src/gajim.py b/src/gajim.py index 505df9580..83d841e83 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -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