From 4989b4295bda92d78d8a0fa1259155a270e3e889 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 3 Mar 2013 12:17:10 +0200 Subject: [PATCH] Add strophe.vcard.js --- Libraries/strophe.vcard.js | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Libraries/strophe.vcard.js diff --git a/Libraries/strophe.vcard.js b/Libraries/strophe.vcard.js new file mode 100644 index 000000000..bc7e78096 --- /dev/null +++ b/Libraries/strophe.vcard.js @@ -0,0 +1,66 @@ +// Generated by CoffeeScript 1.3.3 +/* +Plugin to implement the vCard extension. +http://xmpp.org/extensions/xep-0054.html + +Author: Nathan Zorn (nathan.zorn@gmail.com) +CoffeeScript port: Andreas Guth (guth@dbis.rwth-aachen.de) +*/ + +/* jslint configuration: +*/ + +/* global document, window, setTimeout, clearTimeout, console, + XMLHttpRequest, ActiveXObject, + Base64, MD5, + Strophe, $build, $msg, $iq, $pres +*/ + +var buildIq; + +buildIq = function(type, jid, vCardEl) { + var iq; + iq = $iq(jid ? { + type: type, + to: jid + } : { + type: type + }); + iq.c("vCard", { + xmlns: Strophe.NS.VCARD + }); + if (vCardEl) { + iq.cnode(vCardEl); + } + return iq; +}; + +Strophe.addConnectionPlugin('vcard', { + _connection: null, + init: function(conn) { + this._connection = conn; + return Strophe.addNamespace('VCARD', 'vcard-temp'); + }, + /*Function + Retrieve a vCard for a JID/Entity + Parameters: + (Function) handler_cb - The callback function used to handle the request. + (String) jid - optional - The name of the entity to request the vCard + If no jid is given, this function retrieves the current user's vcard. + */ + + get: function(handler_cb, jid, error_cb) { + var iq; + iq = buildIq("get", jid); + return this._connection.sendIQ(iq, handler_cb, error_cb); + }, + /* Function + Set an entity's vCard. + */ + + set: function(handler_cb, vCardEl, jid, error_cb) { + var iq; + iq = buildIq("set", jid, vCardEl); + return this._connection.sendIQ(iq, handler_cb, error_rb); + } +});