| 
									
										
										
										
											2017-11-17 03:17:15 +01: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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-24 18:17:13 +01:00
										 |  |  | #include <QDirIterator>
 | 
					
						
							| 
									
										
										
										
											2017-11-24 00:47:42 +01:00
										 |  |  | #include <QJsonDocument>
 | 
					
						
							|  |  |  | #include <QJsonArray>
 | 
					
						
							| 
									
										
										
										
											2017-11-22 00:28:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  | #include <boost/lexical_cast.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-20 18:38:26 +01:00
										 |  |  | #include "httpdocrootsettings.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-17 03:17:15 +01:00
										 |  |  | #include "webapirequestmapper.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-18 19:34:47 +01:00
										 |  |  | #include "SWGInstanceSummaryResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-22 18:57:35 +01:00
										 |  |  | #include "SWGInstanceDevicesResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  | #include "SWGInstanceChannelsResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-24 08:46:12 +01:00
										 |  |  | #include "SWGAudioDevices.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  | #include "SWGLocationInformation.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  | #include "SWGDVSeralDevices.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  | #include "SWGPresets.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-25 16:08:18 +01:00
										 |  |  | #include "SWGPresetTransfer.h"
 | 
					
						
							|  |  |  | #include "SWGPresetIdentifier.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  | #include "SWGPresetImport.h"
 | 
					
						
							|  |  |  | #include "SWGPresetExport.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-04 23:07:30 +01:00
										 |  |  | #include "SWGDeviceSettings.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  | #include "SWGDeviceState.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  | #include "SWGDeviceReport.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:08:38 +01:00
										 |  |  | #include "SWGChannelsDetail.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-10 20:27:08 +01:00
										 |  |  | #include "SWGChannelSettings.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-18 20:17:11 +01:00
										 |  |  | #include "SWGChannelReport.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-19 17:55:05 +01:00
										 |  |  | #include "SWGSuccessResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-18 19:34:47 +01:00
										 |  |  | #include "SWGErrorResponse.h"
 | 
					
						
							| 
									
										
										
										
											2017-11-17 03:17:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | WebAPIRequestMapper::WebAPIRequestMapper(QObject* parent) : | 
					
						
							|  |  |  |     HttpRequestHandler(parent), | 
					
						
							|  |  |  |     m_adapter(0) | 
					
						
							| 
									
										
										
										
											2017-11-20 18:38:26 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     qtwebapp::HttpDocrootSettings docrootSettings; | 
					
						
							| 
									
										
										
										
											2018-01-24 18:17:13 +01:00
										 |  |  |     docrootSettings.path = ":/webapi"; | 
					
						
							| 
									
										
										
										
											2017-11-20 18:38:26 +01:00
										 |  |  |     m_staticFileController = new qtwebapp::StaticFileController(docrootSettings, parent); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | WebAPIRequestMapper::~WebAPIRequestMapper() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete m_staticFileController; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-11-17 03:17:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-18 19:34:47 +01:00
										 |  |  | void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							| 
									
										
										
										
											2017-11-17 03:17:15 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (m_adapter == 0) // format service unavailable if adapter is null
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-22 15:27:25 +01:00
										 |  |  |         SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |         response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |         response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-17 08:52:15 +01:00
										 |  |  |         response.setStatus(500,"Service not available"); | 
					
						
							| 
									
										
										
										
											2017-12-22 15:27:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Service not available"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-17 03:17:15 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else // normal processing
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QByteArray path=request.getPath(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-21 22:28:35 +02:00
										 |  |  |         // Handle pre-flight requests
 | 
					
						
							|  |  |  |         if (request.getMethod() == "OPTIONS") | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qDebug("WebAPIRequestMapper::service: method OPTIONS: assume pre-flight"); | 
					
						
							|  |  |  |             response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							|  |  |  |             response.setHeader("Access-Control-Allow-Headers", "*"); | 
					
						
							|  |  |  |             response.setHeader("Access-Control-Allow-Methods", "*"); | 
					
						
							|  |  |  |             response.setStatus(200, "OK"); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01: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); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |         } else if (path == WebAPIAdapterInterface::instanceAudioInputParametersURL) { | 
					
						
							|  |  |  |             instanceAudioInputParametersService(request, response); | 
					
						
							|  |  |  |         } else if (path == WebAPIAdapterInterface::instanceAudioOutputParametersURL) { | 
					
						
							|  |  |  |             instanceAudioOutputParametersService(request, response); | 
					
						
							|  |  |  |         } else if (path == WebAPIAdapterInterface::instanceAudioInputCleanupURL) { | 
					
						
							|  |  |  |             instanceAudioInputCleanupService(request, response); | 
					
						
							|  |  |  |         } else if (path == WebAPIAdapterInterface::instanceAudioOutputCleanupURL) { | 
					
						
							|  |  |  |             instanceAudioOutputCleanupService(request, response); | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  |         } else if (path == WebAPIAdapterInterface::instanceLocationURL) { | 
					
						
							|  |  |  |             instanceLocationService(request, response); | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  |         } else if (path == WebAPIAdapterInterface::instanceDVSerialURL) { | 
					
						
							|  |  |  |             instanceDVSerialService(request, response); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:50:58 +01:00
										 |  |  |         } else if (path == WebAPIAdapterInterface::instancePresetsURL) { | 
					
						
							|  |  |  |             instancePresetsService(request, response); | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  |         } else if (path == WebAPIAdapterInterface::instancePresetURL) { | 
					
						
							|  |  |  |             instancePresetService(request, response); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         } else if (path == WebAPIAdapterInterface::instancePresetFileURL) { | 
					
						
							|  |  |  |             instancePresetFileService(request, response); | 
					
						
							| 
									
										
										
										
											2017-11-25 20:14:16 +01:00
										 |  |  |         } else if (path == WebAPIAdapterInterface::instanceDeviceSetsURL) { | 
					
						
							|  |  |  |             instanceDeviceSetsService(request, response); | 
					
						
							| 
									
										
										
										
											2017-12-22 01:07:03 +01:00
										 |  |  |         } else if (path == WebAPIAdapterInterface::instanceDeviceSetURL) { | 
					
						
							|  |  |  |             instanceDeviceSetService(request, response); | 
					
						
							| 
									
										
										
										
											2017-11-17 03:17:15 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2017-11-22 18:57:35 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  |             std::smatch desc_match; | 
					
						
							|  |  |  |             std::string pathStr(path.constData(), path.length()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetURLRe)) { | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  |                 devicesetService(std::string(desc_match[1]), request, response); | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  |             } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceURLRe)) { | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  |                 devicesetDeviceService(std::string(desc_match[1]), request, response); | 
					
						
							| 
									
										
										
										
											2018-01-06 03:46:53 +01:00
										 |  |  |             } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetFocusURLRe)) { | 
					
						
							|  |  |  |                 devicesetFocusService(std::string(desc_match[1]), request, response); | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  |             } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceSettingsURLRe)) { | 
					
						
							|  |  |  |                 devicesetDeviceSettingsService(std::string(desc_match[1]), request, response); | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  |             } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceRunURLRe)) { | 
					
						
							|  |  |  |                 devicesetDeviceRunService(std::string(desc_match[1]), request, response); | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  |             } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceReportURLRe)) { | 
					
						
							|  |  |  |                 devicesetDeviceReportService(std::string(desc_match[1]), request, response); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:08:38 +01:00
										 |  |  |             } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelsReportURLRe)) { | 
					
						
							|  |  |  |                 devicesetChannelsReportService(std::string(desc_match[1]), request, response); | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01: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 20:27:08 +01:00
										 |  |  |             } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelSettingsURLRe)) { | 
					
						
							|  |  |  |                 devicesetChannelSettingsService(std::string(desc_match[1]), std::string(desc_match[2]), request, response); | 
					
						
							| 
									
										
										
										
											2018-03-18 20:17:11 +01:00
										 |  |  |             } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelReportURLRe)) { | 
					
						
							|  |  |  |                 devicesetChannelReportService(std::string(desc_match[1]), std::string(desc_match[2]), request, response); | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2018-01-24 18:17:13 +01:00
										 |  |  |             else // serve static documentation pages
 | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-01-24 18:17:13 +01:00
										 |  |  |                 m_staticFileController->service(request, response); | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | //            QDirIterator it(":", QDirIterator::Subdirectories);
 | 
					
						
							|  |  |  | //            while (it.hasNext()) {
 | 
					
						
							|  |  |  | //                qDebug() << "WebAPIRequestMapper::service: " << it.next();
 | 
					
						
							|  |  |  | //            }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-22 18:57:35 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::instanceSummaryService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGInstanceSummaryResponse normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceSummary(normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     else if (request.getMethod() == "DELETE") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         SWGSDRangel::SWGSuccessResponse normalResponse; | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceDelete(normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::instanceDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGInstanceDevicesResponse normalResponse; | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QByteArray txStr = request.getParameter("tx"); | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  |         bool tx = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (txStr.length() != 0) { | 
					
						
							|  |  |  |             tx = !(txStr == "0"); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceDevices(tx, normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::instanceChannelsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGInstanceChannelsResponse normalResponse; | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QByteArray txStr = request.getParameter("tx"); | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  |         bool tx = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (txStr.length() != 0) { | 
					
						
							|  |  |  |             tx = !(txStr == "0"); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceChannels(tx, normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::instanceLoggingService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |     SWGSDRangel::SWGLoggingInfo query; | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGLoggingInfo normalResponse; | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int status = m_adapter->instanceLoggingGet(normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (request.getMethod() == "PUT") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QString jsonStr = request.getBody(); | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         QJsonObject jsonObject; | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-11-23 18:43:01 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-02-14 01:42:35 +01:00
										 |  |  |             query.fromJson(jsonStr); | 
					
						
							|  |  |  |             int status = m_adapter->instanceLoggingPut(query, normalResponse, errorResponse); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |             response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |                 response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-23 18:43:01 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-11-24 08:46:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | void WebAPIRequestMapper::instanceAudioService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-24 08:46:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGAudioDevices normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-24 08:46:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |         int status = m_adapter->instanceAudioGet(normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-24 08:46:12 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							|  |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  | void WebAPIRequestMapper::instanceAudioInputParametersService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     // TODO
 | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |     QString jsonStr = request.getBody(); | 
					
						
							|  |  |  |     QJsonObject jsonObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |         SWGSDRangel::SWGAudioInputDevice normalResponse; | 
					
						
							|  |  |  |         resetAudioInputDevice(normalResponse); | 
					
						
							|  |  |  |         QStringList audioInputDeviceKeys; | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |         if (validateAudioInputDevice(normalResponse, jsonObject, audioInputDeviceKeys)) | 
					
						
							| 
									
										
										
										
											2017-11-17 08:52:15 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |             if (request.getMethod() == "PATCH") | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |             { | 
					
						
							|  |  |  |                 int status = m_adapter->instanceAudioInputPatch( | 
					
						
							|  |  |  |                         normalResponse, | 
					
						
							|  |  |  |                         audioInputDeviceKeys, | 
					
						
							|  |  |  |                         errorResponse); | 
					
						
							|  |  |  |                 response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (status/100 == 2) { | 
					
						
							|  |  |  |                     response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |             else if (request.getMethod() == "DELETE") | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 int status = m_adapter->instanceAudioInputDelete( | 
					
						
							|  |  |  |                         normalResponse, | 
					
						
							|  |  |  |                         errorResponse); | 
					
						
							|  |  |  |                 response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (status/100 == 2) { | 
					
						
							|  |  |  |                     response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |                 response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |                 errorResponse.init(); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |                 *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |             response.setStatus(400,"Invalid JSON request"); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |             errorResponse.init(); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |             *errorResponse.getMessage() = "Invalid JSON request"; | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |         response.setStatus(400,"Invalid JSON format"); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         errorResponse.init(); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |         *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  | void WebAPIRequestMapper::instanceAudioOutputParametersService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |     QString jsonStr = request.getBody(); | 
					
						
							|  |  |  |     QJsonObject jsonObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |         SWGSDRangel::SWGAudioOutputDevice normalResponse; | 
					
						
							|  |  |  |         resetAudioOutputDevice(normalResponse); | 
					
						
							|  |  |  |         QStringList audioOutputDeviceKeys; | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |         if (validateAudioOutputDevice(normalResponse, jsonObject, audioOutputDeviceKeys)) | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |             if (request.getMethod() == "PATCH") | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |             { | 
					
						
							|  |  |  |                 int status = m_adapter->instanceAudioOutputPatch( | 
					
						
							|  |  |  |                         normalResponse, | 
					
						
							|  |  |  |                         audioOutputDeviceKeys, | 
					
						
							|  |  |  |                         errorResponse); | 
					
						
							|  |  |  |                 response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (status/100 == 2) { | 
					
						
							|  |  |  |                     response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |             else if (request.getMethod() == "DELETE") | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 int status = m_adapter->instanceAudioOutputDelete( | 
					
						
							|  |  |  |                         normalResponse, | 
					
						
							|  |  |  |                         errorResponse); | 
					
						
							|  |  |  |                 response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (status/100 == 2) { | 
					
						
							|  |  |  |                     response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |                 response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |                 errorResponse.init(); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |                 *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |             response.setStatus(400,"Invalid JSON request"); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             errorResponse.init(); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  |             *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()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::instanceAudioInputCleanupService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "PATCH") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SWGSDRangel::SWGSuccessResponse normalResponse; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceAudioInputCleanupPatch(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::instanceAudioOutputCleanupService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2018-03-29 01:43:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "PATCH") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SWGSDRangel::SWGSuccessResponse normalResponse; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceAudioOutputCleanupPatch(normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (status/100 == 2) { | 
					
						
							|  |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  | void WebAPIRequestMapper::instanceLocationService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGLocationInformation normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceLocationGet(normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (request.getMethod() == "PUT") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGLocationInformation normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  |         QString jsonStr = request.getBody(); | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         QJsonObject jsonObject; | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             normalResponse.fromJson(jsonStr); | 
					
						
							|  |  |  |             int status = m_adapter->instanceLocationPut(normalResponse, errorResponse); | 
					
						
							|  |  |  |             response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  |                 response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  | void WebAPIRequestMapper::instanceDVSerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-02 23:05:53 +02:00
										 |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         SWGSDRangel::SWGDVSeralDevices normalResponse; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceDVSerialGet(normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (status/100 == 2) { | 
					
						
							|  |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (request.getMethod() == "PATCH") | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         QByteArray dvserialStr = request.getParameter("dvserial"); | 
					
						
							|  |  |  |         bool dvserial = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (dvserialStr.length() != 0) { | 
					
						
							|  |  |  |             dvserial = !(dvserialStr == "0"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGDVSeralDevices normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         int status = m_adapter->instanceDVSerialPatch(dvserial, normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-25 04:43:22 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 00:50:58 +01:00
										 |  |  | void WebAPIRequestMapper::instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGPresets normalResponse; | 
					
						
							| 
									
										
										
										
											2017-12-21 00:50:58 +01:00
										 |  |  |         int status = m_adapter->instancePresetsGet(normalResponse, errorResponse); | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-21 00:50:58 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-21 00:50:58 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "PATCH") | 
					
						
							| 
									
										
										
										
											2017-11-25 16:08:18 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGPresetTransfer query; | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetIdentifier normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 16:08:18 +01:00
										 |  |  |         QString jsonStr = request.getBody(); | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         QJsonObject jsonObject; | 
					
						
							| 
									
										
										
										
											2017-11-25 16:08:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-11-25 16:08:18 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             query.fromJson(jsonStr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  |             if (validatePresetTransfer(query)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 int status = m_adapter->instancePresetPatch(query, normalResponse, errorResponse); | 
					
						
							|  |  |  |                 response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |                 if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01: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 16:08:18 +01:00
										 |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-25 16:08:18 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-11-25 16:47:13 +01:00
										 |  |  |     else if (request.getMethod() == "PUT") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGPresetTransfer query; | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetIdentifier normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 16:47:13 +01:00
										 |  |  |         QString jsonStr = request.getBody(); | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         QJsonObject jsonObject; | 
					
						
							| 
									
										
										
										
											2017-11-25 16:47:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-11-25 16:47:13 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             query.fromJson(jsonStr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  |             if (validatePresetTransfer(query)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 int status = m_adapter->instancePresetPut(query, normalResponse, errorResponse); | 
					
						
							|  |  |  |                 response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |                 if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01: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 16:47:13 +01:00
										 |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-25 16:47:13 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-11-25 18:32:37 +01:00
										 |  |  |     else if (request.getMethod() == "POST") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGPresetTransfer query; | 
					
						
							|  |  |  |         SWGSDRangel::SWGPresetIdentifier normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 18:32:37 +01:00
										 |  |  |         QString jsonStr = request.getBody(); | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         QJsonObject jsonObject; | 
					
						
							| 
									
										
										
										
											2017-11-25 18:32:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-11-25 18:32:37 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             query.fromJson(jsonStr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  |             if (validatePresetTransfer(query)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 int status = m_adapter->instancePresetPost(query, normalResponse, errorResponse); | 
					
						
							|  |  |  |                 response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |                 if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01: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-19 01:11:34 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else if (request.getMethod() == "DELETE") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGPresetIdentifier normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  |         QString jsonStr = request.getBody(); | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         QJsonObject jsonObject; | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             normalResponse.fromJson(jsonStr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (validatePresetIdentifer(normalResponse)) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 int status = m_adapter->instancePresetDelete(normalResponse, errorResponse); | 
					
						
							|  |  |  |                 response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |                 if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01: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 18:32:37 +01:00
										 |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01: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"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     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 18:10:43 +01:00
										 |  |  |                 if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |                     response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |                 response.setStatus(400,"Invalid JSON request"); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |                 errorResponse.init(); | 
					
						
							|  |  |  |                 *errorResponse.getMessage() = "Invalid JSON request"; | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |             *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01: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 18:10:43 +01:00
										 |  |  |                 if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |                     response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |                 response.setStatus(400,"Invalid JSON request"); | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |                 errorResponse.init(); | 
					
						
							|  |  |  |                 *errorResponse.getMessage() = "Invalid JSON request"; | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |             *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-25 18:32:37 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-25 20:14:16 +01:00
										 |  |  | void WebAPIRequestMapper::instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-25 20:14:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |         SWGSDRangel::SWGDeviceSetList normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 20:14:16 +01:00
										 |  |  |         int status = m_adapter->instanceDeviceSetsGet(normalResponse, errorResponse); | 
					
						
							|  |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 20:14:16 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-22 01:07:03 +01: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"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-22 01:07:03 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "POST") | 
					
						
							| 
									
										
										
										
											2017-11-25 22:52:24 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-19 17:55:05 +01:00
										 |  |  |         SWGSDRangel::SWGSuccessResponse normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-25 22:52:24 +01:00
										 |  |  |         QByteArray txStr = request.getParameter("tx"); | 
					
						
							|  |  |  |         bool tx = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (txStr.length() != 0) { | 
					
						
							|  |  |  |             tx = !(txStr == "0"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 01:07:03 +01:00
										 |  |  |         int status = m_adapter->instanceDeviceSetPost(tx, normalResponse, errorResponse); | 
					
						
							| 
									
										
										
										
											2017-11-25 22:52:24 +01:00
										 |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 22:52:24 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (request.getMethod() == "DELETE") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-19 17:55:05 +01:00
										 |  |  |         SWGSDRangel::SWGSuccessResponse normalResponse; | 
					
						
							| 
									
										
										
										
											2017-12-22 01:07:03 +01:00
										 |  |  |         int status = m_adapter->instanceDeviceSetDelete(normalResponse, errorResponse); | 
					
						
							| 
									
										
										
										
											2017-11-25 22:52:24 +01:00
										 |  |  |         response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |         if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-25 22:52:24 +01:00
										 |  |  |             response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-11-25 20:14:16 +01:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-25 20:14:16 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | void WebAPIRequestMapper::devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         try | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |             SWGSDRangel::SWGDeviceSet normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  |             int deviceSetIndex = boost::lexical_cast<int>(indexStr); | 
					
						
							|  |  |  |             int status = m_adapter->devicesetGet(deviceSetIndex, normalResponse, errorResponse); | 
					
						
							|  |  |  |             response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01: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 18:56:24 +01:00
										 |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-26 10:37:39 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-06 03:46:53 +01:00
										 |  |  | void WebAPIRequestMapper::devicesetFocusService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2018-01-06 03:46:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int deviceSetIndex = boost::lexical_cast<int>(indexStr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (request.getMethod() == "PATCH") | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGSuccessResponse normalResponse; | 
					
						
							|  |  |  |             int status = m_adapter->devicesetFocusPatch(deviceSetIndex, 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 device set index"; | 
					
						
							|  |  |  |         response.setStatus(400,"Invalid data"); | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | void WebAPIRequestMapper::devicesetDeviceService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int deviceSetIndex = boost::lexical_cast<int>(indexStr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (request.getMethod() == "PUT") | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QString jsonStr = request.getBody(); | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |             QJsonObject jsonObject; | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |             if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-02-14 13:40:34 +01:00
										 |  |  |                 SWGSDRangel::SWGDeviceListItem query; | 
					
						
							| 
									
										
										
										
											2017-12-23 07:28:02 +01:00
										 |  |  |                 SWGSDRangel::SWGDeviceListItem normalResponse; | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 13:40:34 +01:00
										 |  |  |                 if (validateDeviceListItem(query, jsonObject)) | 
					
						
							| 
									
										
										
										
											2017-12-23 07:28:02 +01:00
										 |  |  |                 { | 
					
						
							| 
									
										
										
										
											2018-02-14 13:40:34 +01:00
										 |  |  |                     int status = m_adapter->devicesetDevicePut(deviceSetIndex, query, normalResponse, errorResponse); | 
					
						
							| 
									
										
										
										
											2017-12-23 07:28:02 +01:00
										 |  |  |                     response.setStatus(status); | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-23 07:28:02 +01: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 08:14:07 +01:00
										 |  |  |                     response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01:00
										 |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |                 errorResponse.init(); | 
					
						
							|  |  |  |                 *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01: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 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int deviceSetIndex = boost::lexical_cast<int>(indexStr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |         if ((request.getMethod() == "PUT") || (request.getMethod() == "PATCH")) | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |             QString jsonStr = request.getBody(); | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |             QJsonObject jsonObject; | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |             if (parseJsonBody(jsonStr, jsonObject, response)) | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |             { | 
					
						
							|  |  |  |                 SWGSDRangel::SWGDeviceSettings normalResponse; | 
					
						
							| 
									
										
										
										
											2017-12-07 22:38:39 +01:00
										 |  |  |                 resetDeviceSettings(normalResponse); | 
					
						
							| 
									
										
										
										
											2017-12-27 01:46:33 +01:00
										 |  |  |                 QStringList deviceSettingsKeys; | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-27 01:46:33 +01:00
										 |  |  |                 if (validateDeviceSettings(normalResponse, jsonObject, deviceSettingsKeys)) | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |                 { | 
					
						
							|  |  |  |                     int status = m_adapter->devicesetDeviceSettingsPutPatch( | 
					
						
							|  |  |  |                             deviceSetIndex, | 
					
						
							|  |  |  |                             (request.getMethod() == "PUT"), // force settings on PUT
 | 
					
						
							| 
									
										
										
										
											2017-12-27 01:46:33 +01:00
										 |  |  |                             deviceSettingsKeys, | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |                             normalResponse, | 
					
						
							|  |  |  |                             errorResponse); | 
					
						
							|  |  |  |                     response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |                     if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01: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-19 01:11:34 +01:00
										 |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |                 errorResponse.init(); | 
					
						
							|  |  |  |                 *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  |         else if (request.getMethod() == "GET") | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGDeviceSettings normalResponse; | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  |             resetDeviceSettings(normalResponse); | 
					
						
							|  |  |  |             int status = m_adapter->devicesetDeviceSettingsGet(deviceSetIndex, normalResponse, errorResponse); | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  |             response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  |                 response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     catch (const boost::bad_lexical_cast &e) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Wrong integer conversion on device set index"; | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01: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 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int deviceSetIndex = boost::lexical_cast<int>(indexStr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-09 10:49:20 +01:00
										 |  |  |         if (request.getMethod() == "GET") | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGDeviceState normalResponse; | 
					
						
							|  |  |  |             int status = m_adapter->devicesetDeviceRunGet(deviceSetIndex, normalResponse, errorResponse); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-09 10:49:20 +01:00
										 |  |  |                 response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else if (request.getMethod() == "POST") | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGDeviceState normalResponse; | 
					
						
							|  |  |  |             int status = m_adapter->devicesetDeviceRunPost(deviceSetIndex, normalResponse, errorResponse); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01: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 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  |                 response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     catch (const boost::bad_lexical_cast &e) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         errorResponse.init(); | 
					
						
							|  |  |  |         *errorResponse.getMessage() = "Wrong integer conversion on device set index"; | 
					
						
							| 
									
										
										
										
											2017-11-27 08:14:07 +01:00
										 |  |  |         response.setStatus(400,"Invalid data"); | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  | void WebAPIRequestMapper::devicesetDeviceReportService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         try | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGDeviceReport normalResponse; | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |             resetDeviceReport(normalResponse); | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  |             int deviceSetIndex = boost::lexical_cast<int>(indexStr); | 
					
						
							|  |  |  |             int status = m_adapter->devicesetDeviceReportGet(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()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-19 00:08:38 +01:00
										 |  |  | void WebAPIRequestMapper::devicesetChannelsReportService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2018-03-19 00:08:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (request.getMethod() == "GET") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         try | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelsDetail normalResponse; | 
					
						
							|  |  |  |             int deviceSetIndex = boost::lexical_cast<int>(indexStr); | 
					
						
							|  |  |  |             int status = m_adapter->devicesetChannelsReportGet(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()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  | void WebAPIRequestMapper::devicesetChannelService( | 
					
						
							|  |  |  |         const std::string& deviceSetIndexStr, | 
					
						
							|  |  |  |         qtwebapp::HttpRequest& request, | 
					
						
							|  |  |  |         qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01: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 17:55:05 +01:00
										 |  |  |                 SWGSDRangel::SWGChannelSettings query; | 
					
						
							|  |  |  |                 SWGSDRangel::SWGSuccessResponse normalResponse; | 
					
						
							|  |  |  |                 resetChannelSettings(query); | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 if (jsonObject.contains("tx")) { | 
					
						
							| 
									
										
										
										
											2017-12-19 17:55:05 +01:00
										 |  |  |                     query.setTx(jsonObject["tx"].toInt()); | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  |                 } else { | 
					
						
							| 
									
										
										
										
											2017-12-19 17:55:05 +01:00
										 |  |  |                     query.setTx(0); // assume Rx
 | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (jsonObject.contains("channelType") && jsonObject["channelType"].isString()) | 
					
						
							|  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2017-12-19 17:55:05 +01:00
										 |  |  |                     query.setChannelType(new QString(jsonObject["channelType"].toString())); | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-19 17:55:05 +01:00
										 |  |  |                     int status = m_adapter->devicesetChannelPost(deviceSetIndex, query, normalResponse, errorResponse); | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |                     if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01: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-19 01:11:34 +01:00
										 |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |                 errorResponse.init(); | 
					
						
							|  |  |  |                 *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(405,"Invalid HTTP method"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01: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 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr); | 
					
						
							|  |  |  |         int channelIndex = boost::lexical_cast<int>(channelIndexStr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (request.getMethod() == "DELETE") | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  |             SWGSDRangel::SWGSuccessResponse normalResponse; | 
					
						
							|  |  |  |             int status = m_adapter->devicesetChannelDelete(deviceSetIndex, channelIndex, normalResponse, errorResponse); | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01:00
										 |  |  |                 response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(405,"Invalid HTTP method"); | 
					
						
							|  |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-11 01:18:10 +01: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 20:27:08 +01:00
										 |  |  | void WebAPIRequestMapper::devicesetChannelSettingsService( | 
					
						
							|  |  |  |         const std::string& deviceSetIndexStr, | 
					
						
							|  |  |  |         const std::string& channelIndexStr, | 
					
						
							|  |  |  |         qtwebapp::HttpRequest& request, | 
					
						
							|  |  |  |         qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2017-12-10 20:27:08 +01: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 18:10:43 +01:00
										 |  |  |             if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-10 20:27:08 +01:00
										 |  |  |                 response.write(normalResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01: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-24 03:27:07 +01:00
										 |  |  |                 QStringList channelSettingsKeys; | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |                 if (validateChannelSettings(normalResponse, jsonObject, channelSettingsKeys)) | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01:00
										 |  |  |                 { | 
					
						
							|  |  |  |                     int status = m_adapter->devicesetChannelSettingsPutPatch( | 
					
						
							|  |  |  |                             deviceSetIndex, | 
					
						
							|  |  |  |                             channelIndex, | 
					
						
							|  |  |  |                             (request.getMethod() == "PUT"), // force settings on PUT
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |                             channelSettingsKeys, | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01:00
										 |  |  |                             normalResponse, | 
					
						
							|  |  |  |                             errorResponse); | 
					
						
							|  |  |  |                     response.setStatus(status); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 18:10:43 +01:00
										 |  |  |                     if (status/100 == 2) { | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01: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-19 01:11:34 +01:00
										 |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 response.setStatus(400,"Invalid JSON format"); | 
					
						
							|  |  |  |                 errorResponse.init(); | 
					
						
							|  |  |  |                 *errorResponse.getMessage() = "Invalid JSON format"; | 
					
						
							|  |  |  |                 response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-12-10 20:27:08 +01:00
										 |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             response.setStatus(405,"Invalid HTTP method"); | 
					
						
							| 
									
										
										
										
											2017-12-12 18:56:24 +01:00
										 |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = "Invalid HTTP method"; | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-12-10 20:27:08 +01: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()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-18 20:17:11 +01:00
										 |  |  | void WebAPIRequestMapper::devicesetChannelReportService( | 
					
						
							|  |  |  |         const std::string& deviceSetIndexStr, | 
					
						
							|  |  |  |         const std::string& channelIndexStr, | 
					
						
							|  |  |  |         qtwebapp::HttpRequest& request, | 
					
						
							|  |  |  |         qtwebapp::HttpResponse& response) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							|  |  |  |     response.setHeader("Content-Type", "application/json"); | 
					
						
							| 
									
										
										
										
											2018-07-17 01:50:32 +02:00
										 |  |  |     response.setHeader("Access-Control-Allow-Origin", "*"); | 
					
						
							| 
									
										
										
										
											2018-03-18 20:17:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr); | 
					
						
							|  |  |  |         int channelIndex = boost::lexical_cast<int>(channelIndexStr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (request.getMethod() == "GET") | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelReport normalResponse; | 
					
						
							|  |  |  |             resetChannelReport(normalResponse); | 
					
						
							|  |  |  |             int status = m_adapter->devicesetChannelReportGet(deviceSetIndex, channelIndex, 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 index"; | 
					
						
							|  |  |  |         response.setStatus(400,"Invalid data"); | 
					
						
							|  |  |  |         response.write(errorResponse.asJson().toUtf8()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  | bool WebAPIRequestMapper::parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response) | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGErrorResponse errorResponse; | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     try | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         QByteArray jsonBytes(jsonStr.toStdString().c_str()); | 
					
						
							|  |  |  |         QJsonParseError error; | 
					
						
							|  |  |  |         QJsonDocument doc = QJsonDocument::fromJson(jsonBytes, &error); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 18:50:36 +01:00
										 |  |  |         if (error.error == QJsonParseError::NoError) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             jsonObject = doc.object(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-11-25 04:02:11 +01:00
										 |  |  |             QString errorMsg = QString("Input JSON error: ") + error.errorString() + QString(" at offset ") + QString::number(error.offset); | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01:00
										 |  |  |             errorResponse.init(); | 
					
						
							|  |  |  |             *errorResponse.getMessage() = errorMsg; | 
					
						
							|  |  |  |             response.setStatus(400, errorMsg.toUtf8()); | 
					
						
							|  |  |  |             response.write(errorResponse.asJson().toUtf8()); | 
					
						
							| 
									
										
										
										
											2017-11-17 08:52:15 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-24 17:12:53 +01: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-17 03:17:15 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  | bool WebAPIRequestMapper::validatePresetTransfer(SWGSDRangel::SWGPresetTransfer& presetTransfer) | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  |     SWGSDRangel::SWGPresetIdentifier *presetIdentifier = presetTransfer.getPreset(); | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (presetIdentifier == 0) { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return validatePresetIdentifer(*presetIdentifier); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-02 05:45:30 +01:00
										 |  |  | bool WebAPIRequestMapper::validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier& presetIdentifier) | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return (presetIdentifier.getGroupName() && presetIdentifier.getName() && presetIdentifier.getType()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-19 01:11:34 +01: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 07:28:02 +01: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-27 01:46:33 +01:00
										 |  |  | bool WebAPIRequestMapper::validateDeviceSettings( | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceSettings& deviceSettings, | 
					
						
							|  |  |  |         QJsonObject& jsonObject, | 
					
						
							|  |  |  |         QStringList& deviceSettingsKeys) | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-07 22:38:39 +01:00
										 |  |  |     if (jsonObject.contains("tx")) { | 
					
						
							|  |  |  |         deviceSettings.setTx(jsonObject["tx"].toInt()); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         deviceSettings.setTx(0); // assume Rx
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-08 00:56:29 +01:00
										 |  |  |     if (jsonObject.contains("deviceHwType") && jsonObject["deviceHwType"].isString()) { | 
					
						
							| 
									
										
										
										
											2017-12-07 22:38:39 +01:00
										 |  |  |         deviceSettings.setDeviceHwType(new QString(jsonObject["deviceHwType"].toString())); | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-07 22:38:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QString *deviceHwType = deviceSettings.getDeviceHwType(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-26 13:24:35 +02:00
										 |  |  |     if ((*deviceHwType == "Airspy") && (deviceSettings.getTx() == 0)) | 
					
						
							| 
									
										
										
										
											2018-05-25 22:39:38 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("airspySettings") && jsonObject["airspySettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject airspySettingsJsonObject = jsonObject["airspySettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = airspySettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setAirspySettings(new SWGSDRangel::SWGAirspySettings()); | 
					
						
							|  |  |  |             deviceSettings.getAirspySettings()->fromJsonObject(airspySettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-22 06:34:51 +01:00
										 |  |  |     else if ((*deviceHwType == "AirspyHF") && (deviceSettings.getTx() == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("airspyHFSettings") && jsonObject["airspyHFSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject airspyHFSettingsJsonObject = jsonObject["airspyHFSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = airspyHFSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings()); | 
					
						
							|  |  |  |             deviceSettings.getAirspyHfSettings()->fromJsonObject(airspyHFSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-09-19 05:54:07 +02:00
										 |  |  |     else if ((*deviceHwType == "BladeRF1") && (deviceSettings.getTx() == 0)) | 
					
						
							| 
									
										
										
										
											2018-03-31 19:29:52 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-01-01 18:28:53 +01:00
										 |  |  |         if (jsonObject.contains("bladeRF1InputSettings") && jsonObject["bladeRF1InputSettings"].isObject()) | 
					
						
							| 
									
										
										
										
											2018-03-31 19:29:52 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-01-01 18:28:53 +01:00
										 |  |  |             QJsonObject bladeRF1InputSettingsJsonObject = jsonObject["bladeRF1InputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = bladeRF1InputSettingsJsonObject.keys(); | 
					
						
							| 
									
										
										
										
											2018-09-19 05:54:07 +02:00
										 |  |  |             deviceSettings.setBladeRf1InputSettings(new SWGSDRangel::SWGBladeRF1InputSettings()); | 
					
						
							| 
									
										
										
										
											2019-01-01 18:28:53 +01:00
										 |  |  |             deviceSettings.getBladeRf1InputSettings()->fromJsonObject(bladeRF1InputSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2018-03-31 19:29:52 +02:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-09-19 05:54:07 +02:00
										 |  |  |     else if ((*deviceHwType == "BladeRF1") && (deviceSettings.getTx() != 0)) | 
					
						
							| 
									
										
										
										
											2018-03-31 19:29:52 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-01-01 18:28:53 +01:00
										 |  |  |         if (jsonObject.contains("bladeRF1OutputSettings") && jsonObject["bladeRF1OutputSettings"].isObject()) | 
					
						
							| 
									
										
										
										
											2018-03-31 19:29:52 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-01-01 18:28:53 +01:00
										 |  |  |             QJsonObject bladeRF1OutputSettingsJsonObject = jsonObject["bladeRF1OutputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = bladeRF1OutputSettingsJsonObject.keys(); | 
					
						
							| 
									
										
										
										
											2018-09-19 05:54:07 +02:00
										 |  |  |             deviceSettings.setBladeRf1OutputSettings(new SWGSDRangel::SWGBladeRF1OutputSettings()); | 
					
						
							| 
									
										
										
										
											2019-01-01 18:28:53 +01:00
										 |  |  |             deviceSettings.getBladeRf1OutputSettings()->fromJsonObject(bladeRF1OutputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if ((*deviceHwType == "BladeRF2") && (deviceSettings.getTx() == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("bladeRF2InputSettings") && jsonObject["bladeRF2InputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject bladeRF2InputSettingsJsonObject = jsonObject["bladeRF2InputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = bladeRF2InputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setBladeRf2InputSettings(new SWGSDRangel::SWGBladeRF2InputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getBladeRf2InputSettings()->fromJsonObject(bladeRF2InputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if ((*deviceHwType == "BladeRF2") && (deviceSettings.getTx() != 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("bladeRF2OutputSettings") && jsonObject["bladeRF2OutputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject bladeRF2OutputSettingsJsonObject = jsonObject["bladeRF2OutputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = bladeRF2OutputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setBladeRf2OutputSettings(new SWGSDRangel::SWGBladeRF2OutputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getBladeRf2OutputSettings()->fromJsonObject(bladeRF2OutputSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2018-03-31 19:29:52 +02:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-26 13:24:35 +02:00
										 |  |  |     else if (*deviceHwType == "FCDPro") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("fcdProSettings") && jsonObject["fcdProSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject fcdProSettingsJsonObject = jsonObject["fcdProSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = fcdProSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setFcdProSettings(new SWGSDRangel::SWGFCDProSettings()); | 
					
						
							|  |  |  |             deviceSettings.getFcdProSettings()->fromJsonObject(fcdProSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-01-13 02:18:59 +01:00
										 |  |  |     else if (*deviceHwType == "FCDPro+") | 
					
						
							| 
									
										
										
										
											2018-05-26 13:24:35 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("fcdProPlusSettings") && jsonObject["fcdProPlusSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject fcdProPlusSettingsJsonObject = jsonObject["fcdProPlusSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = fcdProPlusSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setFcdProPlusSettings(new SWGSDRangel::SWGFCDProPlusSettings()); | 
					
						
							|  |  |  |             deviceSettings.getFcdProPlusSettings()->fromJsonObject(fcdProPlusSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (*deviceHwType == "FileSource") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("fileSourceSettings") && jsonObject["fileSourceSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject fileSourceSettingsJsonObject = jsonObject["fileSourceSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = fileSourceSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings()); | 
					
						
							|  |  |  |             deviceSettings.getFileSourceSettings()->fromJsonObject(fileSourceSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-29 01:40:34 +01:00
										 |  |  |     else if ((*deviceHwType == "HackRF") && (deviceSettings.getTx() == 0)) | 
					
						
							| 
									
										
										
										
											2017-12-08 00:56:29 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |         if (jsonObject.contains("hackRFInputSettings") && jsonObject["hackRFInputSettings"].isObject()) | 
					
						
							| 
									
										
										
										
											2017-12-08 00:56:29 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |             QJsonObject hackRFInputSettingsJsonObject = jsonObject["hackRFInputSettings"].toObject(); | 
					
						
							| 
									
										
										
										
											2017-12-29 01:40:34 +01: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-29 02:44:35 +01:00
										 |  |  |         if (jsonObject.contains("hackRFOutputSettings") && jsonObject["hackRFOutputSettings"].isObject()) | 
					
						
							| 
									
										
										
										
											2017-12-29 01:40:34 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |             QJsonObject hackRFOutputSettingsJsonObject = jsonObject["hackRFOutputSettings"].toObject(); | 
					
						
							| 
									
										
										
										
											2017-12-29 01:40:34 +01:00
										 |  |  |             deviceSettingsKeys = hackRFOutputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setHackRfOutputSettings(new SWGSDRangel::SWGHackRFOutputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getHackRfOutputSettings()->fromJsonObject(hackRFOutputSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2017-12-08 00:56:29 +01:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-08 00:56:29 +01:00
										 |  |  |     else if ((*deviceHwType == "LimeSDR") && (deviceSettings.getTx() == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("limeSdrInputSettings") && jsonObject["limeSdrInputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject limeSdrInputSettingsJsonObject = jsonObject["limeSdrInputSettings"].toObject(); | 
					
						
							| 
									
										
										
										
											2017-12-27 01:46:33 +01:00
										 |  |  |             deviceSettingsKeys = limeSdrInputSettingsJsonObject.keys(); | 
					
						
							| 
									
										
										
										
											2017-12-08 00:56:29 +01: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-27 01:46:33 +01:00
										 |  |  |             deviceSettingsKeys = limeSdrOutputSettingsJsonObject.keys(); | 
					
						
							| 
									
										
										
										
											2017-12-08 00:56:29 +01:00
										 |  |  |             deviceSettings.setLimeSdrOutputSettings(new SWGSDRangel::SWGLimeSdrOutputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getLimeSdrOutputSettings()->fromJsonObject(limeSdrOutputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-26 13:24:35 +02:00
										 |  |  |     else if (*deviceHwType == "Perseus") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("perseusSettings") && jsonObject["perseusSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject perseusSettingsJsonObject = jsonObject["perseusSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = perseusSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setPerseusSettings(new SWGSDRangel::SWGPerseusSettings()); | 
					
						
							|  |  |  |             deviceSettings.getPerseusSettings()->fromJsonObject(perseusSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-26 18:07:21 +02:00
										 |  |  |     else if ((*deviceHwType == "PlutoSDR") && (deviceSettings.getTx() == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("plutoSdrInputSettings") && jsonObject["plutoSdrInputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject plutoSdrInputSettingsJsonObject = jsonObject["plutoSdrInputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = plutoSdrInputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setPlutoSdrInputSettings(new SWGSDRangel::SWGPlutoSdrInputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getPlutoSdrInputSettings()->fromJsonObject(plutoSdrInputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-26 20:33:02 +02:00
										 |  |  |     else if ((*deviceHwType == "PlutoSDR") && (deviceSettings.getTx() != 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("plutoSdrOutputSettings") && jsonObject["plutoSdrOutputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject plutoSdrOutputSettingsJsonObject = jsonObject["plutoSdrOutputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = plutoSdrOutputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setPlutoSdrOutputSettings(new SWGSDRangel::SWGPlutoSdrOutputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getPlutoSdrOutputSettings()->fromJsonObject(plutoSdrOutputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-29 01:40:34 +01: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; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-01-17 01:01:59 +01:00
										 |  |  |     else if (*deviceHwType == "SDRplay1") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("sdrPlaySettings") && jsonObject["sdrPlaySettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject sdrPlaySettingsJsonObject = jsonObject["sdrPlaySettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = sdrPlaySettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setSdrPlaySettings(new SWGSDRangel::SWGSDRPlaySettings()); | 
					
						
							|  |  |  |             deviceSettings.getSdrPlaySettings()->fromJsonObject(sdrPlaySettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-11-15 08:46:29 +01:00
										 |  |  |     else if ((*deviceHwType == "SoapySDR")  && (deviceSettings.getTx() == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("soapySDRInputSettings") && jsonObject["soapySDRInputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject soapySdrInputSettingsJsonObject = jsonObject["soapySDRInputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = soapySdrInputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setSoapySdrInputSettings(new SWGSDRangel::SWGSoapySDRInputSettings()); | 
					
						
							| 
									
										
										
										
											2018-11-15 11:27:20 +01:00
										 |  |  |             deviceSettings.getSoapySdrInputSettings()->init(); // contains complex objects
 | 
					
						
							| 
									
										
										
										
											2018-11-15 08:46:29 +01:00
										 |  |  |             deviceSettings.getSoapySdrInputSettings()->fromJsonObject(soapySdrInputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if ((*deviceHwType == "SoapySDR")  && (deviceSettings.getTx() != 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("soapySDROutputSettings") && jsonObject["soapySDROutputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject soapySdrOutputSettingsJsonObject = jsonObject["soapySDROutputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = soapySdrOutputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setSoapySdrOutputSettings(new SWGSDRangel::SWGSoapySDROutputSettings()); | 
					
						
							| 
									
										
										
										
											2018-11-15 11:27:20 +01:00
										 |  |  |             deviceSettings.getSoapySdrInputSettings()->init(); // contains complex objects
 | 
					
						
							| 
									
										
										
										
											2018-11-15 08:46:29 +01:00
										 |  |  |             deviceSettings.getSoapySdrOutputSettings()->fromJsonObject(soapySdrOutputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-08-06 13:13:31 +00:00
										 |  |  |     else if (*deviceHwType == "TestSource") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("testSourceSettings") && jsonObject["testSourceSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject testSourceSettingsJsonObject = jsonObject["testSourceSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = testSourceSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setTestSourceSettings(new SWGSDRangel::SWGTestSourceSettings()); | 
					
						
							|  |  |  |             deviceSettings.getTestSourceSettings()->fromJsonObject(testSourceSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2019-01-01 18:28:53 +01:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if ((*deviceHwType == "XTRX") && (deviceSettings.getTx() == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("xtrxInputSettings") && jsonObject["xtrxInputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject xtrxInputSettingsJsonObject = jsonObject["xtrxInputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = xtrxInputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setXtrxInputSettings(new SWGSDRangel::SWGXtrxInputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getXtrxInputSettings()->fromJsonObject(xtrxInputSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2019-01-16 01:56:43 +01:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if ((*deviceHwType == "XTRX") && (deviceSettings.getTx() != 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("xtrxOutputSettings") && jsonObject["xtrxOutputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject xtrxOutputSettingsJsonObject = jsonObject["xtrxOutputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = xtrxOutputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setXtrxOutputSettings(new SWGSDRangel::SWGXtrxOutputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getXtrxOutputSettings()->fromJsonObject(xtrxOutputSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2018-08-06 13:13:31 +00:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-02-03 00:49:57 +01:00
										 |  |  |     else if ((*deviceHwType == "RemoteInput") && (deviceSettings.getTx() == 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("remoteInputSettings") && jsonObject["remoteInputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject remoteInputSettingsJsonObject = jsonObject["remoteInputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = remoteInputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setRemoteInputSettings(new SWGSDRangel::SWGRemoteInputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getRemoteInputSettings()->fromJsonObject(remoteInputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-02-02 23:27:34 +01:00
										 |  |  |     else if ((*deviceHwType == "RemoteOutput") && (deviceSettings.getTx() != 0)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (jsonObject.contains("remoteOutputSettings") && jsonObject["remoteOutputSettings"].isObject()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject remoteOutputSettingsJsonObject = jsonObject["remoteOutputSettings"].toObject(); | 
					
						
							|  |  |  |             deviceSettingsKeys = remoteOutputSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             deviceSettings.setRemoteOutputSettings(new SWGSDRangel::SWGRemoteOutputSettings()); | 
					
						
							|  |  |  |             deviceSettings.getRemoteOutputSettings()->fromJsonObject(remoteOutputSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-08 00:56:29 +01:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  | bool WebAPIRequestMapper::validateChannelSettings( | 
					
						
							|  |  |  |         SWGSDRangel::SWGChannelSettings& channelSettings, | 
					
						
							|  |  |  |         QJsonObject& jsonObject, | 
					
						
							|  |  |  |         QStringList& channelSettingsKeys) | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01: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(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-22 06:34:51 +01:00
										 |  |  |     if (*channelType == "AMDemod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() == 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject amDemodSettingsJsonObject = jsonObject["AMDemodSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = amDemodSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setAmDemodSettings(new SWGSDRangel::SWGAMDemodSettings()); | 
					
						
							|  |  |  |             channelSettings.getAmDemodSettings()->fromJsonObject(amDemodSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-06 00:54:18 +02:00
										 |  |  |     else if (*channelType == "AMMod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject amModSettingsJsonObject = jsonObject["AMModSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = amModSettingsJsonObject.keys(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelSettingsKeys.contains("cwKeyer")) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QJsonObject cwKeyerSettingsJsonObject; | 
					
						
							|  |  |  |                 appendSettingsSubKeys(amModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             channelSettings.setAmModSettings(new SWGSDRangel::SWGAMModSettings()); | 
					
						
							|  |  |  |             channelSettings.getAmModSettings()->fromJsonObject(amModSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-15 00:52:39 +02:00
										 |  |  |     else if (*channelType == "ATVMod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject atvModSettingsJsonObject = jsonObject["ATVModSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = atvModSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setAtvModSettings(new SWGSDRangel::SWGATVModSettings()); | 
					
						
							|  |  |  |             channelSettings.getAtvModSettings()->fromJsonObject(atvModSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-23 14:56:29 +02:00
										 |  |  |     else if (*channelType == "BFMDemod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() == 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject bfmDemodSettingsJsonObject = jsonObject["BFMDemodSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = bfmDemodSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setBfmDemodSettings(new SWGSDRangel::SWGBFMDemodSettings()); | 
					
						
							|  |  |  |             channelSettings.getBfmDemodSettings()->fromJsonObject(bfmDemodSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-24 18:23:08 +02:00
										 |  |  |     else if (*channelType == "DSDDemod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() == 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject dsdDemodSettingsJsonObject = jsonObject["DSDDemodSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = dsdDemodSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setDsdDemodSettings(new SWGSDRangel::SWGDSDDemodSettings()); | 
					
						
							|  |  |  |             channelSettings.getDsdDemodSettings()->fromJsonObject(dsdDemodSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-22 06:34:51 +01:00
										 |  |  |     else if (*channelType == "NFMDemod") | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() == 0) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-12-12 15:58:04 +01:00
										 |  |  |             QJsonObject nfmDemodSettingsJsonObject = jsonObject["NFMDemodSettings"].toObject(); | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |             channelSettingsKeys = nfmDemodSettingsJsonObject.keys(); | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01: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 15:58:04 +01:00
										 |  |  |             QJsonObject nfmModSettingsJsonObject = jsonObject["NFMModSettings"].toObject(); | 
					
						
							| 
									
										
										
										
											2017-12-24 03:27:07 +01:00
										 |  |  |             channelSettingsKeys = nfmModSettingsJsonObject.keys(); | 
					
						
							| 
									
										
										
										
											2017-12-24 04:19:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (channelSettingsKeys.contains("cwKeyer")) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QJsonObject cwKeyerSettingsJsonObject; | 
					
						
							|  |  |  |                 appendSettingsSubKeys(nfmModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01:00
										 |  |  |             channelSettings.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings()); | 
					
						
							|  |  |  |             channelSettings.getNfmModSettings()->fromJsonObject(nfmModSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-01-22 23:39:12 +01:00
										 |  |  |     else if (*channelType == "RemoteSink") | 
					
						
							| 
									
										
										
										
											2018-09-06 05:32:11 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() == 0) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-01-22 23:39:12 +01:00
										 |  |  |             QJsonObject remoteChannelSinkSettingsJsonObject = jsonObject["RemoteSinkSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = remoteChannelSinkSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setRemoteSinkSettings(new SWGSDRangel::SWGRemoteSinkSettings()); | 
					
						
							|  |  |  |             channelSettings.getRemoteSinkSettings()->fromJsonObject(remoteChannelSinkSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2018-09-06 05:32:11 +02:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-01-23 00:44:13 +01:00
										 |  |  |     else if (*channelType == "RemoteSource") | 
					
						
							| 
									
										
										
										
											2018-08-23 16:06:47 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-09-01 09:53:16 +02:00
										 |  |  |         if (channelSettings.getTx() != 0) | 
					
						
							| 
									
										
										
										
											2018-08-23 17:38:25 +02:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-01-23 00:44:13 +01:00
										 |  |  |             QJsonObject remoteChannelSourceSettingsJsonObject = jsonObject["RemoteSourceSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = remoteChannelSourceSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setRemoteSourceSettings(new SWGSDRangel::SWGRemoteSourceSettings()); | 
					
						
							|  |  |  |             channelSettings.getRemoteSourceSettings()->fromJsonObject(remoteChannelSourceSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2018-08-23 17:38:25 +02:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-08-23 16:06:47 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-26 15:53:22 +02:00
										 |  |  |     else if (*channelType == "SSBDemod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() == 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject ssbDemodSettingsJsonObject = jsonObject["SSBDemodSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = ssbDemodSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setSsbDemodSettings(new SWGSDRangel::SWGSSBDemodSettings()); | 
					
						
							|  |  |  |             channelSettings.getSsbDemodSettings()->fromJsonObject(ssbDemodSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-14 21:46:53 +02:00
										 |  |  |     else if (*channelType == "SSBMod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject ssbModSettingsJsonObject = jsonObject["SSBModSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = ssbModSettingsJsonObject.keys(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelSettingsKeys.contains("cwKeyer")) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QJsonObject cwKeyerSettingsJsonObject; | 
					
						
							|  |  |  |                 appendSettingsSubKeys(ssbModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             channelSettings.setSsbModSettings(new SWGSDRangel::SWGSSBModSettings()); | 
					
						
							|  |  |  |             channelSettings.getSsbModSettings()->fromJsonObject(ssbModSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-09-11 22:36:16 +02:00
										 |  |  |     else if (*channelType == "UDPSource") | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |             QJsonObject udpSourceSettingsJsonObject = jsonObject["UDPSourceSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = udpSourceSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setUdpSourceSettings(new SWGSDRangel::SWGUDPSourceSettings()); | 
					
						
							|  |  |  |             channelSettings.getUdpSourceSettings()->fromJsonObject(udpSourceSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-05-25 18:44:24 +02:00
										 |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-09-12 00:36:30 +02:00
										 |  |  |     else if (*channelType == "UDPSink") | 
					
						
							| 
									
										
										
										
											2018-05-25 18:44:24 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() == 0) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-09-12 00:36:30 +02:00
										 |  |  |             QJsonObject udpSinkSettingsJsonObject = jsonObject["UDPSinkSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = udpSinkSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setUdpSinkSettings(new SWGSDRangel::SWGUDPSinkSettings()); | 
					
						
							|  |  |  |             channelSettings.getUdpSinkSettings()->fromJsonObject(udpSinkSettingsJsonObject); | 
					
						
							| 
									
										
										
										
											2018-05-25 18:44:24 +02:00
										 |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-04-15 18:25:22 +02:00
										 |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-25 10:08:47 +02:00
										 |  |  |     else if (*channelType == "WFMDemod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() == 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject wfmDemodSettingsJsonObject = jsonObject["WFMDemodSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = wfmDemodSettingsJsonObject.keys(); | 
					
						
							|  |  |  |             channelSettings.setWfmDemodSettings(new SWGSDRangel::SWGWFMDemodSettings()); | 
					
						
							|  |  |  |             channelSettings.getWfmDemodSettings()->fromJsonObject(wfmDemodSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-09 00:37:17 +02:00
										 |  |  |     else if (*channelType == "WFMMod") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (channelSettings.getTx() != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             QJsonObject wfmModSettingsJsonObject = jsonObject["WFMModSettings"].toObject(); | 
					
						
							|  |  |  |             channelSettingsKeys = wfmModSettingsJsonObject.keys(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (channelSettingsKeys.contains("cwKeyer")) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QJsonObject cwKeyerSettingsJsonObject; | 
					
						
							|  |  |  |                 appendSettingsSubKeys(wfmModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             channelSettings.setWfmModSettings(new SWGSDRangel::SWGWFMModSettings()); | 
					
						
							|  |  |  |             channelSettings.getWfmModSettings()->fromJsonObject(wfmModSettingsJsonObject); | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-12 23:21:31 +01:00
										 |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-11 18:18:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | bool WebAPIRequestMapper::validateAudioInputDevice( | 
					
						
							|  |  |  |         SWGSDRangel::SWGAudioInputDevice& audioInputDevice, | 
					
						
							|  |  |  |         QJsonObject& jsonObject, | 
					
						
							|  |  |  |         QStringList& audioInputDeviceKeys) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (jsonObject.contains("index")) { | 
					
						
							|  |  |  |         audioInputDevice.setIndex(jsonObject["index"].toInt()); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         audioInputDevice.setIndex(-1); // assume systam default
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (jsonObject.contains("sampleRate")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioInputDevice.setSampleRate(jsonObject["sampleRate"].toInt()); | 
					
						
							|  |  |  |         audioInputDeviceKeys.append("sampleRate"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (jsonObject.contains("volume")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioInputDevice.setVolume(jsonObject["volume"].toDouble()); | 
					
						
							|  |  |  |         audioInputDeviceKeys.append("volume"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool WebAPIRequestMapper::validateAudioOutputDevice( | 
					
						
							|  |  |  |         SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice, | 
					
						
							|  |  |  |         QJsonObject& jsonObject, | 
					
						
							|  |  |  |         QStringList& audioOutputDeviceKeys) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (jsonObject.contains("index")) { | 
					
						
							|  |  |  |         audioOutputDevice.setIndex(jsonObject["index"].toInt()); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         audioOutputDevice.setIndex(-1); // assume systam default
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (jsonObject.contains("sampleRate")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioOutputDevice.setSampleRate(jsonObject["sampleRate"].toInt()); | 
					
						
							|  |  |  |         audioOutputDeviceKeys.append("sampleRate"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (jsonObject.contains("copyToUDP")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioOutputDevice.setCopyToUdp(jsonObject["copyToUDP"].toInt() == 0 ? 0 : 1); | 
					
						
							|  |  |  |         audioOutputDeviceKeys.append("copyToUDP"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (jsonObject.contains("udpUsesRTP")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioOutputDevice.setUdpUsesRtp(jsonObject["udpUsesRTP"].toInt() == 0 ? 0 : 1); | 
					
						
							|  |  |  |         audioOutputDeviceKeys.append("udpUsesRTP"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (jsonObject.contains("udpChannelMode")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioOutputDevice.setUdpChannelMode(jsonObject["udpChannelMode"].toInt()); | 
					
						
							|  |  |  |         audioOutputDeviceKeys.append("udpChannelMode"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-02-15 12:10:01 +01:00
										 |  |  |     if (jsonObject.contains("udpChannelCodec")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioOutputDevice.setUdpChannelCodec(jsonObject["udpChannelCodec"].toInt()); | 
					
						
							|  |  |  |         audioOutputDeviceKeys.append("udpChannelCodec"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (jsonObject.contains("udpDecimationFactor")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioOutputDevice.setUdpDecimationFactor(jsonObject["udpDecimationFactor"].toInt()); | 
					
						
							|  |  |  |         audioOutputDeviceKeys.append("udpDecimationFactor"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  |     if (jsonObject.contains("udpAddress")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioOutputDevice.setUdpAddress(new QString(jsonObject["udpAddress"].toString())); | 
					
						
							|  |  |  |         audioOutputDeviceKeys.append("udpAddress"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (jsonObject.contains("udpPort")) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         audioOutputDevice.setUdpPort(jsonObject["udpPort"].toInt()); | 
					
						
							|  |  |  |         audioOutputDeviceKeys.append("udpPort"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-24 04:19:44 +01: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 22:08:34 +01:00
										 |  |  | void WebAPIRequestMapper::resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     deviceSettings.cleanup(); | 
					
						
							| 
									
										
										
										
											2017-12-28 10:58:50 +01:00
										 |  |  |     deviceSettings.setDeviceHwType(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     deviceSettings.setAirspySettings(0); | 
					
						
							|  |  |  |     deviceSettings.setAirspyHfSettings(0); | 
					
						
							| 
									
										
										
										
											2018-09-19 05:54:07 +02:00
										 |  |  |     deviceSettings.setBladeRf1InputSettings(0); | 
					
						
							|  |  |  |     deviceSettings.setBladeRf1OutputSettings(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     deviceSettings.setFcdProPlusSettings(0); | 
					
						
							|  |  |  |     deviceSettings.setFcdProSettings(0); | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  |     deviceSettings.setFileSourceSettings(0); | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |     deviceSettings.setHackRfInputSettings(0); | 
					
						
							|  |  |  |     deviceSettings.setHackRfOutputSettings(0); | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  |     deviceSettings.setLimeSdrInputSettings(0); | 
					
						
							|  |  |  |     deviceSettings.setLimeSdrOutputSettings(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     deviceSettings.setPerseusSettings(0); | 
					
						
							|  |  |  |     deviceSettings.setPlutoSdrInputSettings(0); | 
					
						
							|  |  |  |     deviceSettings.setPlutoSdrOutputSettings(0); | 
					
						
							| 
									
										
										
										
											2017-12-29 02:44:35 +01:00
										 |  |  |     deviceSettings.setRtlSdrSettings(0); | 
					
						
							| 
									
										
										
										
											2019-02-02 23:27:34 +01:00
										 |  |  |     deviceSettings.setRemoteOutputSettings(0); | 
					
						
							| 
									
										
										
										
											2019-02-03 00:49:57 +01:00
										 |  |  |     deviceSettings.setRemoteInputSettings(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     deviceSettings.setSdrPlaySettings(0); | 
					
						
							|  |  |  |     deviceSettings.setTestSourceSettings(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::resetDeviceReport(SWGSDRangel::SWGDeviceReport& deviceReport) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     deviceReport.cleanup(); | 
					
						
							|  |  |  |     deviceReport.setDeviceHwType(0); | 
					
						
							|  |  |  |     deviceReport.setAirspyHfReport(0); | 
					
						
							|  |  |  |     deviceReport.setAirspyReport(0); | 
					
						
							|  |  |  |     deviceReport.setFileSourceReport(0); | 
					
						
							|  |  |  |     deviceReport.setLimeSdrInputReport(0); | 
					
						
							|  |  |  |     deviceReport.setLimeSdrOutputReport(0); | 
					
						
							|  |  |  |     deviceReport.setPerseusReport(0); | 
					
						
							|  |  |  |     deviceReport.setPlutoSdrInputReport(0); | 
					
						
							|  |  |  |     deviceReport.setPlutoSdrOutputReport(0); | 
					
						
							|  |  |  |     deviceReport.setRtlSdrReport(0); | 
					
						
							| 
									
										
										
										
											2019-02-02 23:27:34 +01:00
										 |  |  |     deviceReport.setRemoteOutputReport(0); | 
					
						
							| 
									
										
										
										
											2019-02-03 00:49:57 +01:00
										 |  |  |     deviceReport.setRemoteInputReport(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     deviceReport.setSdrPlayReport(0); | 
					
						
							| 
									
										
										
										
											2017-12-06 22:08:34 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-11-25 19:42:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-10 20:27:08 +01:00
										 |  |  | void WebAPIRequestMapper::resetChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     channelSettings.cleanup(); | 
					
						
							| 
									
										
										
										
											2017-12-28 10:58:50 +01:00
										 |  |  |     channelSettings.setChannelType(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     channelSettings.setAmDemodSettings(0); | 
					
						
							|  |  |  |     channelSettings.setAmModSettings(0); | 
					
						
							|  |  |  |     channelSettings.setAtvModSettings(0); | 
					
						
							|  |  |  |     channelSettings.setBfmDemodSettings(0); | 
					
						
							|  |  |  |     channelSettings.setDsdDemodSettings(0); | 
					
						
							| 
									
										
										
										
											2017-12-10 20:27:08 +01:00
										 |  |  |     channelSettings.setNfmDemodSettings(0); | 
					
						
							|  |  |  |     channelSettings.setNfmModSettings(0); | 
					
						
							| 
									
										
										
										
											2019-01-22 23:39:12 +01:00
										 |  |  |     channelSettings.setRemoteSinkSettings(0); | 
					
						
							| 
									
										
										
										
											2019-01-23 00:44:13 +01:00
										 |  |  |     channelSettings.setRemoteSourceSettings(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     channelSettings.setSsbDemodSettings(0); | 
					
						
							|  |  |  |     channelSettings.setSsbModSettings(0); | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     channelSettings.setUdpSourceSettings(0); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:36:30 +02:00
										 |  |  |     channelSettings.setUdpSinkSettings(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     channelSettings.setWfmDemodSettings(0); | 
					
						
							|  |  |  |     channelSettings.setWfmModSettings(0); | 
					
						
							| 
									
										
										
										
											2017-12-10 20:27:08 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-18 20:17:11 +01:00
										 |  |  | void WebAPIRequestMapper::resetChannelReport(SWGSDRangel::SWGChannelReport& channelReport) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     channelReport.cleanup(); | 
					
						
							|  |  |  |     channelReport.setChannelType(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     channelReport.setAmDemodReport(0); | 
					
						
							|  |  |  |     channelReport.setAmModReport(0); | 
					
						
							|  |  |  |     channelReport.setAtvModReport(0); | 
					
						
							|  |  |  |     channelReport.setBfmDemodReport(0); | 
					
						
							|  |  |  |     channelReport.setDsdDemodReport(0); | 
					
						
							| 
									
										
										
										
											2018-03-18 20:17:11 +01:00
										 |  |  |     channelReport.setNfmDemodReport(0); | 
					
						
							|  |  |  |     channelReport.setNfmModReport(0); | 
					
						
							| 
									
										
										
										
											2019-01-23 00:44:13 +01:00
										 |  |  |     channelReport.setRemoteSourceReport(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     channelReport.setSsbDemodReport(0); | 
					
						
							|  |  |  |     channelReport.setSsbModReport(0); | 
					
						
							| 
									
										
										
										
											2018-09-11 23:22:59 +02:00
										 |  |  |     channelReport.setUdpSourceReport(0); | 
					
						
							| 
									
										
										
										
											2018-09-12 00:36:30 +02:00
										 |  |  |     channelReport.setUdpSinkReport(0); | 
					
						
							| 
									
										
										
										
											2018-05-28 11:44:32 +02:00
										 |  |  |     channelReport.setWfmDemodReport(0); | 
					
						
							|  |  |  |     channelReport.setWfmModReport(0); | 
					
						
							| 
									
										
										
										
											2018-03-18 20:17:11 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-29 00:38:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::resetAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     audioInputDevice.cleanup(); | 
					
						
							|  |  |  |     audioInputDevice.setName(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebAPIRequestMapper::resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     audioOutputDevice.cleanup(); | 
					
						
							|  |  |  |     audioOutputDevice.setName(0); | 
					
						
							|  |  |  |     audioOutputDevice.setUdpAddress(0); | 
					
						
							|  |  |  | } |