ability to browse server that returns an identity category=pubsub, type=service. fixes #4089
This commit is contained in:
parent
b933e6cef0
commit
3fe385d203
33
src/disco.py
33
src/disco.py
|
@ -278,30 +278,37 @@ class ServicesCache:
|
||||||
_icon_cache[filename] = pix
|
_icon_cache[filename] = pix
|
||||||
return pix
|
return pix
|
||||||
|
|
||||||
def get_browser(self, identities = [], features = []):
|
def get_browser(self, identities=[], features=[]):
|
||||||
'''Return the browser class for an agent.'''
|
'''Return the browser class for an agent.'''
|
||||||
# Grab the first identity with a browser
|
# First pass, we try to find a ToplevelAgentBrowser
|
||||||
browser = None
|
|
||||||
for identity in identities:
|
for identity in identities:
|
||||||
try:
|
try:
|
||||||
cat, type = identity['category'], identity['type']
|
cat, type_ = identity['category'], identity['type']
|
||||||
info = _agent_type_info[(cat, type)]
|
info = _agent_type_info[(cat, type_)]
|
||||||
|
except KeyError:
|
||||||
|
continue
|
||||||
|
browser = info[0]
|
||||||
|
if browser and browser == ToplevelAgentBrowser:
|
||||||
|
return browser
|
||||||
|
|
||||||
|
# second pass, we haven't found a ToplevelAgentBrowser
|
||||||
|
for identity in identities:
|
||||||
|
try:
|
||||||
|
cat, type_ = identity['category'], identity['type']
|
||||||
|
info = _agent_type_info[(cat, type_)]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
browser = info[0]
|
browser = info[0]
|
||||||
if browser:
|
if browser:
|
||||||
break
|
return browser
|
||||||
# Note: possible outcome here is browser=False
|
|
||||||
if browser is None:
|
|
||||||
# NS_BROWSE is deprecated, but we check for it anyways.
|
# NS_BROWSE is deprecated, but we check for it anyways.
|
||||||
# Some services list it in features and respond to
|
# Some services list it in features and respond to
|
||||||
# NS_DISCO_ITEMS anyways.
|
# NS_DISCO_ITEMS anyways.
|
||||||
# Allow browsing for unknown types aswell.
|
# Allow browsing for unknown types aswell.
|
||||||
if (not features and not identities) or\
|
if (not features and not identities) or \
|
||||||
xmpp.NS_DISCO_ITEMS in features or\
|
xmpp.NS_DISCO_ITEMS in features or xmpp.NS_BROWSE in features:
|
||||||
xmpp.NS_BROWSE in features:
|
return AgentBrowser
|
||||||
browser = AgentBrowser
|
return None
|
||||||
return browser
|
|
||||||
|
|
||||||
def get_info(self, jid, node, cb, force = False, nofetch = False, args = ()):
|
def get_info(self, jid, node, cb, force = False, nofetch = False, args = ()):
|
||||||
'''Get info for an agent.'''
|
'''Get info for an agent.'''
|
||||||
|
|
Loading…
Reference in New Issue