+
+ //! Store a Message in the storage backend and set it's unique Id.
+ /** \note This method is threadsafe.
+ *
+ * \param message The message object to be stored
+ * \return true on success
+ */
+ static inline bool storeMessage(Message &message)
+ {
+ return instance()->_storage->logMessage(message);
+ }
+
+
+ //! Store a list of Messages in the storage backend and set their unique Id.
+ /** \note This method is threadsafe.
+ *
+ * \param messages The list message objects to be stored
+ * \return true on success
+ */
+ static inline bool storeMessages(MessageList &messages)
+ {
+ return instance()->_storage->logMessages(messages);
+ }
+
+
+ //! Request a certain number messages stored in a given buffer.
+ /** \param buffer The buffer we request messages from
+ * \param first if != -1 return only messages with a MsgId >= first
+ * \param last if != -1 return only messages with a MsgId < last
+ * \param limit if != -1 limit the returned list to a max of \limit entries
+ * \return The requested list of messages
+ */
+ static inline QList<Message> requestMsgs(UserId user, BufferId bufferId, MsgId first = -1, MsgId last = -1, int limit = -1)
+ {
+ return instance()->_storage->requestMsgs(user, bufferId, first, last, limit);
+ }
+
+
+ //! 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 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 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);
+ }
+
+
+ static inline QDateTime startTime() { return instance()->_startTime; }
+ static inline bool isConfigured() { return instance()->_configured; }
+ static bool sslSupported();
+ static QVariantList backendInfo();
+
+ static QString setup(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData);
+
+ static inline QTimer &syncTimer() { return instance()->_storageSyncTimer; }
+
+ inline OidentdConfigGenerator *oidentdConfigGenerator() const { return _oidentdConfigGenerator; }
+
+ static const int AddClientEventId;
+
+public slots:
+ //! Make storage data persistent
+ /** \note This method is threadsafe.
+ */
+ void syncStorage();
+ void setupInternalClientSession(InternalPeer *clientConnection);
+ QString setupCore(const QString &adminUser, const QString &adminPassword, const QString &backend, const QVariantMap &setupData);
+
+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);
+
+protected:
+ virtual void customEvent(QEvent *event);
+
+private slots:
+ bool startListening();
+ void stopListening(const QString &msg = QString());