2017-09-03 05:57:35 +00:00
|
|
|
#include <QApplication>
|
2018-04-15 06:19:31 +00:00
|
|
|
#include <QMessageBox>
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-02 13:07:40 +00:00
|
|
|
#include "../common/version.h"
|
2018-08-24 11:28:26 +00:00
|
|
|
#include "control/controlmanager.h"
|
|
|
|
#include "control/controlworker.h"
|
2017-09-11 03:54:19 +00:00
|
|
|
#include "driver/drivermanager.h"
|
2017-09-03 09:20:37 +00:00
|
|
|
#include "fortcommon.h"
|
2017-09-01 15:13:17 +00:00
|
|
|
#include "fortmanager.h"
|
2017-09-03 09:20:37 +00:00
|
|
|
#include "fortsettings.h"
|
2017-09-11 11:17:27 +00:00
|
|
|
#include "util/osutil.h"
|
2017-08-23 13:52:22 +00:00
|
|
|
|
2018-04-15 06:19:31 +00:00
|
|
|
#define FORT_ERROR_INSTANCE 1
|
2019-04-04 08:53:59 +00:00
|
|
|
#define FORT_ERROR_CONTROL 2
|
2018-04-15 06:19:31 +00:00
|
|
|
|
2017-08-23 13:52:22 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2017-12-20 14:15:48 +00:00
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
2019-03-26 06:52:28 +00:00
|
|
|
QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
2017-09-02 13:07:40 +00:00
|
|
|
|
2018-01-12 08:29:08 +00:00
|
|
|
QApplication::setQuitOnLastWindowClosed(false);
|
|
|
|
|
2017-09-03 05:57:35 +00:00
|
|
|
QApplication app(argc, argv);
|
2019-02-08 08:19:20 +00:00
|
|
|
QApplication::setApplicationName(APP_NAME);
|
|
|
|
QApplication::setApplicationVersion(APP_VERSION_STR);
|
|
|
|
QApplication::setApplicationDisplayName(APP_NAME " v" APP_VERSION_STR);
|
2017-08-23 13:52:22 +00:00
|
|
|
|
2019-04-06 06:19:12 +00:00
|
|
|
FortSettings fortSettings(QCoreApplication::arguments());
|
2017-09-03 09:20:37 +00:00
|
|
|
|
2018-01-10 01:21:54 +00:00
|
|
|
// Unregister booted provider and exit
|
2017-09-13 11:08:27 +00:00
|
|
|
if (fortSettings.hasProvBoot()) {
|
2017-09-03 09:20:37 +00:00
|
|
|
FortCommon::provUnregister();
|
2018-01-10 01:21:54 +00:00
|
|
|
return 0;
|
2017-09-03 09:20:37 +00:00
|
|
|
}
|
|
|
|
|
2019-02-08 08:19:20 +00:00
|
|
|
ControlManager controlManager(QApplication::applicationName(),
|
2018-08-24 11:28:26 +00:00
|
|
|
fortSettings.controlPath());
|
|
|
|
|
|
|
|
// Send control request to running instance
|
|
|
|
if (controlManager.isClient()) {
|
|
|
|
return controlManager.post(fortSettings.args())
|
|
|
|
? 0 : FORT_ERROR_CONTROL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check running instance
|
2018-04-15 06:19:31 +00:00
|
|
|
if (!OsUtil::createGlobalMutex(APP_NAME)) {
|
|
|
|
QMessageBox::critical(nullptr, QString(),
|
|
|
|
"Application is already running!");
|
|
|
|
return FORT_ERROR_INSTANCE;
|
|
|
|
}
|
2017-09-13 11:08:27 +00:00
|
|
|
|
2017-09-11 03:54:19 +00:00
|
|
|
FortManager fortManager(&fortSettings);
|
2019-02-08 19:25:01 +00:00
|
|
|
fortManager.launch();
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2018-08-24 11:28:26 +00:00
|
|
|
// Process control requests from clients
|
|
|
|
if (!controlManager.listen(&fortManager)) {
|
|
|
|
return FORT_ERROR_CONTROL;
|
|
|
|
}
|
|
|
|
|
2019-02-08 08:19:20 +00:00
|
|
|
return QApplication::exec();
|
2017-08-23 13:52:22 +00:00
|
|
|
}
|