diff --git a/de_web_plugin_private.h b/de_web_plugin_private.h index 312aa660f5..4ecf3a5d65 100644 --- a/de_web_plugin_private.h +++ b/de_web_plugin_private.h @@ -670,6 +670,7 @@ class DeRestPluginPrivate : public QObject int configureWifi(const ApiRequest &req, ApiResponse &rsp); int restoreWifiConfig(const ApiRequest &req, ApiResponse &rsp); int putWifiScanResult(const ApiRequest &req, ApiResponse &rsp); + int putWifiUpdated(const ApiRequest &req, ApiResponse &rsp); void configToMap(const ApiRequest &req, QVariantMap &map); void basicConfigToMap(QVariantMap &map); diff --git a/rest_configuration.cpp b/rest_configuration.cpp index 7797c2d600..30026cc113 100644 --- a/rest_configuration.cpp +++ b/rest_configuration.cpp @@ -356,6 +356,11 @@ int DeRestPluginPrivate::handleConfigurationApi(const ApiRequest &req, ApiRespon { return putWifiScanResult(req, rsp); } + // PUT /api//config/wifi/updated + else if ((req.path.size() == 5) && (req.hdr.method() == "PUT") && (req.path[2] == "config") && (req.path[3] == "wifi") && (req.path[4] == "updated")) + { + return putWifiUpdated(req, rsp); + } // PUT, PATCH /api//config else if ((req.path.size() == 3) && (req.hdr.method() == "PUT" || req.hdr.method() == "PATCH") && (req.path[2] == "config")) { @@ -2392,15 +2397,29 @@ int DeRestPluginPrivate::putWifiScanResult(const ApiRequest &req, ApiResponse &r return REQ_READY_SEND; } +/*! PUT /api/config/wifi/updated (wifi service notifications) + \return REQ_READY_SEND + REQ_NOT_HANDLED */ +int DeRestPluginPrivate::putWifiUpdated(const ApiRequest &req, ApiResponse &rsp) { + QHostAddress localHost(QHostAddress::LocalHost); + rsp.httpStatus = HttpStatusForbidden; + if (req.sock->peerAddress() != localHost) { + rsp.list.append(errorToMap(ERR_UNAUTHORIZED_USER, req.path.join("/"), "unauthorized user")); + return REQ_READY_SEND; } + rsp.httpStatus = HttpStatusOk; + if (!req.content.isEmpty()) { + DBG_Printf(DBG_HTTP, "wifi: %s\n", qPrintable(req.content)); + // TODO forward events } + return REQ_READY_SEND; } /*! POST /api//config/wifiscan