Mercurial > eldonilo > lightstring
diff 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 |
line wrap: on
line diff
--- a/plugins/vcard.js +++ b/plugins/vcard.js @@ -26,18 +26,33 @@ Lightstring.plugins['vcard'] = { stanzas: { get: function(aTo) { if (aTo) - return "<iq type='get' to='" + aTo + "'><vCard xmlns='" + Lightstring.NS.vcard + "'/></iq>"; + return "<iq type='get' to='" + aTo + "'><vCard xmlns='" + Lightstring.ns.vcard + "'/></iq>"; else - return "<iq type='get'><vCard xmlns='" + Lightstring.NS.vcard + "'/></iq>"; + return "<iq type='get'><vCard xmlns='" + Lightstring.ns.vcard + "'/></iq>"; + }, + set: function(aTo) { + if (aTo) + return "<iq type='get' to='" + aTo + "'><vCard xmlns='" + Lightstring.ns.vcard + "'/></iq>"; + else + return "<iq type='get'><vCard xmlns='" + Lightstring.ns.vcard + "'/></iq>"; } }, - //FIXME: we should return a proper vcard, not an XMPP one + //FIXME: we should return a JSON vcard, not an XML one methods: { - get function(aTo, aResult, aError) { + get: function(aTo, aOnSuccess, aOnError) { this.send(Lightstring.stanzas['vcard'].get(aTo), function(stanza) { - var vcard = stanza.DOM.firstChild; - if (vcard) - aCallback(vcard); + var fields = stanza.DOM.firstChild.childNodes; + if (aOnSuccess && fields) + aOnSuccess(fields); + }, aOnError); + }, + set: function(aTo, aFields, aOnSuccess, aOnError) { + this.send(Lightstring.stanzas['vcard'].set(aTo, aFields), function(stanza) { + if (aOnSuccess) + aOnSuccess(); + //~ var vcard = stanza.DOM.firstChild; + //~ if (vcard) + //~ aResult(vcard); }, aError); } }