/***************************************************************************
- * 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 *
{
}
-void ClientBacklogManager::receiveBacklog(BufferId bufferId, int limit, int offset, QVariantList msgs) {
- Q_UNUSED(limit)
- Q_UNUSED(offset)
-
- 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());
}
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<Message>();
+ 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)";
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() {
}
void ClientBacklogManager::dispatchMessages(const MessageList &messages, bool sort) {
+ if(messages.isEmpty())
+ return;
+
MessageList msgs = messages;
clock_t start_t = clock();
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() {