cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / core / storage.h
index b28a99f..ecf9073 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2019 by the Quassel Project                        *
+ *   Copyright (C) 2005-2022 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef STORAGE_H
-#define STORAGE_H
+#pragma once
 
-#include <QtCore>
+#include <vector>
+
+#include <QMap>
+#include <QObject>
+#include <QProcessEnvironment>
+#include <QString>
+#include <QVariant>
+#include <QVariantList>
 
 #include "coreidentity.h"
 #include "message.h"
@@ -39,7 +45,7 @@ public:
     {
         IsReady,      // ready to go
         NeedsSetup,   // need basic setup (ask the user for input)
-        NotAvailable  // remove the storage backend from the list of avaliable backends
+        NotAvailable  // remove the storage backend from the list of available backends
     };
 
     enum HashVersion
@@ -50,7 +56,6 @@ public:
 
     };
 
-public slots:
     /* General */
 
     //! Check if the storage type is available.
@@ -102,7 +107,7 @@ public slots:
 
     //! Makes temp data persistent
     /** This Method is periodically called by the Quassel Core to make temporary
-     *  data persistant. This reduces the data loss drastically in the
+     *  data persistent. This reduces the data loss drastically in the
      *  unlikely case of a Core crash.
      */
     virtual void sync() = 0;
@@ -194,7 +199,7 @@ public slots:
     virtual IdentityId createIdentity(UserId user, CoreIdentity& identity) = 0;
     virtual bool updateIdentity(UserId user, const CoreIdentity& identity) = 0;
     virtual void removeIdentity(UserId user, IdentityId identityId) = 0;
-    virtual QList<CoreIdentity> identities(UserId user) = 0;
+    virtual std::vector<CoreIdentity> identities(UserId user) = 0;
 
     /* Network handling */
 
@@ -209,7 +214,7 @@ public slots:
     /**
      *  \param user        The core user
      *  \param networkInfo The Updated NetworkInfo
-     *  \return true if successfull.
+     *  \return true if successful.
      */
     virtual bool updateNetwork(UserId user, const NetworkInfo& info) = 0;
 
@@ -218,7 +223,7 @@ public slots:
      *
      *  \param user        The core user
      *  \param networkId   The network to delete
-     *  \return true if successfull.
+     *  \return true if successful.
      */
     virtual bool removeNetwork(UserId user, const NetworkId& networkId) = 0;
 
@@ -228,7 +233,7 @@ public slots:
      *  \param user        The core user
      *  \return QList<NetworkInfo>.
      */
-    virtual QList<NetworkInfo> networks(UserId user) = 0;
+    virtual std::vector<NetworkInfo> networks(UserId user) = 0;
 
     //! Get a list of Networks to restore
     /** Return a list of networks the user was connected at the time of core shutdown
@@ -236,7 +241,7 @@ public slots:
      *
      *  \param user  The User Id in question
      */
-    virtual QList<NetworkId> connectedNetworks(UserId user) = 0;
+    virtual std::vector<NetworkId> connectedNetworks(UserId user) = 0;
 
     //! Update the connected state of a network
     /** \note This method is threadsafe
@@ -317,7 +322,7 @@ public slots:
      *  \param networkId The network id
      *  \param type      The type of the buffer (StatusBuffer, Channel, etc.)
      *  \param buffer  The buffer name (if empty, the net's status buffer is returned)
-     *  \param create    Whether or not the buffer should be created if it doesnt exist
+     *  \param create    Whether or not the buffer should be created if it doesn't exist
      *  \return The BufferInfo corresponding to the given network and buffer name, or an invalid BufferInfo if not found
      */
     virtual BufferInfo bufferInfo(UserId user, const NetworkId& networkId, BufferInfo::Type type, const QString& buffer = "", bool create = true)
@@ -335,7 +340,7 @@ public slots:
      *  \param user  The user whose buffers we request
      *  \return A list of the BufferInfos for all buffers as requested
      */
-    virtual QList<BufferInfo> requestBuffers(UserId user) = 0;
+    virtual std::vector<BufferInfo> requestBuffers(UserId user) = 0;
 
     //! Request a list of BufferIds for a given NetworkId
     /** \note This method is threadsafe.
@@ -344,13 +349,13 @@ public slots:
      *  \param networkId  The NetworkId of the network in question
      *  \return List of BufferIds belonging to the Network
      */
-    virtual QList<BufferId> requestBufferIdsForNetwork(UserId user, NetworkId networkId) = 0;
+    virtual std::vector<BufferId> requestBufferIdsForNetwork(UserId user, NetworkId networkId) = 0;
 
     //! Remove permanently a buffer and it's content from the storage backend
     /** This call cannot be reverted!
      *  \param user      The user who is the owner of the buffer
      *  \param bufferId  The bufferId
-     *  \return true if successfull
+     *  \return true if successful
      */
     virtual bool removeBuffer(const UserId& user, const BufferId& bufferId) = 0;
 
@@ -359,7 +364,7 @@ public slots:
      *  \param user      The id of the buffer owner
      *  \param bufferId  The bufferId
      *  \param newName   The new name of the buffer
-     *  \return true if successfull
+     *  \return true if successful
      */
     virtual bool renameBuffer(const UserId& user, const BufferId& bufferId, const QString& newName) = 0;
 
@@ -368,7 +373,7 @@ public slots:
      *  \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 successfull
+     *  \return true if successful
      */
     virtual bool mergeBuffersPermanently(const UserId& user, const BufferId& bufferId1, const BufferId& bufferId2) = 0;
 
@@ -380,6 +385,12 @@ public slots:
      */
     virtual void setBufferLastSeenMsg(UserId user, const BufferId& bufferId, const MsgId& msgId) = 0;
 
+    //! Get a Hash of all last message ids
+    /** This Method is called when the Quassel Core is started to restore the lastMsgIds
+     * \param user      The Owner of the buffers
+     */
+    virtual QHash<BufferId, MsgId> bufferLastMsgIds(UserId user) = 0;
+
     //! Get a Hash of all last seen message ids
     /** This Method is called when the Quassel Core is started to restore the lastSeenMsgIds
      * \param user      The Owner of the buffers
@@ -498,7 +509,7 @@ public slots:
      *  \param limit    if != -1 limit the returned list to a max of \limit entries
      *  \return The requested list of messages
      */
-    virtual QList<Message> requestMsgs(UserId user, BufferId bufferId, MsgId first = -1, MsgId last = -1, int limit = -1) = 0;
+    virtual std::vector<Message> requestMsgs(UserId user, BufferId bufferId, MsgId first = -1, MsgId last = -1, int limit = -1) = 0;
 
     //! Request a certain number messages stored in a given buffer, matching certain filters
     /** \param buffer   The buffer we request messages from
@@ -508,14 +519,30 @@ public slots:
      *  \param type     The Message::Types that should be returned
      *  \return The requested list of messages
      */
-    virtual QList<Message> requestMsgsFiltered(UserId user,
-                                               BufferId bufferId,
-                                               MsgId first = -1,
-                                               MsgId last = -1,
-                                               int limit = -1,
-                                               Message::Types type = Message::Types{-1},
-                                               Message::Flags flags = Message::Flags{-1})
-        = 0;
+    virtual std::vector<Message> requestMsgsFiltered(UserId user,
+                                                     BufferId bufferId,
+                                                     MsgId first = -1,
+                                                     MsgId last = -1,
+                                                     int limit = -1,
+                                                     Message::Types type = Message::Types{-1},
+                                                     Message::Flags flags = Message::Flags{-1}) = 0;
+
+    //! Request a certain number messages stored in a given buffer, matching certain filters, ascending
+    /** \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
+     *  \param type     The Message::Types that should be returned
+     *  \param flags     The Message::Flags that should be returned
+     *  \return The requested list of messages
+     */
+    virtual std::vector<Message> requestMsgsForward(UserId user,
+                                                    BufferId bufferId,
+                                                    MsgId first = -1,
+                                                    MsgId last = -1,
+                                                    int limit = -1,
+                                                    Message::Types type = Message::Types{-1},
+                                                    Message::Flags flags = Message::Flags{-1}) = 0;
 
     //! Request a certain number of messages across all buffers
     /** \param first    if != -1 return only messages with a MsgId >= first
@@ -523,7 +550,7 @@ public slots:
      *  \param limit    Max amount of messages
      *  \return The requested list of messages
      */
-    virtual QList<Message> requestAllMsgs(UserId user, MsgId first = -1, MsgId last = -1, int limit = -1) = 0;
+    virtual std::vector<Message> requestAllMsgs(UserId user, MsgId first = -1, MsgId last = -1, int limit = -1) = 0;
 
     //! Request a certain number of messages across all buffers, matching certain filters
     /** \param first    if != -1 return only messages with a MsgId >= first
@@ -532,13 +559,12 @@ public slots:
      *  \param type     The Message::Types that should be returned
      *  \return The requested list of messages
      */
-    virtual 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})
-        = 0;
+    virtual std::vector<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}) = 0;
 
     //! Fetch all authusernames
     /** \return      Map of all current UserIds to permitted idents
@@ -572,5 +598,3 @@ private:
     bool checkHashedPasswordSha2_512(const QString& password, const QString& hashedPassword);
     QString sha2_512(const QString& input);
 };
-
-#endif