From 9b1288fcb99cba4d4ea458d8f9f0583b0de5c75c Mon Sep 17 00:00:00 2001
From: Tobias Triffterer <tobias@ep1.ruhr-uni-bochum.de>
Date: Fri, 23 Apr 2021 23:55:46 +0200
Subject: [PATCH] Implement Error Command
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This adds the necessary “glue” to the library to support the eror
command and extends all switches accordingly.
---
 src/command.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/command.cpp b/src/command.cpp
index b001644..777ec66 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -63,7 +63,7 @@ Command Command::fromString(const QString& source)
                           : QString();
 
 
-    if (token.isEmpty() && action != Action::queryServerInformation && action != Action::authenticate) {
+    if (token.isEmpty() && action != Action::queryServerInformation && action != Action::authenticate && action != Action::error) {
         logError("JSON object does not contain token although it is required for requested action.");
         return Command();
     }
@@ -84,6 +84,8 @@ Command Command::fromString(const QString& source)
         case Action::stopAdc:
         case Action::clearHistogram:
             return Command(action, Arguments(), token);
+        case Action::error:
+            return parseError(rootobj);
         // Not yet implemented:
         case Action::queryServerInformation:
         case Action::updateExperimentState:
@@ -128,6 +130,8 @@ Action Command::parseActionString(const QString& string)
         return Action::fillHistogram;
     if (string == QStringLiteral("clearHistogram"))
         return Action::clearHistogram;
+    if (string == QStringLiteral("error"))
+        return Action::error;
 
     logError(QStringLiteral("Action \"") + string + QStringLiteral(" unknown."));
     return Action::invalid;
@@ -242,6 +246,8 @@ QString Command::getActionString(const Action action)
             return QStringLiteral("fillHistogram");
         case Action::clearHistogram:
             return QStringLiteral("clearHistogram");
+        case Action::error:
+            return QStringLiteral("error");
         case Action::invalid:
         default:
             return QString();
-- 
GitLab