From 5bd4447e2a5837ce146213a9108d11e6854ffd76 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Sat, 22 Sep 2018 07:23:29 +0200 Subject: [PATCH] Applied WebApplication interface changes --- helloworldapplication.cpp | 8 ++++---- helloworldapplication.h | 7 ++++++- helloworldplugin.cpp | 4 ++-- helloworldplugin.h | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/helloworldapplication.cpp b/helloworldapplication.cpp index 37642bd..f26cd03 100644 --- a/helloworldapplication.cpp +++ b/helloworldapplication.cpp @@ -1,18 +1,18 @@ #include "helloworldapplication.h" +#include "webserver.h" #include "httprequest.h" #include "httpresponse.h" #include "httpclientconnection.h" -HelloWorldApplication::HelloWorldApplication(const QJsonObject &config, QObject *parent) : - WebApplication(parent) +HelloWorldApplication::HelloWorldApplication(const QJsonObject &config, WebServer &webServer) : + WebApplication(&webServer), m_webServer(webServer) { - + Q_UNUSED(config) } void HelloWorldApplication::start() { - } void HelloWorldApplication::handleRequest(HttpClientConnection *connection, const HttpRequest &request) diff --git a/helloworldapplication.h b/helloworldapplication.h index cf553a8..0093118 100644 --- a/helloworldapplication.h +++ b/helloworldapplication.h @@ -4,14 +4,19 @@ class QJsonObject; +class WebServer; + class HelloWorldApplication : public WebApplication { Q_OBJECT public: - HelloWorldApplication(const QJsonObject &config, QObject *parent = Q_NULLPTR); + HelloWorldApplication(const QJsonObject &config, WebServer &webServer); void start() Q_DECL_OVERRIDE; void handleRequest(HttpClientConnection *connection, const HttpRequest &request) Q_DECL_OVERRIDE; + +private: + WebServer &m_webServer; }; diff --git a/helloworldplugin.cpp b/helloworldplugin.cpp index b458230..26a71ba 100644 --- a/helloworldplugin.cpp +++ b/helloworldplugin.cpp @@ -13,8 +13,8 @@ QString HelloWorldPlugin::pluginName() const return QStringLiteral("helloworld"); } -WebApplication *HelloWorldPlugin::createApplication(const QJsonObject &config) const +WebApplication *HelloWorldPlugin::createApplication(const QJsonObject &config, WebServer &webServer) const { - return new HelloWorldApplication(config); + return new HelloWorldApplication(config, webServer); } diff --git a/helloworldplugin.h b/helloworldplugin.h index 2a6cc62..0d09230 100644 --- a/helloworldplugin.h +++ b/helloworldplugin.h @@ -12,5 +12,5 @@ public: HelloWorldPlugin(QObject *parent = Q_NULLPTR); QString pluginName() const Q_DECL_OVERRIDE; - WebApplication *createApplication(const QJsonObject &config) const Q_DECL_OVERRIDE; + WebApplication *createApplication(const QJsonObject &config, WebServer &webServer) const Q_DECL_OVERRIDE; };