kopia lustrzana https://github.com/f4exb/sdrangel
Server: Web API: implemented /sdrangel/preset DELETE
rodzic
15453b7528
commit
e4678ec70c
|
@ -37,6 +37,7 @@
|
|||
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteInstance, Message)
|
||||
MESSAGE_CLASS_DEFINITION(MainCore::MsgLoadPreset, Message)
|
||||
MESSAGE_CLASS_DEFINITION(MainCore::MsgSavePreset, Message)
|
||||
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeletePreset, Message)
|
||||
MESSAGE_CLASS_DEFINITION(MainCore::MsgAddDeviceSet, Message)
|
||||
MESSAGE_CLASS_DEFINITION(MainCore::MsgRemoveLastDeviceSet, Message)
|
||||
|
||||
|
@ -112,6 +113,14 @@ bool MainCore::handleMessage(const Message& cmd)
|
|||
m_settings.save();
|
||||
return true;
|
||||
}
|
||||
else if (MsgDeletePreset::match(cmd))
|
||||
{
|
||||
MsgDeletePreset& notif = (MsgDeletePreset&) cmd;
|
||||
const Preset *presetToDelete = notif.getPreset();
|
||||
// remove preset from settings
|
||||
m_settings.deletePreset(presetToDelete);
|
||||
return true;
|
||||
}
|
||||
else if (MsgAddDeviceSet::match(cmd))
|
||||
{
|
||||
MsgAddDeviceSet& notif = (MsgAddDeviceSet&) cmd;
|
||||
|
|
|
@ -119,6 +119,26 @@ private:
|
|||
{ }
|
||||
};
|
||||
|
||||
class MsgDeletePreset : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const Preset *getPreset() const { return m_preset; }
|
||||
|
||||
static MsgDeletePreset* create(const Preset *preset)
|
||||
{
|
||||
return new MsgDeletePreset(preset);
|
||||
}
|
||||
|
||||
private:
|
||||
const Preset *m_preset;
|
||||
|
||||
MsgDeletePreset(const Preset *preset) :
|
||||
Message(),
|
||||
m_preset(preset)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgDeleteInstance : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
|
|
|
@ -651,6 +651,34 @@ int WebAPIAdapterSrv::instancePresetPost(
|
|||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instancePresetDelete(
|
||||
SWGSDRangel::SWGPresetIdentifier& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*response.getGroupName(),
|
||||
response.getCenterFrequency(),
|
||||
*response.getName());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
.arg(*response.getGroupName())
|
||||
.arg(response.getCenterFrequency())
|
||||
.arg(*response.getName());
|
||||
return 404;
|
||||
}
|
||||
|
||||
response.setCenterFrequency(selectedPreset->getCenterFrequency());
|
||||
*response.getGroupName() = selectedPreset->getGroup();
|
||||
*response.getType() = selectedPreset->isSourcePreset() ? "R" : "T";
|
||||
*response.getName() = selectedPreset->getDescription();
|
||||
|
||||
MainCore::MsgDeletePreset *msg = MainCore::MsgDeletePreset::create(const_cast<Preset*>(selectedPreset));
|
||||
m_mainCore.m_inputMessageQueue.push(msg);
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceDeviceSetsPost(
|
||||
bool tx,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
|
|
|
@ -113,6 +113,10 @@ public:
|
|||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instancePresetDelete(
|
||||
SWGSDRangel::SWGPresetIdentifier& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDeviceSetsDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
|
Ładowanie…
Reference in New Issue