diff --git a/sleekxmpp/__init__.py b/sleekxmpp/__init__.py index 3d659a8..86b74fc 100644 --- a/sleekxmpp/__init__.py +++ b/sleekxmpp/__init__.py @@ -175,7 +175,7 @@ class ClientXMPP(basexmpp, XMLStream): def handler_starttls(self, xml): if not self.authenticated and self.ssl_support: - self.add_handler("", self.handler_tls_start, instream=True) + self.add_handler("", self.handler_tls_start, name='TLS Proceed', instream=True) self.sendXML(xml) return True else: @@ -191,8 +191,8 @@ class ClientXMPP(basexmpp, XMLStream): if '{urn:ietf:params:xml:ns:xmpp-tls}starttls' in self.features: return False logging.debug("Starting SASL Auth") - self.add_handler("", self.handler_auth_success, instream=True) - self.add_handler("", self.handler_auth_fail, instream=True) + self.add_handler("", self.handler_auth_success, name='SASL Sucess', instream=True) + self.add_handler("", self.handler_auth_fail, name='SASL Failure', instream=True) sasl_mechs = xml.findall('{urn:ietf:params:xml:ns:xmpp-sasl}mechanism') if len(sasl_mechs): for sasl_mech in sasl_mechs: diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py index 12dc2a1..8489b24 100644 --- a/sleekxmpp/basexmpp.py +++ b/sleekxmpp/basexmpp.py @@ -118,9 +118,11 @@ class basexmpp(object): self.id += 1 return self.getId() - def add_handler(self, mask, pointer, disposable=False, threaded=False, filter=False, instream=False): - #logging.warning("Deprecated add_handler used for %s: %s." % (mask, pointer)) - self.registerHandler(XMLCallback('add_handler_%s' % self.getNewId(), MatchXMLMask(mask), pointer, threaded, disposable, instream)) + def add_handler(self, mask, pointer, name=None, disposable=False, threaded=False, filter=False, instream=False): + # threaded is no longer needed, but leaving it for backwards compatibility for now + if name is None: + name = 'add_handler_%s' % self.getNewId() + self.registerHandler(XMLCallback(name, MatchXMLMask(mask), pointer, threaded, disposable, instream)) def getId(self): return "%x".upper() % self.id diff --git a/sleekxmpp/plugins/old_0004.py b/sleekxmpp/plugins/old_0004.py index 263f8b2..2d4203a 100644 --- a/sleekxmpp/plugins/old_0004.py +++ b/sleekxmpp/plugins/old_0004.py @@ -29,7 +29,7 @@ class old_0004(base.base_plugin): def plugin_init(self): self.xep = '0004' self.description = '*Deprecated Data Forms' - self.xmpp.add_handler("", self.handler_message_xform) + self.xmpp.add_handler("", self.handler_message_xform, name='Old Message Form') def post_init(self): base.base_plugin.post_init(self) diff --git a/sleekxmpp/plugins/xep_0009.py b/sleekxmpp/plugins/xep_0009.py index 49ffac4..625b03f 100644 --- a/sleekxmpp/plugins/xep_0009.py +++ b/sleekxmpp/plugins/xep_0009.py @@ -178,9 +178,12 @@ class xep_0009(base.base_plugin): def plugin_init(self): self.xep = '0009' self.description = 'Jabber-RPC' - self.xmpp.add_handler("", self._callMethod) - self.xmpp.add_handler("", self._callResult) - self.xmpp.add_handler("", self._callError) + self.xmpp.add_handler("", + self._callMethod, name='Jabber RPC Call') + self.xmpp.add_handler("", + self._callResult, name='Jabber RPC Result') + self.xmpp.add_handler("", + self._callError, name='Jabber RPC Error') self.entries = {} self.activeCalls = [] diff --git a/sleekxmpp/plugins/xep_0050.py b/sleekxmpp/plugins/xep_0050.py index 2f356e1..11a1772 100644 --- a/sleekxmpp/plugins/xep_0050.py +++ b/sleekxmpp/plugins/xep_0050.py @@ -32,11 +32,11 @@ class xep_0050(base.base_plugin): def plugin_init(self): self.xep = '0050' self.description = 'Ad-Hoc Commands' - self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command) - self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command) - self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command_next, threaded=True) - self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command_cancel) - self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command_complete) + self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command, name='Ad-Hoc None') + self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command, name='Ad-Hoc Execute') + self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command_next, name='Ad-Hoc Next', threaded=True) + self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command_cancel, name='Ad-Hoc Cancel') + self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_command_complete, name='Ad-Hoc Complete') self.commands = {} self.sessions = {} self.sd = self.xmpp.plugin['xep_0030'] diff --git a/sleekxmpp/plugins/xep_0092.py b/sleekxmpp/plugins/xep_0092.py index aeebbe0..77a6d9d 100644 --- a/sleekxmpp/plugins/xep_0092.py +++ b/sleekxmpp/plugins/xep_0092.py @@ -30,7 +30,7 @@ class xep_0092(base.base_plugin): self.xep = "0092" self.name = self.config.get('name', 'SleekXMPP') self.version = self.config.get('version', '0.1-dev') - self.xmpp.add_handler("" % self.xmpp.default_ns, self.report_version) + self.xmpp.add_handler("" % self.xmpp.default_ns, self.report_version, name='Sofware Version') def post_init(self): base.base_plugin.post_init(self) diff --git a/sleekxmpp/plugins/xep_0199.py b/sleekxmpp/plugins/xep_0199.py index ccaf0b3..1da57fe 100644 --- a/sleekxmpp/plugins/xep_0199.py +++ b/sleekxmpp/plugins/xep_0199.py @@ -29,7 +29,7 @@ class xep_0199(base.base_plugin): def plugin_init(self): self.description = "XMPP Ping" self.xep = "0199" - self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_ping) + self.xmpp.add_handler("" % self.xmpp.default_ns, self.handler_ping, name='XMPP Ping') self.running = False #if self.config.get('keepalive', True): #self.xmpp.add_event_handler('session_start', self.handler_pingserver, threaded=True) diff --git a/sleekxmpp/tests/testpubsub.py b/sleekxmpp/tests/testpubsub.py index ed9dd5c..d8f3ff4 100755 --- a/sleekxmpp/tests/testpubsub.py +++ b/sleekxmpp/tests/testpubsub.py @@ -34,9 +34,9 @@ class testps(sleekxmpp.ClientXMPP): self.registerPlugin('xep_0030') self.registerPlugin('xep_0060') self.registerPlugin('xep_0092') - self.add_handler("", self.pubsubEventHandler, threaded=True) + self.add_handler("", self.pubsubEventHandler, name='Pubsub Event', threaded=True) self.add_event_handler("session_start", self.start, threaded=True) - self.add_handler("", self.handleError) + self.add_handler("", self.handleError, name='Iq Error') self.events = Queue.Queue() self.default_config = None self.ps = self.plugin['xep_0060']