annotate plugins/feature-not-implemented.js @ 39:5e32481b8a92

Better WebSocket feature discovering and Opera support
author Sonny Piers <sonny.piers@gmail.com>
date Tue, 31 Jan 2012 04:12:34 +0100
parents b43ca01b9f6f
children ea276b47c555
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 'use strict';
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 /**
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 Copyright (c) 2012, Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 Permission to use, copy, modify, and/or distribute this software for any
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 purpose with or without fee is hereby granted, provided that the above
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 copyright notice and this permission notice appear in all copies.
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 */
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 Lightstring.NS.xmpp_stanzas = 'urn:ietf:params:xml:ns:xmpp-stanzas';
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 function register_feature_not_implemented() {
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 var conn = this;
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 conn.on('iq', function callback(stanza) {
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 var type = stanza.DOM.getAttributeNS(null, 'type');
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 if (type !== 'get' && type !== 'set')
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 return;
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 var handlers = conn.handlers;
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 var events = [handlers['iq']];
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 var payload = stanza.DOM.firstChild;
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 if (payload)
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 events.push('iq/' + payload.namespaceURI + ':' + payload.localName);
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 var only = events.every(function(handler) {
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 for (var i in handler)
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 if (callback !== handler[i])
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 return false;
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 return true;
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 });
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 if (only)
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 conn.send("<iq to='" + stanza.DOM.getAttributeNS(null, 'from') + "'" +
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 " id='" + stanza.DOM.getAttributeNS(null, 'id') + "'" +
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 " type='error'>" +
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 "<error type='cancel'>" +
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 "<feature-not-implemented xmlns='" + Lightstring.NS.xmpp_stanzas + "'/>" +
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 "</error>" +
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 "</iq>");
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 });
b43ca01b9f6f Add a plugin that respond an error to each get/set iq not handled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 };