Fix errors in caps related to unwrapped disco data and full JIDs.

This commit is contained in:
Lance Stout 2012-04-08 16:00:36 -04:00
parent f9d0ee824b
commit 8a8926c5e8

View file

@ -36,6 +36,7 @@ class XEP_0115(BasePlugin):
def plugin_init(self):
self.hashes = {'sha-1': hashlib.sha1,
'sha1': hashlib.sha1,
'md5': hashlib.md5}
self.hash = self.config.get('hash', 'sha-1')
@ -77,6 +78,8 @@ class XEP_0115(BasePlugin):
disco = self.xmpp['xep_0030']
self.static = StaticCaps(self.xmpp, disco.static)
self.api.settings['client_bare'] = False
self.api.settings['component_bare'] = False
for op in self._disco_ops:
self.api.register(getattr(self.static, op), op, default=True)
@ -125,21 +128,21 @@ class XEP_0115(BasePlugin):
if pres['caps']['hash'] not in self.hashes:
try:
log.debug("Unknown caps hash: %s", pres['caps']['hash'])
self.xmpp['xep_003'].get_info(jid=pres['from'].full)
self.xmpp['xep_0030'].get_info(jid=pres['from'])
return
except XMPPError:
return
log.debug("New caps verification string: %s", pres['caps']['ver'])
try:
caps = self.xmpp['xep_0030'].get_info(
jid=pres['from'].full,
node='%s#%s' % (pres['caps']['node'],
pres['caps']['ver']))
node = '%s#%s' % (pres['caps']['node'], pres['caps']['ver'])
caps = self.xmpp['xep_0030'].get_info(pres['from'], node)
if isinstance(caps, Iq):
caps = caps['disco_info']
if self._validate_caps(caps['disco_info'],
pres['caps']['hash'],
pres['caps']['ver']):
if self._validate_caps(caps, pres['caps']['hash'],
pres['caps']['ver']):
self.assign_verstring(pres['from'], pres['caps']['ver'])
except XMPPError:
log.debug("Could not retrieve disco#info results for caps")