Bug 656014 - Add a way to prevent DisplayMessage (imap) from marking a message as read automatically
authorJonathan Protzenko <jonathan.protzenko@gmail.com>
Tue, 10 May 2011 22:08:26 +0200
changeset 7755 7d96a5ff480941db91ad13e6156c5f8d29533fc1
parent 7754 151e79cb54bc0bdba6a1c4227ae44ef8650416d5
child 7756 22fe617c4cbd2a7ba084dc0de59e6d64f7534128
push idunknown
push userunknown
push dateunknown
bugs656014
Bug 656014 - Add a way to prevent DisplayMessage (imap) from marking a message as read automatically This is for Thunderbird conversations. When appending messages to a conversation, the imap code marks them read, even though we don't intend them to be. This should fix the random issue I've been seing for quite some time now.
mailnews/imap/src/nsImapService.cpp
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -562,21 +562,22 @@ NS_IMETHODIMP nsImapService::DisplayMess
       nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
       // Should the message fetch force a peek or a traditional fetch?
       // Force peek if there is a delay in marking read (or no auto-marking at all).
       // This is because a FETCH (BODY[]) will implicitly set tha \Seen flag on the msg,
       // but a FETCH (BODY.PEEK[]) won't.
       PRBool forcePeek = PR_FALSE;
       if (NS_SUCCEEDED(rv) && prefBranch)
       {
+        PRInt32 dontMarkAsReadPos = uriStr.Find("&markRead=false");
         PRBool markReadAuto = PR_TRUE;
         prefBranch->GetBoolPref("mailnews.mark_message_read.auto", &markReadAuto);
         PRBool markReadDelay = PR_FALSE;
         prefBranch->GetBoolPref("mailnews.mark_message_read.delay", &markReadDelay);
-        forcePeek = (!markReadAuto || markReadDelay);
+        forcePeek = (!markReadAuto || markReadDelay || (dontMarkAsReadPos != kNotFound));
       }
 
       rv = FetchMessage(imapUrl, forcePeek ? nsIImapUrl::nsImapMsgFetchPeek : nsIImapUrl::nsImapMsgFetch, 
                         folder, imapMessageSink, aMsgWindow, aDisplayConsumer, msgKey, PR_FALSE, 
                         (mPrintingOperation) ? NS_LITERAL_CSTRING("print") : NS_LITERAL_CSTRING(""), aURL);
     }
   }
   return rv;