6 #ifndef SWIFT_CORE_APPLICATION_H
7 #define SWIFT_CORE_APPLICATION_H
13 #include <QCommandLineOption>
14 #include <QCommandLineParser>
16 #include <QNetworkAccessManager>
18 #include <QReadWriteLock>
19 #include <QScopedPointer>
21 #include <QStringList>
46 class CLogCategoryList;
47 namespace shared_state
58 class CWebDataServices;
62 class IContextApplication;
64 class CContextAudioBase;
65 class IContextNetwork;
66 class IContextOwnAircraft;
67 class IContextSimulator;
116 bool isAlreadyRunning()
const;
119 virtual void gracefulShutdown();
123 bool isShuttingDown()
const;
127 bool isIncognito()
const;
131 void setIncognito(
bool incognito);
135 void toggleIncognito();
144 const QString &getApplicationNameAndVersion()
const;
147 const QString &getApplicationNameVersionDetailed()
const;
157 void reloadUpdateInfo();
164 const QString &versionStringDetailed()
const;
167 const QString &swiftVersionString()
const;
170 const char *swiftVersionChar();
185 static QString getTemporaryDirectory();
189 static bool registerAsRunning();
193 static bool unregisterAsRunning();
196 static void exit(
int retcode = EXIT_SUCCESS);
202 static void processEventsFor(
int milliseconds);
211 bool hasUnsavedSettings()
const;
214 void saveSettingsOnShutdown(
bool saveSettings);
241 void addDBusAddressOption();
244 QString getCmdDBusAddressValue()
const;
247 void addNetworkOptions();
250 void addAudioOptions();
253 bool skipSingleApplicationCheck()
const;
256 bool isParserOptionSet(
const QString &option)
const;
274 bool parseCommandLineArgsAndLoadSetup();
277 virtual void cmdLineErrorMessage(
const QString &text,
const QString &informativeText)
const;
286 void simulateCrash();
290 void simulateAssert();
294 void enableCrashDumpUpload(
bool enable);
297 bool isSupportingCrashpad()
const;
310 bool hasSimulator()
const;
323 bool supportsContexts(
bool ignoreShutdownTest =
false)
const;
342 initAndStartWebDataServices(CWebReaderFlags::WebReader webReader,
349 bool isLocalContext()
const;
352 bool isDBusContext()
const;
378 virtual bool hasMinimumMappingVersion()
const;
381 bool hasSetupReader()
const;
388 bool isSetupAvailable()
const;
405 virtual bool start();
412 static constexpr
int NoRedirects = -1;
413 static constexpr
int NoLogRequestId = -1;
414 static constexpr
int DefaultMaxRedirects = 2;
423 void deleteAllCookies();
435 bool hasWebDataServices()
const;
444 int maxRedirects = DefaultMaxRedirects);
449 const ProgressSlot &progress,
int maxRedirects = DefaultMaxRedirects);
454 const ProgressSlot &progress,
int maxRedirects = DefaultMaxRedirects);
459 int maxRedirects = DefaultMaxRedirects);
464 const ProgressSlot &progress,
int maxRedirects = DefaultMaxRedirects);
469 const ProgressSlot &progress,
int maxRedirects = DefaultMaxRedirects);
474 const CallbackSlot &callback,
int maxRedirects = DefaultMaxRedirects);
479 const CallbackSlot &callback);
485 const CallbackSlot &callback);
490 int maxRedirects = NoRedirects);
495 int maxRedirects = NoRedirects);
502 int maxRedirects = DefaultMaxRedirects);
527 virtual void onStartUpCompleted();
530 void init(
bool withMetadata);
543 virtual void onCoreFacadeStarted();
561 static const QString &executable();
576 bool m_parsed =
false;
577 bool m_started =
false;
578 bool m_alreadyRunning =
false;
579 std::atomic_bool m_shutdown {
false };
580 std::atomic_bool m_incognito {
false };
581 std::atomic_bool m_shutdownInProgress {
false };
588 void cmdLineHelpMessage();
591 void cmdLineVersionMessage();
603 bool initIsRunningInDeveloperEnvironment()
const;
608 using NetworkRequestOrPostFunction =
614 int maxRedirects, NetworkRequestOrPostFunction requestOrPostMethod);
619 const ProgressSlot &progress,
int maxRedirects,
620 NetworkRequestOrPostFunction getPostOrDeleteRequest);
623 void httpRequestImplInQAMThread(
const QNetworkRequest &request,
int logId,
const CallbackSlot &callback,
624 const ProgressSlot &progress,
int maxRedirects,
625 NetworkRequestOrPostFunction getPostOrDeleteRequest);
628 void tagApplicationDataDirectory();
632 bool startupCheck()
const;
636 bool loadSetupAndHandleErrors();
642 bool parseCommandLineArguments();
653 const QString m_applicationName;
656 bool m_devFlag =
false;
657 bool m_saveSettingsOnShutdown =
true;
658 bool m_localSettingsLoaded =
false;
662 this, &CApplication::onCrashDumpUploadEnabledChanged
666 void onCrashDumpUploadEnabledChanged();
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
void aboutToShutdown()
About to shutdown.
CInputManager * getInputManager() const
The input manager, if available.
const QNetworkAccessManager * getNetworkAccessManager() const
Access to access manager.
bool isDeveloperFlagSet() const
Running with dev.flag?
QNetworkAccessManager * getNetworkAccessManager()
Access to access manager.
QCommandLineParser m_parser
cmd parser
void coreFacadeStarted()
Facade started.
QList< QCommandLineOption > m_allOptions
All registered options.
CCoreFacade * getCoreFacade()
Get the facade.
const QString & getApplicationName() const
Application name and version.
void updateInfoAvailable(bool success)
Update info available (cache, web load)
const CCoreFacadeConfig & getCoreFacadeConfig() const
The core facade config.
const CCoreFacade * getCoreFacade() const
Get the facade.
virtual swift::misc::CStatusMessageList startHookIn()
Can be used to start special services.
virtual bool parsingHookIn()
Can be used to parse specialized arguments.
void webDataServicesStarted(bool success)
Web data services started.
const swift::misc::CApplicationInfo & getApplicationInfo() const
swift application running
static QStringList arguments()
Similar to QCoreApplication::arguments.
void startUpCompleted(bool success)
Startup has been completed Will be triggered shortly before starting the event loop.
Configuration object for the contexts.
The class providing facades (the contexts) for all DBus relevant operations.
Read the central URLs / locations of our data, setup and versions.
Encapsulates reading data from web sources.
Audio context base class.
Application context interface.
Global settings for readers, debug flags, etc.
Value object encapsulating a list of reader configs.
Description of a swift application.
Application
Enumeration of application roles.
List of swift application descriptions.
Base class with a member CIdentifier to be inherited by a class which has an identity in the environm...
Class template for accessing a specific value in the CSettingsCache.
Callable wrapper for a member function with function signature F.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
Distributions for channel.
Update info, i.e. artifacts and distributions.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
A transport mechanism using signals and slots distributed by DBus.
Backend services of the swift project, like dealing with the network or the simulators.
void registerMetadata()
Register all relevant metadata in swift::core.
Free functions in swift::misc.
QString applicationName()
Get application name.
#define SWIFT_CORE_EXPORT
Export a class or function from the library.