# HG changeset patch # User Emmanuel Gil Peyrot # Date 1328146098 -3600 # Node ID 5dbf93cef55d0c4c501a6aa3a4ceaeb833394d39 # Parent f12c759e4097aa75f9994bed54f07819b229b64c Various fixes. diff --git a/lightstring.js b/lightstring.js --- a/lightstring.js +++ b/lightstring.js @@ -24,7 +24,8 @@ var Lightstring = { */ ns: { streams: 'http://etherx.jabber.org/streams', - jabber_client: 'jabber:client' + jabber_client: 'jabber:client', + xmpp_stanzas: 'urn:ietf:params:xml:ns:xmpp-stanzas' }, /** * @namespace Holds XMPP stanza builders. @@ -150,10 +151,10 @@ Lightstring.Connection.prototype = { if (!this.service) return; //TODO: error - if(typeof(WebSocket) === "function") { + if (typeof(WebSocket) === "function") { this.socket = new WebSocket(this.service, 'xmpp'); } - else if(typeof(MozWebSocket) === "function") { + else if (typeof(MozWebSocket) === "function") { this.socket = new MozWebSocket(this.service, 'xmpp'); } else { @@ -186,7 +187,7 @@ Lightstring.Connection.prototype = { //FIXME: node-xmpp-bosh sends a self-closing stream:stream tag; it is wrong! Conn.emit('input', stanza); - if(!stanza.DOM) + if (!stanza.DOM) return; var name = stanza.DOM.localName; @@ -240,6 +241,10 @@ Lightstring.Connection.prototype = { delete Conn.callbacks[id]; } + + else if (name === 'presence' || name === 'message') { + Conn.emit(name, stanza); + } }); }, /** @@ -253,7 +258,7 @@ Lightstring.Connection.prototype = { else var stanza = aStanza; - if(!stanza) + if (!stanza) return; if (stanza.DOM.tagName === 'iq') { @@ -313,7 +318,7 @@ Lightstring.Connection.prototype = { //Methods this[name] = {}; for (var method in plugin.methods) - this[name][method].bind(this); + this[name][method] = plugin.methods[method].bind(this); if (plugin.init) plugin.init(); @@ -347,6 +352,10 @@ Lightstring.Connection.prototype = { } if (aData && aData.DOM) { + var type = aData.DOM.getAttributeNS(null, 'type'); + if (type !== 'get' && type !== 'set') + return; + var from = aData.DOM.getAttributeNS(null, 'from'); var id = aData.DOM.getAttributeNS(null, 'id'); this.send(Lightstring.stanzas.errors.iq(from, id, 'cancel', 'service-unavailable')); diff --git a/plugins/dataforms.js b/plugins/dataforms.js --- a/plugins/dataforms.js +++ b/plugins/dataforms.js @@ -91,7 +91,7 @@ return fields; }; - Lightstring.plugins['disco'] = { + Lightstring.plugins['dataforms'] = { namespaces: { dataforms: 'jabber:x:data' }, diff --git a/plugins/disco.js b/plugins/disco.js --- a/plugins/disco.js +++ b/plugins/disco.js @@ -83,7 +83,7 @@ }, aError); }, info: function(aTo, aNode, aResult, aError) { - this.send(Lightstring.stanzas.disco.info(aTo, aNode), function(stanza){ + this.send(Lightstring.stanzas.disco.info(aTo, aNode), function(stanza) { var identities = []; var features = []; var fields = {}; @@ -125,8 +125,9 @@ aResult(stanza); }, aError); }, - addFeature: function(feature) { - features.push(feature); + addFeatures: function() { + for (var i = 0; i < arguments.length; i++) + features.push(arguments[i]); } }, init: function() { @@ -167,6 +168,7 @@ ""; conn.send(res); + return true; }); } };