Download manager. Not part of build.

git-svn-id: svn://10.0.0.236/trunk@115701 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
blakeross%telocity.com
2002-03-04 03:58:47 +00:00
parent d20f3f5ea5
commit 192e083099
4 changed files with 66 additions and 152 deletions

View File

@@ -1,123 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Blake Ross <blaker@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* nsIDownloadItem implements nsIWebProgressListener and acts as a "master
* listener" for the ongoing transfer. If clients provide a persist object,
* the item will automatically be set as the persist's listener. Otherwise,
* clients should set this themselves on whatever download mechanism they're
* using. Clients may have their own UI for a download as well, in which case
* they may set the listener attribute. nsIDownloadItem will forward
* notifications to that listener.
*/
#include "nsIWebProgressListener.idl"
interface nsIURI;
interface nsILocalFile;
interface nsIObserver;
interface nsIWebBrowserPersist;
[scriptable, uuid(06cb92f2-1dd2-11b2-95f2-96dfdfb804a1)]
interface nsIDownloadItem : nsIWebProgressListener {
/**
* prettyName
* The user-readable description of the download.
*/
readonly attribute wstring prettyName;
/**
* source
* The source of the download.
*/
readonly attribute nsIURI source;
/**
* target
* The local file where the download is being saved.
*/
readonly attribute nsILocalFile target;
/**
* percentComplete
* The percentage of completion of the download.
*/
readonly attribute PRInt32 percentComplete;
/**
* startTime
* The time a download was started; necessary for more accurate measurements.
*/
attribute long long startTime;
/**
* listener
* Optional; downloading information is passed to this listener and used to
* update client UI.
*/
attribute nsIWebProgressListener listener;
/**
* persist
* Optional. If set, it will be used for cancellation, and the download item
* will be set as its listener. If not, |observer| should be set to listen
* and respond accordingly to topics like oncancel, and the client promises
* to set the download item as the listener for whatever transfer component
* being used.
*/
readonly attribute nsIWebBrowserPersist persist;
/**
* observer
* If set, receives notifications of events like cancel ("oncancel").
* Must be set if no persist object is specified (see above).
*/
attribute nsIObserver observer;
};
%{C++
#define NS_DOWNLOADITEM_CONTRACTID "@mozilla.org/download-manager/item;1"
// {E3FA9D0A-1DD1-11B2-BDEF-8C720B597445}
#define NS_DOWNLOADITEM_CID \
{ 0xe3fa9d0a, 0x1dd1, 0x11b2, { 0xbd, 0xef, 0x8c, 0x72, 0x0b, 0x59, 0x74, 0x45 } }
%}

View File

@@ -44,69 +44,98 @@
interface nsIDOMWindow;
interface nsIURI;
interface nsILocalFile;
interface nsIDownloadItem;
interface nsIDownload;
interface nsIWebBrowserPersist;
[scriptable, uuid(9be66cc0-1dd1-11b2-8617-e3a3ed26e3b0)]
interface nsIDownloadManager : nsISupports {
/**
* addDownload
* Creates (and returns) an nsIDownloadItem with the given properties and adds
* it to the list of downloads being managed by the download manager.
* Creates an nsIDownload and adds it to be managed by the download manager.
*
* @param aSource The source (nsIURI) of the download.
*
* @param aTarget The local file to which the download is being saved.
*
* @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.
*
* @return The newly created download item with the passed-in properties.
*/
nsIDownloadItem addDownload(in nsIURI aURI,
in nsILocalFile aTarget,
in wstring aDisplayName,
in nsIWebBrowserPersist aPersist);
nsIDownload addDownload(in nsIURI aSource,
in nsILocalFile aTarget,
in wstring aDisplayName,
in nsIWebBrowserPersist aPersist);
/**
* getDownload
* Used to retrieve a download managed by the download manager.
* Retrieves an in-progress download managed by the download manager.
*
* @param aPersistentDescriptor The unique identifier used to describe a
* a download, and an attribute of nsILocalFile.
* On Windows and Linux, this is just the path
* of the target, but on Mac this is guaranteed
* to be unique.
*
* @return The download with the specified persistent descriptor.
*/
nsIDownloadItem getDownload(in string persistentDescriptor);
nsIDownload getDownload(in string aPersistentDescriptor);
/**
* cancelDownload
* If a persist is set on the download item, download manager will call
* nsIWebBrowserPersist::CancelSave. Else, if an observer is set on the item
* (it should be), it will be notified with the "oncancel" topic. Callers
* that don't provide a persist object promise to listen for this topic and cancel
* the download.
* Cancels the download with the specified persistent descriptor if it's
* currently in progress. If a "persist" was specified for the download,
* nsIWebBrowserPersist::CancelSave will be called. If an observer was set
* on the nsIDownload, it will be notified with the "oncancel" topic. Clients
* that don't provide a "persist" must listen for this topic and cancel the
* download.
*
* @param aPersistentDescriptor The persistent descriptor of the download to
* be cancelled.
*/
void cancelDownload(in string persistentDescriptor);
void cancelDownload(in string aPersistentDescriptor);
/**
* removeDownload
* Remove a download that is not currently in progress. Whereas cancelDownload simply
* cancels the transfer but retains information about it, removeDownload removes all
* knowledge of it.
* Removes the download with the specified persistent descriptor if it's not
* currently in progress. Whereas cancelDownload simply cancels the transfer
* but retains information about it, removeDownload removes all knowledge of it.
*
* @param aPersistentDescriptor The persistent descriptor of the download to
* be removed.
*/
void removeDownload(in string key);
void removeDownload(in string aPersistentDescriptor);
/**
* open
* Opens the Download Manager front end.
*
* @param aParent The parent, or opener, of the front end (optional).
*/
void open(in nsIDOMWindow aParent);
/**
* openProgressDialogFor
* Opens an individual progress dialog displaying progress for the download.
*
* @param aPersistentDescriptor The persistent descriptor of the download to
* display progress for.
*
* @param aParent The parent, or opener, of the front end (optional).
*/
void openProgressDialogFor(in string persistentDescriptor, in nsIDOMWindow aParent);
void openProgressDialogFor(in string aPersistentDescriptor, in nsIDOMWindow aParent);
/**
* onClose
* Called when the download manager front end is closed. Useful for
* third party managers to let us know when they've closed.
*/
void onClose();
};

View File

@@ -44,6 +44,7 @@ var gDownloadViewChildren = null;
var gDownloadManager = null;
var gRDFService = null;
var gNC_File = null;
var gStatusBar = null;
function NODE_ID(aElement)
{
@@ -84,6 +85,13 @@ function openPropertiesDialog()
gDownloadManager.openProgressDialogFor(selection[0].id, window);
}
function onSelect(aEvent) {
if (!gStatusBar)
gStatusBar = document.getElementById("statusbar-text");
gStatusBar.label = gDownloadView.selectedItems[0].id;
window.updateCommands("tree-select");
}
var downloadViewController = {
supportsCommand: function dVC_supportsCommand (aCommand)
{

View File

@@ -139,7 +139,7 @@
datasources="rdf:null"
seltype="multiple" flags="dont-test-empty"
ondblclick="return goDoCommand('cmd_properties');"
onselect="window.updateCommands('tree-select');"
onselect="onSelect(event);"
style="height: 0px; width: 0px;" flex="1">
<treehead>
@@ -256,7 +256,7 @@
</treecolgroup>
</tree>
<statusbar id="status-bar">
<statusbar id="status-bar" class="chromeclass-status">
<statusbarpanel id="statusbar-text" flex="1"/>
</statusbar>