Files
biboumi/louloulibs/xmpp/adhoc_command.hpp
T
louiz’ 1e56c59e82 Include the Configure ad-hoc command on biboumi's JID for fixed_irc_server
Because a jid like “freenode.example.org” is both the JID for the configured
IRC server, and biboumi’s JID.

fix #3175
2016-04-27 11:03:52 +02:00

48 lines
1.4 KiB
C++

#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() = default;
AdhocCommand(const AdhocCommand&) = default;
AdhocCommand(AdhocCommand&&) = default;
AdhocCommand& operator=(AdhocCommand&&) = delete;
AdhocCommand& operator=(const AdhocCommand&) = delete;
const std::string name;
bool is_admin_only() const;
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(XmppComponent&, AdhocSession& session, XmlNode& command_node);
void HelloStep1(XmppComponent&, AdhocSession& session, XmlNode& command_node);
void HelloStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node);
void Reload(XmppComponent&, AdhocSession& session, XmlNode& command_node);
#endif // ADHOC_COMMAND_HPP