-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebserver.cpp
51 lines (48 loc) · 2.08 KB
/
webserver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "webserver.h"
//FileLogger *logger;
QString configFileName;
webserver::webserver(QObject *parent) : QObject(parent)
{
configFileName="/home/apaul/apaul_projects/qtmop/etc/Demo2.ini";
qDebug() << "CONFIG FILE " << configFileName;
// Configure logging into a file
// QSettings* logSettings=new QSettings(configFileName,QSettings::IniFormat);
// logSettings->beginGroup("logging");
// logger=new FileLogger(logSettings,10000);
// logger->installMsgHandler();
// Configure and start the TCP listener
// qDebug("ServiceHelper: Starting service");
QSettings* listenerSettings=new QSettings(configFileName,QSettings::IniFormat);
listenerSettings->beginGroup("listener");
requestHandler = new RequestHandler;
new HttpListener(listenerSettings,requestHandler);
}
QString webserver::searchConfigFile()
{
QString binDir=QApplication::applicationDirPath();
QString appName=QApplication::applicationName();
QString fileName(appName+".ini");
QStringList searchList;
searchList.append(binDir);
searchList.append(binDir+"/etc");
searchList.append(binDir+"/../etc");
searchList.append(binDir+"/../../etc"); // for development without shadow build
searchList.append(binDir+"/../"+appName+"/etc"); // for development with shadow build
searchList.append(binDir+"/../../"+appName+"/etc"); // for development with shadow build
searchList.append(binDir+"/../../../"+appName+"/etc"); // for development with shadow build
searchList.append(binDir+"/../../../../"+appName+"/etc"); // for development with shadow build
searchList.append(binDir+"/../../../../../"+appName+"/etc"); // for development with shadow build
searchList.append(QDir::rootPath()+"etc/opt");
searchList.append(QDir::rootPath()+"etc");
foreach (QString dir, searchList)
{
QFile file(dir+"/"+fileName);
if (file.exists())
{
// found
fileName=QDir(file.fileName()).canonicalPath();
// qDebug("Using config file %s",qPrintable(fileName));
return fileName;
}
}
}