From eb9a20187098185cc10ad192e91a90dbba12633a Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 27 May 2014 01:01:38 +0200 Subject: Implement the support for adhoc commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have two basic example commands. But it’s not entirely finished because there are some error checks that we don’t do. ref #2521 --- src/xmpp/adhoc_command.hpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/xmpp/adhoc_command.hpp (limited to 'src/xmpp/adhoc_command.hpp') diff --git a/src/xmpp/adhoc_command.hpp b/src/xmpp/adhoc_command.hpp new file mode 100644 index 0000000..59a3cd6 --- /dev/null +++ b/src/xmpp/adhoc_command.hpp @@ -0,0 +1,40 @@ +#ifndef ADHOC_COMMAND_HPP +# define ADHOC_COMMAND_HPP + +/** + * Describe an ad-hoc command. + * + * Can only have zero or one step for now. When execution is requested, it + * can return a result immediately, or provide a form to be filled, and + * provide a result once the filled form is received. + */ + +#include + +#include +#include + +class AdhocCommand +{ + friend class AdhocSession; +public: + AdhocCommand(std::vector&& callback, const std::string& name, const bool admin_only); + ~AdhocCommand(); + + const std::string name; + +private: + /** + * A command may have one or more steps. Each step is a different + * callback, inserting things into a XmlNode and calling + * methods of an AdhocSession. + */ + std::vector callbacks; + const bool admin_only; +}; + +void PingStep1(AdhocSession& session, XmlNode& command_node); +void HelloStep1(AdhocSession& session, XmlNode& command_node); +void HelloStep2(AdhocSession& session, XmlNode& command_node); + +#endif // ADHOC_COMMAND_HPP -- cgit v1.2.3