mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 13:04:28 -04:00
Format code using clang-format
This commit is contained in:
@ -24,12 +24,13 @@
|
||||
/** Short description of this application */
|
||||
#define DESCRIPTION "Comic reader and organizer"
|
||||
|
||||
void Startup::start() {
|
||||
// Initialize the core application
|
||||
QCoreApplication* app = QCoreApplication::instance();
|
||||
QString configFileName=YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini";
|
||||
void Startup::start()
|
||||
{
|
||||
// Initialize the core application
|
||||
QCoreApplication *app = QCoreApplication::instance();
|
||||
QString configFileName = YACReader::getSettingsPath() + "/" + QCoreApplication::applicationName() + ".ini";
|
||||
|
||||
/*
|
||||
/*
|
||||
// Configure logging into files
|
||||
QSettings* mainLogSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
mainLogSettings->beginGroup("mainLogFile");
|
||||
@ -51,103 +52,100 @@ void Startup::start() {
|
||||
Logger* logger=new FileLogger(mainLogSettings,10000,app);
|
||||
logger->installMsgHandler();*/
|
||||
|
||||
// Configure template loader and cache
|
||||
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
templateSettings->beginGroup("templates");
|
||||
// Configure template loader and cache
|
||||
QSettings *templateSettings = new QSettings(configFileName, QSettings::IniFormat, app);
|
||||
templateSettings->beginGroup("templates");
|
||||
|
||||
if(templateSettings->value("cacheSize").isNull())
|
||||
templateSettings->setValue("cacheSize","160000");
|
||||
if (templateSettings->value("cacheSize").isNull())
|
||||
templateSettings->setValue("cacheSize", "160000");
|
||||
|
||||
QString baseTemplatePath = QString("./server/templates");
|
||||
QString templatePath;
|
||||
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
templatePath=QFileInfo(QString(DATADIR)+"/yacreader",baseTemplatePath).absoluteFilePath();
|
||||
#else
|
||||
templatePath=QFileInfo(QCoreApplication::applicationDirPath(),baseTemplatePath).absoluteFilePath();
|
||||
#endif
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
templatePath = QFileInfo(QString(DATADIR) + "/yacreader", baseTemplatePath).absoluteFilePath();
|
||||
#else
|
||||
templatePath = QFileInfo(QCoreApplication::applicationDirPath(), baseTemplatePath).absoluteFilePath();
|
||||
#endif
|
||||
|
||||
if(templateSettings->value("path").isNull())
|
||||
templateSettings->setValue("path",templatePath);
|
||||
if (templateSettings->value("path").isNull())
|
||||
templateSettings->setValue("path", templatePath);
|
||||
|
||||
Static::templateLoader=new TemplateCache(templateSettings,app);
|
||||
Static::templateLoader = new TemplateCache(templateSettings, app);
|
||||
|
||||
// Configure session store
|
||||
QSettings* sessionSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
QSettings *sessionSettings = new QSettings(configFileName, QSettings::IniFormat, app);
|
||||
sessionSettings->beginGroup("sessions");
|
||||
|
||||
if(sessionSettings->value("expirationTime").isNull())
|
||||
sessionSettings->setValue("expirationTime",864000000);
|
||||
if (sessionSettings->value("expirationTime").isNull())
|
||||
sessionSettings->setValue("expirationTime", 864000000);
|
||||
|
||||
Static::sessionStore=new HttpSessionStore(sessionSettings,app);
|
||||
Static::sessionStore = new HttpSessionStore(sessionSettings, app);
|
||||
|
||||
Static::yacreaderSessionStore = new YACReaderHttpSessionStore(Static::sessionStore, app);
|
||||
|
||||
// Configure static file controller
|
||||
QSettings* fileSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
fileSettings->beginGroup("docroot");
|
||||
// Configure static file controller
|
||||
QSettings *fileSettings = new QSettings(configFileName, QSettings::IniFormat, app);
|
||||
fileSettings->beginGroup("docroot");
|
||||
|
||||
QString basedocroot = "./server/docroot";
|
||||
QString docroot;
|
||||
|
||||
#if defined Q_OS_UNIX && ! defined Q_OS_MAC
|
||||
QFileInfo configFile(QString(DATADIR)+"/yacreader");
|
||||
docroot=QFileInfo(QString(DATADIR)+"/yacreader",basedocroot).absoluteFilePath();
|
||||
#else
|
||||
QFileInfo configFile(QCoreApplication::applicationDirPath());
|
||||
docroot=QFileInfo(QCoreApplication::applicationDirPath(),basedocroot).absoluteFilePath();
|
||||
#endif
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
QFileInfo configFile(QString(DATADIR) + "/yacreader");
|
||||
docroot = QFileInfo(QString(DATADIR) + "/yacreader", basedocroot).absoluteFilePath();
|
||||
#else
|
||||
QFileInfo configFile(QCoreApplication::applicationDirPath());
|
||||
docroot = QFileInfo(QCoreApplication::applicationDirPath(), basedocroot).absoluteFilePath();
|
||||
#endif
|
||||
|
||||
if(fileSettings->value("path").isNull())
|
||||
fileSettings->setValue("path",docroot);
|
||||
if (fileSettings->value("path").isNull())
|
||||
fileSettings->setValue("path", docroot);
|
||||
|
||||
Static::staticFileController=new StaticFileController(fileSettings,app);
|
||||
Static::staticFileController = new StaticFileController(fileSettings, app);
|
||||
|
||||
// Configure and start the TCP listener
|
||||
qDebug("ServiceHelper: Starting service");
|
||||
QSettings* listenerSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
QSettings *listenerSettings = new QSettings(configFileName, QSettings::IniFormat, app);
|
||||
listenerSettings->beginGroup("listener");
|
||||
|
||||
if(listenerSettings->value("maxRequestSize").isNull())
|
||||
listenerSettings->setValue("maxRequestSize","32000000");
|
||||
if (listenerSettings->value("maxRequestSize").isNull())
|
||||
listenerSettings->setValue("maxRequestSize", "32000000");
|
||||
|
||||
if(listenerSettings->value("maxMultiPartSize").isNull())
|
||||
listenerSettings->setValue("maxMultiPartSize","32000000");
|
||||
if (listenerSettings->value("maxMultiPartSize").isNull())
|
||||
listenerSettings->setValue("maxMultiPartSize", "32000000");
|
||||
|
||||
if(listenerSettings->value("cleanupInterval").isNull())
|
||||
listenerSettings->setValue("cleanupInterval",10000);
|
||||
if (listenerSettings->value("cleanupInterval").isNull())
|
||||
listenerSettings->setValue("cleanupInterval", 10000);
|
||||
|
||||
if(listenerSettings->value("minThreads").isNull())
|
||||
listenerSettings->setValue("maxThreads",1000);
|
||||
if (listenerSettings->value("minThreads").isNull())
|
||||
listenerSettings->setValue("maxThreads", 1000);
|
||||
|
||||
if(listenerSettings->value("minThreads").isNull())
|
||||
listenerSettings->setValue("minThreads",50);
|
||||
if (listenerSettings->value("minThreads").isNull())
|
||||
listenerSettings->setValue("minThreads", 50);
|
||||
|
||||
listener = new HttpListener(listenerSettings,new RequestMapper(app),app);
|
||||
listener = new HttpListener(listenerSettings, new RequestMapper(app), app);
|
||||
|
||||
qDebug("ServiceHelper: Service has started");
|
||||
}
|
||||
|
||||
|
||||
void Startup::stop() {
|
||||
void Startup::stop()
|
||||
{
|
||||
qDebug("ServiceHelper: Service has been stopped");
|
||||
// QCoreApplication destroys all objects that have been created in start().
|
||||
if(listener!=nullptr)
|
||||
{
|
||||
if (listener != nullptr) {
|
||||
listener->close();
|
||||
delete listener;
|
||||
listener = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Startup::Startup()
|
||||
: listener(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString Startup::getPort()
|
||||
{
|
||||
return QString("%1").arg(listener->serverPort());
|
||||
return QString("%1").arg(listener->serverPort());
|
||||
}
|
||||
|
Reference in New Issue
Block a user