comparison src/memory/disco.py @ 1414:159d16336f87

core, bridge, jp: management of service discovery extensions (XEP-0128)
author Goffi <goffi@goffi.org>
date Fri, 17 Apr 2015 22:59:35 +0200
parents 3265a2639182
children a419da93afef
comparison
equal deleted inserted replaced
1413:e5393b12dd0f 1414:159d16336f87
252 @param entity_jid_s: entity we want to discover 252 @param entity_jid_s: entity we want to discover
253 253
254 @return: list of tu""" 254 @return: list of tu"""
255 entity = jid.JID(entity_jid_s) 255 entity = jid.JID(entity_jid_s)
256 disco_infos = yield self.getInfos(entity, profile_key) 256 disco_infos = yield self.getInfos(entity, profile_key)
257 defer.returnValue((disco_infos.features, [(cat, type_, name or '') for (cat, type_), name in disco_infos.identities.items()])) 257 extensions = {}
258 for form_type, form in disco_infos.extensions.items():
259 fields = []
260 for field in form.fieldList:
261 data = {'type': field.fieldType}
262 for attr in ('var', 'label', 'desc'):
263 value = getattr(field, attr)
264 if value is not None:
265 data[attr] = value
266
267 values = [field.value] if field.value is not None else field.values
268 fields.append((data, values))
269
270 extensions[form_type or ""] = fields
271
272 defer.returnValue((disco_infos.features,
273 [(cat, type_, name or '') for (cat, type_), name in disco_infos.identities.items()],
274 extensions))
258 275
259 @defer.inlineCallbacks 276 @defer.inlineCallbacks
260 def _discoItems(self, entity_jid_s, profile_key=C.PROF_KEY_NONE): 277 def _discoItems(self, entity_jid_s, profile_key=C.PROF_KEY_NONE):
261 """ Discovery method for the bridge 278 """ Discovery method for the bridge
262 @param entity_jid_s: entity we want to discover 279 @param entity_jid_s: entity we want to discover