Rename Startup class to YACReaderHttpServer

This commit is contained in:
Luis Ángel San Martín 2022-10-13 23:24:35 +02:00
parent 59639ad68c
commit be0c0ff341
9 changed files with 44 additions and 54 deletions

View File

@ -79,6 +79,7 @@ greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat
# Input # Input
HEADERS += comic_flow.h \ HEADERS += comic_flow.h \
../common/concurrent_queue.h \ ../common/concurrent_queue.h \
content_views_updater.h \
create_library_dialog.h \ create_library_dialog.h \
db/comic_query_result_processor.h \ db/comic_query_result_processor.h \
db/folder_query_result_processor.h \ db/folder_query_result_processor.h \
@ -162,6 +163,7 @@ HEADERS += comic_flow.h \
SOURCES += comic_flow.cpp \ SOURCES += comic_flow.cpp \
../common/concurrent_queue.cpp \ ../common/concurrent_queue.cpp \
content_views_updater.cpp \
create_library_dialog.cpp \ create_library_dialog.cpp \
db/comic_query_result_processor.cpp \ db/comic_query_result_processor.cpp \
db/folder_query_result_processor.cpp \ db/folder_query_result_processor.cpp \

View File

@ -2595,8 +2595,8 @@ void LibraryWindow::showImportComicsInfo()
importComicsInfoDialog->dest = currentPath() + "/.yacreaderlibrary/library.ydb"; importComicsInfoDialog->dest = currentPath() + "/.yacreaderlibrary/library.ydb";
importComicsInfoDialog->open(); importComicsInfoDialog->open();
} }
#include "startup.h" #include "yacreader_http_server.h"
extern Startup *s; extern YACReaderHttpServer *s;
void LibraryWindow::closeEvent(QCloseEvent *event) void LibraryWindow::closeEvent(QCloseEvent *event)
{ {
if (!trayIconController->handleCloseToTrayIcon(event)) { if (!trayIconController->handleCloseToTrayIcon(event)) {

View File

@ -13,7 +13,7 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include "yacreader_global.h" #include "yacreader_global.h"
#include "startup.h" #include "yacreader_http_server.h"
#include "yacreader_local_server.h" #include "yacreader_local_server.h"
#include "comic_db.h" #include "comic_db.h"
#include "db_helper.h" #include "db_helper.h"
@ -30,7 +30,7 @@
#define PICTUREFLOW_QT4 1 #define PICTUREFLOW_QT4 1
// Server interface // Server interface
Startup *s; YACReaderHttpServer *s;
using namespace QsLogging; using namespace QsLogging;
@ -244,7 +244,7 @@ int main(int argc, char **argv)
QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); QSettings *settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat);
settings->beginGroup("libraryConfig"); settings->beginGroup("libraryConfig");
s = new Startup(); s = new YACReaderHttpServer();
if (settings->value(SERVER_ON, true).toBool()) { if (settings->value(SERVER_ON, true).toBool()) {
s->start(); s->start();

View File

@ -10,8 +10,8 @@ DEPENDPATH += $$PWD/controllers/v2
HEADERS += \ HEADERS += \
$$PWD/static.h \ $$PWD/static.h \
$$PWD/startup.h \
$$PWD/requestmapper.h \ $$PWD/requestmapper.h \
$$PWD/yacreader_http_server.h \
$$PWD/yacreader_http_session.h \ $$PWD/yacreader_http_session.h \
$$PWD/yacreader_http_session_store.h \ $$PWD/yacreader_http_session_store.h \
$$PWD/yacreader_server_data_helper.h \ $$PWD/yacreader_server_data_helper.h \
@ -52,8 +52,8 @@ HEADERS += \
SOURCES += \ SOURCES += \
$$PWD/static.cpp \ $$PWD/static.cpp \
$$PWD/startup.cpp \
$$PWD/requestmapper.cpp \ $$PWD/requestmapper.cpp \
$$PWD/yacreader_http_server.cpp \
$$PWD/yacreader_http_session.cpp \ $$PWD/yacreader_http_session.cpp \
$$PWD/yacreader_http_session_store.cpp \ $$PWD/yacreader_http_session_store.cpp \
$$PWD/yacreader_server_data_helper.cpp \ $$PWD/yacreader_server_data_helper.cpp \

View File

@ -1,38 +0,0 @@
/**
@file
@author Stefan Frings
*/
#ifndef STARTUP_H
#define STARTUP_H
#include <QString>
namespace stefanfrings {
class HttpListener;
}
/**
Helper class to install and run the application as a windows
service.
*/
class Startup
{
private:
// QTcpServer
stefanfrings::HttpListener *listener;
public:
/** Constructor */
Startup();
/** Start the server */
void start(quint16 port = 0);
/** Stop the server */
void stop();
QString getPort();
protected:
};
#endif // STARTUP_H

View File

@ -4,7 +4,7 @@
*/ */
#include "static.h" #include "static.h"
#include "startup.h" #include "yacreader_http_server.h"
//#include "dualfilelogger.h" //#include "dualfilelogger.h"
#include "httplistener.h" #include "httplistener.h"
#include "requestmapper.h" #include "requestmapper.h"
@ -32,7 +32,7 @@ using stefanfrings::HttpSessionStore;
using stefanfrings::StaticFileController; using stefanfrings::StaticFileController;
using stefanfrings::TemplateCache; using stefanfrings::TemplateCache;
void Startup::start(quint16 port) void YACReaderHttpServer::start(quint16 port)
{ {
// Initialize the core application // Initialize the core application
QCoreApplication *app = QCoreApplication::instance(); QCoreApplication *app = QCoreApplication::instance();
@ -146,7 +146,7 @@ void Startup::start(quint16 port)
} }
} }
void Startup::stop() void YACReaderHttpServer::stop()
{ {
qDebug("ServiceHelper: Service has been stopped"); qDebug("ServiceHelper: Service has been stopped");
// QCoreApplication destroys all objects that have been created in start(). // QCoreApplication destroys all objects that have been created in start().
@ -157,12 +157,12 @@ void Startup::stop()
} }
} }
Startup::Startup() YACReaderHttpServer::YACReaderHttpServer()
: listener(nullptr) : listener(nullptr)
{ {
} }
QString Startup::getPort() QString YACReaderHttpServer::getPort()
{ {
return QString("%1").arg(listener->serverPort()); return QString("%1").arg(listener->serverPort());
} }

View File

@ -0,0 +1,26 @@
#ifndef YACREADER_HTTP_SERVER_H
#define YACREADER_HTTP_SERVER_H
#include <QString>
namespace stefanfrings {
class HttpListener;
}
class YACReaderHttpServer
{
private:
stefanfrings::HttpListener *listener;
public:
YACReaderHttpServer();
void start(quint16 port = 0);
void stop();
QString getPort();
protected:
};
#endif // YACREADER_HTTP_SERVER_H

View File

@ -11,7 +11,7 @@
#include <QBitmap> #include <QBitmap>
#include <QPainter> #include <QPainter>
#include "startup.h" #include "yacreader_http_server.h"
#include "yacreader_global_gui.h" #include "yacreader_global_gui.h"
#include "qnaturalsorting.h" #include "qnaturalsorting.h"
@ -78,7 +78,7 @@ QList<QString> addresses()
#endif #endif
extern Startup *s; extern YACReaderHttpServer *s;
ServerConfigDialog::ServerConfigDialog(QWidget *parent) ServerConfigDialog::ServerConfigDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)

View File

@ -6,7 +6,7 @@
#include "comic_db.h" #include "comic_db.h"
#include "db_helper.h" #include "db_helper.h"
#include "startup.h" #include "yacreader_http_server.h"
#include "yacreader_global.h" #include "yacreader_global.h"
#include "yacreader_libraries.h" #include "yacreader_libraries.h"
#include "yacreader_local_server.h" #include "yacreader_local_server.h"
@ -194,7 +194,7 @@ int main(int argc, char **argv)
settings->beginGroup("libraryConfig"); settings->beginGroup("libraryConfig");
// server // server
Startup *s = new Startup(); YACReaderHttpServer *s = new YACReaderHttpServer();
if (parser.isSet("port")) { if (parser.isSet("port")) {
bool valid; bool valid;
qint32 port = parser.value("port").toInt(&valid); qint32 port = parser.value("port").toInt(&valid);