From 6f337b5425a358fe160608ac304644ce970dfb18 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sun, 11 Mar 2012 22:30:02 -0700 Subject: [PATCH] Move XEP-0012 to new system. Still needs to update to the current plugin format though. --- sleekxmpp/plugins/xep_0012.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sleekxmpp/plugins/xep_0012.py b/sleekxmpp/plugins/xep_0012.py index c5532bd4..123181cf 100644 --- a/sleekxmpp/plugins/xep_0012.py +++ b/sleekxmpp/plugins/xep_0012.py @@ -9,11 +9,11 @@ from datetime import datetime import logging -from . import base -from .. stanza.iq import Iq -from .. xmlstream.handler.callback import Callback -from .. xmlstream.matcher.xpath import MatchXPath -from .. xmlstream import ElementBase, ET, JID, register_stanza_plugin +from sleekxmpp.plugins import BasePlugin, register_plugin +from sleekxmpp import Iq +from sleekxmpp.xmlstream.handler.callback import Callback +from sleekxmpp.xmlstream.matcher.xpath import MatchXPath +from sleekxmpp.xmlstream import ElementBase, ET, JID, register_stanza_plugin log = logging.getLogger(__name__) @@ -40,12 +40,18 @@ class LastActivity(ElementBase): def del_status(self): self.xml.text = '' -class xep_0012(base.base_plugin): + +class XEP_0012(BasePlugin): + """ XEP-0012 Last Activity """ + + name = 'xep_0012' + description = 'XEP-0012: Last Activity' + dependencies = set(['xep_0030']) + def plugin_init(self): - self.description = "Last Activity" self.xep = "0012" self.xmpp.registerHandler( @@ -57,9 +63,6 @@ class xep_0012(base.base_plugin): self.xmpp.add_event_handler('last_activity_request', self.handle_last_activity) - - def post_init(self): - base.base_plugin.post_init(self) if self.xmpp.is_component: # We are a component, so we track the uptime self.xmpp.add_event_handler("session_start", self._reset_uptime) @@ -113,3 +116,6 @@ class xep_0012(base.base_plugin): id = iq.get('id') result = iq.send() return result['last_activity']['seconds'] + + +register_plugin(XEP_0012)