Skip to content

Commit

Permalink
Merge pull request #14 from oblivioncth/bugfix/ultimate_qemu_detection
Browse files Browse the repository at this point in the history
Make known daemon detection more flexible
  • Loading branch information
oblivioncth authored May 3, 2023
2 parents d243a32 + 535c1b5 commit 2796387
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
17 changes: 1 addition & 16 deletions lib/include/fp/fp-json.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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:
Expand Down
18 changes: 10 additions & 8 deletions lib/src/fp-json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -331,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))
Expand Down

0 comments on commit 2796387

Please sign in to comment.