From 0783eed3b23868d6020002f7ff97abaad330b5a1 Mon Sep 17 00:00:00 2001 From: Christian H Date: Thu, 7 Apr 2016 11:06:28 +0200 Subject: [PATCH] Remove dead code from sensors --- rest_sensors.cpp | 80 ------------------------------------------------ 1 file changed, 80 deletions(-) diff --git a/rest_sensors.cpp b/rest_sensors.cpp index 05f0e0b..6531916 100644 --- a/rest_sensors.cpp +++ b/rest_sensors.cpp @@ -90,16 +90,6 @@ int DeRestPluginPrivate::handleSensorsApi(ApiRequest &req, ApiResponse &rsp) { return changeSensorState(req, rsp); } - // GET /api//sensors//groupidentifiers - else if ((req.path.size() == 5) && (req.hdr.method() == "GET") && (req.path[4] == "groupidentifiers")) - { - return getGroupIdentifiers(req, rsp); - } - // PUT /api//sensors//recover - else if ((req.path.size() == 5) && (req.hdr.method() == "PUT") && (req.path[4] == "recover")) - { - return recoverSensor(req, rsp); - } return REQ_NOT_HANDLED; } @@ -1409,50 +1399,6 @@ int DeRestPluginPrivate::getDeletedSensors(const ApiRequest &req, ApiResponse &r return REQ_READY_SEND; } -/*! PUT /api//sensors//recover - \return REQ_READY_SEND - REQ_NOT_HANDLED - */ -int DeRestPluginPrivate::recoverSensor(const ApiRequest &req, ApiResponse &rsp) -{ - DBG_Assert(req.path.size() == 5); - - if (req.path.size() != 5) - { - return -1; - } - - const QString &id = req.path[3]; - - Sensor *s = getSensorNodeForId(id); - - if (s->deletedState() == Sensor::StateDeleted) - { - s->setDeletedState(Sensor::StateNormal); - - std::vector::iterator g = groups.begin(); - std::vector::iterator gend = groups.end(); - - for (; g != gend; ++g) - { - std::vector &v = g->m_deviceMemberships; - - if ((std::find(v.begin(), v.end(), id) != v.end()) && (g->state() == Group::StateDeleted)) - { - g->setState(Group::StateNormal); - } - } - } - - queSaveDb(DB_GROUPS | DB_SENSORS,DB_SHORT_SAVE_DELAY); - - QVariantMap rspItem; - rspItem["success"] = QString("sensor: " + id + " reactivated"); - rsp.list.append(rspItem); - rsp.httpStatus = HttpStatusOk; - return REQ_READY_SEND; -} - /*! Put all sensor parameters in a map. \return true - on success false - on error @@ -1567,29 +1513,3 @@ bool DeRestPluginPrivate::sensorToMap(const Sensor *sensor, QVariantMap &map) map["etag"] = etag; return true; } - -/*! GET /api//sensors//groupidentifiers - \return REQ_READY_SEND - REQ_NOT_HANDLED - */ -int DeRestPluginPrivate::getGroupIdentifiers(const ApiRequest &req, ApiResponse &rsp) -{ - QString id = req.path[3]; - Sensor *sensor = getSensorNodeForId(id); - - if (getGroupIdentifiers(sensor, sensor->fingerPrint().endpoint, 0)) - { - QVariantMap rspItem; - rspItem["success"] = QString("request send"); - rsp.list.append(rspItem); - rsp.httpStatus = HttpStatusOk; - } - else - { - QVariantMap rspItem; - rspItem["error"] = QString("send request failed"); - rsp.list.append(rspItem); - rsp.httpStatus = HttpStatusBadRequest; - } - return REQ_READY_SEND; -}