fix vcard problems (we can receive iq without from field when we receive our vcard)
This commit is contained in:
parent
8a7a399288
commit
553b842972
1 changed files with 15 additions and 6 deletions
|
@ -157,7 +157,14 @@ class Connection:
|
||||||
def _vCardCB(self, con, vc):
|
def _vCardCB(self, con, vc):
|
||||||
"""Called when we recieve a vCard
|
"""Called when we recieve a vCard
|
||||||
Parse the vCard and send it to plugins"""
|
Parse the vCard and send it to plugins"""
|
||||||
vcard = {'jid': vc.getFrom().getStripped()}
|
frm = vc.getFrom()
|
||||||
|
if frm:
|
||||||
|
frm = frm.getStripped()
|
||||||
|
else:
|
||||||
|
name = gajim.config.get_per('accounts', self.name, 'name')
|
||||||
|
hostname = gajim.config.get_per('accounts', self.name, 'hostname')
|
||||||
|
frm = name + '@' + hostname
|
||||||
|
vcard = {'jid': frm}
|
||||||
if vc.getTag('vCard').getNamespace() == common.xmpp.NS_VCARD:
|
if vc.getTag('vCard').getNamespace() == common.xmpp.NS_VCARD:
|
||||||
card = vc.getChildren()[0]
|
card = vc.getChildren()[0]
|
||||||
for info in card.getChildren():
|
for info in card.getChildren():
|
||||||
|
@ -638,9 +645,7 @@ class Connection:
|
||||||
self.connection.send(p)
|
self.connection.send(p)
|
||||||
self.dispatch('STATUS', show)
|
self.dispatch('STATUS', show)
|
||||||
#ask our VCard
|
#ask our VCard
|
||||||
iq = common.xmpp.Iq('get')
|
iq = self.request_vcard(None)
|
||||||
iq.setTag(common.xmpp.NS_VCARD + ' vCard')
|
|
||||||
self.connection.send(iq)
|
|
||||||
self.myVCardID.append(iq.getID())
|
self.myVCardID.append(iq.getID())
|
||||||
elif show == 'offline' and self.connected:
|
elif show == 'offline' and self.connected:
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
|
@ -815,12 +820,16 @@ class Connection:
|
||||||
common.xmpp.NS_VERSION)
|
common.xmpp.NS_VERSION)
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
|
|
||||||
def request_vcard(self, jid):
|
def request_vcard(self, jid = None):
|
||||||
|
'''request the VCARD and return the iq'''
|
||||||
if not self.connection:
|
if not self.connection:
|
||||||
return
|
return
|
||||||
iq = common.xmpp.Iq(to = jid, typ = 'get')
|
iq = common.xmpp.Iq(typ = 'get')
|
||||||
|
if jid:
|
||||||
|
iq.setTo(jid)
|
||||||
iq.setTag(common.xmpp.NS_VCARD + ' vCard')
|
iq.setTag(common.xmpp.NS_VCARD + ' vCard')
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
|
return iq
|
||||||
#('VCARD', {entry1: data, entry2: {entry21: data, ...}, ...})
|
#('VCARD', {entry1: data, entry2: {entry21: data, ...}, ...})
|
||||||
|
|
||||||
def send_vcard(self, vcard):
|
def send_vcard(self, vcard):
|
||||||
|
|
Loading…
Add table
Reference in a new issue