SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
webapirequestmapper.h
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB. //
3 // //
4 // Swagger server adapter interface //
5 // //
6 // This program is free software; you can redistribute it and/or modify //
7 // it under the terms of the GNU General Public License as published by //
8 // the Free Software Foundation as version 3 of the License, or //
9 // (at your option) any later version. //
10 // //
11 // This program is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14 // GNU General Public License V3 for more details. //
15 // //
16 // You should have received a copy of the GNU General Public License //
17 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
19 
20 #ifndef SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_
21 #define SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_
22 
23 #include <QJsonParseError>
24 
25 #include "httprequesthandler.h"
26 #include "httprequest.h"
27 #include "httpresponse.h"
28 #include "staticfilecontroller.h"
29 #include "webapiadapterinterface.h"
30 
31 #include "export.h"
32 
33 namespace SWGSDRangel
34 {
35  class SWGPresetTransfer;
36  class SWGPresetIdentifier;
37 }
38 
40  Q_OBJECT
41 public:
42  WebAPIRequestMapper(QObject* parent=0);
44  void service(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
45  void setAdapter(WebAPIAdapterInterface *adapter) { m_adapter = adapter; }
46 
47 private:
50 
51  void instanceSummaryService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
52  void instanceConfigService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
53  void instanceDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
54  void instanceChannelsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
55  void instanceLoggingService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
56  void instanceAudioService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
57  void instanceAudioInputParametersService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
58  void instanceAudioOutputParametersService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
59  void instanceAudioInputCleanupService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
60  void instanceAudioOutputCleanupService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
61  void instanceLocationService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
62  void instanceDVSerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
63  void instanceAMBESerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
64  void instanceAMBEDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
65  void instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
66  void instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
67  void instancePresetFileService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
68  void instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
69  void instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
70 
71  void devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
72  void devicesetFocusService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
73  void devicesetDeviceService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
74  void devicesetDeviceSettingsService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
75  void devicesetDeviceRunService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
76  void devicesetDeviceReportService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
77  void devicesetChannelsReportService(const std::string& deviceSetIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
78  void devicesetChannelService(const std::string& deviceSetIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
79  void devicesetChannelIndexService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
80  void devicesetChannelSettingsService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
81  void devicesetChannelReportService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
82 
83  bool validatePresetTransfer(SWGSDRangel::SWGPresetTransfer& presetTransfer);
84  bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier& presetIdentifier);
85  bool validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport);
86  bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject);
87  bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject, QStringList& deviceSettingsKeys);
88  bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys);
89  bool validateAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice, QJsonObject& jsonObject, QStringList& audioInputDeviceKeys);
90  bool validateAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice, QJsonObject& jsonObject, QStringList& audioOutputDeviceKeys);
91  bool validateAMBEDevices(SWGSDRangel::SWGAMBEDevices& ambeDevices, QJsonObject& jsonObject);
92 
93  void appendSettingsSubKeys(
94  const QJsonObject& parentSettingsJsonObject,
95  QJsonObject& childSettingsJsonObject,
96  const QString& parentKey,
97  QStringList& keyList);
98 
99  void appendSettingsArrayKeys(
100  const QJsonObject& parentSettingsJsonObject,
101  const QString& parentKey,
102  QStringList& keyList);
103 
104  bool parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response);
105 
106  void resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings);
107  void resetDeviceReport(SWGSDRangel::SWGDeviceReport& deviceReport);
108  void resetChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings);
109  void resetChannelReport(SWGSDRangel::SWGChannelReport& deviceSettings);
110  void resetAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice);
111  void resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice);
112 };
113 
114 #endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */
qtwebapp::StaticFileController * m_staticFileController
void setAdapter(WebAPIAdapterInterface *adapter)
WebAPIAdapterInterface * m_adapter
#define SDRBASE_API
Definition: export.h:40