From d817d64c65c62976481690c0bfc3882621ac0455 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Fri, 30 Dec 2011 22:34:57 -0500 Subject: Enable caps stream feature. --- sleekxmpp/plugins/xep_0115/caps.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/plugins/xep_0115') diff --git a/sleekxmpp/plugins/xep_0115/caps.py b/sleekxmpp/plugins/xep_0115/caps.py index 19570d18..306629f6 100644 --- a/sleekxmpp/plugins/xep_0115/caps.py +++ b/sleekxmpp/plugins/xep_0115/caps.py @@ -11,7 +11,7 @@ import hashlib import base64 import sleekxmpp -from sleekxmpp import Presence, Iq +from sleekxmpp.stanza import StreamFeatures, Presence, Iq from sleekxmpp.xmlstream import register_stanza_plugin from sleekxmpp.xmlstream.handler import Callback from sleekxmpp.xmlstream.matcher import StanzaPath @@ -46,6 +46,7 @@ class xep_0115(base_plugin): self.caps_node = 'http://sleekxmpp.com/ver/%s' % ver register_stanza_plugin(Presence, stanza.Capabilities) + register_stanza_plugin(StreamFeatures, stanza.Capabilities) self._disco_ops = ['cache_caps', 'get_caps', @@ -64,6 +65,11 @@ class xep_0115(base_plugin): self.xmpp.add_event_handler('entity_caps', self._process_caps, threaded=True) + self.xmpp.register_feature('caps', + self._handle_caps_feature, + restart=False, + order=10010) + def post_init(self): base_plugin.post_init(self) self.xmpp['xep_0030'].add_feature(stanza.Capabilities.namespace) @@ -96,6 +102,16 @@ class xep_0115(base_plugin): return self.xmpp.event('entity_caps', presence) + def _handle_caps_feature(self, features): + # We already have a method to process presence with + # caps, so wrap things up and use that. + p = Presence() + p['from'] = self.xmpp.boundjid.domain + p.append(features['caps']) + self.xmpp.features.add('caps') + + self.xmpp.event('entity_caps', p) + def _process_caps(self, pres): if not pres['caps']['hash']: log.debug("Received unsupported legacy caps.") -- cgit v1.2.3