201 self:send_iq(disco_request, function (result) |
201 self:send_iq(disco_request, function (result) |
202 if result.attr.type == "error" then |
202 if result.attr.type == "error" then |
203 return callback(nil, result:get_error()); |
203 return callback(nil, result:get_error()); |
204 end |
204 end |
205 |
205 |
206 local identities, features = {}, {}; |
206 local identities, features, extended = {}, {}, {}; |
207 |
207 |
208 for tag in result:get_child("query", xmlns_disco_info):childtags() do |
208 for tag in result:get_child("query", xmlns_disco_info):childtags() do |
209 if tag.name == "identity" then |
209 if tag.name == "identity" then |
210 identities[tag.attr.category.."/"..tag.attr.type] = tag.attr.name or true; |
210 identities[tag.attr.category.."/"..tag.attr.type] = tag.attr.name or true; |
211 elseif tag.name == "feature" then |
211 elseif tag.name == "feature" then |
212 features[tag.attr.var] = true; |
212 features[tag.attr.var] = true; |
213 end |
213 end |
214 end |
214 end |
215 |
215 |
|
216 for tag in result:get_child("query", xmlns_disco_info):childtags("x", "jabber:x:data") do |
|
217 local form_type_field = tag:get_child_with_attr("field", nil, "var", "FORM_TYPE"); |
|
218 local form_type = form_type_field and form_type_field:get_child_text("value"); |
|
219 if form_type then |
|
220 extended[form_type] = tag; |
|
221 end |
|
222 end |
216 |
223 |
217 if not self.disco.cache[jid] then |
224 if not self.disco.cache[jid] then |
218 self.disco.cache[jid] = { nodes = {} }; |
225 self.disco.cache[jid] = { nodes = {} }; |
219 end |
226 end |
220 |
227 |
222 if not self.disco.cache[jid].nodes[node] then |
229 if not self.disco.cache[jid].nodes[node] then |
223 self.disco.cache[jid].nodes[node] = { nodes = {} }; |
230 self.disco.cache[jid].nodes[node] = { nodes = {} }; |
224 end |
231 end |
225 self.disco.cache[jid].nodes[node].identities = identities; |
232 self.disco.cache[jid].nodes[node].identities = identities; |
226 self.disco.cache[jid].nodes[node].features = features; |
233 self.disco.cache[jid].nodes[node].features = features; |
|
234 self.disco.cache[jid].nodes[node].extended = extended; |
227 else |
235 else |
228 self.disco.cache[jid].identities = identities; |
236 self.disco.cache[jid].identities = identities; |
229 self.disco.cache[jid].features = features; |
237 self.disco.cache[jid].features = features; |
|
238 self.disco.cache[jid].extended = extended; |
230 end |
239 end |
231 return callback(self.disco.cache[jid]); |
240 return callback(self.disco.cache[jid]); |
232 end); |
241 end); |
233 end |
242 end |
234 |
243 |