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 //
|
2019-04-11 08:32:15 -04:00
|
|
|
// (at your option) any later version. //
|
2017-11-16 21:17:15 -05: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 11:12:53 -05:00
|
|
|
#include <QJsonParseError>
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
#include "httprequesthandler.h"
|
|
|
|
#include "httprequest.h"
|
|
|
|
#include "httpresponse.h"
|
2017-11-20 12:38:26 -05:00
|
|
|
#include "staticfilecontroller.h"
|
2017-11-16 21:17:15 -05:00
|
|
|
#include "webapiadapterinterface.h"
|
|
|
|
|
2018-03-20 08:49:21 -04:00
|
|
|
#include "export.h"
|
2018-03-03 14:23:38 -05:00
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
namespace SWGSDRangel
|
2017-11-25 13:42:56 -05:00
|
|
|
{
|
|
|
|
class SWGPresetTransfer;
|
|
|
|
class SWGPresetIdentifier;
|
|
|
|
}
|
|
|
|
|
2018-03-03 14:23:38 -05:00
|
|
|
class SDRBASE_API WebAPIRequestMapper : public qtwebapp::HttpRequestHandler {
|
2017-11-16 21:17:15 -05:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
WebAPIRequestMapper(QObject* parent=0);
|
2017-11-20 12:38:26 -05:00
|
|
|
~WebAPIRequestMapper();
|
2017-11-16 21:17:15 -05:00
|
|
|
void service(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void setAdapter(WebAPIAdapterInterface *adapter) { m_adapter = adapter; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
WebAPIAdapterInterface *m_adapter;
|
2017-11-20 12:38:26 -05:00
|
|
|
qtwebapp::StaticFileController *m_staticFileController;
|
2017-11-24 11:12:53 -05:00
|
|
|
|
|
|
|
void instanceSummaryService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
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 19:43:31 -04: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-24 22:02:11 -05:00
|
|
|
void instanceLocationService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-24 22:43:22 -05:00
|
|
|
void instanceDVSerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2019-07-20 19:57:51 -04:00
|
|
|
void instanceAMBESerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
|
|
|
void instanceAMBEDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-20 18:50:58 -05:00
|
|
|
void instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-25 05:14:52 -05:00
|
|
|
void instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-18 19:11:34 -05:00
|
|
|
void instancePresetFileService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-25 14:14:16 -05:00
|
|
|
void instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-21 19:07:03 -05:00
|
|
|
void instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-24 11:12:53 -05:00
|
|
|
|
2017-12-04 12:22:25 -05:00
|
|
|
void devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-01-05 21:46:53 -05:00
|
|
|
void devicesetFocusService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-04 12:22:25 -05:00
|
|
|
void devicesetDeviceService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-06 16:08:34 -05:00
|
|
|
void devicesetDeviceSettingsService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-08 11:12:33 -05:00
|
|
|
void devicesetDeviceRunService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-05-25 19:43:28 -04:00
|
|
|
void devicesetDeviceReportService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-03-18 19:08:38 -04:00
|
|
|
void devicesetChannelsReportService(const std::string& deviceSetIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-12-10 19:18:10 -05: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 14:27:08 -05:00
|
|
|
void devicesetChannelSettingsService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2018-03-18 15:17:11 -04:00
|
|
|
void devicesetChannelReportService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
2017-11-26 04:37:39 -05:00
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
bool validatePresetTransfer(SWGSDRangel::SWGPresetTransfer& presetTransfer);
|
|
|
|
bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier& presetIdentifier);
|
2017-12-18 19:11:34 -05:00
|
|
|
bool validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport);
|
2017-12-23 01:28:02 -05:00
|
|
|
bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject);
|
2017-12-26 19:46:33 -05:00
|
|
|
bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject, QStringList& deviceSettingsKeys);
|
2017-12-23 21:27:07 -05:00
|
|
|
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys);
|
2018-03-28 18:38:01 -04:00
|
|
|
bool validateAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice, QJsonObject& jsonObject, QStringList& audioInputDeviceKeys);
|
|
|
|
bool validateAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice, QJsonObject& jsonObject, QStringList& audioOutputDeviceKeys);
|
2019-07-20 19:57:51 -04:00
|
|
|
bool validateAMBEDevices(SWGSDRangel::SWGAMBEDevices& ambeDevices, QJsonObject& jsonObject);
|
2017-11-25 13:42:56 -05:00
|
|
|
|
2017-12-23 22:19:44 -05:00
|
|
|
void appendSettingsSubKeys(
|
|
|
|
const QJsonObject& parentSettingsJsonObject,
|
|
|
|
QJsonObject& childSettingsJsonObject,
|
|
|
|
const QString& parentKey,
|
|
|
|
QStringList& keyList);
|
|
|
|
|
2019-05-25 20:14:35 -04:00
|
|
|
void appendSettingsArrayKeys(
|
|
|
|
const QJsonObject& parentSettingsJsonObject,
|
|
|
|
const QString& parentKey,
|
|
|
|
QStringList& keyList);
|
|
|
|
|
2017-12-07 12:50:36 -05:00
|
|
|
bool parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response);
|
2017-12-06 16:08:34 -05:00
|
|
|
|
|
|
|
void resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings);
|
2018-05-28 05:44:32 -04:00
|
|
|
void resetDeviceReport(SWGSDRangel::SWGDeviceReport& deviceReport);
|
2017-12-10 14:27:08 -05:00
|
|
|
void resetChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings);
|
2018-03-18 15:17:11 -04:00
|
|
|
void resetChannelReport(SWGSDRangel::SWGChannelReport& deviceSettings);
|
2018-03-28 18:38:01 -04:00
|
|
|
void resetAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice);
|
|
|
|
void resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice);
|
2017-11-16 21:17:15 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */
|