Mercurial > libervia-backend
comparison src/memory/disco.py @ 2150:91347fe95384
core(memory.disco), bridge: discoInfos and discoItems now handle node
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 12 Feb 2017 21:17:56 +0100 |
parents | a543eda2c923 |
children | f047d5410040 |
comparison
equal
deleted
inserted
replaced
2149:a0e6f7951bd7 | 2150:91347fe95384 |
---|---|
306 cap_hash = b64encode(sha1(''.join(s)).digest()) | 306 cap_hash = b64encode(sha1(''.join(s)).digest()) |
307 log.debug(_(u'Capability hash generated: [%s]') % cap_hash) | 307 log.debug(_(u'Capability hash generated: [%s]') % cap_hash) |
308 return cap_hash | 308 return cap_hash |
309 | 309 |
310 @defer.inlineCallbacks | 310 @defer.inlineCallbacks |
311 def _discoInfos(self, entity_jid_s, profile_key=C.PROF_KEY_NONE): | 311 def _discoInfos(self, entity_jid_s, node=u'', profile_key=C.PROF_KEY_NONE): |
312 """ Discovery method for the bridge | 312 """ Discovery method for the bridge |
313 @param entity_jid_s: entity we want to discover | 313 @param entity_jid_s: entity we want to discover |
314 @param node(unicode): optional node to use | |
314 | 315 |
315 @return: list of tuples | 316 @return: list of tuples |
316 """ | 317 """ |
317 client = self.host.getClient(profile_key) | 318 client = self.host.getClient(profile_key) |
318 entity = jid.JID(entity_jid_s) | 319 entity = jid.JID(entity_jid_s) |
319 disco_infos = yield self.getInfos(client, entity) | 320 disco_infos = yield self.getInfos(client, entity, node) |
320 extensions = {} | 321 extensions = {} |
321 for form_type, form in disco_infos.extensions.items(): | 322 for form_type, form in disco_infos.extensions.items(): |
322 fields = [] | 323 fields = [] |
323 for field in form.fieldList: | 324 for field in form.fieldList: |
324 data = {'type': field.fieldType} | 325 data = {'type': field.fieldType} |
347 log.warning(_(u"invalid item (no jid)")) | 348 log.warning(_(u"invalid item (no jid)")) |
348 continue | 349 continue |
349 yield (item.entity.full(), item.nodeIdentifier or '', item.name or '') | 350 yield (item.entity.full(), item.nodeIdentifier or '', item.name or '') |
350 | 351 |
351 @defer.inlineCallbacks | 352 @defer.inlineCallbacks |
352 def _discoItems(self, entity_jid_s, profile_key=C.PROF_KEY_NONE): | 353 def _discoItems(self, entity_jid_s, node=u'', profile_key=C.PROF_KEY_NONE): |
353 """ Discovery method for the bridge | 354 """ Discovery method for the bridge |
354 | 355 |
355 @param entity_jid_s: entity we want to discover | 356 @param entity_jid_s: entity we want to discover |
357 @param node(unicode): optional node to use | |
356 @return: list of tuples""" | 358 @return: list of tuples""" |
357 client = self.host.getClient(profile_key) | 359 client = self.host.getClient(profile_key) |
358 entity = jid.JID(entity_jid_s) | 360 entity = jid.JID(entity_jid_s) |
359 disco_items = yield self.getItems(client, entity) | 361 disco_items = yield self.getItems(client, entity, node) |
360 ret = list(self.items2tuples(disco_items)) | 362 ret = list(self.items2tuples(disco_items)) |
361 defer.returnValue(ret) | 363 defer.returnValue(ret) |