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/messagequeue.h"
#include "util/export.h" #include "util/export.h"
namespace SWGSDRangel
{
class SWGObject;
}
class SDRANGEL_API DeviceSampleSink : public QObject { class SDRANGEL_API DeviceSampleSink : public QObject {
Q_OBJECT Q_OBJECT
public: public:

View File

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

View File

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

View File

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

View File

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