Move XEP-0199 to new system.

This commit is contained in:
Lance Stout 2012-03-12 00:18:33 -07:00
parent 17279de4a3
commit 5a324c01de
2 changed files with 18 additions and 14 deletions

View file

@ -6,5 +6,15 @@
See the file LICENSE for copying permission.
"""
from sleekxmpp.plugins.base import register_plugin
from sleekxmpp.plugins.xep_0199.stanza import Ping
from sleekxmpp.plugins.xep_0199.ping import xep_0199
from sleekxmpp.plugins.xep_0199.ping import XEP_0199
register_plugin(XEP_0199)
# Backwards compatibility for names
xep_0199 = XEP_0199
xep_0199.sendPing = xep_0199.send_ping

View file

@ -15,14 +15,14 @@ from sleekxmpp.exceptions import IqError, IqTimeout
from sleekxmpp.xmlstream import register_stanza_plugin
from sleekxmpp.xmlstream.matcher import StanzaPath
from sleekxmpp.xmlstream.handler import Callback
from sleekxmpp.plugins.base import base_plugin
from sleekxmpp.plugins import BasePlugin
from sleekxmpp.plugins.xep_0199 import stanza, Ping
log = logging.getLogger(__name__)
class xep_0199(base_plugin):
class XEP_0199(BasePlugin):
"""
XEP-0199: XMPP Ping
@ -47,14 +47,15 @@ class xep_0199(base_plugin):
round trip time.
"""
name = 'xep_0199'
description = 'XEP-0199: XMPP Ping'
dependencies = set(['xep_0030'])
stanza = stanza
def plugin_init(self):
"""
Start the XEP-0199 plugin.
"""
self.description = 'XMPP Ping'
self.xep = '0199'
self.stanza = stanza
self.keepalive = self.config.get('keepalive', False)
self.frequency = float(self.config.get('frequency', 300))
self.timeout = self.config.get('timeout', 30)
@ -73,9 +74,6 @@ class xep_0199(base_plugin):
self.xmpp.add_event_handler('session_end',
self._handle_session_end)
def post_init(self):
"""Handle cross-plugin dependencies."""
base_plugin.post_init(self)
self.xmpp['xep_0030'].add_feature(Ping.namespace)
def _handle_keepalive(self, event):
@ -169,7 +167,3 @@ class xep_0199(base_plugin):
log.debug("Pong: %s %f", jid, delay)
return delay
# Backwards compatibility for names
xep_0199.sendPing = xep_0199.send_ping