-void ClientBacklogManager::requestInitialBacklog() {
- if(_requester) {
- qWarning() << "ClientBacklogManager::requestInitialBacklog() called twice in the same session! (Backlog has already been requested)";
- return;
- }
-
- BacklogSettings settings;
- switch(settings.requesterType()) {
- case BacklogRequester::GlobalUnread:
- case BacklogRequester::PerBufferUnread:
- case BacklogRequester::PerBufferFixed:
- default:
- _requester = new FixedBacklogRequester(this);
- };
-
- _requester->requestBacklog();
+
+void ClientBacklogManager::requestInitialBacklog()
+{
+ if (_initBacklogRequested) {
+ Q_ASSERT(_requester);
+ qWarning() << "ClientBacklogManager::requestInitialBacklog() called twice in the same session! (Backlog has already been requested)";
+ return;
+ }
+
+ BacklogSettings settings;
+ switch (settings.requesterType()) {
+ case BacklogRequester::GlobalUnread:
+ _requester = new GlobalUnreadBacklogRequester(this);
+ break;
+ case BacklogRequester::PerBufferUnread:
+ _requester = new PerBufferUnreadBacklogRequester(this);
+ break;
+ case BacklogRequester::PerBufferFixed:
+ default:
+ _requester = new FixedBacklogRequester(this);
+ };
+
+ _requester->requestInitialBacklog();
+ _initBacklogRequested = true;
+ if (_requester->isBuffering()) {
+ updateProgress(0, _requester->totalBuffers());
+ }
+}
+
+
+BufferIdList ClientBacklogManager::filterNewBufferIds(const BufferIdList &bufferIds)
+{
+ BufferIdList newBuffers;
+ QSet<BufferId> availableBuffers = Client::networkModel()->allBufferIds().toSet();
+ foreach(BufferId bufferId, bufferIds) {
+ if (_buffersRequested.contains(bufferId) || !availableBuffers.contains(bufferId))
+ continue;
+ newBuffers << bufferId;
+ }
+ return newBuffers;