diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-05-27 01:01:38 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-05-30 03:58:17 +0200 |
commit | eb9a20187098185cc10ad192e91a90dbba12633a (patch) | |
tree | b8bc59e7120d0c965642de875a8498f50bfd9da4 /src/xmpp/adhoc_command.hpp | |
parent | 1c93afc9a7ec33d90c81062c3f1077b5cf84c212 (diff) | |
download | biboumi-eb9a20187098185cc10ad192e91a90dbba12633a.tar.gz biboumi-eb9a20187098185cc10ad192e91a90dbba12633a.tar.bz2 biboumi-eb9a20187098185cc10ad192e91a90dbba12633a.tar.xz biboumi-eb9a20187098185cc10ad192e91a90dbba12633a.zip |
Implement the support for adhoc commands
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
Diffstat (limited to 'src/xmpp/adhoc_command.hpp')
-rw-r--r-- | src/xmpp/adhoc_command.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
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 <xmpp/adhoc_session.hpp> + +#include <functional> +#include <string> + +class AdhocCommand +{ + friend class AdhocSession; +public: + AdhocCommand(std::vector<AdhocStep>&& 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 <command/> XmlNode and calling + * methods of an AdhocSession. + */ + std::vector<AdhocStep> 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 |