Skip to content
Snippets Groups Projects
Commit 69a6aaff authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

vcard is more complete (avatar is commig soon)

parent 147e14ee
No related branches found
No related tags found
No related merge requests found
......@@ -881,6 +881,7 @@ def request_vcard(self, jid = None):
iq.setTag(common.xmpp.NS_VCARD + ' vCard')
self.connection.send(iq)
return iq
#('VCARD', {entry1: data, entry2: {entry21: data, ...}, ...})
def send_vcard(self, vcard):
......@@ -889,13 +890,20 @@ def send_vcard(self, vcard):
iq = common.xmpp.Iq(typ = 'set')
iq2 = iq.setTag(common.xmpp.NS_VCARD + ' vCard')
for i in vcard.keys():
if i != 'jid':
if type(vcard[i]) == type({}):
iq3 = iq2.addChild(i)
for j in vcard[i].keys():
if i == 'jid':
continue
if type(vcard[i]) == type({}):
for j in vcard[i].keys():
if type(vcard[i][j]) == type({}):
iq3 = iq2.addChild(i)
iq3.addChild(j)
for k in vcard[i][j]:
iq3.addChild(k).setData(vcard[i][j][k])
else:
iq3 = iq2.addChild(i)
iq3.addChild(j).setData(vcard[i][j])
else:
iq2.addChild(i).setData(vcard[i])
else:
iq2.addChild(i).setData(vcard[i])
self.connection.send(iq)
def send_agent_status(self, agent, ptype):
......
This diff is collapsed.
......@@ -76,9 +76,13 @@ def set_value(self, entry_name, value):
def set_values(self, vcard):
for i in vcard.keys():
if type(vcard[i]) == type({}):
add_on = ''
if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
add_on = '_HOME'
if 'WORK' in vcard[i]:
add_on = '_WORK'
for j in vcard[i].keys():
self.set_value(i + '_' + j +
'_entry', vcard[i][j])
self.set_value(i + add_on + '_' + j + '_entry', vcard[i][j])
else:
if i == 'DESC':
self.xml.get_widget('DESC_textview').get_buffer().set_text(
......@@ -163,9 +167,13 @@ def add_to_vcard(self, vcard, entry, txt):
def make_vcard(self):
'''make the vCard dictionary'''
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',
'ADR_STREET', 'ADR_EXTADR', 'ADR_LOCALITY', 'ADR_REGION', 'ADR_PCODE',
'ADR_CTRY', 'ORG_ORGNAME', 'ORG_ORGUNIT', 'TITLE', 'ROLE']
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'URL',
'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX',
'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY',
'ADR_HOME_REGION', 'ADR_HOME_PCODE', 'ADR_HOME_CTRY', 'ORG_ORGNAME',
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'ADR_WORK_STREET', 'ADR_WORK_EXTADR',
'ADR_WORK_LOCALITY', 'ADR_WORK_REGION', 'ADR_WORK_PCODE',
'ADR_WORK_CTRY']
vcard = {}
for e in entries:
txt = self.xml.get_widget(e + '_entry').get_text()
......@@ -193,9 +201,13 @@ def on_publish_button_clicked(self, widget):
gajim.connections[self.account].send_vcard(vcard)
def on_retrieve_button_clicked(self, widget):
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',
'ADR_STREET', 'ADR_EXTADR', 'ADR_LOCALITY', 'ADR_REGION', 'ADR_PCODE',
'ADR_CTRY', 'ORG_ORGNAME', 'ORG_ORGUNIT', 'TITLE', 'ROLE']
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'URL',
'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX',
'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY',
'ADR_HOME_REGION', 'ADR_HOME_PCODE', 'ADR_HOME_CTRY', 'ORG_ORGNAME',
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'ADR_WORK_STREET', 'ADR_WORK_EXTADR',
'ADR_WORK_LOCALITY', 'ADR_WORK_REGION', 'ADR_WORK_PCODE',
'ADR_WORK_CTRY']
if gajim.connections[self.account].connected > 1:
# clear all entries
for e in entries:
......@@ -228,9 +240,13 @@ def change_to_vcard(self):
information_hbuttonbox.reorder_child(button, 2)
#make all entries editable
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',
'ADR_STREET', 'ADR_EXTADR', 'ADR_LOCALITY', 'ADR_REGION', 'ADR_PCODE',
'ADR_CTRY', 'ORG_ORGNAME', 'ORG_ORGUNIT', 'TITLE', 'ROLE']
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'URL',
'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX',
'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY',
'ADR_HOME_REGION', 'ADR_HOME_PCODE', 'ADR_HOME_CTRY', 'ORG_ORGNAME',
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'ADR_WORK_STREET', 'ADR_WORK_EXTADR',
'ADR_WORK_LOCALITY', 'ADR_WORK_REGION', 'ADR_WORK_PCODE',
'ADR_WORK_CTRY']
for e in entries:
self.xml.get_widget(e + '_entry').set_property('editable', True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment