From 07857325b27b8602f100732c724a50263fec7ebc Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Mon, 11 Jul 2005 18:31:28 +0000 Subject: [PATCH] don't count junk mail as new mail, sr=mscott, a=asa 282477, sr=mscott, a=asa git-svn-id: svn://10.0.0.236/trunk@175922 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/imap/src/nsImapMailFolder.cpp | 6 ++++++ mozilla/mailnews/local/src/nsParseMailbox.cpp | 18 +++++++++++------- mozilla/mailnews/local/src/nsPop3Sink.cpp | 9 +++++++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp index 083dfa7b3ba..fcd93d2a70e 100644 --- a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp @@ -3376,6 +3376,8 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindo NS_ASSERTION(keysToClassify, "error getting key bucket"); if (keysToClassify) keysToClassify->Add(msgKey); + if (junkScore == 100) + msgIsNew = PR_FALSE; } } break; @@ -4331,7 +4333,11 @@ nsresult nsImapMailFolder::HandleCustomFlags(nsMsgKey uidOfMessage, nsIMsgDBHdr mDatabase->SetStringProperty(uidOfMessage, "junkscore", "0"); // ### TODO: we really should parse the keywords into space delimited keywords before checking else if (FindInReadable(NS_LITERAL_CSTRING("Junk"), keywords.BeginReading(b), keywords.EndReading(e))) + { + PRUint32 newFlags; + dbHdr->AndFlags(~MSG_FLAG_NEW, &newFlags); mDatabase->SetStringProperty(uidOfMessage, "junkscore", "100"); + } else messageClassified = PR_FALSE; if (messageClassified) diff --git a/mozilla/mailnews/local/src/nsParseMailbox.cpp b/mozilla/mailnews/local/src/nsParseMailbox.cpp index 8559ab04ca7..fa93cbbc3a1 100644 --- a/mozilla/mailnews/local/src/nsParseMailbox.cpp +++ b/mozilla/mailnews/local/src/nsParseMailbox.cpp @@ -1802,6 +1802,8 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWi PRInt32 junkScore; filterAction->GetJunkScore(&junkScore); junkScoreStr.AppendInt(junkScore); + if (junkScore > 50) + msgIsNew = PR_FALSE; nsMsgKey msgKey; msgHdr->GetMessageKey(&msgKey); m_mailDB->SetStringProperty(msgKey, "junkscore", junkScoreStr.get()); @@ -2093,7 +2095,7 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr, return NS_MSG_ERROR_WRITING_MAIL_FOLDER; } - PRBool movedMsgIsNew = PR_TRUE; + PRBool movedMsgIsNew = PR_FALSE; // if we have made it this far then the message has successfully been written to the new folder // now add the header to the destMailDB. if (NS_SUCCEEDED(rv) && destMailDB) @@ -2109,12 +2111,14 @@ nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr, newHdr->GetFlags(&newFlags); if (! (newFlags & MSG_FLAG_READ)) { - newHdr->OrFlags(MSG_FLAG_NEW, &newFlags); - destMailDB->AddToNewList(newMsgPos); - } - else - { - movedMsgIsNew = PR_FALSE; + nsXPIDLCString junkScoreStr; + (void) newHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr)); + if (atoi(junkScoreStr.get()) < 50) + { + newHdr->OrFlags(MSG_FLAG_NEW, &newFlags); + destMailDB->AddToNewList(newMsgPos); + movedMsgIsNew = PR_TRUE; + } } destMailDB->AddNewHdrToDB(newHdr, PR_TRUE); } diff --git a/mozilla/mailnews/local/src/nsPop3Sink.cpp b/mozilla/mailnews/local/src/nsPop3Sink.cpp index 9e5e4a67139..6b6150a4ad8 100644 --- a/mozilla/mailnews/local/src/nsPop3Sink.cpp +++ b/mozilla/mailnews/local/src/nsPop3Sink.cpp @@ -839,8 +839,13 @@ nsPop3Sink::IncorporateComplete(nsIMsgWindow *aMsgWindow, PRInt32 aSize) hdr->GetFlags(&newFlags); if (! (newFlags & MSG_FLAG_READ)) { - hdr->OrFlags(MSG_FLAG_NEW, &newFlags); - m_newMailParser->m_mailDB->AddToNewList(newMsgPos); + nsXPIDLCString junkScoreStr; + (void) hdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr)); + if (atoi(junkScoreStr.get()) < 50) + { + hdr->OrFlags(MSG_FLAG_NEW, &newFlags); + m_newMailParser->m_mailDB->AddToNewList(newMsgPos); + } } m_newMailParser->m_mailDB->AddNewHdrToDB(hdr, PR_TRUE); }