2019-08-01 00:16:56 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
|
|
|
|
// //
|
|
|
|
// Swagger server adapter interface //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_
|
|
|
|
#define SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_
|
|
|
|
|
2019-08-01 19:27:31 +00:00
|
|
|
#include <QMap>
|
|
|
|
|
2019-08-01 00:16:56 +00:00
|
|
|
#include "export.h"
|
|
|
|
#include "SWGPreferences.h"
|
|
|
|
#include "SWGPreset.h"
|
2019-08-01 08:54:45 +00:00
|
|
|
#include "SWGCommand.h"
|
2019-08-01 00:16:56 +00:00
|
|
|
#include "settings/preferences.h"
|
|
|
|
#include "settings/preset.h"
|
2019-08-06 06:48:14 +00:00
|
|
|
#include "settings/mainsettings.h"
|
2019-08-01 08:54:45 +00:00
|
|
|
#include "commands/command.h"
|
2019-08-09 16:45:10 +00:00
|
|
|
#include "webapiadapterinterface.h"
|
2019-08-01 00:16:56 +00:00
|
|
|
|
2019-08-01 16:50:21 +00:00
|
|
|
class PluginManager;
|
2019-08-04 22:10:56 +00:00
|
|
|
class ChannelWebAPIAdapter;
|
2019-08-03 09:21:46 +00:00
|
|
|
class DeviceWebAPIAdapter;
|
2019-08-01 16:50:21 +00:00
|
|
|
|
2019-08-01 00:16:56 +00:00
|
|
|
/**
|
|
|
|
* Adapter between API and objects in sdrbase library
|
|
|
|
*/
|
|
|
|
class SDRBASE_API WebAPIAdapterBase
|
|
|
|
{
|
|
|
|
public:
|
2019-08-01 16:50:21 +00:00
|
|
|
WebAPIAdapterBase();
|
|
|
|
~WebAPIAdapterBase();
|
|
|
|
|
|
|
|
void setPluginManager(const PluginManager *pluginManager) { m_pluginManager = pluginManager; }
|
|
|
|
|
2019-08-01 00:16:56 +00:00
|
|
|
static void webapiFormatPreferences(
|
|
|
|
SWGSDRangel::SWGPreferences *apiPreferences,
|
|
|
|
const Preferences& preferences
|
|
|
|
);
|
2019-08-01 16:50:21 +00:00
|
|
|
void webapiFormatPreset(
|
2019-08-01 00:16:56 +00:00
|
|
|
SWGSDRangel::SWGPreset *apiPreset,
|
|
|
|
const Preset& preset
|
|
|
|
);
|
2019-08-01 08:54:45 +00:00
|
|
|
static void webapiFormatCommand(
|
|
|
|
SWGSDRangel::SWGCommand *apiCommand,
|
|
|
|
const Command& command
|
|
|
|
);
|
2019-08-06 06:48:14 +00:00
|
|
|
static void webapiInitConfig(
|
|
|
|
MainSettings& mainSettings
|
|
|
|
);
|
|
|
|
static void webapiUpdatePreferences(
|
|
|
|
SWGSDRangel::SWGPreferences *apiPreferences,
|
2019-08-09 16:45:10 +00:00
|
|
|
const QStringList& preferenceKeys,
|
2019-08-06 06:48:14 +00:00
|
|
|
Preferences& preferences
|
|
|
|
);
|
2019-08-10 03:16:25 +00:00
|
|
|
void webapiUpdatePreset(
|
|
|
|
bool force,
|
2019-08-09 16:45:10 +00:00
|
|
|
SWGSDRangel::SWGPreset *apiPreset,
|
|
|
|
const WebAPIAdapterInterface::PresetKeys& presetKeys,
|
2019-08-10 23:27:19 +00:00
|
|
|
Preset *preset
|
2019-08-09 16:45:10 +00:00
|
|
|
);
|
|
|
|
static void webapiUpdateCommand(
|
|
|
|
SWGSDRangel::SWGCommand *apiCommand,
|
|
|
|
const WebAPIAdapterInterface::CommandKeys& commandKeys,
|
|
|
|
Command& command
|
|
|
|
);
|
2019-08-01 16:50:21 +00:00
|
|
|
|
|
|
|
private:
|
2019-08-01 19:27:31 +00:00
|
|
|
class WebAPIChannelAdapters
|
|
|
|
{
|
|
|
|
public:
|
2019-08-04 22:10:56 +00:00
|
|
|
ChannelWebAPIAdapter *getChannelWebAPIAdapter(const QString& channelURI, const PluginManager *pluginManager);
|
2019-08-01 19:27:31 +00:00
|
|
|
void flush();
|
|
|
|
private:
|
2019-08-04 22:10:56 +00:00
|
|
|
QMap<QString, ChannelWebAPIAdapter*> m_webAPIChannelAdapters;
|
2019-08-01 19:27:31 +00:00
|
|
|
};
|
|
|
|
|
2019-08-03 09:21:46 +00:00
|
|
|
class WebAPIDeviceAdapters
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DeviceWebAPIAdapter *getDeviceWebAPIAdapter(const QString& deviceId, const PluginManager *pluginManager);
|
|
|
|
void flush();
|
|
|
|
private:
|
|
|
|
QMap<QString, DeviceWebAPIAdapter*> m_webAPIDeviceAdapters;
|
|
|
|
};
|
|
|
|
|
2019-08-01 16:50:21 +00:00
|
|
|
const PluginManager *m_pluginManager;
|
2019-08-01 19:27:31 +00:00
|
|
|
WebAPIChannelAdapters m_webAPIChannelAdapters;
|
2019-08-03 09:21:46 +00:00
|
|
|
WebAPIDeviceAdapters m_webAPIDeviceAdapters;
|
2019-08-01 00:16:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SDRBASE_WEBAPI_WEBAPIADAPTERBASE_H_
|