1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Web API: implement devicesetDeviceGet (2)

This commit is contained in:
f4exb 2017-12-04 23:07:30 +01:00
parent 7dafae3fa1
commit 3fb4af82e6
5 changed files with 21 additions and 16 deletions

View File

@ -25,6 +25,11 @@
#include "util/messagequeue.h"
#include "util/export.h"
namespace SWGSDRangel
{
class SWGObject;
}
class SDRANGEL_API DeviceSampleSink : public QObject {
Q_OBJECT
public:

View File

@ -25,6 +25,11 @@
#include "util/messagequeue.h"
#include "util/export.h"
namespace SWGSDRangel
{
class SWGObject;
}
class SDRANGEL_API DeviceSampleSource : public QObject {
Q_OBJECT
public:

View File

@ -38,6 +38,7 @@ namespace SWGSDRangel
class SWGDeviceSetList;
class SWGDeviceSet;
class SWGDeviceListItem;
class SWGDeviceSettings;
class SWGErrorResponse;
}

View File

@ -34,6 +34,7 @@
#include "SWGPresets.h"
#include "SWGPresetTransfer.h"
#include "SWGPresetIdentifier.h"
#include "SWGDeviceSettings.h"
#include "SWGErrorResponse.h"
WebAPIRequestMapper::WebAPIRequestMapper(QObject* parent) :

View File

@ -50,6 +50,7 @@
#include "SWGPresetItem.h"
#include "SWGPresetTransfer.h"
#include "SWGPresetIdentifier.h"
#include "SWGDeviceSettings.h"
#include "SWGErrorResponse.h"
#include "webapiadaptergui.h"
@ -698,33 +699,25 @@ int WebAPIAdapterGUI::devicesetDeviceGet(
SWGSDRangel::SWGDeviceSettings& response,
SWGSDRangel::SWGErrorResponse& error)
{
if ((deviceSetIndex >= 0) && (m_mainWindow.m_deviceUIs < (int) m_mainWindow.m_deviceUIs.size()))
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size()))
{
DeviceUISet *deviceSet = m_mainWindow.m_deviceUIs[deviceSetIndex];
int tx = response.getTx();
if ((tx == 0) && (deviceSet->m_deviceSinkEngine))
{
*error.getMessage() = QString("Device type (Rx) and device set type (Tx) mismatch");
return 404;
}
if ((tx != 0) && (deviceSet->m_deviceSourceEngine))
{
*error.getMessage() = QString("Device type (Tx) and device set type (Rx) mismatch");
return 404;
}
if (tx == 0) // Rx
if (deviceSet->m_deviceSourceEngine) // Rx
{
DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource();
return source->webapiSettingsGet(response.getData(), *error.getMessage());
}
else // Tx
else if (deviceSet->m_deviceSinkEngine) // Tx
{
DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink();
return sink->webapiSettingsGet(response.getData(), *error.getMessage());
}
else
{
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{