X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclientbacklogmanager.cpp;h=6f45da35027e4f21cb3f56268df711577b3dac36;hp=8cf2af4e2306633a60b8cfeed6cdb2b76d58766d;hb=46d75f41de7c1aaee605c096da28d4b0d8abf138;hpb=de1619ce11bf386490cdb38bc1be134a391eeaae diff --git a/src/client/clientbacklogmanager.cpp b/src/client/clientbacklogmanager.cpp index 8cf2af4e..6f45da35 100644 --- a/src/client/clientbacklogmanager.cpp +++ b/src/client/clientbacklogmanager.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -35,13 +35,8 @@ ClientBacklogManager::ClientBacklogManager(QObject *parent) { } -void ClientBacklogManager::receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, QVariantList msgs) { - Q_UNUSED(first) - Q_UNUSED(last) - Q_UNUSED(limit) - - if(msgs.isEmpty()) - return; +void ClientBacklogManager::receiveBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional, QVariantList msgs) { + Q_UNUSED(first) Q_UNUSED(last) Q_UNUSED(limit) Q_UNUSED(additional) emit messagesReceived(bufferId, msgs.count()); @@ -53,15 +48,31 @@ void ClientBacklogManager::receiveBacklog(BufferId bufferId, MsgId first, MsgId } if(isBuffering()) { - if(!_requester->buffer(bufferId, msglist)) { - // this was the last part to buffer + bool lastPart = !_requester->buffer(bufferId, msglist); + updateProgress(_requester->totalBuffers() - _requester->buffersWaiting(), _requester->totalBuffers()); + if(lastPart) { stopBuffering(); + reset(); } } else { dispatchMessages(msglist); } } +void ClientBacklogManager::receiveBacklogAll(MsgId first, MsgId last, int limit, int additional, QVariantList msgs) { + Q_UNUSED(first) Q_UNUSED(last) Q_UNUSED(limit) Q_UNUSED(additional) + + MessageList msglist; + foreach(QVariant v, msgs) { + Message msg = v.value(); + msg.setFlags(msg.flags() | Message::Backlog); + msglist << msg; + } + + dispatchMessages(msglist); + reset(); +} + void ClientBacklogManager::requestInitialBacklog() { if(_requester) { qWarning() << "ClientBacklogManager::requestInitialBacklog() called twice in the same session! (Backlog has already been requested)"; @@ -71,20 +82,26 @@ void ClientBacklogManager::requestInitialBacklog() { 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->requestBacklog(); + if(_requester->isBuffering()) { + updateProgress(0, _requester->totalBuffers()); + } } void ClientBacklogManager::stopBuffering() { Q_ASSERT(_requester); dispatchMessages(_requester->bufferedMessages(), true); - reset(); } bool ClientBacklogManager::isBuffering() { @@ -92,6 +109,9 @@ bool ClientBacklogManager::isBuffering() { } void ClientBacklogManager::dispatchMessages(const MessageList &messages, bool sort) { + if(messages.isEmpty()) + return; + MessageList msgs = messages; clock_t start_t = clock(); @@ -100,7 +120,7 @@ void ClientBacklogManager::dispatchMessages(const MessageList &messages, bool so Client::messageProcessor()->process(msgs); clock_t end_t = clock(); - emit messagesProcessed(tr("Processed %1 messages in %2 seconds.").arg(msgs.count()).arg((float)(end_t - start_t) / CLOCKS_PER_SEC)); + emit messagesProcessed(tr("Processed %1 messages in %2 seconds.").arg(messages.count()).arg((float)(end_t - start_t) / CLOCKS_PER_SEC)); } void ClientBacklogManager::reset() {