1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 01:18:38 -05:00

API: /sdrangel/featureset (POST, DELETE) fully implemented

This commit is contained in:
f4exb 2021-08-21 20:09:57 +02:00
parent d07f7fbb8a
commit e2286cc741
4 changed files with 46 additions and 10 deletions

View File

@ -1408,11 +1408,9 @@ int WebAPIAdapter::instanceDeviceSetDelete(
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
#ifdef SERVER_MODE
if (m_mainCore->m_deviceSets.size() != 0)
#else
if (m_mainCore->m_deviceSets.size() > 1)
#endif
unsigned int minFeatureSets = QCoreApplication::applicationName() == "SDRangelSrv" ? 0 : 1;
if (m_mainCore->m_deviceSets.size() > minFeatureSets)
{
MainCore::MsgRemoveLastDeviceSet *msg = MainCore::MsgRemoveLastDeviceSet::create();
m_mainCore->m_mainMessageQueue->push(msg);
@ -1449,11 +1447,9 @@ int WebAPIAdapter::instanceFeatureSetDelete(
SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error)
{
#ifdef SERVER_MODE
if (m_mainCore->m_featureSets.size() != 0)
#else
if (m_mainCore->m_featureSets.size() > 1)
#endif
unsigned int minFeatureSets = QCoreApplication::applicationName() == "SDRangelSrv" ? 0 : 1;
if (m_mainCore->m_featureSets.size() > minFeatureSets)
{
MainCore::MsgRemoveLastFeatureSet *msg = MainCore::MsgRemoveLastFeatureSet::create();
m_mainCore->m_mainMessageQueue->push(msg);

View File

@ -1086,6 +1086,19 @@ bool MainWindow::handleMessage(const Message& cmd)
return true;
}
else if (MainCore::MsgAddFeatureSet::match(cmd))
{
addFeatureSet();
return true;
}
else if (MainCore::MsgRemoveLastFeatureSet::match(cmd))
{
if (m_mainCore->m_featureSets.size() != 0) {
removeFeatureSet(m_mainCore->m_featureSets.size() - 1);
}
return true;
}
else if (MainCore::MsgAddChannel::match(cmd))
{
MainCore::MsgAddChannel& notif = (MainCore::MsgAddChannel&) cmd;

View File

@ -190,6 +190,19 @@ bool MainServer::handleMessage(const Message& cmd)
}
return true;
}
else if (MainCore::MsgAddFeatureSet::match(cmd))
{
addFeatureSet();
return true;
}
else if (MainCore::MsgRemoveLastFeatureSet::match(cmd))
{
if (m_mainCore->m_featureSets.size() != 0) {
removeFeatureSet(m_mainCore->m_featureSets.size() - 1);
}
return true;
}
else if (MainCore::MsgAddChannel::match(cmd))
{
MainCore::MsgAddChannel& notif = (MainCore::MsgAddChannel&) cmd;
@ -682,6 +695,18 @@ void MainServer::deleteChannel(int deviceSetIndex, int channelIndex)
}
}
void MainServer::addFeatureSet()
{
m_mainCore->appendFeatureSet();
}
void MainServer::removeFeatureSet(unsigned int featureSetIndex)
{
if (featureSetIndex < m_mainCore->m_featureSets.size()) {
m_mainCore->removeFeatureSet(featureSetIndex);
}
}
void MainServer::addFeature(int featureSetIndex, int selectedFeatureIndex)
{
if (featureSetIndex >= 0)

View File

@ -66,6 +66,8 @@ public:
void changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex);
void addChannel(int deviceSetIndex, int selectedChannelIndex);
void deleteChannel(int deviceSetIndex, int channelIndex);
void addFeatureSet();
void removeFeatureSet(unsigned int featureSetIndex);
void addFeature(int featureSetIndex, int selectedFeatureIndex);
void deleteFeature(int featureSetIndex, int featureIndex);