rails-assets-lygneo_jsxc 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/README.md +22 -0
  4. data/Rakefile +1 -0
  5. data/app/.DS_Store +0 -0
  6. data/app/assets/documents/lygneo_jsxc/dep.json +82 -0
  7. data/app/assets/javascripts/lygneo_jsxc.js +10 -0
  8. data/app/assets/javascripts/lygneo_jsxc/jsxc.min.js +28 -0
  9. data/app/assets/javascripts/lygneo_jsxc/lib/dsa-ww.js +50 -0
  10. data/app/assets/javascripts/lygneo_jsxc/lib/jquery.colorbox-min.js +7 -0
  11. data/app/assets/javascripts/lygneo_jsxc/lib/jquery.fullscreen.js +88 -0
  12. data/app/assets/javascripts/lygneo_jsxc/lib/jquery.min.js +4 -0
  13. data/app/assets/javascripts/lygneo_jsxc/lib/jquery.slimscroll.js +474 -0
  14. data/app/assets/javascripts/lygneo_jsxc/lib/jquery.ui.min.js +7 -0
  15. data/app/assets/javascripts/lygneo_jsxc/lib/jsxc.dep.min.js +72 -0
  16. data/app/assets/javascripts/lygneo_jsxc/lib/strophe.caps.js +270 -0
  17. data/app/assets/javascripts/lygneo_jsxc/lib/strophe.disco.js +232 -0
  18. data/app/assets/javascripts/lygneo_jsxc/lib/strophe.js +5153 -0
  19. data/app/assets/javascripts/lygneo_jsxc/lib/strophe.muc.js +1020 -0
  20. data/app/assets/javascripts/lygneo_jsxc/lib/strophe.vcard.js +66 -0
  21. data/app/assets/stylesheets/lygneo_jsxc.scss +5 -0
  22. data/app/assets/stylesheets/lygneo_jsxc/build/jsxc.scss +1325 -0
  23. data/app/assets/stylesheets/lygneo_jsxc/build/jsxc.webrtc.scss +379 -0
  24. data/app/assets/stylesheets/lygneo_jsxc/lib/jquery-ui.min.scss +4 -0
  25. data/app/assets/stylesheets/lygneo_jsxc/lib/jquery.colorbox.scss +189 -0
  26. data/app/assets/stylesheets/lygneo_jsxc/lib/jquery.mCustomScrollbar.scss +241 -0
  27. data/lib/rails-assets-lygneo_jsxc.rb +55 -0
  28. data/lib/rails-assets-lygneo_jsxc/version.rb +3 -0
  29. data/rails-assets-lygneo_jsxc.gemspec +25 -0
  30. metadata +169 -0
@@ -0,0 +1,1020 @@
1
+ // Generated by CoffeeScript 1.3.3
2
+ /*
3
+ *Plugin to implement the MUC extension.
4
+ http://xmpp.org/extensions/xep-0045.html
5
+ *Previous Author:
6
+ Nathan Zorn <nathan.zorn@gmail.com>
7
+ *Complete CoffeeScript rewrite:
8
+ Andreas Guth <guth@dbis.rwth-aachen.de>
9
+ */
10
+
11
+ var Occupant, RoomConfig, XmppRoom,
12
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
13
+
14
+ Strophe.addConnectionPlugin('muc', {
15
+ _connection: null,
16
+ rooms: {},
17
+ roomNames: [],
18
+ /*Function
19
+ Initialize the MUC plugin. Sets the correct connection object and
20
+ extends the namesace.
21
+ */
22
+
23
+ init: function(conn) {
24
+ this._connection = conn;
25
+ this._muc_handler = null;
26
+ Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + "#owner");
27
+ Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + "#admin");
28
+ Strophe.addNamespace('MUC_USER', Strophe.NS.MUC + "#user");
29
+ return Strophe.addNamespace('MUC_ROOMCONF', Strophe.NS.MUC + "#roomconfig");
30
+ },
31
+ /*Function
32
+ Join a multi-user chat room
33
+ Parameters:
34
+ (String) room - The multi-user chat room to join.
35
+ (String) nick - The nickname to use in the chat room. Optional
36
+ (Function) msg_handler_cb - The function call to handle messages from the
37
+ specified chat room.
38
+ (Function) pres_handler_cb - The function call back to handle presence
39
+ in the chat room.
40
+ (Function) roster_cb - The function call to handle roster info in the chat room
41
+ (String) password - The optional password to use. (password protected
42
+ rooms only)
43
+ (Object) history_attrs - Optional attributes for retrieving history
44
+ (XML DOM Element) extended_presence - Optional XML for extending presence
45
+ */
46
+
47
+ join: function(room, nick, msg_handler_cb, pres_handler_cb, roster_cb, password, history_attrs, extended_presence) {
48
+ var msg, room_nick, _ref,
49
+ _this = this;
50
+ room_nick = this.test_append_nick(room, nick);
51
+ msg = $pres({
52
+ from: this._connection.jid,
53
+ to: room_nick
54
+ }).c("x", {
55
+ xmlns: Strophe.NS.MUC
56
+ });
57
+ if (history_attrs != null) {
58
+ msg = msg.c("history", history_attrs).up();
59
+ }
60
+ if (password != null) {
61
+ msg.cnode(Strophe.xmlElement("password", [], password));
62
+ }
63
+ if (extended_presence != null) {
64
+ msg.up().cnode(extended_presence);
65
+ }
66
+ if ((_ref = this._muc_handler) == null) {
67
+ this._muc_handler = this._connection.addHandler(function(stanza) {
68
+ var from, handler, handlers, id, roomname, x, xmlns, xquery, _i, _len;
69
+ from = stanza.getAttribute('from');
70
+ if (!from) {
71
+ return true;
72
+ }
73
+ roomname = from.split("/")[0];
74
+ if (!_this.rooms[roomname]) {
75
+ return true;
76
+ }
77
+ room = _this.rooms[roomname];
78
+ handlers = {};
79
+ if (stanza.nodeName === "message") {
80
+ handlers = room._message_handlers;
81
+ } else if (stanza.nodeName === "presence") {
82
+ xquery = stanza.getElementsByTagName("x");
83
+ if (xquery.length > 0) {
84
+ for (_i = 0, _len = xquery.length; _i < _len; _i++) {
85
+ x = xquery[_i];
86
+ xmlns = x.getAttribute("xmlns");
87
+ if (xmlns && xmlns.match(Strophe.NS.MUC)) {
88
+ handlers = room._presence_handlers;
89
+ break;
90
+ }
91
+ }
92
+ }
93
+ }
94
+ for (id in handlers) {
95
+ handler = handlers[id];
96
+ if (!handler(stanza, room)) {
97
+ delete handlers[id];
98
+ }
99
+ }
100
+ return true;
101
+ });
102
+ }
103
+ if (!this.rooms.hasOwnProperty(room)) {
104
+ this.rooms[room] = new XmppRoom(this, room, nick, password);
105
+ this.roomNames.push(room);
106
+ }
107
+ if (pres_handler_cb) {
108
+ this.rooms[room].addHandler('presence', pres_handler_cb);
109
+ }
110
+ if (msg_handler_cb) {
111
+ this.rooms[room].addHandler('message', msg_handler_cb);
112
+ }
113
+ if (roster_cb) {
114
+ this.rooms[room].addHandler('roster', roster_cb);
115
+ }
116
+ return this._connection.send(msg);
117
+ },
118
+ /*Function
119
+ Leave a multi-user chat room
120
+ Parameters:
121
+ (String) room - The multi-user chat room to leave.
122
+ (String) nick - The nick name used in the room.
123
+ (Function) handler_cb - Optional function to handle the successful leave.
124
+ (String) exit_msg - optional exit message.
125
+ Returns:
126
+ iqid - The unique id for the room leave.
127
+ */
128
+
129
+ leave: function(room, nick, handler_cb, exit_msg) {
130
+ var id, presence, presenceid, room_nick;
131
+ id = this.roomNames.indexOf(room);
132
+ delete this.rooms[room];
133
+ if (id >= 0) {
134
+ this.roomNames.splice(id, 1);
135
+ if (this.roomNames.length === 0) {
136
+ this._connection.deleteHandler(this._muc_handler);
137
+ this._muc_handler = null;
138
+ }
139
+ }
140
+ room_nick = this.test_append_nick(room, nick);
141
+ presenceid = this._connection.getUniqueId();
142
+ presence = $pres({
143
+ type: "unavailable",
144
+ id: presenceid,
145
+ from: this._connection.jid,
146
+ to: room_nick
147
+ });
148
+ if (exit_msg != null) {
149
+ presence.c("status", exit_msg);
150
+ }
151
+ if (handler_cb != null) {
152
+ this._connection.addHandler(handler_cb, null, "presence", null, presenceid);
153
+ }
154
+ this._connection.send(presence);
155
+ return presenceid;
156
+ },
157
+ /*Function
158
+ Parameters:
159
+ (String) room - The multi-user chat room name.
160
+ (String) nick - The nick name used in the chat room.
161
+ (String) message - The plaintext message to send to the room.
162
+ (String) html_message - The message to send to the room with html markup.
163
+ (String) type - "groupchat" for group chat messages o
164
+ "chat" for private chat messages
165
+ Returns:
166
+ msgiq - the unique id used to send the message
167
+ */
168
+
169
+ message: function(room, nick, message, html_message, type) {
170
+ var msg, msgid, parent, room_nick;
171
+ room_nick = this.test_append_nick(room, nick);
172
+ type = type || (nick != null ? "chat" : "groupchat");
173
+ msgid = this._connection.getUniqueId();
174
+ msg = $msg({
175
+ to: room_nick,
176
+ from: this._connection.jid,
177
+ type: type,
178
+ id: msgid
179
+ }).c("body", {
180
+ xmlns: Strophe.NS.CLIENT
181
+ }).t(message);
182
+ msg.up();
183
+ if (html_message != null) {
184
+ msg.c("html", {
185
+ xmlns: Strophe.NS.XHTML_IM
186
+ }).c("body", {
187
+ xmlns: Strophe.NS.XHTML
188
+ }).t(html_message);
189
+ if (msg.node.childNodes.length === 0) {
190
+ parent = msg.node.parentNode;
191
+ msg.up().up();
192
+ msg.node.removeChild(parent);
193
+ } else {
194
+ msg.up().up();
195
+ }
196
+ }
197
+ msg.c("x", {
198
+ xmlns: "jabber:x:event"
199
+ }).c("composing");
200
+ this._connection.send(msg);
201
+ return msgid;
202
+ },
203
+ /*Function
204
+ Convenience Function to send a Message to all Occupants
205
+ Parameters:
206
+ (String) room - The multi-user chat room name.
207
+ (String) message - The plaintext message to send to the room.
208
+ (String) html_message - The message to send to the room with html markup.
209
+ Returns:
210
+ msgiq - the unique id used to send the message
211
+ */
212
+
213
+ groupchat: function(room, message, html_message) {
214
+ return this.message(room, null, message, html_message);
215
+ },
216
+ /*Function
217
+ Send a mediated invitation.
218
+ Parameters:
219
+ (String) room - The multi-user chat room name.
220
+ (String) receiver - The invitation's receiver.
221
+ (String) reason - Optional reason for joining the room.
222
+ Returns:
223
+ msgiq - the unique id used to send the invitation
224
+ */
225
+
226
+ invite: function(room, receiver, reason) {
227
+ var invitation, msgid;
228
+ msgid = this._connection.getUniqueId();
229
+ invitation = $msg({
230
+ from: this._connection.jid,
231
+ to: room,
232
+ id: msgid
233
+ }).c('x', {
234
+ xmlns: Strophe.NS.MUC_USER
235
+ }).c('invite', {
236
+ to: receiver
237
+ });
238
+ if (reason != null) {
239
+ invitation.c('reason', reason);
240
+ }
241
+ this._connection.send(invitation);
242
+ return msgid;
243
+ },
244
+ /*Function
245
+ Send a direct invitation.
246
+ Parameters:
247
+ (String) room - The multi-user chat room name.
248
+ (String) receiver - The invitation's receiver.
249
+ (String) reason - Optional reason for joining the room.
250
+ (String) password - Optional password for the room.
251
+ Returns:
252
+ msgiq - the unique id used to send the invitation
253
+ */
254
+
255
+ directInvite: function(room, receiver, reason, password) {
256
+ var attrs, invitation, msgid;
257
+ msgid = this._connection.getUniqueId();
258
+ attrs = {
259
+ xmlns: 'jabber:x:conference',
260
+ jid: room
261
+ };
262
+ if (reason != null) {
263
+ attrs.reason = reason;
264
+ }
265
+ if (password != null) {
266
+ attrs.password = password;
267
+ }
268
+ invitation = $msg({
269
+ from: this._connection.jid,
270
+ to: receiver,
271
+ id: msgid
272
+ }).c('x', attrs);
273
+ this._connection.send(invitation);
274
+ return msgid;
275
+ },
276
+ /*Function
277
+ Queries a room for a list of occupants
278
+ (String) room - The multi-user chat room name.
279
+ (Function) success_cb - Optional function to handle the info.
280
+ (Function) error_cb - Optional function to handle an error.
281
+ Returns:
282
+ id - the unique id used to send the info request
283
+ */
284
+
285
+ queryOccupants: function(room, success_cb, error_cb) {
286
+ var attrs, info;
287
+ attrs = {
288
+ xmlns: Strophe.NS.DISCO_ITEMS
289
+ };
290
+ info = $iq({
291
+ from: this._connection.jid,
292
+ to: room,
293
+ type: 'get'
294
+ }).c('query', attrs);
295
+ return this._connection.sendIQ(info, success_cb, error_cb);
296
+ },
297
+ /*Function
298
+ Start a room configuration.
299
+ Parameters:
300
+ (String) room - The multi-user chat room name.
301
+ (Function) handler_cb - Optional function to handle the config form.
302
+ Returns:
303
+ id - the unique id used to send the configuration request
304
+ */
305
+
306
+ configure: function(room, handler_cb, error_cb) {
307
+ var config, stanza;
308
+ config = $iq({
309
+ to: room,
310
+ type: "get"
311
+ }).c("query", {
312
+ xmlns: Strophe.NS.MUC_OWNER
313
+ });
314
+ stanza = config.tree();
315
+ return this._connection.sendIQ(stanza, handler_cb, error_cb);
316
+ },
317
+ /*Function
318
+ Cancel the room configuration
319
+ Parameters:
320
+ (String) room - The multi-user chat room name.
321
+ Returns:
322
+ id - the unique id used to cancel the configuration.
323
+ */
324
+
325
+ cancelConfigure: function(room) {
326
+ var config, stanza;
327
+ config = $iq({
328
+ to: room,
329
+ type: "set"
330
+ }).c("query", {
331
+ xmlns: Strophe.NS.MUC_OWNER
332
+ }).c("x", {
333
+ xmlns: "jabber:x:data",
334
+ type: "cancel"
335
+ });
336
+ stanza = config.tree();
337
+ return this._connection.sendIQ(stanza);
338
+ },
339
+ /*Function
340
+ Save a room configuration.
341
+ Parameters:
342
+ (String) room - The multi-user chat room name.
343
+ (Array) config- Form Object or an array of form elements used to configure the room.
344
+ Returns:
345
+ id - the unique id used to save the configuration.
346
+ */
347
+
348
+ saveConfiguration: function(room, config, success_cb, error_cb) {
349
+ var conf, iq, stanza, _i, _len;
350
+ iq = $iq({
351
+ to: room,
352
+ type: "set"
353
+ }).c("query", {
354
+ xmlns: Strophe.NS.MUC_OWNER
355
+ });
356
+ if (config instanceof Form) {
357
+ config.type = "submit";
358
+ iq.cnode(config.toXML());
359
+ } else {
360
+ iq.c("x", {
361
+ xmlns: "jabber:x:data",
362
+ type: "submit"
363
+ });
364
+ for (_i = 0, _len = config.length; _i < _len; _i++) {
365
+ conf = config[_i];
366
+ iq.cnode(conf).up();
367
+ }
368
+ }
369
+ stanza = iq.tree();
370
+ return this._connection.sendIQ(stanza, success_cb, error_cb);
371
+ },
372
+ /*Function
373
+ Parameters:
374
+ (String) room - The multi-user chat room name.
375
+ Returns:
376
+ id - the unique id used to create the chat room.
377
+ */
378
+
379
+ createInstantRoom: function(room, success_cb, error_cb) {
380
+ var roomiq;
381
+ roomiq = $iq({
382
+ to: room,
383
+ type: "set"
384
+ }).c("query", {
385
+ xmlns: Strophe.NS.MUC_OWNER
386
+ }).c("x", {
387
+ xmlns: "jabber:x:data",
388
+ type: "submit"
389
+ });
390
+ return this._connection.sendIQ(roomiq.tree(), success_cb, error_cb);
391
+ },
392
+ /*Function
393
+ Set the topic of the chat room.
394
+ Parameters:
395
+ (String) room - The multi-user chat room name.
396
+ (String) topic - Topic message.
397
+ */
398
+
399
+ setTopic: function(room, topic) {
400
+ var msg;
401
+ msg = $msg({
402
+ to: room,
403
+ from: this._connection.jid,
404
+ type: "groupchat"
405
+ }).c("subject", {
406
+ xmlns: "jabber:client"
407
+ }).t(topic);
408
+ return this._connection.send(msg.tree());
409
+ },
410
+ /*Function
411
+ Internal Function that Changes the role or affiliation of a member
412
+ of a MUC room. This function is used by modifyRole and modifyAffiliation.
413
+ The modification can only be done by a room moderator. An error will be
414
+ returned if the user doesn't have permission.
415
+ Parameters:
416
+ (String) room - The multi-user chat room name.
417
+ (Object) item - Object with nick and role or jid and affiliation attribute
418
+ (String) reason - Optional reason for the change.
419
+ (Function) handler_cb - Optional callback for success
420
+ (Function) error_cb - Optional callback for error
421
+ Returns:
422
+ iq - the id of the mode change request.
423
+ */
424
+
425
+ _modifyPrivilege: function(room, item, reason, handler_cb, error_cb) {
426
+ var iq;
427
+ iq = $iq({
428
+ to: room,
429
+ type: "set"
430
+ }).c("query", {
431
+ xmlns: Strophe.NS.MUC_ADMIN
432
+ }).cnode(item.node);
433
+ if (reason != null) {
434
+ iq.c("reason", reason);
435
+ }
436
+ return this._connection.sendIQ(iq.tree(), handler_cb, error_cb);
437
+ },
438
+ /*Function
439
+ Changes the role of a member of a MUC room.
440
+ The modification can only be done by a room moderator. An error will be
441
+ returned if the user doesn't have permission.
442
+ Parameters:
443
+ (String) room - The multi-user chat room name.
444
+ (String) nick - The nick name of the user to modify.
445
+ (String) role - The new role of the user.
446
+ (String) affiliation - The new affiliation of the user.
447
+ (String) reason - Optional reason for the change.
448
+ (Function) handler_cb - Optional callback for success
449
+ (Function) error_cb - Optional callback for error
450
+ Returns:
451
+ iq - the id of the mode change request.
452
+ */
453
+
454
+ modifyRole: function(room, nick, role, reason, handler_cb, error_cb) {
455
+ var item;
456
+ item = $build("item", {
457
+ nick: nick,
458
+ role: role
459
+ });
460
+ return this._modifyPrivilege(room, item, reason, handler_cb, error_cb);
461
+ },
462
+ kick: function(room, nick, reason, handler_cb, error_cb) {
463
+ return this.modifyRole(room, nick, 'none', reason, handler_cb, error_cb);
464
+ },
465
+ voice: function(room, nick, reason, handler_cb, error_cb) {
466
+ return this.modifyRole(room, nick, 'participant', reason, handler_cb, error_cb);
467
+ },
468
+ mute: function(room, nick, reason, handler_cb, error_cb) {
469
+ return this.modifyRole(room, nick, 'visitor', reason, handler_cb, error_cb);
470
+ },
471
+ op: function(room, nick, reason, handler_cb, error_cb) {
472
+ return this.modifyRole(room, nick, 'moderator', reason, handler_cb, error_cb);
473
+ },
474
+ deop: function(room, nick, reason, handler_cb, error_cb) {
475
+ return this.modifyRole(room, nick, 'participant', reason, handler_cb, error_cb);
476
+ },
477
+ /*Function
478
+ Changes the affiliation of a member of a MUC room.
479
+ The modification can only be done by a room moderator. An error will be
480
+ returned if the user doesn't have permission.
481
+ Parameters:
482
+ (String) room - The multi-user chat room name.
483
+ (String) jid - The jid of the user to modify.
484
+ (String) affiliation - The new affiliation of the user.
485
+ (String) reason - Optional reason for the change.
486
+ (Function) handler_cb - Optional callback for success
487
+ (Function) error_cb - Optional callback for error
488
+ Returns:
489
+ iq - the id of the mode change request.
490
+ */
491
+
492
+ modifyAffiliation: function(room, jid, affiliation, reason, handler_cb, error_cb) {
493
+ var item;
494
+ item = $build("item", {
495
+ jid: jid,
496
+ affiliation: affiliation
497
+ });
498
+ return this._modifyPrivilege(room, item, reason, handler_cb, error_cb);
499
+ },
500
+ ban: function(room, jid, reason, handler_cb, error_cb) {
501
+ return this.modifyAffiliation(room, jid, 'outcast', reason, handler_cb, error_cb);
502
+ },
503
+ member: function(room, jid, reason, handler_cb, error_cb) {
504
+ return this.modifyAffiliation(room, jid, 'member', reason, handler_cb, error_cb);
505
+ },
506
+ revoke: function(room, jid, reason, handler_cb, error_cb) {
507
+ return this.modifyAffiliation(room, jid, 'none', reason, handler_cb, error_cb);
508
+ },
509
+ owner: function(room, jid, reason, handler_cb, error_cb) {
510
+ return this.modifyAffiliation(room, jid, 'owner', reason, handler_cb, error_cb);
511
+ },
512
+ admin: function(room, jid, reason, handler_cb, error_cb) {
513
+ return this.modifyAffiliation(room, jid, 'admin', reason, handler_cb, error_cb);
514
+ },
515
+ /*Function
516
+ Change the current users nick name.
517
+ Parameters:
518
+ (String) room - The multi-user chat room name.
519
+ (String) user - The new nick name.
520
+ */
521
+
522
+ changeNick: function(room, user) {
523
+ var presence, room_nick;
524
+ room_nick = this.test_append_nick(room, user);
525
+ presence = $pres({
526
+ from: this._connection.jid,
527
+ to: room_nick,
528
+ id: this._connection.getUniqueId()
529
+ });
530
+ return this._connection.send(presence.tree());
531
+ },
532
+ /*Function
533
+ Change the current users status.
534
+ Parameters:
535
+ (String) room - The multi-user chat room name.
536
+ (String) user - The current nick.
537
+ (String) show - The new show-text.
538
+ (String) status - The new status-text.
539
+ */
540
+
541
+ setStatus: function(room, user, show, status) {
542
+ var presence, room_nick;
543
+ room_nick = this.test_append_nick(room, user);
544
+ presence = $pres({
545
+ from: this._connection.jid,
546
+ to: room_nick
547
+ });
548
+ if (show != null) {
549
+ presence.c('show', show).up();
550
+ }
551
+ if (status != null) {
552
+ presence.c('status', status);
553
+ }
554
+ return this._connection.send(presence.tree());
555
+ },
556
+ /*Function
557
+ List all chat room available on a server.
558
+ Parameters:
559
+ (String) server - name of chat server.
560
+ (String) handle_cb - Function to call for room list return.
561
+ (String) error_cb - Function to call on error.
562
+ */
563
+
564
+ listRooms: function(server, handle_cb, error_cb) {
565
+ var iq;
566
+ iq = $iq({
567
+ to: server,
568
+ from: this._connection.jid,
569
+ type: "get"
570
+ }).c("query", {
571
+ xmlns: Strophe.NS.DISCO_ITEMS
572
+ });
573
+ return this._connection.sendIQ(iq, handle_cb, error_cb);
574
+ },
575
+ test_append_nick: function(room, nick) {
576
+ return room + (nick != null ? "/" + (Strophe.escapeNode(nick)) : "");
577
+ }
578
+ });
579
+
580
+ XmppRoom = (function() {
581
+
582
+ function XmppRoom(client, name, nick, password) {
583
+ this.client = client;
584
+ this.name = name;
585
+ this.nick = nick;
586
+ this.password = password;
587
+ this._roomRosterHandler = __bind(this._roomRosterHandler, this);
588
+
589
+ this._addOccupant = __bind(this._addOccupant, this);
590
+
591
+ this.roster = {};
592
+ this._message_handlers = {};
593
+ this._presence_handlers = {};
594
+ this._roster_handlers = {};
595
+ this._handler_ids = 0;
596
+ if (client.muc) {
597
+ this.client = client.muc;
598
+ }
599
+ this.name = Strophe.getBareJidFromJid(name);
600
+ this.addHandler('presence', this._roomRosterHandler);
601
+ }
602
+
603
+ XmppRoom.prototype.join = function(msg_handler_cb, pres_handler_cb, roster_cb) {
604
+ return this.client.join(this.name, this.nick, msg_handler_cb, pres_handler_cb, roster_cb, this.password);
605
+ };
606
+
607
+ XmppRoom.prototype.leave = function(handler_cb, message) {
608
+ this.client.leave(this.name, this.nick, handler_cb, message);
609
+ return delete this.client.rooms[this.name];
610
+ };
611
+
612
+ XmppRoom.prototype.message = function(nick, message, html_message, type) {
613
+ return this.client.message(this.name, nick, message, html_message, type);
614
+ };
615
+
616
+ XmppRoom.prototype.groupchat = function(message, html_message) {
617
+ return this.client.groupchat(this.name, message, html_message);
618
+ };
619
+
620
+ XmppRoom.prototype.invite = function(receiver, reason) {
621
+ return this.client.invite(this.name, receiver, reason);
622
+ };
623
+
624
+ XmppRoom.prototype.directInvite = function(receiver, reason) {
625
+ return this.client.directInvite(this.name, receiver, reason, this.password);
626
+ };
627
+
628
+ XmppRoom.prototype.configure = function(handler_cb) {
629
+ return this.client.configure(this.name, handler_cb);
630
+ };
631
+
632
+ XmppRoom.prototype.cancelConfigure = function() {
633
+ return this.client.cancelConfigure(this.name);
634
+ };
635
+
636
+ XmppRoom.prototype.saveConfiguration = function(config) {
637
+ return this.client.saveConfiguration(this.name, config);
638
+ };
639
+
640
+ XmppRoom.prototype.queryOccupants = function(success_cb, error_cb) {
641
+ return this.client.queryOccupants(this.name, success_cb, error_cb);
642
+ };
643
+
644
+ XmppRoom.prototype.setTopic = function(topic) {
645
+ return this.client.setTopic(this.name, topic);
646
+ };
647
+
648
+ XmppRoom.prototype.modifyRole = function(nick, role, reason, success_cb, error_cb) {
649
+ return this.client.modifyRole(this.name, nick, role, reason, success_cb, error_cb);
650
+ };
651
+
652
+ XmppRoom.prototype.kick = function(nick, reason, handler_cb, error_cb) {
653
+ return this.client.kick(this.name, nick, reason, handler_cb, error_cb);
654
+ };
655
+
656
+ XmppRoom.prototype.voice = function(nick, reason, handler_cb, error_cb) {
657
+ return this.client.voice(this.name, nick, reason, handler_cb, error_cb);
658
+ };
659
+
660
+ XmppRoom.prototype.mute = function(nick, reason, handler_cb, error_cb) {
661
+ return this.client.mute(this.name, nick, reason, handler_cb, error_cb);
662
+ };
663
+
664
+ XmppRoom.prototype.op = function(nick, reason, handler_cb, error_cb) {
665
+ return this.client.op(this.name, nick, reason, handler_cb, error_cb);
666
+ };
667
+
668
+ XmppRoom.prototype.deop = function(nick, reason, handler_cb, error_cb) {
669
+ return this.client.deop(this.name, nick, reason, handler_cb, error_cb);
670
+ };
671
+
672
+ XmppRoom.prototype.modifyAffiliation = function(jid, affiliation, reason, success_cb, error_cb) {
673
+ return this.client.modifyAffiliation(this.name, jid, affiliation, reason, success_cb, error_cb);
674
+ };
675
+
676
+ XmppRoom.prototype.ban = function(jid, reason, handler_cb, error_cb) {
677
+ return this.client.ban(this.name, jid, reason, handler_cb, error_cb);
678
+ };
679
+
680
+ XmppRoom.prototype.member = function(jid, reason, handler_cb, error_cb) {
681
+ return this.client.member(this.name, jid, reason, handler_cb, error_cb);
682
+ };
683
+
684
+ XmppRoom.prototype.revoke = function(jid, reason, handler_cb, error_cb) {
685
+ return this.client.revoke(this.name, jid, reason, handler_cb, error_cb);
686
+ };
687
+
688
+ XmppRoom.prototype.owner = function(jid, reason, handler_cb, error_cb) {
689
+ return this.client.owner(this.name, jid, reason, handler_cb, error_cb);
690
+ };
691
+
692
+ XmppRoom.prototype.admin = function(jid, reason, handler_cb, error_cb) {
693
+ return this.client.admin(this.name, jid, reason, handler_cb, error_cb);
694
+ };
695
+
696
+ XmppRoom.prototype.changeNick = function(nick) {
697
+ this.nick = nick;
698
+ return this.client.changeNick(this.name, nick);
699
+ };
700
+
701
+ XmppRoom.prototype.setStatus = function(show, status) {
702
+ return this.client.setStatus(this.name, this.nick, show, status);
703
+ };
704
+
705
+ /*Function
706
+ Adds a handler to the MUC room.
707
+ Parameters:
708
+ (String) handler_type - 'message', 'presence' or 'roster'.
709
+ (Function) handler - The handler function.
710
+ Returns:
711
+ id - the id of handler.
712
+ */
713
+
714
+
715
+ XmppRoom.prototype.addHandler = function(handler_type, handler) {
716
+ var id;
717
+ id = this._handler_ids++;
718
+ switch (handler_type) {
719
+ case 'presence':
720
+ this._presence_handlers[id] = handler;
721
+ break;
722
+ case 'message':
723
+ this._message_handlers[id] = handler;
724
+ break;
725
+ case 'roster':
726
+ this._roster_handlers[id] = handler;
727
+ break;
728
+ default:
729
+ this._handler_ids--;
730
+ return null;
731
+ }
732
+ return id;
733
+ };
734
+
735
+ /*Function
736
+ Removes a handler from the MUC room.
737
+ This function takes ONLY ids returned by the addHandler function
738
+ of this room. passing handler ids returned by connection.addHandler
739
+ may brake things!
740
+ Parameters:
741
+ (number) id - the id of the handler
742
+ */
743
+
744
+
745
+ XmppRoom.prototype.removeHandler = function(id) {
746
+ delete this._presence_handlers[id];
747
+ delete this._message_handlers[id];
748
+ return delete this._roster_handlers[id];
749
+ };
750
+
751
+ /*Function
752
+ Creates and adds an Occupant to the Room Roster.
753
+ Parameters:
754
+ (Object) data - the data the Occupant is filled with
755
+ Returns:
756
+ occ - the created Occupant.
757
+ */
758
+
759
+
760
+ XmppRoom.prototype._addOccupant = function(data) {
761
+ var occ;
762
+ occ = new Occupant(data, this);
763
+ this.roster[occ.nick] = occ;
764
+ return occ;
765
+ };
766
+
767
+ /*Function
768
+ The standard handler that managed the Room Roster.
769
+ Parameters:
770
+ (Object) pres - the presence stanza containing user information
771
+ */
772
+
773
+
774
+ XmppRoom.prototype._roomRosterHandler = function(pres) {
775
+ var data, handler, id, newnick, nick, _ref;
776
+ data = XmppRoom._parsePresence(pres);
777
+ nick = data.nick;
778
+ newnick = data.newnick || null;
779
+ switch (data.type) {
780
+ case 'error':
781
+ return;
782
+ case 'unavailable':
783
+ if (newnick) {
784
+ data.nick = newnick;
785
+ if (this.roster[nick] && this.roster[newnick]) {
786
+ this.roster[nick].update(this.roster[newnick]);
787
+ this.roster[newnick] = this.roster[nick];
788
+ }
789
+ if (this.roster[nick] && !this.roster[newnick]) {
790
+ this.roster[newnick] = this.roster[nick].update(data);
791
+ }
792
+ }
793
+ delete this.roster[nick];
794
+ break;
795
+ default:
796
+ if (this.roster[nick]) {
797
+ this.roster[nick].update(data);
798
+ } else {
799
+ this._addOccupant(data);
800
+ }
801
+ }
802
+ _ref = this._roster_handlers;
803
+ for (id in _ref) {
804
+ handler = _ref[id];
805
+ if (!handler(this.roster, this)) {
806
+ delete this._roster_handlers[id];
807
+ }
808
+ }
809
+ return true;
810
+ };
811
+
812
+ /*Function
813
+ Parses a presence stanza
814
+ Parameters:
815
+ (Object) data - the data extracted from the presence stanza
816
+ */
817
+
818
+
819
+ XmppRoom._parsePresence = function(pres) {
820
+ var a, c, c2, data, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
821
+ data = {};
822
+ a = pres.attributes;
823
+ data.nick = Strophe.getResourceFromJid(a.from.textContent);
824
+ data.type = ((_ref = a.type) != null ? _ref.textContent : void 0) || null;
825
+ data.states = [];
826
+ _ref1 = pres.childNodes;
827
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
828
+ c = _ref1[_i];
829
+ switch (c.nodeName) {
830
+ case "status":
831
+ data.status = c.textContent || null;
832
+ break;
833
+ case "show":
834
+ data.show = c.textContent || null;
835
+ break;
836
+ case "x":
837
+ a = c.attributes;
838
+ if (((_ref2 = a.xmlns) != null ? _ref2.textContent : void 0) === Strophe.NS.MUC_USER) {
839
+ _ref3 = c.childNodes;
840
+ for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
841
+ c2 = _ref3[_j];
842
+ switch (c2.nodeName) {
843
+ case "item":
844
+ a = c2.attributes;
845
+ data.affiliation = ((_ref4 = a.affiliation) != null ? _ref4.textContent : void 0) || null;
846
+ data.role = ((_ref5 = a.role) != null ? _ref5.textContent : void 0) || null;
847
+ data.jid = ((_ref6 = a.jid) != null ? _ref6.textContent : void 0) || null;
848
+ data.newnick = ((_ref7 = a.nick) != null ? _ref7.textContent : void 0) || null;
849
+ break;
850
+ case "status":
851
+ if (c2.attributes.code) {
852
+ data.states.push(c2.attributes.code.textContent);
853
+ }
854
+ }
855
+ }
856
+ }
857
+ }
858
+ }
859
+ return data;
860
+ };
861
+
862
+ return XmppRoom;
863
+
864
+ })();
865
+
866
+ RoomConfig = (function() {
867
+
868
+ function RoomConfig(info) {
869
+ this.parse = __bind(this.parse, this);
870
+ if (info != null) {
871
+ this.parse(info);
872
+ }
873
+ }
874
+
875
+ RoomConfig.prototype.parse = function(result) {
876
+ var attr, attrs, child, field, identity, query, _i, _j, _k, _len, _len1, _len2, _ref;
877
+ query = result.getElementsByTagName("query")[0].childNodes;
878
+ this.identities = [];
879
+ this.features = [];
880
+ this.x = [];
881
+ for (_i = 0, _len = query.length; _i < _len; _i++) {
882
+ child = query[_i];
883
+ attrs = child.attributes;
884
+ switch (child.nodeName) {
885
+ case "identity":
886
+ identity = {};
887
+ for (_j = 0, _len1 = attrs.length; _j < _len1; _j++) {
888
+ attr = attrs[_j];
889
+ identity[attr.name] = attr.textContent;
890
+ }
891
+ this.identities.push(identity);
892
+ break;
893
+ case "feature":
894
+ this.features.push(attrs["var"].textContent);
895
+ break;
896
+ case "x":
897
+ attrs = child.childNodes[0].attributes;
898
+ if ((!attrs["var"].textContent === 'FORM_TYPE') || (!attrs.type.textContent === 'hidden')) {
899
+ break;
900
+ }
901
+ _ref = child.childNodes;
902
+ for (_k = 0, _len2 = _ref.length; _k < _len2; _k++) {
903
+ field = _ref[_k];
904
+ if (!(!field.attributes.type)) {
905
+ continue;
906
+ }
907
+ attrs = field.attributes;
908
+ this.x.push({
909
+ "var": attrs["var"].textContent,
910
+ label: attrs.label.textContent || "",
911
+ value: field.firstChild.textContent || ""
912
+ });
913
+ }
914
+ }
915
+ }
916
+ return {
917
+ "identities": this.identities,
918
+ "features": this.features,
919
+ "x": this.x
920
+ };
921
+ };
922
+
923
+ return RoomConfig;
924
+
925
+ })();
926
+
927
+ Occupant = (function() {
928
+
929
+ function Occupant(data, room) {
930
+ this.room = room;
931
+ this.update = __bind(this.update, this);
932
+
933
+ this.admin = __bind(this.admin, this);
934
+
935
+ this.owner = __bind(this.owner, this);
936
+
937
+ this.revoke = __bind(this.revoke, this);
938
+
939
+ this.member = __bind(this.member, this);
940
+
941
+ this.ban = __bind(this.ban, this);
942
+
943
+ this.modifyAffiliation = __bind(this.modifyAffiliation, this);
944
+
945
+ this.deop = __bind(this.deop, this);
946
+
947
+ this.op = __bind(this.op, this);
948
+
949
+ this.mute = __bind(this.mute, this);
950
+
951
+ this.voice = __bind(this.voice, this);
952
+
953
+ this.kick = __bind(this.kick, this);
954
+
955
+ this.modifyRole = __bind(this.modifyRole, this);
956
+
957
+ this.update(data);
958
+ }
959
+
960
+ Occupant.prototype.modifyRole = function(role, reason, success_cb, error_cb) {
961
+ return this.room.modifyRole(this.nick, role, reason, success_cb, error_cb);
962
+ };
963
+
964
+ Occupant.prototype.kick = function(reason, handler_cb, error_cb) {
965
+ return this.room.kick(this.nick, reason, handler_cb, error_cb);
966
+ };
967
+
968
+ Occupant.prototype.voice = function(reason, handler_cb, error_cb) {
969
+ return this.room.voice(this.nick, reason, handler_cb, error_cb);
970
+ };
971
+
972
+ Occupant.prototype.mute = function(reason, handler_cb, error_cb) {
973
+ return this.room.mute(this.nick, reason, handler_cb, error_cb);
974
+ };
975
+
976
+ Occupant.prototype.op = function(reason, handler_cb, error_cb) {
977
+ return this.room.op(this.nick, reason, handler_cb, error_cb);
978
+ };
979
+
980
+ Occupant.prototype.deop = function(reason, handler_cb, error_cb) {
981
+ return this.room.deop(this.nick, reason, handler_cb, error_cb);
982
+ };
983
+
984
+ Occupant.prototype.modifyAffiliation = function(affiliation, reason, success_cb, error_cb) {
985
+ return this.room.modifyAffiliation(this.jid, affiliation, reason, success_cb, error_cb);
986
+ };
987
+
988
+ Occupant.prototype.ban = function(reason, handler_cb, error_cb) {
989
+ return this.room.ban(this.jid, reason, handler_cb, error_cb);
990
+ };
991
+
992
+ Occupant.prototype.member = function(reason, handler_cb, error_cb) {
993
+ return this.room.member(this.jid, reason, handler_cb, error_cb);
994
+ };
995
+
996
+ Occupant.prototype.revoke = function(reason, handler_cb, error_cb) {
997
+ return this.room.revoke(this.jid, reason, handler_cb, error_cb);
998
+ };
999
+
1000
+ Occupant.prototype.owner = function(reason, handler_cb, error_cb) {
1001
+ return this.room.owner(this.jid, reason, handler_cb, error_cb);
1002
+ };
1003
+
1004
+ Occupant.prototype.admin = function(reason, handler_cb, error_cb) {
1005
+ return this.room.admin(this.jid, reason, handler_cb, error_cb);
1006
+ };
1007
+
1008
+ Occupant.prototype.update = function(data) {
1009
+ this.nick = data.nick || null;
1010
+ this.affiliation = data.affiliation || null;
1011
+ this.role = data.role || null;
1012
+ this.jid = data.jid || null;
1013
+ this.status = data.status || null;
1014
+ this.show = data.show || null;
1015
+ return this;
1016
+ };
1017
+
1018
+ return Occupant;
1019
+
1020
+ })();