mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
Fix bug in XEP-0030 plugin.
xep_0030 still referenced event_handlers. Added the method event_handled which will return the number of registered handlers for an event to resolve the issue.
This commit is contained in:
parent
973890e2c9
commit
9e248bb852
2 changed files with 272 additions and 262 deletions
|
@ -241,8 +241,7 @@ class xep_0030(base.base_plugin):
|
|||
A default handler for disco#info requests. If another
|
||||
handler is registered, this one will defer and not run.
|
||||
"""
|
||||
handlers = self.xmpp.event_handlers['disco_info_request']
|
||||
if not forwarded and len(handlers) > 1:
|
||||
if not forwarded and self.xmpp.event_handled('disco_info_request'):
|
||||
return
|
||||
|
||||
node_name = iq['disco_info']['node']
|
||||
|
@ -270,8 +269,7 @@ class xep_0030(base.base_plugin):
|
|||
If this handler is called by your own custom handler with
|
||||
forwarded set to True, then it will run as normal.
|
||||
"""
|
||||
handlers = self.xmpp.event_handlers['disco_items_request']
|
||||
if not forwarded and len(handlers) > 1:
|
||||
if not forwarded and self.xmpp.event_handled('disco_items_request'):
|
||||
return
|
||||
|
||||
node_name = iq['disco_items']['node']
|
||||
|
|
|
@ -379,6 +379,7 @@ class XMLStream(object):
|
|||
"""
|
||||
if self.ssl_support:
|
||||
logging.info("Negotiating TLS")
|
||||
logging.info("Using SSL version: %s" % str(self.ssl_version))
|
||||
ssl_socket = ssl.wrap_socket(self.socket,
|
||||
ssl_version=self.ssl_version,
|
||||
do_handshake_on_connect=False)
|
||||
|
@ -527,6 +528,17 @@ class XMLStream(object):
|
|||
self.__event_handlers[name] = filter(filter_pointers,
|
||||
self.__event_handlers[name])
|
||||
|
||||
def event_handled(self, name):
|
||||
"""
|
||||
Indicates if an event has any associated handlers.
|
||||
|
||||
Returns the number of registered handlers.
|
||||
|
||||
Arguments:
|
||||
name -- The name of the event to check.
|
||||
"""
|
||||
return len(self.__event_handlers.get(name, []))
|
||||
|
||||
def event(self, name, data={}, direct=False):
|
||||
"""
|
||||
Manually trigger a custom event.
|
||||
|
|
Loading…
Reference in a new issue