AusweisApp2/src/main.cpp

166 lines
5.1 KiB
C++
Raw Normal View History

2017-12-20 14:54:05 +01:00
/*
2018-03-28 15:10:51 +02:00
* \copyright Copyright (c) 2014-2018 Governikus GmbH & Co. KG, Germany
2017-12-20 14:54:05 +01:00
*/
2017-07-03 09:30:10 +02:00
#include "controller/AppController.h"
2017-09-15 10:23:30 +02:00
#include "CommandLineParser.h"
2017-07-03 09:30:10 +02:00
#include "global/BuildHelper.h"
2017-12-20 14:54:05 +01:00
#include "global/DeviceInfo.h"
2017-07-03 09:30:10 +02:00
#include "global/LogHandler.h"
2017-09-15 10:23:30 +02:00
#include "SignalHandler.h"
2017-07-03 09:30:10 +02:00
#include <QLoggingCategory>
#include <QSslSocket>
#include <QSysInfo>
#include <QtPlugin>
2017-09-15 10:23:30 +02:00
#include <QThread>
2017-07-03 09:30:10 +02:00
2017-07-03 09:33:28 +02:00
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || defined(Q_OS_WINRT)
2017-07-03 09:30:10 +02:00
#include <QGuiApplication>
#define QAPP QGuiApplication
#else
#include <QApplication>
#define QAPP QApplication
#endif
// Includes for version API
#include <openssl/crypto.h>
2017-12-20 14:54:05 +01:00
#if !defined(Q_OS_WINRT)
Q_IMPORT_PLUGIN(RemoteReaderManagerPlugIn)
#endif
2017-07-03 09:33:28 +02:00
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(Q_OS_WINRT)
2017-07-03 09:30:10 +02:00
Q_IMPORT_PLUGIN(PcscReaderManagerPlugIn)
Q_IMPORT_PLUGIN(WebserviceActivationHandler)
#endif
Q_IMPORT_PLUGIN(InternalActivationHandler)
#if defined(Q_OS_ANDROID)
Q_IMPORT_PLUGIN(NfcReaderManagerPlugIn)
Q_IMPORT_PLUGIN(IntentActivationHandler)
#endif
#if defined(Q_OS_IOS)
Q_IMPORT_PLUGIN(CustomSchemeActivationHandler)
2017-12-20 14:54:05 +01:00
Q_IMPORT_PLUGIN(QJpegPlugin)
Q_IMPORT_PLUGIN(QSvgPlugin)
Q_IMPORT_PLUGIN(QtQmlModelsPlugin)
Q_IMPORT_PLUGIN(QtQmlStateMachinePlugin)
Q_IMPORT_PLUGIN(QtGraphicalEffectsPlugin)
Q_IMPORT_PLUGIN(QtGraphicalEffectsPrivatePlugin)
// Do not delete the comments to avoid searching for the class name
Q_IMPORT_PLUGIN(QtQuickExtrasStylesPlugin)
Q_IMPORT_PLUGIN(QtQuickControls1Plugin)
//Q_IMPORT_PLUGIN(QtQuickControls2MaterialStylePlugin)
//Q_IMPORT_PLUGIN(QtQuickControls2UniversalStylePlugin)
Q_IMPORT_PLUGIN(QtQuickControls2Plugin)
//Q_IMPORT_PLUGIN(QtQuick2DialogsPrivatePlugin)
Q_IMPORT_PLUGIN(QtQuick2DialogsPlugin)
//Q_IMPORT_PLUGIN(QtQuickExtrasPlugin)
Q_IMPORT_PLUGIN(QtQuickLayoutsPlugin)
//Q_IMPORT_PLUGIN(QQmlLocalStoragePlugin)
//Q_IMPORT_PLUGIN(QtQuick2ParticlesPlugin)
Q_IMPORT_PLUGIN(QtQuickTemplates2Plugin)
Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)
Q_IMPORT_PLUGIN(QtQuick2Plugin)
2017-07-03 09:30:10 +02:00
#endif
2017-09-15 10:23:30 +02:00
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || (defined(Q_OS_LINUX) && !defined(QT_NO_DEBUG))
2017-07-03 09:30:10 +02:00
Q_IMPORT_PLUGIN(BluetoothReaderManagerPlugIn)
#endif
2017-07-03 09:33:28 +02:00
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(Q_OS_WINRT)
2017-07-03 09:30:10 +02:00
Q_IMPORT_PLUGIN(UIPlugInCli)
Q_IMPORT_PLUGIN(UIPlugInWidgets)
#endif
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || !defined(QT_NO_DEBUG)
Q_IMPORT_PLUGIN(UIPlugInJsonApi)
Q_IMPORT_PLUGIN(UIPlugInAidl)
Q_IMPORT_PLUGIN(UIPlugInQml)
#endif
#ifndef QT_NO_DEBUG
Q_IMPORT_PLUGIN(UIPlugInWebSocket)
#endif
using namespace governikus;
Q_DECLARE_LOGGING_CATEGORY(init)
static inline void printInfo()
{
qCDebug(init) << "Logging to" << LogHandler::getInstance();
qCInfo(init) << "##################################################";
qCInfo(init) << "### ApplicationName:" << QCoreApplication::applicationName();
qCInfo(init) << "### ApplicationVersion:" << QCoreApplication::applicationVersion();
qCInfo(init) << "### OrganizationName:" << QCoreApplication::organizationName();
qCInfo(init) << "### OrganizationDomain:" << QCoreApplication::organizationDomain();
qCInfo(init) << "### Build:" << BuildHelper::getDateTime();
qCInfo(init) << "### System:" << QSysInfo::prettyProductName();
qCInfo(init) << "### Kernel:" << QSysInfo::kernelVersion();
qCInfo(init) << "### Architecture:" << QSysInfo::currentCpuArchitecture();
#ifdef Q_OS_ANDROID
qCInfo(init) << "### Device:" << DeviceInfo::getPrettyInfo();
2017-07-03 09:33:28 +02:00
qCInfo(init) << "### VersionCode:" << BuildHelper::getVersionCode();
2017-12-20 14:54:05 +01:00
#else
qCInfo(init) << "### Devicename:" << DeviceInfo::getName();
2017-07-03 09:30:10 +02:00
#endif
qCInfo(init) << "### Qt Version:" << qVersion();
qCInfo(init) << "### OpenSSL Version:" << QSslSocket::sslLibraryVersionString();
qCInfo(init) << "##################################################";
if (QSslSocket::sslLibraryVersionString() != QLatin1String(SSLeay_version(0)))
{
qCWarning(init) << "Linked OpenSSL Version differs:" << SSLeay_version(0);
}
const auto libPathes = QCoreApplication::libraryPaths();
for (const auto& path : libPathes)
{
qCDebug(init) << "Library path:" << path;
}
}
2017-12-20 14:54:05 +01:00
#include "config.h" // use in main only!
2017-07-03 09:33:28 +02:00
Q_DECL_EXPORT int main(int argc, char** argv)
2017-07-03 09:30:10 +02:00
{
2017-12-20 14:54:05 +01:00
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QCoreApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif
2017-07-03 09:30:10 +02:00
QCoreApplication::setOrganizationName(QStringLiteral(VENDOR));
QCoreApplication::setOrganizationDomain(QStringLiteral(VENDOR_DOMAIN));
2017-12-20 14:54:05 +01:00
QCoreApplication::setApplicationName(QStringLiteral(PRODUCT));
2017-07-03 09:30:10 +02:00
QCoreApplication::setApplicationVersion(QStringLiteral(VERSION));
QGuiApplication::setQuitOnLastWindowClosed(false);
QAPP app(argc, argv);
QThread::currentThread()->setObjectName(QStringLiteral("MainThread"));
LogHandler::getInstance().init();
SignalHandler::getInstance().init();
CommandLineParser::getInstance().parse();
printInfo();
AppController controller;
if (!controller.start())
{
qCCritical(init) << "Cannot start application controller, exit application";
return EXIT_FAILURE;
}
SignalHandler::getInstance().setController(controller);
return SignalHandler::getInstance().shouldQuit() ? EXIT_SUCCESS : app.exec();
}