From 9b159a7c312b1a84a60f5098a9da5bd7b0f6968b Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Thu, 15 May 2003 18:07:46 +0000 Subject: [PATCH] synch with the trunk. Add the Thread menu item back which was removed during a bad merge. --- mail/base/content/mailWindowOverlay.js | 84 +++++++++++++++++++++++-- mail/base/content/mailWindowOverlay.xul | 15 +++++ 2 files changed, 93 insertions(+), 6 deletions(-) diff --git a/mail/base/content/mailWindowOverlay.js b/mail/base/content/mailWindowOverlay.js index 6432eaf9cf30..969ba6a91b0a 100644 --- a/mail/base/content/mailWindowOverlay.js +++ b/mail/base/content/mailWindowOverlay.js @@ -25,6 +25,12 @@ * David Bienvenu */ +const MSG_FLAG_IMAP_DELETED = 0x200000; +const MSG_FLAG_MDN_REPORT_NEEDED = 0x400000; +const MSG_FLAG_MDN_REPORT_SENT = 0x800000; +const MDN_DISPOSE_TYPE_DISPLAYED = 0; +const ADDR_DB_LARGE_COMMIT = 1; + var gMessengerBundle; var gPromptService; var gOfflinePromptsBundle; @@ -557,7 +563,6 @@ function UpdateDeleteCommand() function SelectedMessagesAreDeleted() { try { - const MSG_FLAG_IMAP_DELETED = 0x200000; return gDBView.hdrForFirstSelectedMessage.flags & MSG_FLAG_IMAP_DELETED; } catch (ex) { @@ -1942,18 +1947,30 @@ function SetUpJunkBar(aMsgHdr) goUpdateCommand('button_junk'); } -function OnMsgLoaded(folder, aMessageURI) +function OnMsgLoaded(aUrl) { - if (/type=x-message-display/.test(aMessageURI)) + if (!aUrl) + return; + + var folder = aUrl.folder; + var msgURI = GetLoadedMessage(); + + if (!folder || !msgURI) + return; + + if (/type=x-message-display/.test(msgURI)) SetUpJunkBar(null); else { - var msgHdr = messenger.messageServiceFromURI(aMessageURI).messageURIToMsgHdr(aMessageURI); - SetUpJunkBar(msgHdr); + var msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI); + SetUpJunkBar(msgHdr); } + // See if MDN was requested but has not been sent. + HandleMDNResponse(aUrl); + var currentMsgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder); - if (!IsImapMessage(aMessageURI)) + if (!IsImapMessage(msgURI)) return; var imapServer = currentMsgFolder.server.QueryInterface(Components.interfaces.nsIImapIncomingServer); @@ -1992,6 +2009,61 @@ function OnMsgLoaded(folder, aMessageURI) } } +// +// This function handles all mdn response generation (ie, imap and pop). +// For pop the msg uid can be 0 (ie, 1st msg in a local folder) so no +// need to check uid here. No one seems to set mimeHeaders to null so +// no need to check it either. +// +function HandleMDNResponse(aUrl) +{ + if (!aUrl) + return; + + var msgFolder = aUrl.folder; + var msgURI = GetLoadedMessage(); + if (!msgFolder || !msgURI) + return; + + var msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI); + var mimeHdr = aUrl.mimeHeaders; + + // If we didn't get the message id when we downloaded the message header, + // we cons up an md5: message id. If we've done that, we'll try to extract + // the message id out of the mime headers for the whole message. + var msgId = msgHdr.messageId; + if (msgId.split(":")[0] == "md5") + { + var mimeMsgId = mimeHdr.extractHeader("Message-Id", false); + if (mimeMsgId) + msgHdr.messageId = mimeMsgId; + } + + // After a msg is downloaded it's already marked READ at this point so we must check if + // the msg has a "Disposition-Notification-To" header and no MDN report has been sent yet. + var msgFlags = msgHdr.flags; + if ((msgFlags & MSG_FLAG_IMAP_DELETED) || (msgFlags & MSG_FLAG_MDN_REPORT_SENT)) + return; + + var DNTHeader = mimeHdr.extractHeader("Disposition-Notification-To", false); + if (!DNTHeader) + return; + + // Everything looks good so far, let's generate the MDN response. + var mdnGenerator = Components.classes["@mozilla.org/messenger-mdn/generator;1"]. + createInstance(Components.interfaces.nsIMsgMdnGenerator); + mdnGenerator.process(MDN_DISPOSE_TYPE_DISPLAYED, msgWindow, msgFolder, msgHdr.messageKey, mimeHdr, false); + + // Reset mark msg MDN "Sent" and "Not Needed". + msgHdr.flags = (msgFlags & ~MSG_FLAG_MDN_REPORT_NEEDED); + msgHdr.OrFlags(MSG_FLAG_MDN_REPORT_SENT); + + // Commit db changes. + var msgdb = msgFolder.getMsgDatabase(msgWindow); + if (msgdb) + msgdb.Commit(ADDR_DB_LARGE_COMMIT); +} + function MsgSearchMessages() { var preselectedFolder = null; diff --git a/mail/base/content/mailWindowOverlay.xul b/mail/base/content/mailWindowOverlay.xul index ef4ebdb5f96e..da35d88629cb 100644 --- a/mail/base/content/mailWindowOverlay.xul +++ b/mail/base/content/mailWindowOverlay.xul @@ -1132,7 +1132,22 @@ Rights Reserved. + + + + + + + + + + + + + + +