diff --git a/core/core.py b/core/core.py index 7fdfaec88..2f7565c0d 100644 --- a/core/core.py +++ b/core/core.py @@ -51,13 +51,19 @@ class GajimCore: def vCardCB(self, con, vc): """Called when we recieve a vCard""" + vcard = {'jid': vc.getFrom().getBasic()} # print vc - if vc._getTag('vCard') == common.jabber.NS_VCARD: - print "vcard :" + if vc._getTag('vcard') == common.jabber.NS_VCARD: +# print "vcard :" card = vc.getChildren()[0] for info in card.getChildren(): # print "name" - print info.getName() + " : " + info.getData() +# print info.getName() + " : " + info.getData() + if info.getChildren() == []: + vcard[info.getName()] = info.getData() + else: + for c in info.getChildren(): + vcard[info.getName()+'_'+c.getName()] = c.getData() # print "Data" # print info.getData() # print "DataAsParts" @@ -65,7 +71,9 @@ class GajimCore: # print "Namespace" # print info.getNamespace() # print "Children" -# print info.getChildren() +# print info.getChildren() +# print vcard + self.hub.sendPlugin('VCARD', vcard) def messageCB(self, con, msg): """Called when we recieve a message""" @@ -299,11 +307,12 @@ class GajimCore: print "error " + c.lastErr else: self.hub.sendPlugin('ACC_OK', ev[1]) - elif ev[0] == 'TEST_VCARD': - iq = ev[1] - id = self.con.getAnID() - iq.setID(id) - self.con.send(ev[1]) + #('VCARD', jid) + elif ev[0] == 'VCARD': + iq = common.jabber.Iq(to=ev[1], type="get") + iq._setTag('vcard', common.jabber.NS_VCARD) + iq.setID(self.con.getAnID()) + self.con.send(iq) else: log.debug("Unknown Command %s" % ev[0]) elif self.connected == 1: @@ -334,6 +343,7 @@ def loadPlugins(gc): gc.hub.register(mod, 'QUIT') gc.hub.register(mod, 'ACC_OK') gc.hub.register(mod, 'CONFIG') + gc.hub.register(mod, 'VCARD') modObj.load() # END loadPLugins diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index c0efca44b..9ab212799 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -1356,6 +1356,120 @@ Yann Le Boulanger (asterix@crans.org) tab + + + + 2 + True + 2 + 2 + False + 3 + 3 + + + + True + Informations about you are stored +on the server. + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + 5 + 5 + fill + + + + + + + True + True + Edit personal details... + True + GTK_RELIEF_NORMAL + + + + 1 + 2 + 0 + 1 + 5 + 5 + fill + + + + + + False + True + + + + + + 5 + True + False + 5 + + + + True + gtk-justify-center + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + True + <b>Details</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + tab + + 0 @@ -4264,4 +4378,1125 @@ when NOT onlie + + True + jid + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + + + + True + False + 0 + + + + 3 + True + True + True + True + GTK_POS_TOP + False + False + + + + True + 6 + 2 + False + 6 + 15 + + + + True + Name + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Nickname + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Birthday + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + E-Mail + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + Homepage + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + Phone # + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 5 + 6 + 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 + True + True + True + 0 + + True + * + False + + + 1 + 2 + 5 + 6 + + + + + + False + True + + + + + + True + General + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + True + 6 + 2 + False + 6 + 15 + + + + True + Street + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + + 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 + 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 + True + True + True + 0 + + True + * + False + + + 1 + 2 + 5 + 6 + + + + + + False + True + + + + + + True + Location + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + True + 4 + 2 + False + 6 + 15 + + + + True + Company + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Department + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Position + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Role + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + 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 + + + + + + False + True + + + + + + True + Work + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + False + True + + + + + + True + About + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 15 + + + + True + True + True + GTK_RELIEF_NORMAL + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-goto-top + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Publish + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + GTK_RELIEF_NORMAL + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-goto-bottom + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Retrieve + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + GTK_RELIEF_NORMAL + + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-close + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Close + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + 4 + False + True + + + + + + diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index 694d6d0e2..5a1a113a2 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -50,14 +50,37 @@ class user: self.resource = args[6] else: raise TypeError, 'bad arguments' +class vCard_Window: + """Class for window that show vCard information""" + def delete_event(self, widget): + """close window""" + self.window.destroy() + + def set_values(self, vcard): + for i in vcard.keys(): + try: + self.xml.get_widget('entry_'+i).set_text(vcard[i]) + except AttributeError, e: + pass +# print "error with %s" % i + + def on_retrieve(self, widget): + self.r.queueOUT.put(('VCARD', self.jid)) + + def __init__(self, acc_pref, jid): + self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard') + self.window = self.xml.get_widget("vcard") + self.jid = jid + self.r = acc_pref.accs.r + + self.xml.signal_connect('gtk_widget_destroy', self.delete_event) + self.xml.signal_connect('on_close_clicked', self.delete_event) + self.xml.signal_connect('on_retrieve_clicked', self.on_retrieve) + class infoUser_Window: """Class for user's information window""" def test_vcard(self): - iq = common.jabber.Iq(to="asterix2@jabber.lagaule.org", type="get") - print iq - iq._setTag('vcard', common.jabber.NS_VCARD) - print iq - self.r.queueOUT.put(('TEST_VCARD', iq)) + self.r.queueOUT.put(('VCARD', self.user.jid)) def delete_event(self, widget): """close window""" @@ -524,6 +547,10 @@ class accountPreference_Window: self.accs.r.plugin.accounts))) self.accs.init_accounts() self.delete_event(self) + + def on_edit_details_clicked(self, widget): + self.accs.r.tab_vcard[self.entryJid.get_text()] = vCard_Window(self, self.entryJid.get_text()) + self.accs.r.queueOUT.put(('VCARD', self.entryJid.get_text())) #info must be a dictionnary def __init__(self, accs, infos = {}): @@ -543,6 +570,7 @@ class accountPreference_Window: self.check.set_sensitive(FALSE) xml.signal_connect('gtk_widget_destroy', self.delete_event) xml.signal_connect('on_save_clicked', self.on_save_clicked) + xml.signal_connect('on_edit_details_clicked', self.on_edit_details_clicked) class accounts_Window: """Class for accounts window : lists of accounts""" @@ -1266,6 +1294,7 @@ class roster_Window: self.optionmenu.set_history(6) self.tab_messages = {} self.tab_queues = {} + self.tab_vcard = {} if self.plugin.config.has_key('showoffline'): self.showOffline = self.plugin.config['showoffline'] @@ -1461,6 +1490,9 @@ class plugin: accountsWindow.init_accounts() elif ev[0] == 'QUIT': self.r.on_quit(self) + elif ev[0] == 'VCARD': + if self.r.tab_vcard.has_key(ev[1]['jid']): + self.r.tab_vcard[ev[1]['jid']].set_values(ev[1]) return 1 def read_sleepy(self):