-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
99 lines (82 loc) · 2.85 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/****************************************************************************************
** Copyright (C) 2011, 2015 Simone Angeloni
** This file is part of C3 External Admin Interface.
**
** C3 External Admin Interface is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** C3 External Admin Interface is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with C3 External Admin Interface. If not, see <http://www.gnu.org/licenses/>
**
****************************************************************************************/
#include "stdafx.h"
#include <QtNetwork/QHttp>
#include <QtCore/QTranslator>
#include "programinfo.h"
#include "util/logger/logCommon.h"
/* LIBRARIES INCLUDE FOR gEnv */
#include "util/logger/logSystem.h"
#include "util/settings/settings.h"
#include "util/generic/ipUtils.h"
SSystemGlobalEnvironment *gEnv = NULL;
/* WINDOWS */
#include "interface/window.h"
#include "interface/splash.h"
#include "interface/server.h"
/**
* This takes care to handle the logs coming from Qt.
* @parar type Message type (debug, critical, warning, ...).
* @paran msg Message body.
*/
void myMessageDebugOutput(QtMsgType type, const char *msg)
{
LOGQt(QString("Type:'%1', Message:'%2'").arg((int)type).arg(msg));
}
/**
* Create global environment and attach it to gEnv global pointer.
*/
void MakeGEnv()
{
gEnv = new SSystemGlobalEnvironment();
gEnv->pLog = new CLogSystem();
gEnv->pSettings = new CSettingsFile();
gEnv->pUtils->pIPStringUtils = new CIPUtils();
if (!gEnv->bDebug)
{
gEnv->pSplashScreen = new CSplashScreenDialog();
}
gEnv->pLog->setLogTypes(gEnv->pSettings->getValueString(SETTING_LOGTYPES));
gEnv->pLog->setLogOutputs(gEnv->pSettings->getValueString(SETTING_LOGOUTPUT));
}
/**
* Main program.
* You should know what it does :)
*/
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QCoreApplication::setApplicationName(PROG_NAME_SHORT);
QCoreApplication::setOrganizationName(PROG_ORGANIZATION);
qRegisterMetaType<QHttp::Error> ("QHttp::Error");
qRegisterMetaType<CServerWidget::SServer> ("CServerWidget::SServer");
qInstallMsgHandler(myMessageDebugOutput);
QTranslator translator;
translator.load(QString(":/translations.qm"));
app.installTranslator(&translator);
MakeGEnv();
if (!gEnv->bDebug)
gEnv->pSplashScreen->show();
CMainWindow mainWin;
if (!gEnv->bDebug)
gEnv->pSplashScreen->checkUpdates();
if (gEnv->bDebug)
mainWin.show();
return app.exec();
}