summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-02-23 19:09:55 +0100
committermathieui <mathieui@mathieui.net>2015-02-24 22:46:03 +0100
commit506ca6991790cffb90c5b6e3b765237ccc136e1a (patch)
tree0455c85ddaa3eeefaff65615e52b4b66b30890c2
parent8ac0ecdf4063345249ca15f35817262f3b29cdef (diff)
downloadslixmpp-506ca6991790cffb90c5b6e3b765237ccc136e1a.tar.gz
slixmpp-506ca6991790cffb90c5b6e3b765237ccc136e1a.tar.bz2
slixmpp-506ca6991790cffb90c5b6e3b765237ccc136e1a.tar.xz
slixmpp-506ca6991790cffb90c5b6e3b765237ccc136e1a.zip
XEP-0030: allow get_info and get_items to return a coroutine
-rw-r--r--slixmpp/plugins/xep_0030/disco.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/slixmpp/plugins/xep_0030/disco.py b/slixmpp/plugins/xep_0030/disco.py
index c8c18ea7..7833dffd 100644
--- a/slixmpp/plugins/xep_0030/disco.py
+++ b/slixmpp/plugins/xep_0030/disco.py
@@ -10,6 +10,7 @@ import logging
from slixmpp import Iq
from slixmpp.plugins import BasePlugin
+from slixmpp import coroutine_wrapper
from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.xmlstream import register_stanza_plugin, JID
@@ -288,6 +289,7 @@ class XEP_0030(BasePlugin):
'cached': cached}
return self.api['has_identity'](jid, node, ifrom, data)
+ @coroutine_wrapper
def get_info(self, jid=None, node=None, local=None,
cached=None, **kwargs):
"""
@@ -362,9 +364,10 @@ class XEP_0030(BasePlugin):
iq['to'] = jid
iq['type'] = 'get'
iq['disco_info']['node'] = node if node else ''
- iq.send(timeout=kwargs.get('timeout', None),
- callback=kwargs.get('callback', None),
- timeout_callback=kwargs.get('timeout_callback', None))
+ return iq.send(timeout=kwargs.get('timeout', None),
+ callback=kwargs.get('callback', None),
+ coroutine=kwargs.get('coroutine', False),
+ timeout_callback=kwargs.get('timeout_callback', None))
def set_info(self, jid=None, node=None, info=None):
"""
@@ -375,6 +378,7 @@ class XEP_0030(BasePlugin):
info = info['disco_info']
self.api['set_info'](jid, node, None, info)
+ @coroutine_wrapper
def get_items(self, jid=None, node=None, local=False, **kwargs):
"""
Retrieve the disco#items results from a given JID/node combination.
@@ -423,9 +427,10 @@ class XEP_0030(BasePlugin):
raise NotImplementedError("XEP 0059 has not yet been fixed")
return self.xmpp['xep_0059'].iterate(iq, 'disco_items')
else:
- iq.send(timeout=kwargs.get('timeout', None),
- callback=kwargs.get('callback', None),
- timeout_callback=kwargs.get('timeout_callback', None))
+ return iq.send(timeout=kwargs.get('timeout', None),
+ callback=kwargs.get('callback', None),
+ coroutine=kwargs.get('coroutine', False),
+ timeout_callback=kwargs.get('timeout_callback', None))
def set_items(self, jid=None, node=None, **kwargs):
"""