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,232 @@
1
+ /*
2
+ Copyright 2010, François de Metz <francois@2metz.fr>
3
+ */
4
+
5
+ /**
6
+ * Disco Strophe Plugin
7
+ * Implement http://xmpp.org/extensions/xep-0030.html
8
+ * TODO: manage node hierarchies, and node on info request
9
+ */
10
+ Strophe.addConnectionPlugin('disco',
11
+ {
12
+ _connection: null,
13
+ _identities : [],
14
+ _features : [],
15
+ _items : [],
16
+ /** Function: init
17
+ * Plugin init
18
+ *
19
+ * Parameters:
20
+ * (Strophe.Connection) conn - Strophe connection
21
+ */
22
+ init: function(conn)
23
+ {
24
+ this._connection = conn;
25
+ this._identities = [];
26
+ this._features = [];
27
+ this._items = [];
28
+ // disco info
29
+ conn.addHandler(this._onDiscoInfo.bind(this), Strophe.NS.DISCO_INFO, 'iq', 'get', null, null);
30
+ // disco items
31
+ conn.addHandler(this._onDiscoItems.bind(this), Strophe.NS.DISCO_ITEMS, 'iq', 'get', null, null);
32
+ },
33
+ /** Function: addIdentity
34
+ * See http://xmpp.org/registrar/disco-categories.html
35
+ * Parameters:
36
+ * (String) category - category of identity (like client, automation, etc ...)
37
+ * (String) type - type of identity (like pc, web, bot , etc ...)
38
+ * (String) name - name of identity in natural language
39
+ * (String) lang - lang of name parameter
40
+ *
41
+ * Returns:
42
+ * Boolean
43
+ */
44
+ addIdentity: function(category, type, name, lang)
45
+ {
46
+ for (var i=0; i<this._identities.length; i++)
47
+ {
48
+ if (this._identities[i].category == category &&
49
+ this._identities[i].type == type &&
50
+ this._identities[i].name == name &&
51
+ this._identities[i].lang == lang)
52
+ {
53
+ return false;
54
+ }
55
+ }
56
+ this._identities.push({category: category, type: type, name: name, lang: lang});
57
+ return true;
58
+ },
59
+ /** Function: addFeature
60
+ *
61
+ * Parameters:
62
+ * (String) var_name - feature name (like jabber:iq:version)
63
+ *
64
+ * Returns:
65
+ * boolean
66
+ */
67
+ addFeature: function(var_name)
68
+ {
69
+ for (var i=0; i<this._features.length; i++)
70
+ {
71
+ if (this._features[i] == var_name)
72
+ return false;
73
+ }
74
+ this._features.push(var_name);
75
+ return true;
76
+ },
77
+ /** Function: removeFeature
78
+ *
79
+ * Parameters:
80
+ * (String) var_name - feature name (like jabber:iq:version)
81
+ *
82
+ * Returns:
83
+ * boolean
84
+ */
85
+ removeFeature: function(var_name)
86
+ {
87
+ for (var i=0; i<this._features.length; i++)
88
+ {
89
+ if (this._features[i] === var_name){
90
+ this._features.splice(i,1)
91
+ return true;
92
+ }
93
+ }
94
+ return false;
95
+ },
96
+ /** Function: addItem
97
+ *
98
+ * Parameters:
99
+ * (String) jid
100
+ * (String) name
101
+ * (String) node
102
+ * (Function) call_back
103
+ *
104
+ * Returns:
105
+ * boolean
106
+ */
107
+ addItem: function(jid, name, node, call_back)
108
+ {
109
+ if (node && !call_back)
110
+ return false;
111
+ this._items.push({jid: jid, name: name, node: node, call_back: call_back});
112
+ return true;
113
+ },
114
+ /** Function: info
115
+ * Info query
116
+ *
117
+ * Parameters:
118
+ * (Function) call_back
119
+ * (String) jid
120
+ * (String) node
121
+ */
122
+ info: function(jid, node, success, error, timeout)
123
+ {
124
+ var attrs = {xmlns: Strophe.NS.DISCO_INFO};
125
+ if (node)
126
+ attrs.node = node;
127
+
128
+ var info = $iq({from:this._connection.jid,
129
+ to:jid, type:'get'}).c('query', attrs);
130
+ this._connection.sendIQ(info, success, error, timeout);
131
+ },
132
+ /** Function: items
133
+ * Items query
134
+ *
135
+ * Parameters:
136
+ * (Function) call_back
137
+ * (String) jid
138
+ * (String) node
139
+ */
140
+ items: function(jid, node, success, error, timeout)
141
+ {
142
+ var attrs = {xmlns: Strophe.NS.DISCO_ITEMS};
143
+ if (node)
144
+ attrs.node = node;
145
+
146
+ var items = $iq({from:this._connection.jid,
147
+ to:jid, type:'get'}).c('query', attrs);
148
+ this._connection.sendIQ(items, success, error, timeout);
149
+ },
150
+
151
+ /** PrivateFunction: _buildIQResult
152
+ */
153
+ _buildIQResult: function(stanza, query_attrs)
154
+ {
155
+ var id = stanza.getAttribute('id');
156
+ var from = stanza.getAttribute('from');
157
+ var iqresult = $iq({type: 'result', id: id});
158
+
159
+ if (from !== null) {
160
+ iqresult.attrs({to: from});
161
+ }
162
+
163
+ return iqresult.c('query', query_attrs);
164
+ },
165
+
166
+ /** PrivateFunction: _onDiscoInfo
167
+ * Called when receive info request
168
+ */
169
+ _onDiscoInfo: function(stanza)
170
+ {
171
+ var node = stanza.getElementsByTagName('query')[0].getAttribute('node');
172
+ var attrs = {xmlns: Strophe.NS.DISCO_INFO};
173
+ if (node)
174
+ {
175
+ attrs.node = node;
176
+ }
177
+ var iqresult = this._buildIQResult(stanza, attrs);
178
+ for (var i=0; i<this._identities.length; i++)
179
+ {
180
+ var attrs = {category: this._identities[i].category,
181
+ type : this._identities[i].type};
182
+ if (this._identities[i].name)
183
+ attrs.name = this._identities[i].name;
184
+ if (this._identities[i].lang)
185
+ attrs['xml:lang'] = this._identities[i].lang;
186
+ iqresult.c('identity', attrs).up();
187
+ }
188
+ for (var i=0; i<this._features.length; i++)
189
+ {
190
+ iqresult.c('feature', {'var':this._features[i]}).up();
191
+ }
192
+ this._connection.send(iqresult.tree());
193
+ return true;
194
+ },
195
+ /** PrivateFunction: _onDiscoItems
196
+ * Called when receive items request
197
+ */
198
+ _onDiscoItems: function(stanza)
199
+ {
200
+ var query_attrs = {xmlns: Strophe.NS.DISCO_ITEMS};
201
+ var node = stanza.getElementsByTagName('query')[0].getAttribute('node');
202
+ if (node)
203
+ {
204
+ query_attrs.node = node;
205
+ var items = [];
206
+ for (var i = 0; i < this._items.length; i++)
207
+ {
208
+ if (this._items[i].node == node)
209
+ {
210
+ items = this._items[i].call_back(stanza);
211
+ break;
212
+ }
213
+ }
214
+ }
215
+ else
216
+ {
217
+ var items = this._items;
218
+ }
219
+ var iqresult = this._buildIQResult(stanza, query_attrs);
220
+ for (var i = 0; i < items.length; i++)
221
+ {
222
+ var attrs = {jid: items[i].jid};
223
+ if (items[i].name)
224
+ attrs.name = items[i].name;
225
+ if (items[i].node)
226
+ attrs.node = items[i].node;
227
+ iqresult.c('item', attrs).up();
228
+ }
229
+ this._connection.send(iqresult.tree());
230
+ return true;
231
+ }
232
+ });
@@ -0,0 +1,61 @@
1
+ (function($) {
2
+
3
+ function log(msg) {
4
+ if (window.console) {
5
+ console.log('epic.' + msg);
6
+ }
7
+ }
8
+
9
+ var templates = {
10
+ roster: '<ul class="epic-roster"></ul>',
11
+ roster_item: '<li data-jid="${jid}" class="epic-roster-item">${jid}</li>',
12
+ cmds: '<ul class="epic-cmds"></ul>',
13
+ cmds_item: '<li class="epic-cmd-item" data-jid="${jid}" data-node="${node}">${name}</li>'
14
+ };
15
+
16
+ var epic = {
17
+ _create: function() {
18
+ log('create');
19
+ this.element.append(templates.roster);
20
+ this.element.append(templates.cmds);
21
+ this._conn = this.options.conn;
22
+ this._conn.roster.onPresenceChanged = $.proxy(this.updateRoster, this);
23
+ this.element.delegate('.epic-roster', 'click', $.proxy(this.getCmdList,this));
24
+ this.element.delegate('.epic-cmds', 'click', $.proxy(this.executeCmd,this));
25
+ },
26
+ updateRoster: function(jid, status) {
27
+ log('updateRoster');
28
+ var roster = this.element.find('.epic-roster');
29
+ $(".epic-roster-item[data-jid='" + jid + "']", roster).remove();
30
+ if (status !== 'unavailable') {
31
+ $.tmpl(templates.roster_item, {jid: jid}).appendTo(roster);
32
+ }
33
+ },
34
+ getCmdList: function(e) {
35
+ var node = $(e.target).text();
36
+ log('getCmdList for ' + node);
37
+ this._conn.disco.items(node, Strophe.NS.CMDS, $.proxy(this.updateCmdList, this));
38
+ },
39
+ updateCmdList: function(iq) {
40
+ var cmds = this.element.find('.epic-cmds');
41
+ $("item",iq).each(function(i,item) {
42
+ item = $(item);
43
+ var data = {
44
+ node: item.attr('node'),
45
+ name: item.attr('name'),
46
+ jid: item.attr('jid')
47
+ };
48
+ $.tmpl(templates.cmds_item, data).appendTo(cmds);
49
+ });
50
+ },
51
+ executeCmd: function(e) {
52
+ var target = $(e.target);
53
+ var node = target.attr('data-node');
54
+ var jid = target.attr('data-jid');
55
+ log('executeCmd for ' + node + ' on ' + jid);
56
+ this._conn.cmds.execute(jid, node);
57
+ }
58
+ };
59
+
60
+ $.widget('nmk.epic', epic);
61
+ })(jQuery);
@@ -0,0 +1,9 @@
1
+ beforeEach(function() {
2
+ this.addMatchers({
3
+ toBePlaying: function(expectedSong) {
4
+ var player = this.actual;
5
+ return player.currentlyPlayingSong === expectedSong
6
+ && player.isPlaying;
7
+ }
8
+ })
9
+ });
@@ -0,0 +1,39 @@
1
+ describe("plugin", function() {
2
+ var conn, epic;
3
+ beforeEach(function() {
4
+ conn = new Strophe.Connection();
5
+ conn.authenticated = true;
6
+ conn._changeConnectStatus(Strophe.Status.CONNECTED);
7
+ epic = $("<div/>").epic({conn: conn});
8
+ });
9
+
10
+ it("shows item in roster", function() {
11
+ var pres = $pres({from: 'n@d/r'});
12
+ conn._dataRecv(createRequest(pres));
13
+ expect(conn.roster.contacts).toEqual({'n@d/r': 'available'});
14
+ expect(epic.find('.epic-roster-item').text()).toEqual('n@d/r');
15
+ });
16
+
17
+ it("gets commands and displays them", function() {
18
+ var x = '<ul class="epic-roster"><li class="epic-roster-item">n@d/r</li></ul>';
19
+ epic.append(x);
20
+ spyOn(conn,'send').andCallFake(function(iq) {
21
+ var res = $iq({type: 'result', id: $(iq).attr('id')});
22
+ res.c('query', {xmlns: Strophe.NS.DISCO_ITEMS, node: Strophe.NS.CMDS});
23
+ res.c('item', {name: 'aName', node: 'aNode', jid: $(iq).attr('from')});
24
+ conn._dataRecv(createRequest(res));
25
+ expect(epic.find('.epic-cmd-item').text()).toEqual('aName');
26
+
27
+ });
28
+ epic.find('.epic-roster-item').click();
29
+ });
30
+
31
+ it("executes command", function() {
32
+ var x = '<ul class="epic-cmds"><li data-node="aNode" data-jid="n@d/r" class="epic-cmd-item">cmd</li></ul>';
33
+ epic.append(x);
34
+ spyOn(conn,'send');
35
+ epic.find('.epic-cmd-item').click();
36
+ expect(conn.send).toHaveBeenCalled();
37
+ });
38
+
39
+ });
@@ -0,0 +1,22 @@
1
+ {
2
+ "src_dir" : "/public/javascript/",
3
+ "spec_dir" : "/spec/",
4
+
5
+ "server":{
6
+ "port":8124
7
+ },
8
+ "externals":[
9
+ "https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js",
10
+ "http://localhost/jquery.ui.widget.js",
11
+ "http://localhost/strophe.js",
12
+ "http://localhost/strophe.roster.js",
13
+ "http://localhost/strophe.disco.js",
14
+ "http://localhost/strophe.cmds.js",
15
+ "http://localhost/Stanzas.js",
16
+ "http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js"
17
+ ],
18
+
19
+ "_other external files you can add above":[
20
+ "https://github.com/pivotal/jasmine-ajax/raw/master/lib/mock-ajax.js"
21
+ ]
22
+ }
@@ -0,0 +1,36 @@
1
+ Strophe.addConnectionPlugin('iexdomain', {
2
+ init: function(conn) {
3
+ // replace Strophe.Request._newXHR with new IE CrossDomain version
4
+ if (window.XDomainRequest) {
5
+ Strophe.Request.prototype._newXHR = function() {
6
+ var xhr = new XDomainRequest();
7
+ xhr.readyState = 0;
8
+
9
+ xhr.onreadystatechange = this.func.prependArg(this);
10
+ xhr.onerror = function() {
11
+ xhr.readyState = 4;
12
+ xhr.status = 500;
13
+ xhr.onreadystatechange(xhr.responseText);
14
+ };
15
+ xhr.ontimeout = function() {
16
+ xhr.readyState = 4;
17
+ xhr.status = 0;
18
+ xhr.onreadystatechange(xhr.responseText);
19
+ };
20
+ xhr.onload = function() {
21
+ xhr.readyState = 4;
22
+ xhr.status = 200;
23
+ var _response = xhr.responseText;
24
+ var _xml = new ActiveXObject('Microsoft.XMLDOM');
25
+ _xml.async = 'false';
26
+ _xml.loadXML(_response);
27
+ xhr.responseXML = _xml;
28
+ xhr.onreadystatechange(_response);
29
+ };
30
+ return xhr;
31
+ };
32
+ } else {
33
+ console.info("Browser doesnt support XDomainRequest." + " Falling back to native XHR implementation.");
34
+ }
35
+ }
36
+ });
@@ -0,0 +1,117 @@
1
+ # Jabber Object Access Protocol
2
+
3
+ A strophe plugin for the Jabber Object Access Protocol
4
+ ([XEP-0075](http://xmpp.org/extensions/xep-0075.html)).
5
+
6
+ ## Usage
7
+
8
+ Link the `rpc`, `jid` and the `joap` plugin below the strophe library in your
9
+ HTML head section:
10
+
11
+ ``` html
12
+ <head>
13
+ <!-- ... -->
14
+ <script type="text/javascript" src="strophe.min.js"></script>
15
+ <script type="text/javascript" src="jid.js"></script>
16
+ <script type="text/javascript" src="strophe.disco.js"></script>
17
+ <script type="text/javascript" src="strophe.rpc.js"></script>
18
+ <script type="text/javascript" src="strophe.joap.js"></script>
19
+ <!-- ... -->
20
+ </head>
21
+ ```
22
+
23
+ After your client is sucessfully connected you can create, read, update and
24
+ delete objects.
25
+
26
+ ### Server
27
+
28
+ ``` coffeescript
29
+ objectServer = new connection.joap.JOAPServer "component.example.org"
30
+
31
+ # requesting the server description
32
+ objectServer.describe (iq, err, parsedDescription) ->
33
+
34
+ # requesting a class description
35
+ objectServer.describe "User", (iq, err, parsedDescription) ->
36
+
37
+ # creating a new instance
38
+ objectServer.add "User", { name:"My Name", age: 99 }, (iq, err, instanceAddress) ->
39
+
40
+ # reading an instance
41
+ objectServer.read "User", "instanceId", (iq, err, parsedResult) ->
42
+
43
+ # reading only a few properties of an instance
44
+ objectServer.read "User", "instanceId", ["email", "age"], (iq, err, parsedResult) ->
45
+
46
+ # modifying properties of an instance
47
+ objectServer.edit "User", "instanceId", { age: 27 }, (iq, err) ->
48
+
49
+ # deleting an instance
50
+ objectServer.delete "User", "instanceId", (iq, err) ->
51
+
52
+ # searching for instances
53
+ objectServer.search "User", {age: 60} , (iq, err, arrayOfInstanceIDs) ->
54
+
55
+ # searching and reading in one step
56
+ objectServer.searchAndRead "User", {type: "admin"}, ["email"], (iq, err, arrayOfInstancObjects) ->
57
+
58
+ # performing a method call
59
+ objectServer.methodCall "myMethod", "User", ["param1","param2"], (iq, err, result) ->
60
+ ```
61
+
62
+ ### Class
63
+
64
+ ``` coffeescript
65
+ aClass = new connection.joap.JOAPClass "myClass@component.example.org"
66
+
67
+ # requesting a class description
68
+ aClass.describe (iq, err, parsedDescription) ->
69
+
70
+ # searching for class instances
71
+ aClass.search (iq, err, arrayOfInstanceIDs) ->
72
+
73
+ # searching and reading
74
+ aClass.searchAndRead filter, limits, (iq, err, arrayOfInstances) ->
75
+
76
+ # creating a new instance
77
+ aClass.add { aProperty:"aValue" }, (iq, err, instanceAddress) ->
78
+ ```
79
+
80
+ ### Object
81
+
82
+ ``` coffeescript
83
+ obj = new connection.joap.JOAPObject "myClass@component.example.org/instanceId"
84
+
85
+ # modifying properties
86
+ obj.edit { key: 'value' }, (iq, err) ->
87
+ ```
88
+
89
+ ## Dependencies
90
+
91
+ - jid.js
92
+ - [rpc](https://github.com/metajack/strophejs-plugins/tree/master/rpc)
93
+ - [punycode](https://github.com/bestiejs/punycode.js/) (optional)
94
+ - [service discovery](https://github.com/metajack/strophejs-plugins/tree/master/disco) (optional)
95
+
96
+ ## Available JOAP server implementations
97
+
98
+ - [node-xmpp-joap](https://github.com/flosse/node-xmpp-joap)
99
+
100
+ ## Tests & specs
101
+
102
+ [buster.js](https://github.com/busterjs/) and
103
+ [buster-coffee](https://github.com/jodal/buster-coffee) and
104
+ are required (`npm install -g buster buster-coffee`) for running the tests.
105
+
106
+ First start a test server
107
+
108
+ ```bash
109
+ buster server
110
+ ```
111
+
112
+ Then navigate with one or more browsers to `localhost:1111` and capture them.
113
+ Afterwards you can run the specs:
114
+
115
+ ```bash
116
+ cake test
117
+ ```
@@ -0,0 +1,23 @@
1
+ var config = module.exports;
2
+
3
+ config["joap"] = {
4
+ environment: "browser",
5
+ specs: ["spec/strophe.joap.spec.coffee"],
6
+ specHelpers: ["spec/browserSetup.coffee"],
7
+ sources: ["strophe.joap.js"],
8
+ libs: [
9
+ "lib/punycode.js",
10
+ "jid.js",
11
+ "lib/jquery.js",
12
+ "lib/strophe.js",
13
+ "lib/strophe.rpc.js" ],
14
+ extensions: [require("buster-coffee")],
15
+ };
16
+
17
+ config["jid"] = {
18
+ environment: "browser",
19
+ specs: ["spec/jid.spec.coffee"],
20
+ sources: ["jid.js"],
21
+ libs: ["lib/punycode.js"],
22
+ extensions: [require("buster-coffee")],
23
+ };
@@ -0,0 +1,64 @@
1
+ ###
2
+ This program is distributed under the terms of the MIT license.
3
+ Copyright 2012 (c) Markus Kohlhase <mail@markus-kohlhase.de>
4
+ ###
5
+
6
+ ###
7
+ This is coffee-script fork of
8
+ https://github.com/astro/node-xmpp/blob/master/lib/xmpp/jid.js
9
+ ###
10
+
11
+ toUnicode = punycode?.toUnicode or (a) -> a
12
+
13
+ class JID
14
+
15
+ constructor: (a, b, c) ->
16
+
17
+ if a and not b? and not c?
18
+ @parseJID a
19
+ else if b?
20
+ @setUser a
21
+ @setDomain b
22
+ @resource = c
23
+ else
24
+ throw new Error 'Argument error'
25
+
26
+ user : null
27
+ resource : null
28
+ domain : null
29
+
30
+ parseJID: (s) ->
31
+ if s.indexOf('@') >= 0
32
+ @setUser(s.substr(0, s.indexOf('@')))
33
+ s = s.substr(s.indexOf('@') + 1)
34
+ if (s.indexOf('/') >= 0)
35
+ @resource = s.substr(s.indexOf('/') + 1)
36
+ s = s.substr(0, s.indexOf('/'))
37
+ @setDomain s
38
+
39
+ toString: ->
40
+ s = @domain
41
+ s = @user + '@' + s if @user
42
+ s += '/' + @resource if @resource
43
+ s
44
+
45
+ # Convenience method to distinguish users
46
+ bare : ->
47
+ if @resource then new JID @user, @domain, null
48
+ else @
49
+
50
+ # Comparison function
51
+ equals: (other) ->
52
+ @user is other.user and
53
+ @domain is other.domain and
54
+ @resource is other.resource
55
+
56
+ # Setters that do stringprep normalization.
57
+ setUser: (user) -> @user = user and user.toLowerCase()
58
+
59
+ # http://xmpp.org/rfcs/rfc6122.html#addressing-domain
60
+ setDomain: (domain) ->
61
+ @domain = domain and
62
+ (domain.split(".").map(toUnicode).join(".")).toLowerCase()
63
+
64
+ window.JID = JID
@@ -0,0 +1,92 @@
1
+ // Generated by CoffeeScript 1.3.3
2
+
3
+ /*
4
+ This program is distributed under the terms of the MIT license.
5
+ Copyright 2012 (c) Markus Kohlhase <mail@markus-kohlhase.de>
6
+ */
7
+
8
+
9
+ /*
10
+ This is coffee-script fork of
11
+ https://github.com/astro/node-xmpp/blob/master/lib/xmpp/jid.js
12
+ */
13
+
14
+
15
+ (function() {
16
+ var JID, toUnicode;
17
+
18
+ toUnicode = (typeof punycode !== "undefined" && punycode !== null ? punycode.toUnicode : void 0) || function(a) {
19
+ return a;
20
+ };
21
+
22
+ JID = (function() {
23
+
24
+ function JID(a, b, c) {
25
+ if (a && !(b != null) && !(c != null)) {
26
+ this.parseJID(a);
27
+ } else if (b != null) {
28
+ this.setUser(a);
29
+ this.setDomain(b);
30
+ this.resource = c;
31
+ } else {
32
+ throw new Error('Argument error');
33
+ }
34
+ }
35
+
36
+ JID.prototype.user = null;
37
+
38
+ JID.prototype.resource = null;
39
+
40
+ JID.prototype.domain = null;
41
+
42
+ JID.prototype.parseJID = function(s) {
43
+ if (s.indexOf('@') >= 0) {
44
+ this.setUser(s.substr(0, s.indexOf('@')));
45
+ s = s.substr(s.indexOf('@') + 1);
46
+ }
47
+ if (s.indexOf('/') >= 0) {
48
+ this.resource = s.substr(s.indexOf('/') + 1);
49
+ s = s.substr(0, s.indexOf('/'));
50
+ }
51
+ return this.setDomain(s);
52
+ };
53
+
54
+ JID.prototype.toString = function() {
55
+ var s;
56
+ s = this.domain;
57
+ if (this.user) {
58
+ s = this.user + '@' + s;
59
+ }
60
+ if (this.resource) {
61
+ s += '/' + this.resource;
62
+ }
63
+ return s;
64
+ };
65
+
66
+ JID.prototype.bare = function() {
67
+ if (this.resource) {
68
+ return new JID(this.user, this.domain, null);
69
+ } else {
70
+ return this;
71
+ }
72
+ };
73
+
74
+ JID.prototype.equals = function(other) {
75
+ return this.user === other.user && this.domain === other.domain && this.resource === other.resource;
76
+ };
77
+
78
+ JID.prototype.setUser = function(user) {
79
+ return this.user = user && user.toLowerCase();
80
+ };
81
+
82
+ JID.prototype.setDomain = function(domain) {
83
+ return this.domain = domain && (domain.split(".").map(toUnicode).join(".")).toLowerCase();
84
+ };
85
+
86
+ return JID;
87
+
88
+ })();
89
+
90
+ window.JID = JID;
91
+
92
+ }).call(this);