adhoc_command.hpp 1.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#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;

26 27
  bool is_admin_only() const;

28 29 30 31 32 33 34 35 36 37
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;
};

38 39 40 41 42
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 DisconnectUserStep1(XmppComponent*, AdhocSession& session, XmlNode& command_node);
void DisconnectUserStep2(XmppComponent*, AdhocSession& session, XmlNode& command_node);
louiz’'s avatar
louiz’ committed
43
void Reload(XmppComponent*, AdhocSession& session, XmlNode& command_node);
44 45

#endif // ADHOC_COMMAND_HPP