+
+ //! Request a certain number of messages across all buffers
+ /** \param first if != -1 return only messages with a MsgId >= first
+ * \param last if != -1 return only messages with a MsgId < last
+ * \param limit Max amount of messages
+ * \return The requested list of messages
+ */
+ static inline QList<Message> requestAllMsgs(UserId user, MsgId first = -1, MsgId last = -1, int limit = -1)
+ {
+ return instance()->_storage->requestAllMsgs(user, first, last, limit);
+ }
+
+
+ //! Request a certain number of messages across all buffers, matching certain filters
+ /** \param first if != -1 return only messages with a MsgId >= first
+ * \param last if != -1 return only messages with a MsgId < last
+ * \param limit Max amount of messages
+ * \param type The Message::Types that should be returned
+ * \return The requested list of messages
+ */
+ static inline QList<Message> requestAllMsgsFiltered(UserId user, MsgId first = -1, MsgId last = -1, int limit = -1,
+ Message::Types type = Message::Types{-1},
+ Message::Flags flags = Message::Flags{-1})
+ {
+ return instance()->_storage->requestAllMsgsFiltered(user, first, last, limit, type, flags);
+ }
+
+
+ //! Request a list of all buffers known to a user.
+ /** This method is used to get a list of all buffers we have stored a backlog from.
+ * \note This method is threadsafe.
+ *
+ * \param user The user whose buffers we request
+ * \return A list of the BufferInfos for all buffers as requested
+ */
+ static inline QList<BufferInfo> requestBuffers(UserId user)
+ {
+ return instance()->_storage->requestBuffers(user);
+ }
+
+
+ //! Request a list of BufferIds for a given NetworkId
+ /** \note This method is threadsafe.
+ *
+ * \param user The user whose buffers we request
+ * \param networkId The NetworkId of the network in question
+ * \return List of BufferIds belonging to the Network
+ */
+ static inline QList<BufferId> requestBufferIdsForNetwork(UserId user, NetworkId networkId)
+ {
+ return instance()->_storage->requestBufferIdsForNetwork(user, networkId);
+ }
+
+
+ //! Remove permanently a buffer and it's content from the storage backend
+ /** This call cannot be reverted!
+ * \note This method is threadsafe.
+ *
+ * \param user The user who is the owner of the buffer
+ * \param bufferId The bufferId
+ * \return true if successfull
+ */
+ static inline bool removeBuffer(const UserId &user, const BufferId &bufferId)
+ {
+ return instance()->_storage->removeBuffer(user, bufferId);
+ }
+
+
+ //! Rename a Buffer
+ /** \note This method is threadsafe.
+ * \param user The id of the buffer owner
+ * \param bufferId The bufferId
+ * \param newName The new name of the buffer
+ * \return true if successfull
+ */
+ static inline bool renameBuffer(const UserId &user, const BufferId &bufferId, const QString &newName)
+ {
+ return instance()->_storage->renameBuffer(user, bufferId, newName);
+ }
+
+
+ //! Merge the content of two Buffers permanently. This cannot be reversed!
+ /** \note This method is threadsafe.
+ * \param user The id of the buffer owner
+ * \param bufferId1 The bufferId of the remaining buffer
+ * \param bufferId2 The buffer that is about to be removed
+ * \return true if successfulln
+ */
+ static inline bool mergeBuffersPermanently(const UserId &user, const BufferId &bufferId1, const BufferId &bufferId2)
+ {
+ return instance()->_storage->mergeBuffersPermanently(user, bufferId1, bufferId2);
+ }
+
+
+ //! Update the LastSeenDate for a Buffer
+ /** This Method is used to make the LastSeenDate of a Buffer persistent
+ * \note This method is threadsafe.
+ *
+ * \param user The Owner of that Buffer
+ * \param bufferId The buffer id
+ * \param MsgId The Message id of the message that has been just seen
+ */
+ static inline void setBufferLastSeenMsg(UserId user, const BufferId &bufferId, const MsgId &msgId)
+ {
+ return instance()->_storage->setBufferLastSeenMsg(user, bufferId, msgId);
+ }
+
+
+ //! Get a usable sysident for the given user in oidentd-strict mode
+ /** \param user The user to retrieve the sysident for
+ * \return The authusername
+ */
+ QString strictSysIdent(UserId user) const;
+
+
+ //! Get a Hash of all last seen message ids
+ /** This Method is called when the Quassel Core is started to restore the lastSeenMsgIds
+ * \note This method is threadsafe.
+ *
+ * \param user The Owner of the buffers
+ */
+ static inline QHash<BufferId, MsgId> bufferLastSeenMsgIds(UserId user)
+ {
+ return instance()->_storage->bufferLastSeenMsgIds(user);
+ }
+
+
+ //! Update the MarkerLineMsgId for a Buffer
+ /** This Method is used to make the marker line position of a Buffer persistent
+ * \note This method is threadsafe.
+ *
+ * \param user The Owner of that Buffer
+ * \param bufferId The buffer id
+ * \param MsgId The Message id where the marker line should be placed
+ */
+ static inline void setBufferMarkerLineMsg(UserId user, const BufferId &bufferId, const MsgId &msgId)
+ {
+ return instance()->_storage->setBufferMarkerLineMsg(user, bufferId, msgId);
+ }
+
+
+ //! Get a Hash of all marker line message ids
+ /** This Method is called when the Quassel Core is started to restore the MarkerLineMsgIds
+ * \note This method is threadsafe.
+ *
+ * \param user The Owner of the buffers
+ */
+ static inline QHash<BufferId, MsgId> bufferMarkerLineMsgIds(UserId user)
+ {
+ return instance()->_storage->bufferMarkerLineMsgIds(user);
+ }
+
+ //! Update the BufferActivity for a Buffer
+ /** This Method is used to make the activity state of a Buffer persistent
+ * \note This method is threadsafe.
+ *
+ * \param user The Owner of that Buffer
+ * \param bufferId The buffer id
+ * \param MsgId The Message id where the marker line should be placed
+ */
+ static inline void setBufferActivity(UserId user, BufferId bufferId, Message::Types activity) {
+ return instance()->_storage->setBufferActivity(user, bufferId, activity);
+ }
+
+
+ //! Get a Hash of all buffer activity states
+ /** This Method is called when the Quassel Core is started to restore the BufferActivity
+ * \note This method is threadsafe.
+ *
+ * \param user The Owner of the buffers
+ */
+ static inline QHash<BufferId, Message::Types> bufferActivities(UserId user) {
+ return instance()->_storage->bufferActivities(user);
+ }
+
+ //! Get the bitset of buffer activity states for a buffer
+ /** This method is used to load the activity state of a buffer when its last seen message changes.
+ * \note This method is threadsafe.
+ *
+ * \param bufferId The buffer
+ * \param lastSeenMsgId The last seen message
+ */
+ static inline Message::Types bufferActivity(BufferId bufferId, MsgId lastSeenMsgId) {
+ return instance()->_storage->bufferActivity(bufferId, lastSeenMsgId);
+ }
+
+ //! Update the highlight count for a Buffer
+ /** This Method is used to make the highlight count state of a Buffer persistent
+ * \note This method is threadsafe.
+ *
+ * \param user The Owner of that Buffer
+ * \param bufferId The buffer id
+ * \param MsgId The Message id where the marker line should be placed
+ */
+ static inline void setHighlightCount(UserId user, BufferId bufferId, int highlightCount) {
+ return instance()->_storage->setHighlightCount(user, bufferId, highlightCount);
+ }
+
+
+ //! Get a Hash of all highlight count states
+ /** This Method is called when the Quassel Core is started to restore the highlight count
+ * \note This method is threadsafe.
+ *
+ * \param user The Owner of the buffers
+ */
+ static inline QHash<BufferId, int> highlightCounts(UserId user) {
+ return instance()->_storage->highlightCounts(user);
+ }
+ //! Get the highlight count states for a buffer
+ /** This method is used to load the highlight count of a buffer when its last seen message changes.
+ * \note This method is threadsafe.
+ *
+ * \param bufferId The buffer
+ * \param lastSeenMsgId The last seen message
+ */
+ static inline int highlightCount(BufferId bufferId, MsgId lastSeenMsgId) {
+ return instance()->_storage->highlightCount(bufferId, lastSeenMsgId);
+ }
+
+ static inline QDateTime startTime() { return instance()->_startTime; }
+ static inline bool isConfigured() { return instance()->_configured; }
+
+ /**
+ * Whether or not strict ident mode is enabled, locking users' idents to Quassel username
+ *
+ * @return True if strict mode enabled, otherwise false
+ */
+ static inline bool strictIdentEnabled() { return instance()->_strictIdentEnabled; }
+
+ static bool sslSupported();
+
+ static QVariantList backendInfo();
+ static QVariantList authenticatorInfo();
+
+ static QString setup(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authenticator, const QVariantMap &authSetupMap);
+
+ static inline QTimer *syncTimer() { return &instance()->_storageSyncTimer; }
+
+ inline OidentdConfigGenerator *oidentdConfigGenerator() const { return _oidentdConfigGenerator; }
+ inline IdentServer *identServer() const { return _identServer; }
+
+ static const int AddClientEventId;
+
+signals:
+ //! Sent when a BufferInfo is updated in storage.
+ void bufferInfoUpdated(UserId user, const BufferInfo &info);
+
+ //! Relay from CoreSession::sessionState(). Used for internal connection only
+ void sessionState(const Protocol::SessionState &sessionState);
+
+ //! Emitted when database schema upgrade starts or ends
+ void dbUpgradeInProgress(bool inProgress);
+
+ //! Emitted when a fatal error was encountered during async initialization
+ void exitRequested(int exitCode, const QString &reason);
+
+ //! Emitted once core shutdown is complete
+ void shutdownComplete();
+
+public slots:
+ void initAsync();
+
+ /** Persist storage.
+ *
+ * @note This method is threadsafe.
+ */
+ void syncStorage();
+
+ /**
+ * Reload SSL certificates used for connection with clients.
+ *
+ * @return True if certificates reloaded successfully, otherwise false.
+ */
+ bool reloadCerts();
+
+ void cacheSysIdent();
+
+ QString setupCore(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData, const QString &authenticator, const QVariantMap &authSetupMap);
+
+ void connectInternalPeer(QPointer<InternalPeer> peer);
+
+protected:
+ void customEvent(QEvent *event) override;
+
+private slots:
+ bool startListening();
+ void stopListening(const QString &msg = QString());