comparison plugins/vcard.js @ 49:e25dfe389dab

Fix vCard-temp plugin.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 01 Feb 2012 03:13:50 +0100
parents bdfbd58b4835
children 26d372c9e270
comparison
equal deleted inserted replaced
48:a118a7822410 49:e25dfe389dab
17 */ 17 */
18 18
19 ///////// 19 /////////
20 //vCard// 20 //vCard//
21 ///////// 21 /////////
22 Lightstring.NS.vcard = 'vcard-temp'; 22 Lightstring.plugins['vcard'] = {
23 Lightstring.stanza.vcard = { 23 namespaces: {
24 'get': function(aTo) { 24 vcard: 'vcard-temp'
25 if(aTo) 25 },
26 return "<iq type='get' to='"+aTo+"'><vCard xmlns='"+Lightstring.NS.vcard+"'/></iq>"; 26 stanzas: {
27 else 27 get: function(aTo) {
28 return "<iq type='get'><vCard xmlns='"+Lightstring.NS.vcard+"'/></iq>"; 28 if (aTo)
29 return "<iq type='get' to='" + aTo + "'><vCard xmlns='" + Lightstring.NS.vcard + "'/></iq>";
30 else
31 return "<iq type='get'><vCard xmlns='" + Lightstring.NS.vcard + "'/></iq>";
32 }
33 },
34 //FIXME: we should return a proper vcard, not an XMPP one
35 methods: {
36 get function(aTo, aResult, aError) {
37 this.send(Lightstring.stanzas['vcard'].get(aTo), function(stanza) {
38 var vcard = stanza.DOM.firstChild;
39 if (vcard)
40 aCallback(vcard);
41 }, aError);
42 }
29 } 43 }
30 }; 44 };
31 //FIXME we should return a proper vcard, not an XMPP one
32 Lightstring.getVcard = function(aConnection, aTo, aCallback) {
33 aConnection.send(Lightstring.stanza.vcard.get(aTo), function(stanza, err){
34 if(stanza) {
35 var vcard = stanza.DOM.querySelector('vCard');
36 if(vcard)
37 aCallback(vcard);
38 }
39 else
40 aCallback(null);
41 });
42 }