X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcorebacklogmanager.cpp;h=d9f3d9088c03d064a45f51db546f4d7d51dd1eb8;hp=bd1bc4f4a2e7c07541101d40f659ef95a56d85d6;hb=dc2aa39d20b60e7cd8e0ba66ca6c9ed729add008;hpb=de1619ce11bf386490cdb38bc1be134a391eeaae;ds=sidebyside diff --git a/src/core/corebacklogmanager.cpp b/src/core/corebacklogmanager.cpp index bd1bc4f4..d9f3d908 100644 --- a/src/core/corebacklogmanager.cpp +++ b/src/core/corebacklogmanager.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 * @@ -30,7 +30,7 @@ CoreBacklogManager::CoreBacklogManager(CoreSession *coreSession) { } -QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, MsgId last, int limit) { +QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional) { QVariantList backlog; QList msgList; msgList = Core::requestMsgs(coreSession()->user(), bufferId, first, last, limit); @@ -41,5 +41,64 @@ QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, backlog << qVariantFromValue(*msgIter); msgIter++; } + + if(additional) { + if(first != -1) { + last = first; + } else { + last = -1; + if(!msgList.isEmpty()) { + if(msgList.first().msgId() < msgList.last().msgId()) + last = msgList.first().msgId(); + else + last = msgList.last().msgId(); + } + } + msgList = Core::requestMsgs(coreSession()->user(), bufferId, -1, last, additional); + msgIter = msgList.constBegin(); + msgListEnd = msgList.constEnd(); + while(msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; + } + } + + return backlog; +} + +QVariantList CoreBacklogManager::requestBacklogAll(MsgId first, MsgId last, int limit, int additional) { + qDebug() << "CoreBacklogManager::requestBacklogAll" << first << last << limit << additional; + QVariantList backlog; + QList msgList; + msgList = Core::requestAllMsgs(coreSession()->user(), first, last, limit); + + QList::const_iterator msgIter = msgList.constBegin(); + QList::const_iterator msgListEnd = msgList.constEnd(); + while(msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; + } + + if(additional) { + if(first != -1) { + last = first; + } else { + last = -1; + if(!msgList.isEmpty()) { + if(msgList.first().msgId() < msgList.last().msgId()) + last = msgList.first().msgId(); + else + last = msgList.last().msgId(); + } + } + msgList = Core::requestAllMsgs(coreSession()->user(), -1, last, additional); + msgIter = msgList.constBegin(); + msgListEnd = msgList.constEnd(); + while(msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; + } + } + return backlog; }