diff --git a/browser/base/content/contentAreaUtils.js b/browser/base/content/contentAreaUtils.js index f44cfc39faa9..bc7d685339c0 100644 --- a/browser/base/content/contentAreaUtils.js +++ b/browser/base/content/contentAreaUtils.js @@ -233,7 +233,7 @@ function foundHeaderInfo(aSniffer, aData, aSkipPrompt) var persistArgs = { source : source, contentType : (isDocument && saveAsType == kSaveAsType_Text) ? "text/plain" : contentType, - target : file, + target : makeFileURL(file), postData : aData.document ? getPostData() : null, bypassCache : aData.bypassCache }; @@ -259,10 +259,7 @@ function foundHeaderInfo(aSniffer, aData, aSkipPrompt) var filesFolder = null; if (persistArgs.contentType != "text/plain") { // Create the local directory into which to save associated files. - const nsILocalFile = Components.interfaces.nsILocalFile; - const lfContractID = "@mozilla.org/file/local;1"; - filesFolder = Components.classes[lfContractID].createInstance(nsILocalFile); - filesFolder.initWithPath(persistArgs.target.path); + filesFolder = file.clone(); var nameWithoutExtension = filesFolder.leafName; nameWithoutExtension = nameWithoutExtension.substring(0, nameWithoutExtension.lastIndexOf(".")); @@ -690,7 +687,13 @@ function makeURL(aURL) var ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); return ioService.newURI(aURL, null, null); - +} + +function makeFileURL(aFile) +{ + var ioService = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + return ioService.newFileURI(aFile); } function makeFilePicker() diff --git a/embedding/components/ui/progressDlg/nsIProgressDialog.idl b/embedding/components/ui/progressDlg/nsIProgressDialog.idl index 4db9ab671ea5..25986fe55a94 100644 --- a/embedding/components/ui/progressDlg/nsIProgressDialog.idl +++ b/embedding/components/ui/progressDlg/nsIProgressDialog.idl @@ -46,8 +46,8 @@ interface nsIDOMWindow; * not need to hold a reference to it. */ -[scriptable, uuid(88A478B3-AF65-440a-94DC-ED9B154D2990)] -interface nsIProgressDialog : nsIDownload { +[scriptable, uuid(1915c4f1-ee57-4684-b46a-0d9f695403b4)] +interface nsIProgressDialog : nsITransfer { /** * Open the dialog * diff --git a/embedding/components/ui/progressDlg/nsProgressDialog.js b/embedding/components/ui/progressDlg/nsProgressDialog.js index 6c6c37a81016..9c84e0b226ae 100644 --- a/embedding/components/ui/progressDlg/nsProgressDialog.js +++ b/embedding/components/ui/progressDlg/nsProgressDialog.js @@ -63,6 +63,7 @@ function nsProgressDialog() { this.strings = new Array; this.mSource = null; this.mTarget = null; + this.mTargetFile = null; this.mMIMEInfo = null; this.mDialog = null; this.mDisplayName = null; @@ -76,7 +77,13 @@ function nsProgressDialog() { this.mCancelDownloadOnClose = true; } -const nsIProgressDialog = Components.interfaces.nsIProgressDialog; +const nsIProgressDialog = Components.interfaces.nsIProgressDialog; +const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher; +const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; +const nsITextToSubURI = Components.interfaces.nsITextToSubURI; +const nsIChannel = Components.interfaces.nsIChannel; +const nsIFileURL = Components.interfaces.nsIFileURL; +const nsIURL = Components.interfaces.nsIURL; nsProgressDialog.prototype = { // Turn this on to get debugging messages. @@ -108,7 +115,7 @@ nsProgressDialog.prototype = { get source() { return this.mSource; }, set source(newval) { return this.mSource = newval; }, get target() { return this.mTarget; }, - set target(newval) { return this.mTarget = newval; }, + get targetFile() { return this.mTargetFile; }, get MIMEInfo() { return this.mMIMEInfo; }, set MIMEInfo(newval) { return this.mMIMEInfo = newval; }, get dialog() { return this.mDialog; }, @@ -126,6 +133,14 @@ nsProgressDialog.prototype = { get cancelDownloadOnClose() { return this.mCancelDownloadOnClose; }, set cancelDownloadOnClose(newval) { return this.mCancelDownloadOnClose = newval; }, + set target(newval) { + // If newval references a file on the local filesystem, then grab a + // reference to its corresponding nsIFile. + this.mTargetFile = newval instanceof nsIFileURL ? newfile.file : null; + + return this.mTarget = newval; + }, + // These setters use functions that update the dialog. set paused(newval) { return this.setPaused(newval); }, set completed(newval) { return this.setCompleted(newval); }, @@ -142,7 +157,7 @@ nsProgressDialog.prototype = { // Open dialog using the WindowWatcher service. var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] - .getService( Components.interfaces.nsIWindowWatcher ); + .getService( nsIWindowWatcher ); this.dialog = ww.openWindow( this.parent, this.dialogChrome, null, @@ -165,9 +180,25 @@ nsProgressDialog.prototype = { // Look for STATE_STOP and update dialog to indicate completion when it happens. onStateChange: function( aWebProgress, aRequest, aStateFlags, aStatus ) { - if ( aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP ) { - // we are done downloading... - this.completed = true; + if ( aStateFlags & nsIWebProgressListener.STATE_STOP ) { + // if we are downloading, then just wait for the first STATE_STOP + if ( this.targetFile != null ) { + // we are done transfering... + this.completed = true; + return; + } + + // otherwise, wait for STATE_STOP with aRequest corresponding to + // our target. XXX redirects might screw up this logic. + try { + var chan = aRequest.QueryInterface(nsIChannel); + if (chan.URI.equals(this.target)) { + // we are done transfering... + this.completed = true; + } + } + catch (e) { + } } }, @@ -326,14 +357,35 @@ nsProgressDialog.prototype = { QueryInterface: function (iid) { if (!iid.equals(Components.interfaces.nsIProgressDialog) && !iid.equals(Components.interfaces.nsIDownload) && + !iid.equals(Components.interfaces.nsITransfer) && !iid.equals(Components.interfaces.nsIWebProgressListener) && !iid.equals(Components.interfaces.nsIObserver) && + !iid.equals(Components.interfaces.nsIInterfaceRequestor) && !iid.equals(Components.interfaces.nsISupports)) { throw Components.results.NS_ERROR_NO_INTERFACE; } return this; }, + // ---------- nsIInterfaceRequestor methods ---------- + + getInterface: function(iid) { + if (iid.equals(Components.interfaces.nsIPrompt) || + iid.equals(Components.interfaces.nsIAuthPrompt)) { + // use the window watcher service to get a nsIPrompt/nsIAuthPrompt impl + var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] + .getService(Components.interfaces.nsIWindowWatcher); + var prompt; + if (iid.equals(Components.interfaces.nsIPrompt)) + prompt = ww.getNewPrompter(this.parent); + else + prompt = ww.getNewAuthPrompter(this.parent); + return prompt; + } + Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE; + return null; + }, + // ---------- implementation methods ---------- // Initialize the dialog. @@ -384,8 +436,15 @@ nsProgressDialog.prototype = { this.hide( "targetRow" ); } } else { - // Target is the destination file. - this.setValue( "target", this.target.path ); + // If target is not a local file, then hide extra dialog controls. + if (this.targetFile != null) { + this.setValue( "target", this.targetFile.path ); + } else { + this.setValue( "target", this.target.spec ); + this.hide( "pauseResume" ); + this.hide( "launch" ); + this.hide( "reveal" ); + } } // Set source field. @@ -402,8 +461,9 @@ nsProgressDialog.prototype = { this.setValue( "timeElapsed", this.formatSeconds( this.elapsed / 1000 ) ); this.setValue( "timeLeft", this.getString( "unknownTime" ) ); - // Initialize the "keep open" box. Hide this if we're opening a helper app. - if ( !this.saving ) { + // Initialize the "keep open" box. Hide this if we're opening a helper app + // or if we are uploading. + if ( !this.saving || !this.targetFile ) { // Hide this in this case. this.hide( "keep" ); } else { @@ -422,17 +482,17 @@ nsProgressDialog.prototype = { // Cancel button stops the download (if not completed), // and closes the dialog. onCancel: function() { - // Cancel the download, if not completed. - if ( !this.completed ) { - if ( this.operation ) { - this.operation.cancelSave(); - // XXX We're supposed to clean up files/directories. - } - if ( this.observer ) { - this.observer.observe( this, "oncancel", "" ); - } - this.paused = false; - } + // Cancel the download, if not completed. + if ( !this.completed ) { + if ( this.operation ) { + this.operation.cancelSave(); + // XXX We're supposed to clean up files/directories. + } + if ( this.observer ) { + this.observer.observe( this, "oncancel", "" ); + } + this.paused = false; + } // Test whether the dialog is already closed. // This will be the case if we've come through onUnload. if ( this.dialog ) { @@ -477,7 +537,7 @@ nsProgressDialog.prototype = { // we need to ask if we're unsure dontAskAgain = false; } - if ( !dontAskAgain && this.target.isExecutable() ) { + if ( !dontAskAgain && this.targetFile.isExecutable() ) { try { var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService( Components.interfaces.nsIPromptService ); @@ -503,7 +563,7 @@ nsProgressDialog.prototype = { if ( !okToProceed ) return; } - this.target.launch(); + this.targetFile.launch(); this.dialog.close(); } catch ( exception ) { // XXX Need code here to tell user the launch failed! @@ -515,15 +575,23 @@ nsProgressDialog.prototype = { // Invoke the reveal method of the target file. onReveal: function() { try { - this.target.reveal(); + this.targetFile.reveal(); this.dialog.close(); } catch ( exception ) { } }, - // Get filename from target file. + // Get filename from the target. fileName: function() { - return this.target ? this.target.leafName : ""; + if ( this.targetFile != null ) + return this.targetFile.leafName; + try { + var escapedFileName = this.target.QueryInterface(nsIURL).fileName; + var textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"] + .getService(nsITextToSubURI); + return textToSubURI.unEscapeURIForUI(this.target.originCharset, escapedFileName); + } catch (e) {} + return ""; }, // Set the dialog title. @@ -623,7 +691,7 @@ nsProgressDialog.prototype = { this.formatSeconds( this.elapsed/1000 ) ); string = this.replaceInsert( string, 2, - this.target.fileSize >> 10 ); + this.targetFile.fileSize >> 10 ); this.setValue( "status", string); // Put progress meter at 100%. @@ -649,7 +717,7 @@ nsProgressDialog.prototype = { if ( enableButtons ) { this.enable( "reveal" ); try { - if ( this.target ) { + if ( this.targetFile != null ) { this.enable( "launch" ); } } catch(e) { @@ -795,15 +863,17 @@ nsProgressDialog.prototype = { // Hide a given dialog field. hide: function( field ) { - this.dialogElement( field ).setAttribute( "style", "display: none;" ); - // Hide the associated separator, too. - this.dialogElement( field+"Separator" ).setAttribute( "style", "display: none;" ); + this.dialogElement( field ).hidden = true; + + // Also hide any related separator element... + var sep = this.dialogElement( field+"Separator" ); + if (sep) + sep.hidden = true; }, // Return input in hex, prepended with "0x" and leading zeros (to 8 digits). hex: function( x ) { - var hex = Number(x).toString(16); - return "0x" + ( "00000000" + hex ).substring( hex.length ); + return "0x" + ("0000000" + Number(x).toString(16)).slice(-8); }, // Dump text (if debug is on). diff --git a/embedding/components/ui/progressDlg/nsProgressDialog.xul b/embedding/components/ui/progressDlg/nsProgressDialog.xul index 90de66711071..fc164a858c9d 100644 --- a/embedding/components/ui/progressDlg/nsProgressDialog.xul +++ b/embedding/components/ui/progressDlg/nsProgressDialog.xul @@ -64,7 +64,8 @@ class="dialog" title="&defaultTitle;" onload="notifyObserver('onload')" - onunload="notifyObserver('onunload')"> + onunload="notifyObserver('onunload')" + style="width: 32em;"> - + @@ -330,6 +331,8 @@ + + diff --git a/xpfe/communicator/resources/content/contentAreaUtils.js b/xpfe/communicator/resources/content/contentAreaUtils.js index cab37140f917..36be407b5b81 100644 --- a/xpfe/communicator/resources/content/contentAreaUtils.js +++ b/xpfe/communicator/resources/content/contentAreaUtils.js @@ -351,7 +351,7 @@ function foundHeaderInfo(aSniffer, aData) var persistArgs = { source : source, contentType : (useSaveDocument && fp.filterIndex == 2) ? "text/plain" : contentType, - target : fp.file, + target : makeFileURL(fp.file), postData : isDocument ? getPostData() : null, bypassCache : aData.bypassCache }; @@ -377,10 +377,7 @@ function foundHeaderInfo(aSniffer, aData) var filesFolder = null; if (persistArgs.contentType != "text/plain") { // Create the local directory into which to save associated files. - const lfContractID = "@mozilla.org/file/local;1"; - const lfIID = Components.interfaces.nsILocalFile; - filesFolder = Components .classes[lfContractID].createInstance(lfIID); - filesFolder.initWithPath(persistArgs.target.path); + filesFolder = fp.file.clone(); var nameWithoutExtension = filesFolder.leafName.replace(/\.[^.]*$/, ""); var filesFolderLeafName = getStringBundle().formatStringFromName("filesFolder", @@ -706,7 +703,13 @@ function makeURL(aURL) var ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); return ioService.newURI(aURL, null, null); - +} + +function makeFileURL(aFile) +{ + var ioService = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + return ioService.newFileURI(aFile); } function makeFilePicker() diff --git a/xpfe/components/download-manager/public/nsIDownloadManager.idl b/xpfe/components/download-manager/public/nsIDownloadManager.idl index 15920ed57264..0b22d2a8b2b0 100644 --- a/xpfe/components/download-manager/public/nsIDownloadManager.idl +++ b/xpfe/components/download-manager/public/nsIDownloadManager.idl @@ -74,7 +74,7 @@ interface nsIDownloadManager : nsISupports { */ nsIDownload addDownload(in nsIURI aSource, - in nsILocalFile aTarget, + in nsIURI aTarget, in wstring aDisplayName, in nsIMIMEInfo aMIMEInfo, in long long startTime, diff --git a/xpfe/components/download-manager/resources/downloadmanager.js b/xpfe/components/download-manager/resources/downloadmanager.js index 8e3768ba685f..22d3ba47cf46 100644 --- a/xpfe/components/download-manager/resources/downloadmanager.js +++ b/xpfe/components/download-manager/resources/downloadmanager.js @@ -56,7 +56,7 @@ const dlObserver = { function selectDownload(aDownload) { - var dlElt = document.getElementById(aDownload.target.path); + var dlElt = document.getElementById(aDownload.targetFile.path); var dlIndex = gDownloadView.contentView.getIndexOfItem(dlElt); gDownloadView.treeBoxObject.selection.select(dlIndex); gDownloadView.treeBoxObject.ensureRowIsVisible(dlIndex); diff --git a/xpfe/components/download-manager/src/nsDownloadManager.cpp b/xpfe/components/download-manager/src/nsDownloadManager.cpp index a7b6e20140df..a7cb8f5b9b86 100644 --- a/xpfe/components/download-manager/src/nsDownloadManager.cpp +++ b/xpfe/components/download-manager/src/nsDownloadManager.cpp @@ -61,7 +61,7 @@ #include "nsIProfileChangeStatus.h" #include "nsISound.h" #include "nsIPrefService.h" -#include "nsIURL.h" +#include "nsIFileURL.h" /* Outstanding issues/todo: * 1. Implement pause/resume. @@ -88,6 +88,28 @@ static nsIRDFService* gRDFService = nsnull; static PRInt32 gRefCnt = 0; +/** + * This function extracts the local file path corresponding to the given URI. + */ +static nsresult +GetFilePathUTF8(nsIURI *aURI, nsACString &aResult) +{ + nsresult rv; + + nsCOMPtr fileURL = do_QueryInterface(aURI, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr file; + rv = fileURL->GetFile(getter_AddRefs(file)); + if (NS_FAILED(rv)) return rv; + + nsAutoString path; + rv = file->GetPath(path); + if (NS_SUCCEEDED(rv)) + CopyUTF16toUTF8(path, aResult); + return rv; +} + /////////////////////////////////////////////////////////////////////////////// // nsDownloadManager @@ -397,7 +419,7 @@ nsDownloadManager::AssertProgressInfoFor(const nsACString& aTargetPath) NS_IMETHODIMP nsDownloadManager::AddDownload(nsIURI* aSource, - nsILocalFile* aTarget, + nsIURI* aTarget, const PRUnichar* aDisplayName, nsIMIMEInfo *aMIMEInfo, PRInt64 aStartTime, @@ -418,13 +440,17 @@ nsDownloadManager::AddDownload(nsIURI* aSource, NS_ADDREF(*aDownload = internalDownload); - // the persistent descriptor of the target is the unique identifier we use - nsAutoString path; - rv = aTarget->GetPath(path); + // the path of the target is the unique identifier we use + nsCOMPtr targetFile; + rv = internalDownload->GetTargetFile(getter_AddRefs(targetFile)); if (NS_FAILED(rv)) return rv; - NS_ConvertUCS2toUTF8 utf8Path(path); - + nsAutoString path; + rv = targetFile->GetPath(path); + if (NS_FAILED(rv)) return rv; + + NS_ConvertUTF16toUTF8 utf8Path(path); + nsCOMPtr downloadRes; gRDFService->GetResource(utf8Path, getter_AddRefs(downloadRes)); @@ -446,7 +472,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource, // Set and assert the "pretty" (display) name of the download nsAutoString displayName; displayName.Assign(aDisplayName); if (displayName.IsEmpty()) { - aTarget->GetLeafName(displayName); + targetFile->GetLeafName(displayName); } internalDownload->SetDisplayName(displayName.get()); @@ -740,7 +766,7 @@ nsDownloadManager::OpenProgressDialogFor(nsIDownload* aDownload, nsIDOMWindow* a aDownload->GetSource(getter_AddRefs(source)); // target... - nsCOMPtr target; + nsCOMPtr target; aDownload->GetTarget(getter_AddRefs(target)); // helper app... @@ -797,21 +823,19 @@ nsDownloadManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUn nsresult rv; if (nsCRT::strcmp(aTopic, "oncancel") == 0) { nsCOMPtr dialog = do_QueryInterface(aSubject); - nsCOMPtr target; + nsCOMPtr target; dialog->GetTarget(getter_AddRefs(target)); - - nsAutoString path; - rv = target->GetPath(path); - if (NS_FAILED(rv)) return rv; - NS_ConvertUCS2toUTF8 utf8Path(path); + nsCAutoString path; + rv = GetFilePathUTF8(target, path); + if (NS_FAILED(rv)) return rv; - nsDownload* download = mCurrDownloads.GetWeak(utf8Path); + nsDownload* download = mCurrDownloads.GetWeak(path); if (download) { // unset dialog since it's closing download->SetDialog(nsnull); - return CancelDownload(utf8Path); + return CancelDownload(path); } } else if (nsCRT::strcmp(aTopic, "profile-approve-change") == 0) { @@ -887,10 +911,10 @@ nsDownloadManager::Observe(nsISupports* aSubject, const char* aTopic, const PRUn /////////////////////////////////////////////////////////////////////////////// // nsDownload -NS_IMPL_ISUPPORTS2(nsDownload, nsIDownload, nsIWebProgressListener) +NS_IMPL_ISUPPORTS3(nsDownload, nsIDownload, nsITransfer, nsIWebProgressListener) nsDownload::nsDownload(nsDownloadManager* aManager, - nsILocalFile* aTarget, + nsIURI* aTarget, nsIURI* aSource) : mDownloadManager(aManager), mTarget(aTarget), @@ -906,11 +930,11 @@ nsDownload::nsDownload(nsDownloadManager* aManager, nsDownload::~nsDownload() { - nsAutoString path; - nsresult rv = mTarget->GetPath(path); + nsCAutoString path; + nsresult rv = GetFilePathUTF8(mTarget, path); if (NS_FAILED(rv)) return; - mDownloadManager->AssertProgressInfoFor(NS_ConvertUCS2toUTF8(path)); + mDownloadManager->AssertProgressInfoFor(path); } /////////////////////////////////////////////////////////////////////////////// @@ -938,12 +962,12 @@ nsDownload::OnProgressChange(nsIWebProgress *aWebProgress, mLastUpdate = now; if (mDownloadState == NOTSTARTED) { - nsAutoString path; - nsresult rv = mTarget->GetPath(path); + nsCAutoString path; + nsresult rv = GetFilePathUTF8(mTarget, path); if (NS_FAILED(rv)) return rv; mDownloadState = DOWNLOADING; - mDownloadManager->DownloadStarted(NS_ConvertUCS2toUTF8(path)); + mDownloadManager->DownloadStarted(path); } if (aMaxTotalProgress > 0) @@ -1003,10 +1027,10 @@ nsDownload::OnStatusChange(nsIWebProgress *aWebProgress, { if (NS_FAILED(aStatus)) { mDownloadState = FAILED; - nsAutoString path; - nsresult rv = mTarget->GetPath(path); + nsCAutoString path; + nsresult rv = GetFilePathUTF8(mTarget, path); if (NS_SUCCEEDED(rv)) - mDownloadManager->DownloadEnded(NS_ConvertUCS2toUTF8(path), aMessage); + mDownloadManager->DownloadEnded(path, aMessage); } if (mListener) @@ -1104,11 +1128,11 @@ nsDownload::OnStateChange(nsIWebProgress* aWebProgress, } } - nsAutoString path; - rv = mTarget->GetPath(path); + nsCAutoString path; + rv = GetFilePathUTF8(mTarget, path); // can't do an early return; have to break reference cycle below if (NS_SUCCEEDED(rv)) { - mDownloadManager->DownloadEnded(NS_ConvertUCS2toUTF8(path), nsnull); + mDownloadManager->DownloadEnded(path, nsnull); } } @@ -1155,7 +1179,7 @@ nsDownload::OnSecurityChange(nsIWebProgress *aWebProgress, NS_IMETHODIMP nsDownload::Init(nsIURI* aSource, - nsILocalFile* aTarget, + nsIURI* aTarget, const PRUnichar* aDisplayName, nsIMIMEInfo *aMIMEInfo, PRInt64 aStartTime, @@ -1175,11 +1199,11 @@ nsDownload::SetDisplayName(const PRUnichar* aDisplayName) nsCOMPtr nameLiteral; nsCOMPtr res; - nsAutoString path; - nsresult rv = mTarget->GetPath(path); + nsCAutoString path; + nsresult rv = GetFilePathUTF8(mTarget, path); if (NS_FAILED(rv)) return rv; - gRDFService->GetUnicodeResource(path, getter_AddRefs(res)); + gRDFService->GetResource(path, getter_AddRefs(res)); gRDFService->GetLiteral(aDisplayName, getter_AddRefs(nameLiteral)); ds->Assert(res, gNC_Name, nameLiteral, PR_TRUE); @@ -1195,7 +1219,7 @@ nsDownload::GetDisplayName(PRUnichar** aDisplayName) } NS_IMETHODIMP -nsDownload::GetTarget(nsILocalFile** aTarget) +nsDownload::GetTarget(nsIURI** aTarget) { *aTarget = mTarget; NS_IF_ADDREF(*aTarget); @@ -1269,3 +1293,18 @@ nsDownload::GetMIMEInfo(nsIMIMEInfo** aMIMEInfo) NS_IF_ADDREF(*aMIMEInfo); return NS_OK; } + +NS_IMETHODIMP +nsDownload::GetTargetFile(nsILocalFile** aTargetFile) +{ + nsresult rv; + + nsCOMPtr fileURL = do_QueryInterface(mTarget, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr file; + rv = fileURL->GetFile(getter_AddRefs(file)); + if (NS_SUCCEEDED(rv)) + rv = CallQueryInterface(file, aTargetFile); + return rv; +} diff --git a/xpfe/components/download-manager/src/nsDownloadManager.h b/xpfe/components/download-manager/src/nsDownloadManager.h index 8f50102f1a63..ebfcefe4b605 100644 --- a/xpfe/components/download-manager/src/nsDownloadManager.h +++ b/xpfe/components/download-manager/src/nsDownloadManager.h @@ -108,10 +108,11 @@ class nsDownload : public nsIDownload, { public: NS_DECL_NSIWEBPROGRESSLISTENER + NS_DECL_NSITRANSFER NS_DECL_NSIDOWNLOAD NS_DECL_ISUPPORTS - nsDownload(nsDownloadManager* aManager, nsILocalFile* aTarget, nsIURI* aSource); + nsDownload(nsDownloadManager* aManager, nsIURI* aTarget, nsIURI* aSource); ~nsDownload(); void SetDialogListener(nsIWebProgressListener* aInternalListener) { @@ -156,7 +157,7 @@ private: nsString mDisplayName; - nsCOMPtr mTarget; + nsCOMPtr mTarget; nsCOMPtr mSource; nsCOMPtr mListener; nsCOMPtr mDialogListener; diff --git a/xpfe/components/download-manager/src/nsDownloadProxy.h b/xpfe/components/download-manager/src/nsDownloadProxy.h index 3ce39cbf73c6..1a3ab4353836 100644 --- a/xpfe/components/download-manager/src/nsDownloadProxy.h +++ b/xpfe/components/download-manager/src/nsDownloadProxy.h @@ -58,7 +58,7 @@ public: NS_DECL_ISUPPORTS NS_IMETHODIMP Init(nsIURI* aSource, - nsILocalFile* aTarget, + nsIURI* aTarget, const PRUnichar* aDisplayName, nsIMIMEInfo *aMIMEInfo, PRInt64 aStartTime, @@ -115,7 +115,7 @@ public: return mInner->GetSource(aSource); } - NS_IMETHODIMP GetTarget(nsILocalFile** aTarget) + NS_IMETHODIMP GetTarget(nsIURI** aTarget) { if (!mInner) return NS_ERROR_NOT_INITIALIZED; @@ -171,6 +171,13 @@ public: return mInner->GetPersist(aPersist); } + NS_IMETHODIMP GetTargetFile(nsILocalFile** aTargetFile) + { + if (!mInner) + return NS_ERROR_NOT_INITIALIZED; + return mInner->GetTargetFile(aTargetFile); + } + NS_IMETHODIMP OnStateChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, PRUint32 aStateFlags, PRUint32 aStatus) @@ -227,6 +234,6 @@ private: nsCOMPtr mInner; }; -NS_IMPL_ISUPPORTS2(nsDownloadProxy, nsIDownload, nsIWebProgressListener) +NS_IMPL_ISUPPORTS3(nsDownloadProxy, nsIDownload, nsITransfer, nsIWebProgressListener) #endif diff --git a/xpfe/components/filepicker/res/content/filepicker.js b/xpfe/components/filepicker/res/content/filepicker.js index 0086dd3578e9..9ac76f6eb608 100644 --- a/xpfe/components/filepicker/res/content/filepicker.js +++ b/xpfe/components/filepicker/res/content/filepicker.js @@ -94,8 +94,6 @@ function filepickerLoad() { (filePickerMode == nsIFilePicker.modeOpenMultiple) || (filePickerMode == nsIFilePicker.modeSave)) { - treeView.setFilter(filterTypes[0]); - /* build filter popup */ var filterPopup = document.createElement("menupopup"); @@ -117,6 +115,9 @@ function filepickerLoad() { filterBox.removeAttribute("hidden"); filterMenuList.selectedIndex = o.filterIndex; + + treeView.setFilter(filterTypes[o.filterIndex]); + } else if (filePickerMode == nsIFilePicker.modeGetFolder) { treeView.showOnlyDirectories = true; }