mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
REST API: config: GET (3) added commands and removed usless friend class
This commit is contained in:
parent
b95fa98e5a
commit
8ce4788b55
@ -37,8 +37,6 @@ public:
|
||||
bool getUseLogFile() const { return m_useLogFile; }
|
||||
const QString& getLogFileName() const { return m_logFileName; }
|
||||
|
||||
friend class WebAPIAdapterBase;
|
||||
|
||||
protected:
|
||||
QString m_sourceDevice; //!< Identification of the source used in R0 tab (GUI flavor) at startup
|
||||
int m_sourceIndex; //!< Index of the source used in R0 tab (GUI flavor) at startup
|
||||
|
@ -77,6 +77,9 @@ public:
|
||||
void setSpectrumConfig(const QByteArray& data) { m_spectrumConfig = data; }
|
||||
const QByteArray& getSpectrumConfig() const { return m_spectrumConfig; }
|
||||
|
||||
bool hasDCOffsetCorrection() const { return m_dcOffsetCorrection; }
|
||||
bool hasIQImbalanceCorrection() const { return m_iqImbalanceCorrection; }
|
||||
|
||||
void setLayout(const QByteArray& data) { m_layout = data; }
|
||||
const QByteArray& getLayout() const { return m_layout; }
|
||||
|
||||
@ -117,8 +120,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
friend class WebAPIAdapterBase;
|
||||
|
||||
protected:
|
||||
bool m_sourcePreset;
|
||||
|
||||
|
@ -24,16 +24,16 @@ void WebAPIAdapterBase::webapiFormatPreferences(
|
||||
)
|
||||
{
|
||||
apiPreferences->init();
|
||||
apiPreferences->setSourceDevice(new QString(preferences.m_sourceDevice));
|
||||
apiPreferences->setSourceIndex(preferences.m_sourceIndex);
|
||||
apiPreferences->setAudioType(new QString(preferences.m_audioType));
|
||||
apiPreferences->setAudioDevice(new QString(preferences.m_audioDevice));
|
||||
apiPreferences->setLatitude(preferences.m_latitude);
|
||||
apiPreferences->setLongitude(preferences.m_longitude);
|
||||
apiPreferences->setConsoleMinLogLevel((int) preferences.m_consoleMinLogLevel);
|
||||
apiPreferences->setUseLogFile(preferences.m_useLogFile ? 1 : 0);
|
||||
apiPreferences->setLogFileName(new QString(preferences.m_logFileName));
|
||||
apiPreferences->setFileMinLogLevel((int) preferences.m_fileMinLogLevel);
|
||||
apiPreferences->setSourceDevice(new QString(preferences.getSourceDevice()));
|
||||
apiPreferences->setSourceIndex(preferences.getSourceIndex());
|
||||
apiPreferences->setAudioType(new QString(preferences.getAudioType()));
|
||||
apiPreferences->setAudioDevice(new QString(preferences.getAudioDevice()));
|
||||
apiPreferences->setLatitude(preferences.getLatitude());
|
||||
apiPreferences->setLongitude(preferences.getLongitude());
|
||||
apiPreferences->setConsoleMinLogLevel((int) preferences.getConsoleMinLogLevel());
|
||||
apiPreferences->setUseLogFile(preferences.getUseLogFile() ? 1 : 0);
|
||||
apiPreferences->setLogFileName(new QString(preferences.getLogFileName()));
|
||||
apiPreferences->setFileMinLogLevel((int) preferences.getFileMinLogLevel());
|
||||
}
|
||||
|
||||
void WebAPIAdapterBase::webapiFormatPreset(
|
||||
@ -42,13 +42,13 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
||||
)
|
||||
{
|
||||
apiPreset->init();
|
||||
apiPreset->setSourcePreset(preset.m_sourcePreset ? 1 : 0);
|
||||
apiPreset->setGroup(new QString(preset.m_group));
|
||||
apiPreset->setDescription(new QString(preset.m_description));
|
||||
apiPreset->setCenterFrequency(preset.m_centerFrequency);
|
||||
apiPreset->setSourcePreset(preset.isSourcePreset() ? 1 : 0);
|
||||
apiPreset->setGroup(new QString(preset.getGroup()));
|
||||
apiPreset->setDescription(new QString(preset.getDescription()));
|
||||
apiPreset->setCenterFrequency(preset.getCenterFrequency());
|
||||
apiPreset->getSpectrumConfig()->init(); // TODO when spectrum config is extracted to sdrbase
|
||||
apiPreset->setDcOffsetCorrection(preset.m_dcOffsetCorrection ? 1 : 0);
|
||||
apiPreset->setIqImbalanceCorrection(preset.m_iqImbalanceCorrection ? 1 : 0);
|
||||
apiPreset->setDcOffsetCorrection(preset.hasDCOffsetCorrection() ? 1 : 0);
|
||||
apiPreset->setIqImbalanceCorrection(preset.hasIQImbalanceCorrection() ? 1 : 0);
|
||||
|
||||
int nbChannels = preset.getChannelCount();
|
||||
for (int i = 0; i < nbChannels; i++)
|
||||
@ -70,3 +70,19 @@ void WebAPIAdapterBase::webapiFormatPreset(
|
||||
swgdeviceConfigs->back()->setDeviceSequence(deviceConfig.m_deviceSequence);
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIAdapterBase::webapiFormatCommand(
|
||||
SWGSDRangel::SWGCommand *apiCommand,
|
||||
const Command& command
|
||||
)
|
||||
{
|
||||
apiCommand->init();
|
||||
apiCommand->setGroup(new QString(command.getGroup()));
|
||||
apiCommand->setDescription(new QString(command.getDescription()));
|
||||
apiCommand->setCommand(new QString(command.getCommand()));
|
||||
apiCommand->setArgString(new QString(command.getArgString()));
|
||||
apiCommand->setKey((int) command.getKey());
|
||||
apiCommand->setKeyModifiers((int) command.getKeyModifiers());
|
||||
apiCommand->setAssociateKey(command.getAssociateKey() ? 1 : 0);
|
||||
apiCommand->setRelease(command.getRelease() ? 1 : 0);
|
||||
}
|
@ -22,8 +22,10 @@
|
||||
#include "export.h"
|
||||
#include "SWGPreferences.h"
|
||||
#include "SWGPreset.h"
|
||||
#include "SWGCommand.h"
|
||||
#include "settings/preferences.h"
|
||||
#include "settings/preset.h"
|
||||
#include "commands/command.h"
|
||||
|
||||
/**
|
||||
* Adapter between API and objects in sdrbase library
|
||||
@ -39,6 +41,10 @@ public:
|
||||
SWGSDRangel::SWGPreset *apiPreset,
|
||||
const Preset& preset
|
||||
);
|
||||
static void webapiFormatCommand(
|
||||
SWGSDRangel::SWGCommand *apiCommand,
|
||||
const Command& command
|
||||
);
|
||||
};
|
||||
|
||||
#endif // SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_
|
@ -136,6 +136,16 @@ int WebAPIAdapterGUI::instanceConfigGet(
|
||||
WebAPIAdapterBase::webapiFormatPreset(swgPresets->back(), *preset);
|
||||
}
|
||||
|
||||
int nbCommands = m_mainWindow.m_settings.getCommandCount();
|
||||
QList<SWGSDRangel::SWGCommand*> *swgCommands = response.getCommands();
|
||||
|
||||
for (int i = 0; i < nbCommands; i++)
|
||||
{
|
||||
const Command *command = m_mainWindow.m_settings.getCommand(i);
|
||||
swgCommands->append(new SWGSDRangel::SWGCommand);
|
||||
WebAPIAdapterBase::webapiFormatCommand(swgCommands->back(), *command);
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,16 @@ int WebAPIAdapterSrv::instanceConfigGet(
|
||||
WebAPIAdapterBase::webapiFormatPreset(swgPresets->back(), *preset);
|
||||
}
|
||||
|
||||
int nbCommands = m_mainCore.m_settings.getCommandCount();
|
||||
QList<SWGSDRangel::SWGCommand*> *swgCommands = response.getCommands();
|
||||
|
||||
for (int i = 0; i < nbCommands; i++)
|
||||
{
|
||||
const Command *command = m_mainCore.m_settings.getCommand(i);
|
||||
swgCommands->append(new SWGSDRangel::SWGCommand);
|
||||
WebAPIAdapterBase::webapiFormatCommand(swgCommands->back(), *command);
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user