From 855857239fd8e78a23eb87c85cfef4a039b566e3 Mon Sep 17 00:00:00 2001 From: Christian Heimlich Date: Sun, 30 Apr 2023 07:57:34 -0400 Subject: [PATCH 1/2] Make known daemon detection more flexible --- lib/src/fp-json.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/fp-json.cpp b/lib/src/fp-json.cpp index 02bcb72..0609078 100644 --- a/lib/src/fp-json.cpp +++ b/lib/src/fp-json.cpp @@ -278,10 +278,12 @@ Qx::GenericError Json::ServicesReader::parseDocument(const QJsonDocument& servic /* NOTE: If for some reason this list becomes large, use a hash instead * (e.g. if(hash.contains("NAME")){ recognizedDaemons.setFlag(hash["NAME]); } ) */ - if(daemonBuffer.name == Object_Daemon::KNOWN_DAEMON_DOCKER_NAME) - targetServices->recognizedDaemons.setFlag(KnownDaemon::Docker); - else if(daemonBuffer.name == Object_Daemon::KNOWN_DAEMON_QEMU_NAME) + if(daemonBuffer.name.contains("qemu", Qt::CaseInsensitive) || + daemonBuffer.filename.contains("qemu", Qt::CaseInsensitive)) targetServices->recognizedDaemons.setFlag(KnownDaemon::Qemu); + else if(daemonBuffer.name.contains("docker", Qt::CaseInsensitive) || + daemonBuffer.filename.contains("docker", Qt::CaseInsensitive)) + targetServices->recognizedDaemons.setFlag(KnownDaemon::Docker); } // Get starts From 535c1b5ed2c9e465630f174f8281d082df366678 Mon Sep 17 00:00:00 2001 From: Christian Heimlich Date: Sun, 30 Apr 2023 07:58:53 -0400 Subject: [PATCH 2/2] Combine JSON Object_Daemon and Object_Server --- lib/include/fp/fp-json.h | 17 +---------------- lib/src/fp-json.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/lib/include/fp/fp-json.h b/lib/include/fp/fp-json.h index 6713f5f..2260d3b 100644 --- a/lib/include/fp/fp-json.h +++ b/lib/include/fp/fp-json.h @@ -65,7 +65,7 @@ class FP_FP_EXPORT Json static inline const QString KEY_BROWSER_MODE_PROXY = "browserModeProxy"; }; - class Object_Server + class Object_ServerDaemon { public: static inline const QString KEY_NAME = "name"; @@ -83,21 +83,6 @@ class FP_FP_EXPORT Json static inline const QString KEY_ARGUMENTS = "arguments"; }; - class Object_Daemon - { - public: -/* NOTE: Unused since daemons/server are handled the same, maybe remove this - * - * static inline const QString KEY_NAME = "name"; - * static inline const QString KEY_PATH = "path"; - * static inline const QString KEY_FILENAME = "filename"; - * static inline const QString KEY_ARGUMENTS = "arguments"; - * static inline const QString KEY_KILL = "kill"; - */ - static inline const QString KNOWN_DAEMON_DOCKER_NAME = "Docker GameZip"; - static inline const QString KNOWN_DAEMON_QEMU_NAME = "QEMU GameZip"; - }; - class Object_Services { public: diff --git a/lib/src/fp-json.cpp b/lib/src/fp-json.cpp index 0609078..424c2db 100644 --- a/lib/src/fp-json.cpp +++ b/lib/src/fp-json.cpp @@ -333,21 +333,21 @@ Qx::GenericError Json::ServicesReader::parseServerDaemon(ServerDaemon& serverBuf Qx::GenericError valueError; // Get direct values - if((valueError = Qx::Json::checkedKeyRetrieval(serverBuffer.name, joServer, Object_Server::KEY_NAME)).isValid()) + if((valueError = Qx::Json::checkedKeyRetrieval(serverBuffer.name, joServer, Object_ServerDaemon::KEY_NAME)).isValid()) return valueError.setErrorLevel(Qx::GenericError::Critical); - if((valueError = Qx::Json::checkedKeyRetrieval(serverBuffer.path, joServer, Object_Server::KEY_PATH)).isValid()) + if((valueError = Qx::Json::checkedKeyRetrieval(serverBuffer.path, joServer, Object_ServerDaemon::KEY_PATH)).isValid()) return valueError.setErrorLevel(Qx::GenericError::Critical); - if((valueError = Qx::Json::checkedKeyRetrieval(serverBuffer.filename, joServer, Object_Server::KEY_FILENAME)).isValid()) + if((valueError = Qx::Json::checkedKeyRetrieval(serverBuffer.filename, joServer, Object_ServerDaemon::KEY_FILENAME)).isValid()) return valueError.setErrorLevel(Qx::GenericError::Critical); - if((valueError = Qx::Json::checkedKeyRetrieval(serverBuffer.kill, joServer, Object_Server::KEY_KILL)).isValid()) + if((valueError = Qx::Json::checkedKeyRetrieval(serverBuffer.kill, joServer, Object_ServerDaemon::KEY_KILL)).isValid()) return valueError.setErrorLevel(Qx::GenericError::Critical); // Get arguments QJsonArray jaArgs; - if((valueError = Qx::Json::checkedKeyRetrieval(jaArgs, joServer, Object_Server::KEY_ARGUMENTS)).isValid()) + if((valueError = Qx::Json::checkedKeyRetrieval(jaArgs, joServer, Object_ServerDaemon::KEY_ARGUMENTS)).isValid()) return valueError.setErrorLevel(Qx::GenericError::Critical); for(const QJsonValue& jvArg : qAsConst(jaArgs))