comparison plugins/vcard.js @ 30:1506992c33e2

Split plugins.js into multiple plugins.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 28 Jan 2012 01:50:22 +0100
parents
children bdfbd58b4835
comparison
equal deleted inserted replaced
28:630b9579fe4a 30:1506992c33e2
1 'use strict';
2
3 /**
4 Copyright (c) 2011, Sonny Piers <sonny at fastmail dot net>
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 /////////
20 //vCard//
21 /////////
22 Lightstring.NS.vcard = 'vcard-temp';
23 Lightstring.stanza.vcard = {
24 'get': function(aTo) {
25 if(aTo)
26 return "<iq type='get' to='"+aTo+"'><vCard xmlns='"+Lightstring.NS.vcard+"'/></iq>";
27 else
28 return "<iq type='get'><vCard xmlns='"+Lightstring.NS.vcard+"'/></iq>";
29 }
30 };
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(answer, err){
34 if(answer) {
35 var vcard = answer.querySelector('vCard');
36 if(vcard)
37 aCallback(vcard);
38 }
39 else
40 aCallback(null);
41 });
42 }