diff --git a/mozilla/mailnews/base/public/nsIMsgMailSession.idl b/mozilla/mailnews/base/public/nsIMsgMailSession.idl index 5ef44325987..11e624831cc 100644 --- a/mozilla/mailnews/base/public/nsIMsgMailSession.idl +++ b/mozilla/mailnews/base/public/nsIMsgMailSession.idl @@ -77,5 +77,7 @@ interface nsIMsgMailSession : nsISupports { void RemoveMsgWindow(in nsIMsgWindow msgWindow); readonly attribute nsISupportsArray msgWindowsArray; boolean IsFolderOpenInWindow(in nsIMsgFolder folder); + + string ConvertMsgURIToMsgURL(in string aURI); }; diff --git a/mozilla/mailnews/base/resources/content/widgetglue.js b/mozilla/mailnews/base/resources/content/widgetglue.js index 23e80f023bc..fff76040a2b 100644 --- a/mozilla/mailnews/base/resources/content/widgetglue.js +++ b/mozilla/mailnews/base/resources/content/widgetglue.js @@ -994,16 +994,44 @@ function MsgViewPageSource() { dump("MsgViewPageSource(); \n "); - var uri = window.frames["messagepane"].location+"?header=src"; - dump('URI=' + uri); - - // Use a browser window to view source - window.openDialog( "chrome://navigator/content/", - "_blank", - "chrome,menubar,status,dialog=no,resizable", - uri, - "view-source" ); + var tree = GetThreadTree(); + var selectedItems = tree.selectedItems; + var numSelected = selectedItems.length; + var url; + var uri; + var mailSessionProgID = "component://netscape/messenger/services/session"; + if (numSelected == 0) + { + dump("MsgViewPageSource(): No messages selected.\n"); + return false; + } + + // First, get the mail session + var mailSession = Components.classes[mailSessionProgID].getService(); + if (!mailSession) + return false; + + mailSession = mailSession.QueryInterface(Components.interfaces.nsIMsgMailSession); + if (!mailSession) + return false; + + for(var i = 0; i < numSelected; i++) + { + uri = selectedItems[i].getAttribute("id"); + + // Now, we need to get a URL from a URI + url = mailSession.ConvertMsgURIToMsgURL(uri); + if (url) + url += "?header=src"; + + // Use a browser window to view source + window.openDialog( "chrome://navigator/content/", + "_blank", + "chrome,menubar,status,dialog=no,resizable", + url, + "view-source" ); + } } function MsgViewPageInfo() {} diff --git a/mozilla/mailnews/base/src/nsMsgMailSession.cpp b/mozilla/mailnews/base/src/nsMsgMailSession.cpp index 718035810ae..ab0a591aba7 100644 --- a/mozilla/mailnews/base/src/nsMsgMailSession.cpp +++ b/mozilla/mailnews/base/src/nsMsgMailSession.cpp @@ -29,6 +29,10 @@ #include "nsFileLocations.h" #include "nsIMsgStatusFeedback.h" #include "nsIMsgWindow.h" +#include "nsIMsgMessageService.h" +#include "nsMsgUtils.h" +#include "nsIURI.h" +#include "nsXPIDLString.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsMsgMailSession, nsIMsgMailSession); @@ -329,3 +333,31 @@ NS_IMETHODIMP nsMsgMailSession::IsFolderOpenInWindow(nsIMsgFolder *folder, PRBoo return NS_OK; } +NS_IMETHODIMP +nsMsgMailSession::ConvertMsgURIToMsgURL(const char *aURI, char **aURL) +{ + if ((!aURI) || (!aURL)) + return NS_ERROR_NULL_POINTER; + + // convert the rdf msg uri into a url that represents the message... + nsIMsgMessageService *msgService = nsnull; + nsresult rv = GetMessageServiceFromURI(aURI, &msgService); + if (NS_FAILED(rv)) + return NS_ERROR_NULL_POINTER; + + nsCOMPtr tURI; + rv = msgService->GetUrlForUri(aURI, getter_AddRefs(tURI)); + if (NS_FAILED(rv)) + return NS_ERROR_NULL_POINTER; + + nsXPIDLCString urlString; + if (NS_SUCCEEDED(tURI->GetSpec(getter_Copies(urlString)))) + { + *aURL = nsCRT::strdup(urlString); + if (!(aURL)) + return NS_ERROR_NULL_POINTER; + } + + ReleaseMessageServiceFromURI(aURI, msgService); + return rv; +} diff --git a/mozilla/mailnews/mime/src/mimedrft.cpp b/mozilla/mailnews/mime/src/mimedrft.cpp index 5a45e58006c..d400d77827c 100644 --- a/mozilla/mailnews/mime/src/mimedrft.cpp +++ b/mozilla/mailnews/mime/src/mimedrft.cpp @@ -1826,6 +1826,8 @@ mime_bridge_create_draft_stream( } } + ReleaseMessageServiceFromURI(turl, msgService); + newPluginObj2->GetForwardInline(&mdd->forwardInline); newPluginObj2->GetIdentity(getter_AddRefs(mdd->identity)); mdd->format_out = format_out; diff --git a/mozilla/mailnews/mime/tests/mimetest/mimetest.cpp b/mozilla/mailnews/mime/tests/mimetest/mimetest.cpp index 3eddee33362..1df7a9f2a82 100644 --- a/mozilla/mailnews/mime/tests/mimetest/mimetest.cpp +++ b/mozilla/mailnews/mime/tests/mimetest/mimetest.cpp @@ -470,7 +470,11 @@ main(int argc, char** argv) // Do some sanity checking... if (argc < 2) { - fprintf(stderr, "usage: %s \n\nwhere output_format is:\n\n19 - indentation formatting\n1 - nsMimeMessageBodyDisplay\n", argv[0]); + fprintf(stderr, "usage: %s \n\n", argv[0]); + fprintf(stderr, "where output_format is:\n\n19 - indentation formatting\n"); + fprintf(stderr, " 1 - nsMimeMessagePrintOutput\n"); + fprintf(stderr, " 2 - nsMimeMessageBodyDisplay\n"); + fprintf(stderr, " 3 - nsMimeMessageQuoting\n"); return 1; } @@ -517,6 +521,8 @@ DoRFC822toHTMLConversion(char *filename, int numArgs, int outFormat) outFormat = nsMimeOutput::nsMimeMessagePrintOutput; else if (outFormat == 2) outFormat = nsMimeOutput::nsMimeMessageBodyDisplay; + else if (outFormat == 3) + outFormat = nsMimeOutput::nsMimeMessageBodyDisplay; char *opts = PL_strchr(filename, '?'); char save;