Set working directory for scripts to their scriptdir
[quassel.git] / src / client / clientbacklogmanager.cpp
index 742d305..6f45da3 100644 (file)
@@ -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  *
@@ -48,8 +48,9 @@ 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();
     }
@@ -92,6 +93,9 @@ void ClientBacklogManager::requestInitialBacklog() {
   };
 
   _requester->requestBacklog();
+  if(_requester->isBuffering()) {
+    updateProgress(0, _requester->totalBuffers());
+  }
 }
 
 void ClientBacklogManager::stopBuffering() {
@@ -105,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();
@@ -113,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() {