From dd25bcee0f7e3e03fc37b226027b48d01da3ba14 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Wed, 6 Jul 2005 23:12:22 +0000 Subject: [PATCH] Bug 298842 make the temp file part of nsITransfer r=mconnor sr=darin a=shaver git-svn-id: svn://10.0.0.236/trunk@175720 18797224-902f-48f8-a5cc-f745e15eee43 --- .../camino/src/download/nsDownloadListener.mm | 3 ++- .../browser/cocoa/src/nsDownloadListener.mm | 5 +++-- .../browser/powerplant/source/UDownload.cpp | 6 ++++-- .../ui/progressDlg/nsProgressDialog.js | 3 ++- mozilla/mailnews/base/src/nsMessenger.cpp | 3 ++- .../downloads/public/nsIDownloadManager.idl | 9 ++++++++- .../downloads/src/nsDownloadManager.cpp | 2 ++ .../components/downloads/src/nsDownloadProxy.h | 4 +++- mozilla/toolkit/content/contentAreaUtils.js | 4 ++-- mozilla/uriloader/base/nsIDownload.idl | 2 +- mozilla/uriloader/base/nsITransfer.idl | 18 +++++++++--------- .../exthandler/nsExternalHelperAppService.cpp | 8 ++------ .../resources/content/contentAreaUtils.js | 4 ++-- .../public/nsIDownloadManager.idl | 8 +++++++- .../download-manager/src/nsDownloadManager.cpp | 5 ++++- .../download-manager/src/nsDownloadProxy.h | 4 +++- 16 files changed, 56 insertions(+), 32 deletions(-) diff --git a/mozilla/camino/src/download/nsDownloadListener.mm b/mozilla/camino/src/download/nsDownloadListener.mm index 00246616515..51558754ec4 100644 --- a/mozilla/camino/src/download/nsDownloadListener.mm +++ b/mozilla/camino/src/download/nsDownloadListener.mm @@ -71,7 +71,8 @@ NS_IMPL_ISUPPORTS_INHERITED4(nsDownloadListener, CHDownloader, nsIDownload, /* void init (in nsIURI aSource, in nsIURI aTarget, in AString aDisplayName, in wstring openingWith, in long long startTime, in nsICancelable aCancelable); */ NS_IMETHODIMP nsDownloadListener::Init(nsIURI *aSource, nsIURI *aTarget, const nsAString &aDisplayName, - nsIMIMEInfo* aMIMEInfo, PRInt64 startTime, nsICancelable* aCancelable) + nsIMIMEInfo* aMIMEInfo, PRInt64 startTime, nsILocalFile* aTempFile, + nsICancelable* aCancelable) { // get the local file corresponding to the given target URI nsCOMPtr targetFile; diff --git a/mozilla/embedding/browser/cocoa/src/nsDownloadListener.mm b/mozilla/embedding/browser/cocoa/src/nsDownloadListener.mm index 2c0ecfc731f..3dcf88350cd 100644 --- a/mozilla/embedding/browser/cocoa/src/nsDownloadListener.mm +++ b/mozilla/embedding/browser/cocoa/src/nsDownloadListener.mm @@ -64,10 +64,11 @@ NS_IMPL_ISUPPORTS_INHERITED4(nsDownloadListener, CHDownloader, nsIDownload, #pragma mark - -/* void init (in nsIURI aSource, in nsILocalFile aTarget, in AString aDisplayName, in wstring openingWith, in long long startTime, in nsICancelable aCancelable); */ +/* void init (in nsIURI aSource, in nsILocalFile aTarget, in AString aDisplayName, in wstring openingWith, in long long startTime, in nsILocalFile aTempFile, in nsICancelable aCancelable); */ NS_IMETHODIMP nsDownloadListener::Init(nsIURI *aSource, nsILocalFile *aTarget, const nsAString &aDisplayName, - nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsICancelable* aCancelable) + nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsILocalFile* aTempFile, + nsICancelable* aCancelable) { CreateDownloadDisplay(); // call the base class to make the download UI diff --git a/mozilla/embedding/browser/powerplant/source/UDownload.cpp b/mozilla/embedding/browser/powerplant/source/UDownload.cpp index 097540bec09..0688e00c508 100644 --- a/mozilla/embedding/browser/powerplant/source/UDownload.cpp +++ b/mozilla/embedding/browser/powerplant/source/UDownload.cpp @@ -75,8 +75,10 @@ NS_IMPL_ISUPPORTS4(CDownload, nsIDownload, nsITransfer, #pragma mark - #pragma mark [CDownload::nsIDownload] -/* void init (in nsIURI aSource, in nsILocalFile aTarget, in wstring aDisplayName, in nsIMIMEInfo aMIMEInfo, in long long startTime, in nsICancelable aCancelable); */ -NS_IMETHODIMP CDownload::Init(nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisplayName, nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsICancelable* aCancelable) +/* void init (in nsIURI aSource, in nsILocalFile aTarget, in wstring aDisplayName, in nsIMIMEInfo aMIMEInfo, in long long startTime, in nsILocalFile aTempFile, in nsICancelable aCancelable); */ +NS_IMETHODIMP CDownload::Init(nsIURI *aSource, nsILocalFile *aTarget, + const PRUnichar *aDisplayName, nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, + nsILocalFile* aTempFile, nsICancelable* aCancelable) { try { mSource = aSource; diff --git a/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.js b/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.js index f283b1fc66a..0f32f9a5ebb 100644 --- a/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.js +++ b/mozilla/embedding/components/ui/progressDlg/nsProgressDialog.js @@ -169,7 +169,8 @@ nsProgressDialog.prototype = { this ); }, - init: function( aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime, aOperation ) { + init: function( aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime, + aTempFile, aOperation ) { this.source = aSource; this.target = aTarget; this.displayName = aDisplayName; diff --git a/mozilla/mailnews/base/src/nsMessenger.cpp b/mozilla/mailnews/base/src/nsMessenger.cpp index 4e132ca2b17..7a924f34e1e 100644 --- a/mozilla/mailnews/base/src/nsMessenger.cpp +++ b/mozilla/mailnews/base/src/nsMessenger.cpp @@ -1916,7 +1916,8 @@ nsresult nsSaveMsgListener::InitializeDownload(nsIRequest * aRequest, PRInt32 aB nsCOMPtr url; channel->GetURI(getter_AddRefs(url)); - rv = tr->Init(url, outputURI, EmptyString(), mimeinfo, timeDownloadStarted, this); + rv = tr->Init(url, outputURI, EmptyString(), mimeinfo, + timeDownloadStarted, nsnull, this); // now store the web progresslistener mTransfer = tr; diff --git a/mozilla/toolkit/components/downloads/public/nsIDownloadManager.idl b/mozilla/toolkit/components/downloads/public/nsIDownloadManager.idl index df66605af9f..35a32b0de04 100644 --- a/mozilla/toolkit/components/downloads/public/nsIDownloadManager.idl +++ b/mozilla/toolkit/components/downloads/public/nsIDownloadManager.idl @@ -51,7 +51,7 @@ interface nsIRDFDataSource; interface nsIDownloadProgressListener; interface nsISupportsArray; -[scriptable, uuid(31e8cfdc-52c7-4a36-b1c2-8038a12c271d)] +[scriptable, uuid(1f280341-30f4-4009-bb0d-a78f2936d1fb)] interface nsIDownloadManager : nsISupports { // Download States const short DOWNLOAD_NOTSTARTED = -1; @@ -81,6 +81,12 @@ interface nsIDownloadManager : nsISupports { * * @param startTime Time when the download started * + * @param aTempFile The location of a temporary file; i.e. a file in which + * the received data will be stored, but which is not + * equal to the target file. (will be moved to the real + * target by the caller, when the download is finished) + * May be null. + * * @param aCancelable An object that can be used to abort the download. * Must not be null. * @@ -93,6 +99,7 @@ interface nsIDownloadManager : nsISupports { in AString aIconURL, in nsIMIMEInfo aMIMEInfo, in PRTime aStartTime, + in nsILocalFile aTempFile, in nsICancelable aCancelable); /** diff --git a/mozilla/toolkit/components/downloads/src/nsDownloadManager.cpp b/mozilla/toolkit/components/downloads/src/nsDownloadManager.cpp index ce437a3306c..d034512121f 100644 --- a/mozilla/toolkit/components/downloads/src/nsDownloadManager.cpp +++ b/mozilla/toolkit/components/downloads/src/nsDownloadManager.cpp @@ -500,6 +500,7 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType, nsIMIMEInfo *aMIMEInfo, PRTime aStartTime, nsICancelable* aCancelable, + nsILocalFile* aTempFile, nsIDownload** aDownload) { NS_ENSURE_ARG_POINTER(aSource); @@ -2177,6 +2178,7 @@ nsDownload::Init(nsIURI* aSource, const nsAString& aDisplayName, nsIMIMEInfo *aMIMEInfo, PRTime aStartTime, + nsILocalFile* aTempFile, nsICancelable* aCancelable) { NS_WARNING("Huh...how did we get here?!"); diff --git a/mozilla/toolkit/components/downloads/src/nsDownloadProxy.h b/mozilla/toolkit/components/downloads/src/nsDownloadProxy.h index 4c7e406f52d..20f7e4583eb 100644 --- a/mozilla/toolkit/components/downloads/src/nsDownloadProxy.h +++ b/mozilla/toolkit/components/downloads/src/nsDownloadProxy.h @@ -63,6 +63,7 @@ public: const nsAString& aDisplayName, nsIMIMEInfo *aMIMEInfo, PRTime aStartTime, + nsILocalFile* aTempFile, nsICancelable* aCancelable) { nsresult rv; nsCOMPtr dm = do_GetService("@mozilla.org/download-manager;1", &rv); @@ -71,7 +72,8 @@ public: rv = dm->AddDownload(nsIDownloadManager::DOWNLOAD_TYPE_DOWNLOAD, aSource, aTarget, aDisplayName, EmptyString(), aMIMEInfo, - aStartTime, aCancelable, getter_AddRefs(mInner)); + aStartTime, aCancelable, aTempFile, + getter_AddRefs(mInner)); if (NS_FAILED(rv)) return rv; nsCOMPtr prefs = do_GetService("@mozilla.org/preferences-service;1", &rv); diff --git a/mozilla/toolkit/content/contentAreaUtils.js b/mozilla/toolkit/content/contentAreaUtils.js index bbc11199364..cc2f4824797 100644 --- a/mozilla/toolkit/content/contentAreaUtils.js +++ b/mozilla/toolkit/content/contentAreaUtils.js @@ -418,13 +418,13 @@ function internalSave(aURL, aDocument, aDefaultFileName, aContentDisposition, const kWrapColumn = 80; tr.init((aChosenData ? aChosenData.uri : fileInfo.uri), - persistArgs.target, "", null, null, persist); + persistArgs.target, "", null, null, null, persist); persist.progressListener = tr; persist.saveDocument(persistArgs.source, persistArgs.target, filesFolder, persistArgs.contentType, encodingFlags, kWrapColumn); } else { tr.init((aChosenData ? aChosenData.uri : source), - persistArgs.target, "", null, null, persist); + persistArgs.target, "", null, null, null, persist); persist.progressListener = tr; persist.saveURI((aChosenData ? aChosenData.uri : source), null, aReferrer, persistArgs.postData, null, diff --git a/mozilla/uriloader/base/nsIDownload.idl b/mozilla/uriloader/base/nsIDownload.idl index 013ad711806..fd75626f7bf 100644 --- a/mozilla/uriloader/base/nsIDownload.idl +++ b/mozilla/uriloader/base/nsIDownload.idl @@ -45,7 +45,7 @@ interface nsICancelable; interface nsIWebProgressListener; interface nsIMIMEInfo; -[scriptable, uuid(1cb42fb4-f092-4a0e-8930-6c06a524da07)] +[scriptable, uuid(9e1fd9f2-9727-4926-85cd-f16c375bba6d)] interface nsIDownload : nsITransfer { /** diff --git a/mozilla/uriloader/base/nsITransfer.idl b/mozilla/uriloader/base/nsITransfer.idl index 8d3b173339d..e779b25208c 100644 --- a/mozilla/uriloader/base/nsITransfer.idl +++ b/mozilla/uriloader/base/nsITransfer.idl @@ -41,8 +41,9 @@ interface nsIURI; interface nsICancelable; interface nsIMIMEInfo; +interface nsILocalFile; -[scriptable, uuid(0721AAF2-28AC-46cd-BCFA-5F8CA2A8B99B)] +[scriptable, uuid(23c51569-e9a1-4a92-adeb-3723db82ef7c)] interface nsITransfer : nsIWebProgressListener2 { /** @@ -64,6 +65,12 @@ interface nsITransfer : nsIWebProgressListener2 { * response from the server was received) * XXX presumably wbp and exthandler do this differently * + * @param aTempFile The location of a temporary file; i.e. a file in which + * the received data will be stored, but which is not + * equal to the target file. (will be moved to the real + * target by the caller, when the download is finished) + * May be null. + * * @param aCancelable An object that can be used to abort the download. * Must not be null. * Implementations are expected to hold a strong @@ -76,6 +83,7 @@ interface nsITransfer : nsIWebProgressListener2 { in AString aDisplayName, in nsIMIMEInfo aMIMEInfo, in PRTime startTime, + in nsILocalFile aTempFile, in nsICancelable aCancelable); }; @@ -87,19 +95,11 @@ interface nsITransfer : nsIWebProgressListener2 { * Notifications of the download progress will happen via * nsIWebProgressListener/nsIWebProgressListener2. * - * If nsIObserver is implemented, the component may get a notification with - * topic "temp-file" and an nsILocalFile instance as subject, which indicates - * the location of a temporary file; i.e. a file in which the received data will - * be stored, but which is not equal to the target file. - * * INTERFACES THAT MUST BE IMPLEMENTED: * nsITransfer * nsIWebProgressListener * nsIWebProgressListener2 * - * INTERFACES THAT MAY BE IMPLEMENTED: - * nsIObserver - * * XXX move this to nsEmbedCID.h once the interfaces (and the contract ID) are * frozen. */ diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index 10a107b68d1..a5483fc2d54 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -2085,15 +2085,11 @@ nsresult nsExternalAppHandler::InitializeDownload(nsITransfer* aTransfer) rv = NS_NewFileURI(getter_AddRefs(target), mFinalFileDestination); if (NS_FAILED(rv)) return rv; + nsCOMPtr lf(do_QueryInterface(mTempFile)); rv = aTransfer->Init(mSourceUrl, target, EmptyString(), - mMimeInfo, mTimeDownloadStarted, this); + mMimeInfo, mTimeDownloadStarted, lf, this); if (NS_FAILED(rv)) return rv; - // Tell the listener about the location of the target file - nsCOMPtr obs(do_QueryInterface(aTransfer)); - if (obs) - obs->Observe(mTempFile, "temp-file", nsnull); - return rv; } diff --git a/mozilla/xpfe/communicator/resources/content/contentAreaUtils.js b/mozilla/xpfe/communicator/resources/content/contentAreaUtils.js index dbf9c612e86..b3fed243309 100644 --- a/mozilla/xpfe/communicator/resources/content/contentAreaUtils.js +++ b/mozilla/xpfe/communicator/resources/content/contentAreaUtils.js @@ -394,13 +394,13 @@ function internalSave(aURL, aDocument, aDefaultFileName, aContentDisposition, const kWrapColumn = 80; tr.init((aChosenData ? aChosenData.uri : fileInfo.uri), - persistArgs.target, "", null, null, persist); + persistArgs.target, "", null, null, null, persist); persist.progressListener = tr; persist.saveDocument(persistArgs.source, persistArgs.target, filesFolder, persistArgs.contentType, encodingFlags, kWrapColumn); } else { tr.init((aChosenData ? aChosenData.uri : source), - persistArgs.target, "", null, null, persist); + persistArgs.target, "", null, null, null, persist); persist.progressListener = tr; persist.saveURI((aChosenData ? aChosenData.uri : source), null, aReferrer, persistArgs.postData, null, diff --git a/mozilla/xpfe/components/download-manager/public/nsIDownloadManager.idl b/mozilla/xpfe/components/download-manager/public/nsIDownloadManager.idl index b075bdf0450..1330d1e2156 100644 --- a/mozilla/xpfe/components/download-manager/public/nsIDownloadManager.idl +++ b/mozilla/xpfe/components/download-manager/public/nsIDownloadManager.idl @@ -49,7 +49,7 @@ interface nsIDownload; interface nsICancelable; interface nsIMIMEInfo; -[scriptable, uuid(db2eb695-ebb3-4296-9f52-41ddcfce4ca3)] +[scriptable, uuid(9cdfcea3-fbe4-4ba1-a0fd-fe273097ddfa)] interface nsIDownloadManager : nsISupports { // Methods called by clients to carry out various managing functions @@ -70,6 +70,11 @@ interface nsIDownloadManager : nsISupports { * * @param startTime Time when the download started (ie, when the first * response from the server was received) + * @param aTempFile The location of a temporary file; i.e. a file in which + * the received data will be stored, but which is not + * equal to the target file. (will be moved to the real + * target by the caller, when the download is finished) + * May be null. * * @param aCancelable An object that can be used to abort the download. * Must not be null. @@ -81,6 +86,7 @@ interface nsIDownloadManager : nsISupports { in AString aDisplayName, in nsIMIMEInfo aMIMEInfo, in PRTime startTime, + in nsILocalFile aTempFile, in nsICancelable aCancelable); /** diff --git a/mozilla/xpfe/components/download-manager/src/nsDownloadManager.cpp b/mozilla/xpfe/components/download-manager/src/nsDownloadManager.cpp index c147ab4874b..175e395ea5f 100644 --- a/mozilla/xpfe/components/download-manager/src/nsDownloadManager.cpp +++ b/mozilla/xpfe/components/download-manager/src/nsDownloadManager.cpp @@ -435,6 +435,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource, const nsAString& aDisplayName, nsIMIMEInfo *aMIMEInfo, PRTime aStartTime, + nsILocalFile* aTempFile, nsICancelable* aCancelable, nsIDownload** aDownload) { @@ -761,7 +762,8 @@ nsDownloadManager::OpenProgressDialogFor(nsIDownload* aDownload, nsIDOMWindow* a nsCOMPtr mimeInfo; aDownload->GetMIMEInfo(getter_AddRefs(mimeInfo)); - dialog->Init(source, target, EmptyString(), mimeInfo, startTime, nsnull); + dialog->Init(source, target, EmptyString(), mimeInfo, startTime, nsnull, + nsnull); dialog->SetObserver(internalDownload); // now set the listener so we forward notifications to the dialog @@ -1307,6 +1309,7 @@ nsDownload::Init(nsIURI* aSource, const nsAString& aDisplayName, nsIMIMEInfo *aMIMEInfo, PRTime aStartTime, + nsILocalFile* aTempFile, nsICancelable* aCancelable) { NS_NOTREACHED("Huh...how did we get here?!"); diff --git a/mozilla/xpfe/components/download-manager/src/nsDownloadProxy.h b/mozilla/xpfe/components/download-manager/src/nsDownloadProxy.h index acab0ba12a0..ddf59eadd43 100644 --- a/mozilla/xpfe/components/download-manager/src/nsDownloadProxy.h +++ b/mozilla/xpfe/components/download-manager/src/nsDownloadProxy.h @@ -64,13 +64,15 @@ public: const nsAString& aDisplayName, nsIMIMEInfo *aMIMEInfo, PRTime aStartTime, + nsILocalFile* aTempFile, nsICancelable* aCancelable) { nsresult rv; nsCOMPtr dm = do_GetService("@mozilla.org/download-manager;1", &rv); if (NS_FAILED(rv)) return rv; - rv = dm->AddDownload(aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime, aCancelable, getter_AddRefs(mInner)); + rv = dm->AddDownload(aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime, + aTempFile, aCancelable, getter_AddRefs(mInner)); if (NS_FAILED(rv)) return rv;