ability to browse server that returns an identity category=pubsub, type=service. fixes #4089

This commit is contained in:
Yann Leboulanger 2008-07-11 07:42:57 +00:00
parent b933e6cef0
commit 3fe385d203
1 changed files with 24 additions and 17 deletions

View File

@ -280,28 +280,35 @@ class ServicesCache:
def get_browser(self, identities=[], features=[]):
'''Return the browser class for an agent.'''
# Grab the first identity with a browser
browser = None
# First pass, we try to find a ToplevelAgentBrowser
for identity in identities:
try:
cat, type = identity['category'], identity['type']
info = _agent_type_info[(cat, type)]
cat, type_ = identity['category'], identity['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:
continue
browser = info[0]
if browser:
break
# Note: possible outcome here is browser=False
if browser is None:
return browser
# NS_BROWSE is deprecated, but we check for it anyways.
# Some services list it in features and respond to
# NS_DISCO_ITEMS anyways.
# Allow browsing for unknown types aswell.
if (not features and not identities) or \
xmpp.NS_DISCO_ITEMS in features or\
xmpp.NS_BROWSE in features:
browser = AgentBrowser
return browser
xmpp.NS_DISCO_ITEMS in features or xmpp.NS_BROWSE in features:
return AgentBrowser
return None
def get_info(self, jid, node, cb, force = False, nofetch = False, args = ()):
'''Get info for an agent.'''