diff options
author | Lance Stout <lancestout@gmail.com> | 2011-12-30 22:34:57 -0500 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-12-30 22:34:57 -0500 |
commit | d817d64c65c62976481690c0bfc3882621ac0455 (patch) | |
tree | 10b0b13a393b7f7ce7b25e5e6edd810f0fe865df | |
parent | 8a29ec67ac91528747c2a954cc8f89b5bbe71e58 (diff) | |
download | slixmpp-d817d64c65c62976481690c0bfc3882621ac0455.tar.gz slixmpp-d817d64c65c62976481690c0bfc3882621ac0455.tar.bz2 slixmpp-d817d64c65c62976481690c0bfc3882621ac0455.tar.xz slixmpp-d817d64c65c62976481690c0bfc3882621ac0455.zip |
Enable caps stream feature.
-rw-r--r-- | sleekxmpp/plugins/xep_0115/caps.py | 18 |
1 files changed, 17 insertions, 1 deletions
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.") |