- enum RunMode {
- Monolithic,
- ClientOnly,
- CoreOnly
- };
-
- struct BuildInfo {
- QString fancyVersionString; // clickable rev
- QString plainVersionString; // no <a> tag
-
- QString baseVersion;
- QString generatedVersion;
- QString commitHash;
- uint commitDate;
- QString buildDate;
- bool isSourceDirty;
- uint protocolVersion;
- uint clientNeedsProtocol;
- uint coreNeedsProtocol;
-
- QString applicationName;
- QString coreApplicationName;
- QString clientApplicationName;
- QString organizationName;
- QString organizationDomain;
- };
-
- virtual ~Quassel();
-
- static void setupBuildInfo(const QString &generated);
- static inline const BuildInfo & buildInfo();
- static inline RunMode runMode();
-
- static QString configDirPath();
-
- //! Returns a list of data directory paths
- /** There are several locations for applications to install their data files in. On Unix,
- * a common location is /usr/share; others include $PREFIX/share and additional directories
- * specified in the env variable XDG_DATA_DIRS.
- * \return A list of directory paths to look for data files in
- */
- static QStringList dataDirPaths();
-
- //! Searches for a data file in the possible data directories
- /** Data files can reside in $DATA_DIR/apps/quassel, where $DATA_DIR is one of the directories
- * returned by \sa dataDirPaths().
- * \Note With KDE integration enabled, files are searched (only) in KDE's appdata dirs.
- * \return The full path to the data file if found; a null QString else
- */
- static QString findDataFilePath(const QString &filename);
-
- static QString translationDirPath();
-
- //! Returns a list of directories we look for scripts in
- /** We look for a subdirectory named "scripts" in the configdir and in all datadir paths.
- * \return A list of directory paths containing executable scripts for /exec
- */
- static QStringList scriptDirPaths();
-
- static void loadTranslation(const QLocale &locale);
-
- static inline void setCliParser(AbstractCliParser *cliParser);
- static inline AbstractCliParser *cliParser();
- static inline QString optionValue(const QString &option);
- static inline bool isOptionSet(const QString &option);
-
- static const QString &coreDumpFileName();
-
- static bool DEBUG;
-
- static void logFatalMessage(const char *msg);
-
-protected:
- Quassel();
- virtual bool init();
- virtual void quit();
-
- inline void setRunMode(RunMode mode);
- inline void setDataDirPaths(const QStringList &paths);
- QStringList findDataDirPaths() const;
- inline void disableCrashhandler();
+ enum RunMode
+ {
+ Monolithic,
+ ClientOnly,
+ CoreOnly
+ };
+
+ struct BuildInfo
+ {
+ QString fancyVersionString; // clickable rev
+ QString plainVersionString; // no <a> tag
+
+ QString baseVersion;
+ QString generatedVersion;
+ QString commitHash;
+ QString commitDate;
+
+ uint protocolVersion; // deprecated
+
+ QString applicationName;
+ QString coreApplicationName;
+ QString clientApplicationName;
+ QString organizationName;
+ QString organizationDomain;
+ };
+
+ /**
+ * This enum defines the optional features supported by cores/clients prior to version 0.13.
+ *
+ * Since the number of features declared this way is limited to 16 (due to the enum not having a defined
+ * width in cores/clients prior to 0.13), and for more robustness when negotiating features on connect,
+ * the bitfield-based representation was replaced by a string-based representation in 0.13, support for
+ * which is indicated by having the ExtendedFeatures flag set. Extended features are defined in the Feature
+ * enum.
+ *
+ * @warning Do not alter this enum; new features must be added (only) to the @a Feature enum.
+ *
+ * @sa Feature
+ */
+ enum class LegacyFeature : quint32
+ {
+ SynchronizedMarkerLine = 0x0001,
+ SaslAuthentication = 0x0002,
+ SaslExternal = 0x0004,
+ HideInactiveNetworks = 0x0008,
+ PasswordChange = 0x0010,
+ CapNegotiation = 0x0020,
+ VerifyServerSSL = 0x0040,
+ CustomRateLimits = 0x0080,
+ // DccFileTransfer = 0x0100, // never in use
+ AwayFormatTimestamp = 0x0200,
+ Authenticators = 0x0400,
+ BufferActivitySync = 0x0800,
+ CoreSideHighlights = 0x1000,
+ SenderPrefixes = 0x2000,
+ RemoteDisconnect = 0x4000,
+ ExtendedFeatures = 0x8000,
+ };
+ Q_FLAGS(LegacyFeature)
+ Q_DECLARE_FLAGS(LegacyFeatures, LegacyFeature)
+
+ /**
+ * A list of features that are optional in core and/or client, but need runtime checking.
+ *
+ * Some features require an uptodate counterpart, but don't justify a protocol break.
+ * This is what we use this enum for. Add such features to it and check at runtime on the other
+ * side for their existence.
+ *
+ * For feature negotiation, these enum values are serialized as strings, so order does not matter. However,
+ * do not rename existing enum values to avoid breaking compatibility.
+ *
+ * This list should be cleaned up after every protocol break, as we can assume them to be present then.
+ */
+ enum class Feature : uint32_t
+ {
+ SynchronizedMarkerLine,
+ SaslAuthentication,
+ SaslExternal,
+ HideInactiveNetworks,
+ PasswordChange, ///< Remote password change
+ CapNegotiation, ///< IRCv3 capability negotiation, account tracking
+ VerifyServerSSL, ///< IRC server SSL validation
+ CustomRateLimits, ///< IRC server custom message rate limits
+ AwayFormatTimestamp, ///< Timestamp formatting in away (e.g. %%hh:mm%%)
+ Authenticators, ///< Whether or not the core supports auth backends
+ BufferActivitySync, ///< Sync buffer activity status
+ CoreSideHighlights, ///< Core-Side highlight configuration and matching
+ SenderPrefixes, ///< Show prefixes for senders in backlog
+ RemoteDisconnect, ///< Allow this peer to be remotely disconnected
+ ExtendedFeatures, ///< Extended features
+ LongTime, ///< Serialize time as 64-bit values
+ RichMessages, ///< Real Name and Avatar URL in backlog
+ BacklogFilterType, ///< BacklogManager supports filtering backlog by MessageType
+ EcdsaCertfpKeys, ///< ECDSA keys for CertFP in identities
+ LongMessageId, ///< 64-bit IDs for messages
+ SyncedCoreInfo, ///< CoreInfo dynamically updated using signals
+ LoadBacklogForwards, ///< Allow loading backlog in ascending order, old to new
+ SkipIrcCaps, ///< Control what IRCv3 capabilities are skipped during negotiation
+ };
+ Q_ENUMS(Feature)
+
+ class Features;
+
+ Quassel();
+
+ void init(RunMode runMode);
+
+ /**
+ * Provides access to the Logger instance.
+ *
+ * @returns The Logger instance
+ */
+ Logger* logger() const;
+
+ static void setupBuildInfo();
+ static const BuildInfo& buildInfo();
+ static RunMode runMode();
+
+ static QString configDirPath();
+
+ //! Returns a list of data directory paths
+ /** There are several locations for applications to install their data files in. On Unix,
+ * a common location is /usr/share; others include $PREFIX/share and additional directories
+ * specified in the env variable XDG_DATA_DIRS.
+ * \return A list of directory paths to look for data files in
+ */
+ static QStringList dataDirPaths();
+
+ //! Searches for a data file in the possible data directories
+ /** Data files can reside in $DATA_DIR/apps/quassel, where $DATA_DIR is one of the directories
+ * returned by \sa dataDirPaths().
+ * \Note With KDE integration enabled, files are searched (only) in KDE's appdata dirs.
+ * \return The full path to the data file if found; a null QString else
+ */
+ static QString findDataFilePath(const QString& filename);
+
+ static QString translationDirPath();
+
+ //! Returns a list of directories we look for scripts in
+ /** We look for a subdirectory named "scripts" in the configdir and in all datadir paths.
+ * \return A list of directory paths containing executable scripts for /exec
+ */
+ static QStringList scriptDirPaths();
+
+ static void loadTranslation(const QLocale& locale);
+
+ static QString optionValue(const QString& option);
+ static bool isOptionSet(const QString& option);
+
+ using ReloadHandler = std::function<bool()>;
+
+ static void registerReloadHandler(ReloadHandler handler);
+
+ using QuitHandler = std::function<void()>;
+
+ /**
+ * 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);