comparison plugins.js @ 26:82bffc4a07a9

Fix disco info.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 27 Jan 2012 04:58:44 +0100
parents 7fcccf59e6ec
children b6e4bc19ff5a
comparison
equal deleted inserted replaced
25:06e3a883d3a3 26:82bffc4a07a9
152 aCallback(items); 152 aCallback(items);
153 }); 153 });
154 }; 154 };
155 Lightstring.discoInfo = function(aConnection, aTo, aNode, aCallback) { 155 Lightstring.discoInfo = function(aConnection, aTo, aNode, aCallback) {
156 aConnection.send(Lightstring.stanza.disco.info(aTo, aNode), function(answer){ 156 aConnection.send(Lightstring.stanza.disco.info(aTo, aNode), function(answer){
157 var field = answer.querySelector('field[var="pubsub#creator"] > value'); 157 var identities = [];
158 var creator = field ? field.textContent : ''; 158 var features = [];
159 //FIXME callback the entire data 159
160 aCallback(creator); 160 var children = answer.firstChild.children;
161 var length = children.length;
162
163 for (var i = 0; i < length; i++) {
164 var child = children[i];
165
166 if (child.localName === 'feature')
167 features.push(child.getAttributeNS(null, 'var'));
168
169 else if (child.localName === 'identity') {
170 var identity = {
171 category: child.getAttributeNS(null, 'category'),
172 type: child.getAttributeNS(null, 'type')
173 };
174 var name = child.getAttributeNS(null, 'name');
175 if (name)
176 identity.name = name;
177 identities.push(identity);
178 }
179 }
180
181 aCallback({identities: identities, features: features});
161 }); 182 });
162 }; 183 };
163 ////////// 184 //////////
164 //PubSub// 185 //PubSub//
165 ////////// 186 //////////