diff options
author | Lance Stout <lancestout@gmail.com> | 2012-03-16 23:12:38 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-03-16 23:12:38 -0700 |
commit | eafd2aee93c56da98f7385f6589a0dcdb6aaa1c4 (patch) | |
tree | 80d13efa8e756158d51f0262b583e11ae1e58791 /sleekxmpp/plugins/xep_0060/pubsub.py | |
parent | a6f3d740a29832692c082f59e5c2d63d7430d58b (diff) | |
download | slixmpp-eafd2aee93c56da98f7385f6589a0dcdb6aaa1c4.tar.gz slixmpp-eafd2aee93c56da98f7385f6589a0dcdb6aaa1c4.tar.bz2 slixmpp-eafd2aee93c56da98f7385f6589a0dcdb6aaa1c4.tar.xz slixmpp-eafd2aee93c56da98f7385f6589a0dcdb6aaa1c4.zip |
Add events for configuration and subscription notifications.
New events:
pubsub_config
pubsub_subscription
Diffstat (limited to 'sleekxmpp/plugins/xep_0060/pubsub.py')
-rw-r--r-- | sleekxmpp/plugins/xep_0060/pubsub.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/xep_0060/pubsub.py b/sleekxmpp/plugins/xep_0060/pubsub.py index 6239b5d9..31e59be9 100644 --- a/sleekxmpp/plugins/xep_0060/pubsub.py +++ b/sleekxmpp/plugins/xep_0060/pubsub.py @@ -44,6 +44,14 @@ class XEP_0060(BasePlugin): Callback('Pubsub Event: Delete', StanzaPath('message/pubsub_event/delete'), self._handle_event_delete)) + self.xmpp.register_handler( + Callback('Pubsub Event: Configuration', + StanzaPath('message/pubsub_event/configuration'), + self._handle_event_configuration)) + self.xmpp.register_handler( + Callback('Pubsub Event: Subscription', + StanzaPath('message/pubsub_event/subscription'), + self._handle_event_subscription)) def _handle_event_items(self, msg): """Raise events for publish and retraction notifications.""" @@ -93,6 +101,24 @@ class XEP_0060(BasePlugin): if event_name: self.xmpp.event('%s_delete' % event_name, msg) + def _handle_event_configuration(self, msg): + """Raise events for node configuration notifications.""" + node = msg['pubsub_event']['configuration']['node'] + event_name = self.node_event_map.get(node, None) + + self.xmpp.event('pubsub_config', msg) + if event_name: + self.xmpp.event('%s_config' % event_name, msg) + + def _handle_event_subscription(self, msg): + """Raise events for node subscription notifications.""" + node = msg['pubsub_event']['subscription']['node'] + event_name = self.node_event_map.get(node, None) + + self.xmpp.event('pubsub_subscription', msg) + if event_name: + self.xmpp.event('%s_subscription' % event_name, msg) + def map_node_event(self, node, event_name): """ Map node names to events. |