summaryrefslogtreecommitdiff
path: root/src/xmpp/adhoc_command.hpp
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-06-24 09:21:31 +0200
committerJonas Smedegaard <dr@jones.dk>2017-06-24 09:21:31 +0200
commitc21cbbf9667991d2b928562a9c199e625d3f9bba (patch)
treeffd5e6895a578102ed9055fbb02a88031154ae0b /src/xmpp/adhoc_command.hpp
parentde62b6456bebd130f98ce6192cd63ff42e654fac (diff)
parent23a3372144215c9ba7a30d599164677284813fa4 (diff)
downloadbiboumi-c21cbbf9667991d2b928562a9c199e625d3f9bba.tar.gz
biboumi-c21cbbf9667991d2b928562a9c199e625d3f9bba.tar.bz2
biboumi-c21cbbf9667991d2b928562a9c199e625d3f9bba.tar.xz
biboumi-c21cbbf9667991d2b928562a9c199e625d3f9bba.zip
New upstream version 5.0
Diffstat (limited to 'src/xmpp/adhoc_command.hpp')
-rw-r--r--src/xmpp/adhoc_command.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/xmpp/adhoc_command.hpp b/src/xmpp/adhoc_command.hpp
new file mode 100644
index 0000000..c00d9e6
--- /dev/null
+++ b/src/xmpp/adhoc_command.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+/**
+ * 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>&& callbacks, 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);