Fix for view source URL problem - Bug #30459

This commit is contained in:
rhp%netscape.com 2000-03-20 22:52:51 +00:00
Родитель e1ef01689d
Коммит b68c624cd1
5 изменённых файлов: 80 добавлений и 10 удалений

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

@ -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);
};

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

@ -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() {}

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

@ -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<nsIURI> 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;
}

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

@ -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;

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

@ -470,7 +470,11 @@ main(int argc, char** argv)
// Do some sanity checking...
if (argc < 2)
{
fprintf(stderr, "usage: %s <rfc822_disk_file> <output_format>\n\nwhere output_format is:\n\n19 - indentation formatting\n1 - nsMimeMessageBodyDisplay\n", argv[0]);
fprintf(stderr, "usage: %s <rfc822_disk_file> <output_format>\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;