mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-12 10:48:42 -04:00
Channel settings feature feedback: all plugins
This commit is contained in:
@@ -33,7 +33,9 @@
|
||||
#include "dsp/devicesamplesink.h"
|
||||
#include "dsp/hbfilterchainconverter.h"
|
||||
#include "dsp/filerecord.h"
|
||||
#include "feature/feature.h"
|
||||
#include "util/db.h"
|
||||
#include "maincore.h"
|
||||
|
||||
#include "filesourcebaseband.h"
|
||||
|
||||
@@ -261,6 +263,10 @@ void FileSource::applySettings(const FileSourceSettings& settings, bool force)
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
if (m_featuresSettingsFeedback.size() > 0) {
|
||||
featuresSendSettings(reverseAPIKeys, settings, force);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
@@ -498,10 +504,67 @@ void FileSource::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& respon
|
||||
void FileSource::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const FileSourceSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
||||
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
|
||||
|
||||
QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
|
||||
.arg(settings.m_reverseAPIAddress)
|
||||
.arg(settings.m_reverseAPIPort)
|
||||
.arg(settings.m_reverseAPIDeviceIndex)
|
||||
.arg(settings.m_reverseAPIChannelIndex);
|
||||
m_networkRequest.setUrl(QUrl(channelSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer = new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
buffer->write(swgChannelSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
|
||||
// Always use PATCH to avoid passing reverse API settings
|
||||
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
||||
buffer->setParent(reply);
|
||||
|
||||
delete swgChannelSettings;
|
||||
}
|
||||
|
||||
void FileSource::featuresSendSettings(QList<QString>& channelSettingsKeys, const FileSourceSettings& settings, bool force)
|
||||
{
|
||||
QList<Feature*>::iterator it = m_featuresSettingsFeedback.begin();
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
|
||||
for (; it != m_featuresSettingsFeedback.end(); ++it)
|
||||
{
|
||||
if (mainCore->existsFeature(*it))
|
||||
{
|
||||
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
||||
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
|
||||
|
||||
Feature::MsgChannelSettings *msg = Feature::MsgChannelSettings::create(
|
||||
this,
|
||||
channelSettingsKeys,
|
||||
swgChannelSettings,
|
||||
force
|
||||
);
|
||||
|
||||
(*it)->getInputMessageQueue()->push(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_featuresSettingsFeedback.removeOne(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FileSource::webapiFormatChannelSettings(
|
||||
QList<QString>& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
||||
const FileSourceSettings& settings,
|
||||
bool force
|
||||
)
|
||||
{
|
||||
swgChannelSettings->setDirection(1); // single source (Tx)
|
||||
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
|
||||
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
|
||||
swgChannelSettings->setChannelType(new QString("FileSource"));
|
||||
swgChannelSettings->setChannelType(new QString(m_channelId));
|
||||
swgChannelSettings->setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings());
|
||||
SWGSDRangel::SWGFileSourceSettings *swgFileSourceSettings = swgChannelSettings->getFileSourceSettings();
|
||||
|
||||
@@ -525,25 +588,6 @@ void FileSource::webapiReverseSendSettings(QList<QString>& channelSettingsKeys,
|
||||
if (channelSettingsKeys.contains("streamIndex") || force) {
|
||||
swgFileSourceSettings->setStreamIndex(settings.m_streamIndex);
|
||||
}
|
||||
|
||||
QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
|
||||
.arg(settings.m_reverseAPIAddress)
|
||||
.arg(settings.m_reverseAPIPort)
|
||||
.arg(settings.m_reverseAPIDeviceIndex)
|
||||
.arg(settings.m_reverseAPIChannelIndex);
|
||||
m_networkRequest.setUrl(QUrl(channelSettingsURL));
|
||||
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
|
||||
QBuffer *buffer = new QBuffer();
|
||||
buffer->open((QBuffer::ReadWrite));
|
||||
buffer->write(swgChannelSettings->asJson().toUtf8());
|
||||
buffer->seek(0);
|
||||
|
||||
// Always use PATCH to avoid passing reverse API settings
|
||||
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
||||
buffer->setParent(reply);
|
||||
|
||||
delete swgChannelSettings;
|
||||
}
|
||||
|
||||
void FileSource::networkManagerFinished(QNetworkReply *reply)
|
||||
@@ -585,4 +629,4 @@ double FileSource::getMagSq() const
|
||||
uint32_t FileSource::getNumberOfDeviceStreams() const
|
||||
{
|
||||
return m_deviceAPI->getNbSinkStreams();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user