XEP 0050¶
Stanza elements¶
Slixmpp: The Slick XMPP Library Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout This file is part of Slixmpp.
See the file LICENSE for copying permission.
- class slixmpp.plugins.xep_0050.stanza.Command(xml=None, parent=None)[source]¶
XMPP’s Adhoc Commands provides a generic workflow mechanism for interacting with applications. The result is similar to menu selections and multi-step dialogs in normal desktop applications. Clients do not need to know in advance what commands are provided by any particular application or agent. While adhoc commands provide similar functionality to Jabber-RPC, adhoc commands are used primarily for human interaction.
Also see <http://xmpp.org/extensions/xep-0050.html>
Example command stanzas:
<iq type="set"> <command xmlns="http://jabber.org/protocol/commands" node="run_foo" action="execute" /> </iq> <iq type="result"> <command xmlns="http://jabber.org/protocol/commands" node="run_foo" sessionid="12345" status="executing"> <actions> <complete /> </actions> <note type="info">Information!</note> <x xmlns="jabber:x:data"> <field var="greeting" type="text-single" label="Greeting" /> </x> </command> </iq>
Stanza Interface:
action -- The action to perform. actions -- The set of allowable next actions. node -- The node associated with the command. notes -- A list of tuples for informative notes. sessionid -- A unique identifier for a command session. status -- May be one of: canceled, completed, or executing.
- actions = {'cancel', 'complete', 'execute', 'next', 'prev'}¶
- add_note(msg='', ntype='info')[source]¶
Add a single note annotation to the command.
- Arguments:
msg – A human readable message. ntype – One of: ‘info’, ‘warning’, ‘error’
- get_action()[source]¶
Return the value of the action attribute.
If the Iq stanza’s type is “set” then use a default value of “execute”.
- get_notes()[source]¶
Return a list of note information.
- Example:
- [(‘info’, ‘Some informative data’),
(‘warning’, ‘Use caution’), (‘error’, ‘The command ran, but had errors’)]
- interfaces = {'action', 'actions', 'node', 'notes', 'sessionid', 'status'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attrib
value of any registered stanza plugins.
- name = 'command'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object for<message />
would usename = 'message'
.
- namespace = 'http://jabber.org/protocol/commands'¶
The XML namespace for the element. Given
<foo xmlns="bar" />
, thennamespace = "bar"
should be used. The default namespace isjabber:client
since this is being used in an XMPP library.
- next_actions = {'complete', 'next', 'prev'}¶
- plugin_attrib = 'command'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- set_actions(values)[source]¶
Assign the set of allowable next actions.
- Parameters
values – A list containing any combination of: ‘prev’, ‘next’, and ‘complete’
- set_notes(notes)[source]¶
Add multiple notes to the command result.
Each note is a tuple, with the first item being one of: ‘info’, ‘warning’, or ‘error’, and the second item being any human readable message.
- Example:
- [(‘info’, ‘Some informative data’),
(‘warning’, ‘Use caution’), (‘error’, ‘The command ran, but had errors’)]
- Arguments:
notes – A list of tuples of note information.
- statuses = {'canceled', 'completed', 'executing'}¶