summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-02-23 19:15:18 +0100
committermathieui <mathieui@mathieui.net>2015-02-24 22:46:04 +0100
commitea5615f236bd80fb4217398977833ca790cbef71 (patch)
tree71f42ef6d080948c415f64602cd0c4a51ffb2442
parent69da1c1d7cf7a1c0dbbeeb83f528b4e5f5b5be0c (diff)
downloadslixmpp-ea5615f236bd80fb4217398977833ca790cbef71.tar.gz
slixmpp-ea5615f236bd80fb4217398977833ca790cbef71.tar.bz2
slixmpp-ea5615f236bd80fb4217398977833ca790cbef71.tar.xz
slixmpp-ea5615f236bd80fb4217398977833ca790cbef71.zip
XEP-0084: wrap functions with coroutine_wrapper
-rw-r--r--slixmpp/plugins/xep_0084/avatar.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/slixmpp/plugins/xep_0084/avatar.py b/slixmpp/plugins/xep_0084/avatar.py
index 2bae765a..9216bdf0 100644
--- a/slixmpp/plugins/xep_0084/avatar.py
+++ b/slixmpp/plugins/xep_0084/avatar.py
@@ -15,6 +15,7 @@ from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.xmlstream import register_stanza_plugin, JID
from slixmpp.plugins.xep_0084 import stanza, Data, MetaData
+from slixmpp import coroutine_wrapper
log = logging.getLogger(__name__)
@@ -44,26 +45,30 @@ class XEP_0084(BasePlugin):
def generate_id(self, data):
return hashlib.sha1(data).hexdigest()
- def retrieve_avatar(self, jid, id, url=None, ifrom=None,
- callback=None, timeout=None):
+ @coroutine_wrapper
+ def retrieve_avatar(self, jid, id, url=None, ifrom=None, callback=None,
+ timeout=None, coroutine=False):
return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id,
- ifrom=ifrom,
- callback=callback,
- timeout=timeout)
+ ifrom=ifrom, callback=callback,
+ timeout=timeout,
+ coroutine=coroutine)
+ @coroutine_wrapper
def publish_avatar(self, data, ifrom=None, callback=None,
- timeout=None):
+ timeout=None, coroutine=False):
payload = Data()
payload['value'] = data
return self.xmpp['xep_0163'].publish(payload,
id=self.generate_id(data),
ifrom=ifrom,
callback=callback,
- timeout=timeout)
+ timeout=timeout,
+ coroutine=coroutine)
+ @coroutine_wrapper
def publish_avatar_metadata(self, items=None, pointers=None,
- ifrom=None,
- callback=None, timeout=None):
+ ifrom=None, callback=None, timeout=None,
+ coroutine=False):
metadata = MetaData()
if items is None:
items = []
@@ -83,9 +88,11 @@ class XEP_0084(BasePlugin):
id=info['id'],
ifrom=ifrom,
callback=callback,
- timeout=timeout)
+ timeout=timeout,
+ coroutine=coroutine)
- def stop(self, ifrom=None, callback=None, timeout=None):
+ @coroutine_wrapper
+ def stop(self, ifrom=None, callback=None, timeout=None, coroutine=False):
"""
Clear existing avatar metadata information to stop notifications.
@@ -102,4 +109,5 @@ class XEP_0084(BasePlugin):
node=MetaData.namespace,
ifrom=ifrom,
callback=callback,
- timeout=timeout)
+ timeout=timeout,
+ coroutine=coroutine)