From 009b529d4dd27ab38a87afcc759ec46b83384c2d Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Mon, 1 Oct 2001 18:45:16 +0000 Subject: [PATCH] partial fix for #100835. fwding (inline) imap messages with large attachments and editing imap templates & drafts with large attachments is slow since we have to download the attachment. this makes it so the user sees download progress in the msg window. r=ducarroz, sr=mscott git-svn-id: svn://10.0.0.236/trunk@104327 18797224-902f-48f8-a5cc-f745e15eee43 --- .../base/resources/content/mailCommands.js | 8 ++--- .../base/resources/content/mailOverlay.xul | 18 +++++----- .../compose/public/nsIMsgComposeService.idl | 7 ++-- .../mailnews/compose/public/nsIMsgDraft.idl | 5 +-- .../resources/content/MsgComposeCommands.js | 7 +--- .../compose/src/nsMsgComposeService.cpp | 8 ++--- mozilla/mailnews/compose/src/nsMsgCreate.cpp | 35 +++++++------------ mozilla/mailnews/compose/src/nsMsgCreate.h | 2 +- .../components/remote/src/remoteControl.js | 1 + 9 files changed, 40 insertions(+), 51 deletions(-) diff --git a/mozilla/mailnews/base/resources/content/mailCommands.js b/mozilla/mailnews/base/resources/content/mailCommands.js index 0ab0aa41720..0a21b48b5b0 100644 --- a/mozilla/mailnews/base/resources/content/mailCommands.js +++ b/mozilla/mailnews/base/resources/content/mailCommands.js @@ -183,13 +183,13 @@ function ComposeMessage(type, format, folder, messageArray) if (type == msgComposeType.New) //new message { //dump("OpenComposeWindow with " + identity + "\n"); - msgComposeService.OpenComposeWindow(null, null, type, format, identity); + msgComposeService.OpenComposeWindow(null, null, type, format, identity, msgWindow); return; } else if (type == msgComposeType.NewsPost) { //dump("OpenComposeWindow with " + identity + " and " + newsgroup + "\n"); - msgComposeService.OpenComposeWindow(null, newsgroup, type, format, identity); + msgComposeService.OpenComposeWindow(null, newsgroup, type, format, identity, msgWindow); return; } @@ -211,7 +211,7 @@ function ComposeMessage(type, format, folder, messageArray) type == msgComposeType.ReplyToSenderAndGroup || type == msgComposeType.Template || type == msgComposeType.Draft) { - msgComposeService.OpenComposeWindow(null, messageUri, type, format, identity); + msgComposeService.OpenComposeWindow(null, messageUri, type, format, identity, msgWindow); } else { @@ -222,7 +222,7 @@ function ComposeMessage(type, format, folder, messageArray) } if (type == msgComposeType.ForwardAsAttachment) { - msgComposeService.OpenComposeWindow(null, uri, type, format, identity); + msgComposeService.OpenComposeWindow(null, uri, type, format, identity, msgWindow); } } else diff --git a/mozilla/mailnews/base/resources/content/mailOverlay.xul b/mozilla/mailnews/base/resources/content/mailOverlay.xul index 5eacc933bd9..48f7999e36f 100644 --- a/mozilla/mailnews/base/resources/content/mailOverlay.xul +++ b/mozilla/mailnews/base/resources/content/mailOverlay.xul @@ -16,24 +16,24 @@ function goOpenNewMessage() { - try - { - var cwindowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService(); - var iwindowManager = Components.interfaces.nsIWindowMediator; - var windowManager = cwindowManager.QueryInterface(iwindowManager); - var mailWindow = windowManager.getMostRecentWindow('mail:3pane'); - mailWindow.MsgNewMessage(); + try + { + var cwindowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService(); + var iwindowManager = Components.interfaces.nsIWindowMediator; + var windowManager = cwindowManager.QueryInterface(iwindowManager); + var mailWindow = windowManager.getMostRecentWindow('mail:3pane'); + mailWindow.MsgNewMessage(); return; } catch(ex) { - ; } + var msgComposeService = Components.classes["@mozilla.org/messengercompose;1"].getService(); msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService); msgComposeService.OpenComposeWindow(null, null, Components.interfaces.nsIMsgCompType.New, Components.interfaces.nsIMsgCompFormat.Default, - null); + null, null); } ]]> diff --git a/mozilla/mailnews/compose/public/nsIMsgComposeService.idl b/mozilla/mailnews/compose/public/nsIMsgComposeService.idl index aeecd990467..07b724e390b 100644 --- a/mozilla/mailnews/compose/public/nsIMsgComposeService.idl +++ b/mozilla/mailnews/compose/public/nsIMsgComposeService.idl @@ -43,14 +43,15 @@ interface nsIURI; interface nsIDOMWindowInternal; - +interface nsIMsgWindow; [scriptable, uuid(B004F4AE-1AC2-11d3-A715-0060B0EB39B5)] interface nsIMsgComposeService : nsISupports { - /* ... */ + /* we need a msg window because when we forward inline we may need progress */ void OpenComposeWindow(in string msgComposeWindowURL, in string originalMsgURI, in MSG_ComposeType type, in MSG_ComposeFormat format, - in nsIMsgIdentity identity); + in nsIMsgIdentity identity, + in nsIMsgWindow aMsgWindow); /* use this method to invoke a compose window given a mailto url. aMsgComposeWindowURL --> can be null in most cases. If you have your own chrome diff --git a/mozilla/mailnews/compose/public/nsIMsgDraft.idl b/mozilla/mailnews/compose/public/nsIMsgDraft.idl index 63a9346994d..b22feaebe0e 100644 --- a/mozilla/mailnews/compose/public/nsIMsgDraft.idl +++ b/mozilla/mailnews/compose/public/nsIMsgDraft.idl @@ -39,6 +39,7 @@ #include "nsIMsgIdentity.idl" #include "nsIMsgHdr.idl" +interface nsIMsgWindow; [scriptable, uuid(A6237474-453B-11d3-8F0F-00A024A7D144)] @@ -49,9 +50,9 @@ interface nsIMsgDraft : nsISupports * a URI */ void OpenDraftMsg(in string msgURI, out nsIMsgDBHdr aMsgToReplace, - in nsIMsgIdentity identity, in PRBool addInlineHeaders); + in nsIMsgIdentity identity, in PRBool addInlineHeaders, in nsIMsgWindow aMsgWindow); void OpenEditorTemplate(in string msgURI, out nsIMsgDBHdr aMsgReplace, - in nsIMsgIdentity identity); + in nsIMsgIdentity identity, in nsIMsgWindow aMsgWindow); }; diff --git a/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js b/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js index fb699bde755..6eed8c252a5 100644 --- a/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js +++ b/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js @@ -1469,12 +1469,7 @@ function SendMessage() function SendMessageWithCheck() { - var warn; - try { - warn = prefs.GetBoolPref("mail.warn_on_send_accel_key"); - } catch (ex) { - warn = true; - } + var warn = prefs.GetBoolPref("mail.warn_on_send_accel_key"); if (warn) { var buttonPressed = {value:1}; diff --git a/mozilla/mailnews/compose/src/nsMsgComposeService.cpp b/mozilla/mailnews/compose/src/nsMsgComposeService.cpp index f4eab911007..b5af7f4faee 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeService.cpp +++ b/mozilla/mailnews/compose/src/nsMsgComposeService.cpp @@ -157,7 +157,7 @@ static nsresult openWindow( const char *chrome, nsIMsgComposeParams *params ) NS_IMETHODIMP nsMsgComposeService::OpenComposeWindow(const char *msgComposeWindowURL, const char *originalMsgURI, - MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgIdentity * identity) + MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgIdentity * identity, nsIMsgWindow *aMsgWindow) { nsresult rv; @@ -175,13 +175,13 @@ nsMsgComposeService::OpenComposeWindow(const char *msgComposeWindowURL, const ch switch(type) { case nsIMsgCompType::ForwardInline: - rv = pMsgDraft->OpenDraftMsg(uriToOpen.get(), nsnull, identity, PR_TRUE); + rv = pMsgDraft->OpenDraftMsg(uriToOpen.get(), nsnull, identity, PR_TRUE, aMsgWindow); break; case nsIMsgCompType::Draft: - rv = pMsgDraft->OpenDraftMsg(uriToOpen.get(), nsnull, identity, PR_FALSE); + rv = pMsgDraft->OpenDraftMsg(uriToOpen.get(), nsnull, identity, PR_FALSE, aMsgWindow); break; case nsIMsgCompType::Template: - rv = pMsgDraft->OpenEditorTemplate(uriToOpen.get(), nsnull, identity); + rv = pMsgDraft->OpenEditorTemplate(uriToOpen.get(), nsnull, identity, aMsgWindow); break; } } diff --git a/mozilla/mailnews/compose/src/nsMsgCreate.cpp b/mozilla/mailnews/compose/src/nsMsgCreate.cpp index 21b56ae187e..bb4a297af40 100644 --- a/mozilla/mailnews/compose/src/nsMsgCreate.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCreate.cpp @@ -64,7 +64,6 @@ #include "nsMsgCopy.h" #include "nsNetUtil.h" #include "nsMsgMimeCID.h" -#include "nsIMsgMailSession.h" #include "nsIMsgMailNewsUrl.h" #include "nsMsgBaseCID.h" @@ -104,7 +103,7 @@ static NS_DEFINE_CID(kStreamConverterCID, NS_MAILNEWS_MIME_STREAM_CONVERTER_C nsresult nsMsgDraft::ProcessDraftOrTemplateOperation(const char *msgURI, nsMimeOutputType aOutType, - nsIMsgIdentity * identity, nsIMsgDBHdr **aMsgToReplace) + nsIMsgIdentity * identity, nsIMsgDBHdr **aMsgToReplace, nsIMsgWindow *aMsgWindow) { nsresult rv; @@ -166,25 +165,17 @@ nsMsgDraft::ProcessDraftOrTemplateOperation(const char *msgURI, nsMimeOutputType nsCOMPtr aURL; rv = CreateStartupUrl(mURI, getter_AddRefs(aURL)); - // HACK: if we are forwarding a message and that message used a charset over ride - // (as speciifed in the top most window (assuming the reply originated from that window) + // 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 - nsCOMPtr mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID); nsXPIDLString mailCharset; - if (mailSession) + if (aMsgWindow) { - nsCOMPtr msgWindow; - mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow)); - if (msgWindow) + aMsgWindow->GetMailCharacterSet(getter_Copies(mailCharset)); + if (mailCharset) { - - msgWindow->GetMailCharacterSet(getter_Copies(mailCharset)); - if (mailCharset) - { - nsCOMPtr i18nUrl(do_QueryInterface(aURL)); - if (i18nUrl) - i18nUrl->SetCharsetOverRide(mailCharset); - } + nsCOMPtr i18nUrl(do_QueryInterface(aURL)); + if (i18nUrl) + i18nUrl->SetCharsetOverRide(mailCharset); } } @@ -207,7 +198,7 @@ nsMsgDraft::ProcessDraftOrTemplateOperation(const char *msgURI, nsMimeOutputType GetMsgDBHdrFromURI(msgURI, aMsgToReplace); // Now, just plug the two together and get the hell out of the way! - rv = mMessageService->DisplayMessage(mURI, convertedListener, nsnull, nsnull, mailCharset, nsnull); + rv = mMessageService->DisplayMessage(mURI, convertedListener, aMsgWindow, nsnull, mailCharset, nsnull); ReleaseMessageServiceFromURI(mURI, mMessageService); mMessageService = nsnull; @@ -221,7 +212,7 @@ nsMsgDraft::ProcessDraftOrTemplateOperation(const char *msgURI, nsMimeOutputType nsresult nsMsgDraft::OpenDraftMsg(const char *msgURI, nsIMsgDBHdr **aMsgToReplace, - nsIMsgIdentity * identity, PRBool addInlineHeaders) + nsIMsgIdentity * identity, PRBool addInlineHeaders, nsIMsgWindow *aMsgWindow) { // We should really never get here, but if we do, just return // with an error @@ -230,14 +221,14 @@ nsMsgDraft::OpenDraftMsg(const char *msgURI, nsIMsgDBHdr **aMsgToReplace, mAddInlineHeaders = addInlineHeaders; return ProcessDraftOrTemplateOperation(msgURI, nsMimeOutput::nsMimeMessageDraftOrTemplate, - identity, aMsgToReplace); + identity, aMsgToReplace, aMsgWindow); } nsresult nsMsgDraft::OpenEditorTemplate(const char *msgURI, nsIMsgDBHdr **aMsgToReplace, - nsIMsgIdentity * identity) + nsIMsgIdentity * identity, nsIMsgWindow *aMsgWindow) { return ProcessDraftOrTemplateOperation(msgURI, nsMimeOutput::nsMimeMessageEditorTemplate, - identity, aMsgToReplace); + identity, aMsgToReplace, aMsgWindow); } diff --git a/mozilla/mailnews/compose/src/nsMsgCreate.h b/mozilla/mailnews/compose/src/nsMsgCreate.h index ae07fa02f1b..58592c14ec4 100644 --- a/mozilla/mailnews/compose/src/nsMsgCreate.h +++ b/mozilla/mailnews/compose/src/nsMsgCreate.h @@ -55,7 +55,7 @@ public: NS_DECL_NSIMSGDRAFT nsresult ProcessDraftOrTemplateOperation(const char *msgURI, nsMimeOutputType aOutType, - nsIMsgIdentity * identity, nsIMsgDBHdr **aMsgToReplace); + nsIMsgIdentity * identity, nsIMsgDBHdr **aMsgToReplace, nsIMsgWindow *aMsgWindow); // // Implementation data... diff --git a/mozilla/xpfe/components/remote/src/remoteControl.js b/mozilla/xpfe/components/remote/src/remoteControl.js index 3d3ea5d0535..194c8f222c4 100644 --- a/mozilla/xpfe/components/remote/src/remoteControl.js +++ b/mozilla/xpfe/components/remote/src/remoteControl.js @@ -84,6 +84,7 @@ var browserRemoteControl = { null, Components.interfaces.nsIMsgCompType.New, Components.interfaces.nsIMsgCompFormat.Default, + null, null); } return(true);