adapting the backlogmanagers to the new storage api
[quassel.git] / src / client / clientbacklogmanager.h
index 2f0fcf3..a3f19ae 100644 (file)
 #include "backlogmanager.h"
 #include "message.h"
 
+class BacklogRequester;
+
 class ClientBacklogManager : public BacklogManager {
   Q_OBJECT
 
 public:
   ClientBacklogManager(QObject *parent = 0);
 
-  virtual const QMetaObject *syncMetaObject() const { return &BacklogManager::staticMetaObject; }
+  // helper for the backlogRequester, as it isn't a QObject and can't emit itself
+  inline void emitMessagesRequested(const QString &msg) const { emit messagesRequested(msg); }
+
+  void reset();
 
 public slots:
-  virtual void receiveBacklog(BufferId bufferId, int lastMsgs, int offset, QVariantList msgs);
-  virtual QVariantList requestBacklog(BufferId bufferId, int lastMsgs = -1, int offset = -1);
+  virtual void receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, QVariantList msgs);
   void requestInitialBacklog();
 
+signals:
+  void messagesReceived(BufferId bufferId, int count) const;
+  void messagesRequested(const QString &) const;
+  void messagesProcessed(const QString &) const;
+
 private:
-  bool _buffer;
-  QList<Message> _messageBuffer;
-  QSet<BufferId> _buffersWaiting;
+  bool isBuffering();
+  void stopBuffering();
+
+  void dispatchMessages(const MessageList &messages, bool sort = false);
+
+  BacklogRequester *_requester;
 };
 
 #endif // CLIENTBACKLOGMANAGER_H