core: fixed findByFeatures:
jids where not correctly put in `found_own` and `found_roster` lists.
This commit is contained in:
parent
b1edf2198c
commit
53cc1f1bac
2 changed files with 38 additions and 37 deletions
|
|
@ -906,13 +906,14 @@ class SAT(service.Service):
|
|||
def _findByFeatures(self, namespaces, identities, bare_jids, service, roster, own_jid,
|
||||
local_device, profile_key):
|
||||
client = self.getClient(profile_key)
|
||||
return self.findByFeatures(client, namespaces, identities, bare_jids, service,
|
||||
roster, own_jid, local_device,)
|
||||
return defer.ensureDeferred(self.findByFeatures(
|
||||
client, namespaces, identities, bare_jids, service, roster, own_jid,
|
||||
local_device))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def findByFeatures(self, client, namespaces, identities=None, bare_jids=False,
|
||||
service=True, roster=True, own_jid=True, local_device=False):
|
||||
"""retrieve all services or contacts managing a set a features
|
||||
async def findByFeatures(
|
||||
self, client, namespaces, identities=None, bare_jids=False, service=True,
|
||||
roster=True, own_jid=True, local_device=False):
|
||||
"""Retrieve all services or contacts managing a set a features
|
||||
|
||||
@param namespaces(list[unicode]): features which must be handled
|
||||
@param identities(list[tuple[unicode,unicode]], None): if not None or empty,
|
||||
|
|
@ -942,9 +943,9 @@ class SAT(service.Service):
|
|||
found_own = {}
|
||||
found_roster = {}
|
||||
if service:
|
||||
services_jids = yield self.findFeaturesSet(client, namespaces)
|
||||
services_jids = await self.findFeaturesSet(client, namespaces)
|
||||
services_jids = list(services_jids) # we need a list to map results below
|
||||
services_infos = yield defer.DeferredList(
|
||||
services_infos = await defer.DeferredList(
|
||||
[self.getDiscoInfos(client, service_jid) for service_jid in services_jids]
|
||||
)
|
||||
|
||||
|
|
@ -970,10 +971,10 @@ class SAT(service.Service):
|
|||
if roster:
|
||||
to_find.append((found_roster, client.roster.getJids()))
|
||||
|
||||
full_jids = []
|
||||
d_list = []
|
||||
|
||||
for found, jids in to_find:
|
||||
full_jids = []
|
||||
disco_defers = []
|
||||
|
||||
for jid_ in jids:
|
||||
if jid_.resource:
|
||||
if bare_jids:
|
||||
|
|
@ -998,34 +999,34 @@ class SAT(service.Service):
|
|||
continue
|
||||
full_jids.append(full_jid)
|
||||
|
||||
d_list.append(self.getDiscoInfos(client, full_jid))
|
||||
disco_defers.append(self.getDiscoInfos(client, full_jid))
|
||||
|
||||
d_list = defer.DeferredList(d_list)
|
||||
# XXX: 10 seconds may be too low for slow connections (e.g. mobiles)
|
||||
# but for discovery, that's also the time the user will wait the first time
|
||||
# before seing the page, if something goes wrong.
|
||||
d_list.addTimeout(10, reactor)
|
||||
infos_data = yield d_list
|
||||
d_list = defer.DeferredList(disco_defers)
|
||||
# XXX: 10 seconds may be too low for slow connections (e.g. mobiles)
|
||||
# but for discovery, that's also the time the user will wait the first time
|
||||
# before seing the page, if something goes wrong.
|
||||
d_list.addTimeout(10, reactor)
|
||||
infos_data = await d_list
|
||||
|
||||
for idx, (success, infos) in enumerate(infos_data):
|
||||
full_jid = full_jids[idx]
|
||||
if not success:
|
||||
log.warning(
|
||||
_("Can't retrieve {full_jid} infos, ignoring")
|
||||
.format(full_jid=full_jid.full()))
|
||||
continue
|
||||
if infos.features.issuperset(namespaces):
|
||||
if identities is not None and not set(
|
||||
infos.identities.keys()
|
||||
).issuperset(identities):
|
||||
for idx, (success, infos) in enumerate(infos_data):
|
||||
full_jid = full_jids[idx]
|
||||
if not success:
|
||||
log.warning(
|
||||
_("Can't retrieve {full_jid} infos, ignoring")
|
||||
.format(full_jid=full_jid.full()))
|
||||
continue
|
||||
found_identities = [
|
||||
(cat, type_, name or "")
|
||||
for (cat, type_), name in infos.identities.items()
|
||||
]
|
||||
found[full_jid.full()] = found_identities
|
||||
if infos.features.issuperset(namespaces):
|
||||
if identities is not None and not set(
|
||||
infos.identities.keys()
|
||||
).issuperset(identities):
|
||||
continue
|
||||
found_identities = [
|
||||
(cat, type_, name or "")
|
||||
for (cat, type_), name in infos.identities.items()
|
||||
]
|
||||
found[full_jid.full()] = found_identities
|
||||
|
||||
defer.returnValue((found_service, found_own, found_roster))
|
||||
return (found_service, found_own, found_roster)
|
||||
|
||||
## Generic HMI ##
|
||||
|
||||
|
|
|
|||
|
|
@ -329,9 +329,9 @@ class AdHocDBus(object):
|
|||
- device name
|
||||
- device label
|
||||
"""
|
||||
found_data = yield self.host.findByFeatures(
|
||||
found_data = yield defer.ensureDeferred(self.host.findByFeatures(
|
||||
client, [self.host.ns_map['commands']], service=False, roster=False,
|
||||
own_jid=True, local_device=True)
|
||||
own_jid=True, local_device=True))
|
||||
|
||||
remotes = []
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue