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; }
51 //! returns false if it was the last missing backlogpart
52 bool buffer(BufferId bufferId, const MessageList &messages);
54 virtual inline void requestBacklog() { requestBacklog(allBufferIds()); }
55 virtual void requestBacklog(const QList<BufferId> &bufferIds) = 0;
58 QList<BufferId> allBufferIds() const;
59 inline void setWaitingBuffers(const QList<BufferId> &buffers) { setWaitingBuffers(buffers.toSet()); }
60 void setWaitingBuffers(const QSet<BufferId> &buffers);
61 void addWaitingBuffer(BufferId buffer);
63 ClientBacklogManager *backlogManager;
67 RequesterType _requesterType;
68 MessageList _bufferedMessages;
70 QSet<BufferId> _buffersWaiting;
73 // ========================================
74 // FIXED BACKLOG REQUESTER
75 // ========================================
76 class FixedBacklogRequester : public BacklogRequester {
78 FixedBacklogRequester(ClientBacklogManager *backlogManager);
79 virtual void requestBacklog(const QList<BufferId> &bufferIds);
85 // ========================================
86 // GLOBAL UNREAD BACKLOG REQUESTER
87 // ========================================
88 class GlobalUnreadBacklogRequester : public BacklogRequester {
90 GlobalUnreadBacklogRequester(ClientBacklogManager *backlogManager);
91 virtual void requestBacklog();
92 virtual void requestBacklog(const QList<BufferId> &) {}
99 // ========================================
100 // PER BUFFER UNREAD BACKLOG REQUESTER
101 // ========================================
102 class PerBufferUnreadBacklogRequester : public BacklogRequester {
104 PerBufferUnreadBacklogRequester(ClientBacklogManager *backlogManager);
105 virtual void requestBacklog(const QList<BufferId> &bufferIds);
112 #endif //BACKLOGREQUESTER_H