Mercurial > libervia-backend
diff src/memory/disco.py @ 963:723f28cd15c7
core (disco): added discoInfos and discoItems bridge methods
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 01 Apr 2014 21:14:57 +0200 |
parents | 0e8c2414f89c |
children | 4a8903021fda |
line wrap: on
line diff
--- a/src/memory/disco.py Mon Mar 31 20:19:34 2014 +0200 +++ b/src/memory/disco.py Tue Apr 01 21:14:57 2014 +0200 @@ -114,7 +114,7 @@ @param jid_: jid of the target, or None for profile's server @param profile_key: %(doc_profile_key)s - @return: a Deferred which fire disco.DiscoInfo + @return: a Deferred which fire disco.DiscoItems """ client = self.host.getClient(profile_key) if jid_ is None: @@ -212,3 +212,23 @@ cap_hash = b64encode(sha1(''.join(s)).digest()) debug(_('Capability hash generated: [%s]') % cap_hash) return cap_hash + + @defer.inlineCallbacks + def _discoInfos(self, entity_jid_s, profile_key=C.PROF_KEY_NONE): + """ Discovery method for the bridge + @param entity_jid_s: entity we want to discover + + @return: list of tu""" + entity = jid.JID(entity_jid_s) + disco_infos = yield self.getInfos(entity, profile_key) + defer.returnValue((disco_infos.features, [(cat, type_, name or '') for (cat, type_), name in disco_infos.identities.items()])) + + @defer.inlineCallbacks + def _discoItems(self, entity_jid_s, profile_key=C.PROF_KEY_NONE): + """ Discovery method for the bridge + @param entity_jid_s: entity we want to discover + + @return: list of tu""" + entity = jid.JID(entity_jid_s) + disco_items = yield self.getItems(entity, profile_key) + defer.returnValue([(item.entity.full(), item.nodeIdentifier or '', item.name or '') for item in disco_items])