Download manager. Not part of build. a=asa

This commit is contained in:
blakeross%telocity.com 2002-03-13 05:20:13 +00:00
Родитель aab5fe14b4
Коммит 35f9a421a0
4 изменённых файлов: 78 добавлений и 3 удалений

Просмотреть файл

@ -47,10 +47,28 @@ interface nsIWebProgressListener;
[scriptable, uuid(06cb92f2-1dd2-11b2-95f2-96dfdfb804a1)]
interface nsIDownload : nsISupports {
/**
* Initializes the download with certain properties.
*
* @param aSource The source (nsIURI) of the download.
*
* @param aTarget The local file to which the download is being saved.
*
* @param aDisplayName The user-readable description of the download.
*
* @param aPersist The "persist" used to transfer the download. If set,
* the manager will set its listener to the download item
* and use it for cancellation. If not set, the client
* is expected to set the download item as the listener on
* whatever transfer component is being used, and to
* set an observer on the download item that listens for
* the "oncancel" topic and cancels the download.
*/
void init(in nsIURI aSource,
in nsILocalFile aTarget,
in wstring aDisplayName,
in nsIWebBrowserPersist aPersist);
/**
* The source of the download.
*/

Просмотреть файл

@ -59,6 +59,8 @@ interface nsIDownloadManager : nsISupports {
*
* @param aTarget The local file to which the download is being saved.
*
* @param aDisplayName The user-readable description of the download.
*
* @param aPersist The "persist" used to transfer the download. If set,
* the manager will set its listener to the download item
* and use it for cancellation. If not set, the client

Просмотреть файл

@ -767,7 +767,7 @@ nsDownload::nsDownload():mStartTime(0),
mMaxBytes(0),
mDownloadState(NOTSTARTED),
mLastUpdate(-500),
mOpeningWith(nsnull)
mOpeningWith(NS_LITERAL_STRING(""))
{
NS_INIT_ISUPPORTS();
}

Просмотреть файл

@ -42,7 +42,8 @@
#include "nsIDownload.h"
#include "nsIDownloadManager.h"
class nsDownloadProxy : nsIDownload
class nsDownloadProxy : public nsIDownload,
public nsIWebProgressListener
{
public:
@ -66,6 +67,7 @@ public:
aTarget->GetPersistentDescriptor(&persistentDescriptor);
return dm->OpenProgressDialogFor(persistentDescriptor, nsnull);
}
NS_IMETHODIMP GetDisplayName(PRUnichar** aDisplayName)
{
@ -136,11 +138,64 @@ public:
{
return mInner->GetPersist(aPersist);
}
NS_IMETHODIMP OnStateChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest, PRInt32 aStateFlags,
PRUint32 aStatus)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP OnStatusChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsresult aStatus,
const PRUnichar *aMessage)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *aLocation)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnLocationChange(aWebProgress, aRequest, aLocation);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress,
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRInt32 aState)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnSecurityChange(aWebProgress, aRequest, aState);
return NS_ERROR_FAILURE;
}
private:
nsCOMPtr<nsIDownload> mInner;
};
NS_IMPL_ISUPPORTS1(nsDownloadProxy, nsIDownload)
NS_IMPL_ISUPPORTS2(nsDownloadProxy, nsIDownload, nsIWebProgressListener)
#endif