mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-16 15:54:23 -04:00
REST API: config: GET (11). Support of the rest of devices
This commit is contained in:
@@ -4,14 +4,16 @@ set(fileinput_SOURCES
|
||||
fileinput.cpp
|
||||
fileinputplugin.cpp
|
||||
fileinputthread.cpp
|
||||
fileinputsettings.cpp
|
||||
fileinputsettings.cpp
|
||||
fileinputwebapiadapter.cpp
|
||||
)
|
||||
|
||||
set(fileinput_HEADERS
|
||||
fileinput.h
|
||||
fileinputplugin.h
|
||||
fileinputthread.h
|
||||
fileinputsettings.h
|
||||
fileinputsettings.h
|
||||
fileinputwebapiadapter.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
||||
@@ -465,7 +465,26 @@ int FileInput::webapiSettingsPutPatch(
|
||||
{
|
||||
(void) errorMessage;
|
||||
FileInputSettings settings = m_settings;
|
||||
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
|
||||
|
||||
MsgConfigureFileInput *msg = MsgConfigureFileInput::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureFileInput *msgToGUI = MsgConfigureFileInput::create(settings, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
webapiFormatDeviceSettings(response, settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
void FileInput::webapiUpdateDeviceSettings(
|
||||
FileInputSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response)
|
||||
{
|
||||
if (deviceSettingsKeys.contains("fileName")) {
|
||||
settings.m_fileName = *response.getFileInputSettings()->getFileName();
|
||||
}
|
||||
@@ -487,18 +506,6 @@ int FileInput::webapiSettingsPutPatch(
|
||||
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
||||
settings.m_reverseAPIDeviceIndex = response.getFileInputSettings()->getReverseApiDeviceIndex();
|
||||
}
|
||||
|
||||
MsgConfigureFileInput *msg = MsgConfigureFileInput::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureFileInput *msgToGUI = MsgConfigureFileInput::create(settings, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
webapiFormatDeviceSettings(response, settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileInput::webapiRunGet(
|
||||
|
||||
@@ -319,6 +319,15 @@ public:
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage);
|
||||
|
||||
static void webapiFormatDeviceSettings(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const FileInputSettings& settings);
|
||||
|
||||
static void webapiUpdateDeviceSettings(
|
||||
FileInputSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response);
|
||||
|
||||
private:
|
||||
DeviceAPI *m_deviceAPI;
|
||||
QMutex m_mutex;
|
||||
@@ -339,7 +348,6 @@ public:
|
||||
void openFileStream();
|
||||
void seekFileStream(int seekMillis);
|
||||
bool applySettings(const FileInputSettings& settings, bool force = false);
|
||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FileInputSettings& settings);
|
||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FileInputSettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
@@ -26,10 +26,11 @@
|
||||
#include "fileinputgui.h"
|
||||
#endif
|
||||
#include "fileinputplugin.h"
|
||||
#include "fileinputwebapiadapter.h"
|
||||
|
||||
const PluginDescriptor FileInputPlugin::m_pluginDescriptor = {
|
||||
QString("File device input"),
|
||||
QString("4.11.0"),
|
||||
QString("4.11.6"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
@@ -115,3 +116,7 @@ DeviceSampleSource *FileInputPlugin::createSampleSourcePluginInstance(const QStr
|
||||
}
|
||||
}
|
||||
|
||||
DeviceWebAPIAdapter *FileInputPlugin::createDeviceWebAPIAdapter() const
|
||||
{
|
||||
return new FileInputWebAPIAdapter();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
QWidget **widget,
|
||||
DeviceUISet *deviceUISet);
|
||||
virtual DeviceSampleSource* createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI);
|
||||
virtual DeviceWebAPIAdapter* createDeviceWebAPIAdapter() const;
|
||||
|
||||
static const QString m_hardwareID;
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// Implementation of static web API adapters used for preset serialization and //
|
||||
// deserialization //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "fileinput.h"
|
||||
#include "fileinputwebapiadapter.h"
|
||||
|
||||
FileInputWebAPIAdapter::FileInputWebAPIAdapter()
|
||||
{}
|
||||
|
||||
FileInputWebAPIAdapter::~FileInputWebAPIAdapter()
|
||||
{}
|
||||
|
||||
int FileInputWebAPIAdapter::webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings());
|
||||
response.getAirspyHfSettings()->init();
|
||||
FileInput::webapiFormatDeviceSettings(response, m_settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileInputWebAPIAdapter::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
FileInput::webapiUpdateDeviceSettings(m_settings, deviceSettingsKeys, response);
|
||||
return 200;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
||||
// //
|
||||
// Implementation of static web API adapters used for preset serialization and //
|
||||
// deserialization //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "device/devicewebapiadapter.h"
|
||||
#include "fileinputsettings.h"
|
||||
|
||||
class FileInputWebAPIAdapter : public DeviceWebAPIAdapter
|
||||
{
|
||||
public:
|
||||
FileInputWebAPIAdapter();
|
||||
virtual ~FileInputWebAPIAdapter();
|
||||
virtual QByteArray serialize() { return m_settings.serialize(); }
|
||||
virtual bool deserialize(const QByteArray& data) { return m_settings.deserialize(data); }
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage);
|
||||
|
||||
private:
|
||||
FileInputSettings m_settings;
|
||||
};
|
||||
Reference in New Issue
Block a user