xmppify 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/app/assets/javascripts/xmpp/index.js +0 -0
  8. data/app/assets/javascripts/xmpp/scripts/checkplayer.js +12 -0
  9. data/app/assets/javascripts/xmpp/scripts/crossdomain.xml +7 -0
  10. data/app/assets/javascripts/xmpp/scripts/flXHR.js +2 -0
  11. data/app/assets/javascripts/xmpp/scripts/flXHR.swf +0 -0
  12. data/app/assets/javascripts/xmpp/scripts/flXHR.vbs +44 -0
  13. data/app/assets/javascripts/xmpp/scripts/flensed.js +12 -0
  14. data/app/assets/javascripts/xmpp/scripts/strophe.flxhr.js +31 -0
  15. data/app/assets/javascripts/xmpp/scripts/strophe.js +3538 -0
  16. data/app/assets/javascripts/xmpp/scripts/swfobject.js +5 -0
  17. data/app/assets/javascripts/xmpp/scripts/updateplayer.swf +0 -0
  18. data/app/assets/javascripts/xmpp/scripts/xmpp.js.coffee +386 -0
  19. data/app/assets/javascripts/xmpp/strophejs-plugins/LICENSE.txt +19 -0
  20. data/app/assets/javascripts/xmpp/strophejs-plugins/README.markdown +95 -0
  21. data/app/assets/javascripts/xmpp/strophejs-plugins/archive/README.markdown +14 -0
  22. data/app/assets/javascripts/xmpp/strophejs-plugins/archive/iso8601_support.js +32 -0
  23. data/app/assets/javascripts/xmpp/strophejs-plugins/archive/strophe.archive.js +88 -0
  24. data/app/assets/javascripts/xmpp/strophejs-plugins/caps/README.markdown +53 -0
  25. data/app/assets/javascripts/xmpp/strophejs-plugins/caps/sha1.js +202 -0
  26. data/app/assets/javascripts/xmpp/strophejs-plugins/caps/strophe.CAPS.coffee +153 -0
  27. data/app/assets/javascripts/xmpp/strophejs-plugins/caps/strophe.CAPS.js +88 -0
  28. data/app/assets/javascripts/xmpp/strophejs-plugins/caps/strophe.caps.jsonly.js +240 -0
  29. data/app/assets/javascripts/xmpp/strophejs-plugins/chatstates/strophe.chatstates.js +80 -0
  30. data/app/assets/javascripts/xmpp/strophejs-plugins/cmds/README.markdown +47 -0
  31. data/app/assets/javascripts/xmpp/strophejs-plugins/cmds/spec/GetUrlComamndSpec.js +66 -0
  32. data/app/assets/javascripts/xmpp/strophejs-plugins/cmds/spec/strophe.cmds.spec.coffee +145 -0
  33. data/app/assets/javascripts/xmpp/strophejs-plugins/cmds/spec/support/jasmine.json +16 -0
  34. data/app/assets/javascripts/xmpp/strophejs-plugins/cmds/src/strophe.cmds.coffee +265 -0
  35. data/app/assets/javascripts/xmpp/strophejs-plugins/cmds/src/strophe.cmds.js +403 -0
  36. data/app/assets/javascripts/xmpp/strophejs-plugins/dataforms/README.markdown +82 -0
  37. data/app/assets/javascripts/xmpp/strophejs-plugins/dataforms/spec/strophe.x.coffee +715 -0
  38. data/app/assets/javascripts/xmpp/strophejs-plugins/dataforms/src/strophe.x.coffee +443 -0
  39. data/app/assets/javascripts/xmpp/strophejs-plugins/dataforms/src/strophe.x.js +854 -0
  40. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/.gitignore +1 -0
  41. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/README.markdown +0 -0
  42. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/convert.js +13 -0
  43. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/jasmine.json +11 -0
  44. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/lib/strophe.disco.js +137 -0
  45. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/public/javascript/strophe.disco.js +137 -0
  46. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/01_querying_information.xml +6 -0
  47. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/02_result_set_for_information_request.xml +22 -0
  48. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/03_target_entity_does_not_exist.xml +10 -0
  49. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/04_service_unavailable.xml +11 -0
  50. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/09_querying_specific_jid_and_node_combination.xml +7 -0
  51. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/10_jid_and_node_result.xml +12 -0
  52. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/11_requesting_all_items.xml +6 -0
  53. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/12_result_set_for_all_items.xml +23 -0
  54. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/13_empty_result_set.xml +7 -0
  55. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/17_service_returns_nodes.xml +16 -0
  56. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/18_requesting_further_nodes.xml +7 -0
  57. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/24_jid_and_node_error.xml +11 -0
  58. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/DiscoNodeSpec.js +50 -0
  59. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/SpecHelper.js +51 -0
  60. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/Stanzas.js +0 -0
  61. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/strophe.disco.spec.helper.js +54 -0
  62. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/strophe.disco.spec.js +0 -0
  63. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/spec/support/jasmine.json +13 -0
  64. data/app/assets/javascripts/xmpp/strophejs-plugins/disco/strophe.disco.js +232 -0
  65. data/app/assets/javascripts/xmpp/strophejs-plugins/epic/public/javascript/jquery.epic.js +61 -0
  66. data/app/assets/javascripts/xmpp/strophejs-plugins/epic/spec/SpecHelper.js +9 -0
  67. data/app/assets/javascripts/xmpp/strophejs-plugins/epic/spec/jquery.epic.js +39 -0
  68. data/app/assets/javascripts/xmpp/strophejs-plugins/epic/spec/support/jasmine.json +22 -0
  69. data/app/assets/javascripts/xmpp/strophejs-plugins/iexdomain/iexdomain.js +36 -0
  70. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/README.markdown +117 -0
  71. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/buster.js +23 -0
  72. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/jid.coffee +64 -0
  73. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/jid.js +92 -0
  74. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/spec/browserSetup.coffee +1 -0
  75. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/spec/jid.spec.coffee +96 -0
  76. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/spec/strophe.joap.spec.coffee +461 -0
  77. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/strophe.joap.coffee +304 -0
  78. data/app/assets/javascripts/xmpp/strophejs-plugins/joap/strophe.joap.js +522 -0
  79. data/app/assets/javascripts/xmpp/strophejs-plugins/mam/LICENSE.txt +19 -0
  80. data/app/assets/javascripts/xmpp/strophejs-plugins/mam/README.markdown +52 -0
  81. data/app/assets/javascripts/xmpp/strophejs-plugins/mam/strophe.mam.js +62 -0
  82. data/app/assets/javascripts/xmpp/strophejs-plugins/muc/LICENSE.txt +20 -0
  83. data/app/assets/javascripts/xmpp/strophejs-plugins/muc/strophe.muc.js +1003 -0
  84. data/app/assets/javascripts/xmpp/strophejs-plugins/ping/README.markdown +28 -0
  85. data/app/assets/javascripts/xmpp/strophejs-plugins/ping/strophe.ping.js +68 -0
  86. data/app/assets/javascripts/xmpp/strophejs-plugins/private/README.markdown +16 -0
  87. data/app/assets/javascripts/xmpp/strophejs-plugins/private/strophe.private.js +192 -0
  88. data/app/assets/javascripts/xmpp/strophejs-plugins/pubsub/strophe.pubsub.js +555 -0
  89. data/app/assets/javascripts/xmpp/strophejs-plugins/receipts/strophe.receipts.js +155 -0
  90. data/app/assets/javascripts/xmpp/strophejs-plugins/register/README.markdown +44 -0
  91. data/app/assets/javascripts/xmpp/strophejs-plugins/register/strophe.register.js +431 -0
  92. data/app/assets/javascripts/xmpp/strophejs-plugins/roster/public/javascript/strophe.roster.js +40 -0
  93. data/app/assets/javascripts/xmpp/strophejs-plugins/roster/spec/strophe.roster.spec.js +65 -0
  94. data/app/assets/javascripts/xmpp/strophejs-plugins/roster/spec/support/jasmine.json +15 -0
  95. data/app/assets/javascripts/xmpp/strophejs-plugins/roster/strophe.roster.js +438 -0
  96. data/app/assets/javascripts/xmpp/strophejs-plugins/rpc/.gitignore +6 -0
  97. data/app/assets/javascripts/xmpp/strophejs-plugins/rpc/README.md +113 -0
  98. data/app/assets/javascripts/xmpp/strophejs-plugins/rpc/buster.js +11 -0
  99. data/app/assets/javascripts/xmpp/strophejs-plugins/rpc/lib/strophe.js +4198 -0
  100. data/app/assets/javascripts/xmpp/strophejs-plugins/rpc/spec/strophe.rpc.spec.helper.js +38 -0
  101. data/app/assets/javascripts/xmpp/strophejs-plugins/rpc/spec/strophe.rpc.spec.js +262 -0
  102. data/app/assets/javascripts/xmpp/strophejs-plugins/rpc/strophe.rpc.js +464 -0
  103. data/app/assets/javascripts/xmpp/strophejs-plugins/rsm/strophe.rsm.js +52 -0
  104. data/app/assets/javascripts/xmpp/strophejs-plugins/serverdate/strophe.serverdate.js +58 -0
  105. data/app/assets/javascripts/xmpp/strophejs-plugins/vcard/examples/index.html +17 -0
  106. data/app/assets/javascripts/xmpp/strophejs-plugins/vcard/examples/strophevcard.js +0 -0
  107. data/app/assets/javascripts/xmpp/strophejs-plugins/vcard/strophe.vcard.coffee +44 -0
  108. data/app/assets/javascripts/xmpp/strophejs-plugins/vcard/strophe.vcard.js +66 -0
  109. data/app/assets/stylesheets/xmpp/index.css +0 -0
  110. data/app/controllers/omniauth_callbacks_controller.rb +15 -0
  111. data/app/controllers/ruby_bosh.rb +221 -0
  112. data/app/models/identity.rb +3 -0
  113. data/app/models/user.rb +40 -0
  114. data/bin/rails +8 -0
  115. data/db/migrate/20140329065635_create_users.rb +10 -0
  116. data/db/migrate/20140329070238_create_identities.rb +11 -0
  117. data/lib/xmppify/version.rb +3 -0
  118. data/lib/xmppify.rb +6 -0
  119. data/xmppify.gemspec +23 -0
  120. metadata +197 -0
@@ -0,0 +1,522 @@
1
+ // Generated by CoffeeScript 1.4.0
2
+
3
+ /*
4
+ This program is distributed under the terms of the MIT license.
5
+ Copyright 2012 - 2013 (c) Markus Kohlhase <mail@markus-kohlhase.de>
6
+ */
7
+
8
+
9
+ (function() {
10
+ var JOAPClass, JOAPError, JOAPObject, JOAPServer, JOAP_NS, RPC_NS, add, addRPCElements, addXMLAttributes, conn, createIq, del, describe, edit, getAddress, methodCall, onError, parseAttributeDescription, parseAttributes, parseDesc, parseDescription, parseMethodDescription, parseNewAddress, parseRPCParams, parseSearch, read, search, searchAndRead, sendRequest,
11
+ __hasProp = {}.hasOwnProperty,
12
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
13
+
14
+ JOAP_NS = "jabber:iq:joap";
15
+
16
+ RPC_NS = "jabber:iq:rpc";
17
+
18
+ conn = null;
19
+
20
+ onError = function(cb) {
21
+ if (cb == null) {
22
+ cb = function() {};
23
+ }
24
+ return function(iq) {
25
+ var code, err, msg;
26
+ err = iq.getElementsByTagName("error")[0];
27
+ if (err != null) {
28
+ code = err.getAttribute("code") * 1;
29
+ msg = err.textContent;
30
+ if (code === 503) {
31
+ msg = "JOAP server is unavailable";
32
+ }
33
+ return cb(iq, new JOAPError(msg, code));
34
+ } else {
35
+ return cb(iq, new JOAPError("Unknown error"));
36
+ }
37
+ };
38
+ };
39
+
40
+ addXMLAttributes = function(iq, attrs) {
41
+ var k, v, _results;
42
+ if (!(attrs != null)) {
43
+ return;
44
+ }
45
+ if (attrs instanceof Array) {
46
+ return typeof console !== "undefined" && console !== null ? typeof console.warn === "function" ? console.warn("No attributes added: attribute parameter is not an object") : void 0 : void 0;
47
+ } else if (typeof attrs === "object") {
48
+ _results = [];
49
+ for (k in attrs) {
50
+ v = attrs[k];
51
+ _results.push(iq.c("attribute").c("name").t(k).up().cnode(conn.rpc._convertToXML(v)).up().up());
52
+ }
53
+ return _results;
54
+ }
55
+ };
56
+
57
+ addRPCElements = function(iq, method, params) {
58
+ var p, _i, _len, _results;
59
+ if (params == null) {
60
+ params = [];
61
+ }
62
+ if (typeof method !== "string") {
63
+ throw new TypeError;
64
+ }
65
+ iq.c("methodCall").c("methodName").t(method).up();
66
+ if (!(params instanceof Array)) {
67
+ if (typeof console !== "undefined" && console !== null) {
68
+ if (typeof console.warn === "function") {
69
+ console.warn("No parameters added: parameter is not an array");
70
+ }
71
+ }
72
+ return;
73
+ }
74
+ if (params.length > 0) {
75
+ iq.c("params");
76
+ _results = [];
77
+ for (_i = 0, _len = params.length; _i < _len; _i++) {
78
+ p = params[_i];
79
+ _results.push(iq.c("param").cnode(conn.rpc._convertToXML(p)).up().up());
80
+ }
81
+ return _results;
82
+ }
83
+ };
84
+
85
+ parseAttributes = function(iq) {
86
+ var a, attrs, data, key, _i, _len;
87
+ attrs = iq.getElementsByTagName("attribute");
88
+ data = {};
89
+ for (_i = 0, _len = attrs.length; _i < _len; _i++) {
90
+ a = attrs[_i];
91
+ key = a.getElementsByTagName("name")[0].textContent;
92
+ data[key] = conn.rpc._convertFromXML(a.getElementsByTagName("value")[0]);
93
+ }
94
+ return data;
95
+ };
96
+
97
+ parseRPCParams = function(iq) {
98
+ return conn.rpc._convertFromXML(iq.getElementsByTagName("param")[0].getElementsByTagName("value")[0]);
99
+ };
100
+
101
+ parseNewAddress = function(iq) {
102
+ var address;
103
+ return address = new JID(iq.getElementsByTagName("newAddress")[0].textContent).toString();
104
+ };
105
+
106
+ parseSearch = function(iq) {
107
+ var i, items, _i, _len, _results;
108
+ items = iq.getElementsByTagName("item");
109
+ _results = [];
110
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
111
+ i = items[_i];
112
+ _results.push(new JID(i.textContent).toString());
113
+ }
114
+ return _results;
115
+ };
116
+
117
+ parseAttributeDescription = function(d) {
118
+ var _ref, _ref1;
119
+ return {
120
+ name: (_ref = d.getElementsByTagName("name")[0]) != null ? _ref.textContent : void 0,
121
+ type: (_ref1 = d.getElementsByTagName("type")[0]) != null ? _ref1.textContent : void 0,
122
+ desc: parseDesc(d.getElementsByTagName("desc"))
123
+ };
124
+ };
125
+
126
+ parseMethodDescription = function(d) {
127
+ var _ref, _ref1;
128
+ return {
129
+ name: (_ref = d.getElementsByTagName("name")[0]) != null ? _ref.textContent : void 0,
130
+ returnType: (_ref1 = d.getElementsByTagName("returnType")[0]) != null ? _ref1.textContent : void 0,
131
+ desc: parseDesc(d.getElementsByTagName("desc"))
132
+ };
133
+ };
134
+
135
+ parseDesc = function(desc) {
136
+ var c, res, _i, _len;
137
+ res = {};
138
+ if (desc instanceof NodeList) {
139
+ for (_i = 0, _len = desc.length; _i < _len; _i++) {
140
+ c = desc[_i];
141
+ res[c.getAttribute("xml:lang")] = c.textContent;
142
+ }
143
+ } else {
144
+ res.desc[desc.getAttribute("xml:lang")] = desc.textContent;
145
+ }
146
+ return res;
147
+ };
148
+
149
+ parseDescription = function(iq) {
150
+ var ad, c, describe, md, result, _i, _len, _ref;
151
+ result = {
152
+ desc: {},
153
+ attributes: {},
154
+ methods: {},
155
+ classes: []
156
+ };
157
+ describe = iq.getElementsByTagName("describe")[0];
158
+ _ref = describe.childNodes;
159
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
160
+ c = _ref[_i];
161
+ switch (c.tagName.toLowerCase()) {
162
+ case "desc":
163
+ result.desc[c.getAttribute("xml:lang")] = c.textContent;
164
+ break;
165
+ case "attributedescription":
166
+ ad = parseAttributeDescription(c);
167
+ result.attributes[ad.name] = ad;
168
+ break;
169
+ case "methoddescription":
170
+ md = parseMethodDescription(c);
171
+ result.methods[md.name] = md;
172
+ break;
173
+ case "superclass":
174
+ result.superclass = new JID(c.textContent).toString();
175
+ break;
176
+ case "timestamp":
177
+ result.timestamp = c.textContent;
178
+ break;
179
+ case "class":
180
+ classes.push = c.textContent;
181
+ }
182
+ }
183
+ return result;
184
+ };
185
+
186
+ getAddress = function(clazz, service, instance) {
187
+ return (new JID(clazz, service, instance)).toString();
188
+ };
189
+
190
+ createIq = function(type, to) {
191
+ var iqType, xmlns;
192
+ iqType = (type === "read" || type === "search" || type === "describe") ? "get" : "set";
193
+ xmlns = type === "query" ? RPC_NS : JOAP_NS;
194
+ return $iq({
195
+ to: to,
196
+ type: iqType
197
+ }).c(type, {
198
+ xmlns: xmlns
199
+ });
200
+ };
201
+
202
+ sendRequest = function(type, to, cb, opt) {
203
+ var iq, success;
204
+ if (opt == null) {
205
+ opt = {};
206
+ }
207
+ iq = createIq(type, to);
208
+ if (typeof opt.beforeSend === "function") {
209
+ opt.beforeSend(iq);
210
+ }
211
+ success = function(res) {
212
+ return typeof cb === "function" ? cb(res, null, typeof opt.onResult === "function" ? opt.onResult(res) : void 0) : void 0;
213
+ };
214
+ return conn.sendIQ(iq, success, onError(cb));
215
+ };
216
+
217
+ describe = function(id, cb) {
218
+ return sendRequest("describe", id, cb, {
219
+ onResult: parseDescription
220
+ });
221
+ };
222
+
223
+ read = function(instance, limits, cb) {
224
+ if (typeof limits === "function") {
225
+ cb = limits;
226
+ limits = null;
227
+ }
228
+ return sendRequest("read", instance, cb, {
229
+ beforeSend: function(iq) {
230
+ var l, _i, _len, _results;
231
+ if (limits instanceof Array) {
232
+ _results = [];
233
+ for (_i = 0, _len = limits.length; _i < _len; _i++) {
234
+ l = limits[_i];
235
+ _results.push(iq.c("name").t(l).up());
236
+ }
237
+ return _results;
238
+ }
239
+ },
240
+ onResult: parseAttributes
241
+ });
242
+ };
243
+
244
+ add = function(clazz, attrs, cb) {
245
+ if (typeof attrs === "function") {
246
+ cb = attrs;
247
+ }
248
+ return sendRequest("add", clazz, cb, {
249
+ beforeSend: function(iq) {
250
+ return addXMLAttributes(iq, attrs);
251
+ },
252
+ onResult: parseNewAddress
253
+ });
254
+ };
255
+
256
+ edit = function(instance, attrs, cb) {
257
+ return sendRequest("edit", instance, cb, {
258
+ beforeSend: function(iq) {
259
+ return addXMLAttributes(iq, attrs);
260
+ },
261
+ onResult: parseAttributes
262
+ });
263
+ };
264
+
265
+ search = function(clazz, attrs, cb) {
266
+ if (typeof attrs === "function") {
267
+ cb = attrs;
268
+ attrs = null;
269
+ }
270
+ return sendRequest("search", clazz, cb, {
271
+ beforeSend: function(iq) {
272
+ return addXMLAttributes(iq, attrs);
273
+ },
274
+ onResult: parseSearch
275
+ });
276
+ };
277
+
278
+ searchAndRead = function(clazz, attrs, limits, cb) {
279
+ if (typeof limits === "function") {
280
+ cb = limits;
281
+ limits = null;
282
+ }
283
+ if (typeof attrs === "function" && !(limits != null)) {
284
+ cb = attrs;
285
+ attrs = null;
286
+ } else if (attrs instanceof Array && !(limits != null)) {
287
+ limits = attrs;
288
+ attrs = null;
289
+ }
290
+ return search(clazz, attrs, function(iq, err, res) {
291
+ var count, id, objects, readCB, _i, _len, _results;
292
+ if (err != null) {
293
+ return cb(err);
294
+ } else {
295
+ objects = [];
296
+ count = res.length;
297
+ if (count > 0) {
298
+ readCB = function(iq, err, o) {
299
+ if (err != null) {
300
+ return cb(err);
301
+ } else {
302
+ count--;
303
+ objects.push(o);
304
+ if (count === 0) {
305
+ return cb(null, objects);
306
+ }
307
+ }
308
+ };
309
+ _results = [];
310
+ for (_i = 0, _len = res.length; _i < _len; _i++) {
311
+ id = res[_i];
312
+ _results.push((function(id) {
313
+ return read(id, limits, readCB);
314
+ })(id));
315
+ }
316
+ return _results;
317
+ } else {
318
+ return cb(null, objects);
319
+ }
320
+ }
321
+ });
322
+ };
323
+
324
+ del = function(instance, cb) {
325
+ return sendRequest("delete", instance, cb);
326
+ };
327
+
328
+ methodCall = function(method, address, params, cb) {
329
+ return sendRequest("query", address, cb, {
330
+ beforeSend: function(iq) {
331
+ return addRPCElements(iq, method, params);
332
+ },
333
+ onResult: parseRPCParams
334
+ });
335
+ };
336
+
337
+ JOAPError = (function(_super) {
338
+
339
+ __extends(JOAPError, _super);
340
+
341
+ function JOAPError(message, code) {
342
+ this.message = message;
343
+ this.code = code;
344
+ this.name = "JOAPError";
345
+ }
346
+
347
+ return JOAPError;
348
+
349
+ })(Error);
350
+
351
+ JOAPServer = (function() {
352
+
353
+ function JOAPServer(service) {
354
+ this.jid = new JID(service);
355
+ }
356
+
357
+ JOAPServer.prototype.describe = function(clazz, instance, cb) {
358
+ if (typeof clazz === "function") {
359
+ cb = clazz;
360
+ clazz = instance = null;
361
+ } else if (typeof instance === "function") {
362
+ cb = instance;
363
+ instance = null;
364
+ }
365
+ return describe(getAddress(clazz, this.jid.domain, instance), cb);
366
+ };
367
+
368
+ JOAPServer.prototype.add = function(clazz, attrs, cb) {
369
+ return add(getAddress(clazz, this.jid.domain), attrs, cb);
370
+ };
371
+
372
+ JOAPServer.prototype.read = function(clazz, instance, limits, cb) {
373
+ return read(getAddress(clazz, this.jid.domain, instance), limits, cb);
374
+ };
375
+
376
+ JOAPServer.prototype.edit = function(clazz, instance, attrs, cb) {
377
+ return edit(getAddress(clazz, this.jid.domain, instance), attrs, cb);
378
+ };
379
+
380
+ JOAPServer.prototype["delete"] = function(clazz, instance, cb) {
381
+ return del(getAddress(clazz, this.jid.domain, instance), cb);
382
+ };
383
+
384
+ JOAPServer.prototype.search = function(clazz, attrs, cb) {
385
+ return search(getAddress(clazz, this.jid.domain), attrs, cb);
386
+ };
387
+
388
+ JOAPServer.prototype.searchAndRead = function(clazz, attrs, limits, cb) {
389
+ return searchAndRead(getAddress(clazz, this.jid.domain), attrs, limits, cb);
390
+ };
391
+
392
+ JOAPServer.prototype.methodCall = function(method, clazz, instance, params, cb) {
393
+ if (typeof clazz === "function") {
394
+ cb = clazz;
395
+ clazz = instance = params = null;
396
+ } else if (typeof instance === "function") {
397
+ cb = instance;
398
+ instance = params = null;
399
+ } else if (typeof params === "function") {
400
+ cb = params;
401
+ params = null;
402
+ }
403
+ return methodCall(method, getAddress(clazz, this.jid.domain, instance), params, cb);
404
+ };
405
+
406
+ return JOAPServer;
407
+
408
+ })();
409
+
410
+ JOAPObject = (function() {
411
+
412
+ function JOAPObject(id) {
413
+ this.jid = new JID(id);
414
+ }
415
+
416
+ JOAPObject.prototype.read = function(limits, cb) {
417
+ return read(this.jid.toString(), limits, cb);
418
+ };
419
+
420
+ JOAPObject.prototype.edit = function(attrs, cb) {
421
+ return edit(this.jid.toString(), attrs, cb);
422
+ };
423
+
424
+ JOAPObject.prototype.describe = function(cb) {
425
+ return describe(this.jid.toString(), cb);
426
+ };
427
+
428
+ JOAPObject.prototype.methodCall = function(method, params, cb) {
429
+ if (typeof params === "function") {
430
+ cb = params;
431
+ params = null;
432
+ }
433
+ return methodCall(method, this.jid.toString(), params, cb);
434
+ };
435
+
436
+ return JOAPObject;
437
+
438
+ })();
439
+
440
+ JOAPClass = (function() {
441
+
442
+ function JOAPClass(id) {
443
+ this.jid = new JID(id);
444
+ }
445
+
446
+ JOAPClass.prototype.describe = function(instance, cb) {
447
+ if (typeof instance === "function") {
448
+ cb = instance;
449
+ instance = null;
450
+ }
451
+ return describe(getAddress(this.jid.user, this.jid.domain, instance), cb);
452
+ };
453
+
454
+ JOAPClass.prototype.add = function(attrs, cb) {
455
+ return add(getAddress(this.jid.user, this.jid.domain), attrs, cb);
456
+ };
457
+
458
+ JOAPClass.prototype.read = function(instance, limits, cb) {
459
+ return read(getAddress(this.jid.user, this.jid.domain, instance), limits, cb);
460
+ };
461
+
462
+ JOAPClass.prototype.edit = function(instance, attrs, cb) {
463
+ return edit(getAddress(this.jid.user, this.jid.domain, instance), attrs, cb);
464
+ };
465
+
466
+ JOAPClass.prototype["delete"] = function(instance, cb) {
467
+ return del(getAddress(this.jid.user, this.jid.domain, instance), cb);
468
+ };
469
+
470
+ JOAPClass.prototype.search = function(attrs, cb) {
471
+ return search(getAddress(this.jid.user, this.jid.domain), attrs, cb);
472
+ };
473
+
474
+ JOAPClass.prototype.searchAndRead = function(attrs, limits, cb) {
475
+ return searchAndRead(getAddress(this.jid.user, this.jid.domain), attrs, limits, cb);
476
+ };
477
+
478
+ JOAPClass.prototype.methodCall = function(method, instance, params, cb) {
479
+ if (typeof instance === "function") {
480
+ cb = instance;
481
+ instance = params = null;
482
+ } else if (typeof params === "function") {
483
+ cb = params;
484
+ params = null;
485
+ }
486
+ return methodCall(method, getAddress(this.jid.user, this.jid.domain, instance), params, cb);
487
+ };
488
+
489
+ return JOAPClass;
490
+
491
+ })();
492
+
493
+ Strophe.addConnectionPlugin('joap', (function() {
494
+ var init;
495
+ init = function(c) {
496
+ conn = c;
497
+ Strophe.addNamespace("JOAP", JOAP_NS);
498
+ if (!conn.hasOwnProperty("disco")) {
499
+ return Strophe.warn("You need the discovery plugin to have JOAP fully implemented.");
500
+ } else {
501
+ conn.disco.addIdentity("automation", "joap");
502
+ return conn.disco.addFeature(Strophe.NS.JOAP);
503
+ }
504
+ };
505
+ return {
506
+ init: init,
507
+ describe: describe,
508
+ add: add,
509
+ read: read,
510
+ edit: edit,
511
+ "delete": del,
512
+ search: search,
513
+ searchAndRead: searchAndRead,
514
+ methodCall: methodCall,
515
+ JOAPError: JOAPError,
516
+ JOAPServer: JOAPServer,
517
+ JOAPObject: JOAPObject,
518
+ JOAPClass: JOAPClass
519
+ };
520
+ })());
521
+
522
+ }).call(this);
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2012 Kim Alvefur
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a
4
+ copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the
8
+ Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19
+ DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # strophe.mam.js
2
+
3
+ strophe.mam.js is a plugin to provide Message Archiving Management
4
+ ( [XEP-0313]( http://xmpp.org/extensions/xep-0313.html ) ).
5
+
6
+ ## Usage
7
+
8
+ ### Querying an archive
9
+
10
+ `connection.mam.query(where, parameters)`
11
+
12
+ `where` is the JID hosting the archive. In most cases you will want to
13
+ set this to your own bare JID in order query your personal archive, but
14
+ it could also be a MUC room, an archiving component or a bot.
15
+
16
+ `parameters` is an object containing parameters for the query. This can
17
+ have properties from two and a half categories:
18
+
19
+ **Handlers**: `onMessage` which gets called for each message received,
20
+ and `onComplete` which is called when the query is completed.
21
+
22
+ **Filtering**: Half of this is the parameters defined by MAM; `with`,
23
+ `start` or `end`, which allow you to filter the results on who the
24
+ conversation was *with*, and the time range.
25
+
26
+ Additionally, parameters from [Result Set Management][RSM] can be
27
+ supplied. You would probably be most interested in the `after` and
28
+ `before` properties, which allow you to do pagination of the result set,
29
+ and the `max` property, which allow you to limit the number of items in
30
+ each page. *Note:* Better RSM integration is on the TODO, you currently
31
+ have to pick out the `last` or `first` items yourself and pass
32
+ those as `after` or `before` respectively.
33
+
34
+ [RSM]: http://xmpp.org/extensions/xep-0059.html
35
+
36
+ ### Example
37
+
38
+ To query, for example, your personal archive for conversations with
39
+ `juliet@capulet.com` you could do:
40
+
41
+ connection.mam.query("you@example.com", {
42
+ "with": "juliet@capulet.com",
43
+ onMessage: function(message) {
44
+ console.log("Message from ", $(message).find("forwarded message").attr("from"),
45
+ ": ", $(message).find("forwarded message body").text());
46
+ },
47
+ onComplete: function(response) {
48
+ console.log("Got all the messages");
49
+ }
50
+ });
51
+
52
+
@@ -0,0 +1,62 @@
1
+ /* XEP-0313: Message Archive Management
2
+ * Copyright (C) 2012 Kim Alvefur
3
+ *
4
+ * This file is MIT/X11 licensed. Please see the
5
+ * LICENSE.txt file in the source package for more information.
6
+ *
7
+ * TODO:
8
+ * Get RSM from the reply
9
+ * Clean remove onMessage handler afterwards
10
+ * queryid?
11
+ *
12
+ */
13
+
14
+ Strophe.addConnectionPlugin('mam', {
15
+ _c: null,
16
+ _p: [ "with", "start", "end" ],
17
+ init:
18
+ function(conn) {
19
+ this._c = conn;
20
+ Strophe.addNamespace('MAM', 'urn:xmpp:mam:tmp');
21
+ },
22
+ query:
23
+ function(jid, options) {
24
+ var _p = this._p;
25
+ var attr = {type:"get",to:jid};
26
+ var mamAttr = {xmlns: Strophe.NS.MAM};
27
+ var iq = $iq(attr).c("query", mamAttr);
28
+ for (i=0; i < this._p.length; i++) {
29
+ var pn = _p[i];
30
+ var p = options[pn]; delete options[pn];
31
+ if(!!p) {
32
+ iq.c(pn).t(p).up();
33
+ }
34
+ }
35
+ var onMessage = options["onMessage"]; delete options['onMessage'];
36
+ var onComplete = options["onComplete"]; delete options['onComplete'];
37
+ iq.cnode(new Strophe.RSM(options).toXML());
38
+ this._c.addHandler(onMessage, Strophe.NS.MAM, "message", null);
39
+ return this._c.sendIQ(iq, onComplete);
40
+ },
41
+ /* Proposed format for preferences, once implemented:
42
+ *
43
+ * prefs ::= Object
44
+ * prefs.default ::= [ "always" | "never" | "roster" ]
45
+ * prefs.always ::= Array( JID* )
46
+ * prefs.never ::= Array( JID* )
47
+ *
48
+ * Example
49
+ * setPrefs(me, {
50
+ * default: "roster",
51
+ * always: [ "alice@wonderland.lit" ],
52
+ * never: [ "madhatter@wonderland.lit" ]
53
+ * });
54
+ *
55
+ getPrefs:
56
+ function(jid) {
57
+ },
58
+ setPrefs:
59
+ function(jid, prefs) {
60
+ },
61
+ */
62
+ });
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Andreas Guth, Dominik Renzel, RWTH Aachen University,
2
+ Chair of Computer Science 5 (Databases & Information Systems), ACIS Group
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.