2017-11-16 21:17:15 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB. //
|
|
|
|
// //
|
|
|
|
// Swagger server adapter interface //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-11-21 18:28:26 -05:00
|
|
|
//#include <QDirIterator>
|
2017-11-23 18:47:42 -05:00
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonArray>
|
2017-11-21 18:28:26 -05:00
|
|
|
|
2017-11-26 04:37:39 -05:00
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
2017-11-20 12:38:26 -05:00
|
|
|
#include "httpdocrootsettings.h"
|
2017-11-16 21:17:15 -05:00
|
|
|
#include "webapirequestmapper.h"
|
2017-11-18 13:34:47 -05:00
|
|
|
#include "SWGInstanceSummaryResponse.h"
|
2017-11-22 12:57:35 -05:00
|
|
|
#include "SWGInstanceDevicesResponse.h"
|
2017-11-22 19:19:32 -05:00
|
|
|
#include "SWGInstanceChannelsResponse.h"
|
2017-11-24 02:46:12 -05:00
|
|
|
#include "SWGAudioDevices.h"
|
|
|
|
#include "SWGAudioDevicesSelect.h"
|
2017-11-24 22:02:11 -05:00
|
|
|
#include "SWGLocationInformation.h"
|
2017-11-24 22:43:22 -05:00
|
|
|
#include "SWGDVSeralDevices.h"
|
2017-11-25 05:14:52 -05:00
|
|
|
#include "SWGPresets.h"
|
2017-11-25 10:08:18 -05:00
|
|
|
#include "SWGPresetTransfer.h"
|
|
|
|
#include "SWGPresetIdentifier.h"
|
2017-12-18 19:11:34 -05:00
|
|
|
#include "SWGPresetImport.h"
|
|
|
|
#include "SWGPresetExport.h"
|
2017-12-04 17:07:30 -05:00
|
|
|
#include "SWGDeviceSettings.h"
|
2017-12-08 11:12:33 -05:00
|
|
|
#include "SWGDeviceState.h"
|
2017-12-10 14:27:08 -05:00
|
|
|
#include "SWGChannelSettings.h"
|
2017-12-19 11:55:05 -05:00
|
|
|
#include "SWGSuccessResponse.h"
|
2017-11-18 13:34:47 -05:00
|
|
|
#include "SWGErrorResponse.h"
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
WebAPIRequestMapper::WebAPIRequestMapper(QObject* parent) :
|
|
|
|
HttpRequestHandler(parent),
|
|
|
|
m_adapter(0)
|
2017-11-20 12:38:26 -05:00
|
|
|
{
|
|
|
|
qtwebapp::HttpDocrootSettings docrootSettings;
|
|
|
|
docrootSettings.path = ":/";
|
|
|
|
m_staticFileController = new qtwebapp::StaticFileController(docrootSettings, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
WebAPIRequestMapper::~WebAPIRequestMapper()
|
|
|
|
{
|
|
|
|
delete m_staticFileController;
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-11-18 13:34:47 -05:00
|
|
|
void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
2017-11-16 21:17:15 -05:00
|
|
|
{
|
|
|
|
if (m_adapter == 0) // format service unavailable if adapter is null
|
|
|
|
{
|
2017-12-22 09:27:25 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-17 02:52:15 -05:00
|
|
|
response.setStatus(500,"Service not available");
|
2017-12-22 09:27:25 -05:00
|
|
|
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Service not available";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
|
|
|
else // normal processing
|
|
|
|
{
|
|
|
|
QByteArray path=request.getPath();
|
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
if (path == WebAPIAdapterInterface::instanceSummaryURL) {
|
|
|
|
instanceSummaryService(request, response);
|
|
|
|
} else if (path == WebAPIAdapterInterface::instanceDevicesURL) {
|
|
|
|
instanceDevicesService(request, response);
|
|
|
|
} else if (path == WebAPIAdapterInterface::instanceChannelsURL) {
|
|
|
|
instanceChannelsService(request, response);
|
|
|
|
} else if (path == WebAPIAdapterInterface::instanceLoggingURL) {
|
|
|
|
instanceLoggingService(request, response);
|
|
|
|
} else if (path == WebAPIAdapterInterface::instanceAudioURL) {
|
|
|
|
instanceAudioService(request, response);
|
2017-11-24 22:02:11 -05:00
|
|
|
} else if (path == WebAPIAdapterInterface::instanceLocationURL) {
|
|
|
|
instanceLocationService(request, response);
|
2017-11-24 22:43:22 -05:00
|
|
|
} else if (path == WebAPIAdapterInterface::instanceDVSerialURL) {
|
|
|
|
instanceDVSerialService(request, response);
|
2017-12-20 18:50:58 -05:00
|
|
|
} else if (path == WebAPIAdapterInterface::instancePresetsURL) {
|
|
|
|
instancePresetsService(request, response);
|
2017-11-25 05:14:52 -05:00
|
|
|
} else if (path == WebAPIAdapterInterface::instancePresetURL) {
|
|
|
|
instancePresetService(request, response);
|
2017-12-18 19:11:34 -05:00
|
|
|
} else if (path == WebAPIAdapterInterface::instancePresetFileURL) {
|
|
|
|
instancePresetFileService(request, response);
|
2017-11-25 14:14:16 -05:00
|
|
|
} else if (path == WebAPIAdapterInterface::instanceDeviceSetsURL) {
|
|
|
|
instanceDeviceSetsService(request, response);
|
2017-12-21 19:07:03 -05:00
|
|
|
} else if (path == WebAPIAdapterInterface::instanceDeviceSetURL) {
|
|
|
|
instanceDeviceSetService(request, response);
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
else
|
2017-11-22 12:57:35 -05:00
|
|
|
{
|
2017-11-26 04:37:39 -05:00
|
|
|
std::smatch desc_match;
|
|
|
|
std::string pathStr(path.constData(), path.length());
|
|
|
|
|
|
|
|
if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetURLRe)) {
|
2017-12-04 12:22:25 -05:00
|
|
|
devicesetService(std::string(desc_match[1]), request, response);
|
2017-11-27 02:14:07 -05:00
|
|
|
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceURLRe)) {
|
2017-12-04 12:22:25 -05:00
|
|
|
devicesetDeviceService(std::string(desc_match[1]), request, response);
|
2017-12-06 16:08:34 -05:00
|
|
|
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceSettingsURLRe)) {
|
|
|
|
devicesetDeviceSettingsService(std::string(desc_match[1]), request, response);
|
2017-12-08 11:12:33 -05:00
|
|
|
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceRunURLRe)) {
|
|
|
|
devicesetDeviceRunService(std::string(desc_match[1]), request, response);
|
2017-12-10 19:18:10 -05:00
|
|
|
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelURLRe)) {
|
|
|
|
devicesetChannelService(std::string(desc_match[1]), request, response);
|
|
|
|
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelIndexURLRe)) {
|
|
|
|
devicesetChannelIndexService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
2017-12-10 14:27:08 -05:00
|
|
|
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelSettingsURLRe)) {
|
|
|
|
devicesetChannelSettingsService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
2017-11-26 04:37:39 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QByteArray path = "/index.html";
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setStatus(400, "API URL does not exist");
|
2017-11-26 04:37:39 -05:00
|
|
|
m_staticFileController->service(path, response);
|
|
|
|
}
|
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
// QDirIterator it(":", QDirIterator::Subdirectories);
|
|
|
|
// while (it.hasNext()) {
|
|
|
|
// qDebug() << "WebAPIRequestMapper::service: " << it.next();
|
|
|
|
// }
|
|
|
|
|
2017-11-22 12:57:35 -05:00
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::instanceSummaryService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
2017-12-12 12:56:24 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
|
|
|
response.setHeader("Content-Type", "application/json");
|
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGInstanceSummaryResponse normalResponse;
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
int status = m_adapter->instanceSummary(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 11:12:53 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-17 17:15:42 -05:00
|
|
|
else if (request.getMethod() == "DELETE")
|
|
|
|
{
|
2017-12-21 12:10:43 -05:00
|
|
|
SWGSDRangel::SWGSuccessResponse normalResponse;
|
2017-12-17 17:15:42 -05:00
|
|
|
|
|
|
|
int status = m_adapter->instanceDelete(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-17 17:15:42 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::instanceDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGInstanceDevicesResponse normalResponse;
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
|
|
|
QByteArray txStr = request.getParameter("tx");
|
2017-11-24 22:43:22 -05:00
|
|
|
bool tx = false;
|
|
|
|
|
|
|
|
if (txStr.length() != 0) {
|
|
|
|
tx = !(txStr == "0");
|
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
int status = m_adapter->instanceDevices(tx, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 11:12:53 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-22 19:19:32 -05:00
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::instanceChannelsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGInstanceChannelsResponse normalResponse;
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
|
|
|
QByteArray txStr = request.getParameter("tx");
|
2017-11-24 22:43:22 -05:00
|
|
|
bool tx = false;
|
|
|
|
|
|
|
|
if (txStr.length() != 0) {
|
|
|
|
tx = !(txStr == "0");
|
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
int status = m_adapter->instanceChannels(tx, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 11:12:53 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::instanceLoggingService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGLoggingInfo normalResponse;
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
|
|
|
int status = m_adapter->instanceLoggingGet(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 11:12:53 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (request.getMethod() == "PUT")
|
|
|
|
{
|
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-11-24 11:12:53 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-11-23 12:43:01 -05:00
|
|
|
{
|
2017-11-24 11:12:53 -05:00
|
|
|
normalResponse.fromJson(jsonStr);
|
|
|
|
int status = m_adapter->instanceLoggingPut(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 11:12:53 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-23 12:43:01 -05:00
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
}
|
2017-11-24 02:46:12 -05:00
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
void WebAPIRequestMapper::instanceAudioService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-24 02:46:12 -05:00
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGAudioDevices normalResponse;
|
2017-11-24 02:46:12 -05:00
|
|
|
|
2017-11-24 11:12:53 -05:00
|
|
|
int status = m_adapter->instanceAudioGet(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 11:12:53 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-24 02:46:12 -05:00
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
else if (request.getMethod() == "PATCH")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGAudioDevicesSelect normalResponse;
|
2017-11-24 11:12:53 -05:00
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-11-24 11:12:53 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-11-17 02:52:15 -05:00
|
|
|
{
|
2017-11-24 11:12:53 -05:00
|
|
|
normalResponse.fromJson(jsonStr);
|
|
|
|
int status = m_adapter->instanceAudioPatch(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
2017-11-21 18:28:26 -05:00
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 11:12:53 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-24 11:12:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 22:02:11 -05:00
|
|
|
void WebAPIRequestMapper::instanceLocationService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-24 22:02:11 -05:00
|
|
|
|
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGLocationInformation normalResponse;
|
2017-11-24 22:02:11 -05:00
|
|
|
|
|
|
|
int status = m_adapter->instanceLocationGet(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 22:02:11 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (request.getMethod() == "PUT")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGLocationInformation normalResponse;
|
2017-11-24 22:02:11 -05:00
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-11-24 22:02:11 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-11-24 22:02:11 -05:00
|
|
|
{
|
|
|
|
normalResponse.fromJson(jsonStr);
|
|
|
|
int status = m_adapter->instanceLocationPut(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 22:02:11 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-11-24 22:02:11 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-24 22:02:11 -05:00
|
|
|
}
|
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
|
2017-11-24 22:43:22 -05:00
|
|
|
void WebAPIRequestMapper::instanceDVSerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-24 22:43:22 -05:00
|
|
|
|
|
|
|
if (request.getMethod() == "PATCH")
|
|
|
|
{
|
|
|
|
QByteArray dvserialStr = request.getParameter("dvserial");
|
|
|
|
bool dvserial = false;
|
|
|
|
|
|
|
|
if (dvserialStr.length() != 0) {
|
|
|
|
dvserial = !(dvserialStr == "0");
|
|
|
|
}
|
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGDVSeralDevices normalResponse;
|
2017-11-24 22:43:22 -05:00
|
|
|
|
|
|
|
int status = m_adapter->instanceDVSerialPatch(dvserial, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-24 22:43:22 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-24 22:43:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-20 18:50:58 -05:00
|
|
|
void WebAPIRequestMapper::instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
2017-11-25 05:14:52 -05:00
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-25 05:14:52 -05:00
|
|
|
|
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGPresets normalResponse;
|
2017-12-20 18:50:58 -05:00
|
|
|
int status = m_adapter->instancePresetsGet(normalResponse, errorResponse);
|
2017-11-25 05:14:52 -05:00
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-25 05:14:52 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-20 18:50:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
|
|
|
response.setHeader("Content-Type", "application/json");
|
|
|
|
|
|
|
|
if (request.getMethod() == "PATCH")
|
2017-11-25 10:08:18 -05:00
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGPresetTransfer query;
|
|
|
|
SWGSDRangel::SWGPresetIdentifier normalResponse;
|
2017-11-25 10:08:18 -05:00
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-11-25 10:08:18 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-11-25 10:08:18 -05:00
|
|
|
{
|
|
|
|
query.fromJson(jsonStr);
|
|
|
|
|
2017-11-25 13:42:56 -05:00
|
|
|
if (validatePresetTransfer(query))
|
|
|
|
{
|
|
|
|
int status = m_adapter->instancePresetPatch(query, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-25 13:42:56 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON request");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
2017-11-25 10:08:18 -05:00
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-11-25 10:08:18 -05:00
|
|
|
}
|
2017-11-25 10:47:13 -05:00
|
|
|
else if (request.getMethod() == "PUT")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGPresetTransfer query;
|
|
|
|
SWGSDRangel::SWGPresetIdentifier normalResponse;
|
2017-11-25 10:47:13 -05:00
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-11-25 10:47:13 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-11-25 10:47:13 -05:00
|
|
|
{
|
|
|
|
query.fromJson(jsonStr);
|
|
|
|
|
2017-11-25 13:42:56 -05:00
|
|
|
if (validatePresetTransfer(query))
|
|
|
|
{
|
|
|
|
int status = m_adapter->instancePresetPut(query, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-25 13:42:56 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON request");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
2017-11-25 10:47:13 -05:00
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-11-25 10:47:13 -05:00
|
|
|
}
|
2017-11-25 12:32:37 -05:00
|
|
|
else if (request.getMethod() == "POST")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGPresetTransfer query;
|
|
|
|
SWGSDRangel::SWGPresetIdentifier normalResponse;
|
2017-11-25 12:32:37 -05:00
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-11-25 12:32:37 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-11-25 12:32:37 -05:00
|
|
|
{
|
|
|
|
query.fromJson(jsonStr);
|
|
|
|
|
2017-11-25 13:42:56 -05:00
|
|
|
if (validatePresetTransfer(query))
|
|
|
|
{
|
|
|
|
int status = m_adapter->instancePresetPost(query, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-25 13:42:56 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON request");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-11-25 13:42:56 -05:00
|
|
|
}
|
|
|
|
else if (request.getMethod() == "DELETE")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGPresetIdentifier normalResponse;
|
2017-11-25 13:42:56 -05:00
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-11-25 13:42:56 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-11-25 13:42:56 -05:00
|
|
|
{
|
|
|
|
normalResponse.fromJson(jsonStr);
|
|
|
|
|
|
|
|
if (validatePresetIdentifer(normalResponse))
|
|
|
|
{
|
|
|
|
int status = m_adapter->instancePresetDelete(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-25 13:42:56 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON request");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
2017-11-25 12:32:37 -05:00
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::instancePresetFileService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
|
|
|
response.setHeader("Content-Type", "application/json");
|
|
|
|
|
|
|
|
if (request.getMethod() == "PUT")
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGPresetImport query;
|
|
|
|
SWGSDRangel::SWGPresetIdentifier normalResponse;
|
|
|
|
QString jsonStr = request.getBody();
|
|
|
|
QJsonObject jsonObject;
|
|
|
|
|
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
|
|
|
{
|
|
|
|
query.fromJson(jsonStr);
|
|
|
|
|
|
|
|
if (query.getFilePath())
|
|
|
|
{
|
|
|
|
int status = m_adapter->instancePresetFilePut(query, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-18 19:11:34 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-28 20:44:35 -05:00
|
|
|
response.setStatus(400,"Invalid JSON request");
|
2017-12-18 19:11:34 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
2017-12-28 20:44:35 -05:00
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
2017-12-18 19:11:34 -05:00
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (request.getMethod() == "POST")
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGPresetExport query;
|
|
|
|
SWGSDRangel::SWGPresetIdentifier normalResponse;
|
|
|
|
QString jsonStr = request.getBody();
|
|
|
|
QJsonObject jsonObject;
|
|
|
|
|
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
|
|
|
{
|
|
|
|
query.fromJson(jsonStr);
|
|
|
|
|
|
|
|
if (validatePresetExport(query))
|
|
|
|
{
|
|
|
|
int status = m_adapter->instancePresetFilePost(query, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-18 19:11:34 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-28 20:44:35 -05:00
|
|
|
response.setStatus(400,"Invalid JSON request");
|
2017-12-18 19:11:34 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
2017-12-28 20:44:35 -05:00
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
2017-12-18 19:11:34 -05:00
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-11-25 12:32:37 -05:00
|
|
|
}
|
2017-11-25 05:14:52 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-25 05:14:52 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-25 14:14:16 -05:00
|
|
|
void WebAPIRequestMapper::instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-25 14:14:16 -05:00
|
|
|
|
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGDeviceSetList normalResponse;
|
2017-11-25 14:14:16 -05:00
|
|
|
int status = m_adapter->instanceDeviceSetsGet(normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-25 14:14:16 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-21 19:07:03 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
|
|
|
response.setHeader("Content-Type", "application/json");
|
|
|
|
|
|
|
|
if (request.getMethod() == "POST")
|
2017-11-25 16:52:24 -05:00
|
|
|
{
|
2017-12-19 11:55:05 -05:00
|
|
|
SWGSDRangel::SWGSuccessResponse normalResponse;
|
2017-11-25 16:52:24 -05:00
|
|
|
QByteArray txStr = request.getParameter("tx");
|
|
|
|
bool tx = false;
|
|
|
|
|
|
|
|
if (txStr.length() != 0) {
|
|
|
|
tx = !(txStr == "0");
|
|
|
|
}
|
|
|
|
|
2017-12-21 19:07:03 -05:00
|
|
|
int status = m_adapter->instanceDeviceSetPost(tx, normalResponse, errorResponse);
|
2017-11-25 16:52:24 -05:00
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-25 16:52:24 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (request.getMethod() == "DELETE")
|
|
|
|
{
|
2017-12-19 11:55:05 -05:00
|
|
|
SWGSDRangel::SWGSuccessResponse normalResponse;
|
2017-12-21 19:07:03 -05:00
|
|
|
int status = m_adapter->instanceDeviceSetDelete(normalResponse, errorResponse);
|
2017-11-25 16:52:24 -05:00
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-25 16:52:24 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-11-25 14:14:16 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-25 14:14:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-04 12:22:25 -05:00
|
|
|
void WebAPIRequestMapper::devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
2017-11-26 04:37:39 -05:00
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-26 04:37:39 -05:00
|
|
|
|
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGDeviceSet normalResponse;
|
2017-11-26 04:37:39 -05:00
|
|
|
int deviceSetIndex = boost::lexical_cast<int>(indexStr);
|
|
|
|
int status = m_adapter->devicesetGet(deviceSetIndex, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-11-26 04:37:39 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const boost::bad_lexical_cast &e)
|
|
|
|
{
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Wrong integer conversion on device set index";
|
|
|
|
response.setStatus(400,"Invalid data");
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-26 04:37:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-04 12:22:25 -05:00
|
|
|
void WebAPIRequestMapper::devicesetDeviceService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
2017-11-27 02:14:07 -05:00
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-11-27 02:14:07 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
int deviceSetIndex = boost::lexical_cast<int>(indexStr);
|
|
|
|
|
|
|
|
if (request.getMethod() == "PUT")
|
|
|
|
{
|
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-11-27 02:14:07 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-11-27 02:14:07 -05:00
|
|
|
{
|
2017-12-23 01:28:02 -05:00
|
|
|
SWGSDRangel::SWGDeviceListItem normalResponse;
|
2017-11-27 02:14:07 -05:00
|
|
|
|
2017-12-23 01:28:02 -05:00
|
|
|
if (validateDeviceListItem(normalResponse, jsonObject))
|
|
|
|
{
|
|
|
|
int status = m_adapter->devicesetDevicePut(deviceSetIndex, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
2017-11-27 02:14:07 -05:00
|
|
|
|
2017-12-23 01:28:02 -05:00
|
|
|
if (status/100 == 2) {
|
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Missing device identification");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Missing device identification";
|
2017-11-27 02:14:07 -05:00
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-11-27 02:14:07 -05:00
|
|
|
}
|
2017-12-06 16:08:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-12-06 16:08:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const boost::bad_lexical_cast &e)
|
|
|
|
{
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Wrong integer conversion on device set index";
|
|
|
|
response.setStatus(400,"Invalid data");
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::devicesetDeviceSettingsService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-12-06 16:08:34 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
int deviceSetIndex = boost::lexical_cast<int>(indexStr);
|
|
|
|
|
2017-12-07 07:55:42 -05:00
|
|
|
if ((request.getMethod() == "PUT") || (request.getMethod() == "PATCH"))
|
2017-12-06 16:08:34 -05:00
|
|
|
{
|
2017-12-07 07:55:42 -05:00
|
|
|
QString jsonStr = request.getBody();
|
2017-12-07 12:50:36 -05:00
|
|
|
QJsonObject jsonObject;
|
2017-12-07 07:55:42 -05:00
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
2017-12-07 07:55:42 -05:00
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceSettings normalResponse;
|
2017-12-07 16:38:39 -05:00
|
|
|
resetDeviceSettings(normalResponse);
|
2017-12-26 19:46:33 -05:00
|
|
|
QStringList deviceSettingsKeys;
|
2017-12-07 07:55:42 -05:00
|
|
|
|
2017-12-26 19:46:33 -05:00
|
|
|
if (validateDeviceSettings(normalResponse, jsonObject, deviceSettingsKeys))
|
2017-12-07 07:55:42 -05:00
|
|
|
{
|
|
|
|
int status = m_adapter->devicesetDeviceSettingsPutPatch(
|
|
|
|
deviceSetIndex,
|
|
|
|
(request.getMethod() == "PUT"), // force settings on PUT
|
2017-12-26 19:46:33 -05:00
|
|
|
deviceSettingsKeys,
|
2017-12-07 07:55:42 -05:00
|
|
|
normalResponse,
|
|
|
|
errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-07 07:55:42 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON request");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-12-06 16:08:34 -05:00
|
|
|
}
|
2017-12-04 12:22:25 -05:00
|
|
|
else if (request.getMethod() == "GET")
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceSettings normalResponse;
|
2017-12-06 16:08:34 -05:00
|
|
|
resetDeviceSettings(normalResponse);
|
|
|
|
int status = m_adapter->devicesetDeviceSettingsGet(deviceSetIndex, normalResponse, errorResponse);
|
2017-12-04 12:22:25 -05:00
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-04 12:22:25 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-11-27 02:14:07 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-27 02:14:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const boost::bad_lexical_cast &e)
|
|
|
|
{
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Wrong integer conversion on device set index";
|
2017-12-08 11:12:33 -05:00
|
|
|
response.setStatus(400,"Invalid data");
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::devicesetDeviceRunService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-12-08 11:12:33 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
int deviceSetIndex = boost::lexical_cast<int>(indexStr);
|
|
|
|
|
2017-12-09 04:49:20 -05:00
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceState normalResponse;
|
|
|
|
int status = m_adapter->devicesetDeviceRunGet(deviceSetIndex, normalResponse, errorResponse);
|
|
|
|
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-09 04:49:20 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (request.getMethod() == "POST")
|
2017-12-08 11:12:33 -05:00
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceState normalResponse;
|
|
|
|
int status = m_adapter->devicesetDeviceRunPost(deviceSetIndex, normalResponse, errorResponse);
|
|
|
|
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-08 11:12:33 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (request.getMethod() == "DELETE")
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceState normalResponse;
|
|
|
|
int status = m_adapter->devicesetDeviceRunDelete(deviceSetIndex, normalResponse, errorResponse);
|
|
|
|
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-08 11:12:33 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-12-08 11:12:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const boost::bad_lexical_cast &e)
|
|
|
|
{
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Wrong integer conversion on device set index";
|
2017-11-27 02:14:07 -05:00
|
|
|
response.setStatus(400,"Invalid data");
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-10 19:18:10 -05:00
|
|
|
void WebAPIRequestMapper::devicesetChannelService(
|
|
|
|
const std::string& deviceSetIndexStr,
|
|
|
|
qtwebapp::HttpRequest& request,
|
|
|
|
qtwebapp::HttpResponse& response)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-12-10 19:18:10 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr);
|
|
|
|
|
|
|
|
if (request.getMethod() == "POST")
|
|
|
|
{
|
|
|
|
QString jsonStr = request.getBody();
|
|
|
|
QJsonObject jsonObject;
|
|
|
|
|
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
|
|
|
{
|
2017-12-19 11:55:05 -05:00
|
|
|
SWGSDRangel::SWGChannelSettings query;
|
|
|
|
SWGSDRangel::SWGSuccessResponse normalResponse;
|
|
|
|
resetChannelSettings(query);
|
2017-12-10 19:18:10 -05:00
|
|
|
|
|
|
|
if (jsonObject.contains("tx")) {
|
2017-12-19 11:55:05 -05:00
|
|
|
query.setTx(jsonObject["tx"].toInt());
|
2017-12-10 19:18:10 -05:00
|
|
|
} else {
|
2017-12-19 11:55:05 -05:00
|
|
|
query.setTx(0); // assume Rx
|
2017-12-10 19:18:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (jsonObject.contains("channelType") && jsonObject["channelType"].isString())
|
|
|
|
{
|
2017-12-19 11:55:05 -05:00
|
|
|
query.setChannelType(new QString(jsonObject["channelType"].toString()));
|
2017-12-10 19:18:10 -05:00
|
|
|
|
2017-12-19 11:55:05 -05:00
|
|
|
int status = m_adapter->devicesetChannelPost(deviceSetIndex, query, normalResponse, errorResponse);
|
2017-12-10 19:18:10 -05:00
|
|
|
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-10 19:18:10 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON request");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-12-10 19:18:10 -05:00
|
|
|
}
|
2017-12-12 12:56:24 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-12-10 19:18:10 -05:00
|
|
|
}
|
|
|
|
catch (const boost::bad_lexical_cast &e)
|
|
|
|
{
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Wrong integer conversion on index";
|
|
|
|
response.setStatus(400,"Invalid data");
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebAPIRequestMapper::devicesetChannelIndexService(
|
|
|
|
const std::string& deviceSetIndexStr,
|
|
|
|
const std::string& channelIndexStr,
|
|
|
|
qtwebapp::HttpRequest& request,
|
|
|
|
qtwebapp::HttpResponse& response)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-12-10 19:18:10 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr);
|
|
|
|
int channelIndex = boost::lexical_cast<int>(channelIndexStr);
|
|
|
|
|
|
|
|
if (request.getMethod() == "DELETE")
|
|
|
|
{
|
2017-12-23 16:33:30 -05:00
|
|
|
SWGSDRangel::SWGSuccessResponse normalResponse;
|
|
|
|
int status = m_adapter->devicesetChannelDelete(deviceSetIndex, channelIndex, normalResponse, errorResponse);
|
2017-12-10 19:18:10 -05:00
|
|
|
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-10 19:18:10 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-12 12:56:24 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-12-10 19:18:10 -05:00
|
|
|
}
|
|
|
|
catch (const boost::bad_lexical_cast &e)
|
|
|
|
{
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Wrong integer conversion on index";
|
|
|
|
response.setStatus(400,"Invalid data");
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-10 14:27:08 -05:00
|
|
|
void WebAPIRequestMapper::devicesetChannelSettingsService(
|
|
|
|
const std::string& deviceSetIndexStr,
|
|
|
|
const std::string& channelIndexStr,
|
|
|
|
qtwebapp::HttpRequest& request,
|
|
|
|
qtwebapp::HttpResponse& response)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-12-12 12:56:24 -05:00
|
|
|
response.setHeader("Content-Type", "application/json");
|
2017-12-10 14:27:08 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr);
|
|
|
|
int channelIndex = boost::lexical_cast<int>(channelIndexStr);
|
|
|
|
|
|
|
|
if (request.getMethod() == "GET")
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings normalResponse;
|
|
|
|
resetChannelSettings(normalResponse);
|
|
|
|
int status = m_adapter->devicesetChannelSettingsGet(deviceSetIndex, channelIndex, normalResponse, errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-10 14:27:08 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-11 12:18:47 -05:00
|
|
|
else if ((request.getMethod() == "PUT") || (request.getMethod() == "PATCH"))
|
|
|
|
{
|
|
|
|
QString jsonStr = request.getBody();
|
|
|
|
QJsonObject jsonObject;
|
|
|
|
|
|
|
|
if (parseJsonBody(jsonStr, jsonObject, response))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings normalResponse;
|
|
|
|
resetChannelSettings(normalResponse);
|
2017-12-23 21:27:07 -05:00
|
|
|
QStringList channelSettingsKeys;
|
2017-12-11 12:18:47 -05:00
|
|
|
|
2017-12-23 21:27:07 -05:00
|
|
|
if (validateChannelSettings(normalResponse, jsonObject, channelSettingsKeys))
|
2017-12-11 12:18:47 -05:00
|
|
|
{
|
|
|
|
int status = m_adapter->devicesetChannelSettingsPutPatch(
|
|
|
|
deviceSetIndex,
|
|
|
|
channelIndex,
|
|
|
|
(request.getMethod() == "PUT"), // force settings on PUT
|
2017-12-23 21:27:07 -05:00
|
|
|
channelSettingsKeys,
|
2017-12-11 12:18:47 -05:00
|
|
|
normalResponse,
|
|
|
|
errorResponse);
|
|
|
|
response.setStatus(status);
|
|
|
|
|
2017-12-21 12:10:43 -05:00
|
|
|
if (status/100 == 2) {
|
2017-12-11 12:18:47 -05:00
|
|
|
response.write(normalResponse.asJson().toUtf8());
|
|
|
|
} else {
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON request");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON request";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(400,"Invalid JSON format");
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid JSON format";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
2017-12-11 12:18:47 -05:00
|
|
|
}
|
2017-12-10 14:27:08 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
response.setStatus(405,"Invalid HTTP method");
|
2017-12-12 12:56:24 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Invalid HTTP method";
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-12-10 14:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const boost::bad_lexical_cast &e)
|
|
|
|
{
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = "Wrong integer conversion on index";
|
|
|
|
response.setStatus(400,"Invalid data");
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
bool WebAPIRequestMapper::parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response)
|
2017-11-24 11:12:53 -05:00
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGErrorResponse errorResponse;
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
QByteArray jsonBytes(jsonStr.toStdString().c_str());
|
|
|
|
QJsonParseError error;
|
|
|
|
QJsonDocument doc = QJsonDocument::fromJson(jsonBytes, &error);
|
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
if (error.error == QJsonParseError::NoError)
|
|
|
|
{
|
|
|
|
jsonObject = doc.object();
|
|
|
|
}
|
|
|
|
else
|
2017-11-24 11:12:53 -05:00
|
|
|
{
|
2017-11-24 22:02:11 -05:00
|
|
|
QString errorMsg = QString("Input JSON error: ") + error.errorString() + QString(" at offset ") + QString::number(error.offset);
|
2017-11-24 11:12:53 -05:00
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = errorMsg;
|
|
|
|
response.setStatus(400, errorMsg.toUtf8());
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
2017-11-17 02:52:15 -05:00
|
|
|
}
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
return (error.error == QJsonParseError::NoError);
|
|
|
|
}
|
|
|
|
catch (const std::exception& ex)
|
|
|
|
{
|
|
|
|
QString errorMsg = QString("Error parsing request: ") + ex.what();
|
|
|
|
errorResponse.init();
|
|
|
|
*errorResponse.getMessage() = errorMsg;
|
|
|
|
response.setStatus(500, errorMsg.toUtf8());
|
|
|
|
response.write(errorResponse.asJson().toUtf8());
|
|
|
|
|
|
|
|
return false;
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
|
|
|
}
|
2017-11-25 13:42:56 -05:00
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
bool WebAPIRequestMapper::validatePresetTransfer(SWGSDRangel::SWGPresetTransfer& presetTransfer)
|
2017-11-25 13:42:56 -05:00
|
|
|
{
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGSDRangel::SWGPresetIdentifier *presetIdentifier = presetTransfer.getPreset();
|
2017-11-25 13:42:56 -05:00
|
|
|
|
|
|
|
if (presetIdentifier == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return validatePresetIdentifer(*presetIdentifier);
|
|
|
|
}
|
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
bool WebAPIRequestMapper::validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier& presetIdentifier)
|
2017-11-25 13:42:56 -05:00
|
|
|
{
|
|
|
|
return (presetIdentifier.getGroupName() && presetIdentifier.getName() && presetIdentifier.getType());
|
|
|
|
}
|
|
|
|
|
2017-12-18 19:11:34 -05:00
|
|
|
bool WebAPIRequestMapper::validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport)
|
|
|
|
{
|
|
|
|
if (presetExport.getFilePath() == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SWGSDRangel::SWGPresetIdentifier *presetIdentifier = presetExport.getPreset();
|
|
|
|
|
|
|
|
if (presetIdentifier == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return validatePresetIdentifer(*presetIdentifier);
|
|
|
|
}
|
|
|
|
|
2017-12-23 01:28:02 -05:00
|
|
|
bool WebAPIRequestMapper::validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject)
|
|
|
|
{
|
|
|
|
if (jsonObject.contains("tx")) {
|
|
|
|
deviceListItem.setTx(jsonObject["tx"].toInt());
|
|
|
|
} else {
|
|
|
|
deviceListItem.setTx(0); // assume Rx
|
|
|
|
}
|
|
|
|
|
|
|
|
bool identified = false;
|
|
|
|
|
|
|
|
if (jsonObject.contains("displayedName") && jsonObject["displayedName"].isString())
|
|
|
|
{
|
|
|
|
deviceListItem.setDisplayedName(new QString(jsonObject["displayedName"].toString()));
|
|
|
|
identified = true;
|
|
|
|
} else {
|
|
|
|
deviceListItem.setDisplayedName(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (jsonObject.contains("hwType") && jsonObject["hwType"].isString())
|
|
|
|
{
|
|
|
|
deviceListItem.setHwType(new QString(jsonObject["hwType"].toString()));
|
|
|
|
identified = true;
|
|
|
|
} else {
|
|
|
|
deviceListItem.setHwType(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jsonObject.contains("serial") && jsonObject["serial"].isString())
|
|
|
|
{
|
|
|
|
deviceListItem.setSerial(new QString(jsonObject["serial"].toString()));
|
|
|
|
identified = true;
|
|
|
|
} else {
|
|
|
|
deviceListItem.setSerial(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jsonObject.contains("index")) {
|
|
|
|
deviceListItem.setIndex(jsonObject["index"].toInt(-1));
|
|
|
|
} else {
|
|
|
|
deviceListItem.setIndex(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jsonObject.contains("sequence")){
|
|
|
|
deviceListItem.setSequence(jsonObject["sequence"].toInt(-1));
|
|
|
|
} else {
|
|
|
|
deviceListItem.setSequence(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jsonObject.contains("streamIndex")) {
|
|
|
|
deviceListItem.setStreamIndex(jsonObject["streamIndex"].toInt(-1));
|
|
|
|
} else {
|
|
|
|
deviceListItem.setStreamIndex(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return identified;
|
|
|
|
}
|
|
|
|
|
2017-12-26 19:46:33 -05:00
|
|
|
bool WebAPIRequestMapper::validateDeviceSettings(
|
|
|
|
SWGSDRangel::SWGDeviceSettings& deviceSettings,
|
|
|
|
QJsonObject& jsonObject,
|
|
|
|
QStringList& deviceSettingsKeys)
|
2017-12-07 07:55:42 -05:00
|
|
|
{
|
2017-12-07 16:38:39 -05:00
|
|
|
if (jsonObject.contains("tx")) {
|
|
|
|
deviceSettings.setTx(jsonObject["tx"].toInt());
|
|
|
|
} else {
|
|
|
|
deviceSettings.setTx(0); // assume Rx
|
|
|
|
}
|
2017-12-07 07:55:42 -05:00
|
|
|
|
2017-12-07 18:56:29 -05:00
|
|
|
if (jsonObject.contains("deviceHwType") && jsonObject["deviceHwType"].isString()) {
|
2017-12-07 16:38:39 -05:00
|
|
|
deviceSettings.setDeviceHwType(new QString(jsonObject["deviceHwType"].toString()));
|
|
|
|
} else {
|
2017-12-07 07:55:42 -05:00
|
|
|
return false;
|
|
|
|
}
|
2017-12-07 16:38:39 -05:00
|
|
|
|
|
|
|
QString *deviceHwType = deviceSettings.getDeviceHwType();
|
|
|
|
|
2017-12-07 18:56:29 -05:00
|
|
|
if (*deviceHwType == "FileSource")
|
|
|
|
{
|
|
|
|
if (jsonObject.contains("fileSourceSettings") && jsonObject["fileSourceSettings"].isObject())
|
|
|
|
{
|
|
|
|
QJsonObject fileSourceSettingsJsonObject = jsonObject["fileSourceSettings"].toObject();
|
2017-12-26 19:46:33 -05:00
|
|
|
deviceSettingsKeys = fileSourceSettingsJsonObject.keys();
|
2017-12-07 16:38:39 -05:00
|
|
|
deviceSettings.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings());
|
2017-12-07 18:56:29 -05:00
|
|
|
deviceSettings.getFileSourceSettings()->fromJsonObject(fileSourceSettingsJsonObject);
|
2017-12-07 16:38:39 -05:00
|
|
|
return true;
|
2017-12-07 18:56:29 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-07 16:38:39 -05:00
|
|
|
return false;
|
|
|
|
}
|
2017-12-07 18:56:29 -05:00
|
|
|
}
|
2017-12-28 19:40:34 -05:00
|
|
|
else if ((*deviceHwType == "HackRF") && (deviceSettings.getTx() == 0))
|
2017-12-07 18:56:29 -05:00
|
|
|
{
|
2017-12-28 20:44:35 -05:00
|
|
|
if (jsonObject.contains("hackRFInputSettings") && jsonObject["hackRFInputSettings"].isObject())
|
2017-12-07 18:56:29 -05:00
|
|
|
{
|
2017-12-28 20:44:35 -05:00
|
|
|
QJsonObject hackRFInputSettingsJsonObject = jsonObject["hackRFInputSettings"].toObject();
|
2017-12-28 19:40:34 -05:00
|
|
|
deviceSettingsKeys = hackRFInputSettingsJsonObject.keys();
|
|
|
|
deviceSettings.setHackRfInputSettings(new SWGSDRangel::SWGHackRFInputSettings());
|
|
|
|
deviceSettings.getHackRfInputSettings()->fromJsonObject(hackRFInputSettingsJsonObject);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((*deviceHwType == "HackRF") && (deviceSettings.getTx() != 0))
|
|
|
|
{
|
2017-12-28 20:44:35 -05:00
|
|
|
if (jsonObject.contains("hackRFOutputSettings") && jsonObject["hackRFOutputSettings"].isObject())
|
2017-12-28 19:40:34 -05:00
|
|
|
{
|
2017-12-28 20:44:35 -05:00
|
|
|
QJsonObject hackRFOutputSettingsJsonObject = jsonObject["hackRFOutputSettings"].toObject();
|
2017-12-28 19:40:34 -05:00
|
|
|
deviceSettingsKeys = hackRFOutputSettingsJsonObject.keys();
|
|
|
|
deviceSettings.setHackRfOutputSettings(new SWGSDRangel::SWGHackRFOutputSettings());
|
|
|
|
deviceSettings.getHackRfOutputSettings()->fromJsonObject(hackRFOutputSettingsJsonObject);
|
2017-12-07 18:56:29 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
2017-12-07 07:55:42 -05:00
|
|
|
}
|
|
|
|
}
|
2017-12-07 18:56:29 -05:00
|
|
|
else if ((*deviceHwType == "LimeSDR") && (deviceSettings.getTx() == 0))
|
|
|
|
{
|
|
|
|
if (jsonObject.contains("limeSdrInputSettings") && jsonObject["limeSdrInputSettings"].isObject())
|
|
|
|
{
|
|
|
|
QJsonObject limeSdrInputSettingsJsonObject = jsonObject["limeSdrInputSettings"].toObject();
|
2017-12-26 19:46:33 -05:00
|
|
|
deviceSettingsKeys = limeSdrInputSettingsJsonObject.keys();
|
2017-12-07 18:56:29 -05:00
|
|
|
deviceSettings.setLimeSdrInputSettings(new SWGSDRangel::SWGLimeSdrInputSettings());
|
|
|
|
deviceSettings.getLimeSdrInputSettings()->fromJsonObject(limeSdrInputSettingsJsonObject);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((*deviceHwType == "LimeSDR") && (deviceSettings.getTx() != 0))
|
|
|
|
{
|
|
|
|
if (jsonObject.contains("limeSdrOutputSettings") && jsonObject["limeSdrOutputSettings"].isObject())
|
|
|
|
{
|
|
|
|
QJsonObject limeSdrOutputSettingsJsonObject = jsonObject["limeSdrOutputSettings"].toObject();
|
2017-12-26 19:46:33 -05:00
|
|
|
deviceSettingsKeys = limeSdrOutputSettingsJsonObject.keys();
|
2017-12-07 18:56:29 -05:00
|
|
|
deviceSettings.setLimeSdrOutputSettings(new SWGSDRangel::SWGLimeSdrOutputSettings());
|
|
|
|
deviceSettings.getLimeSdrOutputSettings()->fromJsonObject(limeSdrOutputSettingsJsonObject);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2017-12-28 19:40:34 -05:00
|
|
|
else if (*deviceHwType == "RTLSDR")
|
|
|
|
{
|
|
|
|
if (jsonObject.contains("rtlSdrSettings") && jsonObject["rtlSdrSettings"].isObject())
|
|
|
|
{
|
|
|
|
QJsonObject rtlSdrSettingsJsonObject = jsonObject["rtlSdrSettings"].toObject();
|
|
|
|
deviceSettingsKeys = rtlSdrSettingsJsonObject.keys();
|
|
|
|
deviceSettings.setRtlSdrSettings(new SWGSDRangel::SWGRtlSdrSettings());
|
|
|
|
deviceSettings.getRtlSdrSettings()->fromJsonObject(rtlSdrSettingsJsonObject);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2017-12-07 18:56:29 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-07 07:55:42 -05:00
|
|
|
}
|
|
|
|
|
2017-12-23 21:27:07 -05:00
|
|
|
bool WebAPIRequestMapper::validateChannelSettings(
|
|
|
|
SWGSDRangel::SWGChannelSettings& channelSettings,
|
|
|
|
QJsonObject& jsonObject,
|
|
|
|
QStringList& channelSettingsKeys)
|
2017-12-11 12:18:47 -05:00
|
|
|
{
|
|
|
|
if (jsonObject.contains("tx")) {
|
|
|
|
channelSettings.setTx(jsonObject["tx"].toInt());
|
|
|
|
} else {
|
|
|
|
channelSettings.setTx(0); // assume Rx
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jsonObject.contains("channelType") && jsonObject["channelType"].isString()) {
|
|
|
|
channelSettings.setChannelType(new QString(jsonObject["channelType"].toString()));
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString *channelType = channelSettings.getChannelType();
|
|
|
|
|
|
|
|
if (*channelType == "NFMDemod")
|
|
|
|
{
|
|
|
|
if (channelSettings.getTx() == 0)
|
|
|
|
{
|
2017-12-12 09:58:04 -05:00
|
|
|
QJsonObject nfmDemodSettingsJsonObject = jsonObject["NFMDemodSettings"].toObject();
|
2017-12-23 21:27:07 -05:00
|
|
|
channelSettingsKeys = nfmDemodSettingsJsonObject.keys();
|
2017-12-11 12:18:47 -05:00
|
|
|
channelSettings.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings());
|
|
|
|
channelSettings.getNfmDemodSettings()->fromJsonObject(nfmDemodSettingsJsonObject);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*channelType == "NFMMod")
|
|
|
|
{
|
|
|
|
if (channelSettings.getTx() != 0)
|
|
|
|
{
|
2017-12-12 09:58:04 -05:00
|
|
|
QJsonObject nfmModSettingsJsonObject = jsonObject["NFMModSettings"].toObject();
|
2017-12-23 21:27:07 -05:00
|
|
|
channelSettingsKeys = nfmModSettingsJsonObject.keys();
|
2017-12-23 22:19:44 -05:00
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer"))
|
|
|
|
{
|
|
|
|
QJsonObject cwKeyerSettingsJsonObject;
|
|
|
|
appendSettingsSubKeys(nfmModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys);
|
|
|
|
}
|
|
|
|
|
2017-12-11 12:18:47 -05:00
|
|
|
channelSettings.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
|
|
|
|
channelSettings.getNfmModSettings()->fromJsonObject(nfmModSettingsJsonObject);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2017-12-12 17:21:31 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-11 12:18:47 -05:00
|
|
|
}
|
|
|
|
|
2017-12-23 22:19:44 -05:00
|
|
|
void WebAPIRequestMapper::appendSettingsSubKeys(
|
|
|
|
const QJsonObject& parentSettingsJsonObject,
|
|
|
|
QJsonObject& childSettingsJsonObject,
|
|
|
|
const QString& parentKey,
|
|
|
|
QStringList& keyList)
|
|
|
|
{
|
|
|
|
childSettingsJsonObject = parentSettingsJsonObject[parentKey].toObject();
|
|
|
|
QStringList childSettingsKeys = childSettingsJsonObject.keys();
|
|
|
|
|
|
|
|
for (int i = 0; i < childSettingsKeys.size(); i++) {
|
|
|
|
keyList.append(parentKey + QString(".") + childSettingsKeys.at(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-06 16:08:34 -05:00
|
|
|
void WebAPIRequestMapper::resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings)
|
|
|
|
{
|
|
|
|
deviceSettings.cleanup();
|
2017-12-28 04:58:50 -05:00
|
|
|
deviceSettings.setDeviceHwType(0);
|
2017-12-06 16:08:34 -05:00
|
|
|
deviceSettings.setFileSourceSettings(0);
|
2017-12-28 20:44:35 -05:00
|
|
|
deviceSettings.setHackRfInputSettings(0);
|
|
|
|
deviceSettings.setHackRfOutputSettings(0);
|
2017-12-06 16:08:34 -05:00
|
|
|
deviceSettings.setLimeSdrInputSettings(0);
|
|
|
|
deviceSettings.setLimeSdrOutputSettings(0);
|
2017-12-28 20:44:35 -05:00
|
|
|
deviceSettings.setRtlSdrSettings(0);
|
2017-12-06 16:08:34 -05:00
|
|
|
}
|
2017-11-25 13:42:56 -05:00
|
|
|
|
2017-12-10 14:27:08 -05:00
|
|
|
void WebAPIRequestMapper::resetChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings)
|
|
|
|
{
|
|
|
|
channelSettings.cleanup();
|
2017-12-28 04:58:50 -05:00
|
|
|
channelSettings.setChannelType(0);
|
2017-12-10 14:27:08 -05:00
|
|
|
channelSettings.setNfmDemodSettings(0);
|
|
|
|
channelSettings.setNfmModSettings(0);
|
|
|
|
}
|
|
|
|
|