summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r--sleekxmpp/plugins/xep_0027/stanza.py2
-rw-r--r--sleekxmpp/plugins/xep_0047/ibb.py4
-rw-r--r--sleekxmpp/plugins/xep_0095/stream_initiation.py29
3 files changed, 26 insertions, 9 deletions
diff --git a/sleekxmpp/plugins/xep_0027/stanza.py b/sleekxmpp/plugins/xep_0027/stanza.py
index 3170ca6e..08f2032b 100644
--- a/sleekxmpp/plugins/xep_0027/stanza.py
+++ b/sleekxmpp/plugins/xep_0027/stanza.py
@@ -39,7 +39,7 @@ class Encrypted(ElementBase):
def set_encrypted(self, value):
parent = self.parent()
xmpp = parent.stream
- data = xmpp['xep_0027'].encrypt(value, parent['to'].bare)
+ data = xmpp['xep_0027'].encrypt(value, parent['to'])
if data:
self.xml.text = data
else:
diff --git a/sleekxmpp/plugins/xep_0047/ibb.py b/sleekxmpp/plugins/xep_0047/ibb.py
index 6110b26c..62dddac2 100644
--- a/sleekxmpp/plugins/xep_0047/ibb.py
+++ b/sleekxmpp/plugins/xep_0047/ibb.py
@@ -85,7 +85,7 @@ class XEP_0047(BasePlugin):
self._streams[(jid, sid, peer_jid)] = stream
def _del_stream(self, jid, sid, peer_jid, data):
- with self._streams_lock:
+ with self._stream_lock:
if (jid, sid, peer_jid) in self._streams:
del self._streams[(jid, sid, peer_jid)]
@@ -207,7 +207,7 @@ class XEP_0047(BasePlugin):
def _handle_close(self, iq):
sid = iq['ibb_close']['sid']
- stream = self.api['get_stream'](stanza['to'], sid, stanza['from'])
+ stream = self.api['get_stream'](iq['to'], sid, iq['from'])
if stream is not None and iq['from'] == stream.peer_jid:
stream._closed(iq)
self.api['del_stream'](stream.self_jid, stream.sid, stream.peer_jid)
diff --git a/sleekxmpp/plugins/xep_0095/stream_initiation.py b/sleekxmpp/plugins/xep_0095/stream_initiation.py
index cfe6deb5..927248a5 100644
--- a/sleekxmpp/plugins/xep_0095/stream_initiation.py
+++ b/sleekxmpp/plugins/xep_0095/stream_initiation.py
@@ -37,11 +37,12 @@ class XEP_0095(BasePlugin):
def plugin_init(self):
self._profiles = {}
self._methods = {}
+ self._methods_order = []
self._pending_lock = threading.Lock()
self._pending= {}
- self.register_method(SOCKS5, 'xep_0065')
- self.register_method(IBB, 'xep_0047')
+ self.register_method(SOCKS5, 'xep_0065', 100)
+ self.register_method(IBB, 'xep_0047', 50)
register_stanza_plugin(Iq, SI)
register_stanza_plugin(SI, self.xmpp['xep_0020'].stanza.FeatureNegotiation)
@@ -71,8 +72,17 @@ class XEP_0095(BasePlugin):
except KeyError:
pass
- def register_method(self, method, plugin_name):
- self._methods[method] = plugin_name
+ def register_method(self, method, plugin_name, order=50):
+ self._methods[method] = (plugin_name, order)
+ self._methods_order.append((order, method, plugin_name))
+ self._methods_order.sort()
+
+ def unregister_method(self, method):
+ if method in self._methods:
+ plugin_name, order = self._methods[method]
+ del self._methods[method]
+ self._methods_order.remove((order, method, plugin_name))
+ self._methods_order.sort()
def _handle_request(self, iq):
profile = iq['si']['profile']
@@ -101,7 +111,14 @@ class XEP_0095(BasePlugin):
extension='no-valid-streams',
extension_ns=SI.namespace)
- selected_method = SOCKS5 if SOCKS5 in methods else IBB
+ selected_method = None
+ log.debug('Available: %s', methods)
+ for order, method, plugin in self._methods_order:
+ log.debug('Testing: %s', method)
+ if method in methods:
+ selected_method = method
+ break
+
receiver = iq['to']
sender = iq['from']
@@ -157,7 +174,7 @@ class XEP_0095(BasePlugin):
if ifrom is None:
ifrom = self.xmpp.boundjid
- method_plugin = self._methods[stream['method']]
+ method_plugin = self._methods[stream['method']][0]
self.xmpp[method_plugin].api['preauthorize_sid'](ifrom, sid, jid)
self.api['del_pending'](ifrom, sid, jid)