From 28b518107b065acf45b8a9b486ed47e1b6a01131 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 29 Oct 2017 21:48:53 +0100 Subject: [PATCH] bump api version and clean up config methods --- guh.pri | 2 +- libguh-core/jsonrpc/configurationhandler.cpp | 21 +++++++------------- libguh-core/jsonrpc/configurationhandler.h | 1 - tests/auto/api.json | 20 +++++++++++++++---- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/guh.pri b/guh.pri index c72b65be..dfd9af8c 100644 --- a/guh.pri +++ b/guh.pri @@ -6,7 +6,7 @@ GUH_PLUGINS_PATH=/usr/lib/$$system('dpkg-architecture -q DEB_HOST_MULTIARCH')/gu # define protocol versions JSON_PROTOCOL_VERSION_MAJOR=0 -JSON_PROTOCOL_VERSION_MINOR=51 +JSON_PROTOCOL_VERSION_MINOR=52 REST_API_VERSION=1 DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \ diff --git a/libguh-core/jsonrpc/configurationhandler.cpp b/libguh-core/jsonrpc/configurationhandler.cpp index 9f06571d..1e49e36a 100644 --- a/libguh-core/jsonrpc/configurationhandler.cpp +++ b/libguh-core/jsonrpc/configurationhandler.cpp @@ -99,6 +99,9 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): QVariantList webSocketServerConfigurations; webSocketServerConfigurations.append(JsonTypes::serverConfigurationRef()); returns.insert("webSocketServerConfigurations", webSocketServerConfigurations); + QVariantMap cloudConfiguration; + cloudConfiguration.insert("enabled", JsonTypes::basicTypeToString(JsonTypes::Bool)); + returns.insert("cloud", cloudConfiguration); setReturns("GetConfigurations", returns); params.clear(); returns.clear(); @@ -164,12 +167,6 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent): returns.insert("configurationError", JsonTypes::configurationErrorRef()); setReturns("DeleteWebServerConfiguration", returns); - params.clear(); returns.clear(); - setDescription("GetCloudEnabled", "Returns whether the cloud connection is enabled or disabled in the settings."); - setParams("GetCloudEnabled", params); - returns.insert("enabled", JsonTypes::basicTypeToString(QVariant::Bool)); - setReturns("GetCloudEnabled", returns); - params.clear(); returns.clear(); setDescription("SetCloudEnabled", "Sets whether the cloud connection is enabled or disabled in the settings."); params.insert("enabled", JsonTypes::basicTypeToString(QVariant::Bool)); @@ -248,6 +245,10 @@ JsonReply *ConfigurationHandler::GetConfigurations(const QVariantMap ¶ms) co } returns.insert("webSocketServerConfigurations", webSocketServerConfigs); + QVariantMap cloudConfig; + cloudConfig.insert("enabled", GuhCore::instance()->configuration()->cloudEnabled()); + returns.insert("cloud", cloudConfig); + return createReply(returns); } @@ -402,14 +403,6 @@ JsonReply *ConfigurationHandler::DeleteWebSocketServerConfiguration(const QVaria return createReply(statusToReply(GuhConfiguration::ConfigurationErrorNoError)); } -JsonReply *ConfigurationHandler::GetCloudEnabled(const QVariantMap ¶ms) const -{ - Q_UNUSED(params) - QVariantMap ret; - ret.insert("enabled", GuhCore::instance()->configuration()->cloudEnabled()); - return createReply(ret); -} - JsonReply *ConfigurationHandler::SetCloudEnabled(const QVariantMap ¶ms) const { bool enabled = params.value("enabled").toBool(); diff --git a/libguh-core/jsonrpc/configurationhandler.h b/libguh-core/jsonrpc/configurationhandler.h index c062e1db..5a1bad9a 100644 --- a/libguh-core/jsonrpc/configurationhandler.h +++ b/libguh-core/jsonrpc/configurationhandler.h @@ -47,7 +47,6 @@ public: Q_INVOKABLE JsonReply *DeleteWebServerConfiguration(const QVariantMap ¶ms) const; Q_INVOKABLE JsonReply *SetWebSocketServerConfiguration(const QVariantMap ¶ms) const; Q_INVOKABLE JsonReply *DeleteWebSocketServerConfiguration(const QVariantMap ¶ms) const; - Q_INVOKABLE JsonReply *GetCloudEnabled(const QVariantMap ¶ms) const; Q_INVOKABLE JsonReply *SetCloudEnabled(const QVariantMap ¶ms) const; signals: diff --git a/tests/auto/api.json b/tests/auto/api.json index c95c6d10..74c0075a 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -1,4 +1,4 @@ -0.51 +0.52 { "methods": { "Actions.ExecuteAction": { @@ -80,6 +80,9 @@ "serverUuid": "Uuid", "timeZone": "String" }, + "cloud": { + "enabled": "Bool" + }, "tcpServerConfigurations": [ "$ref:ServerConfiguration" ], @@ -101,6 +104,15 @@ ] } }, + "Configuration.SetCloudEnabled": { + "description": "Sets whether the cloud connection is enabled or disabled in the settings.", + "params": { + "enabled": "Bool" + }, + "returns": { + "configurationError": "$ref:ConfigurationError" + } + }, "Configuration.SetLanguage": { "description": "Sets the server language to the given language. See also: \"GetAvailableLanguages\"", "params": { @@ -458,11 +470,11 @@ "JSONRPC.SetupRemoteAccess": { "description": "Setup the remote connection by providing AWS token information", "params": { - "authToken": "String", - "cognitoId": "String", - "idToken": "String" + "idToken": "String", + "userId": "String" }, "returns": { + "message": "String", "status": "Int" } },