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

List:       kde-pim
Subject:    Re: [Kde-pim] [PATCH] fix IMAP filtering (Bug 95064)
From:       Thomas McGuire <mcguire () kde ! org>
Date:       2008-10-30 19:39:52
Message-ID: 200810302039.58695.mcguire () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

here is another approach: Don't filter the message if it is in one of the 
maps, since that means we've already seen the mail before.

It fixes the part of the bug that I could reproduce, namely filters being 
applied to messages more than once. Not sure if that also fixes the duplicate 
problem.

Please try the patch and let me now if it works for me.

I'm not sure if the patch is safe, it might also prevent filtering of messages 
that we want filtered, so please test and review if you can.

Regards,
Thomas

["fix-filtering.diff" (text/x-patch)]

Index: kmfolderimap.cpp
===================================================================
--- kmfolderimap.cpp	(revision 877935)
+++ kmfolderimap.cpp	(working copy)
@@ -1611,8 +1611,10 @@
         md =  mUidMetaDataMap[uid];
       }
       ulong serNum = 0;
+      bool serialNumberInCache = false;
       if ( md ) {
         serNum = md->serNum();
+        serialNumberInCache = true;
       }
       bool ok = true;
       if ( uid <= lastUid() && serNum > 0 ) {
@@ -1642,6 +1644,7 @@
             msg->setStatus( md->messageStatus() );
             if ( md->serNum() != 0 && serNum == 0 ) {
               msg->setMsgSerNum( md->serNum() );
+              serialNumberInCache = true;
             }
             mMetaDataMap.remove( id );
             delete md;
@@ -1658,8 +1661,20 @@
         }
         // Filter messages that have arrived in the inbox folder
         if ( folder()->isSystemFolder() && imapPath() == "/INBOX/"
-            && kmkernel->filterMgr()->atLeastOneIncomingFilterAppliesTo( account()->id() ) )
+            && kmkernel->filterMgr()->atLeastOneIncomingFilterAppliesTo( account()->id() ) ) {
+
+          // If the message was already in one of the maps (mMetaDataMap or
+          // mUidMetaDataMap, depending on whether UIDPLUS is supported by the
+          // server), don't filter this message, since it means that the message
+          // was likely uploaded by ourselves.
+          //
+          // This fixes a bug when an already filtered message was filtered again,
+          // because after uploading the filtered message, KMail thought that message
+          // was new and filtered it again.
+          if ( !serialNumberInCache ) {
             account()->execFilters( msg->getMsgSerNum() );
+          }
+        }
 
         if ( count() > 1 ) {
           unGetMsg(count() - 1);

["signature.asc" (application/pgp-signature)]

_______________________________________________
KDE PIM mailing list kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/

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

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