kopia lustrzana https://github.com/f4exb/sdrangel
Put web server for API in place in the main window (1)
rodzic
5628b580ce
commit
279a88a17f
|
@ -66,7 +66,12 @@ HttpConnectionHandler* HttpConnectionHandlerPool::getConnectionHandler()
|
|||
int maxConnectionHandlers = useQtSettings ? settings->value("maxThreads",100).toInt() : listenerSettings.maxThreads;
|
||||
if (pool.count()<maxConnectionHandlers)
|
||||
{
|
||||
freeHandler=new HttpConnectionHandler(settings,requestHandler,sslConfiguration);
|
||||
if (useQtSettings) {
|
||||
freeHandler = new HttpConnectionHandler(settings, requestHandler, sslConfiguration);
|
||||
} else {
|
||||
freeHandler = new HttpConnectionHandler(listenerSettings, requestHandler, sslConfiguration);
|
||||
}
|
||||
|
||||
freeHandler->setBusy();
|
||||
pool.append(freeHandler);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,11 @@ void HttpListener::listen()
|
|||
{
|
||||
if (!pool)
|
||||
{
|
||||
pool=new HttpConnectionHandlerPool(settings,requestHandler);
|
||||
if (useQtSettings) {
|
||||
pool = new HttpConnectionHandlerPool(settings, requestHandler);
|
||||
} else {
|
||||
pool = new HttpConnectionHandlerPool(listenerSettings, requestHandler);
|
||||
}
|
||||
}
|
||||
QString host = useQtSettings ? settings->value("host").toString() : listenerSettings.host;
|
||||
int port = useQtSettings ? settings->value("port").toInt() : listenerSettings.port;
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
using namespace qtwebapp;
|
||||
|
||||
HttpRequest::HttpRequest(QSettings* settings)
|
||||
HttpRequest::HttpRequest(QSettings* settings) :
|
||||
useQtSettings(true)
|
||||
{
|
||||
status=waitForRequest;
|
||||
currentSize=0;
|
||||
|
@ -22,7 +23,8 @@ HttpRequest::HttpRequest(QSettings* settings)
|
|||
tempFile=0;
|
||||
}
|
||||
|
||||
HttpRequest::HttpRequest(const HttpListenerSettings& settings)
|
||||
HttpRequest::HttpRequest(const HttpListenerSettings& settings) :
|
||||
useQtSettings(false)
|
||||
{
|
||||
status=waitForRequest;
|
||||
currentSize=0;
|
||||
|
|
|
@ -239,6 +239,8 @@ private:
|
|||
/** Buffer for collecting characters of request and header lines */
|
||||
QByteArray lineBuffer;
|
||||
|
||||
/** Settings flag */
|
||||
bool useQtSettings;
|
||||
};
|
||||
|
||||
} // end of namespace
|
||||
|
|
|
@ -27,7 +27,7 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
|||
{
|
||||
if (m_adapter == 0) // format service unavailable if adapter is null
|
||||
{
|
||||
|
||||
response.setStatus(500,"Service not available");
|
||||
}
|
||||
else // normal processing
|
||||
{
|
||||
|
@ -37,5 +37,9 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
|||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(404,"Not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,6 +148,8 @@ include_directories(
|
|||
.
|
||||
${CMAKE_SOURCE_DIR}/sdrbase
|
||||
${CMAKE_SOURCE_DIR}/logging
|
||||
${CMAKE_SOURCE_DIR}/httpserver
|
||||
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${OPENGL_INCLUDE_DIR}
|
||||
)
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include "gui/glspectrum.h"
|
||||
#include "gui/glspectrumgui.h"
|
||||
#include "loggerwithfile.h"
|
||||
#include "webapi/webapirequestmapper.h"
|
||||
#include "webapi/webapiserver.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
@ -195,11 +197,19 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, QWidget* parent) :
|
|||
|
||||
connect(ui->tabInputsView, SIGNAL(currentChanged(int)), this, SLOT(tabInputViewIndexChanged()));
|
||||
|
||||
m_requestMapper = new WebAPIRequestMapper(qApp);
|
||||
m_apiServer = new WebAPIServer(m_requestMapper);
|
||||
m_apiServer->start();
|
||||
|
||||
qDebug() << "MainWindow::MainWindow: end";
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
m_apiServer->stop();
|
||||
delete m_apiServer;
|
||||
delete m_requestMapper;
|
||||
|
||||
delete m_pluginManager;
|
||||
delete m_dateTimeWidget;
|
||||
delete m_showSystemWidget;
|
||||
|
|
|
@ -49,6 +49,8 @@ class DeviceSinkAPI;
|
|||
class DeviceUISet;
|
||||
class PluginInterface;
|
||||
class QWidget;
|
||||
class WebAPIRequestMapper;
|
||||
class WebAPIServer;
|
||||
|
||||
namespace qtwebapp {
|
||||
class LoggerWithFile;
|
||||
|
@ -116,6 +118,9 @@ private:
|
|||
|
||||
qtwebapp::LoggerWithFile *m_logger;
|
||||
|
||||
WebAPIRequestMapper *m_requestMapper;
|
||||
WebAPIServer *m_apiServer;
|
||||
|
||||
void loadSettings();
|
||||
void loadPresetSettings(const Preset* preset, int tabIndex);
|
||||
void savePresetSettings(Preset* preset, int tabIndex);
|
||||
|
|
Ładowanie…
Reference in New Issue