/
main.cpp
34 lines (28 loc) · 1.16 KB
/
main.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
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include "Logger.h"
#include "SpThreadServer.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
app.addLibraryPath(app.applicationDirPath() + "/lib");
QCommandLineParser parser;
QList<QCommandLineOption> optionList;
optionList.append({{"d", "debug"}, "Log debug messages."});
optionList.append({{"c", "console"}, "Output log to the console."});
optionList.append({{"p", "port"}, "Application connection port.", "port", "1067"});
optionList.append({"database", "The name of the database file.", "database", "softphoneDatabase.db3"});
parser.addOptions(optionList);
parser.process(app);
bool debugOutput = parser.isSet("debug");
Logger::getInstance().enableDebugOutput(debugOutput);
bool consoleOutput = parser.isSet("console");
Logger::getInstance().enableConsoleOutput(consoleOutput);
SpThreadServer *server = new SpThreadServer();
server->setPort(quint16(parser.value("port").toInt()));
server->setDatabasePath(parser.value("database"));
server->start();
app.exec();
server->deleteLater();
}