round 2,partial fix bug 10802; passed in part number and content type for open attachment

This commit is contained in:
jefft%netscape.com 2000-05-02 22:45:44 +00:00
Родитель 24ea211304
Коммит cc939ec96c
8 изменённых файлов: 38 добавлений и 103 удалений

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

@ -79,7 +79,7 @@ interface nsIMessenger : nsISupports {
void SendUnsentMessages(in nsIMsgIdentity aIdentity);
void SetDocumentCharset(in wstring characterSet);
void saveAs(in string url, in boolean asFile, in nsIMsgIdentity identity, in nsIMsgWindow aMsgWindow);
void openAttachment(in string url, in string displayName, in string messageUri);
void openAttachment(in string contentTpe, in string url, in string displayName, in string messageUri);
void saveAttachment(in string url, in string displayName, in string messageUri);
void saveAllAttachments(in unsigned long count, [array, size_is(count)] in string urlArray, [array, size_is(count)] in string displayNameArray, [array, size_is(count)] in string messageUriArray);
void find();

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

@ -153,11 +153,11 @@ var messageHeaderSink = {
},
handleAttachment: function(url, displayName, uri, notDownloaded)
handleAttachment: function(contentType, url, displayName, uri, notDownloaded)
{
// be sure to escape the display name before we insert it into the
// method
var commandString = "OpenAttachURL('" + url + "', '" + escape(displayName) + "', '" + uri + "')";
var commandString = "OpenAttachURL('" + contentType + "', '" + url + "', '" + escape(displayName) + "', '" + uri + "')";
if (notDownloaded)
{
displayName += " " + Bundle.GetStringFromName("notDownloaded");
@ -209,14 +209,14 @@ function AddSenderToAddressBook()
}
}
function OpenAttachURL(url, displayName, messageUri)
function OpenAttachURL(contentType, url, displayName, messageUri)
{
var args = {dspname: displayName, opval: 0};
window.openDialog("chrome://messenger/content/openSaveAttachment.xul",
"openSaveAttachment", "chrome,modal", args);
if (args.opval == 1)
messenger.openAttachment(url, displayName, messageUri);
messenger.openAttachment(contentType, url, displayName, messageUri);
else if (args.opval == 2)
messenger.saveAttachment(url, displayName, messageUri);
}

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

@ -575,96 +575,16 @@ done:
}
NS_IMETHODIMP
nsMessenger::OpenAttachment(const char * url, const char * displayName,
const char * messageUri)
nsMessenger::OpenAttachment(const char * contentType, const char * url, const
char * displayName, const char * messageUri)
{
nsIMsgMessageService * messageService = nsnull;
nsAutoString from, to;
nsCOMPtr<nsISupports> channelSupport;
nsCOMPtr<nsIStreamListener> convertedListener;
nsAutoString urlString;
char *urlCString = nsnull;
char *unescapedUrl = nsnull;
nsCOMPtr<nsIURI> aURL;
PRBool canFetchMimeParts = PR_FALSE;
nsCAutoString fullMessageUri = messageUri;
nsresult rv = NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIChannel> channel;
NS_WITH_SERVICE(nsIStreamConverterService,
streamConverterService,
kIStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) goto done;
if (!url) return NS_ERROR_NULL_POINTER;
unescapedUrl = PL_strdup(url);
if (!unescapedUrl) return NS_ERROR_OUT_OF_MEMORY;
nsUnescape(unescapedUrl);
urlString.AssignWithConversion(unescapedUrl);
urlString.ReplaceSubstring(NS_ConvertASCIItoUCS2("/;section"), NS_ConvertASCIItoUCS2("?section"));
urlCString = urlString.ToNewCString();
rv = CreateStartupUrl(urlCString, getter_AddRefs(aURL));
nsCRT::free(urlCString);
if (NS_FAILED(rv)) goto done;
rv = GetMessageServiceFromURI(messageUri, &messageService);
if (NS_FAILED(rv)) goto done;
messageService->GetCanFetchMimeParts(&canFetchMimeParts);
if (canFetchMimeParts)
{
PRInt32 sectionPos = urlString.Find("?section");
nsString mimePart;
urlString.Right(mimePart, urlString.Length() - sectionPos);
fullMessageUri.AppendWithConversion(mimePart);
messageUri = fullMessageUri.GetBuffer();
}
{
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURL,
nsnull, // inputStream
nsnull, // contentType
-1);
if (NS_FAILED(rv)) goto done;
from.AssignWithConversion(MESSAGE_RFC822);
to.AssignWithConversion("text/xul");
channelSupport = do_QueryInterface(channel);
// *** this isn't working yet needs to come back for it
// *** We need to use the mime stream coverter to pull out the part stream
// *** and then pass it to the display consumer
rv = streamConverterService->AsyncConvertData(
from.GetUnicode(), to.GetUnicode(), nsnull,
channelSupport, getter_AddRefs(convertedListener));
if (NS_FAILED(rv)) goto done;
if (canFetchMimeParts)
rv = messageService->OpenAttachment(aURL, messageUri, convertedListener,
mMsgWindow, nsnull,nsnull);
else
rv = messageService->DisplayMessage(messageUri,
convertedListener,mMsgWindow,
nsnull, nsnull);
}
done:
if (messageService)
ReleaseMessageServiceFromURI(unescapedUrl, messageService);
PR_FREEIF(unescapedUrl);
return rv;
nsCString partMsgUrl = messageUri;
partMsgUrl += "?";
const char *part = PL_strstr(url, "part=");
partMsgUrl += part;
partMsgUrl += "&type=";
partMsgUrl += contentType;
return OpenURL(partMsgUrl.GetBuffer());
}
NS_IMETHODIMP

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

@ -199,7 +199,12 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequest(nsIChannel * aChannel, nsISupports *
// so pass in ourself as the channel and not the underlying socket or file channel the protocol
// happens to be using
if (m_channelListener)
{
if (!m_channelContext)
m_channelContext = do_QueryInterface(ctxt);
rv = m_channelListener->OnStartRequest(this, m_channelContext);
}
return rv;
}

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

@ -125,7 +125,6 @@ NS_IMETHODIMP nsMailboxProtocol::OnStartRequest(nsIChannel * aChannel, nsISuppor
// extract the appropriate event sinks from the url and initialize them in our protocol data
// the URL should be queried for a nsINewsURL. If it doesn't support a news URL interface then
// we have an error.
if (m_nextState == MAILBOX_READ_FOLDER && m_mailboxParser)
{
// we need to inform our mailbox parser that it's time to start...

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

@ -37,7 +37,12 @@
#include "nsMsgBaseCID.h"
#include "nsIDocShell.h"
#include "nsIPop3Service.h"
#include "nsMsgUtils.h"
#include "nsIStreamConverterService.h"
#include "nsNetUtil.h"
static NS_DEFINE_CID(kIStreamConverterServiceCID,
NS_STREAMCONVERTERSERVICE_CID);
static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID);
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
@ -153,7 +158,9 @@ nsresult nsMailboxService::DisplayMessage(const char* aMessageURI,
nsIUrlListener * aUrlListener,
nsIURI ** aURL)
{
return FetchMessage(aMessageURI, aDisplayConsumer, aMsgWindow,aUrlListener, nsIMailboxUrl::ActionDisplayMessage, aURL);
return FetchMessage(aMessageURI, aDisplayConsumer,
aMsgWindow,aUrlListener,
nsIMailboxUrl::ActionDisplayMessage, aURL);
}
/* void OpenAttachment (in nsIURI aURI, in nsISupports aDisplayConsumer, in nsIMsgWindow aMsgWindow, in nsIUrlListener aUrlListener, out nsIURI aURL); */
@ -265,6 +272,7 @@ nsresult nsMailboxService::PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsI
nsCAutoString folderURI;
nsFileSpec folderPath;
nsMsgKey msgKey;
const char *part = PL_strstr(aSrcMsgMailboxURI, "part=");
rv = nsParseLocalMessageURI(aSrcMsgMailboxURI, folderURI, &msgKey);
rv = nsLocalURI2Path(kMailboxMessageRootURI, folderURI, folderPath);
@ -274,11 +282,14 @@ nsresult nsMailboxService::PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsI
// set up the url spec and initialize the url with it.
nsFilePath filePath(folderPath); // convert to file url representation...
if (mPrintingOperation)
urlSpec = PR_smprintf("mailbox://%s?number=%d&header=print", (const char *) filePath, msgKey);
else
urlSpec = PR_smprintf("mailbox://%s?number=%d", (const char *) filePath, msgKey);
if (mPrintingOperation)
urlSpec = PR_smprintf("mailbox://%s?number=%d&header=print", (const char *) filePath, msgKey);
else if (part)
urlSpec = PR_smprintf("mailbox://%s?number=%d&%s", (const char *)
filePath, msgKey, part);
else
urlSpec = PR_smprintf("mailbox://%s?number=%d", (const char *) filePath, msgKey);
nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(*aMailboxUrl);
url->SetSpec(urlSpec);
PR_FREEIF(urlSpec);

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

@ -254,7 +254,7 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name, const char *contentT
nsXPIDLString::Copy(attachmentName.GetUnicode());
}
headerSink->HandleAttachment(url /* was escapedUrl */, unicodeHeaderValue, uriString, aNotDownloaded);
headerSink->HandleAttachment(contentType, url /* was escapedUrl */, unicodeHeaderValue, uriString, aNotDownloaded);
nsCRT::free(escapedUrl);
mSkipAttachment = PR_TRUE;

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

@ -51,7 +51,7 @@ interface nsIMsgHeaderSink : nsISupports{
// make a sandwhich around header processing.....
void onStartHeaders();
void onEndHeaders();
void handleAttachment(in string url, in wstring displayName, in string
void handleAttachment(in string contentType, in string url, in wstring displayName, in string
uri, in boolean aNotDownloaded);
void onEndAllAttachments();
};