From d03c0354896914511b5cd6e653a45ebf2ee376c7 Mon Sep 17 00:00:00 2001 From: "blakeross%telocity.com" Date: Sun, 17 Mar 2002 21:18:26 +0000 Subject: [PATCH] 102477 - Turn on download manager, take 2. r=law sr=ben a=dbaron --- uriloader/base/MANIFEST_IDL | 1 + uriloader/base/Makefile.in | 1 + uriloader/base/makefile.win | 1 + .../exthandler/nsExternalHelperAppService.cpp | 63 ++++++++----------- uriloader/macbuild/uriLoaderIDL.xml | 60 ++++++++++++++++++ xpfe/components/build/Makefile.in | 4 ++ .../macbuild/DownloadManagerIDL.xml | 8 +-- 7 files changed, 98 insertions(+), 40 deletions(-) diff --git a/uriloader/base/MANIFEST_IDL b/uriloader/base/MANIFEST_IDL index 6cf29fcda06f..dda9d5c061b7 100644 --- a/uriloader/base/MANIFEST_IDL +++ b/uriloader/base/MANIFEST_IDL @@ -9,3 +9,4 @@ nsIURILoader.idl nsIDocumentLoader.idl nsIWebProgress.idl nsIWebProgressListener.idl +nsIDownload.idl diff --git a/uriloader/base/Makefile.in b/uriloader/base/Makefile.in index 7aeef0c06f92..d51022f8c34a 100644 --- a/uriloader/base/Makefile.in +++ b/uriloader/base/Makefile.in @@ -54,6 +54,7 @@ XPIDLSRCS = \ nsIURIContentListener.idl \ nsIURILoader.idl \ nsCURILoader.idl \ + nsIDownload.idl \ nsIDocumentLoader.idl \ nsIWebProgress.idl \ nsIWebProgressListener.idl \ diff --git a/uriloader/base/makefile.win b/uriloader/base/makefile.win index 94ca302bf3e5..38138bf7d7e0 100644 --- a/uriloader/base/makefile.win +++ b/uriloader/base/makefile.win @@ -51,6 +51,7 @@ XPIDLSRCS= \ .\nsIDocumentLoader.idl \ .\nsIWebProgress.idl \ .\nsIWebProgressListener.idl \ + .\nsIDownload.idl \ $(NULL) LIBRARY_NAME=uriloaderbase_s diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 0d9cf6ef2378..c91253ae40f5 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -39,6 +39,7 @@ #include "nsCURILoader.h" #include "nsIWebProgress.h" #include "nsIWebProgressListener.h" +#include "nsIDownload.h" #include "nsReadableUtils.h" // used to manage our in memory data source of helper applications @@ -1384,52 +1385,42 @@ nsresult nsExternalAppHandler::ShowProgressDialog() { // we are back from the helper app dialog (where the user chooses to save or open), but we aren't // done processing the load. in this case, throw up a progress dialog so the user can see what's going on... - nsresult rv = NS_OK; + nsresult rv; + nsCOMPtr local = do_QueryInterface(mFinalFileDestination); - nsCOMPtr progressDlg = do_CreateInstance( "@mozilla.org/progressdialog;1", &rv ); - if (progressDlg) + nsCOMPtr dl = do_CreateInstance("@mozilla.org/download;1", &rv); + if (NS_FAILED(rv)) return rv; + + nsXPIDLString openWith(NS_LITERAL_STRING("")); + nsMIMEInfoHandleAction action = nsIMIMEInfo::saveToDisk; + mMimeInfo->GetPreferredAction(&action); + if (action != nsIMIMEInfo::saveToDisk) { - // Wire up this progress dialog. - progressDlg->SetSource( mSourceUrl ); - progressDlg->SetStartTime( mTimeDownloadStarted ); - progressDlg->SetObserver(this); - nsCOMPtr local = do_QueryInterface(mFinalFileDestination); - progressDlg->SetTarget(local); - - nsMIMEInfoHandleAction action = nsIMIMEInfo::saveToDisk; - mMimeInfo->GetPreferredAction(&action); - if (action != nsIMIMEInfo::saveToDisk) + // Opening with an application; use either description or application file name. + mMimeInfo->GetApplicationDescription(getter_Copies(openWith)); + if (openWith.IsEmpty()) { - // Opening with an application; use either description or application file name. - nsXPIDLString openWith; - mMimeInfo->GetApplicationDescription(getter_Copies(openWith)); - if (openWith.IsEmpty()) + nsCOMPtr appl; + mMimeInfo->GetPreferredApplicationHandler(getter_AddRefs(appl)); + if (appl) { - nsCOMPtr appl; - mMimeInfo->GetPreferredApplicationHandler(getter_AddRefs(appl)); - if (appl) + nsCOMPtr file = do_QueryInterface(appl); + if (file) { - nsCOMPtr file = do_QueryInterface(appl); - if (file) - { - file->GetUnicodeLeafName(getter_Copies(openWith)); - } + file->GetUnicodeLeafName(getter_Copies(openWith)); } } - // Tell progress dialog what we're opening with. - progressDlg->SetOpeningWith(openWith); - } - - // Open the dialog. - rv = progressDlg->Open(nsnull, nsnull); - - if(NS_SUCCEEDED(rv)) - { - // Send notifications to the dialog. - this->SetWebProgressListener(progressDlg); } } + rv = dl->Init(mSourceUrl, local, nsnull, openWith, mTimeDownloadStarted, nsnull); + if (NS_FAILED(rv)) return rv; + + dl->SetObserver(this); + nsCOMPtr listener = do_QueryInterface(dl); + if (listener) + SetWebProgressListener(listener); + return rv; } diff --git a/uriloader/macbuild/uriLoaderIDL.xml b/uriloader/macbuild/uriLoaderIDL.xml index d4bf1e28c48c..2c28f27c7100 100644 --- a/uriloader/macbuild/uriLoaderIDL.xml +++ b/uriloader/macbuild/uriLoaderIDL.xml @@ -790,6 +790,20 @@ Text + + Name + nsIDownload.idl + MacOS + Text + + + + Name + nsIDownload.idl + MacOS + Text + + @@ -842,6 +856,16 @@ nsIExternalProtocolService.idl MacOS + + Name + nsIDownload.idl + MacOS + + + Name + nsIDownload.idl + MacOS + @@ -1581,6 +1605,20 @@ Text + + Name + nsIDownload.idl + MacOS + Text + + + + Name + nsIDownload.idl + MacOS + Text + + @@ -1633,6 +1671,16 @@ nsIExternalProtocolService.idl MacOS + + Name + nsIDownload.idl + MacOS + + + Name + nsIDownload.idl + MacOS + @@ -1703,6 +1751,18 @@ nsIExternalProtocolService.idl MacOS + + headers + Name + nsIDownload.idl + MacOS + + + headers + Name + nsIDownload.idl + MacOS + diff --git a/xpfe/components/build/Makefile.in b/xpfe/components/build/Makefile.in index d16b500cc069..9a845cfa48a7 100644 --- a/xpfe/components/build/Makefile.in +++ b/xpfe/components/build/Makefile.in @@ -45,6 +45,10 @@ REQUIRES = xpcom \ dom \ pref \ docshell \ + downloadmanager\ + webbrowserpersist \ + progressDlg \ + uriloader \ webshell \ $(NULL) diff --git a/xpfe/components/download-manager/macbuild/DownloadManagerIDL.xml b/xpfe/components/download-manager/macbuild/DownloadManagerIDL.xml index 2e40fdb1732d..4fc3bc5944ea 100644 --- a/xpfe/components/download-manager/macbuild/DownloadManagerIDL.xml +++ b/xpfe/components/download-manager/macbuild/DownloadManagerIDL.xml @@ -739,7 +739,7 @@ - download-manager.xpt + downloadmanager.xpt @@ -798,7 +798,7 @@ Linkerxpt Linker PreLinker PostLinker - Targetnamedownload-manager.xpt + Targetnamedownloadmanager.xpt OutputDirectory Path: PathFormatMacOS @@ -1390,7 +1390,7 @@ MWProject_X86_minsize4 MWProject_X86_importlib xpidl Settings - 00010003010114646F776E6C6F61642D6D616E616765722E7870740000000000 + 00010003010113646F776E6C6F61646D616E616765722E787074740000000000 0000000000000000 @@ -1427,7 +1427,7 @@ headers - download-manager.xpt + downloadmanager.xpt