mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-04 15:04:38 -04:00
REST API: config: GET (3): mechanism to deal with channel settings API formatting without creating a complete channel object. Applied to AM demod
This commit is contained in:
@@ -16,8 +16,17 @@
|
||||
// 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 "plugin/pluginmanager.h"
|
||||
#include "channel/channelapi.h"
|
||||
#include "webapiadapterbase.h"
|
||||
|
||||
WebAPIAdapterBase::WebAPIAdapterBase()
|
||||
{}
|
||||
|
||||
WebAPIAdapterBase::~WebAPIAdapterBase()
|
||||
{}
|
||||
|
||||
void WebAPIAdapterBase::webapiFormatPreferences(
|
||||
SWGSDRangel::SWGPreferences *apiPreferences,
|
||||
const Preferences& preferences
|
||||
@@ -57,6 +66,18 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
||||
QList<SWGSDRangel::SWGChannelConfig *> *swgChannelConfigs = apiPreset->getChannelConfigs();
|
||||
swgChannelConfigs->append(new SWGSDRangel::SWGChannelConfig);
|
||||
swgChannelConfigs->back()->setChannelIdUri(new QString(channelConfig.m_channelIdURI));
|
||||
const QByteArray& channelSettings = channelConfig.m_config;
|
||||
SWGSDRangel::SWGChannelSettings *swgChannelSettings = swgChannelConfigs->back()->getConfig();
|
||||
swgChannelSettings->init();
|
||||
const PluginInterface *pluginInterface = m_pluginManager->getChannelPluginInterface(channelConfig.m_channelIdURI);
|
||||
|
||||
if (pluginInterface) // TODO: optimize by caching web API adapters
|
||||
{
|
||||
ChannelAPI *channelWebAPIAdapter = pluginInterface->createChannelWebAPIAdapter();
|
||||
channelWebAPIAdapter->deserialize(channelSettings);
|
||||
QString errorMessage;
|
||||
channelWebAPIAdapter->webapiSettingsGet(*swgChannelSettings, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
int nbDevices = preset.getDeviceCount();
|
||||
@@ -68,6 +89,9 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
||||
swgdeviceConfigs->back()->setDeviceId(new QString(deviceConfig.m_deviceId));
|
||||
swgdeviceConfigs->back()->setDeviceSerial(new QString(deviceConfig.m_deviceSerial));
|
||||
swgdeviceConfigs->back()->setDeviceSequence(deviceConfig.m_deviceSequence);
|
||||
const QByteArray& deviceSettings = deviceConfig.m_config;
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = swgdeviceConfigs->back()->getConfig();
|
||||
swgDeviceSettings->init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,24 @@
|
||||
#include "settings/preset.h"
|
||||
#include "commands/command.h"
|
||||
|
||||
class PluginManager;
|
||||
|
||||
/**
|
||||
* Adapter between API and objects in sdrbase library
|
||||
*/
|
||||
class SDRBASE_API WebAPIAdapterBase
|
||||
{
|
||||
public:
|
||||
WebAPIAdapterBase();
|
||||
~WebAPIAdapterBase();
|
||||
|
||||
void setPluginManager(const PluginManager *pluginManager) { m_pluginManager = pluginManager; }
|
||||
|
||||
static void webapiFormatPreferences(
|
||||
SWGSDRangel::SWGPreferences *apiPreferences,
|
||||
const Preferences& preferences
|
||||
);
|
||||
static void webapiFormatPreset(
|
||||
void webapiFormatPreset(
|
||||
SWGSDRangel::SWGPreset *apiPreset,
|
||||
const Preset& preset
|
||||
);
|
||||
@@ -45,6 +52,9 @@ public:
|
||||
SWGSDRangel::SWGCommand *apiCommand,
|
||||
const Command& command
|
||||
);
|
||||
|
||||
private:
|
||||
const PluginManager *m_pluginManager;
|
||||
};
|
||||
|
||||
#endif // SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_
|
||||
Reference in New Issue
Block a user