diff options
author | Lance Stout <lancestout@gmail.com> | 2012-03-11 21:15:01 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-03-12 19:32:19 -0700 |
commit | 1f5a3a444521e67afc7036cfd8f8e98fee982141 (patch) | |
tree | 9ae162795ed3e85fb22f48aabab7a6cc8d0d2d91 | |
parent | be363e0b46681125a54e2d96f70c0c259216fee1 (diff) | |
download | slixmpp-1f5a3a444521e67afc7036cfd8f8e98fee982141.tar.gz slixmpp-1f5a3a444521e67afc7036cfd8f8e98fee982141.tar.bz2 slixmpp-1f5a3a444521e67afc7036cfd8f8e98fee982141.tar.xz slixmpp-1f5a3a444521e67afc7036cfd8f8e98fee982141.zip |
Move XEP-0047 to new system.
-rw-r--r-- | sleekxmpp/plugins/xep_0047/__init__.py | 10 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0047/ibb.py | 17 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0047/stanza.py | 3 | ||||
-rw-r--r-- | sleekxmpp/plugins/xep_0047/stream.py | 6 |
4 files changed, 22 insertions, 14 deletions
diff --git a/sleekxmpp/plugins/xep_0047/__init__.py b/sleekxmpp/plugins/xep_0047/__init__.py index 5a6487cc..5cd7df2e 100644 --- a/sleekxmpp/plugins/xep_0047/__init__.py +++ b/sleekxmpp/plugins/xep_0047/__init__.py @@ -6,8 +6,16 @@ See the file LICENSE for copying permission. """ +from sleekxmpp.plugins.base import register_plugin + from sleekxmpp.plugins.xep_0047 import stanza from sleekxmpp.plugins.xep_0047.stanza import Open, Close, Data from sleekxmpp.plugins.xep_0047.stream import IBBytestream -from sleekxmpp.plugins.xep_0047.ibb import xep_0047 +from sleekxmpp.plugins.xep_0047.ibb import XEP_0047 + + +register_plugin(XEP_0047) + +# Retain some backwards compatibility +xep_0047 = XEP_0047 diff --git a/sleekxmpp/plugins/xep_0047/ibb.py b/sleekxmpp/plugins/xep_0047/ibb.py index 5b138daf..c8a4b5e7 100644 --- a/sleekxmpp/plugins/xep_0047/ibb.py +++ b/sleekxmpp/plugins/xep_0047/ibb.py @@ -3,24 +3,25 @@ import logging import threading from sleekxmpp import Message, Iq -from sleekxmpp.exceptions import XMPPError, IqError, IqTimeout +from sleekxmpp.exceptions import XMPPError from sleekxmpp.xmlstream.handler import Callback from sleekxmpp.xmlstream.matcher import StanzaPath from sleekxmpp.xmlstream import register_stanza_plugin -from sleekxmpp.plugins.base import base_plugin +from sleekxmpp.plugins import BasePlugin from sleekxmpp.plugins.xep_0047 import stanza, Open, Close, Data, IBBytestream log = logging.getLogger(__name__) -class xep_0047(base_plugin): +class XEP_0047(BasePlugin): - def plugin_init(self): - self.xep = '0047' - self.description = 'In-Band Bytestreams' - self.stanza = stanza + name = 'xep_0047' + description = 'XEP-0047: In-band Bytestreams' + dependencies = set(['xep_0030']) + stanza = stanza + def plugin_init(self): self.streams = {} self.pending_streams = {3: 5} self.pending_close_streams = {} @@ -50,7 +51,6 @@ class xep_0047(base_plugin): StanzaPath('iq@type=set/ibb_data'), self._handle_data)) - def post_init(self): self.xmpp['xep_0030'].add_feature('http://jabber.org/protocol/ibb') def _accept_stream(self, iq): @@ -97,7 +97,6 @@ class xep_0047(base_plugin): cb = self._handle_opened_stream return iq.send(block=block, timeout=timeout, callback=cb) - def _handle_opened_stream(self, iq): if iq['type'] == 'result': with self._stream_lock: diff --git a/sleekxmpp/plugins/xep_0047/stanza.py b/sleekxmpp/plugins/xep_0047/stanza.py index fb0d4309..afba07a8 100644 --- a/sleekxmpp/plugins/xep_0047/stanza.py +++ b/sleekxmpp/plugins/xep_0047/stanza.py @@ -2,7 +2,7 @@ import re import base64 from sleekxmpp.exceptions import XMPPError -from sleekxmpp.xmlstream import register_stanza_plugin, ET, ElementBase +from sleekxmpp.xmlstream import ElementBase from sleekxmpp.thirdparty.suelta.util import bytes @@ -12,6 +12,7 @@ VALID_B64 = re.compile(r'[A-Za-z0-9\+\/]*=*') def to_b64(data): return bytes(base64.b64encode(bytes(data))).decode('utf-8') + def from_b64(data): return bytes(base64.b64decode(bytes(data))).decode('utf-8') diff --git a/sleekxmpp/plugins/xep_0047/stream.py b/sleekxmpp/plugins/xep_0047/stream.py index 73c34425..49f56f36 100644 --- a/sleekxmpp/plugins/xep_0047/stream.py +++ b/sleekxmpp/plugins/xep_0047/stream.py @@ -28,7 +28,7 @@ class IBBytestream(object): self._send_seq_lock = threading.Lock() self._recv_seq_lock = threading.Lock() - + self.stream_started = threading.Event() self.stream_in_closed = threading.Event() self.stream_out_closed = threading.Event() @@ -55,7 +55,7 @@ class IBBytestream(object): iq['from'] = self.sender iq['ibb_data']['sid'] = self.sid iq['ibb_data']['seq'] = seq - iq['ibb_data']['data'] = data + iq['ibb_data']['data'] = data self.window_empty.clear() self.window_ids.add(iq['id']) iq.send(block=False, callback=self._recv_ack) @@ -113,7 +113,7 @@ class IBBytestream(object): iq['from'] = self.sender iq['ibb_close']['sid'] = self.sid self.stream_out_closed.set() - iq.send(block=False, + iq.send(block=False, callback=lambda x: self.stream_in_closed.set()) self.xmpp.event('ibb_stream_end', self) |