Fixes #3432. Allow execute to be used with the meaning of 'next'.
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
72b355de8c
commit
412a9169bd
@ -96,24 +96,10 @@ class XEP_0050(BasePlugin):
|
|||||||
register_stanza_plugin(Iq, Command)
|
register_stanza_plugin(Iq, Command)
|
||||||
register_stanza_plugin(Command, Form, iterable=True)
|
register_stanza_plugin(Command, Form, iterable=True)
|
||||||
|
|
||||||
self.xmpp.add_event_handler('command_execute',
|
self.xmpp.add_event_handler('command', self._handle_command_all)
|
||||||
self._handle_command_start)
|
|
||||||
self.xmpp.add_event_handler('command_next',
|
|
||||||
self._handle_command_next)
|
|
||||||
self.xmpp.add_event_handler('command_cancel',
|
|
||||||
self._handle_command_cancel)
|
|
||||||
self.xmpp.add_event_handler('command_complete',
|
|
||||||
self._handle_command_complete)
|
|
||||||
|
|
||||||
def plugin_end(self):
|
def plugin_end(self):
|
||||||
self.xmpp.del_event_handler('command_execute',
|
self.xmpp.del_event_handler('command', self._handle_command_all)
|
||||||
self._handle_command_start)
|
|
||||||
self.xmpp.del_event_handler('command_next',
|
|
||||||
self._handle_command_next)
|
|
||||||
self.xmpp.del_event_handler('command_cancel',
|
|
||||||
self._handle_command_cancel)
|
|
||||||
self.xmpp.del_event_handler('command_complete',
|
|
||||||
self._handle_command_complete)
|
|
||||||
self.xmpp.remove_handler('Ad-Hoc Execute')
|
self.xmpp.remove_handler('Ad-Hoc Execute')
|
||||||
self.xmpp['xep_0030'].del_feature(feature=Command.namespace)
|
self.xmpp['xep_0030'].del_feature(feature=Command.namespace)
|
||||||
self.xmpp['xep_0030'].set_items(node=Command.namespace, items=tuple())
|
self.xmpp['xep_0030'].set_items(node=Command.namespace, items=tuple())
|
||||||
@ -201,8 +187,27 @@ class XEP_0050(BasePlugin):
|
|||||||
|
|
||||||
def _handle_command(self, iq):
|
def _handle_command(self, iq):
|
||||||
"""Raise command events based on the command action."""
|
"""Raise command events based on the command action."""
|
||||||
|
self.xmpp.event('command', iq)
|
||||||
self.xmpp.event('command_%s' % iq['command']['action'], iq)
|
self.xmpp.event('command_%s' % iq['command']['action'], iq)
|
||||||
|
|
||||||
|
def _handle_command_all(self, iq: Iq) -> None:
|
||||||
|
action = iq['command']['action']
|
||||||
|
sessionid = iq['command']['sessionid']
|
||||||
|
session = self.sessions.get(sessionid)
|
||||||
|
|
||||||
|
if session is None:
|
||||||
|
return self._handle_command_start(iq)
|
||||||
|
|
||||||
|
if action in ('next', 'execute'):
|
||||||
|
return self._handle_command_next(iq)
|
||||||
|
if action == 'prev':
|
||||||
|
return self._handle_command_prev(iq)
|
||||||
|
if action == 'complete':
|
||||||
|
return self._handle_command_complete(iq)
|
||||||
|
if action == 'cancel':
|
||||||
|
return self._handle_command_cancel(iq)
|
||||||
|
return None
|
||||||
|
|
||||||
def _handle_command_start(self, iq):
|
def _handle_command_start(self, iq):
|
||||||
"""
|
"""
|
||||||
Process an initial request to execute a command.
|
Process an initial request to execute a command.
|
||||||
|
Loading…
Reference in New Issue
Block a user