Mercurial > eldonilo > lightstring
changeset 26:82bffc4a07a9
Fix disco info.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 27 Jan 2012 04:58:44 +0100 |
parents | 06e3a883d3a3 |
children | b6e4bc19ff5a |
files | plugins.js |
diffstat | 1 files changed, 25 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins.js +++ b/plugins.js @@ -154,10 +154,31 @@ Lightstring.discoItems = function(aConne }; Lightstring.discoInfo = function(aConnection, aTo, aNode, aCallback) { aConnection.send(Lightstring.stanza.disco.info(aTo, aNode), function(answer){ - var field = answer.querySelector('field[var="pubsub#creator"] > value'); - var creator = field ? field.textContent : ''; - //FIXME callback the entire data - aCallback(creator); + var identities = []; + var features = []; + + var children = answer.firstChild.children; + 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')); + + else if (child.localName === 'identity') { + var identity = { + category: child.getAttributeNS(null, 'category'), + type: child.getAttributeNS(null, 'type') + }; + var name = child.getAttributeNS(null, 'name'); + if (name) + identity.name = name; + identities.push(identity); + } + } + + aCallback({identities: identities, features: features}); }); }; //////////