diff --git a/debian/control b/debian/control index c5bbf4dd..43764632 100644 --- a/debian/control +++ b/debian/control @@ -162,7 +162,7 @@ Depends: ${shlibs:Depends}, Replaces: libguh1 Provides: nymea-update-plugin-api-1, nymea-zeroconf-plugin-api-1, - nymea-system-plugin-api-1 + nymea-system-plugin-api-2 Description: An open source IoT server - core library The nymea daemon is a plugin based IoT (Internet of Things) server. The server works like a translator for devices, things and services and diff --git a/libnymea-core/jsonrpc/systemhandler.cpp b/libnymea-core/jsonrpc/systemhandler.cpp index 61ae5f29..81a2396d 100644 --- a/libnymea-core/jsonrpc/systemhandler.cpp +++ b/libnymea-core/jsonrpc/systemhandler.cpp @@ -47,7 +47,7 @@ SystemHandler::SystemHandler(Platform *platform, QObject *parent): // Methods QString description; QVariantMap params; QVariantMap returns; description = "Get the list of capabilites on this system. The property \"powerManagement\" indicates whether " - "rebooting or shutting down is supported on this system. The property \"updateManagement indicates " + "restarting nymea and rebooting or shutting down is supported on this system. The property \"updateManagement indicates " "whether system update features are available in this system. The property \"timeManagement\" " "indicates whether the system time can be configured on this system. Note that GetTime will be " "available in any case."; @@ -56,6 +56,11 @@ SystemHandler::SystemHandler(Platform *platform, QObject *parent): returns.insert("timeManagement", enumValueName(Bool)); registerMethod("GetCapabilities", description, params, returns); + params.clear(); returns.clear(); + description = "Initiate a restart of the nymea service. The return value will indicate whether the procedure has been initiated successfully."; + returns.insert("success", enumValueName(Bool)); + registerMethod("Restart", description, params, returns); + params.clear(); returns.clear(); description = "Initiate a reboot of the system. The return value will indicate whether the procedure has been initiated successfully."; returns.insert("success", enumValueName(Bool)); @@ -283,6 +288,15 @@ JsonReply *SystemHandler::GetCapabilities(const QVariantMap ¶ms) return createReply(data); } +JsonReply *SystemHandler::Restart(const QVariantMap ¶ms) const +{ + Q_UNUSED(params) + bool status = m_platform->systemController()->restart(); + QVariantMap returns; + returns.insert("success", status); + return createReply(returns); +} + JsonReply *SystemHandler::Reboot(const QVariantMap ¶ms) const { Q_UNUSED(params) diff --git a/libnymea-core/jsonrpc/systemhandler.h b/libnymea-core/jsonrpc/systemhandler.h index d5b1833c..ee8e2043 100644 --- a/libnymea-core/jsonrpc/systemhandler.h +++ b/libnymea-core/jsonrpc/systemhandler.h @@ -51,6 +51,7 @@ public: Q_INVOKABLE JsonReply *GetCapabilities(const QVariantMap ¶ms); + Q_INVOKABLE JsonReply *Restart(const QVariantMap ¶ms) const; Q_INVOKABLE JsonReply *Reboot(const QVariantMap ¶ms) const; Q_INVOKABLE JsonReply *Shutdown(const QVariantMap ¶ms) const; diff --git a/libnymea/platform/platformsystemcontroller.cpp b/libnymea/platform/platformsystemcontroller.cpp index 98dea803..2666ff3e 100644 --- a/libnymea/platform/platformsystemcontroller.cpp +++ b/libnymea/platform/platformsystemcontroller.cpp @@ -42,6 +42,11 @@ bool PlatformSystemController::powerManagementAvailable() const return false; } +bool PlatformSystemController::restart() +{ + return false; +} + bool PlatformSystemController::reboot() { return false; diff --git a/libnymea/platform/platformsystemcontroller.h b/libnymea/platform/platformsystemcontroller.h index c9fa8f15..9206d475 100644 --- a/libnymea/platform/platformsystemcontroller.h +++ b/libnymea/platform/platformsystemcontroller.h @@ -42,6 +42,7 @@ public: virtual ~PlatformSystemController() = default; virtual bool powerManagementAvailable() const; + virtual bool restart(); virtual bool reboot(); virtual bool shutdown(); diff --git a/tests/auto/api.json b/tests/auto/api.json index 9d48436d..bb399bdd 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -1709,7 +1709,7 @@ } }, "System.GetCapabilities": { - "description": "Get the list of capabilites on this system. The property \"powerManagement\" indicates whether rebooting or shutting down is supported on this system. The property \"updateManagement indicates whether system update features are available in this system. The property \"timeManagement\" indicates whether the system time can be configured on this system. Note that GetTime will be available in any case.", + "description": "Get the list of capabilites on this system. The property \"powerManagement\" indicates whether restarting nymea and rebooting or shutting down is supported on this system. The property \"updateManagement indicates whether system update features are available in this system. The property \"timeManagement\" indicates whether the system time can be configured on this system. Note that GetTime will be available in any case.", "params": { }, "returns": { @@ -1781,6 +1781,14 @@ "success": "Bool" } }, + "System.Restart": { + "description": "Initiate a restart of the nymea service. The return value will indicate whether the procedure has been initiated successfully.", + "params": { + }, + "returns": { + "success": "Bool" + } + }, "System.RollbackPackages": { "description": "Starts a rollback. Returns true if the rollback has been started successfully. Before calling this method, clients should check whether the package can be rolled back (canRollback set to true).", "params": {