fix for #178934. junk classification of local mail (and incoming pop mail)

was getting marked as read.  r=dmose, sr=bienvenu.  thanks to granrose for finding the bug.
This commit is contained in:
sspitzer%netscape.com 2002-11-07 21:26:38 +00:00
Родитель d026a4cb8e
Коммит 2029990b82
1 изменённых файлов: 69 добавлений и 57 удалений

Просмотреть файл

@ -381,75 +381,87 @@ NS_IMETHODIMP nsMailboxProtocol::OnStopRequest(nsIRequest *request, nsISupports
PRInt32 nsMailboxProtocol::DoneReadingMessage()
{
nsresult rv = NS_OK;
// and close the article file if it was open....
nsresult rv = NS_OK;
// and close the article file if it was open....
if (m_mailboxAction == nsIMailboxUrl::ActionSaveMessageToDisk && m_tempMessageFile)
rv = m_tempMessageFile->CloseStream();
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(m_runningUrl, &rv);
NS_ENSURE_SUCCESS(rv,rv);
if (m_mailboxAction == nsIMailboxUrl::ActionSaveMessageToDisk && m_tempMessageFile)
rv = m_tempMessageFile->CloseStream();
nsCAutoString queryStr;
rv = msgUrl->GetQuery(queryStr);
NS_ENSURE_SUCCESS(rv,rv);
if (m_mailboxAction == nsIMailboxUrl::ActionFetchMessage)
{
// now mark the message as read
nsCOMPtr<nsIMsgDBHdr> msgHdr;
nsMsgKey msgKey;
// check if this is a filter plugin requesting the message.
// in that case, don't mark it as read,
// since the user didn't actually read it.
// the spec for msgUrl is of the form:
// mailbox:///<path to mbox file on disk>/Inbox?number=3287862&header=filter"
if ((queryStr.Find("header=filter") == kNotFound) && m_mailboxAction == nsIMailboxUrl::ActionFetchMessage)
{
// now mark the message as read
nsCOMPtr<nsIMsgDBHdr> msgHdr;
nsMsgKey msgKey;
if (m_runningUrl)
rv = m_runningUrl->GetMessageHeader(getter_AddRefs(msgHdr));
rv = m_runningUrl->GetMessageHeader(getter_AddRefs(msgHdr));
NS_ASSERTION(msgHdr, "no msg hdr!");
if (!msgHdr) return NS_ERROR_UNEXPECTED;
PRBool isRead;
msgHdr->GetIsRead(&isRead);
if (NS_SUCCEEDED(rv) && !isRead)
{
PRUint32 msgFlags, newFlags;
msgHdr->GetFlags(&msgFlags);
if (msgFlags & MSG_FLAG_MDN_REPORT_NEEDED)
{
nsCOMPtr<nsIMsgMdnGenerator> mdnGenerator;
nsCOMPtr<nsIMimeHeaders> mimeHeaders;
mdnGenerator =
do_CreateInstance(NS_MSGMDNGENERATOR_CONTRACTID, &rv);
// To ensure code works w/o MDN enabled
if (NS_SUCCEEDED(rv) && mdnGenerator)
{
PRUint32 msgFlags, newFlags;
msgHdr->GetFlags(&msgFlags);
if (msgFlags & MSG_FLAG_MDN_REPORT_NEEDED)
mimeHeaders =
do_CreateInstance(NS_IMIMEHEADERS_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && mimeHeaders)
{
nsCOMPtr<nsIMsgFolder> msgFolder;
msgHdr->GetFolder(getter_AddRefs(msgFolder));
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl =
do_QueryInterface(m_runningUrl);
if (msgUrl)
{
nsCOMPtr<nsIMsgMdnGenerator> mdnGenerator;
nsCOMPtr<nsIMimeHeaders> mimeHeaders;
mdnGenerator =
do_CreateInstance(NS_MSGMDNGENERATOR_CONTRACTID, &rv);
// To ensure code works w/o MDN enabled
if (NS_SUCCEEDED(rv) && mdnGenerator)
{
mimeHeaders =
do_CreateInstance(NS_IMIMEHEADERS_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && mimeHeaders)
{
nsCOMPtr<nsIMsgFolder> msgFolder;
msgHdr->GetFolder(getter_AddRefs(msgFolder));
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl =
do_QueryInterface(m_runningUrl);
if (msgUrl)
{
nsCOMPtr<nsIMsgWindow> msgWindow;
msgUrl->GetMsgWindow(getter_AddRefs(msgWindow));
msgHdr->GetMessageKey(&msgKey);
nsCOMPtr<nsIMimeHeaders> mimeHeaders;
msgUrl->GetMimeHeaders(getter_AddRefs(mimeHeaders));
mdnGenerator->Process(nsIMsgMdnGenerator::eDisplayed,
msgWindow, msgFolder, msgKey,
mimeHeaders, PR_FALSE);
msgUrl->SetMimeHeaders(nsnull);
// no longer needed
}
}
}
// unsetting MDN_REPORT_NEEDED flag and mark the message as
// MDN_REPORT_SENT
// There are cases that: a) user wishes not to send MDN, b)
// mdn module is not installed, c) the message can be marked
// as unread and force it back to the original mdn
// needed state.
msgHdr->SetFlags(msgFlags & ~MSG_FLAG_MDN_REPORT_NEEDED);
msgHdr->OrFlags(MSG_FLAG_MDN_REPORT_SENT, &newFlags);
nsCOMPtr<nsIMsgWindow> msgWindow;
msgUrl->GetMsgWindow(getter_AddRefs(msgWindow));
msgHdr->GetMessageKey(&msgKey);
nsCOMPtr<nsIMimeHeaders> mimeHeaders;
msgUrl->GetMimeHeaders(getter_AddRefs(mimeHeaders));
mdnGenerator->Process(nsIMsgMdnGenerator::eDisplayed,
msgWindow, msgFolder, msgKey,
mimeHeaders, PR_FALSE);
msgUrl->SetMimeHeaders(nsnull);
// no longer needed
}
msgHdr->MarkRead(PR_TRUE);
}
}
}
return rv;
// unsetting MDN_REPORT_NEEDED flag and mark the message as
// MDN_REPORT_SENT
// There are cases that: a) user wishes not to send MDN, b)
// mdn module is not installed, c) the message can be marked
// as unread and force it back to the original mdn
// needed state.
msgHdr->SetFlags(msgFlags & ~MSG_FLAG_MDN_REPORT_NEEDED);
msgHdr->OrFlags(MSG_FLAG_MDN_REPORT_SENT, &newFlags);
}
msgHdr->MarkRead(PR_TRUE);
}
}
return rv;
}
PRInt32 nsMailboxProtocol::SetupMessageExtraction()