1 /***************************************************************************
2 * Copyright (C) 2005-09 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef BACKLOGREQUESTER_H
22 #define BACKLOGREQUESTER_H
28 #include "networkmodel.h"
31 class ClientBacklogManager;
33 class BacklogRequester {
42 BacklogRequester(bool buffering, RequesterType requesterType, ClientBacklogManager *backlogManger);
43 virtual inline ~BacklogRequester() {}
45 inline bool isBuffering() { return _isBuffering; }
46 inline RequesterType type() { return _requesterType; }
47 inline const QList<Message> &bufferedMessages() { return _bufferedMessages; }
49 inline int buffersWaiting() const { return _buffersWaiting.count(); }
50 inline int totalBuffers() const { return _totalBuffers; }
52 bool buffer(BufferId bufferId, const MessageList &messages); //! returns false if it was the last missing backlogpart
54 virtual void requestBacklog(const BufferIdList &bufferIds) = 0;
55 virtual inline void requestInitialBacklog() { requestBacklog(allBufferIds()); }
57 virtual void flushBuffer();
60 BufferIdList allBufferIds() const;
61 inline void setWaitingBuffers(const QList<BufferId> &buffers) { setWaitingBuffers(buffers.toSet()); }
62 void setWaitingBuffers(const QSet<BufferId> &buffers);
63 void addWaitingBuffer(BufferId buffer);
65 ClientBacklogManager *backlogManager;
69 RequesterType _requesterType;
70 MessageList _bufferedMessages;
72 QSet<BufferId> _buffersWaiting;
75 // ========================================
76 // FIXED BACKLOG REQUESTER
77 // ========================================
78 class FixedBacklogRequester : public BacklogRequester {
80 FixedBacklogRequester(ClientBacklogManager *backlogManager);
81 virtual void requestBacklog(const BufferIdList &bufferIds);
87 // ========================================
88 // GLOBAL UNREAD BACKLOG REQUESTER
89 // ========================================
90 class GlobalUnreadBacklogRequester : public BacklogRequester {
92 GlobalUnreadBacklogRequester(ClientBacklogManager *backlogManager);
93 virtual void requestInitialBacklog();
94 virtual void requestBacklog(const BufferIdList &) {}
101 // ========================================
102 // PER BUFFER UNREAD BACKLOG REQUESTER
103 // ========================================
104 class PerBufferUnreadBacklogRequester : public BacklogRequester {
106 PerBufferUnreadBacklogRequester(ClientBacklogManager *backlogManager);
107 virtual void requestBacklog(const BufferIdList &bufferIds);
114 #endif //BACKLOGREQUESTER_H