From 7c7fa0f00826f304dab12faad297ef339a7de2a0 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sat, 8 Jan 2011 11:19:31 -0500 Subject: Add support for XEP-0059 to XEP-0030 plugin. --- sleekxmpp/plugins/xep_0030/disco.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'sleekxmpp/plugins/xep_0030') diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index 4958c931..b4f5e79f 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -120,6 +120,11 @@ class xep_0030(base_plugin): 'jid': {}, 'node': {}} + def post_init(self): + """Handle cross-plugin dependencies.""" + if self.xmpp['xep_0059']: + register_stanza_plugin(DiscoItems, self.xmpp['xep_0059'].stanza.Set) + def set_node_handler(self, htype, jid=None, node=None, handler=None): """ Add a node handler for the given hierarchy level and @@ -292,6 +297,9 @@ class xep_0030(base_plugin): callback -- Optional callback to execute when a reply is received instead of blocking and waiting for the reply. + iterator -- If True, return a result set iterator using + the XEP-0059 plugin, if the plugin is loaded. + Otherwise the parameter is ignored. """ if local or jid is None: return self._run_node_handler('get_items', jid, node, kwargs) @@ -302,9 +310,12 @@ class xep_0030(base_plugin): iq['to'] = jid iq['type'] = 'get' iq['disco_items']['node'] = node if node else '' - return iq.send(timeout=kwargs.get('timeout', None), - block=kwargs.get('block', None), - callback=kwargs.get('callback', None)) + if kwargs.get('iterator', False) and self.xmpp['xep_0059']: + return self.xmpp['xep_0059'].iterate(iq, 'disco_items') + else: + return iq.send(timeout=kwargs.get('timeout', None), + block=kwargs.get('block', None), + callback=kwargs.get('callback', None)) def set_items(self, jid=None, node=None, **kwargs): """ -- cgit v1.2.3