summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0085
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-03-11 22:56:07 -0700
committerLance Stout <lancestout@gmail.com>2012-03-12 19:32:19 -0700
commit3fda053606c3e36943aab638359c59e33c878635 (patch)
tree1c77133e8085bdc95b1397ae88308ad524b6efd3 /sleekxmpp/plugins/xep_0085
parent6d855ec06cd1fb7cdbef0f11d6d10e39766cc006 (diff)
downloadslixmpp-3fda053606c3e36943aab638359c59e33c878635.tar.gz
slixmpp-3fda053606c3e36943aab638359c59e33c878635.tar.bz2
slixmpp-3fda053606c3e36943aab638359c59e33c878635.tar.xz
slixmpp-3fda053606c3e36943aab638359c59e33c878635.zip
Move XEP-0085 to the new system.
Optimized handlers so that only one is needed.
Diffstat (limited to 'sleekxmpp/plugins/xep_0085')
-rw-r--r--sleekxmpp/plugins/xep_0085/__init__.py11
-rw-r--r--sleekxmpp/plugins/xep_0085/chat_states.py24
-rw-r--r--sleekxmpp/plugins/xep_0085/stanza.py1
3 files changed, 22 insertions, 14 deletions
diff --git a/sleekxmpp/plugins/xep_0085/__init__.py b/sleekxmpp/plugins/xep_0085/__init__.py
index ff882f05..445d5059 100644
--- a/sleekxmpp/plugins/xep_0085/__init__.py
+++ b/sleekxmpp/plugins/xep_0085/__init__.py
@@ -6,5 +6,14 @@
See the file LICENSE for copying permissio
"""
+from sleekxmpp.plugins.base import register_plugin
+
from sleekxmpp.plugins.xep_0085.stanza import ChatState
-from sleekxmpp.plugins.xep_0085.chat_states import xep_0085
+from sleekxmpp.plugins.xep_0085.chat_states import XEP_0085
+
+
+register_plugin(XEP_0085)
+
+
+# Retain some backwards compatibility
+xep_0085 = XEP_0085
diff --git a/sleekxmpp/plugins/xep_0085/chat_states.py b/sleekxmpp/plugins/xep_0085/chat_states.py
index 6f7cfddf..d10b317b 100644
--- a/sleekxmpp/plugins/xep_0085/chat_states.py
+++ b/sleekxmpp/plugins/xep_0085/chat_states.py
@@ -13,29 +13,29 @@ from sleekxmpp.stanza import Message
from sleekxmpp.xmlstream.handler import Callback
from sleekxmpp.xmlstream.matcher import StanzaPath
from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase, ET
-from sleekxmpp.plugins.base import base_plugin
+from sleekxmpp.plugins import BasePlugin
from sleekxmpp.plugins.xep_0085 import stanza, ChatState
log = logging.getLogger(__name__)
-class xep_0085(base_plugin):
+class XEP_0085(BasePlugin):
"""
XEP-0085 Chat State Notifications
"""
- def plugin_init(self):
- self.xep = '0085'
- self.description = 'Chat State Notifications'
- self.stanza = stanza
+ name = 'xep_0085'
+ description = 'XEP-0085: Chat State Notifications'
+ dependencies = set(['xep_0030'])
+ stanza = stanza
- for state in ChatState.states:
- self.xmpp.register_handler(
- Callback('Chat State: %s' % state,
- StanzaPath('message@chat_state=%s' % state),
- self._handle_chat_state))
+ def plugin_init(self):
+ self.xmpp.register_handler(
+ Callback('Chat State',
+ StanzaPath('message/chat_state'),
+ self._handle_chat_state))
register_stanza_plugin(Message, stanza.Active)
register_stanza_plugin(Message, stanza.Composing)
@@ -43,8 +43,6 @@ class xep_0085(base_plugin):
register_stanza_plugin(Message, stanza.Inactive)
register_stanza_plugin(Message, stanza.Paused)
- def post_init(self):
- base_plugin.post_init(self)
self.xmpp.plugin['xep_0030'].add_feature(ChatState.namespace)
def _handle_chat_state(self, msg):
diff --git a/sleekxmpp/plugins/xep_0085/stanza.py b/sleekxmpp/plugins/xep_0085/stanza.py
index 73c109ac..c2cafb19 100644
--- a/sleekxmpp/plugins/xep_0085/stanza.py
+++ b/sleekxmpp/plugins/xep_0085/stanza.py
@@ -38,6 +38,7 @@ class ChatState(ElementBase):
namespace = 'http://jabber.org/protocol/chatstates'
plugin_attrib = 'chat_state'
interfaces = set(('chat_state',))
+ sub_interfaces = interfaces
is_extension = True
states = set(('active', 'composing', 'gone', 'inactive', 'paused'))