From 6e8235544cc1bdefea75a8d93e5e3a48a13552ba Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 23 Feb 2015 19:33:22 +0100 Subject: XEP-0191: wrap functions with coroutine_wrapper --- slixmpp/plugins/xep_0191/blocking.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/slixmpp/plugins/xep_0191/blocking.py b/slixmpp/plugins/xep_0191/blocking.py index 22610d78..9a6971a8 100644 --- a/slixmpp/plugins/xep_0191/blocking.py +++ b/slixmpp/plugins/xep_0191/blocking.py @@ -9,6 +9,7 @@ import logging from slixmpp import Iq +from slixmpp import coroutine_wrapper from slixmpp.plugins import BasePlugin from slixmpp.xmlstream.handler import Callback from slixmpp.xmlstream.matcher import StanzaPath @@ -45,14 +46,18 @@ class XEP_0191(BasePlugin): self.xmpp.remove_handler('Blocked Contact') self.xmpp.remove_handler('Unblocked Contact') - def get_blocked(self, ifrom=None, timeout=None, callback=None): + @coroutine_wrapper + def get_blocked(self, ifrom=None, timeout=None, callback=None, + coroutine=False): iq = self.xmpp.Iq() iq['type'] = 'get' iq['from'] = ifrom iq.enable('blocklist') - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, coroutine=coroutine) - def block(self, jids, ifrom=None, timeout=None, callback=None): + @coroutine_wrapper + def block(self, jids, ifrom=None, timeout=None, callback=None, + coroutine=False): iq = self.xmpp.Iq() iq['type'] = 'set' iq['from'] = ifrom @@ -61,9 +66,11 @@ class XEP_0191(BasePlugin): jids = [jids] iq['block']['items'] = jids - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, coroutine=coroutine) - def unblock(self, jids=None, ifrom=None, timeout=None, callback=None): + @coroutine_wrapper + def unblock(self, jids=None, ifrom=None, timeout=None, callback=None, + coroutine=False): iq = self.xmpp.Iq() iq['type'] = 'set' iq['from'] = ifrom @@ -74,7 +81,7 @@ class XEP_0191(BasePlugin): jids = [jids] iq['unblock']['items'] = jids - return iq.send(timeout=timeout, callback=callback) + return iq.send(timeout=timeout, callback=callback, coroutine=coroutine) def _handle_blocked(self, iq): self.xmpp.event('blocked', iq) -- cgit v1.2.3