summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-05-26 14:50:01 -0700
committerLance Stout <lancestout@gmail.com>2013-05-26 14:50:01 -0700
commit82e1508d6fbef3cf63bfa5f46a243054eeddd451 (patch)
tree44ad57b65ce722119f83ae98de34fed7da91cf70 /sleekxmpp/plugins
parent400f08db9db4c122a18209934e40704c6df4e492 (diff)
downloadslixmpp-82e1508d6fbef3cf63bfa5f46a243054eeddd451.tar.gz
slixmpp-82e1508d6fbef3cf63bfa5f46a243054eeddd451.tar.bz2
slixmpp-82e1508d6fbef3cf63bfa5f46a243054eeddd451.tar.xz
slixmpp-82e1508d6fbef3cf63bfa5f46a243054eeddd451.zip
Make stream initiation methods unregisterable.
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r--sleekxmpp/plugins/xep_0095/stream_initiation.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/sleekxmpp/plugins/xep_0095/stream_initiation.py b/sleekxmpp/plugins/xep_0095/stream_initiation.py
index cfe6deb5..b72c840f 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,16 @@ class XEP_0095(BasePlugin):
except KeyError:
pass
- def register_method(self, method, plugin_name):
+ def register_method(self, method, plugin_name, order=50):
self._methods[method] = plugin_name
+ self._methods_order.append((order, method, plugin_name))
+ self._methods_order.sort()
+
+ def unregister_method(self, method, plugin_name, order):
+ if method in self._methods:
+ 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 +110,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']