Index: mailnews/base/src/nsMessenger.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/base/src/nsMessenger.cpp,v retrieving revision 1.326 diff -u -w -p -8 -r1.326 nsMessenger.cpp --- base/src/nsMessenger.cpp 26 Sep 2005 01:38:19 -0000 1.326 +++ mailnews/base/src/nsMessenger.cpp 21 Oct 2005 15:51:26 -0000 @@ -612,16 +612,17 @@ nsMessenger::LoadURL(nsIDOMWindowInterna NS_ConvertASCIItoUTF16 uriString(aURL); // Cleanup the empty spaces that might be on each end. uriString.Trim(" "); // Eliminate embedded newlines, which single-line text fields now allow: uriString.StripChars("\r\n"); NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE); PRBool loadingFromFile = PR_FALSE; + PRBool getDummyMsgHdr = PR_FALSE; PRInt64 fileSize; if (StringBeginsWith(uriString, NS_LITERAL_STRING("file:"))) { nsCOMPtr fileUri; rv = NS_NewURI(getter_AddRefs(fileUri), uriString); NS_ENSURE_SUCCESS(rv, rv); @@ -629,41 +630,48 @@ nsMessenger::LoadURL(nsIDOMWindowInterna NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr file; rv = fileUrl->GetFile(getter_AddRefs(file)); NS_ENSURE_SUCCESS(rv, rv); file->GetFileSize(&fileSize); uriString.ReplaceSubstring(NS_LITERAL_STRING("file:"), NS_LITERAL_STRING("mailbox:")); uriString.Append(NS_LITERAL_STRING("&number=0")); loadingFromFile = PR_TRUE; + getDummyMsgHdr = PR_TRUE; } + else if (FindInReadable(NS_LITERAL_STRING("type=application/x-message-display"), uriString)) + getDummyMsgHdr = PR_TRUE; nsCOMPtr uri; rv = NS_NewURI(getter_AddRefs(uri), uriString); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); nsCOMPtr msgurl = do_QueryInterface(uri); if (msgurl) { msgurl->SetMsgWindow(mMsgWindow); + if (loadingFromFile || getDummyMsgHdr) + { if (loadingFromFile) { nsCOMPtr mailboxUrl = do_QueryInterface(msgurl, &rv); mailboxUrl->SetMessageSize((PRUint32) fileSize); + } + if (getDummyMsgHdr) + { nsCOMPtr headerSink; // need to tell the header sink to capture some headers to create a fake db header // so we can do reply to a .eml file or a rfc822 msg attachment. mMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink)); if (headerSink) { nsCOMPtr dummyHeader; headerSink->GetDummyMsgHeader(getter_AddRefs(dummyHeader)); - if (dummyHeader) - { + if (dummyHeader && loadingFromFile) dummyHeader->SetMessageSize((PRUint32) fileSize); } } } } nsCOMPtr loadInfo; rv = mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo)); @@ -1386,17 +1394,17 @@ nsMessenger::MessageServiceFromURI(const NS_IMETHODIMP nsMessenger::MsgHdrFromURI(const char *aUri, nsIMsgDBHdr **aMsgHdr) { NS_ENSURE_ARG_POINTER(aUri); NS_ENSURE_ARG_POINTER(aMsgHdr); nsCOMPtr msgService; nsresult rv; - if (!strncmp(aUri, "file:", 5)) + if (!strncmp(aUri, "file:", 5) || PL_strstr(aUri, "type=application/x-message-display")) { nsCOMPtr headerSink; mMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink)); if (headerSink) { rv = headerSink->GetDummyMsgHeader(aMsgHdr); // Is there a way to check if they're asking for the hdr currently // displayed in a stand-alone msg window from a .eml file? Index: base/src/nsMsgCopyService.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/base/src/nsMsgCopyService.cpp,v retrieving revision 1.51 diff -u -w -p -8 -r1.51 nsMsgCopyService.cpp --- base/src/nsMsgCopyService.cpp 8 Aug 2005 20:36:39 -0000 1.51 +++ mailnews/base/src/nsMsgCopyService.cpp 21 Oct 2005 15:51:27 -0000 @@ -549,23 +549,20 @@ nsMsgCopyService::CopyFileMessage(nsIFil PRUint32 aMsgFlags, nsIMsgCopyServiceListener* listener, nsIMsgWindow* window) { nsresult rv = NS_ERROR_NULL_POINTER; nsCopyRequest* copyRequest; nsCopySource* copySource = nsnull; nsCOMPtr fileSupport; - nsCOMPtr txnMgr; NS_ENSURE_ARG_POINTER(fileSpec); NS_ENSURE_ARG_POINTER(dstFolder); - if (window) - window->GetTransactionManager(getter_AddRefs(txnMgr)); copyRequest = new nsCopyRequest(); if (!copyRequest) return rv; fileSupport = do_QueryInterface(fileSpec, &rv); if (NS_FAILED(rv)) goto done; rv = copyRequest->Init(nsCopyFileMessageType, fileSupport, dstFolder, isDraft, aMsgFlags, listener, window, PR_FALSE); if (NS_FAILED(rv)) goto done; Index: base/src/nsMsgDBView.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/base/src/nsMsgDBView.cpp,v retrieving revision 1.226 diff -u -w -p -8 -r1.226 nsMsgDBView.cpp --- base/src/nsMsgDBView.cpp 20 Oct 2005 16:03:26 -0000 1.226 +++ mailnews/base/src/nsMsgDBView.cpp 21 Oct 2005 15:51:35 -0000 @@ -974,17 +974,18 @@ NS_IMETHODIMP nsMsgDBView::ReloadMessage { if (m_currentlyDisplayedMsgUri.IsEmpty()) return NS_ERROR_FAILURE; if (mSuppressMsgDisplay) return NS_OK; nsCAutoString forceAllParts(m_currentlyDisplayedMsgUri); - forceAllParts.AppendLiteral("?fetchCompleteMessage=true"); + forceAllParts += (forceAllParts.FindChar('?') == kNotFound) ? "?" : "&"; + forceAllParts.AppendLiteral("fetchCompleteMessage=true"); return mMessengerInstance->OpenURL(forceAllParts.get()); } NS_IMETHODIMP nsMsgDBView::ReloadMessage() { if (m_currentlyDisplayedMsgUri.IsEmpty()) return NS_ERROR_FAILURE; Index: compose/src/nsMsgAttachmentHandler.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/compose/src/nsMsgAttachmentHandler.cpp,v retrieving revision 1.117 diff -u -w -p -8 -r1.117 nsMsgAttachmentHandler.cpp --- compose/src/nsMsgAttachmentHandler.cpp 21 Apr 2005 18:48:36 -0000 1.117 +++ mailnews/compose/src/nsMsgAttachmentHandler.cpp 21 Oct 2005 15:51:47 -0000 @@ -555,17 +555,18 @@ nsMsgAttachmentHandler::SnarfMsgAttachme goto done; } rv = fetcher->Initialize(localFile, mOutFile, FetcherURLDoneCallback, this); rv = GetMessageServiceFromURI(m_uri, getter_AddRefs(messageService)); if (NS_SUCCEEDED(rv) && messageService) { nsCAutoString uri(m_uri); - uri.Append("?fetchCompleteMessage=true"); + uri += (uri.FindChar('?') == kNotFound) ? "?" : "&"; + uri.Append("fetchCompleteMessage=true"); nsCOMPtr strListener; fetcher->QueryInterface(NS_GET_IID(nsIStreamListener), getter_AddRefs(strListener)); // initialize a new stream converter, that uses the strListener as its input // obtain the input stream listener from the new converter, // and pass the converter's input stream listener to DisplayMessage m_mime_parser = do_CreateInstance(NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID, &rv); Index: compose/src/nsMsgCompose.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/compose/src/nsMsgCompose.cpp,v retrieving revision 1.471 diff -u -w -p -8 -r1.471 nsMsgCompose.cpp --- compose/src/nsMsgCompose.cpp 18 Oct 2005 16:29:37 -0000 1.471 +++ mailnews/compose/src/nsMsgCompose.cpp 21 Oct 2005 15:51:54 -0000 @@ -1468,19 +1468,31 @@ nsresult nsMsgCompose::CreateMessage(con // strip out ?type=application/x-message-display because it confuses libmime PRInt32 typeIndex = msgUri.Find("?type=application/x-message-display"); if (typeIndex != kNotFound) { msgUri.Cut(typeIndex, sizeof("?type=application/x-message-display") - 1); // we also need to replace the next '&' with '?' if (msgUri.CharAt(typeIndex) == '&') msgUri.SetCharAt('?', typeIndex); + originalMsgURI = msgUri.get(); + } } + else // check if we're dealing with a displayed message/rfc822 attachment + { + PRInt32 typeIndex = typeIndex = msgUri.Find("&type=application/x-message-display"); + if (typeIndex != kNotFound) + { + msgUri.Cut(typeIndex, sizeof("&type=application/x-message-display") - 1); + // nsURLFetcher will check for "realtype=message/rfc822" and will set the + // content type to message/rfc822 in the forwarded message. + msgUri.Append("&realtype=message/rfc822"); originalMsgURI = msgUri.get(); } + } if (compFields) { NS_IF_RELEASE(m_compFields); m_compFields = NS_REINTERPRET_CAST(nsMsgCompFields*, compFields); NS_ADDREF(m_compFields); } else { Index: compose/src/nsMsgComposeService.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/compose/src/nsMsgComposeService.cpp,v retrieving revision 1.113 diff -u -w -p -8 -r1.113 nsMsgComposeService.cpp --- compose/src/nsMsgComposeService.cpp 3 Oct 2005 23:51:05 -0000 1.113 +++ mailnews/compose/src/nsMsgComposeService.cpp 21 Oct 2005 15:51:56 -0000 @@ -414,17 +414,19 @@ nsMsgComposeService::OpenComposeWindow(c */ if (type == nsIMsgCompType::ForwardInline || type == nsIMsgCompType::Draft || type == nsIMsgCompType::Template || type == nsIMsgCompType::ReplyWithTemplate) { nsCOMPtr pMsgDraft (do_CreateInstance(NS_MSGDRAFT_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv) && pMsgDraft) { nsCAutoString uriToOpen(originalMsgURI); - uriToOpen.Append("?fetchCompleteMessage=true"); + + uriToOpen += (uriToOpen.FindChar('?') == kNotFound) ? "?" : "&"; + uriToOpen.Append("fetchCompleteMessage=true"); switch(type) { case nsIMsgCompType::ForwardInline: rv = pMsgDraft->OpenDraftMsg(uriToOpen.get(), originalMsgURI, identity, PR_TRUE, aMsgWindow); break; case nsIMsgCompType::Draft: rv = pMsgDraft->OpenDraftMsg(uriToOpen.get(), nsnull, identity, PR_FALSE, aMsgWindow); @@ -470,22 +472,22 @@ nsMsgComposeService::OpenComposeWindow(c esc_FileBaseName|esc_Forced|esc_AlwaysCopy, unescapedName); pMsgCompFields->SetNewsgroups(NS_ConvertUTF8toUTF16(unescapedName)); pMsgCompFields->SetNewshost(host.get()); } else { pMsgComposeParams->SetOriginalMsgURI(originalMsgURI); - if (PL_strstr(originalMsgURI, "?type=application/x-message-display")) + if (PL_strstr(originalMsgURI, "type=application/x-message-display")) { nsCOMPtr msgHdr; if (strncmp(originalMsgURI, "file:", 5)) rv = GetMsgDBHdrFromURI(originalMsgURI, getter_AddRefs(msgHdr)); - else if (aMsgWindow) + if (aMsgWindow && !msgHdr) { nsCOMPtr headerSink; rv = aMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink)); if (headerSink) rv = headerSink->GetDummyMsgHeader(getter_AddRefs(msgHdr)); } pMsgComposeParams->SetOrigMsgHdr(msgHdr); } Index: compose/src/nsMsgCreate.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/compose/src/nsMsgCreate.cpp,v retrieving revision 1.60 diff -u -w -p -8 -r1.60 nsMsgCreate.cpp --- compose/src/nsMsgCreate.cpp 16 Sep 2005 15:18:33 -0000 1.60 +++ mailnews/compose/src/nsMsgCreate.cpp 21 Oct 2005 15:51:57 -0000 @@ -144,19 +144,19 @@ nsMsgDraft::ProcessDraftOrTemplateOperat printf("Unable to get the nsIStreamListener interface from libmime\n"); #endif return NS_ERROR_UNEXPECTED; } nsCOMPtr aURL; nsCAutoString uriString(msgURI); PRBool fileUrl = StringBeginsWith(uriString, NS_LITERAL_CSTRING("file:")); + PRBool forwardedMessage = PL_strstr(msgURI, "&type=application/x-message-display") != nsnull; - - if (fileUrl) + if (fileUrl || forwardedMessage) rv = NS_NewURI(getter_AddRefs(aURL), msgURI); else rv = mMessageService->GetUrlForUri(mURI, getter_AddRefs(aURL), aMsgWindow); if (aURL) aURL->SetSpec(nsDependentCString(mURI)); // if we are forwarding a message and that message used a charset over ride // then use that over ride charset instead of the charset specified in the message Index: compose/src/nsMsgQuote.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/compose/src/nsMsgQuote.cpp,v retrieving revision 1.71 diff -u -w -p -8 -r1.71 nsMsgQuote.cpp --- compose/src/nsMsgQuote.cpp 16 Sep 2005 15:18:33 -0000 1.71 +++ mailnews/compose/src/nsMsgQuote.cpp 21 Oct 2005 15:51:58 -0000 @@ -170,19 +170,19 @@ nsMsgQuote::QuoteMessage(const char *msg if (!msgURI) return NS_ERROR_INVALID_ARG; mQuoteHeaders = quoteHeaders; mStreamListener = aQuoteMsgStreamListener; nsCAutoString msgUri(msgURI); PRBool fileUrl = !strncmp(msgURI, "file:", 5); - + PRBool forwardedMessage = PL_strstr(msgURI, "&realtype=message/rfc822") != nsnull; nsCOMPtr aURL; - if (fileUrl) + if (fileUrl || forwardedMessage) rv = NS_NewURI(getter_AddRefs(aURL), msgURI); else { nsCOMPtr msgService; rv = GetMessageServiceFromURI(msgURI, getter_AddRefs(msgService)); if (NS_FAILED(rv)) return rv; rv = msgService->GetUrlForUri(msgURI, getter_AddRefs(aURL), nsnull); } Index: compose/src/nsURLFetcher.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/compose/src/nsURLFetcher.cpp,v retrieving revision 1.72 diff -u -w -p -8 -r1.72 nsURLFetcher.cpp --- compose/src/nsURLFetcher.cpp 13 Jun 2005 18:10:20 -0000 1.72 +++ mailnews/compose/src/nsURLFetcher.cpp 21 Oct 2005 15:51:58 -0000 @@ -484,26 +484,33 @@ NS_IMETHODIMP nsURLFetcherStreamConsumer { if (!mURLFetcher) return NS_ERROR_FAILURE; // Check the content type! nsCAutoString contentType; nsCAutoString charset; - nsCOMPtr aChannel = do_QueryInterface(aRequest); - if(!aChannel) return NS_ERROR_FAILURE; + nsCOMPtr channel = do_QueryInterface(aRequest); + if(!channel) return NS_ERROR_FAILURE; - if (NS_SUCCEEDED(aChannel->GetContentType(contentType)) && + if (NS_SUCCEEDED(channel->GetContentType(contentType)) && !contentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) { + nsCAutoString uriSpec; + nsCOMPtr channelURI; + channel->GetURI(getter_AddRefs(channelURI)); + channelURI->GetSpec(uriSpec); + if (FindInReadable(NS_LITERAL_CSTRING("&realtype=message/rfc822"), uriSpec)) + mURLFetcher->mContentType = MESSAGE_RFC822; + else mURLFetcher->mContentType = contentType; } - if (NS_SUCCEEDED(aChannel->GetContentCharset(charset)) && !charset.IsEmpty()) + if (NS_SUCCEEDED(channel->GetContentCharset(charset)) && !charset.IsEmpty()) { mURLFetcher->mCharset = charset; } return NS_OK; } /** nsIStreamListener methods **/ =================================================================== RCS file: /cvsroot/mozilla/mailnews/imap/src/nsImapService.cpp,v retrieving revision 1.309 diff -u -w -p -8 -r1.309 nsImapService.cpp --- imap/src/nsImapService.cpp 22 Mar 2005 18:25:33 -0000 1.309 +++ mailnews/imap/src/nsImapService.cpp 21 Oct 2005 15:52:23 -0000 @@ -95,16 +95,17 @@ #include "nsIDOMWindowInternal.h" #include "nsIMessengerWindowService.h" #include "nsIWindowMediator.h" #include "nsIPrompt.h" #include "nsIWindowWatcher.h" #include "nsImapProtocol.h" #include "nsIMsgMailSession.h" #include "nsIStreamConverterService.h" +#include "nsNetUtil.h" #include "nsInt64.h" #define PREF_MAIL_ROOT_IMAP "mail.root.imap" // old - for backward compatibility only #define PREF_MAIL_ROOT_IMAP_REL "mail.root.imap-rel" static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID); static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID); @@ -308,16 +309,20 @@ nsImapService::LiteSelectFolder(nsIEvent return rv; } NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow) { nsresult rv = NS_OK; + if (PL_strstr(aMessageURI, "&type=application/x-message-display")) + return NS_NewURI(aURL, aMessageURI); + + nsCOMPtr folder; nsXPIDLCString msgKey; rv = DecomposeImapURI(aMessageURI, getter_AddRefs(folder), getter_Copies(msgKey)); if (NS_SUCCEEDED(rv)) { nsCOMPtr imapUrl; nsCAutoString urlSpec; PRUnichar hierarchySeparator = GetHierarchyDelimiter(folder); @@ -477,17 +482,47 @@ NS_IMETHODIMP nsImapService::DisplayMess nsIURI ** aURL) { nsresult rv = NS_OK; nsCOMPtr folder; nsXPIDLCString msgKey; nsXPIDLCString mimePart; nsCAutoString folderURI; nsMsgKey key; + nsCAutoString messageURI(aMessageURI); + PRInt32 typeIndex = messageURI.Find("&type=application/x-message-display"); + if (typeIndex != kNotFound) + { + // This happens with forward inline of a message/rfc822 attachment opened in + // a standalone msg window. + // So, just cut to the chase and call AsyncOpen on a channel. + nsCOMPtr uri; + messageURI.Cut(typeIndex, sizeof("&type=application/x-message-display") - 1); + rv = NS_NewURI(getter_AddRefs(uri), messageURI.get()); + NS_ENSURE_SUCCESS(rv, rv); + if (aURL) + NS_IF_ADDREF(*aURL = uri); + nsCOMPtr aStreamListener = do_QueryInterface(aDisplayConsumer, &rv); + if (NS_SUCCEEDED(rv) && aStreamListener) + { + nsCOMPtr aChannel; + nsCOMPtr aLoadGroup; + nsCOMPtr mailnewsUrl = do_QueryInterface(uri, &rv); + if (NS_SUCCEEDED(rv) && mailnewsUrl) + mailnewsUrl->GetLoadGroup(getter_AddRefs(aLoadGroup)); + + rv = NewChannel(uri, getter_AddRefs(aChannel)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr aCtxt = do_QueryInterface(uri); + // now try to open the channel passing in our display consumer as the listener + return aChannel->AsyncOpen(aStreamListener, aCtxt); + } + } rv = DecomposeImapURI(aMessageURI, getter_AddRefs(folder), getter_Copies(msgKey)); if (msgKey.IsEmpty()) return NS_MSG_MESSAGE_NOT_FOUND; rv = nsParseImapMessageURI(aMessageURI, folderURI, &key, getter_Copies(mimePart)); if (NS_SUCCEEDED(rv)) { nsCOMPtr imapMessageSink(do_QueryInterface(folder, &rv)); if (NS_SUCCEEDED(rv)) Index: local/src/nsMailboxProtocol.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/local/src/nsMailboxProtocol.cpp,v retrieving revision 1.122 diff -u -w -p -8 -r1.122 nsMailboxProtocol.cpp --- local/src/nsMailboxProtocol.cpp 1 Jun 2005 19:04:20 -0000 1.122 +++ mailnews/local/src/nsMailboxProtocol.cpp 21 Oct 2005 15:52:26 -0000 @@ -456,16 +456,18 @@ nsresult nsMailboxProtocol::LoadUrl(nsIU m_runningUrl = do_QueryInterface(aURL); if (m_runningUrl) { // find out from the url what action we are supposed to perform... rv = m_runningUrl->GetMailboxAction(&m_mailboxAction); PRBool convertData = PR_FALSE; + // need to check if we're fetching an rfc822 part in order to + // quote a message. if (m_mailboxAction == nsIMailboxUrl::ActionFetchMessage) { nsCOMPtr msgUrl = do_QueryInterface(m_runningUrl, &rv); NS_ENSURE_SUCCESS(rv,rv); nsCAutoString queryStr; rv = msgUrl->GetQuery(queryStr); NS_ENSURE_SUCCESS(rv,rv); Index: local/src/nsMailboxService.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/local/src/nsMailboxService.cpp,v retrieving revision 1.116 diff -u -w -p -8 -r1.116 nsMailboxService.cpp --- local/src/nsMailboxService.cpp 16 Sep 2005 15:19:09 -0000 1.116 +++ mailnews/local/src/nsMailboxService.cpp 21 Oct 2005 15:52:27 -0000 @@ -177,16 +177,19 @@ nsresult nsMailboxService::FetchMessage( nsIURI ** aURL) { nsresult rv = NS_OK; nsCOMPtr mailboxurl; nsMailboxAction actionToUse = mailboxAction; nsCOMPtr url; + + nsCAutoString uriString(aMessageURI); + if (!strncmp(aMessageURI, "file:", 5)) { PRInt64 fileSize; nsCOMPtr fileUri; rv = NS_NewURI(getter_AddRefs(fileUri), aMessageURI); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr fileUrl = do_QueryInterface(fileUri, &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -216,16 +219,27 @@ nsresult nsMailboxService::FetchMessage( headerSink->GetDummyMsgHeader(getter_AddRefs(dummyHeader)); if (dummyHeader) dummyHeader->SetMessageSize((PRUint32) fileSize); } } } else { + + // this happens with forward inline of message/rfc822 attachment + // opened in a stand-alone msg window. + PRInt32 typeIndex = typeIndex = uriString.Find("&type=application/x-message-display"); + if (typeIndex != kNotFound) + { + uriString.Cut(typeIndex, sizeof("&type=application/x-message-display") - 1); + rv = NS_NewURI(getter_AddRefs(url), uriString.get()); + mailboxurl = do_QueryInterface(url); + } + else rv = PrepareMessageUrl(aMessageURI, aUrlListener, actionToUse , getter_AddRefs(mailboxurl), aMsgWindow); if (NS_SUCCEEDED(rv)) { url = do_QueryInterface(mailboxurl); nsCOMPtr msgUrl (do_QueryInterface(url)); msgUrl->SetMsgWindow(aMsgWindow); nsCOMPtr i18nurl (do_QueryInterface(msgUrl)); @@ -313,27 +327,16 @@ NS_IMETHODIMP nsMailboxService::OpenAtta const char *aUrl, const char *aMessageUri, nsISupports *aDisplayConsumer, nsIMsgWindow *aMsgWindow, nsIUrlListener *aUrlListener) { nsCOMPtr URL; nsCAutoString urlString(aUrl); - // strip out ?type=application/x-message-display because it confuses libmime - - PRInt32 typeIndex = urlString.Find("?type=application/x-message-display"); - if (typeIndex != kNotFound) - { - urlString.Cut(typeIndex, sizeof("?type=application/x-message-display") - 1); - // we also need to replace the next '&' with '?' - PRInt32 firstPartIndex = urlString.FindChar('&'); - if (firstPartIndex != kNotFound) - urlString.SetCharAt('?', firstPartIndex); - } urlString += "&type="; urlString += aContentType; urlString += "&filename="; urlString += aFileName; CreateStartupUrl(urlString.get(), getter_AddRefs(URL)); nsresult rv; // try to run the url in the docshell... nsCOMPtr docShell(do_QueryInterface(aDisplayConsumer, &rv)); @@ -384,17 +387,18 @@ nsMailboxService::SaveMessageToDisk(cons if (aURL) mailboxurl->QueryInterface(NS_GET_IID(nsIURI), (void **) aURL); return rv; } NS_IMETHODIMP nsMailboxService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow) { - if (!strncmp(aMessageURI, "file:", 5)) + if (!strncmp(aMessageURI, "file:", 5) || PL_strstr(aMessageURI, "type=application/x-message-display") + || !strncmp(aMessageURI, "mailbox:", 8)) return NS_NewURI(aURL, aMessageURI); nsresult rv = NS_OK; nsCOMPtr mailboxurl; rv = PrepareMessageUrl(aMessageURI, nsnull, nsIMailboxUrl::ActionFetchMessage, getter_AddRefs(mailboxurl), aMsgWindow); if (NS_SUCCEEDED(rv) && mailboxurl) rv = mailboxurl->QueryInterface(NS_GET_IID(nsIURI), (void **) aURL); return rv; Index: local/src/nsPop3Sink.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/local/src/nsPop3Sink.cpp,v retrieving revision 1.127 diff -u -w -p -8 -r1.127 nsPop3Sink.cpp --- local/src/nsPop3Sink.cpp 7 Aug 2005 15:43:53 -0000 1.127 +++ mailnews/local/src/nsPop3Sink.cpp 21 Oct 2005 15:52:28 -0000 @@ -803,17 +803,16 @@ nsPop3Sink::IncorporateComplete(nsIMsgWi m_outFileStream->flush(); m_outFileStream->close(); m_newMailParser->FinishHeader(); // need to re-open the inbox file stream. if (!m_tmpDownloadFileSpec.Exists()) return HandleTempDownloadFailed(aMsgWindow); m_outFileStream->Open(m_tmpDownloadFileSpec, (PR_RDWR | PR_CREATE_FILE)); - m_newMailParser->ApplyFilters(&moved, aMsgWindow, 0); if (!moved) { if (m_outFileStream->is_open()) { nsFileSpec destFolderSpec; nsCOMPtr path; Index: mime/src/mimedrft.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/mime/src/mimedrft.cpp,v retrieving revision 1.142 diff -u -w -p -8 -r1.142 mimedrft.cpp --- mime/src/mimedrft.cpp 20 Jul 2005 11:49:43 -0000 1.142 +++ mailnews/mime/src/mimedrft.cpp 21 Oct 2005 15:52:38 -0000 @@ -2077,16 +2077,20 @@ mime_bridge_create_draft_stream( goto FAIL; rv = msgService->GetUrlForUri(turl.get(), getter_AddRefs(aURL), nsnull); if (NS_FAILED(rv)) goto FAIL; if (NS_SUCCEEDED(aURL->GetSpec(urlString))) { + PRInt32 typeIndex = urlString.Find("&type=application/x-message-display"); + if (typeIndex != kNotFound) + urlString.Cut(typeIndex, sizeof("&type=application/x-message-display") - 1); + mdd->url_name = ToNewCString(urlString); if (!(mdd->url_name)) goto FAIL; } newPluginObj2->GetForwardInline(&mdd->forwardInline); newPluginObj2->GetIdentity(getter_AddRefs(mdd->identity)); newPluginObj2->GetOriginalMsgURI(&mdd->originalMsgURI); Index: mime/src/mimei.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/mime/src/mimei.cpp,v retrieving revision 1.77 diff -u -w -p -8 -r1.77 mimei.cpp --- mime/src/mimei.cpp 13 Jun 2005 18:34:05 -0000 1.77 +++ mailnews/mime/src/mimei.cpp 21 Oct 2005 15:52:41 -0000 @@ -1367,16 +1367,26 @@ mime_set_url_part(const char *url, const const char *part_begin = 0; const char *part_end = 0; PRBool got_q = PR_FALSE; const char *s; char *result; if (!url || !part) return 0; + nsCAutoString urlString(url); + PRInt32 typeIndex = urlString.Find("?type=application/x-message-display"); + if (typeIndex != kNotFound) + { + urlString.Cut(typeIndex, sizeof("?type=application/x-message-display") - 1); + if (urlString.CharAt(typeIndex) == '&') + urlString.SetCharAt('?', typeIndex); + url = urlString.get(); + } + for (s = url; *s; s++) { if (*s == '?') { got_q = PR_TRUE; if (!nsCRT::strncasecmp(s, "?part=", 6)) part_begin = (s += 6); } @@ -1665,34 +1675,32 @@ mime_parse_url_options(const char *url, options->headers = MimeHeadersMicro; else if (end > value && !nsCRT::strncasecmp ("cite", value, end - value)) options->headers = MimeHeadersCitation; else if (end > value && !nsCRT::strncasecmp ("citation", value, end-value)) options->headers = MimeHeadersCitation; else options->headers = default_headers; } - else if (!nsCRT::strncasecmp ("part", q, name_end - q)) + else if (!nsCRT::strncasecmp ("part", q, name_end - q) && + options->format_out != nsMimeOutput::nsMimeMessageBodyQuoting) { PR_FREEIF (options->part_to_load); if (end > value) { options->part_to_load = (char *) PR_MALLOC(end - value + 1); if (!options->part_to_load) return MIME_OUT_OF_MEMORY; memcpy(options->part_to_load, value, end-value); options->part_to_load[end-value] = 0; } } else if (!nsCRT::strncasecmp ("rot13", q, name_end - q)) { - if (end <= value || !nsCRT::strncasecmp ("true", value, end - value)) - options->rot13_p = PR_TRUE; - else - options->rot13_p = PR_FALSE; + options->rot13_p = end <= value || !nsCRT::strncasecmp ("true", value, end - value); } q = end; if (*q) q++; } @@ -1751,16 +1759,17 @@ mime_parse_url_options(const char *url, and leaves them incompatible for: = the first part of a top-level multipart = all elements deeper than the outermost part Life s#$%s when you don't properly think out things that end up turning into de-facto standards... */ + if (options->part_to_load && !PL_strchr(options->part_to_load, '.')) /* doesn't contain a dot */ { if (!nsCRT::strcmp(options->part_to_load, "0")) /* 0 */ { PR_Free(options->part_to_load); options->part_to_load = nsCRT::strdup("1"); if (!options->part_to_load) @@ -1774,17 +1783,16 @@ mime_parse_url_options(const char *url, if (!s) return MIME_OUT_OF_MEMORY; PL_strcpy(s, prefix); PL_strcat(s, options->part_to_load); PR_Free(options->part_to_load); options->part_to_load = s; } } - return 0; } /* Some output-generation utility functions... */ int @@ -1949,16 +1957,28 @@ MimeObject_output_init(MimeObject *obj, char * mime_get_base_url(const char *url) { if (!url) return nsnull; const char *s = strrchr(url, '?'); + if (s && !strncmp(s, "?type=application/x-message-display", sizeof("?type=application/x-message-display") - 1)) + { + const char *nextTerm = strchr(s, '&'); + s = (nextTerm) ? nextTerm : s + strlen(s) - 1; + } + // we need to keep the ?number part of the url, or we won't know + // which local message the part belongs to. + if (s && *s && *(s+1) && !strncmp(s + 1, "number=", sizeof("number=") - 1)) + { + const char *nextTerm = strchr(++s, '&'); + s = (nextTerm) ? nextTerm : s + strlen(s) - 1; + } char *result = (char *) PR_MALLOC(strlen(url) + 1); NS_ASSERTION(result, "out of memory"); if (!result) return nsnull; memcpy(result, url, s - url); result[s - url] = 0; return result; Index: mime/src/nsStreamConverter.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/mime/src/nsStreamConverter.cpp,v retrieving revision 1.128 diff -u -w -p -8 -r1.128 nsStreamConverter.cpp --- mime/src/nsStreamConverter.cpp 16 Aug 2005 14:23:00 -0000 1.128 +++ mailnews/mime/src/nsStreamConverter.cpp 21 Oct 2005 15:52:42 -0000 @@ -403,17 +403,17 @@ nsStreamConverter::DetermineOutputFormat // Don't muck with this data! *aNewType = nsMimeOutput::nsMimeMessageRaw; return NS_OK; } } // is this is a part that should just come out raw const char *part = FindQueryElementData(queryPart, "part="); - if (part) + if (part && !mToType.Equals("application/vnd.mozilla.xul+xml")) { // default for parts mOutputFormat = "raw"; *aNewType = nsMimeOutput::nsMimeMessageRaw; // if we are being asked to fetch a part....it should have a // content type appended to it...if it does, we want to remember // that as mOutputFormat @@ -1096,16 +1096,19 @@ NS_IMETHODIMP nsStreamConverter::AsyncCo SetMimeHeadersListener(quoteListener, nsMimeOutput::nsMimeMessageQuoting); rv = aMsgQuote->GetQuoteChannel(getter_AddRefs(aChannel)); } else { aChannel = do_QueryInterface(aCtxt, &rv); } + mFromType = aFromType; + mToType = aToType; + NS_ASSERTION(aChannel && NS_SUCCEEDED(rv), "mailnews mime converter has to have the channel passed in..."); if (NS_FAILED(rv)) return rv; nsCOMPtr aUri; aChannel->GetURI(getter_AddRefs(aUri)); return Init(aUri, aListener, aChannel); } Index: mime/src/nsStreamConverter.h =================================================================== RCS file: /cvsroot/mozilla/mailnews/mime/src/nsStreamConverter.h,v retrieving revision 1.25 diff -u -w -p -8 -r1.25 nsStreamConverter.h --- mime/src/nsStreamConverter.h 1 Jun 2004 17:22:01 -0000 1.25 +++ mailnews/mime/src/nsStreamConverter.h 21 Oct 2005 15:52:42 -0000 @@ -102,16 +102,18 @@ private: nsCString mOverrideFormat; // this is a possible override for emitter creation PRBool mWrapperOutput; // Should we output the frame split message display nsCOMPtr mMimeStreamConverterListener; PRBool mForwardInline; nsCOMPtr mIdentity; nsCString mOriginalMsgURI; + nsCString mFromType; + nsCString mToType; #ifdef DEBUG_mscott PRTime mConvertContentTime; #endif nsIRequest * mPendingRequest; // used when we need to delay to fire onStartRequest nsISupports * mPendingContext; // used when we need to delay to fire onStartRequest }; #endif /* nsStreamConverter_h_ */ Index: mailWindowOverlay.js =================================================================== RCS file: /cvsroot/mozilla/mail/base/content/mailWindowOverlay.js,v retrieving revision 1.103 diff -u -w -p -8 -r1.103 mailWindowOverlay.js --- mailWindowOverlay.js 12 Oct 2005 21:32:51 -0000 1.103 +++ mail/base/content/mailWindowOverlay.js 27 Oct 2005 16:46:58 -0000 @@ -2391,17 +2391,17 @@ function HandleMDNResponse(aUrl) if (IsNewsMessage(msgURI)) return; // if the message is marked as junk, do NOT attempt to process a return receipt // in order to better protect the user if (SelectedMessagesAreJunk()) return; - var msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI); + var msgHdr = messenger.msgHdrFromURI(msgURI); var mimeHdr; try { mimeHdr = aUrl.mimeHeaders; } catch (ex) { return; }