Simplify stream method unregistration process

This commit is contained in:
Lance Stout 2013-05-26 14:53:28 -07:00
parent 82e1508d6f
commit 4a590d1497

View File

@ -73,12 +73,13 @@ class XEP_0095(BasePlugin):
pass pass
def register_method(self, method, plugin_name, order=50): def register_method(self, method, plugin_name, order=50):
self._methods[method] = plugin_name self._methods[method] = (plugin_name, order)
self._methods_order.append((order, method, plugin_name)) self._methods_order.append((order, method, plugin_name))
self._methods_order.sort() self._methods_order.sort()
def unregister_method(self, method, plugin_name, order): def unregister_method(self, method):
if method in self._methods: if method in self._methods:
plugin_name, order = self._methods[method]
del self._methods[method] del self._methods[method]
self._methods_order.remove((order, method, plugin_name)) self._methods_order.remove((order, method, plugin_name))
self._methods_order.sort() self._methods_order.sort()
@ -173,7 +174,7 @@ class XEP_0095(BasePlugin):
if ifrom is None: if ifrom is None:
ifrom = self.xmpp.boundjid 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.xmpp[method_plugin].api['preauthorize_sid'](ifrom, sid, jid)
self.api['del_pending'](ifrom, sid, jid) self.api['del_pending'](ifrom, sid, jid)