comparison sat/core/sat_main.py @ 2595:973d4551ffae

core: added local_device argument to discoFindByFeatures
author Goffi <goffi@goffi.org>
date Fri, 25 May 2018 10:52:01 +0200
parents 26edcf3a30eb
children 9446f1ea9eac
comparison
equal deleted inserted replaced
2594:59ba387c17ea 2595:973d4551ffae
669 return self.memory.disco.findServiceEntities(*args, **kwargs) 669 return self.memory.disco.findServiceEntities(*args, **kwargs)
670 670
671 def findFeaturesSet(self, *args, **kwargs): 671 def findFeaturesSet(self, *args, **kwargs):
672 return self.memory.disco.findFeaturesSet(*args, **kwargs) 672 return self.memory.disco.findFeaturesSet(*args, **kwargs)
673 673
674 def _findByFeatures(self, namespaces, identities, bare_jids, service, roster, own_jid, profile_key): 674 def _findByFeatures(self, namespaces, identities, bare_jids, service, roster, own_jid, local_device, profile_key):
675 client = self.getClient(profile_key) 675 client = self.getClient(profile_key)
676 return self.findByFeatures(client, namespaces, identities, bare_jids, service, roster, own_jid) 676 return self.findByFeatures(client, namespaces, identities, bare_jids, service, roster, own_jid, local_device)
677 677
678 @defer.inlineCallbacks 678 @defer.inlineCallbacks
679 def findByFeatures(self, client, namespaces, identities=None, bare_jids=False, service=True, roster=True, own_jid=True): 679 def findByFeatures(self, client, namespaces, identities=None, bare_jids=False, service=True, roster=True, own_jid=True, local_device=False):
680 """retrieve all services or contacts managing a set a features 680 """retrieve all services or contacts managing a set a features
681 681
682 @param namespaces(list[unicode]): features which must be handled 682 @param namespaces(list[unicode]): features which must be handled
683 @param identities(list[tuple[unicode,unicode]], None): if not None or empty, only keep those identities 683 @param identities(list[tuple[unicode,unicode]], None): if not None or empty, only keep those identities
684 tuple must by (category, type) 684 tuple must by (category, type)
686 if False, retrieve full jid of connected devices 686 if False, retrieve full jid of connected devices
687 @param service(bool): if True return service from our roster 687 @param service(bool): if True return service from our roster
688 @param roster(bool): if True, return entities in roster 688 @param roster(bool): if True, return entities in roster
689 full jid of all matching resources available will be returned 689 full jid of all matching resources available will be returned
690 @param own_jid(bool): if True, return profile's jid resources 690 @param own_jid(bool): if True, return profile's jid resources
691 @param local_device(bool): if True, return profile's jid local resource (i.e. client.jid)
691 @return (tuple(dict[jid.JID(), tuple[unicode, unicode, unicode]]*3)): found entities in a tuple with: 692 @return (tuple(dict[jid.JID(), tuple[unicode, unicode, unicode]]*3)): found entities in a tuple with:
692 - service entities 693 - service entities
693 - own entities 694 - own entities
694 - roster entities 695 - roster entities
695 """ 696 """
730 resources = self.memory.getAllResources(client, jid_) 731 resources = self.memory.getAllResources(client, jid_)
731 except exceptions.UnknownEntityError: 732 except exceptions.UnknownEntityError:
732 continue 733 continue
733 for resource in resources: 734 for resource in resources:
734 full_jid = jid.JID(tuple=(jid_.user, jid_.host, resource)) 735 full_jid = jid.JID(tuple=(jid_.user, jid_.host, resource))
736 if full_jid == client.jid and not local_device:
737 continue
735 infos = yield self.getDiscoInfos(client, full_jid) 738 infos = yield self.getDiscoInfos(client, full_jid)
736 if infos.features.issuperset(namespaces): 739 if infos.features.issuperset(namespaces):
737 if identities is not None and not set(infos.identities.keys()).issuperset(identities): 740 if identities is not None and not set(infos.identities.keys()).issuperset(identities):
738 continue 741 continue
739 found_identities = [(cat, type_, name or u'') for (cat, type_), name in infos.identities.iteritems()] 742 found_identities = [(cat, type_, name or u'') for (cat, type_), name in infos.identities.iteritems()]