X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fquassel.h;h=fd1dfd7991ddf041a49d03fce6fb3726e569dafa;hp=17e252c13d3cf28050d4eb77f73657156435c172;hb=8582c2ad5708a1972c85bea1cf8d81ad3ece4814;hpb=493043890c74e4679bb3fdaf512a0e1e52c426d3 diff --git a/src/common/quassel.h b/src/common/quassel.h index 17e252c1..fd1dfd79 100644 --- a/src/common/quassel.h +++ b/src/common/quassel.h @@ -20,25 +20,27 @@ #pragma once +#include "common-export.h" + #include -#include #include +#include #include #include -#include #include +#include #include #include -#include "abstractcliparser.h" +#include "abstractsignalwatcher.h" #include "singleton.h" class QFile; class Logger; -class Quassel : public QObject, public Singleton +class COMMON_EXPORT Quassel : public QObject, public Singleton { // TODO Qt5: Use Q_GADGET Q_OBJECT @@ -114,11 +116,7 @@ public: * * This list should be cleaned up after every protocol break, as we can assume them to be present then. */ - #if QT_VERSION >= 0x050000 enum class Feature : uint32_t { - #else - enum Feature { - #endif SynchronizedMarkerLine, SaslAuthentication, SaslExternal, @@ -137,9 +135,7 @@ public: LongTime, ///< Serialize time as 64-bit values RichMessages, ///< Real Name and Avatar URL in backlog BacklogFilterType, ///< BacklogManager supports filtering backlog by MessageType -#if QT_VERSION >= 0x050500 EcdsaCertfpKeys, ///< ECDSA keys for CertFP in identities -#endif LongMessageId, ///< 64-bit IDs for messages SyncedCoreInfo, ///< CoreInfo dynamically updated using signals }; @@ -149,6 +145,8 @@ public: Quassel(); + void init(RunMode runMode); + /** * Provides access to the Logger instance. * @@ -188,7 +186,6 @@ public: static void loadTranslation(const QLocale &locale); - static void setCliParser(std::shared_ptr cliParser); static QString optionValue(const QString &option); static bool isOptionSet(const QString &option); @@ -198,29 +195,34 @@ public: using QuitHandler = std::function; + /** + * Registers a handler that is called when the application is supposed to quit. + * + * @note If multiple handlers are registered, they are processed in order of registration. + * @note If any handler is registered, quit() will not call QCoreApplication::quit(). It relies + * on one of the handlers doing so, instead. + * @param quitHandler Handler to register + */ static void registerQuitHandler(QuitHandler quitHandler); const QString &coreDumpFileName(); +public slots: + /** + * Requests to quit the application. + * + * Calls any registered quit handlers. If no handlers are registered, calls QCoreApplication::quit(). + */ + void quit(); + signals: void messageLogged(const QDateTime &timeStamp, const QString &msg); -protected: - static bool init(); - - static void setRunMode(Quassel::RunMode runMode); - - static void setDataDirPaths(const QStringList &paths); - static QStringList findDataDirPaths(); - static void disableCrashHandler(); - - friend class CoreApplication; - friend class QtUiApplication; - friend class MonolithicApplication; - private: - void setupEnvironment(); void registerMetaTypes(); + void setupSignalHandling(); + void setupEnvironment(); + void setupCliParser(); /** * Requests a reload of relevant runtime configuration. @@ -232,31 +234,25 @@ private: */ bool reloadConfig(); - /** - * Requests to quit the application. - * - * Calls any registered quit handlers. If no handlers are registered, calls QCoreApplication::quit(). - */ - void quit(); - void logBacktrace(const QString &filename); - static void handleSignal(int signal); +private slots: + void handleSignal(AbstractSignalWatcher::Action action); private: BuildInfo _buildInfo; RunMode _runMode; - bool _initialized{false}; - bool _handleCrashes{true}; + bool _quitting{false}; QString _coreDumpFileName; QString _configDirPath; QStringList _dataDirPaths; QString _translationDirPath; - std::shared_ptr _cliParser; + QCommandLineParser _cliParser; Logger *_logger; + AbstractSignalWatcher *_signalWatcher{nullptr}; std::vector _reloadHandlers; std::vector _quitHandlers; @@ -269,7 +265,7 @@ private: * * @sa Quassel::Feature */ -class Quassel::Features +class COMMON_EXPORT Quassel::Features { public: /**