2017-11-16 21:17:15 -05:00
|
|
|
/**
|
|
|
|
* SDRangel
|
2018-01-05 21:46:53 -05:00
|
|
|
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
|
2017-11-16 21:17:15 -05:00
|
|
|
*
|
|
|
|
* OpenAPI spec version: 4.0.0
|
|
|
|
* Contact: f4exb06@gmail.com
|
|
|
|
*
|
|
|
|
* NOTE: This class is auto generated by the swagger code generator program.
|
|
|
|
* https://github.com/swagger-api/swagger-codegen.git
|
|
|
|
* Do not edit the class manually.
|
|
|
|
*/
|
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
#include "SWGInstanceApi.h"
|
2017-11-16 21:17:15 -05:00
|
|
|
#include "SWGHelpers.h"
|
|
|
|
#include "SWGModelFactory.h"
|
|
|
|
|
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
namespace SWGSDRangel {
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::SWGInstanceApi() {}
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::~SWGInstanceApi() {}
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::SWGInstanceApi(QString host, QString basePath) {
|
2017-11-16 21:17:15 -05:00
|
|
|
this->host = host;
|
|
|
|
this->basePath = basePath;
|
|
|
|
}
|
|
|
|
|
2017-11-25 18:26:56 -05:00
|
|
|
void
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::instanceAudioGet() {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/audio");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "GET");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceAudioGetCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceAudioGetCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGAudioDevices* output = static_cast<SWGAudioDevices*>(create(json, QString("SWGAudioDevices")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceAudioGetSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceAudioGetSignalE(output, error_type, error_str);
|
|
|
|
emit instanceAudioGetSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceAudioPatch(SWGAudioDevicesSelect& body) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/audio");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "PATCH");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceAudioPatchCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceAudioPatchCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGAudioDevicesSelect* output = static_cast<SWGAudioDevicesSelect*>(create(json, QString("SWGAudioDevicesSelect")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceAudioPatchSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceAudioPatchSignalE(output, error_type, error_str);
|
|
|
|
emit instanceAudioPatchSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::instanceChannels(qint32 tx) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/channels");
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (fullPath.indexOf("?") > 0)
|
2017-11-16 21:17:15 -05:00
|
|
|
fullPath.append("&");
|
2018-02-12 12:20:27 -05:00
|
|
|
else
|
2017-11-16 21:17:15 -05:00
|
|
|
fullPath.append("?");
|
|
|
|
fullPath.append(QUrl::toPercentEncoding("tx"))
|
|
|
|
.append("=")
|
|
|
|
.append(QUrl::toPercentEncoding(stringValue(tx)));
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "GET");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceChannelsCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceChannelsCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGInstanceChannelsResponse* output = static_cast<SWGInstanceChannelsResponse*>(create(json, QString("SWGInstanceChannelsResponse")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceChannelsSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceChannelsSignalE(output, error_type, error_str);
|
|
|
|
emit instanceChannelsSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::instanceDVSerialPatch(qint32 dvserial) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/dvserial");
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (fullPath.indexOf("?") > 0)
|
2017-11-16 21:17:15 -05:00
|
|
|
fullPath.append("&");
|
2018-02-12 12:20:27 -05:00
|
|
|
else
|
2017-11-16 21:17:15 -05:00
|
|
|
fullPath.append("?");
|
|
|
|
fullPath.append(QUrl::toPercentEncoding("dvserial"))
|
|
|
|
.append("=")
|
|
|
|
.append(QUrl::toPercentEncoding(stringValue(dvserial)));
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "PATCH");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceDVSerialPatchCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceDVSerialPatchCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGDVSeralDevices* output = static_cast<SWGDVSeralDevices*>(create(json, QString("SWGDVSeralDevices")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceDVSerialPatchSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceDVSerialPatchSignalE(output, error_type, error_str);
|
|
|
|
emit instanceDVSerialPatchSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-12-17 17:15:42 -05:00
|
|
|
void
|
|
|
|
SWGInstanceApi::instanceDelete() {
|
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "DELETE");
|
2017-12-17 17:15:42 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-12-17 17:15:42 -05:00
|
|
|
this,
|
|
|
|
&SWGInstanceApi::instanceDeleteCallback);
|
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceDeleteCallback(SWGHttpRequestWorker * worker) {
|
2017-12-17 17:15:42 -05:00
|
|
|
QString msg;
|
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString json(worker->response);
|
|
|
|
SWGInstanceSummaryResponse* output = static_cast<SWGInstanceSummaryResponse*>(create(json, QString("SWGInstanceSummaryResponse")));
|
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceDeleteSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceDeleteSignalE(output, error_type, error_str);
|
|
|
|
emit instanceDeleteSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-12-17 17:15:42 -05:00
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2017-12-22 09:27:25 -05:00
|
|
|
SWGInstanceApi::instanceDeviceSetsGet() {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/devicesets");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "GET");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-22 09:27:25 -05:00
|
|
|
&SWGInstanceApi::instanceDeviceSetsGetCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceDeviceSetsGetCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
2017-12-22 09:27:25 -05:00
|
|
|
SWGDeviceSetList* output = static_cast<SWGDeviceSetList*>(create(json, QString("SWGDeviceSetList")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceDeviceSetsGetSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceDeviceSetsGetSignalE(output, error_type, error_str);
|
|
|
|
emit instanceDeviceSetsGetSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::instanceDevices(qint32 tx) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/devices");
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (fullPath.indexOf("?") > 0)
|
2017-11-16 21:17:15 -05:00
|
|
|
fullPath.append("&");
|
2018-02-12 12:20:27 -05:00
|
|
|
else
|
2017-11-16 21:17:15 -05:00
|
|
|
fullPath.append("?");
|
|
|
|
fullPath.append(QUrl::toPercentEncoding("tx"))
|
|
|
|
.append("=")
|
|
|
|
.append(QUrl::toPercentEncoding(stringValue(tx)));
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "GET");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceDevicesCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceDevicesCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGInstanceDevicesResponse* output = static_cast<SWGInstanceDevicesResponse*>(create(json, QString("SWGInstanceDevicesResponse")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceDevicesSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceDevicesSignalE(output, error_type, error_str);
|
|
|
|
emit instanceDevicesSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::instanceLocationGet() {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/location");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "GET");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceLocationGetCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceLocationGetCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGLocationInformation* output = static_cast<SWGLocationInformation*>(create(json, QString("SWGLocationInformation")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceLocationGetSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceLocationGetSignalE(output, error_type, error_str);
|
|
|
|
emit instanceLocationGetSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceLocationPut(SWGLocationInformation& body) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/location");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "PUT");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceLocationPutCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceLocationPutCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGLocationInformation* output = static_cast<SWGLocationInformation*>(create(json, QString("SWGLocationInformation")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceLocationPutSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceLocationPutSignalE(output, error_type, error_str);
|
|
|
|
emit instanceLocationPutSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::instanceLoggingGet() {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/logging");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "GET");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceLoggingGetCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceLoggingGetCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGLoggingInfo* output = static_cast<SWGLoggingInfo*>(create(json, QString("SWGLoggingInfo")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceLoggingGetSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceLoggingGetSignalE(output, error_type, error_str);
|
|
|
|
emit instanceLoggingGetSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceLoggingPut(SWGLoggingInfo& body) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/logging");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "PUT");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceLoggingPutCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceLoggingPutCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGLoggingInfo* output = static_cast<SWGLoggingInfo*>(create(json, QString("SWGLoggingInfo")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceLoggingPutSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceLoggingPutSignalE(output, error_type, error_str);
|
|
|
|
emit instanceLoggingPutSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetDelete(SWGPresetIdentifier& body) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/preset");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "DELETE");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instancePresetDeleteCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetDeleteCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGPresetIdentifier* output = static_cast<SWGPresetIdentifier*>(create(json, QString("SWGPresetIdentifier")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instancePresetDeleteSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instancePresetDeleteSignalE(output, error_type, error_str);
|
|
|
|
emit instancePresetDeleteSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-12-18 19:11:34 -05:00
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetFilePost(SWGPresetExport& body) {
|
2017-12-18 19:11:34 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/preset/file");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "POST");
|
2017-12-18 19:11:34 -05:00
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-12-18 19:11:34 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-12-18 19:11:34 -05:00
|
|
|
this,
|
|
|
|
&SWGInstanceApi::instancePresetFilePostCallback);
|
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetFilePostCallback(SWGHttpRequestWorker * worker) {
|
2017-12-18 19:11:34 -05:00
|
|
|
QString msg;
|
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString json(worker->response);
|
|
|
|
SWGPresetIdentifier* output = static_cast<SWGPresetIdentifier*>(create(json, QString("SWGPresetIdentifier")));
|
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instancePresetFilePostSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instancePresetFilePostSignalE(output, error_type, error_str);
|
|
|
|
emit instancePresetFilePostSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetFilePut(SWGPresetImport& body) {
|
2017-12-18 19:11:34 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/preset/file");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "PUT");
|
2017-12-18 19:11:34 -05:00
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-12-18 19:11:34 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-12-18 19:11:34 -05:00
|
|
|
this,
|
|
|
|
&SWGInstanceApi::instancePresetFilePutCallback);
|
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetFilePutCallback(SWGHttpRequestWorker * worker) {
|
2017-12-18 19:11:34 -05:00
|
|
|
QString msg;
|
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString json(worker->response);
|
|
|
|
SWGPresetIdentifier* output = static_cast<SWGPresetIdentifier*>(create(json, QString("SWGPresetIdentifier")));
|
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instancePresetFilePutSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instancePresetFilePutSignalE(output, error_type, error_str);
|
|
|
|
emit instancePresetFilePutSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-12-18 19:11:34 -05:00
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::instancePresetGet() {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
2017-12-20 18:50:58 -05:00
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/presets");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "GET");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instancePresetGetCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetGetCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGPresets* output = static_cast<SWGPresets*>(create(json, QString("SWGPresets")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instancePresetGetSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instancePresetGetSignalE(output, error_type, error_str);
|
|
|
|
emit instancePresetGetSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetPatch(SWGPresetTransfer& body) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/preset");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "PATCH");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instancePresetPatchCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetPatchCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGPresetIdentifier* output = static_cast<SWGPresetIdentifier*>(create(json, QString("SWGPresetIdentifier")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instancePresetPatchSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instancePresetPatchSignalE(output, error_type, error_str);
|
|
|
|
emit instancePresetPatchSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetPost(SWGPresetTransfer& body) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/preset");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "POST");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instancePresetPostCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetPostCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGPresetIdentifier* output = static_cast<SWGPresetIdentifier*>(create(json, QString("SWGPresetIdentifier")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instancePresetPostSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instancePresetPostSignalE(output, error_type, error_str);
|
|
|
|
emit instancePresetPostSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetPut(SWGPresetTransfer& body) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel/preset");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "PUT");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
QString output = body.asJson();
|
|
|
|
input.request_body.append(output);
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instancePresetPutCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instancePresetPutCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGPresetIdentifier* output = static_cast<SWGPresetIdentifier*>(create(json, QString("SWGPresetIdentifier")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instancePresetPutSignal(output);
|
|
|
|
} else {
|
|
|
|
emit instancePresetPutSignalE(output, error_type, error_str);
|
|
|
|
emit instancePresetPutSignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
void
|
2017-12-01 23:45:30 -05:00
|
|
|
SWGInstanceApi::instanceSummary() {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString fullPath;
|
|
|
|
fullPath.append(this->host).append(this->basePath).append("/sdrangel");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
|
|
|
SWGHttpRequestInput input(fullPath, "GET");
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
|
|
|
|
foreach(QString key, this->defaultHeaders.keys()) {
|
|
|
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
|
|
|
}
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
connect(worker,
|
2018-02-12 12:20:27 -05:00
|
|
|
&SWGHttpRequestWorker::on_execution_finished,
|
2017-11-16 21:17:15 -05:00
|
|
|
this,
|
2017-12-01 23:45:30 -05:00
|
|
|
&SWGInstanceApi::instanceSummaryCallback);
|
2017-11-16 21:17:15 -05:00
|
|
|
|
|
|
|
worker->execute(&input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-02-12 12:20:27 -05:00
|
|
|
SWGInstanceApi::instanceSummaryCallback(SWGHttpRequestWorker * worker) {
|
2017-11-16 21:17:15 -05:00
|
|
|
QString msg;
|
2017-11-17 08:51:16 -05:00
|
|
|
QString error_str = worker->error_str;
|
|
|
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = "Error: " + worker->error_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 08:51:16 -05:00
|
|
|
QString json(worker->response);
|
|
|
|
SWGInstanceSummaryResponse* output = static_cast<SWGInstanceSummaryResponse*>(create(json, QString("SWGInstanceSummaryResponse")));
|
2017-11-16 21:17:15 -05:00
|
|
|
worker->deleteLater();
|
|
|
|
|
2018-02-12 12:20:27 -05:00
|
|
|
if (worker->error_type == QNetworkReply::NoError) {
|
|
|
|
emit instanceSummarySignal(output);
|
|
|
|
} else {
|
|
|
|
emit instanceSummarySignalE(output, error_type, error_str);
|
|
|
|
emit instanceSummarySignalEFull(worker, error_type, error_str);
|
|
|
|
}
|
2017-11-17 08:51:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-16 21:17:15 -05:00
|
|
|
}
|