XEP-0280: wrap functions with coroutine_wrapper

This commit is contained in:
mathieui 2015-02-23 19:33:52 +01:00
parent 6e8235544c
commit f795ac02e3
No known key found for this signature in database
GPG Key ID: C59F84CEEFD616E3

View File

@ -9,6 +9,7 @@
import logging import logging
import slixmpp import slixmpp
from slixmpp import coroutine_wrapper
from slixmpp.stanza import Message, Iq from slixmpp.stanza import Message, Iq
from slixmpp.xmlstream.handler import Callback from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath from slixmpp.xmlstream.matcher import StanzaPath
@ -66,20 +67,22 @@ class XEP_0280(BasePlugin):
def _handle_carbon_sent(self, msg): def _handle_carbon_sent(self, msg):
self.xmpp.event('carbon_sent', msg) self.xmpp.event('carbon_sent', msg)
@coroutine_wrapper
def enable(self, ifrom=None, timeout=None, callback=None, def enable(self, ifrom=None, timeout=None, callback=None,
timeout_callback=None): timeout_callback=None, coroutine=False):
iq = self.xmpp.Iq() iq = self.xmpp.Iq()
iq['type'] = 'set' iq['type'] = 'set'
iq['from'] = ifrom iq['from'] = ifrom
iq.enable('carbon_enable') iq.enable('carbon_enable')
return iq.send(timeout_callback=timeout_callback, timeout=timeout, return iq.send(timeout_callback=timeout_callback, timeout=timeout,
callback=callback) callback=callback, coroutine=coroutine)
@coroutine_wrapper
def disable(self, ifrom=None, timeout=None, callback=None, def disable(self, ifrom=None, timeout=None, callback=None,
timeout_callback=None): timeout_callback=None, coroutine=False):
iq = self.xmpp.Iq() iq = self.xmpp.Iq()
iq['type'] = 'set' iq['type'] = 'set'
iq['from'] = ifrom iq['from'] = ifrom
iq.enable('carbon_disable') iq.enable('carbon_disable')
return iq.send(timeout_callback=timeout_callback, timeout=timeout, return iq.send(timeout_callback=timeout_callback, timeout=timeout,
callback=callback) callback=callback, coroutine=coroutine)