From 9610a6b93a0695348455ae8dc82fdc031ff70a4c Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 2 Aug 2019 13:14:59 +0200 Subject: [PATCH] REST API: config (7): preset channel Tx adapters where there is no CW keyer --- plugins/channeltx/filesource/CMakeLists.txt | 6 +- .../channeltx/filesource/filesourceplugin.cpp | 9 ++- .../channeltx/filesource/filesourceplugin.h | 1 + .../filesource/filesourcewebapiadapter.cpp | 51 +++++++++++++++ .../filesource/filesourcewebapiadapter.h | 65 +++++++++++++++++++ plugins/channeltx/localsource/CMakeLists.txt | 6 +- .../localsource/localsourceplugin.cpp | 9 ++- .../channeltx/localsource/localsourceplugin.h | 1 + .../localsource/localsourcewebapiadapter.cpp | 51 +++++++++++++++ .../localsource/localsourcewebapiadapter.h | 65 +++++++++++++++++++ plugins/channeltx/modatv/CMakeLists.txt | 6 +- plugins/channeltx/modatv/atvmodplugin.cpp | 9 ++- plugins/channeltx/modatv/atvmodplugin.h | 1 + .../channeltx/modatv/atvmodwebapiadapter.cpp | 51 +++++++++++++++ .../channeltx/modatv/atvmodwebapiadapter.h | 65 +++++++++++++++++++ plugins/channeltx/remotesource/CMakeLists.txt | 6 +- .../remotesource/remotesourceplugin.cpp | 9 ++- .../remotesource/remotesourceplugin.h | 1 + .../remotesourcewebapiadapter.cpp | 51 +++++++++++++++ .../remotesource/remotesourcewebapiadapter.h | 65 +++++++++++++++++++ plugins/channeltx/udpsource/CMakeLists.txt | 6 +- .../channeltx/udpsource/udpsourceplugin.cpp | 9 ++- plugins/channeltx/udpsource/udpsourceplugin.h | 1 + .../udpsource/udpsourcewebapiadapter.cpp | 51 +++++++++++++++ .../udpsource/udpsourcewebapiadapter.h | 65 +++++++++++++++++++ 25 files changed, 638 insertions(+), 22 deletions(-) create mode 100644 plugins/channeltx/filesource/filesourcewebapiadapter.cpp create mode 100644 plugins/channeltx/filesource/filesourcewebapiadapter.h create mode 100644 plugins/channeltx/localsource/localsourcewebapiadapter.cpp create mode 100644 plugins/channeltx/localsource/localsourcewebapiadapter.h create mode 100644 plugins/channeltx/modatv/atvmodwebapiadapter.cpp create mode 100644 plugins/channeltx/modatv/atvmodwebapiadapter.h create mode 100644 plugins/channeltx/remotesource/remotesourcewebapiadapter.cpp create mode 100644 plugins/channeltx/remotesource/remotesourcewebapiadapter.h create mode 100644 plugins/channeltx/udpsource/udpsourcewebapiadapter.cpp create mode 100644 plugins/channeltx/udpsource/udpsourcewebapiadapter.h diff --git a/plugins/channeltx/filesource/CMakeLists.txt b/plugins/channeltx/filesource/CMakeLists.txt index 6d6db7390..746cad56d 100644 --- a/plugins/channeltx/filesource/CMakeLists.txt +++ b/plugins/channeltx/filesource/CMakeLists.txt @@ -12,13 +12,15 @@ endif() set(filesource_SOURCES filesource.cpp filesourceplugin.cpp - filesourcesettings.cpp + filesourcesettings.cpp + filesourcewebapiadapter.cpp ) set(filesource_HEADERS filesource.h filesourceplugin.h - filesourcesettings.h + filesourcesettings.h + filesourcewebapiadapter.h ) include_directories( diff --git a/plugins/channeltx/filesource/filesourceplugin.cpp b/plugins/channeltx/filesource/filesourceplugin.cpp index ea5e81467..3eb7de6a3 100644 --- a/plugins/channeltx/filesource/filesourceplugin.cpp +++ b/plugins/channeltx/filesource/filesourceplugin.cpp @@ -22,11 +22,12 @@ #include "filesourcegui.h" #endif #include "filesource.h" +#include "filesourcewebapiadapter.h" #include "filesourceplugin.h" const PluginDescriptor FileSourcePlugin::m_pluginDescriptor = { QString("File channel source"), - QString("4.11.0"), + QString("4.11.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, @@ -76,5 +77,7 @@ ChannelAPI* FileSourcePlugin::createTxChannelCS(DeviceAPI *deviceAPI) const return new FileSource(deviceAPI); } - - +ChannelAPI* FileSourcePlugin::createChannelWebAPIAdapter() const +{ + return new FileSourceWebAPIAdapter(); +} diff --git a/plugins/channeltx/filesource/filesourceplugin.h b/plugins/channeltx/filesource/filesourceplugin.h index a74b58034..1a6b1d166 100644 --- a/plugins/channeltx/filesource/filesourceplugin.h +++ b/plugins/channeltx/filesource/filesourceplugin.h @@ -38,6 +38,7 @@ public: virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const; virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const; virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const; + virtual ChannelAPI* createChannelWebAPIAdapter() const; private: static const PluginDescriptor m_pluginDescriptor; diff --git a/plugins/channeltx/filesource/filesourcewebapiadapter.cpp b/plugins/channeltx/filesource/filesourcewebapiadapter.cpp new file mode 100644 index 000000000..b76f1d60b --- /dev/null +++ b/plugins/channeltx/filesource/filesourcewebapiadapter.cpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "SWGChannelSettings.h" +#include "filesource.h" +#include "filesourcewebapiadapter.h" + +FileSourceWebAPIAdapter::FileSourceWebAPIAdapter() : + ChannelAPI(FileSource::m_channelIdURI, ChannelAPI::StreamSingleSource) +{} + +FileSourceWebAPIAdapter::~FileSourceWebAPIAdapter() +{} + +int FileSourceWebAPIAdapter::webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + response.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings()); + response.getFileSourceSettings()->init(); + FileSource::webapiFormatChannelSettings(response, m_settings); + + return 200; +} + +int FileSourceWebAPIAdapter::webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + FileSource::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response); + + return 200; +} diff --git a/plugins/channeltx/filesource/filesourcewebapiadapter.h b/plugins/channeltx/filesource/filesourcewebapiadapter.h new file mode 100644 index 000000000..1615c9ace --- /dev/null +++ b/plugins/channeltx/filesource/filesourcewebapiadapter.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_FILESOURCE_WEBAPIADAPTER_H +#define INCLUDE_FILESOURCE_WEBAPIADAPTER_H + +#include "channel/channelapi.h" +#include "filesourcesettings.h" + +/** + * Standalone API adapter only for the settings + */ +class FileSourceWebAPIAdapter : public ChannelAPI { +public: + FileSourceWebAPIAdapter(); + virtual ~FileSourceWebAPIAdapter(); + + // unused pure virtual methods + virtual void destroy() {} + virtual void getIdentifier(QString& id) {} + virtual void getTitle(QString& title) {} + virtual qint64 getCenterFrequency() const { return 0; } + virtual int getNbSinkStreams() const { return 1; } + virtual int getNbSourceStreams() const { return 0; } + + virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const + { + (void) streamIndex; + (void) sinkElseSource; + return 0; + } + + // virtual methods actually implemented + virtual QByteArray serialize() const { return m_settings.serialize(); } + virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); } + + virtual int webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + + virtual int webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + +private: + FileSourceSettings m_settings; +}; + +#endif // INCLUDE_FILESOURCE_WEBAPIADAPTER_H diff --git a/plugins/channeltx/localsource/CMakeLists.txt b/plugins/channeltx/localsource/CMakeLists.txt index 68be3ac18..176c14f60 100644 --- a/plugins/channeltx/localsource/CMakeLists.txt +++ b/plugins/channeltx/localsource/CMakeLists.txt @@ -4,14 +4,16 @@ set(localsource_SOURCES localsource.cpp localsourcethread.cpp localsourceplugin.cpp - localsourcesettings.cpp + localsourcesettings.cpp + localsourcewebapiadapter.cpp ) set(localsource_HEADERS localsource.h localsourcethread.h localsourceplugin.h - localsourcesettings.h + localsourcesettings.h + localsourcewebapiadapter.h ) include_directories( diff --git a/plugins/channeltx/localsource/localsourceplugin.cpp b/plugins/channeltx/localsource/localsourceplugin.cpp index 4db49bfc6..400f9b0bd 100644 --- a/plugins/channeltx/localsource/localsourceplugin.cpp +++ b/plugins/channeltx/localsource/localsourceplugin.cpp @@ -24,10 +24,12 @@ #include "localsourcegui.h" #endif #include "localsource.h" +#include "localsourcewebapiadapter.h" +#include "localsourceplugin.h" const PluginDescriptor LocalSourcePlugin::m_pluginDescriptor = { QString("Local channel source"), - QString("4.8.0"), + QString("4.11.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, @@ -76,3 +78,8 @@ ChannelAPI* LocalSourcePlugin::createTxChannelCS(DeviceAPI *deviceAPI) const { return new LocalSource(deviceAPI); } + +ChannelAPI* LocalSourcePlugin::createChannelWebAPIAdapter() const +{ + return new LocalSourceWebAPIAdapter(); +} diff --git a/plugins/channeltx/localsource/localsourceplugin.h b/plugins/channeltx/localsource/localsourceplugin.h index 9f49f2ad7..ef0fdcc99 100644 --- a/plugins/channeltx/localsource/localsourceplugin.h +++ b/plugins/channeltx/localsource/localsourceplugin.h @@ -39,6 +39,7 @@ public: virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const; virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const; virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const; + virtual ChannelAPI* createChannelWebAPIAdapter() const; private: static const PluginDescriptor m_pluginDescriptor; diff --git a/plugins/channeltx/localsource/localsourcewebapiadapter.cpp b/plugins/channeltx/localsource/localsourcewebapiadapter.cpp new file mode 100644 index 000000000..34417f57c --- /dev/null +++ b/plugins/channeltx/localsource/localsourcewebapiadapter.cpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "SWGChannelSettings.h" +#include "localsource.h" +#include "localsourcewebapiadapter.h" + +LocalSourceWebAPIAdapter::LocalSourceWebAPIAdapter() : + ChannelAPI(LocalSource::m_channelIdURI, ChannelAPI::StreamSingleSource) +{} + +LocalSourceWebAPIAdapter::~LocalSourceWebAPIAdapter() +{} + +int LocalSourceWebAPIAdapter::webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + response.setLocalSourceSettings(new SWGSDRangel::SWGLocalSourceSettings()); + response.getLocalSourceSettings()->init(); + LocalSource::webapiFormatChannelSettings(response, m_settings); + + return 200; +} + +int LocalSourceWebAPIAdapter::webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + LocalSource::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response); + + return 200; +} diff --git a/plugins/channeltx/localsource/localsourcewebapiadapter.h b/plugins/channeltx/localsource/localsourcewebapiadapter.h new file mode 100644 index 000000000..ec5e84ac2 --- /dev/null +++ b/plugins/channeltx/localsource/localsourcewebapiadapter.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_LOCALSOURCE_WEBAPIADAPTER_H +#define INCLUDE_LOCALSOURCE_WEBAPIADAPTER_H + +#include "channel/channelapi.h" +#include "localsourcesettings.h" + +/** + * Standalone API adapter only for the settings + */ +class LocalSourceWebAPIAdapter : public ChannelAPI { +public: + LocalSourceWebAPIAdapter(); + virtual ~LocalSourceWebAPIAdapter(); + + // unused pure virtual methods + virtual void destroy() {} + virtual void getIdentifier(QString& id) {} + virtual void getTitle(QString& title) {} + virtual qint64 getCenterFrequency() const { return 0; } + virtual int getNbSinkStreams() const { return 1; } + virtual int getNbSourceStreams() const { return 0; } + + virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const + { + (void) streamIndex; + (void) sinkElseSource; + return 0; + } + + // virtual methods actually implemented + virtual QByteArray serialize() const { return m_settings.serialize(); } + virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); } + + virtual int webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + + virtual int webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + +private: + LocalSourceSettings m_settings; +}; + +#endif // INCLUDE_LOCALSOURCE_WEBAPIADAPTER_H diff --git a/plugins/channeltx/modatv/CMakeLists.txt b/plugins/channeltx/modatv/CMakeLists.txt index c5f5b6635..0c1eab90e 100644 --- a/plugins/channeltx/modatv/CMakeLists.txt +++ b/plugins/channeltx/modatv/CMakeLists.txt @@ -3,13 +3,15 @@ project(modatv) set(modatv_SOURCES atvmod.cpp atvmodplugin.cpp - atvmodsettings.cpp + atvmodsettings.cpp + atvmodwebapiadapter.cpp ) set(modatv_HEADERS atvmod.h atvmodplugin.h - atvmodsettings.h + atvmodsettings.h + atvmodwebapiadapter.h ) include_directories( diff --git a/plugins/channeltx/modatv/atvmodplugin.cpp b/plugins/channeltx/modatv/atvmodplugin.cpp index 5c2ac6361..2d876cfb7 100644 --- a/plugins/channeltx/modatv/atvmodplugin.cpp +++ b/plugins/channeltx/modatv/atvmodplugin.cpp @@ -22,11 +22,12 @@ #include "atvmodgui.h" #endif #include "atvmod.h" +#include "atvmodwebapiadapter.h" #include "atvmodplugin.h" const PluginDescriptor ATVModPlugin::m_pluginDescriptor = { QString("ATV Modulator"), - QString("4.5.2"), + QString("4.11.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, @@ -76,5 +77,7 @@ ChannelAPI* ATVModPlugin::createTxChannelCS(DeviceAPI *deviceAPI) const return new ATVMod(deviceAPI); } - - +ChannelAPI* ATVModPlugin::createChannelWebAPIAdapter() const +{ + return new ATVModWebAPIAdapter(); +} diff --git a/plugins/channeltx/modatv/atvmodplugin.h b/plugins/channeltx/modatv/atvmodplugin.h index 1d37c658a..fc78c26fe 100644 --- a/plugins/channeltx/modatv/atvmodplugin.h +++ b/plugins/channeltx/modatv/atvmodplugin.h @@ -38,6 +38,7 @@ public: virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const; virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const; virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const; + virtual ChannelAPI* createChannelWebAPIAdapter() const; private: static const PluginDescriptor m_pluginDescriptor; diff --git a/plugins/channeltx/modatv/atvmodwebapiadapter.cpp b/plugins/channeltx/modatv/atvmodwebapiadapter.cpp new file mode 100644 index 000000000..7fe2ea355 --- /dev/null +++ b/plugins/channeltx/modatv/atvmodwebapiadapter.cpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "SWGChannelSettings.h" +#include "atvmod.h" +#include "atvmodwebapiadapter.h" + +ATVModWebAPIAdapter::ATVModWebAPIAdapter() : + ChannelAPI(ATVMod::m_channelIdURI, ChannelAPI::StreamSingleSource) +{} + +ATVModWebAPIAdapter::~ATVModWebAPIAdapter() +{} + +int ATVModWebAPIAdapter::webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + response.setAtvModSettings(new SWGSDRangel::SWGATVModSettings()); + response.getAtvModSettings()->init(); + ATVMod::webapiFormatChannelSettings(response, m_settings); + + return 200; +} + +int ATVModWebAPIAdapter::webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + ATVMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response); + + return 200; +} diff --git a/plugins/channeltx/modatv/atvmodwebapiadapter.h b/plugins/channeltx/modatv/atvmodwebapiadapter.h new file mode 100644 index 000000000..4e4829164 --- /dev/null +++ b/plugins/channeltx/modatv/atvmodwebapiadapter.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_ATVMOD_WEBAPIADAPTER_H +#define INCLUDE_ATVMOD_WEBAPIADAPTER_H + +#include "channel/channelapi.h" +#include "atvmodsettings.h" + +/** + * Standalone API adapter only for the settings + */ +class ATVModWebAPIAdapter : public ChannelAPI { +public: + ATVModWebAPIAdapter(); + virtual ~ATVModWebAPIAdapter(); + + // unused pure virtual methods + virtual void destroy() {} + virtual void getIdentifier(QString& id) {} + virtual void getTitle(QString& title) {} + virtual qint64 getCenterFrequency() const { return 0; } + virtual int getNbSinkStreams() const { return 1; } + virtual int getNbSourceStreams() const { return 0; } + + virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const + { + (void) streamIndex; + (void) sinkElseSource; + return 0; + } + + // virtual methods actually implemented + virtual QByteArray serialize() const { return m_settings.serialize(); } + virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); } + + virtual int webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + + virtual int webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + +private: + ATVModSettings m_settings; +}; + +#endif // INCLUDE_ATVMOD_WEBAPIADAPTER_H diff --git a/plugins/channeltx/remotesource/CMakeLists.txt b/plugins/channeltx/remotesource/CMakeLists.txt index 3007c7b64..5533824db 100644 --- a/plugins/channeltx/remotesource/CMakeLists.txt +++ b/plugins/channeltx/remotesource/CMakeLists.txt @@ -13,14 +13,16 @@ set(remotesource_SOURCES remotesource.cpp remotesourcethread.cpp remotesourceplugin.cpp - remotesourcesettings.cpp + remotesourcesettings.cpp + remotesourcewebapiadapter.cpp ) set(remotesource_HEADERS remotesource.h remotesourcethread.h remotesourceplugin.h - remotesourcesettings.h + remotesourcesettings.h + remotesourcewebapiadapter.cpp ) include_directories( diff --git a/plugins/channeltx/remotesource/remotesourceplugin.cpp b/plugins/channeltx/remotesource/remotesourceplugin.cpp index 9cdb2dbcf..f8f2ad8bd 100644 --- a/plugins/channeltx/remotesource/remotesourceplugin.cpp +++ b/plugins/channeltx/remotesource/remotesourceplugin.cpp @@ -22,11 +22,12 @@ #include "remotesourcegui.h" #endif #include "remotesource.h" +#include "remotesourcewebapiadapter.h" #include "remotesourceplugin.h" const PluginDescriptor RemoteSourcePlugin::m_pluginDescriptor = { QString("Remote channel source"), - QString("4.5.2"), + QString("4.11.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, @@ -76,5 +77,7 @@ ChannelAPI* RemoteSourcePlugin::createTxChannelCS(DeviceAPI *deviceAPI) const return new RemoteSource(deviceAPI); } - - +ChannelAPI* RemoteSourcePlugin::createChannelWebAPIAdapter() const +{ + return new RemoteSourceWebAPIAdapter(); +} diff --git a/plugins/channeltx/remotesource/remotesourceplugin.h b/plugins/channeltx/remotesource/remotesourceplugin.h index 75fece053..4595afac4 100644 --- a/plugins/channeltx/remotesource/remotesourceplugin.h +++ b/plugins/channeltx/remotesource/remotesourceplugin.h @@ -38,6 +38,7 @@ public: virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const; virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const; virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const; + virtual ChannelAPI* createChannelWebAPIAdapter() const; private: static const PluginDescriptor m_pluginDescriptor; diff --git a/plugins/channeltx/remotesource/remotesourcewebapiadapter.cpp b/plugins/channeltx/remotesource/remotesourcewebapiadapter.cpp new file mode 100644 index 000000000..9ba5f977d --- /dev/null +++ b/plugins/channeltx/remotesource/remotesourcewebapiadapter.cpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "SWGChannelSettings.h" +#include "remotesource.h" +#include "remotesourcewebapiadapter.h" + +RemoteSourceWebAPIAdapter::RemoteSourceWebAPIAdapter() : + ChannelAPI(RemoteSource::m_channelIdURI, ChannelAPI::StreamSingleSource) +{} + +RemoteSourceWebAPIAdapter::~RemoteSourceWebAPIAdapter() +{} + +int RemoteSourceWebAPIAdapter::webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + response.setRemoteSourceSettings(new SWGSDRangel::SWGRemoteSourceSettings()); + response.getRemoteSourceSettings()->init(); + RemoteSource::webapiFormatChannelSettings(response, m_settings); + + return 200; +} + +int RemoteSourceWebAPIAdapter::webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + RemoteSource::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response); + + return 200; +} diff --git a/plugins/channeltx/remotesource/remotesourcewebapiadapter.h b/plugins/channeltx/remotesource/remotesourcewebapiadapter.h new file mode 100644 index 000000000..768d3a763 --- /dev/null +++ b/plugins/channeltx/remotesource/remotesourcewebapiadapter.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_REMOTESOURCE_WEBAPIADAPTER_H +#define INCLUDE_REMOTESOURCE_WEBAPIADAPTER_H + +#include "channel/channelapi.h" +#include "remotesourcesettings.h" + +/** + * Standalone API adapter only for the settings + */ +class RemoteSourceWebAPIAdapter : public ChannelAPI { +public: + RemoteSourceWebAPIAdapter(); + virtual ~RemoteSourceWebAPIAdapter(); + + // unused pure virtual methods + virtual void destroy() {} + virtual void getIdentifier(QString& id) {} + virtual void getTitle(QString& title) {} + virtual qint64 getCenterFrequency() const { return 0; } + virtual int getNbSinkStreams() const { return 1; } + virtual int getNbSourceStreams() const { return 0; } + + virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const + { + (void) streamIndex; + (void) sinkElseSource; + return 0; + } + + // virtual methods actually implemented + virtual QByteArray serialize() const { return m_settings.serialize(); } + virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); } + + virtual int webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + + virtual int webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + +private: + RemoteSourceSettings m_settings; +}; + +#endif // INCLUDE_REMOTESOURCE_WEBAPIADAPTER_H diff --git a/plugins/channeltx/udpsource/CMakeLists.txt b/plugins/channeltx/udpsource/CMakeLists.txt index edb726b8e..e9a5e1558 100644 --- a/plugins/channeltx/udpsource/CMakeLists.txt +++ b/plugins/channeltx/udpsource/CMakeLists.txt @@ -5,7 +5,8 @@ set(udpsource_SOURCES udpsourceplugin.cpp udpsourceudphandler.cpp udpsourcemsg.cpp - udpsourcesettings.cpp + udpsourcesettings.cpp + udpsourcewebapiadapter.cpp ) set(udpsource_HEADERS @@ -13,7 +14,8 @@ set(udpsource_HEADERS udpsourceplugin.h udpsourceudphandler.h udpsourcemsg.h - udpsourcesettings.h + udpsourcesettings.h + udpsourcewebapiadapter.h ) include_directories( diff --git a/plugins/channeltx/udpsource/udpsourceplugin.cpp b/plugins/channeltx/udpsource/udpsourceplugin.cpp index 95bb0bac4..0396e229d 100644 --- a/plugins/channeltx/udpsource/udpsourceplugin.cpp +++ b/plugins/channeltx/udpsource/udpsourceplugin.cpp @@ -25,10 +25,12 @@ #include "udpsourcegui.h" #endif #include "udpsource.h" +#include "udpsourcewebapiadapter.h" +#include "udpsourceplugin.h" const PluginDescriptor UDPSourcePlugin::m_pluginDescriptor = { QString("UDP Channel Source"), - QString("4.5.2"), + QString("4.11.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, @@ -78,4 +80,7 @@ ChannelAPI* UDPSourcePlugin::createTxChannelCS(DeviceAPI *deviceAPI) const return new UDPSource(deviceAPI); } - +ChannelAPI* UDPSourcePlugin::createChannelWebAPIAdapter() const +{ + return new UDPSourceWebAPIAdapter(); +} diff --git a/plugins/channeltx/udpsource/udpsourceplugin.h b/plugins/channeltx/udpsource/udpsourceplugin.h index 54fe91276..772dee99c 100644 --- a/plugins/channeltx/udpsource/udpsourceplugin.h +++ b/plugins/channeltx/udpsource/udpsourceplugin.h @@ -39,6 +39,7 @@ public: virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const; virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const; virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const; + virtual ChannelAPI* createChannelWebAPIAdapter() const; private: static const PluginDescriptor m_pluginDescriptor; diff --git a/plugins/channeltx/udpsource/udpsourcewebapiadapter.cpp b/plugins/channeltx/udpsource/udpsourcewebapiadapter.cpp new file mode 100644 index 000000000..b1905fc5e --- /dev/null +++ b/plugins/channeltx/udpsource/udpsourcewebapiadapter.cpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "SWGChannelSettings.h" +#include "udpsource.h" +#include "udpsourcewebapiadapter.h" + +UDPSourceWebAPIAdapter::UDPSourceWebAPIAdapter() : + ChannelAPI(UDPSource::m_channelIdURI, ChannelAPI::StreamSingleSource) +{} + +UDPSourceWebAPIAdapter::~UDPSourceWebAPIAdapter() +{} + +int UDPSourceWebAPIAdapter::webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + response.setUdpSourceSettings(new SWGSDRangel::SWGUDPSourceSettings()); + response.getUdpSourceSettings()->init(); + UDPSource::webapiFormatChannelSettings(response, m_settings); + + return 200; +} + +int UDPSourceWebAPIAdapter::webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) +{ + (void) errorMessage; + UDPSource::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response); + + return 200; +} diff --git a/plugins/channeltx/udpsource/udpsourcewebapiadapter.h b/plugins/channeltx/udpsource/udpsourcewebapiadapter.h new file mode 100644 index 000000000..1919379de --- /dev/null +++ b/plugins/channeltx/udpsource/udpsourcewebapiadapter.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2019 Edouard Griffiths, F4EXB. // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_UDPSOURCE_WEBAPIADAPTER_H +#define INCLUDE_UDPSOURCE_WEBAPIADAPTER_H + +#include "channel/channelapi.h" +#include "udpsourcesettings.h" + +/** + * Standalone API adapter only for the settings + */ +class UDPSourceWebAPIAdapter : public ChannelAPI { +public: + UDPSourceWebAPIAdapter(); + virtual ~UDPSourceWebAPIAdapter(); + + // unused pure virtual methods + virtual void destroy() {} + virtual void getIdentifier(QString& id) {} + virtual void getTitle(QString& title) {} + virtual qint64 getCenterFrequency() const { return 0; } + virtual int getNbSinkStreams() const { return 1; } + virtual int getNbSourceStreams() const { return 0; } + + virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const + { + (void) streamIndex; + (void) sinkElseSource; + return 0; + } + + // virtual methods actually implemented + virtual QByteArray serialize() const { return m_settings.serialize(); } + virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); } + + virtual int webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + + virtual int webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage); + +private: + UDPSourceSettings m_settings; +}; + +#endif // INCLUDE_UDPSOURCE_WEBAPIADAPTER_H