[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Re: [PATCH] increase moveMsg performance
From:       Carsten Burghardt <cb () magic-shop ! de>
Date:       2002-08-29 6:06:43
[Download RAW message or body]

On Wednesday 28 August 2002 22:24, Michael Häckel wrote:
> On Monday 26 August 2002 08:26, Carsten Burghardt wrote:
> > On Sunday 25 August 2002 19:58, Carsten Burghardt wrote:
> > > Hi,
> > >
> > > at the moment the destination folder of an imap moveMsg is downloaded
> > > (getFolder) after each operation. This is too time-consuming.
>
> I can't confirm this. Looks actually quite fast here. getFolder shouldn't
> be a very expensive operation if the folder has already been seen in the
> current KMail session otherwise there is something strange.
>
> Maybe with really huge folders it can take the server some time to respond.
> Is that the case for you?

My trashfolder has 1600 messages, so no big deal. You simply notice the 
difference if you're working with imap.

> > > The attached patch does 2 things:
> > > - just increment the cached total-count for the total-column
>
> You forgot to update the number of unread messages, when unread messages
> are moved. This number is probably the reason why I added that getFolder
> call.

See my last mail. Attached is the corrected version.

-- 
Regards,

Carsten Burghardt
["movemsg.diff" (text/x-diff)]

Index: kmfolder.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolder.cpp,v
retrieving revision 1.226
diff -u -3 -p -r1.226 kmfolder.cpp
--- kmfolder.cpp	2002/07/29 09:21:01	1.226
+++ kmfolder.cpp	2002/08/29 06:01:44
@@ -956,15 +956,19 @@ int KMFolder::moveMsg(KMMessage* aMsg, i
   assert(aMsg != NULL);
   msgParent = aMsg->parent();
 
-  if (msgParent)
-    msgParent->open();
+  if (protocol() != "imap") {
+    if (msgParent)
+      msgParent->open();
 
-  open();
+    open();
+  }
   rc = addMsg(aMsg, aIndex_ret);
-  close();
+  if (protocol() != "imap") {
+    close();
 
-  if (msgParent)
-    msgParent->close();
+    if (msgParent)
+      msgParent->close();
+  }
 
   return rc;
 }
@@ -979,15 +983,19 @@ int KMFolder::moveMsg(QPtrList<KMMessage
   assert(aMsg != NULL);
   msgParent = aMsg->parent();
 
-  if (msgParent)
-    msgParent->open();
+  if (protocol() != "imap") {
+    if (msgParent)
+      msgParent->open();
 
-  open();
+    open();
+  }
   rc = static_cast<KMFolderImap*>(this)->addMsg(msglist, aIndex_ret);
-  close();
+  if (protocol() != "imap") {
+    close();
 
-  if (msgParent)
-    msgParent->close();
+    if (msgParent)
+      msgParent->close();
+  }
 
   return rc;
 }
Index: kmfolderimap.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolderimap.cpp,v
retrieving revision 1.67
diff -u -3 -p -r1.67 kmfolderimap.cpp
--- kmfolderimap.cpp	2002/08/25 18:08:03	1.67
+++ kmfolderimap.cpp	2002/08/29 06:01:45
@@ -166,23 +166,56 @@ void KMFolderImap::addMsgQuiet(KMMessage
 {
   KMFolder *folder = aMsg->parent();
   if (folder) kernel->undoStack()->pushAction( aMsg->getMsgSerNum(), folder, this );
+  // correct the unread-count if the folder won't be get'ted
+  if (!mIsSelected && 
+      aMsg->status()==KMMsgStatusUnread ||
+      aMsg->status()==KMMsgStatusNew ||
+      (this == kernel->outboxFolder())) {
+    if (mUnreadMsgs == -1) mUnreadMsgs = 1;
+    else ++mUnreadMsgs;
+  }
   if (folder) folder->take(folder->find(aMsg));
   delete aMsg;
-  getFolder();
+  if (mIsSelected) {
+    // folder is selected, so we can fetch the (new) content
+    getFolder();
+  } else {
+    // increase the cached total count
+    ++mTotalMsgs;
+    emit msgAdded(static_cast<KMFolder*>(this));
+    emit numUnreadMsgsChanged( this );
+  }
 }
 
 //-----------------------------------------------------------------------------
 void KMFolderImap::addMsgQuiet(QPtrList<KMMessage> msgList)
 {
+  int count = msgList.count();
   KMFolder *folder = msgList.first()->parent();
   for ( KMMessage* msg = msgList.first(); msg; msg = msgList.next() )
   {
     kernel->undoStack()->pushAction( msg->getMsgSerNum(), folder, this );
+    // correct the unread-count if the folder won't be get'ted
+    if (!mIsSelected && 
+        msg->status()==KMMsgStatusUnread ||
+        msg->status()==KMMsgStatusNew ||
+        (this == kernel->outboxFolder())) {
+      if (mUnreadMsgs == -1) mUnreadMsgs = 1;
+      else ++mUnreadMsgs;
+    }
   }
   if (folder) folder->take(msgList);
   msgList.setAutoDelete(true);
   msgList.clear();
-  getFolder();
+  if (mIsSelected) {
+    // folder is selected, so we can fetch the (new) content
+    getFolder();
+  } else {
+    // increase the cached total count
+    mTotalMsgs += count;
+    emit msgAdded(static_cast<KMFolder*>(this));
+    emit numUnreadMsgsChanged( this );
+  }
 }
 
 //-----------------------------------------------------------------------------
Index: kmfoldertree.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfoldertree.cpp,v
retrieving revision 1.193
diff -u -3 -p -r1.193 kmfoldertree.cpp
--- kmfoldertree.cpp	2002/08/23 05:37:19	1.193
+++ kmfoldertree.cpp	2002/08/29 06:01:45
@@ -450,13 +450,14 @@ void KMFolderTree::reload(bool openFolde
               this,SLOT(slotUpdateCounts(KMFolderImap*, bool)));
           connect(fti->folder(), SIGNAL(folderComplete(KMFolderImap*, bool)),
               this,SLOT(slotUpdateCounts(KMFolderImap*, bool)));
-        } else {
-          // others-only, imap doesn't need this because of the folderComplete-signal
-          disconnect(fti->folder(), SIGNAL(msgAdded(KMFolder*)),
-              this,SLOT(slotUpdateCounts(KMFolder*)));
-          connect(fti->folder(), SIGNAL(msgAdded(KMFolder*)),
-              this,SLOT(slotUpdateCounts(KMFolder*)));
         }
+        // msgAdded
+        disconnect(fti->folder(), SIGNAL(msgAdded(KMFolder*)),
+            this,SLOT(slotUpdateCounts(KMFolder*)));
+        connect(fti->folder(), SIGNAL(msgAdded(KMFolder*)),
+            this,SLOT(slotUpdateCounts(KMFolder*)));
+
+        // msgRemoved
         disconnect(fti->folder(), SIGNAL(msgRemoved(KMFolder*)),
             this,SLOT(slotUpdateCounts(KMFolder*)));
         connect(fti->folder(), SIGNAL(msgRemoved(KMFolder*)),
Index: kmheaders.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmheaders.cpp,v
retrieving revision 1.436
diff -u -3 -p -r1.436 kmheaders.cpp
--- kmheaders.cpp	2002/08/25 13:22:14	1.436
+++ kmheaders.cpp	2002/08/29 06:01:47
@@ -1742,10 +1742,13 @@ void KMHeaders::moveMsgToFolder (KMFolde
 	     this,SLOT(highlightMessage(QListViewItem*)));
   kernel->kbp()->busy();
 
-  if (destFolder && destFolder->open() != 0)
+  if (destFolder && destFolder->protocol() != "imap")
   {
-      kernel->kbp()->idle();
-      return;
+      // no need to open with imap
+      if (destFolder->open() != 0) {
+        kernel->kbp()->idle();
+        return;
+      }
   }
 
   int contentX, contentY;
@@ -1832,7 +1835,9 @@ void KMHeaders::moveMsgToFolder (KMFolde
   connect(this,SIGNAL(currentChanged(QListViewItem*)),
 	     this,SLOT(highlightMessage(QListViewItem*)));
 
-  if (destFolder) {
+  if (destFolder && destFolder->protocol() != "imap") 
+  {
+      // no need for imap
       destFolder->sync();
       destFolder->close();
   }

_______________________________________________
KMail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic