From f4be0bbdc62f0ea8deaa3009872d5e5df57fd10f Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Fri, 7 Jul 2000 21:57:39 +0000 Subject: [PATCH] Bug #43661 --> open attachment needs to pass in the file name r=bienvenu --- mailnews/base/public/nsIMsgMessageService.idl | 2 ++ mailnews/imap/src/nsImapService.cpp | 7 ++++- mailnews/local/src/nsMailboxService.cpp | 30 +++++++++++-------- mailnews/local/src/nsMailboxService.h | 1 + mailnews/news/src/nsNntpService.cpp | 4 ++- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/mailnews/base/public/nsIMsgMessageService.idl b/mailnews/base/public/nsIMsgMessageService.idl index 7dad23f598f..2ee51d63e90 100644 --- a/mailnews/base/public/nsIMsgMessageService.idl +++ b/mailnews/base/public/nsIMsgMessageService.idl @@ -84,12 +84,14 @@ interface nsIMsgMessageService : nsISupports { ///////////////////////////////////////////////////////////////////// // OpenAttachment: When you want an attachment downloaded // aContentType --> we need to know the content type of the attachment + // aFileName --> the name of the attachment. // aUrl --> string representation of the original url associated with the msg. // aMessageUri --> RDF resource that describes the message // aMsgWindow --> message window /////////////////////////////////////////////////////////////////// void openAttachment(in string aContentType, + in string aFileName, in string aUrl, in string aMessageUri, in nsISupports aDisplayConsumer, diff --git a/mailnews/imap/src/nsImapService.cpp b/mailnews/imap/src/nsImapService.cpp index 3703e0e9a09..92456222032 100644 --- a/mailnews/imap/src/nsImapService.cpp +++ b/mailnews/imap/src/nsImapService.cpp @@ -292,7 +292,9 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL return rv; } -NS_IMETHODIMP nsImapService::OpenAttachment(const char *aContentType, const char *aUrl, +NS_IMETHODIMP nsImapService::OpenAttachment(const char *aContentType, + const char *aFileName, + const char *aUrl, const char *aMessageUri, nsISupports *aDisplayConsumer, nsIMsgWindow *aMsgWindow, @@ -350,6 +352,9 @@ NS_IMETHODIMP nsImapService::OpenAttachment(const char *aContentType, const char return rv; if (uriMimePart) { + nsCOMPtr mailUrl (do_QueryInterface(imapUrl)); + if (mailUrl) + mailUrl->SetFileName(aFileName); rv = FetchMimePart(imapUrl, nsIImapUrl::nsImapOpenMimePart, folder, imapMessageSink, nsnull, aDisplayConsumer, msgKey, uriMimePart); } diff --git a/mailnews/local/src/nsMailboxService.cpp b/mailnews/local/src/nsMailboxService.cpp index 73bb03d9cc2..d092b55d5b2 100644 --- a/mailnews/local/src/nsMailboxService.cpp +++ b/mailnews/local/src/nsMailboxService.cpp @@ -105,7 +105,7 @@ nsresult nsMailboxService::CopyMessage(const char * aSrcMailboxURI, nsMailboxAction mailboxAction = nsIMailboxUrl::ActionMoveMessage; if (!moveMessage) mailboxAction = nsIMailboxUrl::ActionCopyMessage; - return FetchMessage(aSrcMailboxURI, aMailboxCopyHandler, nsnull, aUrlListener, mailboxAction, nsnull, aURL); + return FetchMessage(aSrcMailboxURI, aMailboxCopyHandler, nsnull, aUrlListener, nsnull, mailboxAction, nsnull, aURL); } nsresult nsMailboxService::CopyMessages(nsMsgKeyArray *msgKeys, @@ -123,6 +123,7 @@ nsresult nsMailboxService::FetchMessage(const char* aMessageURI, nsISupports * aDisplayConsumer, nsIMsgWindow * aMsgWindow, nsIUrlListener * aUrlListener, + const char * aFileName, /* only used by open attachment... */ nsMailboxAction mailboxAction, const PRUnichar * aCharsetOverride, nsIURI ** aURL) @@ -144,6 +145,9 @@ nsresult nsMailboxService::FetchMessage(const char* aMessageURI, nsCOMPtr i18nurl (do_QueryInterface(msgUrl)); i18nurl->SetCharsetOverRide(aCharsetOverride); + if (aFileName) + msgUrl->SetFileName(aFileName); + // instead of running the mailbox url like we used to, let's try to run the url in the docshell... nsCOMPtr docShell(do_QueryInterface(aDisplayConsumer, &rv)); // if we were given a docShell, run the url in the docshell..otherwise just run it normally. @@ -179,15 +183,17 @@ nsresult nsMailboxService::DisplayMessage(const char* aMessageURI, nsIURI ** aURL) { return FetchMessage(aMessageURI, aDisplayConsumer, - aMsgWindow,aUrlListener, + aMsgWindow,aUrlListener, nsnull, nsIMailboxUrl::ActionDisplayMessage, aCharsetOveride, aURL); } -NS_IMETHODIMP nsMailboxService::OpenAttachment(const char *aContentType, const char *aUrl, - const char *aMessageUri, - nsISupports *aDisplayConsumer, - nsIMsgWindow *aMsgWindow, - nsIUrlListener *aUrlListener) +NS_IMETHODIMP nsMailboxService::OpenAttachment(const char *aContentType, + const char *aFileName, + const char *aUrl, + const char *aMessageUri, + nsISupports *aDisplayConsumer, + nsIMsgWindow *aMsgWindow, + nsIUrlListener *aUrlListener) { nsCAutoString partMsgUrl = aMessageUri; @@ -198,7 +204,7 @@ NS_IMETHODIMP nsMailboxService::OpenAttachment(const char *aContentType, const c partMsgUrl += "&type="; partMsgUrl += aContentType; return FetchMessage(partMsgUrl, aDisplayConsumer, - aMsgWindow,aUrlListener, + aMsgWindow,aUrlListener, aFileName, nsIMailboxUrl::ActionOpenAttachment, nsnull, nsnull); } @@ -223,9 +229,9 @@ nsMailboxService::SaveMessageToDisk(const char *aMessageURI, nsCOMPtr msgUrl = do_QueryInterface(mailboxurl); if (msgUrl) { - msgUrl->SetMessageFile(aFile); - msgUrl->SetAddDummyEnvelope(aAddDummyEnvelope); - msgUrl->SetCanonicalLineEnding(canonicalLineEnding); + msgUrl->SetMessageFile(aFile); + msgUrl->SetAddDummyEnvelope(aAddDummyEnvelope); + msgUrl->SetCanonicalLineEnding(canonicalLineEnding); } nsCOMPtr url = do_QueryInterface(mailboxurl); @@ -414,7 +420,7 @@ nsresult nsMailboxService::DisplayMessageForPrinting(const char* aMessageURI, nsIURI ** aURL) { mPrintingOperation = PR_TRUE; - nsresult rv = FetchMessage(aMessageURI, aDisplayConsumer, aMsgWindow,aUrlListener, + nsresult rv = FetchMessage(aMessageURI, aDisplayConsumer, aMsgWindow,aUrlListener, nsnull, nsIMailboxUrl::ActionDisplayMessage, nsnull, aURL); mPrintingOperation = PR_FALSE; return rv; diff --git a/mailnews/local/src/nsMailboxService.h b/mailnews/local/src/nsMailboxService.h index c9ea3d30a5a..e3120385832 100644 --- a/mailnews/local/src/nsMailboxService.h +++ b/mailnews/local/src/nsMailboxService.h @@ -62,6 +62,7 @@ protected: nsISupports * aDisplayConsumer, nsIMsgWindow * aMsgWindow, nsIUrlListener * aUrlListener, + const char * aFileName, /* only used by open attachment */ nsMailboxAction mailboxAction, const PRUnichar * aCharsetOverride, nsIURI ** aURL); diff --git a/mailnews/news/src/nsNntpService.cpp b/mailnews/news/src/nsNntpService.cpp index 2bfcb0318f1..567cee98059 100644 --- a/mailnews/news/src/nsNntpService.cpp +++ b/mailnews/news/src/nsNntpService.cpp @@ -214,7 +214,9 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon } -NS_IMETHODIMP nsNntpService::OpenAttachment(const char *aContentType, const char *aUrl, +NS_IMETHODIMP nsNntpService::OpenAttachment(const char *aContentType, + const char *aFileName, + const char *aUrl, const char *aMessageUri, nsISupports *aDisplayConsumer, nsIMsgWindow *aMsgWindow,