1 /***************************************************************************
2 * Copyright (C) 2005-2020 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
29 #include "networkmodel.h"
32 class ClientBacklogManager;
34 class BacklogRequester
45 BacklogRequester(bool buffering, RequesterType requesterType, ClientBacklogManager* backlogManger);
46 virtual ~BacklogRequester() = default;
48 inline bool isBuffering() { return _isBuffering; }
49 inline RequesterType type() { return _requesterType; }
50 inline const QList<Message>& bufferedMessages() { return _bufferedMessages; }
52 inline int buffersWaiting() const { return int(_buffersWaiting.size()); }
53 inline int totalBuffers() const { return _totalBuffers; }
55 bool buffer(BufferId bufferId, const MessageList& messages); //! returns false if it was the last missing backlogpart
57 virtual void requestBacklog(const BufferIdList& bufferIds) = 0;
58 virtual inline void requestInitialBacklog() { requestBacklog(allBufferIds()); }
60 virtual void flushBuffer();
63 BufferIdList allBufferIds() const;
64 void setWaitingBuffers(const BufferIdList& buffers);
66 ClientBacklogManager* backlogManager;
70 RequesterType _requesterType;
71 MessageList _bufferedMessages;
73 std::set<BufferId> _buffersWaiting;
76 // ========================================
77 // FIXED BACKLOG REQUESTER
78 // ========================================
79 class FixedBacklogRequester : public BacklogRequester
82 FixedBacklogRequester(ClientBacklogManager* backlogManager);
83 void requestBacklog(const BufferIdList& bufferIds) override;
89 // ========================================
90 // GLOBAL UNREAD BACKLOG REQUESTER
91 // ========================================
92 class GlobalUnreadBacklogRequester : public BacklogRequester
95 GlobalUnreadBacklogRequester(ClientBacklogManager* backlogManager);
96 void requestInitialBacklog() override;
97 void requestBacklog(const BufferIdList&) override {}
104 // ========================================
105 // PER BUFFER UNREAD BACKLOG REQUESTER
106 // ========================================
107 class PerBufferUnreadBacklogRequester : public BacklogRequester
110 PerBufferUnreadBacklogRequester(ClientBacklogManager* backlogManager);
111 void requestBacklog(const BufferIdList& bufferIds) override;