1 /***************************************************************************
2 * Copyright (C) 2005-08 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 #include "backlogrequester.h"
25 #include "backlogsettings.h"
26 #include "clientbacklogmanager.h"
28 BacklogRequester::BacklogRequester(bool buffering, ClientBacklogManager *backlogManager)
29 : backlogManager(backlogManager),
30 _isBuffering(buffering)
32 Q_ASSERT(backlogManager);
35 bool BacklogRequester::buffer(BufferId bufferId, const MessageList &messages) {
36 _bufferedMessages << messages;
37 _buffersWaiting.remove(bufferId);
38 return !_buffersWaiting.isEmpty();
41 // ========================================
42 // FIXED BACKLOG REQUESTER
43 // ========================================
44 FixedBacklogRequester::FixedBacklogRequester(ClientBacklogManager *backlogManager)
45 : BacklogRequester(true, backlogManager)
47 BacklogSettings backlogSettings;
48 _backlogCount = backlogSettings.fixedBacklogAmount();
51 void FixedBacklogRequester::requestBacklog() {
52 QList<BufferId> allBuffers = allBufferIds();
53 setWaitingBuffers(allBuffers);
54 backlogManager->emitMessagesRequested(QObject::tr("Requesting a total of up to %1 backlog messages for %2 buffers").arg(_backlogCount * allBuffers.count()).arg(allBuffers.count()));
55 foreach(BufferId bufferId, allBuffers) {
56 backlogManager->requestBacklog(bufferId, _backlogCount, -1);