X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fquassel.h;h=157386a8e47118971fd0f193c1418846f40088f1;hp=fd91f9a3371d590f2532b65a72455aea8814e88d;hb=1f2784bfa1c1ce90defa32f13c78afd72c227bfd;hpb=20f446a492d8e681156423f0dc3637db78c45bae diff --git a/src/common/quassel.h b/src/common/quassel.h index fd91f9a3..157386a8 100644 --- a/src/common/quassel.h +++ b/src/common/quassel.h @@ -32,10 +32,13 @@ #include #include "abstractcliparser.h" +#include "singleton.h" class QFile; -class Quassel : public QObject +class Logger; + +class Quassel : public QObject, public Singleton { // TODO Qt5: Use Q_GADGET Q_OBJECT @@ -131,17 +134,27 @@ public: SenderPrefixes, ///< Show prefixes for senders in backlog RemoteDisconnect, ///< Allow this peer to be remotely disconnected ExtendedFeatures, ///< Extended features - LongMessageTime, ///< Serialize message time as 64-bit + 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 }; Q_ENUMS(Feature) class Features; - static Quassel *instance(); + Quassel(); + + /** + * Provides access to the Logger instance. + * + * @returns The Logger instance + */ + Logger *logger() const; static void setupBuildInfo(); static const BuildInfo &buildInfo(); @@ -179,31 +192,37 @@ public: static QString optionValue(const QString &option); static bool isOptionSet(const QString &option); - enum LogLevel { - DebugLevel, - InfoLevel, - WarningLevel, - ErrorLevel - }; - - static LogLevel logLevel(); - static void setLogLevel(LogLevel logLevel); - static QFile *logFile(); - static bool logToSyslog(); - - static void logFatalMessage(const char *msg); - using ReloadHandler = std::function; static void registerReloadHandler(ReloadHandler handler); 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 destroy(); static void setRunMode(Quassel::RunMode runMode); @@ -216,12 +235,9 @@ protected: friend class MonolithicApplication; private: - Quassel(); void setupEnvironment(); void registerMetaTypes(); - const QString &coreDumpFileName(); - /** * Requests a reload of relevant runtime configuration. * @@ -232,13 +248,6 @@ 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); @@ -248,18 +257,17 @@ private: RunMode _runMode; bool _initialized{false}; bool _handleCrashes{true}; + bool _quitting{false}; QString _coreDumpFileName; QString _configDirPath; QStringList _dataDirPaths; QString _translationDirPath; - LogLevel _logLevel{InfoLevel}; - bool _logToSyslog{false}; - std::unique_ptr _logFile; - std::shared_ptr _cliParser; + Logger *_logger; + std::vector _reloadHandlers; std::vector _quitHandlers; };