Mercurial > eldonilo > lightstring
comparison plugins/vcard.js @ 93:26d372c9e270
fix the vcard plugin
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Thu, 19 Apr 2012 16:49:46 +0200 |
parents | e25dfe389dab |
children | 90fdbe5454c4 |
comparison
equal
deleted
inserted
replaced
92:b211a00efa7f | 93:26d372c9e270 |
---|---|
24 vcard: 'vcard-temp' | 24 vcard: 'vcard-temp' |
25 }, | 25 }, |
26 stanzas: { | 26 stanzas: { |
27 get: function(aTo) { | 27 get: function(aTo) { |
28 if (aTo) | 28 if (aTo) |
29 return "<iq type='get' to='" + aTo + "'><vCard xmlns='" + Lightstring.NS.vcard + "'/></iq>"; | 29 return "<iq type='get' to='" + aTo + "'><vCard xmlns='" + Lightstring.ns.vcard + "'/></iq>"; |
30 else | 30 else |
31 return "<iq type='get'><vCard xmlns='" + Lightstring.NS.vcard + "'/></iq>"; | 31 return "<iq type='get'><vCard xmlns='" + Lightstring.ns.vcard + "'/></iq>"; |
32 }, | |
33 set: function(aTo) { | |
34 if (aTo) | |
35 return "<iq type='get' to='" + aTo + "'><vCard xmlns='" + Lightstring.ns.vcard + "'/></iq>"; | |
36 else | |
37 return "<iq type='get'><vCard xmlns='" + Lightstring.ns.vcard + "'/></iq>"; | |
32 } | 38 } |
33 }, | 39 }, |
34 //FIXME: we should return a proper vcard, not an XMPP one | 40 //FIXME: we should return a JSON vcard, not an XML one |
35 methods: { | 41 methods: { |
36 get function(aTo, aResult, aError) { | 42 get: function(aTo, aOnSuccess, aOnError) { |
37 this.send(Lightstring.stanzas['vcard'].get(aTo), function(stanza) { | 43 this.send(Lightstring.stanzas['vcard'].get(aTo), function(stanza) { |
38 var vcard = stanza.DOM.firstChild; | 44 var fields = stanza.DOM.firstChild.childNodes; |
39 if (vcard) | 45 if (aOnSuccess && fields) |
40 aCallback(vcard); | 46 aOnSuccess(fields); |
47 }, aOnError); | |
48 }, | |
49 set: function(aTo, aFields, aOnSuccess, aOnError) { | |
50 this.send(Lightstring.stanzas['vcard'].set(aTo, aFields), function(stanza) { | |
51 if (aOnSuccess) | |
52 aOnSuccess(); | |
53 //~ var vcard = stanza.DOM.firstChild; | |
54 //~ if (vcard) | |
55 //~ aResult(vcard); | |
41 }, aError); | 56 }, aError); |
42 } | 57 } |
43 } | 58 } |
44 }; | 59 }; |