X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientbacklogmanager.h;h=c1ecccf50ced493c47f4ea3ff3282562be9feea0;hp=ae6b14754ad032ff74cdb15b0fcca30459bafdc4;hb=52209badc8e769e50aa3019b63689dda0e79e9d0;hpb=97513984bfb9f50354942390803d4c75fededc53 diff --git a/src/client/clientbacklogmanager.h b/src/client/clientbacklogmanager.h index ae6b1475..c1ecccf5 100644 --- a/src/client/clientbacklogmanager.h +++ b/src/client/clientbacklogmanager.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,34 +15,60 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef CLIENTBACKLOGMANAGER_H -#define CLIENTBACKLOGMANAGER_H +#pragma once + +#include "client-export.h" #include "backlogmanager.h" #include "message.h" -class ClientBacklogManager : public BacklogManager { - Q_OBJECT +class BacklogRequester; + +class CLIENT_EXPORT ClientBacklogManager : public BacklogManager +{ + Q_OBJECT public: - ClientBacklogManager(QObject *parent = 0); + ClientBacklogManager(QObject* parent = nullptr); - 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); - void requestInitialBacklog(); + QVariantList requestBacklog(BufferId bufferId, MsgId first = -1, MsgId last = -1, int limit = -1, int additional = 0) override; + void receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional, QVariantList msgs) override; + void receiveBacklogAll(MsgId first, MsgId last, int limit, int additional, QVariantList msgs) override; + + void requestInitialBacklog(); - void reset(); + void checkForBacklog(BufferId bufferId); + void checkForBacklog(const BufferIdList& bufferIds); + +signals: + void messagesReceived(BufferId bufferId, int count) const; + void messagesRequested(const QString&) const; + void messagesProcessed(const QString&) const; + + void updateProgress(int, int); private: - bool _buffer; - QList _messageBuffer; - QSet _buffersWaiting; + bool isBuffering(); + BufferIdList filterNewBufferIds(const BufferIdList& bufferIds); + + void dispatchMessages(const MessageList& messages, bool sort = false); + + BacklogRequester* _requester{nullptr}; + bool _initBacklogRequested{false}; + QSet _buffersRequested; }; -#endif // CLIENTBACKLOGMANAGER_H +// inlines +inline void ClientBacklogManager::checkForBacklog(BufferId bufferId) +{ + checkForBacklog(BufferIdList() << bufferId); +}