XEP-0257: wrap functions with coroutine_wrapper
This commit is contained in:
parent
cd7ff685fb
commit
4da870fd19
1 changed files with 13 additions and 8 deletions
|
@ -10,6 +10,7 @@ import logging
|
|||
|
||||
from slixmpp import Iq
|
||||
from slixmpp.plugins import BasePlugin
|
||||
from slixmpp import coroutine_wrapper
|
||||
from slixmpp.xmlstream import register_stanza_plugin
|
||||
from slixmpp.plugins.xep_0257 import stanza, Certs
|
||||
from slixmpp.plugins.xep_0257 import AppendCert, DisableCert, RevokeCert
|
||||
|
@ -31,35 +32,39 @@ class XEP_0257(BasePlugin):
|
|||
register_stanza_plugin(Iq, DisableCert)
|
||||
register_stanza_plugin(Iq, RevokeCert)
|
||||
|
||||
def get_certs(self, ifrom=None, timeout=None, callback=None):
|
||||
@coroutine_wrapper
|
||||
def get_certs(self, ifrom=None, timeout=None, callback=None, coroutine=False):
|
||||
iq = self.xmpp.Iq()
|
||||
iq['type'] = 'get'
|
||||
iq['from'] = ifrom
|
||||
iq.enable('sasl_certs')
|
||||
return iq.send(timeout=timeout, callback=callback)
|
||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
||||
|
||||
@coroutine_wrapper
|
||||
def add_cert(self, name, cert, allow_management=True, ifrom=None,
|
||||
timeout=None, callback=None):
|
||||
timeout=None, callback=None, coroutine=False):
|
||||
iq = self.xmpp.Iq()
|
||||
iq['type'] = 'set'
|
||||
iq['from'] = ifrom
|
||||
iq['sasl_cert_append']['name'] = name
|
||||
iq['sasl_cert_append']['x509cert'] = cert
|
||||
iq['sasl_cert_append']['cert_management'] = allow_management
|
||||
return iq.send(timeout=timeout, callback=callback)
|
||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
||||
|
||||
def disable_cert(self, name, ifrom=None,
|
||||
@coroutine_wrapper
|
||||
def disable_cert(self, name, ifrom=None, coroutine=False,
|
||||
timeout=None, callback=None):
|
||||
iq = self.xmpp.Iq()
|
||||
iq['type'] = 'set'
|
||||
iq['from'] = ifrom
|
||||
iq['sasl_cert_disable']['name'] = name
|
||||
return iq.send(timeout=timeout, callback=callback)
|
||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
||||
|
||||
def revoke_cert(self, name, ifrom=None,
|
||||
@coroutine_wrapper
|
||||
def revoke_cert(self, name, ifrom=None, coroutine=False,
|
||||
timeout=None, callback=None):
|
||||
iq = self.xmpp.Iq()
|
||||
iq['type'] = 'set'
|
||||
iq['from'] = ifrom
|
||||
iq['sasl_cert_revoke']['name'] = name
|
||||
return iq.send(timeout=timeout, callback=callback)
|
||||
return iq.send(timeout=timeout, callback=callback, coroutine=coroutine)
|
||||
|
|
Loading…
Reference in a new issue