From 69a6aaff74f9f68ff45c8b1d77063d9607b5d03c Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 6 Jun 2005 15:29:27 +0000 Subject: [PATCH] vcard is more complete (avatar is commig soon) --- src/common/connection.py | 20 +- src/gtkgui.glade | 839 +++++++++++++++++++++++++++++++++------ src/vcard.py | 38 +- 3 files changed, 755 insertions(+), 142 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 1584da00e..b650bb285 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -881,6 +881,7 @@ class Connection: 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 @@ class Connection: 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): diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 62a1f144d..a0438f327 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -6601,7 +6601,7 @@ Custom 6 True - 6 + 7 2 False 6 @@ -6632,33 +6632,30 @@ Custom - + True - Nickname: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 + True + False + True + 0 + + True + * + False - 0 - 1 - 1 - 2 - fill + 1 + 2 + 0 + 1 - + True - Birthday: + Phone No.: False False GTK_JUSTIFY_LEFT @@ -6672,32 +6669,8 @@ Custom 0 1 - 2 - 3 - fill - - - - - - - True - E-Mail: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 + 6 + 7 fill @@ -6720,17 +6693,17 @@ Custom 0 1 - 4 - 5 + 5 + 6 fill - + True - Phone No.: + E-Mail: False False GTK_JUSTIFY_LEFT @@ -6744,15 +6717,63 @@ Custom 0 1 - 5 - 6 + 4 + 5 fill - + + True + Birthday: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + Nickname: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + True True False @@ -6766,14 +6787,56 @@ Custom 1 2 - 0 - 1 + 6 + 7 - + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 5 + 6 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 4 + 5 + + + + + + True True False @@ -6793,48 +6856,6 @@ Custom - - - True - True - False - True - 0 - - True - * - False - - - 1 - 2 - 4 - 5 - - - - - - - True - True - False - True - 0 - - True - * - False - - - 1 - 2 - 5 - 6 - - - - True @@ -6847,27 +6868,6 @@ Custom * False - - 1 - 2 - 1 - 2 - - - - - - - True - True - False - True - 0 - - True - * - False - 1 2 @@ -6876,6 +6876,278 @@ Custom + + + + True + True + False + 0 + + + + 6 + True + 5 + 2 + False + 6 + 12 + + + + True + Family: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Given: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Middle: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Prefix: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + Suffix: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 3 + 4 + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 4 + 5 + + + + + + + + + True + More + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + 2 + 1 + 2 + fill + + False @@ -7057,7 +7329,7 @@ Custom - + True True False @@ -7078,7 +7350,7 @@ Custom - + True True False @@ -7099,7 +7371,7 @@ Custom - + True True False @@ -7120,7 +7392,7 @@ Custom - + True True False @@ -7141,7 +7413,7 @@ Custom - + True True False @@ -7162,7 +7434,7 @@ Custom - + True True False @@ -7211,7 +7483,7 @@ Custom 6 True - 4 + 5 2 False 6 @@ -7396,6 +7668,323 @@ Custom + + + + True + True + False + 0 + + + + 6 + True + 6 + 2 + False + 5 + 5 + + + + True + Street: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Extra Address: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + City: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + State: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + Postal Code: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + Country: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 1 + 2 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 3 + 4 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 4 + 5 + + + + + + + True + True + False + True + 0 + + True + * + False + + + 1 + 2 + 5 + 6 + + + + + + + + + True + Address + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + 2 + 4 + 5 + fill + + False diff --git a/src/vcard.py b/src/vcard.py index 4d8373625..b087cac5b 100644 --- a/src/vcard.py +++ b/src/vcard.py @@ -76,9 +76,13 @@ class Vcard_window: 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 @@ class Vcard_window: 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 @@ class Vcard_window: 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 @@ class Vcard_window: 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)