Move XEP-0077 to the new system.

This commit is contained in:
Lance Stout 2012-03-11 22:15:25 -07:00
parent 4a3a9067d4
commit cdd69c6842
3 changed files with 23 additions and 19 deletions

View file

@ -13,7 +13,7 @@ from sleekxmpp.exceptions import XMPPError
from sleekxmpp.xmlstream import register_stanza_plugin
from sleekxmpp.xmlstream.handler import Callback
from sleekxmpp.xmlstream.matcher import StanzaPath
from sleekxmpp.plugins import BasePlugin, register_plugin
from sleekxmpp.plugins import BasePlugin
from sleekxmpp.plugins.xep_0066 import stanza

View file

@ -6,5 +6,14 @@
See the file LICENSE for copying permission.
"""
from sleekxmpp.plugins.base import register_plugin
from sleekxmpp.plugins.xep_0077.stanza import Register, RegisterFeature
from sleekxmpp.plugins.xep_0077.register import xep_0077
from sleekxmpp.plugins.xep_0077.register import XEP_0077
register_plugin(XEP_0077)
# Retain some backwards compatibility
xep_0077 = XEP_0077

View file

@ -8,33 +8,32 @@
import logging
import sleekxmpp
from sleekxmpp.stanza import StreamFeatures, Iq
from sleekxmpp.xmlstream import register_stanza_plugin, JID
from sleekxmpp.plugins.base import base_plugin
from sleekxmpp.plugins import BasePlugin
from sleekxmpp.plugins.xep_0077 import stanza, Register, RegisterFeature
log = logging.getLogger(__name__)
class xep_0077(base_plugin):
class XEP_0077(BasePlugin):
"""
XEP-0077: In-Band Registration
"""
def plugin_init(self):
self.xep = '0077'
self.description = 'In-Band Registration'
self.stanza = stanza
name = 'xep_0077'
description = 'XEP-0077: In-Band Registration'
dependencies = set(['xep_0004', 'xep_0066'])
stanza = stanza
def plugin_init(self):
self.create_account = self.config.get('create_account', True)
register_stanza_plugin(StreamFeatures, RegisterFeature)
register_stanza_plugin(Iq, Register)
if self.xmpp.is_component:
pass
else:
@ -43,13 +42,8 @@ class xep_0077(base_plugin):
restart=False,
order=self.config.get('order', 50))
def post_init(self):
base_plugin.post_init(self)
if 'xep_0004' in self.xmpp.plugin:
register_stanza_plugin(Register, self.xmpp['xep_0004'].stanza.Form)
if 'xep_0066' in self.xmpp.plugin:
register_stanza_plugin(Register, self.xmpp['xep_0066'].stanza.OOB)
register_stanza_plugin(Register, self.xmpp['xep_0004'].stanza.Form)
register_stanza_plugin(Register, self.xmpp['xep_0066'].stanza.OOB)
def _handle_register_feature(self, features):
if 'mechanisms' in self.xmpp.features:
@ -69,7 +63,8 @@ class xep_0077(base_plugin):
iq['to'] = jid
iq['from'] = ifrom
iq.enable('register')
return iq.send(block=block, timeout=timeout, callback=callback, now=True)
return iq.send(block=block, timeout=timeout,
callback=callback, now=True)
def cancel_registration(self, jid=None, ifrom=None, block=True,
timeout=None, callback=None):
@ -82,7 +77,7 @@ class xep_0077(base_plugin):
def change_password(self, password, jid=None, ifrom=None, block=True,
timeout=None, callback=None):
iq= self.xmpp.Iq()
iq = self.xmpp.Iq()
iq['type'] = 'set'
iq['to'] = jid
iq['from'] = ifrom