Web API: implement devicesetDeviceGet (2)

pull/127/head
f4exb 2017-12-04 23:07:30 +01:00
rodzic 7dafae3fa1
commit 3fb4af82e6
5 zmienionych plików z 21 dodań i 16 usunięć

Wyświetl plik

@ -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:

Wyświetl plik

@ -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:

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -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
{