# HG changeset patch # User Sonny Piers # Date 1327963615 -3600 # Node ID 6773e5bc2ca04b0a74bbc2b0a06b17c4c1195478 # Parent b43ca01b9f6f564783d90625170d3e85eda6e06d several fixes diff --git a/lightstring.js b/lightstring.js --- a/lightstring.js +++ b/lightstring.js @@ -328,9 +328,8 @@ Lightstring.Connection.prototype = { if (stanza.DOM.tagName === 'iq') { var id = stanza.DOM.getAttribute('id'); //TODO: This should be done by a plugin - if (!id) { + if (!id) stanza.DOM.setAttribute('id', Lightstring.newId('sendiq:')); - } if (aCallback) this.on(stanza.DOM.getAttribute('id'), aCallback); } @@ -340,7 +339,9 @@ Lightstring.Connection.prototype = { //TODO this.socket.send(stanza.XML); (need some work on Lightstring.Stanza) - this.socket.send(Lightstring.DOM2XML(stanza.DOM)); + var fixme = Lightstring.DOM2XML(stanza.DOM); + stanza.XML = fixme; + this.socket.send(fixme); this.emit('output', stanza); }, /** diff --git a/plugins/disco.js b/plugins/disco.js --- a/plugins/disco.js +++ b/plugins/disco.js @@ -69,28 +69,55 @@ Lightstring.discoInfo = function(aConnec aConnection.send(Lightstring.stanza.disco.info(aTo, aNode), function(stanza){ var identities = []; var features = []; + var fields = {}; - var children = stanza.DOM.firstChild.children; + var children = stanza.DOM.firstChild.childNodes; var length = children.length; for (var i = 0; i < length; i++) { - var child = children[i]; - if (child.localName === 'feature') - features.push(child.getAttributeNS(null, 'var')); + if (children[i].localName === 'feature') + features.push(children[i].getAttributeNS(null, 'var')); - else if (child.localName === 'identity') { + else if (children[i].localName === 'identity') { var identity = { - category: child.getAttributeNS(null, 'category'), - type: child.getAttributeNS(null, 'type') + category: children[i].getAttributeNS(null, 'category'), + type: children[i].getAttributeNS(null, 'type') }; - var name = child.getAttributeNS(null, 'name'); + var name = children[i].getAttributeNS(null, 'name'); if (name) identity.name = name; identities.push(identity); } + + else if (children[i].localName === 'x') { + for (var j = 0; j < children[i].childNodes.length; j++) { + var child = children[i].childNodes[j]; + var field = { + type: child.getAttribute('type') + }; + + var _var = child.getAttribute('var'); + + var label = child.getAttribute('label'); + if(label) field.label = label; + + + for (var y = 0; y < child.childNodes.length; y++) { + if(child.childNodes[y].localName === 'desc') + field.desc = child.childNodes[y].textContent; + else if(child.childNodes[y].localName === 'required') + field.required = true; + else if(child.childNodes[y].localName === 'value') + field.value = child.childNodes[y].textContent; + } + + + fields[_var] = field; + } + } } - aCallback({identities: identities, features: features}); + aCallback({'identities': identities, 'features': features, 'fields': fields}, stanza); }); };