XEP-0050: wrap send_command() and get_commands() with coroutine_wrapper

(if flow=True in send_command, the result will still be using the
default callbacks and the function will return None)
This commit is contained in:
mathieui 2015-02-23 19:46:32 +01:00
parent 18a4978456
commit e034b31d6b
No known key found for this signature in database
GPG Key ID: C59F84CEEFD616E3

View File

@ -10,7 +10,7 @@ import logging
import time import time
from slixmpp import Iq from slixmpp import Iq
from slixmpp.exceptions import IqError from slixmpp.exceptions import XMPPError
from slixmpp.xmlstream.handler import Callback from slixmpp.xmlstream.handler import Callback
from slixmpp.xmlstream.matcher import StanzaPath from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.xmlstream import register_stanza_plugin, JID from slixmpp.xmlstream import register_stanza_plugin, JID
@ -18,6 +18,7 @@ from slixmpp.plugins import BasePlugin
from slixmpp.plugins.xep_0050 import stanza from slixmpp.plugins.xep_0050 import stanza
from slixmpp.plugins.xep_0050 import Command from slixmpp.plugins.xep_0050 import Command
from slixmpp.plugins.xep_0004 import Form from slixmpp.plugins.xep_0004 import Form
from slixmpp import coroutine_wrapper
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -427,6 +428,7 @@ class XEP_0050(BasePlugin):
# ================================================================= # =================================================================
# Client side (command user) API # Client side (command user) API
@coroutine_wrapper
def get_commands(self, jid, **kwargs): def get_commands(self, jid, **kwargs):
""" """
Return a list of commands provided by a given JID. Return a list of commands provided by a given JID.
@ -452,6 +454,7 @@ class XEP_0050(BasePlugin):
node=Command.namespace, node=Command.namespace,
**kwargs) **kwargs)
@coroutine_wrapper
def send_command(self, jid, node, ifrom=None, action='execute', def send_command(self, jid, node, ifrom=None, action='execute',
payload=None, sessionid=None, flow=False, **kwargs): payload=None, sessionid=None, flow=False, **kwargs):
""" """