2017-11-17 02:17:15 +00: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 //
|
2019-04-11 12:32:15 +00:00
|
|
|
// (at your option) any later version. //
|
2017-11-17 02:17:15 +00:00
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_
|
|
|
|
#define SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_
|
|
|
|
|
2017-11-24 16:12:53 +00:00
|
|
|
#include <QJsonParseError>
|
|
|
|
|
2017-11-17 02:17:15 +00:00
|
|
|
#include "httprequesthandler.h"
|
|
|
|
#include "httprequest.h"
|
|
|
|
#include "httpresponse.h"
|
2017-11-20 17:38:26 +00:00
|
|
|
#include "staticfilecontroller.h"
|
2017-11-17 02:17:15 +00:00
|
|
|
#include "webapiadapterinterface.h"
|
|
|
|
|
2018-03-20 12:49:21 +00:00
|
|
|
#include "export.h"
|
2018-03-03 19:23:38 +00:00
|
|
|
|
2017-12-02 04:45:30 +00:00
|
|
|
namespace SWGSDRangel
|
2017-11-25 18:42:56 +00:00
|
|
|
{
|
|
|
|
class SWGPresetTransfer;
|
|
|
|
class SWGPresetIdentifier;
|
2019-08-06 17:06:49 +00:00
|
|
|
class SWGPreset;
|
|
|
|
class SWGChannelConfig;
|
|
|
|
class SWGDeviceConfig;
|
2017-11-25 18:42:56 +00:00
|
|
|
}
|
|
|
|
|
2018-03-03 19:23:38 +00:00
|
|
|
class SDRBASE_API WebAPIRequestMapper : public qtwebapp::HttpRequestHandler {
|
2017-11-17 02:17:15 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
WebAPIRequestMapper(QObject* parent=0);
|
2017-11-20 17:38:26 +00:00
|
|
|
~WebAPIRequestMapper();
|
2017-11-17 02:17:15 +00:00
|
|
|
void service(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void setAdapter(WebAPIAdapterInterface *adapter) { m_adapter = adapter; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
WebAPIAdapterInterface *m_adapter;
|
2017-11-20 17:38:26 +00:00
|
|
|
qtwebapp::StaticFileController *m_staticFileController;
|
2017-11-24 16:12:53 +00:00
|
|
|
|
|
|
|
void instanceSummaryService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2019-08-01 00:16:56 +00:00
|
|
|
void instanceConfigService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-24 16:12:53 +00:00
|
|
|
void instanceDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceChannelsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceLoggingService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceAudioService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-03-28 23:43:31 +00:00
|
|
|
void instanceAudioInputParametersService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceAudioOutputParametersService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceAudioInputCleanupService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceAudioOutputCleanupService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-25 03:02:11 +00:00
|
|
|
void instanceLocationService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-25 03:43:22 +00:00
|
|
|
void instanceDVSerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2019-07-20 23:57:51 +00:00
|
|
|
void instanceAMBESerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceAMBEDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2020-01-12 00:16:04 +00:00
|
|
|
void instanceLimeRFESerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceLimeRFEConfigService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceLimeRFERunService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2020-01-14 14:26:49 +00:00
|
|
|
void instanceLimeRFEPowerService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-20 23:50:58 +00:00
|
|
|
void instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-25 10:14:52 +00:00
|
|
|
void instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-19 00:11:34 +00:00
|
|
|
void instancePresetFileService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-25 19:14:16 +00:00
|
|
|
void instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-22 00:07:03 +00:00
|
|
|
void instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-24 16:12:53 +00:00
|
|
|
|
2017-12-04 17:22:25 +00:00
|
|
|
void devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-01-06 02:46:53 +00:00
|
|
|
void devicesetFocusService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-04 17:22:25 +00:00
|
|
|
void devicesetDeviceService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-06 21:08:34 +00:00
|
|
|
void devicesetDeviceSettingsService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-08 16:12:33 +00:00
|
|
|
void devicesetDeviceRunService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2019-12-24 18:08:11 +00:00
|
|
|
void devicesetDeviceSubsystemRunService(const std::string& indexStr, const std::string& subsystemIndexStr,qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-05-25 23:43:28 +00:00
|
|
|
void devicesetDeviceReportService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2020-03-09 03:01:23 +00:00
|
|
|
void devicesetDeviceActionsService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-03-18 23:08:38 +00:00
|
|
|
void devicesetChannelsReportService(const std::string& deviceSetIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-11 00:18:10 +00:00
|
|
|
void devicesetChannelService(const std::string& deviceSetIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void devicesetChannelIndexService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-10 19:27:08 +00:00
|
|
|
void devicesetChannelSettingsService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-03-18 19:17:11 +00:00
|
|
|
void devicesetChannelReportService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2020-03-09 18:56:09 +00:00
|
|
|
void devicesetChannelActionsService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-26 09:37:39 +00:00
|
|
|
|
2017-12-02 04:45:30 +00:00
|
|
|
bool validatePresetTransfer(SWGSDRangel::SWGPresetTransfer& presetTransfer);
|
|
|
|
bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier& presetIdentifier);
|
2017-12-19 00:11:34 +00:00
|
|
|
bool validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport);
|
2017-12-23 06:28:02 +00:00
|
|
|
bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject);
|
2017-12-27 00:46:33 +00:00
|
|
|
bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject, QStringList& deviceSettingsKeys);
|
2020-03-09 18:56:09 +00:00
|
|
|
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);
|
2018-03-28 22:38:01 +00:00
|
|
|
bool validateAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice, QJsonObject& jsonObject, QStringList& audioInputDeviceKeys);
|
|
|
|
bool validateAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice, QJsonObject& jsonObject, QStringList& audioOutputDeviceKeys);
|
2019-07-20 23:57:51 +00:00
|
|
|
bool validateAMBEDevices(SWGSDRangel::SWGAMBEDevices& ambeDevices, QJsonObject& jsonObject);
|
2020-01-12 00:16:04 +00:00
|
|
|
bool validateLimeRFEConfig(SWGSDRangel::SWGLimeRFESettings& limeRFESettings, QJsonObject& jsonObject, QStringList& limeRFESettingsKeys);
|
2019-08-06 17:06:49 +00:00
|
|
|
bool validateConfig(SWGSDRangel::SWGInstanceConfigResponse& config, QJsonObject& jsonObject, WebAPIAdapterInterface::ConfigKeys& configKeys);
|
|
|
|
|
|
|
|
bool appendPresetKeys(
|
|
|
|
SWGSDRangel::SWGPreset *preset,
|
|
|
|
const QJsonObject& presetJson,
|
|
|
|
WebAPIAdapterInterface::PresetKeys& presetKeys);
|
|
|
|
|
|
|
|
bool appendPresetChannelKeys(
|
|
|
|
SWGSDRangel::SWGChannelConfig *channel,
|
2019-08-06 22:27:34 +00:00
|
|
|
const QJsonObject& channelSettngsJson,
|
2019-08-06 17:06:49 +00:00
|
|
|
WebAPIAdapterInterface::ChannelKeys& channelKeys
|
|
|
|
);
|
|
|
|
|
2020-03-09 18:56:09 +00:00
|
|
|
bool getChannelSettings(
|
2019-08-06 17:06:49 +00:00
|
|
|
const QString& channelSettingsKey,
|
|
|
|
SWGSDRangel::SWGChannelSettings *channelSettings,
|
|
|
|
const QJsonObject& channelSettingsJson,
|
|
|
|
QStringList& channelSettingsKeys
|
|
|
|
);
|
|
|
|
|
2020-03-09 18:56:09 +00:00
|
|
|
bool getChannelActions(
|
|
|
|
const QString& channelActionsKey,
|
|
|
|
SWGSDRangel::SWGChannelActions *channelActions,
|
|
|
|
const QJsonObject& channelActionsJson,
|
|
|
|
QStringList& channelSettingsKeys
|
|
|
|
);
|
|
|
|
|
2019-08-06 17:06:49 +00:00
|
|
|
bool appendPresetDeviceKeys(
|
|
|
|
SWGSDRangel::SWGDeviceConfig *device,
|
2019-08-06 22:27:34 +00:00
|
|
|
const QJsonObject& deviceSettngsJson,
|
|
|
|
WebAPIAdapterInterface::DeviceKeys& devicelKeys
|
|
|
|
);
|
|
|
|
|
2020-03-09 18:56:09 +00:00
|
|
|
bool getDeviceSettings(
|
2019-08-06 22:27:34 +00:00
|
|
|
const QString& deviceSettingsKey,
|
|
|
|
SWGSDRangel::SWGDeviceSettings *deviceSettings,
|
|
|
|
const QJsonObject& deviceSettingsJson,
|
2020-03-09 18:56:09 +00:00
|
|
|
QStringList& deviceActionsKeys
|
|
|
|
);
|
|
|
|
|
|
|
|
bool getDeviceActions(
|
|
|
|
const QString& deviceActionsKey,
|
|
|
|
SWGSDRangel::SWGDeviceActions *deviceActions,
|
|
|
|
const QJsonObject& deviceActionsJson,
|
|
|
|
QStringList& deviceActionsKeys
|
2019-08-06 17:06:49 +00:00
|
|
|
);
|
2017-11-25 18:42:56 +00:00
|
|
|
|
2017-12-24 03:19:44 +00:00
|
|
|
void appendSettingsSubKeys(
|
|
|
|
const QJsonObject& parentSettingsJsonObject,
|
|
|
|
QJsonObject& childSettingsJsonObject,
|
|
|
|
const QString& parentKey,
|
|
|
|
QStringList& keyList);
|
|
|
|
|
2019-05-26 00:14:35 +00:00
|
|
|
void appendSettingsArrayKeys(
|
|
|
|
const QJsonObject& parentSettingsJsonObject,
|
|
|
|
const QString& parentKey,
|
|
|
|
QStringList& keyList);
|
|
|
|
|
2017-12-07 17:50:36 +00:00
|
|
|
bool parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response);
|
2017-12-06 21:08:34 +00:00
|
|
|
|
|
|
|
void resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings);
|
2018-05-28 09:44:32 +00:00
|
|
|
void resetDeviceReport(SWGSDRangel::SWGDeviceReport& deviceReport);
|
2020-03-09 03:01:23 +00:00
|
|
|
void resetDeviceActions(SWGSDRangel::SWGDeviceActions& deviceActions);
|
2017-12-10 19:27:08 +00:00
|
|
|
void resetChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings);
|
2020-03-09 03:01:23 +00:00
|
|
|
void resetChannelReport(SWGSDRangel::SWGChannelReport& channelReport);
|
|
|
|
void resetChannelActions(SWGSDRangel::SWGChannelActions& channelActions);
|
2018-03-28 22:38:01 +00:00
|
|
|
void resetAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice);
|
|
|
|
void resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice);
|
2019-08-06 17:06:49 +00:00
|
|
|
|
2019-08-09 00:41:17 +00:00
|
|
|
void processChannelAnalyzerSettings(
|
|
|
|
SWGSDRangel::SWGChannelSettings *channelSettings,
|
|
|
|
const QJsonObject& channelSettingsJson,
|
|
|
|
QStringList& channelSettingsKeys
|
|
|
|
);
|
|
|
|
|
2019-08-13 10:18:47 +00:00
|
|
|
void processSoapySDRSettings(
|
|
|
|
SWGSDRangel::SWGDeviceSettings *deviceSettings,
|
|
|
|
QJsonObject& deviceSettingsJson,
|
|
|
|
QStringList& deviceSettingsKeys,
|
|
|
|
bool inputElseOutput
|
|
|
|
);
|
|
|
|
|
2019-08-06 17:06:49 +00:00
|
|
|
static const QMap<QString, QString> m_channelURIToSettingsKey;
|
2019-08-06 22:27:34 +00:00
|
|
|
static const QMap<QString, QString> m_deviceIdToSettingsKey;
|
|
|
|
static const QMap<QString, QString> m_channelTypeToSettingsKey;
|
|
|
|
static const QMap<QString, QString> m_sourceDeviceHwIdToSettingsKey;
|
|
|
|
static const QMap<QString, QString> m_sinkDeviceHwIdToSettingsKey;
|
2020-03-09 18:56:09 +00:00
|
|
|
static const QMap<QString, QString> m_mimoDeviceHwIdToSettingsKey;
|
|
|
|
static const QMap<QString, QString> m_channelTypeToActionsKey;
|
|
|
|
static const QMap<QString, QString> m_sourceDeviceHwIdToActionsKey;
|
|
|
|
static const QMap<QString, QString> m_sinkDeviceHwIdToActionsKey;
|
|
|
|
static const QMap<QString, QString> m_mimoDeviceHwIdToActionsKey;
|
2017-11-17 02:17:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */
|