mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-06 16:05:13 -04:00
Feature plugins framework: REST API generated code
This commit is contained in:
@@ -41,6 +41,7 @@ QString WebAPIAdapterInterface::instancePresetURL = "/sdrangel/preset";
|
||||
QString WebAPIAdapterInterface::instancePresetFileURL = "/sdrangel/preset/file";
|
||||
QString WebAPIAdapterInterface::instanceDeviceSetsURL = "/sdrangel/devicesets";
|
||||
QString WebAPIAdapterInterface::instanceDeviceSetURL = "/sdrangel/deviceset";
|
||||
QString WebAPIAdapterInterface::instanceFeatureSetsURL = "/sdrangel/featuresets";
|
||||
|
||||
std::regex WebAPIAdapterInterface::devicesetURLRe("^/sdrangel/deviceset/([0-9]{1,2})$");
|
||||
std::regex WebAPIAdapterInterface::devicesetFocusURLRe("^/sdrangel/deviceset/([0-9]{1,2})/focus$");
|
||||
@@ -59,6 +60,14 @@ std::regex WebAPIAdapterInterface::devicesetChannelSettingsURLRe("^/sdrangel/dev
|
||||
std::regex WebAPIAdapterInterface::devicesetChannelReportURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channel/([0-9]{1,2})/report");
|
||||
std::regex WebAPIAdapterInterface::devicesetChannelActionsURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channel/([0-9]{1,2})/actions");
|
||||
|
||||
std::regex WebAPIAdapterInterface::featuresetURLRe("^/sdrangel/featureset/([0-9]{1,2})$");
|
||||
std::regex WebAPIAdapterInterface::featuresetFeatureURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature$");
|
||||
std::regex WebAPIAdapterInterface::featuresetFeatureIndexURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature/([0-9]{1,2})$");
|
||||
std::regex WebAPIAdapterInterface::featuresetFeatureRunURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature/([0-9]{1,2})/run$");
|
||||
std::regex WebAPIAdapterInterface::featuresetFeatureSettingsURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature/([0-9]{1,2})/settings$");
|
||||
std::regex WebAPIAdapterInterface::featuresetFeatureReportURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature/([0-9]{1,2})/report");
|
||||
std::regex WebAPIAdapterInterface::featuresetFeatureActionsURLRe("^/sdrangel/featureset/([0-9]{1,2})/feature/([0-9]{1,2})/actions");
|
||||
|
||||
void WebAPIAdapterInterface::ConfigKeys::debug() const
|
||||
{
|
||||
qDebug("WebAPIAdapterInterface::ConfigKeys::debug");
|
||||
@@ -140,4 +149,4 @@ void WebAPIAdapterInterface::ConfigKeys::debug() const
|
||||
}
|
||||
qDebug(" }");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,11 @@ namespace SWGSDRangel
|
||||
class SWGSuccessResponse;
|
||||
class SWGGLSpectrum;
|
||||
class SWGSpectrumServer;
|
||||
class SWGFeatureSetList;
|
||||
class SWGFeatureSet;
|
||||
class SWGFeatureSettings;
|
||||
class SWGFeatureReport;
|
||||
class SWGFeatureActions;
|
||||
}
|
||||
|
||||
class SDRBASE_API WebAPIAdapterInterface
|
||||
@@ -630,6 +635,20 @@ public:
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featuresets (GET)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceFeatureSetsGet(
|
||||
SWGSDRangel::SWGFeatureSetList& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/deviceset (POST) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
@@ -1062,7 +1081,6 @@ public:
|
||||
return 501;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/settings (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
@@ -1103,6 +1121,196 @@ public:
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex} (GET)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetGet(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGFeatureSet& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) deviceSetIndex;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature (POST)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeaturePost(
|
||||
int featureSetIndex,
|
||||
SWGSDRangel::SWGFeatureSettings& query,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) query;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/run (GET)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeatureDelete(
|
||||
int featureSetIndex,
|
||||
int featureIndex,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) featureIndex;
|
||||
(void) response;
|
||||
(void) error;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/run (GET)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeatureRunGet(
|
||||
int featureSetIndex,
|
||||
int featureIndex,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) featureIndex;
|
||||
(void) response;
|
||||
(void) error;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/run (POST)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeatureRunPost(
|
||||
int featureSetIndex,
|
||||
int featureIndex,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) featureIndex;
|
||||
(void) response;
|
||||
(void) error;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/run (DELETE)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeatureRunDelete(
|
||||
int featureSetIndex,
|
||||
int featureIndex,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) featureIndex;
|
||||
(void) response;
|
||||
(void) error;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/settings (GET)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeatureSettingsGet(
|
||||
int featureSetIndex,
|
||||
int featureIndex,
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) featureIndex;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/settings (PUT, PATCH)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeatureSettingsPutPatch(
|
||||
int featureSetIndex,
|
||||
int featureIndex,
|
||||
bool force,
|
||||
const QStringList& featureSettingsKeys,
|
||||
SWGSDRangel::SWGFeatureSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) featureIndex;
|
||||
(void) force;
|
||||
(void) featureSettingsKeys;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/report (GET)
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeatureReportGet(
|
||||
int featureSetIndex,
|
||||
int featureIndex,
|
||||
SWGSDRangel::SWGFeatureReport& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) featureIndex;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/featureset/{featuresetIndex}/feature/{featureIndex}/actions (POST)
|
||||
* posts an action on the channel (default 501: not implemented)
|
||||
*/
|
||||
virtual int featuresetFeatureActionsPost(
|
||||
int featureSetIndex,
|
||||
int featureIndex,
|
||||
const QStringList& featureActionsKeys,
|
||||
SWGSDRangel::SWGFeatureActions& query,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) featureSetIndex;
|
||||
(void) featureIndex;
|
||||
(void) featureActionsKeys;
|
||||
(void) query;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
static QString instanceSummaryURL;
|
||||
static QString instanceConfigURL;
|
||||
static QString instanceDevicesURL;
|
||||
@@ -1125,6 +1333,7 @@ public:
|
||||
static QString instancePresetFileURL;
|
||||
static QString instanceDeviceSetsURL;
|
||||
static QString instanceDeviceSetURL;
|
||||
static QString instanceFeatureSetsURL;
|
||||
static std::regex devicesetURLRe;
|
||||
static std::regex devicesetFocusURLRe;
|
||||
static std::regex devicesetSpectrumSettingsURLRe;
|
||||
@@ -1141,6 +1350,13 @@ public:
|
||||
static std::regex devicesetChannelReportURLRe;
|
||||
static std::regex devicesetChannelActionsURLRe;
|
||||
static std::regex devicesetChannelsReportURLRe;
|
||||
static std::regex featuresetURLRe;
|
||||
static std::regex featuresetFeatureURLRe;
|
||||
static std::regex featuresetFeatureIndexURLRe;
|
||||
static std::regex featuresetFeatureRunURLRe;
|
||||
static std::regex featuresetFeatureSettingsURLRe;
|
||||
static std::regex featuresetFeatureReportURLRe;
|
||||
static std::regex featuresetFeatureActionsURLRe;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@
|
||||
#include "SWGErrorResponse.h"
|
||||
#include "SWGGLSpectrum.h"
|
||||
#include "SWGSpectrumServer.h"
|
||||
#include "SWGFeatureSetList.h"
|
||||
#include "SWGFeatureSettings.h"
|
||||
#include "SWGFeatureReport.h"
|
||||
#include "SWGFeatureActions.h"
|
||||
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_channelURIToSettingsKey = {
|
||||
{"sdrangel.channel.amdemod", "AMDemodSettings"},
|
||||
@@ -237,14 +241,22 @@ const QMap<QString, QString> WebAPIRequestMapper::m_sinkDeviceHwIdToSettingsKey
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_sinkDeviceHwIdToActionsKey = {
|
||||
};
|
||||
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_mimoDeviceHwIdToSettingsKey= {
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_mimoDeviceHwIdToSettingsKey = {
|
||||
{"BladeRF2", "bladeRF2MIMOSettings"},
|
||||
{"MetisMISO", "metisMISOSettings"},
|
||||
{"TestMI", "testMISettings"},
|
||||
{"TestMOSync", "testMOSyncSettings"}
|
||||
};
|
||||
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_mimoDeviceHwIdToActionsKey= {
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_mimoDeviceHwIdToActionsKey = {
|
||||
};
|
||||
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_featureTypeToSettingsKey = {
|
||||
{"SimplePTT", "SimplePTTSettings"}
|
||||
};
|
||||
|
||||
const QMap<QString, QString> WebAPIRequestMapper::m_featureTypeToActionsKey = {
|
||||
{"SimplePTT", "SimplePTTActions"}
|
||||
};
|
||||
|
||||
WebAPIRequestMapper::WebAPIRequestMapper(QObject* parent) :
|
||||
@@ -339,6 +351,8 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
||||
instanceDeviceSetsService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instanceDeviceSetURL) {
|
||||
instanceDeviceSetService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instanceFeatureSetsURL) {
|
||||
instanceFeatureSetsService(request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -377,6 +391,20 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
||||
devicesetChannelReportService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
||||
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelActionsURLRe)) {
|
||||
devicesetChannelActionsService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
||||
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetURLRe)) {
|
||||
featuresetService(std::string(desc_match[1]), request, response);
|
||||
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureURLRe)) {
|
||||
featuresetFeatureService(std::string(desc_match[1]), request, response);
|
||||
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureIndexURLRe)) {
|
||||
featuresetFeatureIndexService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
||||
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureRunURLRe)) {
|
||||
featuresetFeatureRunService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
||||
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureSettingsURLRe)) {
|
||||
featuresetFeatureSettingsService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
||||
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureReportURLRe)) {
|
||||
featuresetFeatureReportService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
||||
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::featuresetFeatureActionsURLRe)) {
|
||||
featuresetFeatureActionsService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
|
||||
}
|
||||
else // serve static documentation pages
|
||||
{
|
||||
@@ -1585,6 +1613,33 @@ void WebAPIRequestMapper::instanceDeviceSetService(qtwebapp::HttpRequest& reques
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::instanceFeatureSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
SWGSDRangel::SWGFeatureSetList normalResponse;
|
||||
int status = m_adapter->instanceFeatureSetsGet(normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
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::devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
@@ -2573,6 +2628,443 @@ void WebAPIRequestMapper::devicesetChannelActionsService(
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::featuresetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
try
|
||||
{
|
||||
SWGSDRangel::SWGFeatureSet normalResponse;
|
||||
int deviceSetIndex = boost::lexical_cast<int>(indexStr);
|
||||
int status = m_adapter->featuresetGet(deviceSetIndex, normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
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");
|
||||
errorResponse.init();
|
||||
*errorResponse.getMessage() = "Invalid HTTP method";
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::featuresetFeatureService(
|
||||
const std::string& featureSetIndexStr,
|
||||
qtwebapp::HttpRequest& request,
|
||||
qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
try
|
||||
{
|
||||
int featureSetIndex = boost::lexical_cast<int>(featureSetIndexStr);
|
||||
|
||||
if (request.getMethod() == "POST")
|
||||
{
|
||||
QString jsonStr = request.getBody();
|
||||
QJsonObject jsonObject;
|
||||
|
||||
if (parseJsonBody(jsonStr, jsonObject, response))
|
||||
{
|
||||
SWGSDRangel::SWGFeatureSettings query;
|
||||
SWGSDRangel::SWGSuccessResponse normalResponse;
|
||||
resetFeatureSettings(query);
|
||||
|
||||
if (jsonObject.contains("featureType") && jsonObject["featureType"].isString())
|
||||
{
|
||||
query.setFeatureType(new QString(jsonObject["featureType"].toString()));
|
||||
|
||||
int status = m_adapter->featuresetFeaturePost(featureSetIndex, query, normalResponse, errorResponse);
|
||||
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
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::featuresetFeatureIndexService(
|
||||
const std::string& featureSetIndexStr,
|
||||
const std::string& featureIndexStr,
|
||||
qtwebapp::HttpRequest& request,
|
||||
qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
try
|
||||
{
|
||||
int featureSetIndex = boost::lexical_cast<int>(featureSetIndexStr);
|
||||
int featureIndex = boost::lexical_cast<int>(featureIndexStr);
|
||||
|
||||
if (request.getMethod() == "DELETE")
|
||||
{
|
||||
SWGSDRangel::SWGSuccessResponse normalResponse;
|
||||
int status = m_adapter->featuresetFeatureDelete(featureSetIndex, featureIndex, normalResponse, errorResponse);
|
||||
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(405,"Invalid HTTP method");
|
||||
errorResponse.init();
|
||||
*errorResponse.getMessage() = "Invalid HTTP method";
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
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::featuresetFeatureRunService(
|
||||
const std::string& featureSetIndexStr,
|
||||
const std::string& featureIndexStr,
|
||||
qtwebapp::HttpRequest& request,
|
||||
qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
try
|
||||
{
|
||||
int featureSetIndex = boost::lexical_cast<int>(featureSetIndexStr);
|
||||
int featureIndex = boost::lexical_cast<int>(featureIndexStr);
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
SWGSDRangel::SWGDeviceState normalResponse;
|
||||
int status = m_adapter->featuresetFeatureRunGet(featureSetIndex, featureIndex, normalResponse, errorResponse);
|
||||
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else if (request.getMethod() == "POST")
|
||||
{
|
||||
SWGSDRangel::SWGDeviceState normalResponse;
|
||||
int status = m_adapter->featuresetFeatureRunPost(featureSetIndex, featureIndex, normalResponse, errorResponse);
|
||||
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
|
||||
}
|
||||
else if (request.getMethod() == "DELETE")
|
||||
{
|
||||
SWGSDRangel::SWGDeviceState normalResponse;
|
||||
int status = m_adapter->featuresetFeatureRunDelete(featureSetIndex, featureIndex, normalResponse, errorResponse);
|
||||
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(405,"Invalid HTTP method");
|
||||
errorResponse.init();
|
||||
*errorResponse.getMessage() = "Invalid HTTP method";
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
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::featuresetFeatureSettingsService(
|
||||
const std::string& featureSetIndexStr,
|
||||
const std::string& featureIndexStr,
|
||||
qtwebapp::HttpRequest& request,
|
||||
qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
try
|
||||
{
|
||||
int featureSetIndex = boost::lexical_cast<int>(featureSetIndexStr);
|
||||
int featureIndex = boost::lexical_cast<int>(featureIndexStr);
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
SWGSDRangel::SWGFeatureSettings normalResponse;
|
||||
resetFeatureSettings(normalResponse);
|
||||
int status = m_adapter->featuresetFeatureSettingsGet(featureSetIndex, featureIndex, normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else if ((request.getMethod() == "PUT") || (request.getMethod() == "PATCH"))
|
||||
{
|
||||
QString jsonStr = request.getBody();
|
||||
QJsonObject jsonObject;
|
||||
|
||||
if (parseJsonBody(jsonStr, jsonObject, response))
|
||||
{
|
||||
SWGSDRangel::SWGFeatureSettings normalResponse;
|
||||
resetFeatureSettings(normalResponse);
|
||||
QStringList featureSettingsKeys;
|
||||
|
||||
if (validateFeatureSettings(normalResponse, jsonObject, featureSettingsKeys))
|
||||
{
|
||||
int status = m_adapter->featuresetFeatureSettingsPutPatch(
|
||||
featureSetIndex,
|
||||
featureIndex,
|
||||
(request.getMethod() == "PUT"), // force settings on PUT
|
||||
featureSettingsKeys,
|
||||
normalResponse,
|
||||
errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
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::featuresetFeatureReportService(
|
||||
const std::string& featureSetIndexStr,
|
||||
const std::string& featureIndexStr,
|
||||
qtwebapp::HttpRequest& request,
|
||||
qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
try
|
||||
{
|
||||
int featureSetIndex = boost::lexical_cast<int>(featureSetIndexStr);
|
||||
int featureIndex = boost::lexical_cast<int>(featureIndexStr);
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
SWGSDRangel::SWGFeatureReport normalResponse;
|
||||
resetFeatureReport(normalResponse);
|
||||
int status = m_adapter->featuresetFeatureReportGet(featureSetIndex, featureIndex, normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(405,"Invalid HTTP method");
|
||||
errorResponse.init();
|
||||
*errorResponse.getMessage() = "Invalid HTTP method";
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
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::featuresetFeatureActionsService(
|
||||
const std::string& featureSetIndexStr,
|
||||
const std::string& featureIndexStr,
|
||||
qtwebapp::HttpRequest& request,
|
||||
qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
try
|
||||
{
|
||||
int featureSetIndex = boost::lexical_cast<int>(featureSetIndexStr);
|
||||
int featureIndex = boost::lexical_cast<int>(featureIndexStr);
|
||||
|
||||
if (request.getMethod() == "POST")
|
||||
{
|
||||
QString jsonStr = request.getBody();
|
||||
QJsonObject jsonObject;
|
||||
|
||||
if (parseJsonBody(jsonStr, jsonObject, response))
|
||||
{
|
||||
SWGSDRangel::SWGFeatureActions query;
|
||||
SWGSDRangel::SWGSuccessResponse normalResponse;
|
||||
resetFeatureActions(query);
|
||||
QStringList featureActionsKeys;
|
||||
|
||||
if (validateFeatureActions(query, jsonObject, featureActionsKeys))
|
||||
{
|
||||
int status = m_adapter->featuresetFeatureActionsPost(
|
||||
featureSetIndex,
|
||||
featureIndex,
|
||||
featureActionsKeys,
|
||||
query,
|
||||
normalResponse,
|
||||
errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
@@ -2974,6 +3466,46 @@ bool WebAPIRequestMapper::validateChannelActions(
|
||||
}
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::validateFeatureSettings(
|
||||
SWGSDRangel::SWGFeatureSettings& featureSettings,
|
||||
QJsonObject& jsonObject,
|
||||
QStringList& featureSettingsKeys)
|
||||
{
|
||||
if (jsonObject.contains("featureType") && jsonObject["featureType"].isString()) {
|
||||
featureSettings.setFeatureType(new QString(jsonObject["featureType"].toString()));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString *featureType = featureSettings.getFeatureType();
|
||||
|
||||
if (m_featureTypeToSettingsKey.contains(*featureType)) {
|
||||
return getFeatureSettings(m_featureTypeToSettingsKey[*featureType], &featureSettings, jsonObject, featureSettingsKeys);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::validateFeatureActions(
|
||||
SWGSDRangel::SWGFeatureActions& featureActions,
|
||||
QJsonObject& jsonObject,
|
||||
QStringList& featureActionsKeys)
|
||||
{
|
||||
if (jsonObject.contains("featureType") && jsonObject["featureType"].isString()) {
|
||||
featureActions.setFeatureType(new QString(jsonObject["featureType"].toString()));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString *featureType = featureActions.getFeatureType();
|
||||
|
||||
if (m_featureTypeToActionsKey.contains(*featureType)) {
|
||||
return getFeatureActions(m_featureTypeToActionsKey[*featureType], &featureActions, jsonObject, featureActionsKeys);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::validateAudioInputDevice(
|
||||
SWGSDRangel::SWGAudioInputDevice& audioInputDevice,
|
||||
QJsonObject& jsonObject,
|
||||
@@ -3875,6 +4407,70 @@ bool WebAPIRequestMapper::getDeviceActions(
|
||||
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::getFeatureSettings(
|
||||
const QString& featureSettingsKey,
|
||||
SWGSDRangel::SWGFeatureSettings *featureSettings,
|
||||
const QJsonObject& featureSettingsJson,
|
||||
QStringList& featureSettingsKeys
|
||||
)
|
||||
{
|
||||
QStringList featureKeys = featureSettingsJson.keys();
|
||||
|
||||
if (featureKeys.contains(featureSettingsKey) && featureSettingsJson[featureSettingsKey].isObject())
|
||||
{
|
||||
QJsonObject settingsJsonObject = featureSettingsJson[featureSettingsKey].toObject();
|
||||
featureSettingsKeys = settingsJsonObject.keys();
|
||||
|
||||
if (featureSettingsKey == "SimplePTTSettings")
|
||||
{
|
||||
featureSettings->setSimplePttSettings(new SWGSDRangel::SWGSimplePTTSettings());
|
||||
featureSettings->getSimplePttSettings()->fromJsonObject(settingsJsonObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::getFeatureActions(
|
||||
const QString& featureActionsKey,
|
||||
SWGSDRangel::SWGFeatureActions *featureActions,
|
||||
const QJsonObject& featureActionsJson,
|
||||
QStringList& featureActionsKeys
|
||||
)
|
||||
{
|
||||
QStringList featureKeys = featureActionsJson.keys();
|
||||
|
||||
if (featureKeys.contains(featureActionsKey) && featureActionsJson[featureActionsKey].isObject())
|
||||
{
|
||||
QJsonObject actionsJsonObject = featureActionsJson[featureActionsKey].toObject();
|
||||
featureActionsKeys = actionsJsonObject.keys();
|
||||
|
||||
if (featureActionsKey == "SimplePTTActions")
|
||||
{
|
||||
featureActions->setSimplePttActions(new SWGSDRangel::SWGSimplePTTActions());
|
||||
featureActions->getSimplePttActions()->fromJsonObject(actionsJsonObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::appendSettingsSubKeys(
|
||||
const QJsonObject& parentSettingsJsonObject,
|
||||
QJsonObject& childSettingsJsonObject,
|
||||
@@ -4032,6 +4628,27 @@ void WebAPIRequestMapper::resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevi
|
||||
audioOutputDevice.setUdpAddress(nullptr);
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::resetFeatureSettings(SWGSDRangel::SWGFeatureSettings& featureSettings)
|
||||
{
|
||||
featureSettings.cleanup();
|
||||
featureSettings.setFeatureType(nullptr);
|
||||
featureSettings.setSimplePttSettings(nullptr);
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::resetFeatureReport(SWGSDRangel::SWGFeatureReport& featureReport)
|
||||
{
|
||||
featureReport.cleanup();
|
||||
featureReport.setFeatureType(nullptr);
|
||||
featureReport.setSimplePttReport(nullptr);
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::resetFeatureActions(SWGSDRangel::SWGFeatureActions& featureActions)
|
||||
{
|
||||
featureActions.cleanup();
|
||||
featureActions.setFeatureType(nullptr);
|
||||
featureActions.setSimplePttActions(nullptr);
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::processChannelAnalyzerSettings(
|
||||
SWGSDRangel::SWGChannelSettings *channelSettings,
|
||||
const QJsonObject& channelSettingsJson,
|
||||
@@ -4419,4 +5036,4 @@ void WebAPIRequestMapper::processSoapySDRSettings(
|
||||
|
||||
appendSettingsArrayKeys(deviceSettingsJson, "tunableElements", deviceSettingsKeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace SWGSDRangel
|
||||
class SWGPreset;
|
||||
class SWGChannelConfig;
|
||||
class SWGDeviceConfig;
|
||||
class SWGFeatureActions;
|
||||
}
|
||||
|
||||
class SDRBASE_API WebAPIRequestMapper : public qtwebapp::HttpRequestHandler {
|
||||
@@ -74,6 +75,7 @@ private:
|
||||
void instancePresetFileService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceFeatureSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
|
||||
void devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void devicesetFocusService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
@@ -92,6 +94,14 @@ private:
|
||||
void devicesetChannelReportService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void devicesetChannelActionsService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
|
||||
void featuresetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void featuresetFeatureService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void featuresetFeatureIndexService(const std::string& featureSetIndexStr, const std::string& featureIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void featuresetFeatureRunService(const std::string& featureSetIndexStr, const std::string& featureIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void featuresetFeatureSettingsService(const std::string& featureSetIndexStr, const std::string& featureIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void featuresetFeatureReportService(const std::string& featureSetIndexStr, const std::string& featureIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void featuresetFeatureActionsService(const std::string& featureSetIndexStr, const std::string& featureIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
|
||||
bool validatePresetTransfer(SWGSDRangel::SWGPresetTransfer& presetTransfer);
|
||||
bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier& presetIdentifier);
|
||||
bool validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport);
|
||||
@@ -101,6 +111,8 @@ private:
|
||||
bool validateDeviceActions(SWGSDRangel::SWGDeviceActions& deviceActions, QJsonObject& jsonObject, QStringList& deviceActionsKeys);
|
||||
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys);
|
||||
bool validateChannelActions(SWGSDRangel::SWGChannelActions& channelActions, QJsonObject& jsonObject, QStringList& channelActionsKeys);
|
||||
bool validateFeatureSettings(SWGSDRangel::SWGFeatureSettings& featureSettings, QJsonObject& jsonObject, QStringList& featureSettingsKeys);
|
||||
bool validateFeatureActions(SWGSDRangel::SWGFeatureActions& featureActions, QJsonObject& jsonObject, QStringList& featureActionsKeys);
|
||||
bool validateAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice, QJsonObject& jsonObject, QStringList& audioInputDeviceKeys);
|
||||
bool validateAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice, QJsonObject& jsonObject, QStringList& audioOutputDeviceKeys);
|
||||
bool validateAMBEDevices(SWGSDRangel::SWGAMBEDevices& ambeDevices, QJsonObject& jsonObject);
|
||||
@@ -108,14 +120,15 @@ private:
|
||||
bool validateConfig(SWGSDRangel::SWGInstanceConfigResponse& config, QJsonObject& jsonObject, WebAPIAdapterInterface::ConfigKeys& configKeys);
|
||||
|
||||
bool appendPresetKeys(
|
||||
SWGSDRangel::SWGPreset *preset,
|
||||
const QJsonObject& presetJson,
|
||||
WebAPIAdapterInterface::PresetKeys& presetKeys);
|
||||
SWGSDRangel::SWGPreset *preset,
|
||||
const QJsonObject& presetJson,
|
||||
WebAPIAdapterInterface::PresetKeys& presetKeys
|
||||
);
|
||||
|
||||
bool appendPresetChannelKeys(
|
||||
SWGSDRangel::SWGChannelConfig *channel,
|
||||
const QJsonObject& channelSettngsJson,
|
||||
WebAPIAdapterInterface::ChannelKeys& channelKeys
|
||||
SWGSDRangel::SWGChannelConfig *channel,
|
||||
const QJsonObject& channelSettngsJson,
|
||||
WebAPIAdapterInterface::ChannelKeys& channelKeys
|
||||
);
|
||||
|
||||
bool getChannelSettings(
|
||||
@@ -133,9 +146,9 @@ private:
|
||||
);
|
||||
|
||||
bool appendPresetDeviceKeys(
|
||||
SWGSDRangel::SWGDeviceConfig *device,
|
||||
const QJsonObject& deviceSettngsJson,
|
||||
WebAPIAdapterInterface::DeviceKeys& devicelKeys
|
||||
SWGSDRangel::SWGDeviceConfig *device,
|
||||
const QJsonObject& deviceSettngsJson,
|
||||
WebAPIAdapterInterface::DeviceKeys& devicelKeys
|
||||
);
|
||||
|
||||
bool getDeviceSettings(
|
||||
@@ -153,15 +166,31 @@ private:
|
||||
);
|
||||
|
||||
void appendSettingsSubKeys(
|
||||
const QJsonObject& parentSettingsJsonObject,
|
||||
QJsonObject& childSettingsJsonObject,
|
||||
const QString& parentKey,
|
||||
QStringList& keyList);
|
||||
const QJsonObject& parentSettingsJsonObject,
|
||||
QJsonObject& childSettingsJsonObject,
|
||||
const QString& parentKey,
|
||||
QStringList& keyList
|
||||
);
|
||||
|
||||
void appendSettingsArrayKeys(
|
||||
const QJsonObject& parentSettingsJsonObject,
|
||||
const QString& parentKey,
|
||||
QStringList& keyList);
|
||||
const QJsonObject& parentSettingsJsonObject,
|
||||
const QString& parentKey,
|
||||
QStringList& keyList
|
||||
);
|
||||
|
||||
bool getFeatureSettings(
|
||||
const QString& featureSettingsKey,
|
||||
SWGSDRangel::SWGFeatureSettings *featureSettings,
|
||||
const QJsonObject& featureSettingsJson,
|
||||
QStringList& featureSettingsKeys
|
||||
);
|
||||
|
||||
bool getFeatureActions(
|
||||
const QString& featureActionsKey,
|
||||
SWGSDRangel::SWGFeatureActions *featureActions,
|
||||
const QJsonObject& featureActionsJson,
|
||||
QStringList& featureSettingsKeys
|
||||
);
|
||||
|
||||
bool parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response);
|
||||
|
||||
@@ -174,6 +203,9 @@ private:
|
||||
void resetChannelActions(SWGSDRangel::SWGChannelActions& channelActions);
|
||||
void resetAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice);
|
||||
void resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice);
|
||||
void resetFeatureSettings(SWGSDRangel::SWGFeatureSettings& deviceSettings);
|
||||
void resetFeatureReport(SWGSDRangel::SWGFeatureReport& featureReport);
|
||||
void resetFeatureActions(SWGSDRangel::SWGFeatureActions& featureActions);
|
||||
|
||||
void processChannelAnalyzerSettings(
|
||||
SWGSDRangel::SWGChannelSettings *channelSettings,
|
||||
@@ -198,6 +230,8 @@ private:
|
||||
static const QMap<QString, QString> m_sourceDeviceHwIdToActionsKey;
|
||||
static const QMap<QString, QString> m_sinkDeviceHwIdToActionsKey;
|
||||
static const QMap<QString, QString> m_mimoDeviceHwIdToActionsKey;
|
||||
static const QMap<QString, QString> m_featureTypeToSettingsKey;
|
||||
static const QMap<QString, QString> m_featureTypeToActionsKey;
|
||||
};
|
||||
|
||||
#endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */
|
||||
|
||||
Reference in New Issue
Block a user