XEP-0054: wrap functions with coroutine_wrapper
This commit is contained in:
parent
ea5615f236
commit
3d243f7da5
@ -15,6 +15,7 @@ from slixmpp.xmlstream.handler import Callback
|
|||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.plugins import BasePlugin
|
from slixmpp.plugins import BasePlugin
|
||||||
from slixmpp.plugins.xep_0054 import VCardTemp, stanza
|
from slixmpp.plugins.xep_0054 import VCardTemp, stanza
|
||||||
|
from slixmpp import coroutine_wrapper
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -59,8 +60,9 @@ class XEP_0054(BasePlugin):
|
|||||||
def make_vcard(self):
|
def make_vcard(self):
|
||||||
return VCardTemp()
|
return VCardTemp()
|
||||||
|
|
||||||
|
@coroutine_wrapper
|
||||||
def get_vcard(self, jid=None, ifrom=None, local=None, cached=False,
|
def get_vcard(self, jid=None, ifrom=None, local=None, cached=False,
|
||||||
callback=None, timeout=None):
|
callback=None, timeout=None, coroutine=False):
|
||||||
if local is None:
|
if local is None:
|
||||||
if jid is not None and not isinstance(jid, JID):
|
if jid is not None and not isinstance(jid, JID):
|
||||||
jid = JID(jid)
|
jid = JID(jid)
|
||||||
@ -99,10 +101,11 @@ class XEP_0054(BasePlugin):
|
|||||||
iq['type'] = 'get'
|
iq['type'] = 'get'
|
||||||
iq.enable('vcard_temp')
|
iq.enable('vcard_temp')
|
||||||
|
|
||||||
iq.send(callback=callback, timeout=timeout)
|
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine)
|
||||||
|
|
||||||
|
@coroutine_wrapper
|
||||||
def publish_vcard(self, vcard=None, jid=None, ifrom=None,
|
def publish_vcard(self, vcard=None, jid=None, ifrom=None,
|
||||||
callback=None, timeout=None):
|
callback=None, timeout=None, coroutine=False):
|
||||||
self.api['set_vcard'](jid, None, ifrom, vcard)
|
self.api['set_vcard'](jid, None, ifrom, vcard)
|
||||||
if self.xmpp.is_component:
|
if self.xmpp.is_component:
|
||||||
return
|
return
|
||||||
@ -112,7 +115,7 @@ class XEP_0054(BasePlugin):
|
|||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['type'] = 'set'
|
iq['type'] = 'set'
|
||||||
iq.append(vcard)
|
iq.append(vcard)
|
||||||
return iq.send(callback=callback, timeout=timeout)
|
return iq.send(callback=callback, timeout=timeout, coroutine=coroutine)
|
||||||
|
|
||||||
def _handle_get_vcard(self, iq):
|
def _handle_get_vcard(self, iq):
|
||||||
if iq['type'] == 'result':
|
if iq['type'] == 'result':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user