1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-01 13:47:01 -04:00

REST API device and channel actions: extension of record action: implementation

This commit is contained in:
f4exb
2020-03-10 05:23:19 +01:00
parent ba08ff5090
commit 323e75cddd
49 changed files with 995 additions and 3 deletions
@@ -25,7 +25,9 @@
#include "SWGDeviceSettings.h"
#include "SWGDeviceState.h"
#include "SWGDeviceReport.h"
#include "SWGDeviceActions.h"
#include "SWGRemoteInputReport.h"
#include "SWGRemoteInputActions.h"
#include "util/simpleserializer.h"
#include "dsp/dspcommands.h"
@@ -348,6 +350,37 @@ int RemoteInput::webapiSettingsPutPatch(
return 200;
}
int RemoteInput::webapiActionsPost(
const QStringList& deviceActionsKeys,
SWGSDRangel::SWGDeviceActions& query,
QString& errorMessage)
{
SWGSDRangel::SWGRemoteInputActions *swgRemoteInputActions = query.getRemoteInputActions();
if (swgRemoteInputActions)
{
if (deviceActionsKeys.contains("record"))
{
bool record = swgRemoteInputActions->getRecord() != 0;
MsgFileRecord *msg = MsgFileRecord::create(record);
getInputMessageQueue()->push(msg);
if (getMessageQueueToGUI())
{
MsgFileRecord *msgToGUI = MsgFileRecord::create(record);
getMessageQueueToGUI()->push(msgToGUI);
}
}
return 202;
}
else
{
errorMessage = "Missing RemoteInputActions in query";
return 400;
}
}
void RemoteInput::webapiUpdateDeviceSettings(
RemoteInputSettings& settings,
const QStringList& deviceSettingsKeys,
@@ -313,6 +313,11 @@ public:
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
virtual int webapiActionsPost(
const QStringList& deviceActionsKeys,
SWGSDRangel::SWGDeviceActions& actions,
QString& errorMessage);
static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response,
const RemoteInputSettings& settings);
@@ -238,6 +238,23 @@ bool RemoteInputGui::handleMessage(const Message& message)
return true;
}
else if (RemoteInput::MsgFileRecord::match(message)) // API action "record" feedback
{
const RemoteInput::MsgFileRecord& notif = (const RemoteInput::MsgFileRecord&) message;
bool record = notif.getStartStop();
ui->record->blockSignals(true);
ui->record->setChecked(record);
if (record) {
ui->record->setStyleSheet("QToolButton { background-color : red; }");
} else {
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
ui->record->blockSignals(false);
return true;
}
else
{
return false;