Commit c8e6f53e authored by JC Brand's avatar JC Brand

Remove require.js stuff (we'll have to use shims) and update to newest versions

parent ba201a76
// Generated by CoffeeScript 1.3.3
/* /*
*Plugin to implement the MUC extension. *Plugin to implement the MUC extension.
http://xmpp.org/extensions/xep-0045.html http://xmpp.org/extensions/xep-0045.html
...@@ -7,29 +7,18 @@ ...@@ -7,29 +7,18 @@
*Complete CoffeeScript rewrite: *Complete CoffeeScript rewrite:
Andreas Guth <guth@dbis.rwth-aachen.de> Andreas Guth <guth@dbis.rwth-aachen.de>
*/ */
// AMD/global registrations
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([
"Libraries/strophe"
], function () {
return factory(jQuery, console);
}
);
}
}(this, function ($, console) {
(function() { var Occupant, RoomConfig, XmppRoom,
var Occupant, RoomConfig, XmppRoom,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Strophe.addConnectionPlugin('muc', { Strophe.addConnectionPlugin('muc', {
_connection: null, _connection: null,
rooms: [], rooms: [],
/*Function /*Function
Initialize the MUC plugin. Sets the correct connection object and Initialize the MUC plugin. Sets the correct connection object and
extends the namesace. extends the namesace.
*/ */
init: function(conn) { init: function(conn) {
this._connection = conn; this._connection = conn;
this._muc_handler = null; this._muc_handler = null;
...@@ -50,8 +39,9 @@ ...@@ -50,8 +39,9 @@
(String) password - The optional password to use. (password protected (String) password - The optional password to use. (password protected
rooms only) rooms only)
*/ */
join: function(room, nick, msg_handler_cb, pres_handler_cb, roster_cb, password) { join: function(room, nick, msg_handler_cb, pres_handler_cb, roster_cb, password) {
var msg, room_nick, _base, var msg, room_nick, _base, _ref, _ref1,
_this = this; _this = this;
room_nick = this.test_append_nick(room, nick); room_nick = this.test_append_nick(room, nick);
msg = $pres({ msg = $pres({
...@@ -63,12 +53,17 @@ ...@@ -63,12 +53,17 @@
if (password != null) { if (password != null) {
msg.cnode(Strophe.xmlElement("password", [], password)); msg.cnode(Strophe.xmlElement("password", [], password));
} }
if (this._muc_handler == null) { if ((_ref = this._muc_handler) == null) {
this._muc_handler = this._connection.addHandler(function(stanza) { this._muc_handler = this._connection.addHandler(function(stanza) {
var from, handler, handlers, id, roomname, x, xmlns, xquery, _i, _len; var from, handler, handlers, id, roomname, x, xmlns, xquery, _i, _len;
from = stanza.getAttribute('from'); from = stanza.getAttribute('from');
if (!from) {
return true;
}
roomname = from.split("/")[0]; roomname = from.split("/")[0];
if (!_this.rooms[roomname]) return true; if (!_this.rooms[roomname]) {
return true;
}
room = _this.rooms[roomname]; room = _this.rooms[roomname];
handlers = {}; handlers = {};
if (stanza.nodeName === "message") { if (stanza.nodeName === "message") {
...@@ -88,19 +83,25 @@ ...@@ -88,19 +83,25 @@
} }
for (id in handlers) { for (id in handlers) {
handler = handlers[id]; handler = handlers[id];
if (!handler(stanza, room)) delete handlers[id]; if (!handler(stanza, room)) {
delete handlers[id];
}
} }
return true; return true;
}); });
} }
if ((_base = this.rooms)[room] == null) { if ((_ref1 = (_base = this.rooms)[room]) == null) {
_base[room] = new XmppRoom(this, room, nick, password); _base[room] = new XmppRoom(this, room, nick, password);
} }
if (pres_handler_cb) { if (pres_handler_cb) {
this.rooms[room].addHandler('presence', pres_handler_cb); this.rooms[room].addHandler('presence', pres_handler_cb);
} }
if (msg_handler_cb) this.rooms[room].addHandler('message', msg_handler_cb); if (msg_handler_cb) {
if (roster_cb) this.rooms[room].addHandler('roster', roster_cb); this.rooms[room].addHandler('message', msg_handler_cb);
}
if (roster_cb) {
this.rooms[room].addHandler('roster', roster_cb);
}
return this._connection.send(msg); return this._connection.send(msg);
}, },
/*Function /*Function
...@@ -113,6 +114,7 @@ ...@@ -113,6 +114,7 @@
Returns: Returns:
iqid - The unique id for the room leave. iqid - The unique id for the room leave.
*/ */
leave: function(room, nick, handler_cb, exit_msg) { leave: function(room, nick, handler_cb, exit_msg) {
var presence, presenceid, room_nick; var presence, presenceid, room_nick;
delete this.rooms[room]; delete this.rooms[room];
...@@ -128,7 +130,9 @@ ...@@ -128,7 +130,9 @@
from: this._connection.jid, from: this._connection.jid,
to: room_nick to: room_nick
}); });
if (exit_msg != null) presence.c("status", exit_msg); if (exit_msg != null) {
presence.c("status", exit_msg);
}
if (handler_cb != null) { if (handler_cb != null) {
this._connection.addHandler(handler_cb, null, "presence", null, presenceid); this._connection.addHandler(handler_cb, null, "presence", null, presenceid);
} }
...@@ -146,6 +150,7 @@ ...@@ -146,6 +150,7 @@
Returns: Returns:
msgiq - the unique id used to send the message msgiq - the unique id used to send the message
*/ */
message: function(room, nick, message, html_message, type) { message: function(room, nick, message, html_message, type) {
var msg, msgid, parent, room_nick; var msg, msgid, parent, room_nick;
room_nick = this.test_append_nick(room, nick); room_nick = this.test_append_nick(room, nick);
...@@ -189,6 +194,7 @@ ...@@ -189,6 +194,7 @@
Returns: Returns:
msgiq - the unique id used to send the message msgiq - the unique id used to send the message
*/ */
groupchat: function(room, message, html_message) { groupchat: function(room, message, html_message) {
return this.message(room, null, message, html_message); return this.message(room, null, message, html_message);
}, },
...@@ -201,6 +207,7 @@ ...@@ -201,6 +207,7 @@
Returns: Returns:
msgiq - the unique id used to send the invitation msgiq - the unique id used to send the invitation
*/ */
invite: function(room, receiver, reason) { invite: function(room, receiver, reason) {
var invitation, msgid; var invitation, msgid;
msgid = this._connection.getUniqueId(); msgid = this._connection.getUniqueId();
...@@ -213,7 +220,9 @@ ...@@ -213,7 +220,9 @@
}).c('invite', { }).c('invite', {
to: receiver to: receiver
}); });
if (reason != null) invitation.c('reason', reason); if (reason != null) {
invitation.c('reason', reason);
}
this._connection.send(invitation); this._connection.send(invitation);
return msgid; return msgid;
}, },
...@@ -227,6 +236,7 @@ ...@@ -227,6 +236,7 @@
Returns: Returns:
msgiq - the unique id used to send the invitation msgiq - the unique id used to send the invitation
*/ */
directInvite: function(room, receiver, reason, password) { directInvite: function(room, receiver, reason, password) {
var attrs, invitation, msgid; var attrs, invitation, msgid;
msgid = this._connection.getUniqueId(); msgid = this._connection.getUniqueId();
...@@ -234,8 +244,12 @@ ...@@ -234,8 +244,12 @@
xmlns: 'jabber:x:conference', xmlns: 'jabber:x:conference',
jid: room jid: room
}; };
if (reason != null) attrs.reason = reason; if (reason != null) {
if (password != null) attrs.password = password; attrs.reason = reason;
}
if (password != null) {
attrs.password = password;
}
invitation = $msg({ invitation = $msg({
from: this._connection.jid, from: this._connection.jid,
to: receiver, to: receiver,
...@@ -252,6 +266,7 @@ ...@@ -252,6 +266,7 @@
Returns: Returns:
id - the unique id used to send the info request id - the unique id used to send the info request
*/ */
queryOccupants: function(room, success_cb, error_cb) { queryOccupants: function(room, success_cb, error_cb) {
var attrs, info; var attrs, info;
attrs = { attrs = {
...@@ -272,8 +287,9 @@ ...@@ -272,8 +287,9 @@
Returns: Returns:
id - the unique id used to send the configuration request id - the unique id used to send the configuration request
*/ */
configure: function(room, handler_cb) {
var config, id, stanza; configure: function(room, handler_cb, error_cb) {
var config, stanza;
config = $iq({ config = $iq({
to: room, to: room,
type: "get" type: "get"
...@@ -281,14 +297,7 @@ ...@@ -281,14 +297,7 @@
xmlns: Strophe.NS.MUC_OWNER xmlns: Strophe.NS.MUC_OWNER
}); });
stanza = config.tree(); stanza = config.tree();
id = this._connection.sendIQ(stanza); return this._connection.sendIQ(stanza, handler_cb, error_cb);
if (handler_cb != null) {
this._connection.addHandler(function(stanza) {
handler_cb(stanza);
return false;
}, Strophe.NS.MUC_OWNER, "iq", null, id);
}
return id;
}, },
/*Function /*Function
Cancel the room configuration Cancel the room configuration
...@@ -297,6 +306,7 @@ ...@@ -297,6 +306,7 @@
Returns: Returns:
id - the unique id used to cancel the configuration. id - the unique id used to cancel the configuration.
*/ */
cancelConfigure: function(room) { cancelConfigure: function(room) {
var config, stanza; var config, stanza;
config = $iq({ config = $iq({
...@@ -315,27 +325,34 @@ ...@@ -315,27 +325,34 @@
Save a room configuration. Save a room configuration.
Parameters: Parameters:
(String) room - The multi-user chat room name. (String) room - The multi-user chat room name.
(Array) configarray - an array of form elements used to configure the room. (Array) config- Form Object or an array of form elements used to configure the room.
Returns: Returns:
id - the unique id used to save the configuration. id - the unique id used to save the configuration.
*/ */
saveConfiguration: function(room, configarray) {
var conf, config, stanza, _i, _len; saveConfiguration: function(room, config, success_cb, error_cb) {
config = $iq({ var conf, iq, stanza, _i, _len;
iq = $iq({
to: room, to: room,
type: "set" type: "set"
}).c("query", { }).c("query", {
xmlns: Strophe.NS.MUC_OWNER xmlns: Strophe.NS.MUC_OWNER
}).c("x", { });
if (config instanceof Form) {
config.type = "submit";
iq.cnode(config.toXML());
} else {
iq.c("x", {
xmlns: "jabber:x:data", xmlns: "jabber:x:data",
type: "submit" type: "submit"
}); });
for (_i = 0, _len = configarray.length; _i < _len; _i++) { for (_i = 0, _len = config.length; _i < _len; _i++) {
conf = configarray[_i]; conf = config[_i];
config.cnode(conf).up(); iq.cnode(conf).up();
} }
stanza = config.tree(); }
return this._connection.sendIQ(stanza); stanza = iq.tree();
return this._connection.sendIQ(stanza, success_cb, error_cb);
}, },
/*Function /*Function
Parameters: Parameters:
...@@ -343,7 +360,8 @@ ...@@ -343,7 +360,8 @@
Returns: Returns:
id - the unique id used to create the chat room. id - the unique id used to create the chat room.
*/ */
createInstantRoom: function(room) {
createInstantRoom: function(room, success_cb, error_cb) {
var roomiq; var roomiq;
roomiq = $iq({ roomiq = $iq({
to: room, to: room,
...@@ -354,7 +372,7 @@ ...@@ -354,7 +372,7 @@
xmlns: "jabber:x:data", xmlns: "jabber:x:data",
type: "submit" type: "submit"
}); });
return this._connection.sendIQ(roomiq.tree()); return this._connection.sendIQ(roomiq.tree(), success_cb, error_cb);
}, },
/*Function /*Function
Set the topic of the chat room. Set the topic of the chat room.
...@@ -362,6 +380,7 @@ ...@@ -362,6 +380,7 @@
(String) room - The multi-user chat room name. (String) room - The multi-user chat room name.
(String) topic - Topic message. (String) topic - Topic message.
*/ */
setTopic: function(room, topic) { setTopic: function(room, topic) {
var msg; var msg;
msg = $msg({ msg = $msg({
...@@ -383,10 +402,11 @@ ...@@ -383,10 +402,11 @@
(Object) item - Object with nick and role or jid and affiliation attribute (Object) item - Object with nick and role or jid and affiliation attribute
(String) reason - Optional reason for the change. (String) reason - Optional reason for the change.
(Function) handler_cb - Optional callback for success (Function) handler_cb - Optional callback for success
(Function) errer_cb - Optional callback for error (Function) error_cb - Optional callback for error
Returns: Returns:
iq - the id of the mode change request. iq - the id of the mode change request.
*/ */
_modifyPrivilege: function(room, item, reason, handler_cb, error_cb) { _modifyPrivilege: function(room, item, reason, handler_cb, error_cb) {
var iq; var iq;
iq = $iq({ iq = $iq({
...@@ -395,7 +415,9 @@ ...@@ -395,7 +415,9 @@
}).c("query", { }).c("query", {
xmlns: Strophe.NS.MUC_ADMIN xmlns: Strophe.NS.MUC_ADMIN
}).cnode(item.node); }).cnode(item.node);
if (reason != null) iq.c("reason", reason); if (reason != null) {
iq.c("reason", reason);
}
return this._connection.sendIQ(iq.tree(), handler_cb, error_cb); return this._connection.sendIQ(iq.tree(), handler_cb, error_cb);
}, },
/*Function /*Function
...@@ -409,10 +431,11 @@ ...@@ -409,10 +431,11 @@
(String) affiliation - The new affiliation of the user. (String) affiliation - The new affiliation of the user.
(String) reason - Optional reason for the change. (String) reason - Optional reason for the change.
(Function) handler_cb - Optional callback for success (Function) handler_cb - Optional callback for success
(Function) errer_cb - Optional callback for error (Function) error_cb - Optional callback for error
Returns: Returns:
iq - the id of the mode change request. iq - the id of the mode change request.
*/ */
modifyRole: function(room, nick, role, reason, handler_cb, error_cb) { modifyRole: function(room, nick, role, reason, handler_cb, error_cb) {
var item; var item;
item = $build("item", { item = $build("item", {
...@@ -446,10 +469,11 @@ ...@@ -446,10 +469,11 @@
(String) affiliation - The new affiliation of the user. (String) affiliation - The new affiliation of the user.
(String) reason - Optional reason for the change. (String) reason - Optional reason for the change.
(Function) handler_cb - Optional callback for success (Function) handler_cb - Optional callback for success
(Function) errer_cb - Optional callback for error (Function) error_cb - Optional callback for error
Returns: Returns:
iq - the id of the mode change request. iq - the id of the mode change request.
*/ */
modifyAffiliation: function(room, jid, affiliation, reason, handler_cb, error_cb) { modifyAffiliation: function(room, jid, affiliation, reason, handler_cb, error_cb) {
var item; var item;
item = $build("item", { item = $build("item", {
...@@ -479,6 +503,7 @@ ...@@ -479,6 +503,7 @@
(String) room - The multi-user chat room name. (String) room - The multi-user chat room name.
(String) user - The new nick name. (String) user - The new nick name.
*/ */
changeNick: function(room, user) { changeNick: function(room, user) {
var presence, room_nick; var presence, room_nick;
room_nick = this.test_append_nick(room, user); room_nick = this.test_append_nick(room, user);
...@@ -497,6 +522,7 @@ ...@@ -497,6 +522,7 @@
(String) show - The new show-text. (String) show - The new show-text.
(String) status - The new status-text. (String) status - The new status-text.
*/ */
setStatus: function(room, user, show, status) { setStatus: function(room, user, show, status) {
var presence, room_nick; var presence, room_nick;
room_nick = this.test_append_nick(room, user); room_nick = this.test_append_nick(room, user);
...@@ -504,8 +530,12 @@ ...@@ -504,8 +530,12 @@
from: this._connection.jid, from: this._connection.jid,
to: room_nick to: room_nick
}); });
if (show != null) presence.c('show', show).up(); if (show != null) {
if (status != null) presence.c('status', status); presence.c('show', show).up();
}
if (status != null) {
presence.c('status', status);
}
return this._connection.send(presence.tree()); return this._connection.send(presence.tree());
}, },
/*Function /*Function
...@@ -513,8 +543,10 @@ ...@@ -513,8 +543,10 @@
Parameters: Parameters:
(String) server - name of chat server. (String) server - name of chat server.
(String) handle_cb - Function to call for room list return. (String) handle_cb - Function to call for room list return.
(String) error_cb - Function to call on error.
*/ */
listRooms: function(server, handle_cb) {
listRooms: function(server, handle_cb, error_cb) {
var iq; var iq;
iq = $iq({ iq = $iq({
to: server, to: server,
...@@ -523,14 +555,14 @@ ...@@ -523,14 +555,14 @@
}).c("query", { }).c("query", {
xmlns: Strophe.NS.DISCO_ITEMS xmlns: Strophe.NS.DISCO_ITEMS
}); });
return this._connection.sendIQ(iq, handle_cb); return this._connection.sendIQ(iq, handle_cb, error_cb);
}, },
test_append_nick: function(room, nick) { test_append_nick: function(room, nick) {
return room + (nick != null ? "/" + (Strophe.escapeNode(nick)) : ""); return room + (nick != null ? "/" + (Strophe.escapeNode(nick)) : "");
} }
}); });
XmppRoom = (function() { XmppRoom = (function() {
XmppRoom.prototype.roster = {}; XmppRoom.prototype.roster = {};
...@@ -548,17 +580,19 @@ ...@@ -548,17 +580,19 @@
this.nick = nick; this.nick = nick;
this.password = password; this.password = password;
this._roomRosterHandler = __bind(this._roomRosterHandler, this); this._roomRosterHandler = __bind(this._roomRosterHandler, this);
this._addOccupant = __bind(this._addOccupant, this); this._addOccupant = __bind(this._addOccupant, this);
if (client.muc) this.client = client.muc;
if (client.muc) {
this.client = client.muc;
}
this.name = Strophe.getBareJidFromJid(name); this.name = Strophe.getBareJidFromJid(name);
this.client.rooms[this.name] = this; this.client.rooms[this.name] = this;
this.addHandler('presence', this._roomRosterHandler); this.addHandler('presence', this._roomRosterHandler);
} }
XmppRoom.prototype.join = function(msg_handler_cb, pres_handler_cb) { XmppRoom.prototype.join = function(msg_handler_cb, pres_handler_cb, roster_cb) {
if (!this.client.rooms[this.name]) { return this.client.join(this.name, this.nick, msg_handler_cb, pres_handler_cb, roster_cb, this.password);
return this.client.join(this.name, this.nick, msg_handler_cb, pres_handler_cb, this.password);
}
}; };
XmppRoom.prototype.leave = function(handler_cb, message) { XmppRoom.prototype.leave = function(handler_cb, message) {
...@@ -590,8 +624,8 @@ ...@@ -590,8 +624,8 @@
return this.client.cancelConfigure(this.name); return this.client.cancelConfigure(this.name);
}; };
XmppRoom.prototype.saveConfiguration = function(configarray) { XmppRoom.prototype.saveConfiguration = function(config) {
return this.client.saveConfiguration(this.name, configarray); return this.client.saveConfiguration(this.name, config);
}; };
XmppRoom.prototype.queryOccupants = function(success_cb, error_cb) { XmppRoom.prototype.queryOccupants = function(success_cb, error_cb) {
...@@ -668,6 +702,7 @@ ...@@ -668,6 +702,7 @@
id - the id of handler. id - the id of handler.
*/ */
XmppRoom.prototype.addHandler = function(handler_type, handler) { XmppRoom.prototype.addHandler = function(handler_type, handler) {
var id; var id;
id = this._handler_ids++; id = this._handler_ids++;
...@@ -697,6 +732,7 @@ ...@@ -697,6 +732,7 @@
(number) id - the id of the handler (number) id - the id of the handler
*/ */
XmppRoom.prototype.removeHandler = function(id) { XmppRoom.prototype.removeHandler = function(id) {
delete this._presence_handlers[id]; delete this._presence_handlers[id];
delete this._message_handlers[id]; delete this._message_handlers[id];
...@@ -711,6 +747,7 @@ ...@@ -711,6 +747,7 @@
occ - the created Occupant. occ - the created Occupant.
*/ */
XmppRoom.prototype._addOccupant = function(data) { XmppRoom.prototype._addOccupant = function(data) {
var occ; var occ;
occ = new Occupant(data, this); occ = new Occupant(data, this);
...@@ -724,6 +761,7 @@ ...@@ -724,6 +761,7 @@
(Object) pres - the presence stanza containing user information (Object) pres - the presence stanza containing user information
*/ */
XmppRoom.prototype._roomRosterHandler = function(pres) { XmppRoom.prototype._roomRosterHandler = function(pres) {
var data, handler, id, newnick, nick, _ref; var data, handler, id, newnick, nick, _ref;
data = XmppRoom._parsePresence(pres); data = XmppRoom._parsePresence(pres);
...@@ -755,7 +793,9 @@ ...@@ -755,7 +793,9 @@
_ref = this._roster_handlers; _ref = this._roster_handlers;
for (id in _ref) { for (id in _ref) {
handler = _ref[id]; handler = _ref[id];
if (!handler(this.roster, this)) delete this._roster_handlers[id]; if (!handler(this.roster, this)) {
delete this._roster_handlers[id];
}
} }
return true; return true;
}; };
...@@ -766,16 +806,17 @@ ...@@ -766,16 +806,17 @@
(Object) data - the data extracted from the presence stanza (Object) data - the data extracted from the presence stanza
*/ */
XmppRoom._parsePresence = function(pres) { XmppRoom._parsePresence = function(pres) {
var a, c, c2, data, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8; var a, c, c2, data, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
data = {}; data = {};
a = pres.attributes; a = pres.attributes;
data.nick = Strophe.getResourceFromJid(a.from.textContent); data.nick = Strophe.getResourceFromJid(a.from.textContent);
data.type = ((_ref = a.type) != null ? _ref.textContent : void 0) || null; data.type = ((_ref = a.type) != null ? _ref.textContent : void 0) || null;
data.states = []; data.states = [];
_ref2 = pres.childNodes; _ref1 = pres.childNodes;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
c = _ref2[_i]; c = _ref1[_i];
switch (c.nodeName) { switch (c.nodeName) {
case "status": case "status":
data.status = c.textContent || null; data.status = c.textContent || null;
...@@ -785,17 +826,17 @@ ...@@ -785,17 +826,17 @@
break; break;
case "x": case "x":
a = c.attributes; a = c.attributes;
if (((_ref3 = a.xmlns) != null ? _ref3.textContent : void 0) === Strophe.NS.MUC_USER) { if (((_ref2 = a.xmlns) != null ? _ref2.textContent : void 0) === Strophe.NS.MUC_USER) {
_ref4 = c.childNodes; _ref3 = c.childNodes;
for (_j = 0, _len2 = _ref4.length; _j < _len2; _j++) { for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
c2 = _ref4[_j]; c2 = _ref3[_j];
switch (c2.nodeName) { switch (c2.nodeName) {
case "item": case "item":
a = c2.attributes; a = c2.attributes;
data.affiliation = ((_ref5 = a.affiliation) != null ? _ref5.textContent : void 0) || null; data.affiliation = ((_ref4 = a.affiliation) != null ? _ref4.textContent : void 0) || null;
data.role = ((_ref6 = a.role) != null ? _ref6.textContent : void 0) || null; data.role = ((_ref5 = a.role) != null ? _ref5.textContent : void 0) || null;
data.jid = ((_ref7 = a.jid) != null ? _ref7.textContent : void 0) || null; data.jid = ((_ref6 = a.jid) != null ? _ref6.textContent : void 0) || null;
data.newnick = ((_ref8 = a.nick) != null ? _ref8.textContent : void 0) || null; data.newnick = ((_ref7 = a.nick) != null ? _ref7.textContent : void 0) || null;
break; break;
case "status": case "status":
if (c2.attributes.code) { if (c2.attributes.code) {
...@@ -811,16 +852,19 @@ ...@@ -811,16 +852,19 @@
return XmppRoom; return XmppRoom;
})(); })();
RoomConfig = (function() { RoomConfig = (function() {
function RoomConfig(info) { function RoomConfig(info) {
this.parse = __bind(this.parse, this); if (info != null) this.parse(info); this.parse = __bind(this.parse, this);
if (info != null) {
this.parse(info);
}
} }
RoomConfig.prototype.parse = function(result) { RoomConfig.prototype.parse = function(result) {
var attr, attrs, child, field, identity, query, _i, _j, _k, _len, _len2, _len3, _ref; var attr, attrs, child, field, identity, query, _i, _j, _k, _len, _len1, _len2, _ref;
query = result.getElementsByTagName("query")[0].childNodes; query = result.getElementsByTagName("query")[0].childNodes;
this.identities = []; this.identities = [];
this.features = []; this.features = [];
...@@ -831,7 +875,7 @@ ...@@ -831,7 +875,7 @@
switch (child.nodeName) { switch (child.nodeName) {
case "identity": case "identity":
identity = {}; identity = {};
for (_j = 0, _len2 = attrs.length; _j < _len2; _j++) { for (_j = 0, _len1 = attrs.length; _j < _len1; _j++) {
attr = attrs[_j]; attr = attrs[_j];
identity[attr.name] = attr.textContent; identity[attr.name] = attr.textContent;
} }
...@@ -846,9 +890,11 @@ ...@@ -846,9 +890,11 @@
break; break;
} }
_ref = child.childNodes; _ref = child.childNodes;
for (_k = 0, _len3 = _ref.length; _k < _len3; _k++) { for (_k = 0, _len2 = _ref.length; _k < _len2; _k++) {
field = _ref[_k]; field = _ref[_k];
if (!(!field.attributes.type)) continue; if (!(!field.attributes.type)) {
continue;
}
attrs = field.attributes; attrs = field.attributes;
this.x.push({ this.x.push({
"var": attrs["var"].textContent, "var": attrs["var"].textContent,
...@@ -867,25 +913,38 @@ ...@@ -867,25 +913,38 @@
return RoomConfig; return RoomConfig;
})(); })();
Occupant = (function() { Occupant = (function() {
function Occupant(data, room) { function Occupant(data, room) {
this.room = room; this.room = room;
this.update = __bind(this.update, this); this.update = __bind(this.update, this);
this.admin = __bind(this.admin, this); this.admin = __bind(this.admin, this);
this.owner = __bind(this.owner, this); this.owner = __bind(this.owner, this);
this.revoke = __bind(this.revoke, this); this.revoke = __bind(this.revoke, this);
this.member = __bind(this.member, this); this.member = __bind(this.member, this);
this.ban = __bind(this.ban, this); this.ban = __bind(this.ban, this);
this.modifyAffiliation = __bind(this.modifyAffiliation, this); this.modifyAffiliation = __bind(this.modifyAffiliation, this);
this.deop = __bind(this.deop, this); this.deop = __bind(this.deop, this);
this.op = __bind(this.op, this); this.op = __bind(this.op, this);
this.mute = __bind(this.mute, this); this.mute = __bind(this.mute, this);
this.voice = __bind(this.voice, this); this.voice = __bind(this.voice, this);
this.kick = __bind(this.kick, this); this.kick = __bind(this.kick, this);
this.modifyRole = __bind(this.modifyRole, this); this.modifyRole = __bind(this.modifyRole, this);
this.update(data); this.update(data);
} }
...@@ -949,7 +1008,4 @@ ...@@ -949,7 +1008,4 @@
return Occupant; return Occupant;
})(); })();
}).call(this);
}));
...@@ -13,21 +13,8 @@ ...@@ -13,21 +13,8 @@
* * authorize/unauthorize * * authorize/unauthorize
* * roster versioning (xep 237) * * roster versioning (xep 237)
*/ */
Strophe.addConnectionPlugin('roster',
{
// AMD/global registrations
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([
"Libraries/strophe"
], function () {
return factory(jQuery, console);
}
);
}
}(this, function ($, console) {
Strophe.addConnectionPlugin('roster',
{
_connection: null, _connection: null,
_callbacks : [], _callbacks : [],
...@@ -142,7 +129,7 @@ ...@@ -142,7 +129,7 @@
this.items = items || []; this.items = items || [];
} }
var iq = $iq({type: 'get', 'id' : this._connection.getUniqueId('roster')}).c('query', attrs); var iq = $iq({type: 'get', 'id' : this._connection.getUniqueId('roster')}).c('query', attrs);
this._connection.sendIQ(iq, return this._connection.sendIQ(iq,
this._onReceiveRosterSuccess.bind(this, userCallback), this._onReceiveRosterSuccess.bind(this, userCallback),
this._onReceiveRosterError.bind(this, userCallback)); this._onReceiveRosterError.bind(this, userCallback));
}, },
...@@ -290,7 +277,7 @@ ...@@ -290,7 +277,7 @@
{ {
iq.c('group').t(newGroups[i]).up(); iq.c('group').t(newGroups[i]).up();
} }
this._connection.sendIQ(iq, call_back, call_back); return this._connection.sendIQ(iq, call_back, call_back);
}, },
/** Function: remove /** Function: remove
* Remove roster item * Remove roster item
...@@ -448,5 +435,4 @@ ...@@ -448,5 +435,4 @@
item.groups = groups; item.groups = groups;
} }
} }
}); });
})); \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment