SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Private Member Functions | Private Attributes | List of all members
WebAPIRequestMapper Class Reference

#include <webapirequestmapper.h>

+ Inheritance diagram for WebAPIRequestMapper:
+ Collaboration diagram for WebAPIRequestMapper:

Public Member Functions

 WebAPIRequestMapper (QObject *parent=0)
 
 ~WebAPIRequestMapper ()
 
void service (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void setAdapter (WebAPIAdapterInterface *adapter)
 
- Public Member Functions inherited from qtwebapp::HttpRequestHandler
 HttpRequestHandler (QObject *parent=NULL)
 
virtual ~HttpRequestHandler ()
 

Private Member Functions

void instanceSummaryService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceConfigService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceDevicesService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceChannelsService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceLoggingService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceAudioService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceAudioInputParametersService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceAudioOutputParametersService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceAudioInputCleanupService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceAudioOutputCleanupService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceLocationService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceDVSerialService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceAMBESerialService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceAMBEDevicesService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instancePresetsService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instancePresetService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instancePresetFileService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceDeviceSetsService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void instanceDeviceSetService (qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetService (const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetFocusService (const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetDeviceService (const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetDeviceSettingsService (const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetDeviceRunService (const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetDeviceReportService (const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetChannelsReportService (const std::string &deviceSetIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetChannelService (const std::string &deviceSetIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetChannelIndexService (const std::string &deviceSetIndexStr, const std::string &channelIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetChannelSettingsService (const std::string &deviceSetIndexStr, const std::string &channelIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
void devicesetChannelReportService (const std::string &deviceSetIndexStr, const std::string &channelIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
 
bool validatePresetTransfer (SWGSDRangel::SWGPresetTransfer &presetTransfer)
 
bool validatePresetIdentifer (SWGSDRangel::SWGPresetIdentifier &presetIdentifier)
 
bool validatePresetExport (SWGSDRangel::SWGPresetExport &presetExport)
 
bool validateDeviceListItem (SWGSDRangel::SWGDeviceListItem &deviceListItem, QJsonObject &jsonObject)
 
bool validateDeviceSettings (SWGSDRangel::SWGDeviceSettings &deviceSettings, QJsonObject &jsonObject, QStringList &deviceSettingsKeys)
 
bool validateChannelSettings (SWGSDRangel::SWGChannelSettings &deviceSettings, QJsonObject &jsonObject, QStringList &channelSettingsKeys)
 
bool validateAudioInputDevice (SWGSDRangel::SWGAudioInputDevice &audioInputDevice, QJsonObject &jsonObject, QStringList &audioInputDeviceKeys)
 
bool validateAudioOutputDevice (SWGSDRangel::SWGAudioOutputDevice &audioOutputDevice, QJsonObject &jsonObject, QStringList &audioOutputDeviceKeys)
 
bool validateAMBEDevices (SWGSDRangel::SWGAMBEDevices &ambeDevices, QJsonObject &jsonObject)
 
void appendSettingsSubKeys (const QJsonObject &parentSettingsJsonObject, QJsonObject &childSettingsJsonObject, const QString &parentKey, QStringList &keyList)
 
void appendSettingsArrayKeys (const QJsonObject &parentSettingsJsonObject, const QString &parentKey, QStringList &keyList)
 
bool parseJsonBody (QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
 
void resetDeviceSettings (SWGSDRangel::SWGDeviceSettings &deviceSettings)
 
void resetDeviceReport (SWGSDRangel::SWGDeviceReport &deviceReport)
 
void resetChannelSettings (SWGSDRangel::SWGChannelSettings &deviceSettings)
 
void resetChannelReport (SWGSDRangel::SWGChannelReport &deviceSettings)
 
void resetAudioInputDevice (SWGSDRangel::SWGAudioInputDevice &audioInputDevice)
 
void resetAudioOutputDevice (SWGSDRangel::SWGAudioOutputDevice &audioOutputDevice)
 

Private Attributes

WebAPIAdapterInterfacem_adapter
 
qtwebapp::StaticFileControllerm_staticFileController
 

Detailed Description

Definition at line 39 of file webapirequestmapper.h.

Constructor & Destructor Documentation

◆ WebAPIRequestMapper()

WebAPIRequestMapper::WebAPIRequestMapper ( QObject *  parent = 0)

Definition at line 50 of file webapirequestmapper.cpp.

References m_staticFileController, and qtwebapp::HttpDocrootSettings::path.

50  :
51  HttpRequestHandler(parent),
52  m_adapter(0)
53 {
54 #ifndef _MSC_VER
55  Q_INIT_RESOURCE(webapi);
56 #endif
57  qtwebapp::HttpDocrootSettings docrootSettings;
58  docrootSettings.path = ":/webapi";
59  m_staticFileController = new qtwebapp::StaticFileController(docrootSettings, parent);
60 }
qtwebapp::StaticFileController * m_staticFileController
WebAPIAdapterInterface * m_adapter
HttpRequestHandler(QObject *parent=NULL)

◆ ~WebAPIRequestMapper()

WebAPIRequestMapper::~WebAPIRequestMapper ( )

Definition at line 62 of file webapirequestmapper.cpp.

References m_staticFileController.

63 {
65 #ifndef _MSC_VER
66  Q_CLEANUP_RESOURCE(webapi);
67 #endif
68 }
qtwebapp::StaticFileController * m_staticFileController

Member Function Documentation

◆ appendSettingsArrayKeys()

void WebAPIRequestMapper::appendSettingsArrayKeys ( const QJsonObject &  parentSettingsJsonObject,
const QString &  parentKey,
QStringList &  keyList 
)
private

Definition at line 2785 of file webapirequestmapper.cpp.

References arg(), and i.

Referenced by validateDeviceSettings().

2789 {
2790  QJsonArray streams = parentSettingsJsonObject[parentKey].toArray();
2791 
2792  for (int istream = 0; istream < streams.count(); istream++)
2793  {
2794  QJsonValue v = streams.takeAt(istream);
2795 
2796  if (v.isObject())
2797  {
2798  QJsonObject streamSettingsJsonObject = v.toObject();
2799  QStringList streamSettingsKeys = streamSettingsJsonObject.keys();
2800 
2801  for (int i = 0; i < streamSettingsKeys.size(); i++) {
2802  keyList.append(tr("streams[%1].%2").arg(istream).arg(streamSettingsKeys[i]));
2803  }
2804  }
2805  }
2806 }
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendSettingsSubKeys()

void WebAPIRequestMapper::appendSettingsSubKeys ( const QJsonObject &  parentSettingsJsonObject,
QJsonObject &  childSettingsJsonObject,
const QString &  parentKey,
QStringList &  keyList 
)
private

Definition at line 2771 of file webapirequestmapper.cpp.

References i.

Referenced by validateChannelSettings().

2776 {
2777  childSettingsJsonObject = parentSettingsJsonObject[parentKey].toObject();
2778  QStringList childSettingsKeys = childSettingsJsonObject.keys();
2779 
2780  for (int i = 0; i < childSettingsKeys.size(); i++) {
2781  keyList.append(parentKey + QString(".") + childSettingsKeys.at(i));
2782  }
2783 }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ devicesetChannelIndexService()

void WebAPIRequestMapper::devicesetChannelIndexService ( const std::string &  deviceSetIndexStr,
const std::string &  channelIndexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1557 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGSuccessResponse::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), WebAPIAdapterInterface::devicesetChannelDelete(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1562 {
1563  SWGSDRangel::SWGErrorResponse errorResponse;
1564  response.setHeader("Content-Type", "application/json");
1565  response.setHeader("Access-Control-Allow-Origin", "*");
1566 
1567  try
1568  {
1569  int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr);
1570  int channelIndex = boost::lexical_cast<int>(channelIndexStr);
1571 
1572  if (request.getMethod() == "DELETE")
1573  {
1574  SWGSDRangel::SWGSuccessResponse normalResponse;
1575  int status = m_adapter->devicesetChannelDelete(deviceSetIndex, channelIndex, normalResponse, errorResponse);
1576 
1577  response.setStatus(status);
1578 
1579  if (status/100 == 2) {
1580  response.write(normalResponse.asJson().toUtf8());
1581  } else {
1582  response.write(errorResponse.asJson().toUtf8());
1583  }
1584  }
1585  else
1586  {
1587  response.setStatus(405,"Invalid HTTP method");
1588  errorResponse.init();
1589  *errorResponse.getMessage() = "Invalid HTTP method";
1590  response.write(errorResponse.asJson().toUtf8());
1591  }
1592  }
1593  catch (const boost::bad_lexical_cast &e)
1594  {
1595  errorResponse.init();
1596  *errorResponse.getMessage() = "Wrong integer conversion on index";
1597  response.setStatus(400,"Invalid data");
1598  response.write(errorResponse.asJson().toUtf8());
1599  }
1600 }
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int devicesetChannelDelete(int deviceSetIndex, int channelIndex, SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetChannelReportService()

void WebAPIRequestMapper::devicesetChannelReportService ( const std::string &  deviceSetIndexStr,
const std::string &  channelIndexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1691 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGChannelReport::asJson(), WebAPIAdapterInterface::devicesetChannelReportGet(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, resetChannelReport(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1696 {
1697  SWGSDRangel::SWGErrorResponse errorResponse;
1698  response.setHeader("Content-Type", "application/json");
1699  response.setHeader("Access-Control-Allow-Origin", "*");
1700 
1701  try
1702  {
1703  int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr);
1704  int channelIndex = boost::lexical_cast<int>(channelIndexStr);
1705 
1706  if (request.getMethod() == "GET")
1707  {
1708  SWGSDRangel::SWGChannelReport normalResponse;
1709  resetChannelReport(normalResponse);
1710  int status = m_adapter->devicesetChannelReportGet(deviceSetIndex, channelIndex, normalResponse, errorResponse);
1711  response.setStatus(status);
1712 
1713  if (status/100 == 2) {
1714  response.write(normalResponse.asJson().toUtf8());
1715  } else {
1716  response.write(errorResponse.asJson().toUtf8());
1717  }
1718  }
1719  }
1720  catch (const boost::bad_lexical_cast &e)
1721  {
1722  errorResponse.init();
1723  *errorResponse.getMessage() = "Wrong integer conversion on index";
1724  response.setStatus(400,"Invalid data");
1725  response.write(errorResponse.asJson().toUtf8());
1726  }
1727 }
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
virtual int devicesetChannelReportGet(int deviceSetIndex, int channelIndex, SWGSDRangel::SWGChannelReport &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
void resetChannelReport(SWGSDRangel::SWGChannelReport &deviceSettings)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetChannelService()

void WebAPIRequestMapper::devicesetChannelService ( const std::string &  deviceSetIndexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1480 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGSuccessResponse::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), WebAPIAdapterInterface::devicesetChannelPost(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, parseJsonBody(), resetChannelSettings(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDirection(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1484 {
1485  SWGSDRangel::SWGErrorResponse errorResponse;
1486  response.setHeader("Content-Type", "application/json");
1487  response.setHeader("Access-Control-Allow-Origin", "*");
1488 
1489  try
1490  {
1491  int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr);
1492 
1493  if (request.getMethod() == "POST")
1494  {
1495  QString jsonStr = request.getBody();
1496  QJsonObject jsonObject;
1497 
1498  if (parseJsonBody(jsonStr, jsonObject, response))
1499  {
1501  SWGSDRangel::SWGSuccessResponse normalResponse;
1502  resetChannelSettings(query);
1503 
1504  if (jsonObject.contains("direction")) {
1505  query.setDirection(jsonObject["direction"].toInt());
1506  } else {
1507  query.setDirection(0); // assume Rx
1508  }
1509 
1510  if (jsonObject.contains("channelType") && jsonObject["channelType"].isString())
1511  {
1512  query.setChannelType(new QString(jsonObject["channelType"].toString()));
1513 
1514  int status = m_adapter->devicesetChannelPost(deviceSetIndex, query, normalResponse, errorResponse);
1515 
1516  response.setStatus(status);
1517 
1518  if (status/100 == 2) {
1519  response.write(normalResponse.asJson().toUtf8());
1520  } else {
1521  response.write(errorResponse.asJson().toUtf8());
1522  }
1523  }
1524  else
1525  {
1526  response.setStatus(400,"Invalid JSON request");
1527  errorResponse.init();
1528  *errorResponse.getMessage() = "Invalid JSON request";
1529  response.write(errorResponse.asJson().toUtf8());
1530  }
1531  }
1532  else
1533  {
1534  response.setStatus(400,"Invalid JSON format");
1535  errorResponse.init();
1536  *errorResponse.getMessage() = "Invalid JSON format";
1537  response.write(errorResponse.asJson().toUtf8());
1538  }
1539  }
1540  else
1541  {
1542  response.setStatus(405,"Invalid HTTP method");
1543  errorResponse.init();
1544  *errorResponse.getMessage() = "Invalid HTTP method";
1545  response.write(errorResponse.asJson().toUtf8());
1546  }
1547  }
1548  catch (const boost::bad_lexical_cast &e)
1549  {
1550  errorResponse.init();
1551  *errorResponse.getMessage() = "Wrong integer conversion on index";
1552  response.setStatus(400,"Invalid data");
1553  response.write(errorResponse.asJson().toUtf8());
1554  }
1555 }
void resetChannelSettings(SWGSDRangel::SWGChannelSettings &deviceSettings)
QByteArray getBody() const
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
void setChannelType(QString *channel_type)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual QString asJson() override
virtual int devicesetChannelPost(int deviceSetIndex, SWGSDRangel::SWGChannelSettings &query, SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetChannelSettingsService()

void WebAPIRequestMapper::devicesetChannelSettingsService ( const std::string &  deviceSetIndexStr,
const std::string &  channelIndexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1602 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGChannelSettings::asJson(), WebAPIAdapterInterface::devicesetChannelSettingsGet(), WebAPIAdapterInterface::devicesetChannelSettingsPutPatch(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, parseJsonBody(), resetChannelSettings(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), validateChannelSettings(), and qtwebapp::HttpResponse::write().

Referenced by service().

1607 {
1608  SWGSDRangel::SWGErrorResponse errorResponse;
1609  response.setHeader("Content-Type", "application/json");
1610  response.setHeader("Access-Control-Allow-Origin", "*");
1611 
1612  try
1613  {
1614  int deviceSetIndex = boost::lexical_cast<int>(deviceSetIndexStr);
1615  int channelIndex = boost::lexical_cast<int>(channelIndexStr);
1616 
1617  if (request.getMethod() == "GET")
1618  {
1619  SWGSDRangel::SWGChannelSettings normalResponse;
1620  resetChannelSettings(normalResponse);
1621  int status = m_adapter->devicesetChannelSettingsGet(deviceSetIndex, channelIndex, normalResponse, errorResponse);
1622  response.setStatus(status);
1623 
1624  if (status/100 == 2) {
1625  response.write(normalResponse.asJson().toUtf8());
1626  } else {
1627  response.write(errorResponse.asJson().toUtf8());
1628  }
1629  }
1630  else if ((request.getMethod() == "PUT") || (request.getMethod() == "PATCH"))
1631  {
1632  QString jsonStr = request.getBody();
1633  QJsonObject jsonObject;
1634 
1635  if (parseJsonBody(jsonStr, jsonObject, response))
1636  {
1637  SWGSDRangel::SWGChannelSettings normalResponse;
1638  resetChannelSettings(normalResponse);
1639  QStringList channelSettingsKeys;
1640 
1641  if (validateChannelSettings(normalResponse, jsonObject, channelSettingsKeys))
1642  {
1644  deviceSetIndex,
1645  channelIndex,
1646  (request.getMethod() == "PUT"), // force settings on PUT
1647  channelSettingsKeys,
1648  normalResponse,
1649  errorResponse);
1650  response.setStatus(status);
1651 
1652  if (status/100 == 2) {
1653  response.write(normalResponse.asJson().toUtf8());
1654  } else {
1655  response.write(errorResponse.asJson().toUtf8());
1656  }
1657  }
1658  else
1659  {
1660  response.setStatus(400,"Invalid JSON request");
1661  errorResponse.init();
1662  *errorResponse.getMessage() = "Invalid JSON request";
1663  response.write(errorResponse.asJson().toUtf8());
1664  }
1665  }
1666  else
1667  {
1668  response.setStatus(400,"Invalid JSON format");
1669  errorResponse.init();
1670  *errorResponse.getMessage() = "Invalid JSON format";
1671  response.write(errorResponse.asJson().toUtf8());
1672  }
1673  }
1674  else
1675  {
1676  response.setStatus(405,"Invalid HTTP method");
1677  errorResponse.init();
1678  *errorResponse.getMessage() = "Invalid HTTP method";
1679  response.write(errorResponse.asJson().toUtf8());
1680  }
1681  }
1682  catch (const boost::bad_lexical_cast &e)
1683  {
1684  errorResponse.init();
1685  *errorResponse.getMessage() = "Wrong integer conversion on index";
1686  response.setStatus(400,"Invalid data");
1687  response.write(errorResponse.asJson().toUtf8());
1688  }
1689 }
void resetChannelSettings(SWGSDRangel::SWGChannelSettings &deviceSettings)
QByteArray getBody() const
virtual int devicesetChannelSettingsGet(int deviceSetIndex, int channelIndex, SWGSDRangel::SWGChannelSettings &response, SWGSDRangel::SWGErrorResponse &error)
virtual int devicesetChannelSettingsPutPatch(int deviceSetIndex, int channelIndex, bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings &deviceSettings, QJsonObject &jsonObject, QStringList &channelSettingsKeys)
virtual QString asJson() override
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetChannelsReportService()

void WebAPIRequestMapper::devicesetChannelsReportService ( const std::string &  deviceSetIndexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1442 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGChannelsDetail::asJson(), WebAPIAdapterInterface::devicesetChannelsReportGet(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1443 {
1444  SWGSDRangel::SWGErrorResponse errorResponse;
1445  response.setHeader("Content-Type", "application/json");
1446  response.setHeader("Access-Control-Allow-Origin", "*");
1447 
1448  if (request.getMethod() == "GET")
1449  {
1450  try
1451  {
1452  SWGSDRangel::SWGChannelsDetail normalResponse;
1453  int deviceSetIndex = boost::lexical_cast<int>(indexStr);
1454  int status = m_adapter->devicesetChannelsReportGet(deviceSetIndex, normalResponse, errorResponse);
1455  response.setStatus(status);
1456 
1457  if (status/100 == 2) {
1458  response.write(normalResponse.asJson().toUtf8());
1459  } else {
1460  response.write(errorResponse.asJson().toUtf8());
1461  }
1462  }
1463  catch (const boost::bad_lexical_cast &e)
1464  {
1465  errorResponse.init();
1466  *errorResponse.getMessage() = "Wrong integer conversion on device set index";
1467  response.setStatus(400,"Invalid data");
1468  response.write(errorResponse.asJson().toUtf8());
1469  }
1470  }
1471  else
1472  {
1473  response.setStatus(405,"Invalid HTTP method");
1474  errorResponse.init();
1475  *errorResponse.getMessage() = "Invalid HTTP method";
1476  response.write(errorResponse.asJson().toUtf8());
1477  }
1478 }
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual QString asJson() override
WebAPIAdapterInterface * m_adapter
virtual int devicesetChannelsReportGet(int deviceSetIndex, SWGSDRangel::SWGChannelsDetail &response, SWGSDRangel::SWGErrorResponse &error)
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetDeviceReportService()

void WebAPIRequestMapper::devicesetDeviceReportService ( const std::string &  indexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1403 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGDeviceReport::asJson(), WebAPIAdapterInterface::devicesetDeviceReportGet(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, resetDeviceReport(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1404 {
1405  SWGSDRangel::SWGErrorResponse errorResponse;
1406  response.setHeader("Content-Type", "application/json");
1407  response.setHeader("Access-Control-Allow-Origin", "*");
1408 
1409  if (request.getMethod() == "GET")
1410  {
1411  try
1412  {
1413  SWGSDRangel::SWGDeviceReport normalResponse;
1414  resetDeviceReport(normalResponse);
1415  int deviceSetIndex = boost::lexical_cast<int>(indexStr);
1416  int status = m_adapter->devicesetDeviceReportGet(deviceSetIndex, normalResponse, errorResponse);
1417  response.setStatus(status);
1418 
1419  if (status/100 == 2) {
1420  response.write(normalResponse.asJson().toUtf8());
1421  } else {
1422  response.write(errorResponse.asJson().toUtf8());
1423  }
1424  }
1425  catch (const boost::bad_lexical_cast &e)
1426  {
1427  errorResponse.init();
1428  *errorResponse.getMessage() = "Wrong integer conversion on device set index";
1429  response.setStatus(400,"Invalid data");
1430  response.write(errorResponse.asJson().toUtf8());
1431  }
1432  }
1433  else
1434  {
1435  response.setStatus(405,"Invalid HTTP method");
1436  errorResponse.init();
1437  *errorResponse.getMessage() = "Invalid HTTP method";
1438  response.write(errorResponse.asJson().toUtf8());
1439  }
1440 }
virtual int devicesetDeviceReportGet(int deviceSetIndex, SWGSDRangel::SWGDeviceReport &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
void resetDeviceReport(SWGSDRangel::SWGDeviceReport &deviceReport)
virtual QString asJson() override
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetDeviceRunService()

void WebAPIRequestMapper::devicesetDeviceRunService ( const std::string &  indexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1337 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGDeviceState::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), WebAPIAdapterInterface::devicesetDeviceRunDelete(), WebAPIAdapterInterface::devicesetDeviceRunGet(), WebAPIAdapterInterface::devicesetDeviceRunPost(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1338 {
1339  SWGSDRangel::SWGErrorResponse errorResponse;
1340  response.setHeader("Content-Type", "application/json");
1341  response.setHeader("Access-Control-Allow-Origin", "*");
1342 
1343  try
1344  {
1345  int deviceSetIndex = boost::lexical_cast<int>(indexStr);
1346 
1347  if (request.getMethod() == "GET")
1348  {
1349  SWGSDRangel::SWGDeviceState normalResponse;
1350  int status = m_adapter->devicesetDeviceRunGet(deviceSetIndex, normalResponse, errorResponse);
1351 
1352  response.setStatus(status);
1353 
1354  if (status/100 == 2) {
1355  response.write(normalResponse.asJson().toUtf8());
1356  } else {
1357  response.write(errorResponse.asJson().toUtf8());
1358  }
1359  }
1360  else if (request.getMethod() == "POST")
1361  {
1362  SWGSDRangel::SWGDeviceState normalResponse;
1363  int status = m_adapter->devicesetDeviceRunPost(deviceSetIndex, normalResponse, errorResponse);
1364 
1365  response.setStatus(status);
1366 
1367  if (status/100 == 2) {
1368  response.write(normalResponse.asJson().toUtf8());
1369  } else {
1370  response.write(errorResponse.asJson().toUtf8());
1371  }
1372  }
1373  else if (request.getMethod() == "DELETE")
1374  {
1375  SWGSDRangel::SWGDeviceState normalResponse;
1376  int status = m_adapter->devicesetDeviceRunDelete(deviceSetIndex, normalResponse, errorResponse);
1377 
1378  response.setStatus(status);
1379 
1380  if (status/100 == 2) {
1381  response.write(normalResponse.asJson().toUtf8());
1382  } else {
1383  response.write(errorResponse.asJson().toUtf8());
1384  }
1385  }
1386  else
1387  {
1388  response.setStatus(405,"Invalid HTTP method");
1389  errorResponse.init();
1390  *errorResponse.getMessage() = "Invalid HTTP method";
1391  response.write(errorResponse.asJson().toUtf8());
1392  }
1393  }
1394  catch (const boost::bad_lexical_cast &e)
1395  {
1396  errorResponse.init();
1397  *errorResponse.getMessage() = "Wrong integer conversion on device set index";
1398  response.setStatus(400,"Invalid data");
1399  response.write(errorResponse.asJson().toUtf8());
1400  }
1401 }
virtual int devicesetDeviceRunGet(int deviceSetIndex, SWGSDRangel::SWGDeviceState &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual int devicesetDeviceRunPost(int deviceSetIndex, SWGSDRangel::SWGDeviceState &response, SWGSDRangel::SWGErrorResponse &error)
virtual int devicesetDeviceRunDelete(int deviceSetIndex, SWGSDRangel::SWGDeviceState &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetDeviceService()

void WebAPIRequestMapper::devicesetDeviceService ( const std::string &  indexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1190 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGDeviceListItem::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), WebAPIAdapterInterface::devicesetDevicePut(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, parseJsonBody(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), validateDeviceListItem(), and qtwebapp::HttpResponse::write().

Referenced by service().

1191 {
1192  SWGSDRangel::SWGErrorResponse errorResponse;
1193  response.setHeader("Content-Type", "application/json");
1194  response.setHeader("Access-Control-Allow-Origin", "*");
1195 
1196  try
1197  {
1198  int deviceSetIndex = boost::lexical_cast<int>(indexStr);
1199 
1200  if (request.getMethod() == "PUT")
1201  {
1202  QString jsonStr = request.getBody();
1203  QJsonObject jsonObject;
1204 
1205  if (parseJsonBody(jsonStr, jsonObject, response))
1206  {
1208  SWGSDRangel::SWGDeviceListItem normalResponse;
1209 
1210  if (validateDeviceListItem(query, jsonObject))
1211  {
1212  int status = m_adapter->devicesetDevicePut(deviceSetIndex, query, normalResponse, errorResponse);
1213  response.setStatus(status);
1214 
1215  if (status/100 == 2) {
1216  response.write(normalResponse.asJson().toUtf8());
1217  } else {
1218  response.write(errorResponse.asJson().toUtf8());
1219  }
1220  }
1221  else
1222  {
1223  response.setStatus(400,"Missing device identification");
1224  errorResponse.init();
1225  *errorResponse.getMessage() = "Missing device identification";
1226  response.write(errorResponse.asJson().toUtf8());
1227  }
1228  }
1229  else
1230  {
1231  response.setStatus(400,"Invalid JSON format");
1232  errorResponse.init();
1233  *errorResponse.getMessage() = "Invalid JSON format";
1234  response.write(errorResponse.asJson().toUtf8());
1235  }
1236  }
1237  else
1238  {
1239  response.setStatus(405,"Invalid HTTP method");
1240  errorResponse.init();
1241  *errorResponse.getMessage() = "Invalid HTTP method";
1242  response.write(errorResponse.asJson().toUtf8());
1243  }
1244  }
1245  catch (const boost::bad_lexical_cast &e)
1246  {
1247  errorResponse.init();
1248  *errorResponse.getMessage() = "Wrong integer conversion on device set index";
1249  response.setStatus(400,"Invalid data");
1250  response.write(errorResponse.asJson().toUtf8());
1251  }
1252 }
QByteArray getBody() const
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
virtual int devicesetDevicePut(int deviceSetIndex, SWGSDRangel::SWGDeviceListItem &query, SWGSDRangel::SWGDeviceListItem &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
virtual QString asJson() override
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem &deviceListItem, QJsonObject &jsonObject)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetDeviceSettingsService()

void WebAPIRequestMapper::devicesetDeviceSettingsService ( const std::string &  indexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1254 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGDeviceSettings::asJson(), WebAPIAdapterInterface::devicesetDeviceSettingsGet(), WebAPIAdapterInterface::devicesetDeviceSettingsPutPatch(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, parseJsonBody(), resetDeviceSettings(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), validateDeviceSettings(), and qtwebapp::HttpResponse::write().

Referenced by service().

1255 {
1256  SWGSDRangel::SWGErrorResponse errorResponse;
1257  response.setHeader("Content-Type", "application/json");
1258  response.setHeader("Access-Control-Allow-Origin", "*");
1259 
1260  try
1261  {
1262  int deviceSetIndex = boost::lexical_cast<int>(indexStr);
1263 
1264  if ((request.getMethod() == "PUT") || (request.getMethod() == "PATCH"))
1265  {
1266  QString jsonStr = request.getBody();
1267  QJsonObject jsonObject;
1268 
1269  if (parseJsonBody(jsonStr, jsonObject, response))
1270  {
1271  SWGSDRangel::SWGDeviceSettings normalResponse;
1272  resetDeviceSettings(normalResponse);
1273  QStringList deviceSettingsKeys;
1274 
1275  if (validateDeviceSettings(normalResponse, jsonObject, deviceSettingsKeys))
1276  {
1278  deviceSetIndex,
1279  (request.getMethod() == "PUT"), // force settings on PUT
1280  deviceSettingsKeys,
1281  normalResponse,
1282  errorResponse);
1283  response.setStatus(status);
1284 
1285  if (status/100 == 2) {
1286  response.write(normalResponse.asJson().toUtf8());
1287  } else {
1288  response.write(errorResponse.asJson().toUtf8());
1289  }
1290  }
1291  else
1292  {
1293  response.setStatus(400,"Invalid JSON request");
1294  errorResponse.init();
1295  *errorResponse.getMessage() = "Invalid JSON request";
1296  response.write(errorResponse.asJson().toUtf8());
1297  }
1298  }
1299  else
1300  {
1301  response.setStatus(400,"Invalid JSON format");
1302  errorResponse.init();
1303  *errorResponse.getMessage() = "Invalid JSON format";
1304  response.write(errorResponse.asJson().toUtf8());
1305  }
1306  }
1307  else if (request.getMethod() == "GET")
1308  {
1309  SWGSDRangel::SWGDeviceSettings normalResponse;
1310  resetDeviceSettings(normalResponse);
1311  int status = m_adapter->devicesetDeviceSettingsGet(deviceSetIndex, normalResponse, errorResponse);
1312  response.setStatus(status);
1313 
1314  if (status/100 == 2) {
1315  response.write(normalResponse.asJson().toUtf8());
1316  } else {
1317  response.write(errorResponse.asJson().toUtf8());
1318  }
1319  }
1320  else
1321  {
1322  response.setStatus(405,"Invalid HTTP method");
1323  errorResponse.init();
1324  *errorResponse.getMessage() = "Invalid HTTP method";
1325  response.write(errorResponse.asJson().toUtf8());
1326  }
1327  }
1328  catch (const boost::bad_lexical_cast &e)
1329  {
1330  errorResponse.init();
1331  *errorResponse.getMessage() = "Wrong integer conversion on device set index";
1332  response.setStatus(400,"Invalid data");
1333  response.write(errorResponse.asJson().toUtf8());
1334  }
1335 }
QByteArray getBody() const
virtual QString asJson() override
void resetDeviceSettings(SWGSDRangel::SWGDeviceSettings &deviceSettings)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual int devicesetDeviceSettingsGet(int deviceSetIndex, SWGSDRangel::SWGDeviceSettings &response, SWGSDRangel::SWGErrorResponse &error)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings &deviceSettings, QJsonObject &jsonObject, QStringList &deviceSettingsKeys)
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int devicesetDeviceSettingsPutPatch(int deviceSetIndex, bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, SWGSDRangel::SWGErrorResponse &error)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetFocusService()

void WebAPIRequestMapper::devicesetFocusService ( const std::string &  indexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1150 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGSuccessResponse::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), WebAPIAdapterInterface::devicesetFocusPatch(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1151 {
1152  SWGSDRangel::SWGErrorResponse errorResponse;
1153  response.setHeader("Content-Type", "application/json");
1154  response.setHeader("Access-Control-Allow-Origin", "*");
1155 
1156  try
1157  {
1158  int deviceSetIndex = boost::lexical_cast<int>(indexStr);
1159 
1160  if (request.getMethod() == "PATCH")
1161  {
1162  SWGSDRangel::SWGSuccessResponse normalResponse;
1163  int status = m_adapter->devicesetFocusPatch(deviceSetIndex, normalResponse, errorResponse);
1164 
1165  response.setStatus(status);
1166 
1167  if (status/100 == 2) {
1168  response.write(normalResponse.asJson().toUtf8());
1169  } else {
1170  response.write(errorResponse.asJson().toUtf8());
1171  }
1172  }
1173  else
1174  {
1175  response.setStatus(405,"Invalid HTTP method");
1176  errorResponse.init();
1177  *errorResponse.getMessage() = "Invalid HTTP method";
1178  response.write(errorResponse.asJson().toUtf8());
1179  }
1180  }
1181  catch (const boost::bad_lexical_cast &e)
1182  {
1183  errorResponse.init();
1184  *errorResponse.getMessage() = "Wrong integer conversion on device set index";
1185  response.setStatus(400,"Invalid data");
1186  response.write(errorResponse.asJson().toUtf8());
1187  }
1188 }
virtual int devicesetFocusPatch(int deviceSetIndex, SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual QString asJson() override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ devicesetService()

void WebAPIRequestMapper::devicesetService ( const std::string &  indexStr,
qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1112 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGDeviceSet::asJson(), WebAPIAdapterInterface::devicesetGet(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1113 {
1114  SWGSDRangel::SWGErrorResponse errorResponse;
1115  response.setHeader("Content-Type", "application/json");
1116  response.setHeader("Access-Control-Allow-Origin", "*");
1117 
1118  if (request.getMethod() == "GET")
1119  {
1120  try
1121  {
1122  SWGSDRangel::SWGDeviceSet normalResponse;
1123  int deviceSetIndex = boost::lexical_cast<int>(indexStr);
1124  int status = m_adapter->devicesetGet(deviceSetIndex, normalResponse, errorResponse);
1125  response.setStatus(status);
1126 
1127  if (status/100 == 2) {
1128  response.write(normalResponse.asJson().toUtf8());
1129  } else {
1130  response.write(errorResponse.asJson().toUtf8());
1131  }
1132  }
1133  catch (const boost::bad_lexical_cast &e)
1134  {
1135  errorResponse.init();
1136  *errorResponse.getMessage() = "Wrong integer conversion on device set index";
1137  response.setStatus(400,"Invalid data");
1138  response.write(errorResponse.asJson().toUtf8());
1139  }
1140  }
1141  else
1142  {
1143  response.setStatus(405,"Invalid HTTP method");
1144  errorResponse.init();
1145  *errorResponse.getMessage() = "Invalid HTTP method";
1146  response.write(errorResponse.asJson().toUtf8());
1147  }
1148 }
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual QString asJson() override
virtual int devicesetGet(int deviceSetIndex, SWGSDRangel::SWGDeviceSet &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceAMBEDevicesService()

void WebAPIRequestMapper::instanceAMBEDevicesService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 673 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGSuccessResponse::asJson(), SWGSDRangel::SWGAMBEDevices::asJson(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceAMBEDevicesDelete(), WebAPIAdapterInterface::instanceAMBEDevicesGet(), WebAPIAdapterInterface::instanceAMBEDevicesPatch(), WebAPIAdapterInterface::instanceAMBEDevicesPut(), m_adapter, parseJsonBody(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), validateAMBEDevices(), and qtwebapp::HttpResponse::write().

Referenced by service().

674 {
675  SWGSDRangel::SWGErrorResponse errorResponse;
676  response.setHeader("Content-Type", "application/json");
677  response.setHeader("Access-Control-Allow-Origin", "*");
678 
679  if (request.getMethod() == "GET")
680  {
681  SWGSDRangel::SWGAMBEDevices normalResponse;
682 
683  int status = m_adapter->instanceAMBEDevicesGet(normalResponse, errorResponse);
684  response.setStatus(status);
685 
686  if (status/100 == 2) {
687  response.write(normalResponse.asJson().toUtf8());
688  } else {
689  response.write(errorResponse.asJson().toUtf8());
690  }
691  }
692  else if ((request.getMethod() == "PATCH") || (request.getMethod() == "PUT"))
693  {
695  SWGSDRangel::SWGAMBEDevices normalResponse;
696  QString jsonStr = request.getBody();
697  QJsonObject jsonObject;
698 
699  if (parseJsonBody(jsonStr, jsonObject, response))
700  {
701  if (validateAMBEDevices(query, jsonObject))
702  {
703  int status;
704 
705  if (request.getMethod() == "PATCH") {
706  status = m_adapter->instanceAMBEDevicesPatch(query, normalResponse, errorResponse);
707  } else {
708  status = m_adapter->instanceAMBEDevicesPut(query, normalResponse, errorResponse);
709  }
710 
711  response.setStatus(status);
712 
713  if (status/100 == 2) {
714  response.write(normalResponse.asJson().toUtf8());
715  } else {
716  response.write(errorResponse.asJson().toUtf8());
717  }
718  }
719  else
720  {
721  response.setStatus(400,"Invalid JSON request");
722  errorResponse.init();
723  *errorResponse.getMessage() = "Invalid JSON request";
724  response.write(errorResponse.asJson().toUtf8());
725  }
726  }
727  else
728  {
729  response.setStatus(400,"Invalid JSON format");
730  errorResponse.init();
731  *errorResponse.getMessage() = "Invalid JSON format";
732  response.write(errorResponse.asJson().toUtf8());
733  }
734  }
735  else if (request.getMethod() == "DELETE")
736  {
737  SWGSDRangel::SWGSuccessResponse normalResponse;
738 
739  int status = m_adapter->instanceAMBEDevicesDelete(normalResponse, errorResponse);
740  response.setStatus(status);
741 
742  if (status/100 == 2) {
743  response.write(normalResponse.asJson().toUtf8());
744  } else {
745  response.write(errorResponse.asJson().toUtf8());
746  }
747  }
748  else
749  {
750  response.setStatus(405,"Invalid HTTP method");
751  errorResponse.init();
752  *errorResponse.getMessage() = "Invalid HTTP method";
753  response.write(errorResponse.asJson().toUtf8());
754  }
755 }
QByteArray getBody() const
virtual int instanceAMBEDevicesDelete(SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
bool validateAMBEDevices(SWGSDRangel::SWGAMBEDevices &ambeDevices, QJsonObject &jsonObject)
void setHeader(QByteArray name, QByteArray value)
virtual int instanceAMBEDevicesPatch(SWGSDRangel::SWGAMBEDevices &query, SWGSDRangel::SWGAMBEDevices &response, SWGSDRangel::SWGErrorResponse &error)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
virtual int instanceAMBEDevicesGet(SWGSDRangel::SWGAMBEDevices &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
virtual QString asJson() override
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int instanceAMBEDevicesPut(SWGSDRangel::SWGAMBEDevices &query, SWGSDRangel::SWGAMBEDevices &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceAMBESerialService()

void WebAPIRequestMapper::instanceAMBESerialService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 645 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGDVSerialDevices::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceAMBESerialGet(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

646 {
647  SWGSDRangel::SWGErrorResponse errorResponse;
648  response.setHeader("Content-Type", "application/json");
649  response.setHeader("Access-Control-Allow-Origin", "*");
650 
651  if (request.getMethod() == "GET")
652  {
653  SWGSDRangel::SWGDVSerialDevices normalResponse;
654 
655  int status = m_adapter->instanceAMBESerialGet(normalResponse, errorResponse);
656  response.setStatus(status);
657 
658  if (status/100 == 2) {
659  response.write(normalResponse.asJson().toUtf8());
660  } else {
661  response.write(errorResponse.asJson().toUtf8());
662  }
663  }
664  else
665  {
666  response.setStatus(405,"Invalid HTTP method");
667  errorResponse.init();
668  *errorResponse.getMessage() = "Invalid HTTP method";
669  response.write(errorResponse.asJson().toUtf8());
670  }
671 }
virtual QString asJson() override
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual int instanceAMBESerialGet(SWGSDRangel::SWGDVSerialDevices &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceAudioInputCleanupService()

void WebAPIRequestMapper::instanceAudioInputCleanupService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 535 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGSuccessResponse::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceAudioInputCleanupPatch(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

536 {
537  SWGSDRangel::SWGErrorResponse errorResponse;
538  response.setHeader("Content-Type", "application/json");
539  response.setHeader("Access-Control-Allow-Origin", "*");
540 
541  if (request.getMethod() == "PATCH")
542  {
543  SWGSDRangel::SWGSuccessResponse normalResponse;
544 
545  int status = m_adapter->instanceAudioInputCleanupPatch(normalResponse, errorResponse);
546  response.setStatus(status);
547 
548  if (status/100 == 2) {
549  response.write(normalResponse.asJson().toUtf8());
550  } else {
551  response.write(errorResponse.asJson().toUtf8());
552  }
553  }
554  else
555  {
556  response.setStatus(405,"Invalid HTTP method");
557  errorResponse.init();
558  *errorResponse.getMessage() = "Invalid HTTP method";
559  response.write(errorResponse.asJson().toUtf8());
560  }
561 }
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual int instanceAudioInputCleanupPatch(SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual QString asJson() override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceAudioInputParametersService()

void WebAPIRequestMapper::instanceAudioInputParametersService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 397 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGAudioInputDevice::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceAudioInputDelete(), WebAPIAdapterInterface::instanceAudioInputPatch(), m_adapter, parseJsonBody(), resetAudioInputDevice(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), validateAudioInputDevice(), and qtwebapp::HttpResponse::write().

Referenced by service().

398 {
399  SWGSDRangel::SWGErrorResponse errorResponse;
400  response.setHeader("Content-Type", "application/json");
401  response.setHeader("Access-Control-Allow-Origin", "*");
402 
403  QString jsonStr = request.getBody();
404  QJsonObject jsonObject;
405 
406  if (parseJsonBody(jsonStr, jsonObject, response))
407  {
408  SWGSDRangel::SWGAudioInputDevice normalResponse;
409  resetAudioInputDevice(normalResponse);
410  QStringList audioInputDeviceKeys;
411 
412  if (validateAudioInputDevice(normalResponse, jsonObject, audioInputDeviceKeys))
413  {
414  if (request.getMethod() == "PATCH")
415  {
416  int status = m_adapter->instanceAudioInputPatch(
417  normalResponse,
418  audioInputDeviceKeys,
419  errorResponse);
420  response.setStatus(status);
421 
422  if (status/100 == 2) {
423  response.write(normalResponse.asJson().toUtf8());
424  } else {
425  response.write(errorResponse.asJson().toUtf8());
426  }
427  }
428  else if (request.getMethod() == "DELETE")
429  {
430  int status = m_adapter->instanceAudioInputDelete(
431  normalResponse,
432  errorResponse);
433  response.setStatus(status);
434 
435  if (status/100 == 2) {
436  response.write(normalResponse.asJson().toUtf8());
437  } else {
438  response.write(errorResponse.asJson().toUtf8());
439  }
440  }
441  else
442  {
443  response.setStatus(405,"Invalid HTTP method");
444  errorResponse.init();
445  *errorResponse.getMessage() = "Invalid HTTP method";
446  response.write(errorResponse.asJson().toUtf8());
447  }
448  }
449  else
450  {
451  response.setStatus(400,"Invalid JSON request");
452  errorResponse.init();
453  *errorResponse.getMessage() = "Invalid JSON request";
454  response.write(errorResponse.asJson().toUtf8());
455  }
456  }
457  else
458  {
459  response.setStatus(400,"Invalid JSON format");
460  errorResponse.init();
461  *errorResponse.getMessage() = "Invalid JSON format";
462  response.write(errorResponse.asJson().toUtf8());
463  }
464 }
QByteArray getBody() const
bool validateAudioInputDevice(SWGSDRangel::SWGAudioInputDevice &audioInputDevice, QJsonObject &jsonObject, QStringList &audioInputDeviceKeys)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual int instanceAudioInputPatch(SWGSDRangel::SWGAudioInputDevice &response, const QStringList &audioInputKeys, SWGSDRangel::SWGErrorResponse &error)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
void resetAudioInputDevice(SWGSDRangel::SWGAudioInputDevice &audioInputDevice)
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int instanceAudioInputDelete(SWGSDRangel::SWGAudioInputDevice &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceAudioOutputCleanupService()

void WebAPIRequestMapper::instanceAudioOutputCleanupService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 563 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGSuccessResponse::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceAudioOutputCleanupPatch(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

564 {
565  SWGSDRangel::SWGErrorResponse errorResponse;
566  response.setHeader("Content-Type", "application/json");
567  response.setHeader("Access-Control-Allow-Origin", "*");
568 
569  if (request.getMethod() == "PATCH")
570  {
571  SWGSDRangel::SWGSuccessResponse normalResponse;
572 
573  int status = m_adapter->instanceAudioOutputCleanupPatch(normalResponse, errorResponse);
574  response.setStatus(status);
575 
576  if (status/100 == 2) {
577  response.write(normalResponse.asJson().toUtf8());
578  } else {
579  response.write(errorResponse.asJson().toUtf8());
580  }
581  }
582  else
583  {
584  response.setStatus(405,"Invalid HTTP method");
585  errorResponse.init();
586  *errorResponse.getMessage() = "Invalid HTTP method";
587  response.write(errorResponse.asJson().toUtf8());
588  }
589 }
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual int instanceAudioOutputCleanupPatch(SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual QString asJson() override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceAudioOutputParametersService()

void WebAPIRequestMapper::instanceAudioOutputParametersService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 466 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGAudioOutputDevice::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceAudioOutputDelete(), WebAPIAdapterInterface::instanceAudioOutputPatch(), m_adapter, parseJsonBody(), resetAudioOutputDevice(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), validateAudioOutputDevice(), and qtwebapp::HttpResponse::write().

Referenced by service().

467 {
468  SWGSDRangel::SWGErrorResponse errorResponse;
469  response.setHeader("Content-Type", "application/json");
470  response.setHeader("Access-Control-Allow-Origin", "*");
471 
472  QString jsonStr = request.getBody();
473  QJsonObject jsonObject;
474 
475  if (parseJsonBody(jsonStr, jsonObject, response))
476  {
477  SWGSDRangel::SWGAudioOutputDevice normalResponse;
478  resetAudioOutputDevice(normalResponse);
479  QStringList audioOutputDeviceKeys;
480 
481  if (validateAudioOutputDevice(normalResponse, jsonObject, audioOutputDeviceKeys))
482  {
483  if (request.getMethod() == "PATCH")
484  {
485  int status = m_adapter->instanceAudioOutputPatch(
486  normalResponse,
487  audioOutputDeviceKeys,
488  errorResponse);
489  response.setStatus(status);
490 
491  if (status/100 == 2) {
492  response.write(normalResponse.asJson().toUtf8());
493  } else {
494  response.write(errorResponse.asJson().toUtf8());
495  }
496  }
497  else if (request.getMethod() == "DELETE")
498  {
499  int status = m_adapter->instanceAudioOutputDelete(
500  normalResponse,
501  errorResponse);
502  response.setStatus(status);
503 
504  if (status/100 == 2) {
505  response.write(normalResponse.asJson().toUtf8());
506  } else {
507  response.write(errorResponse.asJson().toUtf8());
508  }
509  }
510  else
511  {
512  response.setStatus(405,"Invalid HTTP method");
513  errorResponse.init();
514  *errorResponse.getMessage() = "Invalid HTTP method";
515  response.write(errorResponse.asJson().toUtf8());
516  }
517  }
518  else
519  {
520  response.setStatus(400,"Invalid JSON request");
521  errorResponse.init();
522  *errorResponse.getMessage() = "Invalid JSON request";
523  response.write(errorResponse.asJson().toUtf8());
524  }
525  }
526  else
527  {
528  response.setStatus(400,"Invalid JSON format");
529  errorResponse.init();
530  *errorResponse.getMessage() = "Invalid JSON format";
531  response.write(errorResponse.asJson().toUtf8());
532  }
533 }
QByteArray getBody() const
bool validateAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice &audioOutputDevice, QJsonObject &jsonObject, QStringList &audioOutputDeviceKeys)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
virtual int instanceAudioOutputDelete(SWGSDRangel::SWGAudioOutputDevice &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
virtual int instanceAudioOutputPatch(SWGSDRangel::SWGAudioOutputDevice &response, const QStringList &audioOutputKeys, SWGSDRangel::SWGErrorResponse &error)
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
void resetAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice &audioOutputDevice)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceAudioService()

void WebAPIRequestMapper::instanceAudioService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 369 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGAudioDevices::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceAudioGet(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

370 {
371  SWGSDRangel::SWGErrorResponse errorResponse;
372  response.setHeader("Content-Type", "application/json");
373  response.setHeader("Access-Control-Allow-Origin", "*");
374 
375  if (request.getMethod() == "GET")
376  {
377  SWGSDRangel::SWGAudioDevices normalResponse;
378 
379  int status = m_adapter->instanceAudioGet(normalResponse, errorResponse);
380  response.setStatus(status);
381 
382  if (status/100 == 2) {
383  response.write(normalResponse.asJson().toUtf8());
384  } else {
385  response.write(errorResponse.asJson().toUtf8());
386  }
387  }
388  else
389  {
390  response.setStatus(405,"Invalid HTTP method");
391  errorResponse.init();
392  *errorResponse.getMessage() = "Invalid HTTP method";
393  response.write(errorResponse.asJson().toUtf8());
394  }
395 }
virtual QString asJson() override
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
virtual int instanceAudioGet(SWGSDRangel::SWGAudioDevices &response, SWGSDRangel::SWGErrorResponse &error)
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceChannelsService()

void WebAPIRequestMapper::instanceChannelsService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 277 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGInstanceChannelsResponse::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), qtwebapp::HttpRequest::getParameter(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceChannels(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

278 {
280  SWGSDRangel::SWGErrorResponse errorResponse;
281  response.setHeader("Content-Type", "application/json");
282  response.setHeader("Access-Control-Allow-Origin", "*");
283 
284  if (request.getMethod() == "GET")
285  {
286  QByteArray dirStr = request.getParameter("direction");
287  int direction = 0;
288 
289  if (dirStr.length() != 0)
290  {
291  bool ok;
292  int tmp = dirStr.toInt(&ok);
293  if (ok) {
294  direction = tmp;
295  }
296  }
297 
298  int status = m_adapter->instanceChannels(direction, normalResponse, errorResponse);
299  response.setStatus(status);
300 
301  if (status/100 == 2) {
302  response.write(normalResponse.asJson().toUtf8());
303  } else {
304  response.write(errorResponse.asJson().toUtf8());
305  }
306  }
307  else
308  {
309  response.setStatus(405,"Invalid HTTP method");
310  errorResponse.init();
311  *errorResponse.getMessage() = "Invalid HTTP method";
312  response.write(errorResponse.asJson().toUtf8());
313  }
314 }
QByteArray getParameter(const QByteArray &name) const
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual int instanceChannels(int direction, SWGSDRangel::SWGInstanceChannelsResponse &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceConfigService()

void WebAPIRequestMapper::instanceConfigService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 218 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGInstanceConfigResponse::asJson(), qtwebapp::HttpRequest::getMethod(), WebAPIAdapterInterface::instanceConfigGet(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

219 {
220  SWGSDRangel::SWGErrorResponse errorResponse;
221  response.setHeader("Content-Type", "application/json");
222  response.setHeader("Access-Control-Allow-Origin", "*");
223 
224  if (request.getMethod() == "GET")
225  {
227  int status = m_adapter->instanceConfigGet(normalResponse, errorResponse);
228  response.setStatus(status);
229 
230  if (status/100 == 2) {
231  response.write(normalResponse.asJson().toUtf8());
232  } else {
233  response.write(errorResponse.asJson().toUtf8());
234  }
235  }
236 }
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int instanceConfigGet(SWGSDRangel::SWGInstanceConfigResponse &response, SWGSDRangel::SWGErrorResponse &error)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceDeviceSetService()

void WebAPIRequestMapper::instanceDeviceSetService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1061 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGSuccessResponse::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), qtwebapp::HttpRequest::getParameter(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceDeviceSetDelete(), WebAPIAdapterInterface::instanceDeviceSetPost(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1062 {
1063  SWGSDRangel::SWGErrorResponse errorResponse;
1064  response.setHeader("Content-Type", "application/json");
1065  response.setHeader("Access-Control-Allow-Origin", "*");
1066 
1067  if (request.getMethod() == "POST")
1068  {
1069  SWGSDRangel::SWGSuccessResponse normalResponse;
1070  QByteArray dirStr = request.getParameter("direction");
1071  int direction = 0;
1072 
1073  if (dirStr.length() != 0)
1074  {
1075  bool ok;
1076  int tmp = dirStr.toInt(&ok);
1077  if (ok) {
1078  direction = tmp;
1079  }
1080  }
1081 
1082  int status = m_adapter->instanceDeviceSetPost(direction, normalResponse, errorResponse);
1083  response.setStatus(status);
1084 
1085  if (status/100 == 2) {
1086  response.write(normalResponse.asJson().toUtf8());
1087  } else {
1088  response.write(errorResponse.asJson().toUtf8());
1089  }
1090  }
1091  else if (request.getMethod() == "DELETE")
1092  {
1093  SWGSDRangel::SWGSuccessResponse normalResponse;
1094  int status = m_adapter->instanceDeviceSetDelete(normalResponse, errorResponse);
1095  response.setStatus(status);
1096 
1097  if (status/100 == 2) {
1098  response.write(normalResponse.asJson().toUtf8());
1099  } else {
1100  response.write(errorResponse.asJson().toUtf8());
1101  }
1102  }
1103  else
1104  {
1105  response.setStatus(405,"Invalid HTTP method");
1106  errorResponse.init();
1107  *errorResponse.getMessage() = "Invalid HTTP method";
1108  response.write(errorResponse.asJson().toUtf8());
1109  }
1110 }
virtual int instanceDeviceSetDelete(SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
QByteArray getParameter(const QByteArray &name) const
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual QString asJson() override
virtual int instanceDeviceSetPost(int direction, SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceDeviceSetsService()

void WebAPIRequestMapper::instanceDeviceSetsService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 1034 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGDeviceSetList::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceDeviceSetsGet(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

1035 {
1036  SWGSDRangel::SWGErrorResponse errorResponse;
1037  response.setHeader("Content-Type", "application/json");
1038  response.setHeader("Access-Control-Allow-Origin", "*");
1039 
1040  if (request.getMethod() == "GET")
1041  {
1042  SWGSDRangel::SWGDeviceSetList normalResponse;
1043  int status = m_adapter->instanceDeviceSetsGet(normalResponse, errorResponse);
1044  response.setStatus(status);
1045 
1046  if (status/100 == 2) {
1047  response.write(normalResponse.asJson().toUtf8());
1048  } else {
1049  response.write(errorResponse.asJson().toUtf8());
1050  }
1051  }
1052  else
1053  {
1054  response.setStatus(405,"Invalid HTTP method");
1055  errorResponse.init();
1056  *errorResponse.getMessage() = "Invalid HTTP method";
1057  response.write(errorResponse.asJson().toUtf8());
1058  }
1059 }
virtual QString asJson() override
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int instanceDeviceSetsGet(SWGSDRangel::SWGDeviceSetList &response, SWGSDRangel::SWGErrorResponse &error)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceDevicesService()

void WebAPIRequestMapper::instanceDevicesService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 238 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGInstanceDevicesResponse::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), qtwebapp::HttpRequest::getParameter(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceDevices(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

239 {
241  SWGSDRangel::SWGErrorResponse errorResponse;
242  response.setHeader("Content-Type", "application/json");
243  response.setHeader("Access-Control-Allow-Origin", "*");
244 
245  if (request.getMethod() == "GET")
246  {
247  QByteArray dirStr = request.getParameter("direction");
248  int direction = 0;
249 
250  if (dirStr.length() != 0)
251  {
252  bool ok;
253  int tmp = dirStr.toInt(&ok);
254  if (ok) {
255  direction = tmp;
256  }
257  }
258 
259  int status = m_adapter->instanceDevices(direction, normalResponse, errorResponse);
260  response.setStatus(status);
261 
262  if (status/100 == 2) {
263  response.write(normalResponse.asJson().toUtf8());
264  } else {
265  response.write(errorResponse.asJson().toUtf8());
266  }
267  }
268  else
269  {
270  response.setStatus(405,"Invalid HTTP method");
271  errorResponse.init();
272  *errorResponse.getMessage() = "Invalid HTTP method";
273  response.write(errorResponse.asJson().toUtf8());
274  }
275 }
QByteArray getParameter(const QByteArray &name) const
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
virtual int instanceDevices(int direction, SWGSDRangel::SWGInstanceDevicesResponse &response, SWGSDRangel::SWGErrorResponse &error)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceDVSerialService()

void WebAPIRequestMapper::instanceDVSerialService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

◆ instanceLocationService()

void WebAPIRequestMapper::instanceLocationService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 591 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGLocationInformation::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGLocationInformation::fromJson(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceLocationGet(), WebAPIAdapterInterface::instanceLocationPut(), m_adapter, parseJsonBody(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

592 {
593  SWGSDRangel::SWGErrorResponse errorResponse;
594  response.setHeader("Content-Type", "application/json");
595  response.setHeader("Access-Control-Allow-Origin", "*");
596 
597  if (request.getMethod() == "GET")
598  {
600 
601  int status = m_adapter->instanceLocationGet(normalResponse, errorResponse);
602  response.setStatus(status);
603 
604  if (status/100 == 2) {
605  response.write(normalResponse.asJson().toUtf8());
606  } else {
607  response.write(errorResponse.asJson().toUtf8());
608  }
609  }
610  else if (request.getMethod() == "PUT")
611  {
613  QString jsonStr = request.getBody();
614  QJsonObject jsonObject;
615 
616  if (parseJsonBody(jsonStr, jsonObject, response))
617  {
618  normalResponse.fromJson(jsonStr);
619  int status = m_adapter->instanceLocationPut(normalResponse, errorResponse);
620  response.setStatus(status);
621 
622  if (status/100 == 2) {
623  response.write(normalResponse.asJson().toUtf8());
624  } else {
625  response.write(errorResponse.asJson().toUtf8());
626  }
627  }
628  else
629  {
630  response.setStatus(400,"Invalid JSON format");
631  errorResponse.init();
632  *errorResponse.getMessage() = "Invalid JSON format";
633  response.write(errorResponse.asJson().toUtf8());
634  }
635  }
636  else
637  {
638  response.setStatus(405,"Invalid HTTP method");
639  errorResponse.init();
640  *errorResponse.getMessage() = "Invalid HTTP method";
641  response.write(errorResponse.asJson().toUtf8());
642  }
643 }
QByteArray getBody() const
virtual int instanceLocationGet(SWGSDRangel::SWGLocationInformation &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual SWGLocationInformation * fromJson(QString &jsonString) override
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int instanceLocationPut(SWGSDRangel::SWGLocationInformation &response, SWGSDRangel::SWGErrorResponse &error)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceLoggingService()

void WebAPIRequestMapper::instanceLoggingService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 316 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGLoggingInfo::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGLoggingInfo::fromJson(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceLoggingGet(), WebAPIAdapterInterface::instanceLoggingPut(), m_adapter, parseJsonBody(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

317 {
319  SWGSDRangel::SWGLoggingInfo normalResponse;
320  SWGSDRangel::SWGErrorResponse errorResponse;
321  response.setHeader("Content-Type", "application/json");
322  response.setHeader("Access-Control-Allow-Origin", "*");
323 
324  if (request.getMethod() == "GET")
325  {
326  int status = m_adapter->instanceLoggingGet(normalResponse, errorResponse);
327  response.setStatus(status);
328 
329  if (status/100 == 2) {
330  response.write(normalResponse.asJson().toUtf8());
331  } else {
332  response.write(errorResponse.asJson().toUtf8());
333  }
334  }
335  else if (request.getMethod() == "PUT")
336  {
337  QString jsonStr = request.getBody();
338  QJsonObject jsonObject;
339 
340  if (parseJsonBody(jsonStr, jsonObject, response))
341  {
342  query.fromJson(jsonStr);
343  int status = m_adapter->instanceLoggingPut(query, normalResponse, errorResponse);
344  response.setStatus(status);
345 
346  if (status/100 == 2) {
347  response.write(normalResponse.asJson().toUtf8());
348  } else {
349  response.write(errorResponse.asJson().toUtf8());
350  }
351  }
352  else
353  {
354  response.setStatus(400,"Invalid JSON format");
355  errorResponse.init();
356  *errorResponse.getMessage() = "Invalid JSON format";
357  response.write(errorResponse.asJson().toUtf8());
358  }
359  }
360  else
361  {
362  response.setStatus(405,"Invalid HTTP method");
363  errorResponse.init();
364  *errorResponse.getMessage() = "Invalid HTTP method";
365  response.write(errorResponse.asJson().toUtf8());
366  }
367 }
QByteArray getBody() const
virtual int instanceLoggingGet(SWGSDRangel::SWGLoggingInfo &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
virtual int instanceLoggingPut(SWGSDRangel::SWGLoggingInfo &query, SWGSDRangel::SWGLoggingInfo &response, SWGSDRangel::SWGErrorResponse &error)
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual QString asJson() override
virtual SWGLoggingInfo * fromJson(QString &jsonString) override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instancePresetFileService()

void WebAPIRequestMapper::instancePresetFileService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 943 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGPresetIdentifier::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGPresetImport::fromJson(), SWGSDRangel::SWGPresetExport::fromJson(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGPresetImport::getFilePath(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instancePresetFilePost(), WebAPIAdapterInterface::instancePresetFilePut(), m_adapter, parseJsonBody(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), validatePresetExport(), and qtwebapp::HttpResponse::write().

Referenced by service().

944 {
945  SWGSDRangel::SWGErrorResponse errorResponse;
946  response.setHeader("Content-Type", "application/json");
947  response.setHeader("Access-Control-Allow-Origin", "*");
948 
949  if (request.getMethod() == "PUT")
950  {
952  SWGSDRangel::SWGPresetIdentifier normalResponse;
953  QString jsonStr = request.getBody();
954  QJsonObject jsonObject;
955 
956  if (parseJsonBody(jsonStr, jsonObject, response))
957  {
958  query.fromJson(jsonStr);
959 
960  if (query.getFilePath())
961  {
962  int status = m_adapter->instancePresetFilePut(query, normalResponse, errorResponse);
963  response.setStatus(status);
964 
965  if (status/100 == 2) {
966  response.write(normalResponse.asJson().toUtf8());
967  } else {
968  response.write(errorResponse.asJson().toUtf8());
969  }
970  }
971  else
972  {
973  response.setStatus(400,"Invalid JSON request");
974  errorResponse.init();
975  *errorResponse.getMessage() = "Invalid JSON request";
976  response.write(errorResponse.asJson().toUtf8());
977  }
978  }
979  else
980  {
981  response.setStatus(400,"Invalid JSON format");
982  errorResponse.init();
983  *errorResponse.getMessage() = "Invalid JSON format";
984  response.write(errorResponse.asJson().toUtf8());
985  }
986  }
987  else if (request.getMethod() == "POST")
988  {
990  SWGSDRangel::SWGPresetIdentifier normalResponse;
991  QString jsonStr = request.getBody();
992  QJsonObject jsonObject;
993 
994  if (parseJsonBody(jsonStr, jsonObject, response))
995  {
996  query.fromJson(jsonStr);
997 
998  if (validatePresetExport(query))
999  {
1000  int status = m_adapter->instancePresetFilePost(query, normalResponse, errorResponse);
1001  response.setStatus(status);
1002 
1003  if (status/100 == 2) {
1004  response.write(normalResponse.asJson().toUtf8());
1005  } else {
1006  response.write(errorResponse.asJson().toUtf8());
1007  }
1008  }
1009  else
1010  {
1011  response.setStatus(400,"Invalid JSON request");
1012  errorResponse.init();
1013  *errorResponse.getMessage() = "Invalid JSON request";
1014  response.write(errorResponse.asJson().toUtf8());
1015  }
1016  }
1017  else
1018  {
1019  response.setStatus(400,"Invalid JSON format");
1020  errorResponse.init();
1021  *errorResponse.getMessage() = "Invalid JSON format";
1022  response.write(errorResponse.asJson().toUtf8());
1023  }
1024  }
1025  else
1026  {
1027  response.setStatus(405,"Invalid HTTP method");
1028  errorResponse.init();
1029  *errorResponse.getMessage() = "Invalid HTTP method";
1030  response.write(errorResponse.asJson().toUtf8());
1031  }
1032 }
QByteArray getBody() const
virtual SWGPresetImport * fromJson(QString &jsonString) override
bool validatePresetExport(SWGSDRangel::SWGPresetExport &presetExport)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
virtual int instancePresetFilePost(SWGSDRangel::SWGPresetExport &query, SWGSDRangel::SWGPresetIdentifier &response, SWGSDRangel::SWGErrorResponse &error)
void write(QByteArray data, bool lastPart=false)
virtual SWGPresetExport * fromJson(QString &jsonString) override
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int instancePresetFilePut(SWGSDRangel::SWGPresetImport &query, SWGSDRangel::SWGPresetIdentifier &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instancePresetService()

void WebAPIRequestMapper::instancePresetService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 777 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGPresetIdentifier::asJson(), SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGPresetTransfer::fromJson(), SWGSDRangel::SWGPresetIdentifier::fromJson(), qtwebapp::HttpRequest::getBody(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instancePresetDelete(), WebAPIAdapterInterface::instancePresetPatch(), WebAPIAdapterInterface::instancePresetPost(), WebAPIAdapterInterface::instancePresetPut(), m_adapter, parseJsonBody(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), validatePresetIdentifer(), validatePresetTransfer(), and qtwebapp::HttpResponse::write().

Referenced by service().

778 {
779  SWGSDRangel::SWGErrorResponse errorResponse;
780  response.setHeader("Content-Type", "application/json");
781  response.setHeader("Access-Control-Allow-Origin", "*");
782 
783  if (request.getMethod() == "PATCH")
784  {
786  SWGSDRangel::SWGPresetIdentifier normalResponse;
787  QString jsonStr = request.getBody();
788  QJsonObject jsonObject;
789 
790  if (parseJsonBody(jsonStr, jsonObject, response))
791  {
792  query.fromJson(jsonStr);
793 
794  if (validatePresetTransfer(query))
795  {
796  int status = m_adapter->instancePresetPatch(query, normalResponse, errorResponse);
797  response.setStatus(status);
798 
799  if (status/100 == 2) {
800  response.write(normalResponse.asJson().toUtf8());
801  } else {
802  response.write(errorResponse.asJson().toUtf8());
803  }
804  }
805  else
806  {
807  response.setStatus(400,"Invalid JSON request");
808  errorResponse.init();
809  *errorResponse.getMessage() = "Invalid JSON request";
810  response.write(errorResponse.asJson().toUtf8());
811  }
812  }
813  else
814  {
815  response.setStatus(400,"Invalid JSON format");
816  errorResponse.init();
817  *errorResponse.getMessage() = "Invalid JSON format";
818  response.write(errorResponse.asJson().toUtf8());
819  }
820  }
821  else if (request.getMethod() == "PUT")
822  {
824  SWGSDRangel::SWGPresetIdentifier normalResponse;
825  QString jsonStr = request.getBody();
826  QJsonObject jsonObject;
827 
828  if (parseJsonBody(jsonStr, jsonObject, response))
829  {
830  query.fromJson(jsonStr);
831 
832  if (validatePresetTransfer(query))
833  {
834  int status = m_adapter->instancePresetPut(query, normalResponse, errorResponse);
835  response.setStatus(status);
836 
837  if (status/100 == 2) {
838  response.write(normalResponse.asJson().toUtf8());
839  } else {
840  response.write(errorResponse.asJson().toUtf8());
841  }
842  }
843  else
844  {
845  response.setStatus(400,"Invalid JSON request");
846  errorResponse.init();
847  *errorResponse.getMessage() = "Invalid JSON request";
848  response.write(errorResponse.asJson().toUtf8());
849  }
850  }
851  else
852  {
853  response.setStatus(400,"Invalid JSON format");
854  errorResponse.init();
855  *errorResponse.getMessage() = "Invalid JSON format";
856  response.write(errorResponse.asJson().toUtf8());
857  }
858  }
859  else if (request.getMethod() == "POST")
860  {
862  SWGSDRangel::SWGPresetIdentifier normalResponse;
863  QString jsonStr = request.getBody();
864  QJsonObject jsonObject;
865 
866  if (parseJsonBody(jsonStr, jsonObject, response))
867  {
868  query.fromJson(jsonStr);
869 
870  if (validatePresetTransfer(query))
871  {
872  int status = m_adapter->instancePresetPost(query, normalResponse, errorResponse);
873  response.setStatus(status);
874 
875  if (status/100 == 2) {
876  response.write(normalResponse.asJson().toUtf8());
877  } else {
878  response.write(errorResponse.asJson().toUtf8());
879  }
880  }
881  else
882  {
883  response.setStatus(400,"Invalid JSON request");
884  errorResponse.init();
885  *errorResponse.getMessage() = "Invalid JSON request";
886  response.write(errorResponse.asJson().toUtf8());
887  }
888  }
889  else
890  {
891  response.setStatus(400,"Invalid JSON format");
892  errorResponse.init();
893  *errorResponse.getMessage() = "Invalid JSON format";
894  response.write(errorResponse.asJson().toUtf8());
895  }
896  }
897  else if (request.getMethod() == "DELETE")
898  {
899  SWGSDRangel::SWGPresetIdentifier normalResponse;
900  QString jsonStr = request.getBody();
901  QJsonObject jsonObject;
902 
903  if (parseJsonBody(jsonStr, jsonObject, response))
904  {
905  normalResponse.fromJson(jsonStr);
906 
907  if (validatePresetIdentifer(normalResponse))
908  {
909  int status = m_adapter->instancePresetDelete(normalResponse, errorResponse);
910  response.setStatus(status);
911 
912  if (status/100 == 2) {
913  response.write(normalResponse.asJson().toUtf8());
914  } else {
915  response.write(errorResponse.asJson().toUtf8());
916  }
917  }
918  else
919  {
920  response.setStatus(400,"Invalid JSON request");
921  errorResponse.init();
922  *errorResponse.getMessage() = "Invalid JSON request";
923  response.write(errorResponse.asJson().toUtf8());
924  }
925  }
926  else
927  {
928  response.setStatus(400,"Invalid JSON format");
929  errorResponse.init();
930  *errorResponse.getMessage() = "Invalid JSON format";
931  response.write(errorResponse.asJson().toUtf8());
932  }
933  }
934  else
935  {
936  response.setStatus(405,"Invalid HTTP method");
937  errorResponse.init();
938  *errorResponse.getMessage() = "Invalid HTTP method";
939  response.write(errorResponse.asJson().toUtf8());
940  }
941 }
QByteArray getBody() const
virtual int instancePresetDelete(SWGSDRangel::SWGPresetIdentifier &response, SWGSDRangel::SWGErrorResponse &error)
bool validatePresetTransfer(SWGSDRangel::SWGPresetTransfer &presetTransfer)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier &presetIdentifier)
virtual SWGPresetTransfer * fromJson(QString &jsonString) override
virtual int instancePresetPut(SWGSDRangel::SWGPresetTransfer &query, SWGSDRangel::SWGPresetIdentifier &response, SWGSDRangel::SWGErrorResponse &error)
virtual int instancePresetPost(SWGSDRangel::SWGPresetTransfer &query, SWGSDRangel::SWGPresetIdentifier &response, SWGSDRangel::SWGErrorResponse &error)
bool parseJsonBody(QString &jsonStr, QJsonObject &jsonObject, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
virtual SWGPresetIdentifier * fromJson(QString &jsonString) override
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual QString asJson() override
virtual int instancePresetPatch(SWGSDRangel::SWGPresetTransfer &query, SWGSDRangel::SWGPresetIdentifier &response, SWGSDRangel::SWGErrorResponse &error)
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instancePresetsService()

void WebAPIRequestMapper::instancePresetsService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 757 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGPresets::asJson(), qtwebapp::HttpRequest::getMethod(), WebAPIAdapterInterface::instancePresetsGet(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

758 {
759  SWGSDRangel::SWGErrorResponse errorResponse;
760  response.setHeader("Content-Type", "application/json");
761  response.setHeader("Access-Control-Allow-Origin", "*");
762 
763  if (request.getMethod() == "GET")
764  {
765  SWGSDRangel::SWGPresets normalResponse;
766  int status = m_adapter->instancePresetsGet(normalResponse, errorResponse);
767  response.setStatus(status);
768 
769  if (status/100 == 2) {
770  response.write(normalResponse.asJson().toUtf8());
771  } else {
772  response.write(errorResponse.asJson().toUtf8());
773  }
774  }
775 }
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
virtual QString asJson() override
Definition: SWGPresets.cpp:79
virtual int instancePresetsGet(SWGSDRangel::SWGPresets &response, SWGSDRangel::SWGErrorResponse &error)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instanceSummaryService()

void WebAPIRequestMapper::instanceSummaryService ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
private

Definition at line 177 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGSuccessResponse::asJson(), SWGSDRangel::SWGInstanceSummaryResponse::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), SWGSDRangel::SWGErrorResponse::init(), WebAPIAdapterInterface::instanceDelete(), WebAPIAdapterInterface::instanceSummary(), m_adapter, qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by service().

178 {
179  SWGSDRangel::SWGErrorResponse errorResponse;
180  response.setHeader("Content-Type", "application/json");
181  response.setHeader("Access-Control-Allow-Origin", "*");
182 
183  if (request.getMethod() == "GET")
184  {
186 
187  int status = m_adapter->instanceSummary(normalResponse, errorResponse);
188  response.setStatus(status);
189 
190  if (status/100 == 2) {
191  response.write(normalResponse.asJson().toUtf8());
192  } else {
193  response.write(errorResponse.asJson().toUtf8());
194  }
195  }
196  else if (request.getMethod() == "DELETE")
197  {
198  SWGSDRangel::SWGSuccessResponse normalResponse;
199 
200  int status = m_adapter->instanceDelete(normalResponse, errorResponse);
201  response.setStatus(status);
202 
203  if (status/100 == 2) {
204  response.write(normalResponse.asJson().toUtf8());
205  } else {
206  response.write(errorResponse.asJson().toUtf8());
207  }
208  }
209  else
210  {
211  response.setStatus(405,"Invalid HTTP method");
212  errorResponse.init();
213  *errorResponse.getMessage() = "Invalid HTTP method";
214  response.write(errorResponse.asJson().toUtf8());
215  }
216 }
virtual int instanceSummary(SWGSDRangel::SWGInstanceSummaryResponse &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
void setHeader(QByteArray name, QByteArray value)
WebAPIAdapterInterface * m_adapter
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
virtual int instanceDelete(SWGSDRangel::SWGSuccessResponse &response, SWGSDRangel::SWGErrorResponse &error)
virtual QString asJson() override
QByteArray getMethod() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseJsonBody()

bool WebAPIRequestMapper::parseJsonBody ( QString &  jsonStr,
QJsonObject &  jsonObject,
qtwebapp::HttpResponse response 
)
private

Definition at line 1729 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), SWGSDRangel::SWGErrorResponse::getMessage(), SWGSDRangel::SWGErrorResponse::init(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

Referenced by devicesetChannelService(), devicesetChannelSettingsService(), devicesetDeviceService(), devicesetDeviceSettingsService(), instanceAMBEDevicesService(), instanceAudioInputParametersService(), instanceAudioOutputParametersService(), instanceLocationService(), instanceLoggingService(), instancePresetFileService(), and instancePresetService().

1730 {
1731  SWGSDRangel::SWGErrorResponse errorResponse;
1732 
1733  try
1734  {
1735  QByteArray jsonBytes(jsonStr.toStdString().c_str());
1736  QJsonParseError error;
1737  QJsonDocument doc = QJsonDocument::fromJson(jsonBytes, &error);
1738 
1739  if (error.error == QJsonParseError::NoError)
1740  {
1741  jsonObject = doc.object();
1742  }
1743  else
1744  {
1745  QString errorMsg = QString("Input JSON error: ") + error.errorString() + QString(" at offset ") + QString::number(error.offset);
1746  errorResponse.init();
1747  *errorResponse.getMessage() = errorMsg;
1748  response.setStatus(400, errorMsg.toUtf8());
1749  response.write(errorResponse.asJson().toUtf8());
1750  }
1751 
1752  return (error.error == QJsonParseError::NoError);
1753  }
1754  catch (const std::exception& ex)
1755  {
1756  QString errorMsg = QString("Error parsing request: ") + ex.what();
1757  errorResponse.init();
1758  *errorResponse.getMessage() = errorMsg;
1759  response.setStatus(500, errorMsg.toUtf8());
1760  response.write(errorResponse.asJson().toUtf8());
1761 
1762  return false;
1763  }
1764 }
virtual QString asJson() override
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetAudioInputDevice()

void WebAPIRequestMapper::resetAudioInputDevice ( SWGSDRangel::SWGAudioInputDevice audioInputDevice)
private

Definition at line 2893 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGAudioInputDevice::cleanup(), and SWGSDRangel::SWGAudioInputDevice::setName().

Referenced by instanceAudioInputParametersService().

2894 {
2895  audioInputDevice.cleanup();
2896  audioInputDevice.setName(0);
2897 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetAudioOutputDevice()

void WebAPIRequestMapper::resetAudioOutputDevice ( SWGSDRangel::SWGAudioOutputDevice audioOutputDevice)
private

Definition at line 2899 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGAudioOutputDevice::cleanup(), SWGSDRangel::SWGAudioOutputDevice::setName(), and SWGSDRangel::SWGAudioOutputDevice::setUdpAddress().

Referenced by instanceAudioOutputParametersService().

2900 {
2901  audioOutputDevice.cleanup();
2902  audioOutputDevice.setName(0);
2903  audioOutputDevice.setUdpAddress(0);
2904 }
void setUdpAddress(QString *udp_address)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetChannelReport()

void WebAPIRequestMapper::resetChannelReport ( SWGSDRangel::SWGChannelReport deviceSettings)
private

Definition at line 2873 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGChannelReport::cleanup(), SWGSDRangel::SWGChannelReport::setAmDemodReport(), SWGSDRangel::SWGChannelReport::setAmModReport(), SWGSDRangel::SWGChannelReport::setAtvModReport(), SWGSDRangel::SWGChannelReport::setBfmDemodReport(), SWGSDRangel::SWGChannelReport::setChannelType(), SWGSDRangel::SWGChannelReport::setDsdDemodReport(), SWGSDRangel::SWGChannelReport::setNfmDemodReport(), SWGSDRangel::SWGChannelReport::setNfmModReport(), SWGSDRangel::SWGChannelReport::setRemoteSourceReport(), SWGSDRangel::SWGChannelReport::setSsbDemodReport(), SWGSDRangel::SWGChannelReport::setSsbModReport(), SWGSDRangel::SWGChannelReport::setUdpSinkReport(), SWGSDRangel::SWGChannelReport::setUdpSourceReport(), SWGSDRangel::SWGChannelReport::setWfmDemodReport(), and SWGSDRangel::SWGChannelReport::setWfmModReport().

Referenced by devicesetChannelReportService().

2874 {
2875  channelReport.cleanup();
2876  channelReport.setChannelType(0);
2877  channelReport.setAmDemodReport(0);
2878  channelReport.setAmModReport(0);
2879  channelReport.setAtvModReport(0);
2880  channelReport.setBfmDemodReport(0);
2881  channelReport.setDsdDemodReport(0);
2882  channelReport.setNfmDemodReport(0);
2883  channelReport.setNfmModReport(0);
2884  channelReport.setRemoteSourceReport(0);
2885  channelReport.setSsbDemodReport(0);
2886  channelReport.setSsbModReport(0);
2887  channelReport.setUdpSourceReport(0);
2888  channelReport.setUdpSinkReport(0);
2889  channelReport.setWfmDemodReport(0);
2890  channelReport.setWfmModReport(0);
2891 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetChannelSettings()

void WebAPIRequestMapper::resetChannelSettings ( SWGSDRangel::SWGChannelSettings deviceSettings)
private

Definition at line 2852 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGChannelSettings::cleanup(), SWGSDRangel::SWGChannelSettings::setAmDemodSettings(), SWGSDRangel::SWGChannelSettings::setAmModSettings(), SWGSDRangel::SWGChannelSettings::setAtvModSettings(), SWGSDRangel::SWGChannelSettings::setBfmDemodSettings(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDsdDemodSettings(), SWGSDRangel::SWGChannelSettings::setNfmDemodSettings(), SWGSDRangel::SWGChannelSettings::setNfmModSettings(), SWGSDRangel::SWGChannelSettings::setRemoteSinkSettings(), SWGSDRangel::SWGChannelSettings::setRemoteSourceSettings(), SWGSDRangel::SWGChannelSettings::setSsbDemodSettings(), SWGSDRangel::SWGChannelSettings::setSsbModSettings(), SWGSDRangel::SWGChannelSettings::setUdpSinkSettings(), SWGSDRangel::SWGChannelSettings::setUdpSourceSettings(), SWGSDRangel::SWGChannelSettings::setWfmDemodSettings(), and SWGSDRangel::SWGChannelSettings::setWfmModSettings().

Referenced by devicesetChannelService(), and devicesetChannelSettingsService().

2853 {
2854  channelSettings.cleanup();
2855  channelSettings.setChannelType(0);
2856  channelSettings.setAmDemodSettings(0);
2857  channelSettings.setAmModSettings(0);
2858  channelSettings.setAtvModSettings(0);
2859  channelSettings.setBfmDemodSettings(0);
2860  channelSettings.setDsdDemodSettings(0);
2861  channelSettings.setNfmDemodSettings(0);
2862  channelSettings.setNfmModSettings(0);
2863  channelSettings.setRemoteSinkSettings(0);
2864  channelSettings.setRemoteSourceSettings(0);
2865  channelSettings.setSsbDemodSettings(0);
2866  channelSettings.setSsbModSettings(0);
2867  channelSettings.setUdpSourceSettings(0);
2868  channelSettings.setUdpSinkSettings(0);
2869  channelSettings.setWfmDemodSettings(0);
2870  channelSettings.setWfmModSettings(0);
2871 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetDeviceReport()

void WebAPIRequestMapper::resetDeviceReport ( SWGSDRangel::SWGDeviceReport deviceReport)
private

Definition at line 2834 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGDeviceReport::cleanup(), SWGSDRangel::SWGDeviceReport::setAirspyHfReport(), SWGSDRangel::SWGDeviceReport::setAirspyReport(), SWGSDRangel::SWGDeviceReport::setDeviceHwType(), SWGSDRangel::SWGDeviceReport::setFileInputReport(), SWGSDRangel::SWGDeviceReport::setLimeSdrInputReport(), SWGSDRangel::SWGDeviceReport::setLimeSdrOutputReport(), SWGSDRangel::SWGDeviceReport::setPerseusReport(), SWGSDRangel::SWGDeviceReport::setPlutoSdrInputReport(), SWGSDRangel::SWGDeviceReport::setPlutoSdrOutputReport(), SWGSDRangel::SWGDeviceReport::setRemoteInputReport(), SWGSDRangel::SWGDeviceReport::setRemoteOutputReport(), SWGSDRangel::SWGDeviceReport::setRtlSdrReport(), and SWGSDRangel::SWGDeviceReport::setSdrPlayReport().

Referenced by devicesetDeviceReportService().

2835 {
2836  deviceReport.cleanup();
2837  deviceReport.setDeviceHwType(0);
2838  deviceReport.setAirspyHfReport(0);
2839  deviceReport.setAirspyReport(0);
2840  deviceReport.setFileInputReport(0);
2841  deviceReport.setLimeSdrInputReport(0);
2842  deviceReport.setLimeSdrOutputReport(0);
2843  deviceReport.setPerseusReport(0);
2844  deviceReport.setPlutoSdrInputReport(0);
2845  deviceReport.setPlutoSdrOutputReport(0);
2846  deviceReport.setRtlSdrReport(0);
2847  deviceReport.setRemoteOutputReport(0);
2848  deviceReport.setRemoteInputReport(0);
2849  deviceReport.setSdrPlayReport(0);
2850 }
void setSdrPlayReport(SWGSDRPlayReport *sdr_play_report)
void setLimeSdrOutputReport(SWGLimeSdrOutputReport *lime_sdr_output_report)
void setDeviceHwType(QString *device_hw_type)
void setPerseusReport(SWGPerseusReport *perseus_report)
void setRemoteInputReport(SWGRemoteInputReport *remote_input_report)
void setAirspyReport(SWGAirspyReport *airspy_report)
void setPlutoSdrOutputReport(SWGPlutoSdrOutputReport *pluto_sdr_output_report)
void setRtlSdrReport(SWGRtlSdrReport *rtl_sdr_report)
void setRemoteOutputReport(SWGRemoteOutputReport *remote_output_report)
void setFileInputReport(SWGFileInputReport *file_input_report)
void setAirspyHfReport(SWGAirspyHFReport *airspy_hf_report)
void setPlutoSdrInputReport(SWGPlutoSdrInputReport *pluto_sdr_input_report)
void setLimeSdrInputReport(SWGLimeSdrInputReport *lime_sdr_input_report)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetDeviceSettings()

void WebAPIRequestMapper::resetDeviceSettings ( SWGSDRangel::SWGDeviceSettings deviceSettings)
private

Definition at line 2809 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGDeviceSettings::cleanup(), SWGSDRangel::SWGDeviceSettings::setAirspyHfSettings(), SWGSDRangel::SWGDeviceSettings::setAirspySettings(), SWGSDRangel::SWGDeviceSettings::setBladeRf1InputSettings(), SWGSDRangel::SWGDeviceSettings::setBladeRf1OutputSettings(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setFcdProPlusSettings(), SWGSDRangel::SWGDeviceSettings::setFcdProSettings(), SWGSDRangel::SWGDeviceSettings::setFileInputSettings(), SWGSDRangel::SWGDeviceSettings::setHackRfInputSettings(), SWGSDRangel::SWGDeviceSettings::setHackRfOutputSettings(), SWGSDRangel::SWGDeviceSettings::setLimeSdrInputSettings(), SWGSDRangel::SWGDeviceSettings::setLimeSdrOutputSettings(), SWGSDRangel::SWGDeviceSettings::setPerseusSettings(), SWGSDRangel::SWGDeviceSettings::setPlutoSdrInputSettings(), SWGSDRangel::SWGDeviceSettings::setPlutoSdrOutputSettings(), SWGSDRangel::SWGDeviceSettings::setRemoteInputSettings(), SWGSDRangel::SWGDeviceSettings::setRemoteOutputSettings(), SWGSDRangel::SWGDeviceSettings::setRtlSdrSettings(), SWGSDRangel::SWGDeviceSettings::setSdrPlaySettings(), and SWGSDRangel::SWGDeviceSettings::setTestSourceSettings().

Referenced by devicesetDeviceSettingsService().

2810 {
2811  deviceSettings.cleanup();
2812  deviceSettings.setDeviceHwType(0);
2813  deviceSettings.setAirspySettings(0);
2814  deviceSettings.setAirspyHfSettings(0);
2815  deviceSettings.setBladeRf1InputSettings(0);
2816  deviceSettings.setBladeRf1OutputSettings(0);
2817  deviceSettings.setFcdProPlusSettings(0);
2818  deviceSettings.setFcdProSettings(0);
2819  deviceSettings.setFileInputSettings(0);
2820  deviceSettings.setHackRfInputSettings(0);
2821  deviceSettings.setHackRfOutputSettings(0);
2822  deviceSettings.setLimeSdrInputSettings(0);
2823  deviceSettings.setLimeSdrOutputSettings(0);
2824  deviceSettings.setPerseusSettings(0);
2825  deviceSettings.setPlutoSdrInputSettings(0);
2826  deviceSettings.setPlutoSdrOutputSettings(0);
2827  deviceSettings.setRtlSdrSettings(0);
2828  deviceSettings.setRemoteOutputSettings(0);
2829  deviceSettings.setRemoteInputSettings(0);
2830  deviceSettings.setSdrPlaySettings(0);
2831  deviceSettings.setTestSourceSettings(0);
2832 }
void setBladeRf1OutputSettings(SWGBladeRF1OutputSettings *blade_rf1_output_settings)
void setBladeRf1InputSettings(SWGBladeRF1InputSettings *blade_rf1_input_settings)
void setPlutoSdrOutputSettings(SWGPlutoSdrOutputSettings *pluto_sdr_output_settings)
void setLimeSdrInputSettings(SWGLimeSdrInputSettings *lime_sdr_input_settings)
void setSdrPlaySettings(SWGSDRPlaySettings *sdr_play_settings)
void setPerseusSettings(SWGPerseusSettings *perseus_settings)
void setAirspySettings(SWGAirspySettings *airspy_settings)
void setHackRfOutputSettings(SWGHackRFOutputSettings *hack_rf_output_settings)
void setFileInputSettings(SWGFileInputSettings *file_input_settings)
void setTestSourceSettings(SWGTestSourceSettings *test_source_settings)
void setLimeSdrOutputSettings(SWGLimeSdrOutputSettings *lime_sdr_output_settings)
void setFcdProSettings(SWGFCDProSettings *fcd_pro_settings)
void setRtlSdrSettings(SWGRtlSdrSettings *rtl_sdr_settings)
void setFcdProPlusSettings(SWGFCDProPlusSettings *fcd_pro_plus_settings)
void setRemoteOutputSettings(SWGRemoteOutputSettings *remote_output_settings)
void setRemoteInputSettings(SWGRemoteInputSettings *remote_input_settings)
void setHackRfInputSettings(SWGHackRFInputSettings *hack_rf_input_settings)
void setAirspyHfSettings(SWGAirspyHFSettings *airspy_hf_settings)
void setPlutoSdrInputSettings(SWGPlutoSdrInputSettings *pluto_sdr_input_settings)
void setDeviceHwType(QString *device_hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ service()

void WebAPIRequestMapper::service ( qtwebapp::HttpRequest request,
qtwebapp::HttpResponse response 
)
virtual

Generate a response for an incoming HTTP request.

Parameters
requestThe received HTTP request
responseMust be used to return the response
Warning
This method must be thread safe

Reimplemented from qtwebapp::HttpRequestHandler.

Definition at line 70 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGErrorResponse::asJson(), devicesetChannelIndexService(), WebAPIAdapterInterface::devicesetChannelIndexURLRe, devicesetChannelReportService(), WebAPIAdapterInterface::devicesetChannelReportURLRe, devicesetChannelService(), devicesetChannelSettingsService(), WebAPIAdapterInterface::devicesetChannelSettingsURLRe, devicesetChannelsReportService(), WebAPIAdapterInterface::devicesetChannelsReportURLRe, WebAPIAdapterInterface::devicesetChannelURLRe, devicesetDeviceReportService(), WebAPIAdapterInterface::devicesetDeviceReportURLRe, devicesetDeviceRunService(), WebAPIAdapterInterface::devicesetDeviceRunURLRe, devicesetDeviceService(), devicesetDeviceSettingsService(), WebAPIAdapterInterface::devicesetDeviceSettingsURLRe, WebAPIAdapterInterface::devicesetDeviceURLRe, devicesetFocusService(), WebAPIAdapterInterface::devicesetFocusURLRe, devicesetService(), WebAPIAdapterInterface::devicesetURLRe, SWGSDRangel::SWGErrorResponse::getMessage(), qtwebapp::HttpRequest::getMethod(), qtwebapp::HttpRequest::getPath(), SWGSDRangel::SWGErrorResponse::init(), instanceAMBEDevicesService(), WebAPIAdapterInterface::instanceAMBEDevicesURL, instanceAMBESerialService(), WebAPIAdapterInterface::instanceAMBESerialURL, instanceAudioInputCleanupService(), WebAPIAdapterInterface::instanceAudioInputCleanupURL, instanceAudioInputParametersService(), WebAPIAdapterInterface::instanceAudioInputParametersURL, instanceAudioOutputCleanupService(), WebAPIAdapterInterface::instanceAudioOutputCleanupURL, instanceAudioOutputParametersService(), WebAPIAdapterInterface::instanceAudioOutputParametersURL, instanceAudioService(), WebAPIAdapterInterface::instanceAudioURL, instanceChannelsService(), WebAPIAdapterInterface::instanceChannelsURL, instanceConfigService(), WebAPIAdapterInterface::instanceConfigURL, instanceDeviceSetService(), instanceDeviceSetsService(), WebAPIAdapterInterface::instanceDeviceSetsURL, WebAPIAdapterInterface::instanceDeviceSetURL, instanceDevicesService(), WebAPIAdapterInterface::instanceDevicesURL, instanceLocationService(), WebAPIAdapterInterface::instanceLocationURL, instanceLoggingService(), WebAPIAdapterInterface::instanceLoggingURL, instancePresetFileService(), WebAPIAdapterInterface::instancePresetFileURL, instancePresetService(), instancePresetsService(), WebAPIAdapterInterface::instancePresetsURL, WebAPIAdapterInterface::instancePresetURL, instanceSummaryService(), WebAPIAdapterInterface::instanceSummaryURL, m_adapter, m_staticFileController, qtwebapp::StaticFileController::service(), qtwebapp::HttpResponse::setHeader(), qtwebapp::HttpResponse::setStatus(), and qtwebapp::HttpResponse::write().

71 {
72  if (m_adapter == 0) // format service unavailable if adapter is null
73  {
74  SWGSDRangel::SWGErrorResponse errorResponse;
75  response.setHeader("Content-Type", "application/json");
76  response.setHeader("Access-Control-Allow-Origin", "*");
77  response.setStatus(500,"Service not available");
78 
79  errorResponse.init();
80  *errorResponse.getMessage() = "Service not available";
81  response.write(errorResponse.asJson().toUtf8());
82  }
83  else // normal processing
84  {
85  QByteArray path=request.getPath();
86 
87  // Handle pre-flight requests
88  if (request.getMethod() == "OPTIONS")
89  {
90  qDebug("WebAPIRequestMapper::service: method OPTIONS: assume pre-flight");
91  response.setHeader("Access-Control-Allow-Origin", "*");
92  response.setHeader("Access-Control-Allow-Headers", "*");
93  response.setHeader("Access-Control-Allow-Methods", "*");
94  response.setStatus(200, "OK");
95  return;
96  }
97 
99  instanceSummaryService(request, response);
100  } else if (path == WebAPIAdapterInterface::instanceConfigURL) {
101  instanceConfigService(request, response);
102  } else if (path == WebAPIAdapterInterface::instanceDevicesURL) {
103  instanceDevicesService(request, response);
104  } else if (path == WebAPIAdapterInterface::instanceChannelsURL) {
105  instanceChannelsService(request, response);
106  } else if (path == WebAPIAdapterInterface::instanceLoggingURL) {
107  instanceLoggingService(request, response);
108  } else if (path == WebAPIAdapterInterface::instanceAudioURL) {
109  instanceAudioService(request, response);
111  instanceAudioInputParametersService(request, response);
113  instanceAudioOutputParametersService(request, response);
115  instanceAudioInputCleanupService(request, response);
117  instanceAudioOutputCleanupService(request, response);
118  } else if (path == WebAPIAdapterInterface::instanceLocationURL) {
119  instanceLocationService(request, response);
121  instanceAMBESerialService(request, response);
123  instanceAMBEDevicesService(request, response);
124  } else if (path == WebAPIAdapterInterface::instancePresetsURL) {
125  instancePresetsService(request, response);
126  } else if (path == WebAPIAdapterInterface::instancePresetURL) {
127  instancePresetService(request, response);
129  instancePresetFileService(request, response);
131  instanceDeviceSetsService(request, response);
133  instanceDeviceSetService(request, response);
134  }
135  else
136  {
137  std::smatch desc_match;
138  std::string pathStr(path.constData(), path.length());
139 
140  if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetURLRe)) {
141  devicesetService(std::string(desc_match[1]), request, response);
142  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceURLRe)) {
143  devicesetDeviceService(std::string(desc_match[1]), request, response);
144  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetFocusURLRe)) {
145  devicesetFocusService(std::string(desc_match[1]), request, response);
146  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceSettingsURLRe)) {
147  devicesetDeviceSettingsService(std::string(desc_match[1]), request, response);
148  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceRunURLRe)) {
149  devicesetDeviceRunService(std::string(desc_match[1]), request, response);
150  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceReportURLRe)) {
151  devicesetDeviceReportService(std::string(desc_match[1]), request, response);
152  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelsReportURLRe)) {
153  devicesetChannelsReportService(std::string(desc_match[1]), request, response);
154  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelURLRe)) {
155  devicesetChannelService(std::string(desc_match[1]), request, response);
156  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelIndexURLRe)) {
157  devicesetChannelIndexService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
158  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelSettingsURLRe)) {
159  devicesetChannelSettingsService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
160  } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelReportURLRe)) {
161  devicesetChannelReportService(std::string(desc_match[1]), std::string(desc_match[2]), request, response);
162  }
163  else // serve static documentation pages
164  {
165  m_staticFileController->service(request, response);
166  }
167 
168 // QDirIterator it(":", QDirIterator::Subdirectories);
169 // while (it.hasNext()) {
170 // qDebug() << "WebAPIRequestMapper::service: " << it.next();
171 // }
172 
173  }
174  }
175 }
qtwebapp::StaticFileController * m_staticFileController
void instanceAMBEDevicesService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void devicesetDeviceService(const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static std::regex devicesetDeviceSettingsURLRe
void instanceChannelsService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instanceAMBESerialService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void devicesetChannelSettingsService(const std::string &deviceSetIndexStr, const std::string &channelIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static std::regex devicesetDeviceReportURLRe
void instanceConfigService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void devicesetChannelService(const std::string &deviceSetIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void devicesetDeviceSettingsService(const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static QString instanceAudioOutputParametersURL
void devicesetDeviceReportService(const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
QByteArray getPath() const
virtual QString asJson() override
static QString instanceAudioOutputCleanupURL
void instanceAudioService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instanceAudioOutputCleanupService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void setHeader(QByteArray name, QByteArray value)
void devicesetChannelsReportService(const std::string &deviceSetIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void devicesetService(const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void devicesetChannelIndexService(const std::string &deviceSetIndexStr, const std::string &channelIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instanceDevicesService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instanceDeviceSetService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static std::regex devicesetURLRe
void instancePresetService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instanceLoggingService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static QString instanceAudioInputParametersURL
void instanceAudioInputCleanupService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instanceSummaryService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
WebAPIAdapterInterface * m_adapter
void devicesetDeviceRunService(const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static QString instanceAudioInputCleanupURL
void devicesetFocusService(const std::string &indexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static std::regex devicesetChannelsReportURLRe
static std::regex devicesetChannelReportURLRe
static std::regex devicesetFocusURLRe
void write(QByteArray data, bool lastPart=false)
void setStatus(int statusCode, QByteArray description=QByteArray())
static std::regex devicesetChannelSettingsURLRe
void devicesetChannelReportService(const std::string &deviceSetIndexStr, const std::string &channelIndexStr, qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instanceLocationService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static std::regex devicesetDeviceURLRe
static std::regex devicesetChannelURLRe
void instanceDeviceSetsService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
static std::regex devicesetDeviceRunURLRe
void instanceAudioOutputParametersService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instancePresetsService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void service(HttpRequest &request, HttpResponse &response)
void instanceAudioInputParametersService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
void instancePresetFileService(qtwebapp::HttpRequest &request, qtwebapp::HttpResponse &response)
QByteArray getMethod() const
static std::regex devicesetChannelIndexURLRe
+ Here is the call graph for this function:

◆ setAdapter()

void WebAPIRequestMapper::setAdapter ( WebAPIAdapterInterface adapter)
inline

Definition at line 45 of file webapirequestmapper.h.

Referenced by MainCore::MainCore(), and MainWindow::MainWindow().

45 { m_adapter = adapter; }
WebAPIAdapterInterface * m_adapter
+ Here is the caller graph for this function:

◆ validateAMBEDevices()

bool WebAPIRequestMapper::validateAMBEDevices ( SWGSDRangel::SWGAMBEDevices ambeDevices,
QJsonObject &  jsonObject 
)
private

Definition at line 2730 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGAMBEDevices::getAmbeDevices(), i, SWGSDRangel::SWGAMBEDevices::init(), and SWGSDRangel::SWGAMBEDevices::setNbDevices().

Referenced by instanceAMBEDevicesService().

2731 {
2732  if (jsonObject.contains("nbDevices"))
2733  {
2734  int nbDevices = jsonObject["nbDevices"].toInt();
2735 
2736  if (jsonObject.contains("ambeDevices"))
2737  {
2738  QJsonArray ambeDevicesJson = jsonObject["ambeDevices"].toArray();
2739 
2740  if (nbDevices != ambeDevicesJson.size()) {
2741  return false;
2742  }
2743 
2744  ambeDevices.init();
2745  ambeDevices.setNbDevices(nbDevices);
2746  QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = ambeDevices.getAmbeDevices();
2747 
2748  for (int i = 0; i < nbDevices; i++)
2749  {
2750  QJsonObject ambeDeviceJson = ambeDevicesJson.at(i).toObject();
2751  if (ambeDeviceJson.contains("deviceRef") && ambeDeviceJson.contains("delete"))
2752  {
2753  ambeList->push_back(new SWGSDRangel::SWGAMBEDevice());
2754  ambeList->back()->init();
2755  ambeList->back()->setDeviceRef(new QString(ambeDeviceJson["deviceRef"].toString()));
2756  ambeList->back()->setDelete(ambeDeviceJson["delete"].toInt());
2757  }
2758  else
2759  {
2760  return false;
2761  }
2762  }
2763 
2764  return true;
2765  }
2766  }
2767 
2768  return false;
2769 }
void setNbDevices(qint32 nb_devices)
int32_t i
Definition: decimators.h:244
QList< SWGAMBEDevice * > * getAmbeDevices()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateAudioInputDevice()

bool WebAPIRequestMapper::validateAudioInputDevice ( SWGSDRangel::SWGAudioInputDevice audioInputDevice,
QJsonObject &  jsonObject,
QStringList &  audioInputDeviceKeys 
)
private

Definition at line 2654 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGAudioInputDevice::setIndex(), SWGSDRangel::SWGAudioInputDevice::setSampleRate(), and SWGSDRangel::SWGAudioInputDevice::setVolume().

Referenced by instanceAudioInputParametersService().

2658 {
2659  if (jsonObject.contains("index")) {
2660  audioInputDevice.setIndex(jsonObject["index"].toInt());
2661  } else {
2662  audioInputDevice.setIndex(-1); // assume systam default
2663  }
2664  if (jsonObject.contains("sampleRate"))
2665  {
2666  audioInputDevice.setSampleRate(jsonObject["sampleRate"].toInt());
2667  audioInputDeviceKeys.append("sampleRate");
2668  }
2669  if (jsonObject.contains("volume"))
2670  {
2671  audioInputDevice.setVolume(jsonObject["volume"].toDouble());
2672  audioInputDeviceKeys.append("volume");
2673  }
2674  return true;
2675 }
void setSampleRate(qint32 sample_rate)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateAudioOutputDevice()

bool WebAPIRequestMapper::validateAudioOutputDevice ( SWGSDRangel::SWGAudioOutputDevice audioOutputDevice,
QJsonObject &  jsonObject,
QStringList &  audioOutputDeviceKeys 
)
private

Definition at line 2677 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGAudioOutputDevice::setCopyToUdp(), SWGSDRangel::SWGAudioOutputDevice::setIndex(), SWGSDRangel::SWGAudioOutputDevice::setSampleRate(), SWGSDRangel::SWGAudioOutputDevice::setUdpAddress(), SWGSDRangel::SWGAudioOutputDevice::setUdpChannelCodec(), SWGSDRangel::SWGAudioOutputDevice::setUdpChannelMode(), SWGSDRangel::SWGAudioOutputDevice::setUdpDecimationFactor(), SWGSDRangel::SWGAudioOutputDevice::setUdpPort(), and SWGSDRangel::SWGAudioOutputDevice::setUdpUsesRtp().

Referenced by instanceAudioOutputParametersService().

2681 {
2682  if (jsonObject.contains("index")) {
2683  audioOutputDevice.setIndex(jsonObject["index"].toInt());
2684  } else {
2685  audioOutputDevice.setIndex(-1); // assume systam default
2686  }
2687  if (jsonObject.contains("sampleRate"))
2688  {
2689  audioOutputDevice.setSampleRate(jsonObject["sampleRate"].toInt());
2690  audioOutputDeviceKeys.append("sampleRate");
2691  }
2692  if (jsonObject.contains("copyToUDP"))
2693  {
2694  audioOutputDevice.setCopyToUdp(jsonObject["copyToUDP"].toInt() == 0 ? 0 : 1);
2695  audioOutputDeviceKeys.append("copyToUDP");
2696  }
2697  if (jsonObject.contains("udpUsesRTP"))
2698  {
2699  audioOutputDevice.setUdpUsesRtp(jsonObject["udpUsesRTP"].toInt() == 0 ? 0 : 1);
2700  audioOutputDeviceKeys.append("udpUsesRTP");
2701  }
2702  if (jsonObject.contains("udpChannelMode"))
2703  {
2704  audioOutputDevice.setUdpChannelMode(jsonObject["udpChannelMode"].toInt());
2705  audioOutputDeviceKeys.append("udpChannelMode");
2706  }
2707  if (jsonObject.contains("udpChannelCodec"))
2708  {
2709  audioOutputDevice.setUdpChannelCodec(jsonObject["udpChannelCodec"].toInt());
2710  audioOutputDeviceKeys.append("udpChannelCodec");
2711  }
2712  if (jsonObject.contains("udpDecimationFactor"))
2713  {
2714  audioOutputDevice.setUdpDecimationFactor(jsonObject["udpDecimationFactor"].toInt());
2715  audioOutputDeviceKeys.append("udpDecimationFactor");
2716  }
2717  if (jsonObject.contains("udpAddress"))
2718  {
2719  audioOutputDevice.setUdpAddress(new QString(jsonObject["udpAddress"].toString()));
2720  audioOutputDeviceKeys.append("udpAddress");
2721  }
2722  if (jsonObject.contains("udpPort"))
2723  {
2724  audioOutputDevice.setUdpPort(jsonObject["udpPort"].toInt());
2725  audioOutputDeviceKeys.append("udpPort");
2726  }
2727  return true;
2728 }
void setUdpAddress(QString *udp_address)
void setUdpDecimationFactor(qint32 udp_decimation_factor)
void setUdpChannelCodec(qint32 udp_channel_codec)
void setUdpUsesRtp(qint32 udp_uses_rtp)
void setUdpChannelMode(qint32 udp_channel_mode)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateChannelSettings()

bool WebAPIRequestMapper::validateChannelSettings ( SWGSDRangel::SWGChannelSettings deviceSettings,
QJsonObject &  jsonObject,
QStringList &  channelSettingsKeys 
)
private

Definition at line 2321 of file webapirequestmapper.cpp.

References appendSettingsSubKeys(), SWGSDRangel::SWGAMDemodSettings::fromJsonObject(), SWGSDRangel::SWGBFMDemodSettings::fromJsonObject(), SWGSDRangel::SWGNFMDemodSettings::fromJsonObject(), SWGSDRangel::SWGLocalSinkSettings::fromJsonObject(), SWGSDRangel::SWGDSDDemodSettings::fromJsonObject(), SWGSDRangel::SWGLocalSourceSettings::fromJsonObject(), SWGSDRangel::SWGFreeDVDemodSettings::fromJsonObject(), SWGSDRangel::SWGRemoteSinkSettings::fromJsonObject(), SWGSDRangel::SWGRemoteSourceSettings::fromJsonObject(), SWGSDRangel::SWGATVModSettings::fromJsonObject(), SWGSDRangel::SWGSSBDemodSettings::fromJsonObject(), SWGSDRangel::SWGFreqTrackerSettings::fromJsonObject(), SWGSDRangel::SWGUDPSourceSettings::fromJsonObject(), SWGSDRangel::SWGUDPSinkSettings::fromJsonObject(), SWGSDRangel::SWGWFMDemodSettings::fromJsonObject(), SWGSDRangel::SWGWFMModSettings::fromJsonObject(), SWGSDRangel::SWGNFMModSettings::fromJsonObject(), SWGSDRangel::SWGAMModSettings::fromJsonObject(), SWGSDRangel::SWGFreeDVModSettings::fromJsonObject(), SWGSDRangel::SWGSSBModSettings::fromJsonObject(), SWGSDRangel::SWGChannelSettings::getAmDemodSettings(), SWGSDRangel::SWGChannelSettings::getAmModSettings(), SWGSDRangel::SWGChannelSettings::getAtvModSettings(), SWGSDRangel::SWGChannelSettings::getBfmDemodSettings(), SWGSDRangel::SWGChannelSettings::getChannelType(), SWGSDRangel::SWGChannelSettings::getDirection(), SWGSDRangel::SWGChannelSettings::getDsdDemodSettings(), SWGSDRangel::SWGChannelSettings::getFreeDvDemodSettings(), SWGSDRangel::SWGChannelSettings::getFreeDvModSettings(), SWGSDRangel::SWGChannelSettings::getFreqTrackerSettings(), SWGSDRangel::SWGChannelSettings::getLocalSinkSettings(), SWGSDRangel::SWGChannelSettings::getLocalSourceSettings(), SWGSDRangel::SWGChannelSettings::getNfmDemodSettings(), SWGSDRangel::SWGChannelSettings::getNfmModSettings(), SWGSDRangel::SWGChannelSettings::getRemoteSinkSettings(), SWGSDRangel::SWGChannelSettings::getRemoteSourceSettings(), SWGSDRangel::SWGChannelSettings::getSsbDemodSettings(), SWGSDRangel::SWGChannelSettings::getSsbModSettings(), SWGSDRangel::SWGChannelSettings::getUdpSinkSettings(), SWGSDRangel::SWGChannelSettings::getUdpSourceSettings(), SWGSDRangel::SWGChannelSettings::getWfmDemodSettings(), SWGSDRangel::SWGChannelSettings::getWfmModSettings(), SWGSDRangel::SWGChannelSettings::setAmDemodSettings(), SWGSDRangel::SWGChannelSettings::setAmModSettings(), SWGSDRangel::SWGChannelSettings::setAtvModSettings(), SWGSDRangel::SWGChannelSettings::setBfmDemodSettings(), SWGSDRangel::SWGChannelSettings::setChannelType(), SWGSDRangel::SWGChannelSettings::setDirection(), SWGSDRangel::SWGChannelSettings::setDsdDemodSettings(), SWGSDRangel::SWGChannelSettings::setFreeDvDemodSettings(), SWGSDRangel::SWGChannelSettings::setFreeDvModSettings(), SWGSDRangel::SWGChannelSettings::setFreqTrackerSettings(), SWGSDRangel::SWGChannelSettings::setLocalSinkSettings(), SWGSDRangel::SWGChannelSettings::setLocalSourceSettings(), SWGSDRangel::SWGChannelSettings::setNfmDemodSettings(), SWGSDRangel::SWGChannelSettings::setNfmModSettings(), SWGSDRangel::SWGChannelSettings::setRemoteSinkSettings(), SWGSDRangel::SWGChannelSettings::setRemoteSourceSettings(), SWGSDRangel::SWGChannelSettings::setSsbDemodSettings(), SWGSDRangel::SWGChannelSettings::setSsbModSettings(), SWGSDRangel::SWGChannelSettings::setUdpSinkSettings(), SWGSDRangel::SWGChannelSettings::setUdpSourceSettings(), SWGSDRangel::SWGChannelSettings::setWfmDemodSettings(), and SWGSDRangel::SWGChannelSettings::setWfmModSettings().

Referenced by devicesetChannelSettingsService().

2325 {
2326  if (jsonObject.contains("direction")) {
2327  channelSettings.setDirection(jsonObject["direction"].toInt());
2328  } else {
2329  channelSettings.setDirection(0); // assume single Rx
2330  }
2331 
2332  if (jsonObject.contains("channelType") && jsonObject["channelType"].isString()) {
2333  channelSettings.setChannelType(new QString(jsonObject["channelType"].toString()));
2334  } else {
2335  return false;
2336  }
2337 
2338  QString *channelType = channelSettings.getChannelType();
2339 
2340  if (*channelType == "AMDemod")
2341  {
2342  if (channelSettings.getDirection() == 0)
2343  {
2344  QJsonObject amDemodSettingsJsonObject = jsonObject["AMDemodSettings"].toObject();
2345  channelSettingsKeys = amDemodSettingsJsonObject.keys();
2346  channelSettings.setAmDemodSettings(new SWGSDRangel::SWGAMDemodSettings());
2347  channelSettings.getAmDemodSettings()->fromJsonObject(amDemodSettingsJsonObject);
2348  return true;
2349  }
2350  else {
2351  return false;
2352  }
2353  }
2354  else if (*channelType == "AMMod")
2355  {
2356  if (channelSettings.getDirection() == 1)
2357  {
2358  QJsonObject amModSettingsJsonObject = jsonObject["AMModSettings"].toObject();
2359  channelSettingsKeys = amModSettingsJsonObject.keys();
2360 
2361  if (channelSettingsKeys.contains("cwKeyer"))
2362  {
2363  QJsonObject cwKeyerSettingsJsonObject;
2364  appendSettingsSubKeys(amModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys);
2365  }
2366 
2367  channelSettings.setAmModSettings(new SWGSDRangel::SWGAMModSettings());
2368  channelSettings.getAmModSettings()->fromJsonObject(amModSettingsJsonObject);
2369  return true;
2370  }
2371  else {
2372  return false;
2373  }
2374  }
2375  else if (*channelType == "ATVMod")
2376  {
2377  if (channelSettings.getDirection() == 1)
2378  {
2379  QJsonObject atvModSettingsJsonObject = jsonObject["ATVModSettings"].toObject();
2380  channelSettingsKeys = atvModSettingsJsonObject.keys();
2381  channelSettings.setAtvModSettings(new SWGSDRangel::SWGATVModSettings());
2382  channelSettings.getAtvModSettings()->fromJsonObject(atvModSettingsJsonObject);
2383  return true;
2384  }
2385  else {
2386  return false;
2387  }
2388  }
2389  else if (*channelType == "BFMDemod")
2390  {
2391  if (channelSettings.getDirection() == 0)
2392  {
2393  QJsonObject bfmDemodSettingsJsonObject = jsonObject["BFMDemodSettings"].toObject();
2394  channelSettingsKeys = bfmDemodSettingsJsonObject.keys();
2395  channelSettings.setBfmDemodSettings(new SWGSDRangel::SWGBFMDemodSettings());
2396  channelSettings.getBfmDemodSettings()->fromJsonObject(bfmDemodSettingsJsonObject);
2397  return true;
2398  }
2399  else {
2400  return false;
2401  }
2402  }
2403  else if (*channelType == "DSDDemod")
2404  {
2405  if (channelSettings.getDirection() == 0)
2406  {
2407  QJsonObject dsdDemodSettingsJsonObject = jsonObject["DSDDemodSettings"].toObject();
2408  channelSettingsKeys = dsdDemodSettingsJsonObject.keys();
2409  channelSettings.setDsdDemodSettings(new SWGSDRangel::SWGDSDDemodSettings());
2410  channelSettings.getDsdDemodSettings()->fromJsonObject(dsdDemodSettingsJsonObject);
2411  return true;
2412  }
2413  else {
2414  return false;
2415  }
2416  }
2417  else if (*channelType == "FreeDVDemod")
2418  {
2419  if (channelSettings.getDirection() == 0)
2420  {
2421  QJsonObject freeDVDemodSettingsJsonObject = jsonObject["FreeDVDemodSettings"].toObject();
2422  channelSettingsKeys = freeDVDemodSettingsJsonObject.keys();
2423  channelSettings.setFreeDvDemodSettings(new SWGSDRangel::SWGFreeDVDemodSettings());
2424  channelSettings.getFreeDvDemodSettings()->fromJsonObject(freeDVDemodSettingsJsonObject);
2425  return true;
2426  }
2427  else {
2428  return false;
2429  }
2430  }
2431  else if (*channelType == "FreeDVMod")
2432  {
2433  if (channelSettings.getDirection() == 1)
2434  {
2435  QJsonObject freeDVModSettingsJsonObject = jsonObject["FreeDVModSettings"].toObject();
2436  channelSettingsKeys = freeDVModSettingsJsonObject.keys();
2437  channelSettings.setFreeDvModSettings(new SWGSDRangel::SWGFreeDVModSettings());
2438  channelSettings.getFreeDvModSettings()->fromJsonObject(freeDVModSettingsJsonObject);
2439  return true;
2440  }
2441  else {
2442  return false;
2443  }
2444  }
2445  else if (*channelType == "FreqTracker")
2446  {
2447  if (channelSettings.getDirection() == 0)
2448  {
2449  QJsonObject freqTrackerSettingsJsonObject = jsonObject["FreqTrackerSettings"].toObject();
2450  channelSettingsKeys = freqTrackerSettingsJsonObject.keys();
2451  channelSettings.setFreqTrackerSettings(new SWGSDRangel::SWGFreqTrackerSettings());
2452  channelSettings.getFreqTrackerSettings()->fromJsonObject(freqTrackerSettingsJsonObject);
2453  return true;
2454  }
2455  else {
2456  return false;
2457  }
2458  }
2459  else if (*channelType == "NFMDemod")
2460  {
2461  if (channelSettings.getDirection() == 0)
2462  {
2463  QJsonObject nfmDemodSettingsJsonObject = jsonObject["NFMDemodSettings"].toObject();
2464  channelSettingsKeys = nfmDemodSettingsJsonObject.keys();
2465  channelSettings.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings());
2466  channelSettings.getNfmDemodSettings()->fromJsonObject(nfmDemodSettingsJsonObject);
2467  return true;
2468  }
2469  else {
2470  return false;
2471  }
2472  }
2473  else if (*channelType == "NFMMod")
2474  {
2475  if (channelSettings.getDirection() == 1)
2476  {
2477  QJsonObject nfmModSettingsJsonObject = jsonObject["NFMModSettings"].toObject();
2478  channelSettingsKeys = nfmModSettingsJsonObject.keys();
2479 
2480  if (channelSettingsKeys.contains("cwKeyer"))
2481  {
2482  QJsonObject cwKeyerSettingsJsonObject;
2483  appendSettingsSubKeys(nfmModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys);
2484  }
2485 
2486  channelSettings.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
2487  channelSettings.getNfmModSettings()->fromJsonObject(nfmModSettingsJsonObject);
2488  return true;
2489  }
2490  else {
2491  return false;
2492  }
2493  }
2494  else if (*channelType == "LocalSink")
2495  {
2496  if (channelSettings.getDirection() == 0)
2497  {
2498  QJsonObject localChannelSinkSettingsJsonObject = jsonObject["LocalSinkSettings"].toObject();
2499  channelSettingsKeys = localChannelSinkSettingsJsonObject.keys();
2500  channelSettings.setLocalSinkSettings(new SWGSDRangel::SWGLocalSinkSettings());
2501  channelSettings.getLocalSinkSettings()->fromJsonObject(localChannelSinkSettingsJsonObject);
2502  return true;
2503  }
2504  else {
2505  return false;
2506  }
2507  }
2508  else if (*channelType == "LocalSource")
2509  {
2510  if (channelSettings.getDirection() == 1)
2511  {
2512  QJsonObject localChannelSourceSettingsJsonObject = jsonObject["LocalSourceSettings"].toObject();
2513  channelSettingsKeys = localChannelSourceSettingsJsonObject.keys();
2514  channelSettings.setLocalSourceSettings(new SWGSDRangel::SWGLocalSourceSettings());
2515  channelSettings.getLocalSourceSettings()->fromJsonObject(localChannelSourceSettingsJsonObject);
2516  return true;
2517  }
2518  else {
2519  return false;
2520  }
2521  }
2522  else if (*channelType == "RemoteSink")
2523  {
2524  if (channelSettings.getDirection() == 0)
2525  {
2526  QJsonObject remoteChannelSinkSettingsJsonObject = jsonObject["RemoteSinkSettings"].toObject();
2527  channelSettingsKeys = remoteChannelSinkSettingsJsonObject.keys();
2528  channelSettings.setRemoteSinkSettings(new SWGSDRangel::SWGRemoteSinkSettings());
2529  channelSettings.getRemoteSinkSettings()->fromJsonObject(remoteChannelSinkSettingsJsonObject);
2530  return true;
2531  }
2532  else {
2533  return false;
2534  }
2535  }
2536  else if (*channelType == "RemoteSource")
2537  {
2538  if (channelSettings.getDirection() == 1)
2539  {
2540  QJsonObject remoteChannelSourceSettingsJsonObject = jsonObject["RemoteSourceSettings"].toObject();
2541  channelSettingsKeys = remoteChannelSourceSettingsJsonObject.keys();
2542  channelSettings.setRemoteSourceSettings(new SWGSDRangel::SWGRemoteSourceSettings());
2543  channelSettings.getRemoteSourceSettings()->fromJsonObject(remoteChannelSourceSettingsJsonObject);
2544  return true;
2545  }
2546  else {
2547  return false;
2548  }
2549  }
2550  else if (*channelType == "SSBDemod")
2551  {
2552  if (channelSettings.getDirection() == 0)
2553  {
2554  QJsonObject ssbDemodSettingsJsonObject = jsonObject["SSBDemodSettings"].toObject();
2555  channelSettingsKeys = ssbDemodSettingsJsonObject.keys();
2556  channelSettings.setSsbDemodSettings(new SWGSDRangel::SWGSSBDemodSettings());
2557  channelSettings.getSsbDemodSettings()->fromJsonObject(ssbDemodSettingsJsonObject);
2558  return true;
2559  }
2560  else {
2561  return false;
2562  }
2563  }
2564  else if (*channelType == "SSBMod")
2565  {
2566  if (channelSettings.getDirection() == 1)
2567  {
2568  QJsonObject ssbModSettingsJsonObject = jsonObject["SSBModSettings"].toObject();
2569  channelSettingsKeys = ssbModSettingsJsonObject.keys();
2570 
2571  if (channelSettingsKeys.contains("cwKeyer"))
2572  {
2573  QJsonObject cwKeyerSettingsJsonObject;
2574  appendSettingsSubKeys(ssbModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys);
2575  }
2576 
2577  channelSettings.setSsbModSettings(new SWGSDRangel::SWGSSBModSettings());
2578  channelSettings.getSsbModSettings()->fromJsonObject(ssbModSettingsJsonObject);
2579  return true;
2580  }
2581  else {
2582  return false;
2583  }
2584  }
2585  else if (*channelType == "UDPSource")
2586  {
2587  if (channelSettings.getDirection() == 1)
2588  {
2589  QJsonObject udpSourceSettingsJsonObject = jsonObject["UDPSourceSettings"].toObject();
2590  channelSettingsKeys = udpSourceSettingsJsonObject.keys();
2591  channelSettings.setUdpSourceSettings(new SWGSDRangel::SWGUDPSourceSettings());
2592  channelSettings.getUdpSourceSettings()->fromJsonObject(udpSourceSettingsJsonObject);
2593  return true;
2594  }
2595  else {
2596  return false;
2597  }
2598  }
2599  else if (*channelType == "UDPSink")
2600  {
2601  if (channelSettings.getDirection() == 0)
2602  {
2603  QJsonObject udpSinkSettingsJsonObject = jsonObject["UDPSinkSettings"].toObject();
2604  channelSettingsKeys = udpSinkSettingsJsonObject.keys();
2605  channelSettings.setUdpSinkSettings(new SWGSDRangel::SWGUDPSinkSettings());
2606  channelSettings.getUdpSinkSettings()->fromJsonObject(udpSinkSettingsJsonObject);
2607  return true;
2608  }
2609  else {
2610  return false;
2611  }
2612  }
2613  else if (*channelType == "WFMDemod")
2614  {
2615  if (channelSettings.getDirection() == 0)
2616  {
2617  QJsonObject wfmDemodSettingsJsonObject = jsonObject["WFMDemodSettings"].toObject();
2618  channelSettingsKeys = wfmDemodSettingsJsonObject.keys();
2619  channelSettings.setWfmDemodSettings(new SWGSDRangel::SWGWFMDemodSettings());
2620  channelSettings.getWfmDemodSettings()->fromJsonObject(wfmDemodSettingsJsonObject);
2621  return true;
2622  }
2623  else {
2624  return false;
2625  }
2626  }
2627  else if (*channelType == "WFMMod")
2628  {
2629  if (channelSettings.getDirection() == 1)
2630  {
2631  QJsonObject wfmModSettingsJsonObject = jsonObject["WFMModSettings"].toObject();
2632  channelSettingsKeys = wfmModSettingsJsonObject.keys();
2633 
2634  if (channelSettingsKeys.contains("cwKeyer"))
2635  {
2636  QJsonObject cwKeyerSettingsJsonObject;
2637  appendSettingsSubKeys(wfmModSettingsJsonObject, cwKeyerSettingsJsonObject, "cwKeyer", channelSettingsKeys);
2638  }
2639 
2640  channelSettings.setWfmModSettings(new SWGSDRangel::SWGWFMModSettings());
2641  channelSettings.getWfmModSettings()->fromJsonObject(wfmModSettingsJsonObject);
2642  return true;
2643  }
2644  else {
2645  return false;
2646  }
2647  }
2648  else
2649  {
2650  return false;
2651  }
2652 }
void appendSettingsSubKeys(const QJsonObject &parentSettingsJsonObject, QJsonObject &childSettingsJsonObject, const QString &parentKey, QStringList &keyList)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateDeviceListItem()

bool WebAPIRequestMapper::validateDeviceListItem ( SWGSDRangel::SWGDeviceListItem deviceListItem,
QJsonObject &  jsonObject 
)
private

Definition at line 1797 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGDeviceListItem::setDeviceStreamIndex(), SWGSDRangel::SWGDeviceListItem::setDirection(), SWGSDRangel::SWGDeviceListItem::setDisplayedName(), SWGSDRangel::SWGDeviceListItem::setHwType(), SWGSDRangel::SWGDeviceListItem::setIndex(), SWGSDRangel::SWGDeviceListItem::setSequence(), and SWGSDRangel::SWGDeviceListItem::setSerial().

Referenced by devicesetDeviceService().

1798 {
1799  if (jsonObject.contains("direction")) {
1800  deviceListItem.setDirection(jsonObject["direction"].toInt());
1801  } else {
1802  deviceListItem.setDirection(0); // assume Rx
1803  }
1804 
1805  bool identified = false;
1806 
1807  if (jsonObject.contains("displayedName") && jsonObject["displayedName"].isString())
1808  {
1809  deviceListItem.setDisplayedName(new QString(jsonObject["displayedName"].toString()));
1810  identified = true;
1811  } else {
1812  deviceListItem.setDisplayedName(0);
1813  }
1814 
1815 
1816  if (jsonObject.contains("hwType") && jsonObject["hwType"].isString())
1817  {
1818  deviceListItem.setHwType(new QString(jsonObject["hwType"].toString()));
1819  identified = true;
1820  } else {
1821  deviceListItem.setHwType(0);
1822  }
1823 
1824  if (jsonObject.contains("serial") && jsonObject["serial"].isString())
1825  {
1826  deviceListItem.setSerial(new QString(jsonObject["serial"].toString()));
1827  identified = true;
1828  } else {
1829  deviceListItem.setSerial(0);
1830  }
1831 
1832  if (jsonObject.contains("index")) {
1833  deviceListItem.setIndex(jsonObject["index"].toInt(-1));
1834  } else {
1835  deviceListItem.setIndex(-1);
1836  }
1837 
1838  if (jsonObject.contains("sequence")){
1839  deviceListItem.setSequence(jsonObject["sequence"].toInt(-1));
1840  } else {
1841  deviceListItem.setSequence(-1);
1842  }
1843 
1844  if (jsonObject.contains("deviceStreamIndex")) {
1845  deviceListItem.setDeviceStreamIndex(jsonObject["deviceStreamIndex"].toInt(-1));
1846  } else {
1847  deviceListItem.setDeviceStreamIndex(-1);
1848  }
1849 
1850  return identified;
1851 }
void setDeviceStreamIndex(qint32 device_stream_index)
void setDirection(qint32 direction)
void setDisplayedName(QString *displayed_name)
void setHwType(QString *hw_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateDeviceSettings()

bool WebAPIRequestMapper::validateDeviceSettings ( SWGSDRangel::SWGDeviceSettings deviceSettings,
QJsonObject &  jsonObject,
QStringList &  deviceSettingsKeys 
)
private

Definition at line 1853 of file webapirequestmapper.cpp.

References appendSettingsArrayKeys(), SWGSDRangel::SWGAirspySettings::fromJsonObject(), SWGSDRangel::SWGAirspyHFSettings::fromJsonObject(), SWGSDRangel::SWGHackRFInputSettings::fromJsonObject(), SWGSDRangel::SWGTestSourceSettings::fromJsonObject(), SWGSDRangel::SWGBladeRF1OutputSettings::fromJsonObject(), SWGSDRangel::SWGBladeRF2InputSettings::fromJsonObject(), SWGSDRangel::SWGHackRFOutputSettings::fromJsonObject(), SWGSDRangel::SWGXtrxInputSettings::fromJsonObject(), SWGSDRangel::SWGBladeRF2OutputSettings::fromJsonObject(), SWGSDRangel::SWGKiwiSDRSettings::fromJsonObject(), SWGSDRangel::SWGXtrxOutputSettings::fromJsonObject(), SWGSDRangel::SWGLimeSdrInputSettings::fromJsonObject(), SWGSDRangel::SWGRemoteInputSettings::fromJsonObject(), SWGSDRangel::SWGLocalInputSettings::fromJsonObject(), SWGSDRangel::SWGLimeSdrOutputSettings::fromJsonObject(), SWGSDRangel::SWGRemoteOutputSettings::fromJsonObject(), SWGSDRangel::SWGLocalOutputSettings::fromJsonObject(), SWGSDRangel::SWGBladeRF1InputSettings::fromJsonObject(), SWGSDRangel::SWGFCDProSettings::fromJsonObject(), SWGSDRangel::SWGPerseusSettings::fromJsonObject(), SWGSDRangel::SWGPlutoSdrInputSettings::fromJsonObject(), SWGSDRangel::SWGPlutoSdrOutputSettings::fromJsonObject(), SWGSDRangel::SWGFCDProPlusSettings::fromJsonObject(), SWGSDRangel::SWGRtlSdrSettings::fromJsonObject(), SWGSDRangel::SWGFileInputSettings::fromJsonObject(), SWGSDRangel::SWGSDRPlaySettings::fromJsonObject(), SWGSDRangel::SWGTestMISettings::fromJsonObject(), SWGSDRangel::SWGSoapySDRInputSettings::fromJsonObject(), SWGSDRangel::SWGSoapySDROutputSettings::fromJsonObject(), SWGSDRangel::SWGDeviceSettings::getAirspyHfSettings(), SWGSDRangel::SWGDeviceSettings::getAirspySettings(), SWGSDRangel::SWGDeviceSettings::getBladeRf1InputSettings(), SWGSDRangel::SWGDeviceSettings::getBladeRf1OutputSettings(), SWGSDRangel::SWGDeviceSettings::getBladeRf2InputSettings(), SWGSDRangel::SWGDeviceSettings::getBladeRf2OutputSettings(), SWGSDRangel::SWGDeviceSettings::getDeviceHwType(), SWGSDRangel::SWGDeviceSettings::getDirection(), SWGSDRangel::SWGDeviceSettings::getFcdProPlusSettings(), SWGSDRangel::SWGDeviceSettings::getFcdProSettings(), SWGSDRangel::SWGDeviceSettings::getFileInputSettings(), SWGSDRangel::SWGDeviceSettings::getHackRfInputSettings(), SWGSDRangel::SWGDeviceSettings::getHackRfOutputSettings(), SWGSDRangel::SWGDeviceSettings::getKiwiSdrSettings(), SWGSDRangel::SWGDeviceSettings::getLimeSdrInputSettings(), SWGSDRangel::SWGDeviceSettings::getLimeSdrOutputSettings(), SWGSDRangel::SWGDeviceSettings::getLocalInputSettings(), SWGSDRangel::SWGDeviceSettings::getLocalOutputSettings(), SWGSDRangel::SWGDeviceSettings::getPerseusSettings(), SWGSDRangel::SWGDeviceSettings::getPlutoSdrInputSettings(), SWGSDRangel::SWGDeviceSettings::getPlutoSdrOutputSettings(), SWGSDRangel::SWGDeviceSettings::getRemoteInputSettings(), SWGSDRangel::SWGDeviceSettings::getRemoteOutputSettings(), SWGSDRangel::SWGDeviceSettings::getRtlSdrSettings(), SWGSDRangel::SWGDeviceSettings::getSdrPlaySettings(), SWGSDRangel::SWGDeviceSettings::getSoapySdrInputSettings(), SWGSDRangel::SWGDeviceSettings::getSoapySdrOutputSettings(), SWGSDRangel::SWGDeviceSettings::getTestMiSettings(), SWGSDRangel::SWGDeviceSettings::getTestSourceSettings(), SWGSDRangel::SWGDeviceSettings::getXtrxInputSettings(), SWGSDRangel::SWGDeviceSettings::getXtrxOutputSettings(), SWGSDRangel::SWGSoapySDRInputSettings::init(), SWGSDRangel::SWGDeviceSettings::setAirspyHfSettings(), SWGSDRangel::SWGDeviceSettings::setAirspySettings(), SWGSDRangel::SWGDeviceSettings::setBladeRf1InputSettings(), SWGSDRangel::SWGDeviceSettings::setBladeRf1OutputSettings(), SWGSDRangel::SWGDeviceSettings::setBladeRf2InputSettings(), SWGSDRangel::SWGDeviceSettings::setBladeRf2OutputSettings(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGDeviceSettings::setFcdProPlusSettings(), SWGSDRangel::SWGDeviceSettings::setFcdProSettings(), SWGSDRangel::SWGDeviceSettings::setFileInputSettings(), SWGSDRangel::SWGDeviceSettings::setHackRfInputSettings(), SWGSDRangel::SWGDeviceSettings::setHackRfOutputSettings(), SWGSDRangel::SWGDeviceSettings::setKiwiSdrSettings(), SWGSDRangel::SWGDeviceSettings::setLimeSdrInputSettings(), SWGSDRangel::SWGDeviceSettings::setLimeSdrOutputSettings(), SWGSDRangel::SWGDeviceSettings::setLocalInputSettings(), SWGSDRangel::SWGDeviceSettings::setLocalOutputSettings(), SWGSDRangel::SWGDeviceSettings::setPerseusSettings(), SWGSDRangel::SWGDeviceSettings::setPlutoSdrInputSettings(), SWGSDRangel::SWGDeviceSettings::setPlutoSdrOutputSettings(), SWGSDRangel::SWGDeviceSettings::setRemoteInputSettings(), SWGSDRangel::SWGDeviceSettings::setRemoteOutputSettings(), SWGSDRangel::SWGDeviceSettings::setRtlSdrSettings(), SWGSDRangel::SWGDeviceSettings::setSdrPlaySettings(), SWGSDRangel::SWGDeviceSettings::setSoapySdrInputSettings(), SWGSDRangel::SWGDeviceSettings::setSoapySdrOutputSettings(), SWGSDRangel::SWGDeviceSettings::setTestMiSettings(), SWGSDRangel::SWGDeviceSettings::setTestSourceSettings(), SWGSDRangel::SWGDeviceSettings::setXtrxInputSettings(), and SWGSDRangel::SWGDeviceSettings::setXtrxOutputSettings().

Referenced by devicesetDeviceSettingsService().

1857 {
1858  if (jsonObject.contains("direction")) {
1859  deviceSettings.setDirection(jsonObject["direction"].toInt());
1860  } else {
1861  deviceSettings.setDirection(0); // assume single Rx
1862  }
1863 
1864  if (jsonObject.contains("deviceHwType") && jsonObject["deviceHwType"].isString()) {
1865  deviceSettings.setDeviceHwType(new QString(jsonObject["deviceHwType"].toString()));
1866  } else {
1867  return false;
1868  }
1869 
1870  QString *deviceHwType = deviceSettings.getDeviceHwType();
1871 
1872  if ((*deviceHwType == "Airspy") && (deviceSettings.getDirection() == 0))
1873  {
1874  if (jsonObject.contains("airspySettings") && jsonObject["airspySettings"].isObject())
1875  {
1876  QJsonObject airspySettingsJsonObject = jsonObject["airspySettings"].toObject();
1877  deviceSettingsKeys = airspySettingsJsonObject.keys();
1878  deviceSettings.setAirspySettings(new SWGSDRangel::SWGAirspySettings());
1879  deviceSettings.getAirspySettings()->fromJsonObject(airspySettingsJsonObject);
1880  return true;
1881  }
1882  else
1883  {
1884  return false;
1885  }
1886  }
1887  else if ((*deviceHwType == "AirspyHF") && (deviceSettings.getDirection() == 0))
1888  {
1889  if (jsonObject.contains("airspyHFSettings") && jsonObject["airspyHFSettings"].isObject())
1890  {
1891  QJsonObject airspyHFSettingsJsonObject = jsonObject["airspyHFSettings"].toObject();
1892  deviceSettingsKeys = airspyHFSettingsJsonObject.keys();
1894  deviceSettings.getAirspyHfSettings()->fromJsonObject(airspyHFSettingsJsonObject);
1895  return true;
1896  }
1897  else
1898  {
1899  return false;
1900  }
1901  }
1902  else if ((*deviceHwType == "BladeRF1") && (deviceSettings.getDirection() == 0))
1903  {
1904  if (jsonObject.contains("bladeRF1InputSettings") && jsonObject["bladeRF1InputSettings"].isObject())
1905  {
1906  QJsonObject bladeRF1InputSettingsJsonObject = jsonObject["bladeRF1InputSettings"].toObject();
1907  deviceSettingsKeys = bladeRF1InputSettingsJsonObject.keys();
1909  deviceSettings.getBladeRf1InputSettings()->fromJsonObject(bladeRF1InputSettingsJsonObject);
1910  return true;
1911  }
1912  else
1913  {
1914  return false;
1915  }
1916  }
1917  else if ((*deviceHwType == "BladeRF1") && (deviceSettings.getDirection() == 1))
1918  {
1919  if (jsonObject.contains("bladeRF1OutputSettings") && jsonObject["bladeRF1OutputSettings"].isObject())
1920  {
1921  QJsonObject bladeRF1OutputSettingsJsonObject = jsonObject["bladeRF1OutputSettings"].toObject();
1922  deviceSettingsKeys = bladeRF1OutputSettingsJsonObject.keys();
1924  deviceSettings.getBladeRf1OutputSettings()->fromJsonObject(bladeRF1OutputSettingsJsonObject);
1925  return true;
1926  }
1927  else
1928  {
1929  return false;
1930  }
1931  }
1932  else if ((*deviceHwType == "BladeRF2") && (deviceSettings.getDirection() == 0))
1933  {
1934  if (jsonObject.contains("bladeRF2InputSettings") && jsonObject["bladeRF2InputSettings"].isObject())
1935  {
1936  QJsonObject bladeRF2InputSettingsJsonObject = jsonObject["bladeRF2InputSettings"].toObject();
1937  deviceSettingsKeys = bladeRF2InputSettingsJsonObject.keys();
1939  deviceSettings.getBladeRf2InputSettings()->fromJsonObject(bladeRF2InputSettingsJsonObject);
1940  return true;
1941  }
1942  else
1943  {
1944  return false;
1945  }
1946  }
1947  else if ((*deviceHwType == "BladeRF2") && (deviceSettings.getDirection() == 1))
1948  {
1949  if (jsonObject.contains("bladeRF2OutputSettings") && jsonObject["bladeRF2OutputSettings"].isObject())
1950  {
1951  QJsonObject bladeRF2OutputSettingsJsonObject = jsonObject["bladeRF2OutputSettings"].toObject();
1952  deviceSettingsKeys = bladeRF2OutputSettingsJsonObject.keys();
1954  deviceSettings.getBladeRf2OutputSettings()->fromJsonObject(bladeRF2OutputSettingsJsonObject);
1955  return true;
1956  }
1957  else
1958  {
1959  return false;
1960  }
1961  }
1962  else if (*deviceHwType == "FCDPro")
1963  {
1964  if (jsonObject.contains("fcdProSettings") && jsonObject["fcdProSettings"].isObject())
1965  {
1966  QJsonObject fcdProSettingsJsonObject = jsonObject["fcdProSettings"].toObject();
1967  deviceSettingsKeys = fcdProSettingsJsonObject.keys();
1968  deviceSettings.setFcdProSettings(new SWGSDRangel::SWGFCDProSettings());
1969  deviceSettings.getFcdProSettings()->fromJsonObject(fcdProSettingsJsonObject);
1970  return true;
1971  }
1972  else
1973  {
1974  return false;
1975  }
1976  }
1977  else if (*deviceHwType == "FCDPro+")
1978  {
1979  if (jsonObject.contains("fcdProPlusSettings") && jsonObject["fcdProPlusSettings"].isObject())
1980  {
1981  QJsonObject fcdProPlusSettingsJsonObject = jsonObject["fcdProPlusSettings"].toObject();
1982  deviceSettingsKeys = fcdProPlusSettingsJsonObject.keys();
1984  deviceSettings.getFcdProPlusSettings()->fromJsonObject(fcdProPlusSettingsJsonObject);
1985  return true;
1986  }
1987  else
1988  {
1989  return false;
1990  }
1991  }
1992  else if (*deviceHwType == "FileInput")
1993  {
1994  if (jsonObject.contains("fileInputSettings") && jsonObject["fileInputSettings"].isObject())
1995  {
1996  QJsonObject fileInputSettingsJsonObject = jsonObject["fileInputSettings"].toObject();
1997  deviceSettingsKeys = fileInputSettingsJsonObject.keys();
1999  deviceSettings.getFileInputSettings()->fromJsonObject(fileInputSettingsJsonObject);
2000  return true;
2001  }
2002  else
2003  {
2004  return false;
2005  }
2006  }
2007  else if ((*deviceHwType == "HackRF") && (deviceSettings.getDirection() == 0))
2008  {
2009  if (jsonObject.contains("hackRFInputSettings") && jsonObject["hackRFInputSettings"].isObject())
2010  {
2011  QJsonObject hackRFInputSettingsJsonObject = jsonObject["hackRFInputSettings"].toObject();
2012  deviceSettingsKeys = hackRFInputSettingsJsonObject.keys();
2014  deviceSettings.getHackRfInputSettings()->fromJsonObject(hackRFInputSettingsJsonObject);
2015  return true;
2016  }
2017  else
2018  {
2019  return false;
2020  }
2021  }
2022  else if ((*deviceHwType == "HackRF") && (deviceSettings.getDirection() == 1))
2023  {
2024  if (jsonObject.contains("hackRFOutputSettings") && jsonObject["hackRFOutputSettings"].isObject())
2025  {
2026  QJsonObject hackRFOutputSettingsJsonObject = jsonObject["hackRFOutputSettings"].toObject();
2027  deviceSettingsKeys = hackRFOutputSettingsJsonObject.keys();
2029  deviceSettings.getHackRfOutputSettings()->fromJsonObject(hackRFOutputSettingsJsonObject);
2030  return true;
2031  }
2032  else
2033  {
2034  return false;
2035  }
2036  }
2037  else if ((*deviceHwType == "KiwiSDR") && (deviceSettings.getDirection() == 0))
2038  {
2039  if (jsonObject.contains("kiwiSDRSettings") && jsonObject["kiwiSDRSettings"].isObject())
2040  {
2041  QJsonObject kiwiSDRSettingsJsonObject = jsonObject["kiwiSDRSettings"].toObject();
2042  deviceSettingsKeys = kiwiSDRSettingsJsonObject.keys();
2044  deviceSettings.getKiwiSdrSettings()->fromJsonObject(kiwiSDRSettingsJsonObject);
2045  return true;
2046  }
2047  else
2048  {
2049  return false;
2050  }
2051  }
2052  else if ((*deviceHwType == "LimeSDR") && (deviceSettings.getDirection() == 0))
2053  {
2054  if (jsonObject.contains("limeSdrInputSettings") && jsonObject["limeSdrInputSettings"].isObject())
2055  {
2056  QJsonObject limeSdrInputSettingsJsonObject = jsonObject["limeSdrInputSettings"].toObject();
2057  deviceSettingsKeys = limeSdrInputSettingsJsonObject.keys();
2059  deviceSettings.getLimeSdrInputSettings()->fromJsonObject(limeSdrInputSettingsJsonObject);
2060  return true;
2061  }
2062  else
2063  {
2064  return false;
2065  }
2066  }
2067  else if ((*deviceHwType == "LimeSDR") && (deviceSettings.getDirection() == 1))
2068  {
2069  if (jsonObject.contains("limeSdrOutputSettings") && jsonObject["limeSdrOutputSettings"].isObject())
2070  {
2071  QJsonObject limeSdrOutputSettingsJsonObject = jsonObject["limeSdrOutputSettings"].toObject();
2072  deviceSettingsKeys = limeSdrOutputSettingsJsonObject.keys();
2074  deviceSettings.getLimeSdrOutputSettings()->fromJsonObject(limeSdrOutputSettingsJsonObject);
2075  return true;
2076  }
2077  else
2078  {
2079  return false;
2080  }
2081  }
2082  else if (*deviceHwType == "Perseus")
2083  {
2084  if (jsonObject.contains("perseusSettings") && jsonObject["perseusSettings"].isObject())
2085  {
2086  QJsonObject perseusSettingsJsonObject = jsonObject["perseusSettings"].toObject();
2087  deviceSettingsKeys = perseusSettingsJsonObject.keys();
2089  deviceSettings.getPerseusSettings()->fromJsonObject(perseusSettingsJsonObject);
2090  return true;
2091  }
2092  else
2093  {
2094  return false;
2095  }
2096  }
2097  else if ((*deviceHwType == "PlutoSDR") && (deviceSettings.getDirection() == 0))
2098  {
2099  if (jsonObject.contains("plutoSdrInputSettings") && jsonObject["plutoSdrInputSettings"].isObject())
2100  {
2101  QJsonObject plutoSdrInputSettingsJsonObject = jsonObject["plutoSdrInputSettings"].toObject();
2102  deviceSettingsKeys = plutoSdrInputSettingsJsonObject.keys();
2104  deviceSettings.getPlutoSdrInputSettings()->fromJsonObject(plutoSdrInputSettingsJsonObject);
2105  return true;
2106  }
2107  else
2108  {
2109  return false;
2110  }
2111  }
2112  else if ((*deviceHwType == "PlutoSDR") && (deviceSettings.getDirection() == 1))
2113  {
2114  if (jsonObject.contains("plutoSdrOutputSettings") && jsonObject["plutoSdrOutputSettings"].isObject())
2115  {
2116  QJsonObject plutoSdrOutputSettingsJsonObject = jsonObject["plutoSdrOutputSettings"].toObject();
2117  deviceSettingsKeys = plutoSdrOutputSettingsJsonObject.keys();
2119  deviceSettings.getPlutoSdrOutputSettings()->fromJsonObject(plutoSdrOutputSettingsJsonObject);
2120  return true;
2121  }
2122  else
2123  {
2124  return false;
2125  }
2126  }
2127  else if (*deviceHwType == "RTLSDR")
2128  {
2129  if (jsonObject.contains("rtlSdrSettings") && jsonObject["rtlSdrSettings"].isObject())
2130  {
2131  QJsonObject rtlSdrSettingsJsonObject = jsonObject["rtlSdrSettings"].toObject();
2132  deviceSettingsKeys = rtlSdrSettingsJsonObject.keys();
2133  deviceSettings.setRtlSdrSettings(new SWGSDRangel::SWGRtlSdrSettings());
2134  deviceSettings.getRtlSdrSettings()->fromJsonObject(rtlSdrSettingsJsonObject);
2135  return true;
2136  }
2137  else
2138  {
2139  return false;
2140  }
2141  }
2142  else if (*deviceHwType == "SDRplay1")
2143  {
2144  if (jsonObject.contains("sdrPlaySettings") && jsonObject["sdrPlaySettings"].isObject())
2145  {
2146  QJsonObject sdrPlaySettingsJsonObject = jsonObject["sdrPlaySettings"].toObject();
2147  deviceSettingsKeys = sdrPlaySettingsJsonObject.keys();
2149  deviceSettings.getSdrPlaySettings()->fromJsonObject(sdrPlaySettingsJsonObject);
2150  return true;
2151  }
2152  else
2153  {
2154  return false;
2155  }
2156  }
2157  else if ((*deviceHwType == "SoapySDR") && (deviceSettings.getDirection() == 0))
2158  {
2159  if (jsonObject.contains("soapySDRInputSettings") && jsonObject["soapySDRInputSettings"].isObject())
2160  {
2161  QJsonObject soapySdrInputSettingsJsonObject = jsonObject["soapySDRInputSettings"].toObject();
2162  deviceSettingsKeys = soapySdrInputSettingsJsonObject.keys();
2164  deviceSettings.getSoapySdrInputSettings()->init(); // contains complex objects
2165  deviceSettings.getSoapySdrInputSettings()->fromJsonObject(soapySdrInputSettingsJsonObject);
2166  return true;
2167  }
2168  else
2169  {
2170  return false;
2171  }
2172  }
2173  else if ((*deviceHwType == "SoapySDR") && (deviceSettings.getDirection() == 1))
2174  {
2175  if (jsonObject.contains("soapySDROutputSettings") && jsonObject["soapySDROutputSettings"].isObject())
2176  {
2177  QJsonObject soapySdrOutputSettingsJsonObject = jsonObject["soapySDROutputSettings"].toObject();
2178  deviceSettingsKeys = soapySdrOutputSettingsJsonObject.keys();
2180  deviceSettings.getSoapySdrInputSettings()->init(); // contains complex objects
2181  deviceSettings.getSoapySdrOutputSettings()->fromJsonObject(soapySdrOutputSettingsJsonObject);
2182  return true;
2183  }
2184  else
2185  {
2186  return false;
2187  }
2188  }
2189  else if (*deviceHwType == "TestSource")
2190  {
2191  if (jsonObject.contains("testSourceSettings") && jsonObject["testSourceSettings"].isObject())
2192  {
2193  QJsonObject testSourceSettingsJsonObject = jsonObject["testSourceSettings"].toObject();
2194  deviceSettingsKeys = testSourceSettingsJsonObject.keys();
2196  deviceSettings.getTestSourceSettings()->fromJsonObject(testSourceSettingsJsonObject);
2197  return true;
2198  }
2199  else
2200  {
2201  return false;
2202  }
2203  }
2204  else if ((*deviceHwType == "TestMI") && (deviceSettings.getDirection() == 2))
2205  {
2206  if (jsonObject.contains("TestMISettings") && jsonObject["TestMISettings"].isObject())
2207  {
2208  QJsonObject testMISettingsJsonObject = jsonObject["TestMISettings"].toObject();
2209  deviceSettingsKeys = testMISettingsJsonObject.keys();
2210 
2211  if (deviceSettingsKeys.contains("streams") && testMISettingsJsonObject["streams"].isArray())
2212  {
2213  appendSettingsArrayKeys(testMISettingsJsonObject, "streams", deviceSettingsKeys);
2214  }
2215 
2216  deviceSettings.setTestMiSettings(new SWGSDRangel::SWGTestMISettings());
2217  deviceSettings.getTestMiSettings()->fromJsonObject(testMISettingsJsonObject);
2218  return true;
2219  }
2220  else
2221  {
2222  return false;
2223  }
2224  }
2225  else if ((*deviceHwType == "XTRX") && (deviceSettings.getDirection() == 0))
2226  {
2227  if (jsonObject.contains("xtrxInputSettings") && jsonObject["xtrxInputSettings"].isObject())
2228  {
2229  QJsonObject xtrxInputSettingsJsonObject = jsonObject["xtrxInputSettings"].toObject();
2230  deviceSettingsKeys = xtrxInputSettingsJsonObject.keys();
2232  deviceSettings.getXtrxInputSettings()->fromJsonObject(xtrxInputSettingsJsonObject);
2233  return true;
2234  }
2235  else
2236  {
2237  return false;
2238  }
2239  }
2240  else if ((*deviceHwType == "XTRX") && (deviceSettings.getDirection() == 1))
2241  {
2242  if (jsonObject.contains("xtrxOutputSettings") && jsonObject["xtrxOutputSettings"].isObject())
2243  {
2244  QJsonObject xtrxOutputSettingsJsonObject = jsonObject["xtrxOutputSettings"].toObject();
2245  deviceSettingsKeys = xtrxOutputSettingsJsonObject.keys();
2247  deviceSettings.getXtrxOutputSettings()->fromJsonObject(xtrxOutputSettingsJsonObject);
2248  return true;
2249  }
2250  else
2251  {
2252  return false;
2253  }
2254  }
2255  else if ((*deviceHwType == "RemoteInput") && (deviceSettings.getDirection() == 0))
2256  {
2257  if (jsonObject.contains("remoteInputSettings") && jsonObject["remoteInputSettings"].isObject())
2258  {
2259  QJsonObject remoteInputSettingsJsonObject = jsonObject["remoteInputSettings"].toObject();
2260  deviceSettingsKeys = remoteInputSettingsJsonObject.keys();
2262  deviceSettings.getRemoteInputSettings()->fromJsonObject(remoteInputSettingsJsonObject);
2263  return true;
2264  }
2265  else
2266  {
2267  return false;
2268  }
2269  }
2270  else if ((*deviceHwType == "LocalInput") && (deviceSettings.getDirection() == 0))
2271  {
2272  if (jsonObject.contains("localInputSettings") && jsonObject["localInputSettings"].isObject())
2273  {
2274  QJsonObject localInputSettingsJsonObject = jsonObject["localInputSettings"].toObject();
2275  deviceSettingsKeys = localInputSettingsJsonObject.keys();
2277  deviceSettings.getLocalInputSettings()->fromJsonObject(localInputSettingsJsonObject);
2278  return true;
2279  }
2280  else
2281  {
2282  return false;
2283  }
2284  }
2285  else if ((*deviceHwType == "RemoteOutput") && (deviceSettings.getDirection() == 1))
2286  {
2287  if (jsonObject.contains("remoteOutputSettings") && jsonObject["remoteOutputSettings"].isObject())
2288  {
2289  QJsonObject remoteOutputSettingsJsonObject = jsonObject["remoteOutputSettings"].toObject();
2290  deviceSettingsKeys = remoteOutputSettingsJsonObject.keys();
2292  deviceSettings.getRemoteOutputSettings()->fromJsonObject(remoteOutputSettingsJsonObject);
2293  return true;
2294  }
2295  else
2296  {
2297  return false;
2298  }
2299  }
2300  else if ((*deviceHwType == "LocalOutput") && (deviceSettings.getDirection() == 1))
2301  {
2302  if (jsonObject.contains("localOutputSettings") && jsonObject["localOutputSettings"].isObject())
2303  {
2304  QJsonObject localOutputSettingsJsonObject = jsonObject["localOutputSettings"].toObject();
2305  deviceSettingsKeys = localOutputSettingsJsonObject.keys();
2307  deviceSettings.getLocalOutputSettings()->fromJsonObject(localOutputSettingsJsonObject);
2308  return true;
2309  }
2310  else
2311  {
2312  return false;
2313  }
2314  }
2315  else
2316  {
2317  return false;
2318  }
2319 }
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
void setLocalInputSettings(SWGLocalInputSettings *local_input_settings)
SWGFCDProSettings * getFcdProSettings()
SWGLocalInputSettings * getLocalInputSettings()
void setBladeRf1OutputSettings(SWGBladeRF1OutputSettings *blade_rf1_output_settings)
void setBladeRf1InputSettings(SWGBladeRF1InputSettings *blade_rf1_input_settings)
SWGBladeRF2OutputSettings * getBladeRf2OutputSettings()
void setPlutoSdrOutputSettings(SWGPlutoSdrOutputSettings *pluto_sdr_output_settings)
void setLimeSdrInputSettings(SWGLimeSdrInputSettings *lime_sdr_input_settings)
SWGSDRPlaySettings * getSdrPlaySettings()
void setXtrxInputSettings(SWGXtrxInputSettings *xtrx_input_settings)
SWGTestSourceSettings * getTestSourceSettings()
SWGBladeRF1OutputSettings * getBladeRf1OutputSettings()
SWGLimeSdrOutputSettings * getLimeSdrOutputSettings()
virtual void fromJsonObject(QJsonObject &json) override
SWGRtlSdrSettings * getRtlSdrSettings()
SWGPerseusSettings * getPerseusSettings()
void setSoapySdrOutputSettings(SWGSoapySDROutputSettings *soapy_sdr_output_settings)
void setSdrPlaySettings(SWGSDRPlaySettings *sdr_play_settings)
SWGSoapySDROutputSettings * getSoapySdrOutputSettings()
void setPerseusSettings(SWGPerseusSettings *perseus_settings)
virtual void fromJsonObject(QJsonObject &json) override
SWGAirspySettings * getAirspySettings()
SWGPlutoSdrOutputSettings * getPlutoSdrOutputSettings()
SWGTestMISettings * getTestMiSettings()
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
void setAirspySettings(SWGAirspySettings *airspy_settings)
virtual void fromJsonObject(QJsonObject &json) override
void appendSettingsArrayKeys(const QJsonObject &parentSettingsJsonObject, const QString &parentKey, QStringList &keyList)
SWGBladeRF1InputSettings * getBladeRf1InputSettings()
virtual void fromJsonObject(QJsonObject &json) override
SWGLocalOutputSettings * getLocalOutputSettings()
SWGXtrxInputSettings * getXtrxInputSettings()
void setHackRfOutputSettings(SWGHackRFOutputSettings *hack_rf_output_settings)
void setLocalOutputSettings(SWGLocalOutputSettings *local_output_settings)
SWGXtrxOutputSettings * getXtrxOutputSettings()
void setFileInputSettings(SWGFileInputSettings *file_input_settings)
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
void setTestSourceSettings(SWGTestSourceSettings *test_source_settings)
virtual void fromJsonObject(QJsonObject &json) override
void setKiwiSdrSettings(SWGKiwiSDRSettings *kiwi_sdr_settings)
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
SWGFCDProPlusSettings * getFcdProPlusSettings()
void setBladeRf2InputSettings(SWGBladeRF2InputSettings *blade_rf2_input_settings)
void setLimeSdrOutputSettings(SWGLimeSdrOutputSettings *lime_sdr_output_settings)
virtual void fromJsonObject(QJsonObject &json) override
void setFcdProSettings(SWGFCDProSettings *fcd_pro_settings)
void setRtlSdrSettings(SWGRtlSdrSettings *rtl_sdr_settings)
SWGAirspyHFSettings * getAirspyHfSettings()
void setFcdProPlusSettings(SWGFCDProPlusSettings *fcd_pro_plus_settings)
virtual void fromJsonObject(QJsonObject &json) override
void setRemoteOutputSettings(SWGRemoteOutputSettings *remote_output_settings)
void setTestMiSettings(SWGTestMISettings *test_mi_settings)
virtual void fromJsonObject(QJsonObject &json) override
void setRemoteInputSettings(SWGRemoteInputSettings *remote_input_settings)
SWGFileInputSettings * getFileInputSettings()
virtual void fromJsonObject(QJsonObject &json) override
SWGHackRFOutputSettings * getHackRfOutputSettings()
void setHackRfInputSettings(SWGHackRFInputSettings *hack_rf_input_settings)
SWGRemoteOutputSettings * getRemoteOutputSettings()
virtual void fromJsonObject(QJsonObject &json) override
SWGHackRFInputSettings * getHackRfInputSettings()
virtual void fromJsonObject(QJsonObject &json) override
SWGPlutoSdrInputSettings * getPlutoSdrInputSettings()
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
void setAirspyHfSettings(SWGAirspyHFSettings *airspy_hf_settings)
SWGRemoteInputSettings * getRemoteInputSettings()
virtual void fromJsonObject(QJsonObject &json) override
void setPlutoSdrInputSettings(SWGPlutoSdrInputSettings *pluto_sdr_input_settings)
void setSoapySdrInputSettings(SWGSoapySDRInputSettings *soapy_sdr_input_settings)
SWGLimeSdrInputSettings * getLimeSdrInputSettings()
void setDirection(qint32 direction)
virtual void fromJsonObject(QJsonObject &json) override
virtual void fromJsonObject(QJsonObject &json) override
void setXtrxOutputSettings(SWGXtrxOutputSettings *xtrx_output_settings)
SWGBladeRF2InputSettings * getBladeRf2InputSettings()
void setDeviceHwType(QString *device_hw_type)
void setBladeRf2OutputSettings(SWGBladeRF2OutputSettings *blade_rf2_output_settings)
virtual void fromJsonObject(QJsonObject &json) override
SWGKiwiSDRSettings * getKiwiSdrSettings()
SWGSoapySDRInputSettings * getSoapySdrInputSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validatePresetExport()

bool WebAPIRequestMapper::validatePresetExport ( SWGSDRangel::SWGPresetExport presetExport)
private

Definition at line 1782 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGPresetExport::getFilePath(), SWGSDRangel::SWGPresetExport::getPreset(), and validatePresetIdentifer().

Referenced by instancePresetFileService().

1783 {
1784  if (presetExport.getFilePath() == 0) {
1785  return false;
1786  }
1787 
1788  SWGSDRangel::SWGPresetIdentifier *presetIdentifier = presetExport.getPreset();
1789 
1790  if (presetIdentifier == 0) {
1791  return false;
1792  }
1793 
1794  return validatePresetIdentifer(*presetIdentifier);
1795 }
bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier &presetIdentifier)
SWGPresetIdentifier * getPreset()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validatePresetIdentifer()

bool WebAPIRequestMapper::validatePresetIdentifer ( SWGSDRangel::SWGPresetIdentifier presetIdentifier)
private

Definition at line 1777 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGPresetIdentifier::getGroupName(), SWGSDRangel::SWGPresetIdentifier::getName(), and SWGSDRangel::SWGPresetIdentifier::getType().

Referenced by instancePresetService(), validatePresetExport(), and validatePresetTransfer().

1778 {
1779  return (presetIdentifier.getGroupName() && presetIdentifier.getName() && presetIdentifier.getType());
1780 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validatePresetTransfer()

bool WebAPIRequestMapper::validatePresetTransfer ( SWGSDRangel::SWGPresetTransfer presetTransfer)
private

Definition at line 1766 of file webapirequestmapper.cpp.

References SWGSDRangel::SWGPresetTransfer::getPreset(), and validatePresetIdentifer().

Referenced by instancePresetService().

1767 {
1768  SWGSDRangel::SWGPresetIdentifier *presetIdentifier = presetTransfer.getPreset();
1769 
1770  if (presetIdentifier == 0) {
1771  return false;
1772  }
1773 
1774  return validatePresetIdentifer(*presetIdentifier);
1775 }
bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier &presetIdentifier)
SWGPresetIdentifier * getPreset()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_adapter

WebAPIAdapterInterface* WebAPIRequestMapper::m_adapter
private

◆ m_staticFileController

qtwebapp::StaticFileController* WebAPIRequestMapper::m_staticFileController
private

Definition at line 49 of file webapirequestmapper.h.

Referenced by service(), WebAPIRequestMapper(), and ~WebAPIRequestMapper().


The documentation for this class was generated from the following files: