mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-24 21:58:06 +00:00
Bug 495583 - [SeaMonkey] Remove SUITE_USING_XPFE_DM remnants; r=neil
This commit is contained in:
parent
1edde9da6b
commit
aee7bed953
@ -108,11 +108,9 @@ endif # MOZ_XUL
|
||||
|
||||
endif # MOZ_THUNDERBIRD
|
||||
|
||||
ifndef SUITE_USING_XPFE_DM
|
||||
ifdef MOZ_RDF
|
||||
DIRS += downloads
|
||||
endif
|
||||
endif # SUITE_USING_XPFE_DM
|
||||
|
||||
ifdef MOZ_URL_CLASSIFIER
|
||||
DIRS += url-classifier
|
||||
|
@ -123,11 +123,9 @@ REQUIRES += parentalcontrols
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef SUITE_USING_XPFE_DM
|
||||
ifdef MOZ_RDF
|
||||
SHARED_LIBRARY_LIBS += ../downloads/src/$(LIB_PREFIX)download_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef ALERTS_SERVICE
|
||||
SHARED_LIBRARY_LIBS += ../alerts/src/$(LIB_PREFIX)alerts_s.$(LIB_SUFFIX)
|
||||
|
@ -49,12 +49,10 @@
|
||||
#include "nsAlertsService.h"
|
||||
#endif
|
||||
|
||||
#ifndef SUITE_USING_XPFE_DM
|
||||
#ifdef MOZ_RDF
|
||||
#include "nsDownloadManager.h"
|
||||
#include "nsDownloadProxy.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "nsTypeAheadFind.h"
|
||||
|
||||
@ -83,13 +81,11 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsParentalControlsServiceWin)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAlertsService)
|
||||
#endif
|
||||
|
||||
#ifndef SUITE_USING_XPFE_DM
|
||||
#ifdef MOZ_RDF
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsDownloadManager,
|
||||
nsDownloadManager::GetSingleton)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadProxy)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTypeAheadFind)
|
||||
|
||||
@ -147,7 +143,6 @@ static const nsModuleComponentInfo components[] =
|
||||
NS_PARENTALCONTROLSSERVICE_CONTRACTID,
|
||||
nsParentalControlsServiceWinConstructor },
|
||||
#endif
|
||||
#ifndef SUITE_USING_XPFE_DM
|
||||
#ifdef MOZ_RDF
|
||||
{ "Download Manager",
|
||||
NS_DOWNLOADMANAGER_CID,
|
||||
@ -157,7 +152,6 @@ static const nsModuleComponentInfo components[] =
|
||||
NS_DOWNLOAD_CID,
|
||||
NS_TRANSFER_CONTRACTID,
|
||||
nsDownloadProxyConstructor },
|
||||
#endif
|
||||
#endif
|
||||
{ "TypeAheadFind Component",
|
||||
NS_TYPEAHEADFIND_CID,
|
||||
|
@ -42,12 +42,10 @@ VPATH = @srcdir@
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
ifndef SUITE_USING_XPFE_DM
|
||||
DIRS = src
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += tests
|
||||
endif
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
@ -559,10 +559,6 @@ MAKEFILES_xpfe="
|
||||
xpfe/browser/src/Makefile
|
||||
xpfe/components/Makefile
|
||||
xpfe/components/directory/Makefile
|
||||
xpfe/components/download-manager/Makefile
|
||||
xpfe/components/download-manager/src/Makefile
|
||||
xpfe/components/download-manager/public/Makefile
|
||||
xpfe/components/download-manager/resources/Makefile
|
||||
xpfe/components/find/Makefile
|
||||
xpfe/components/find/public/Makefile
|
||||
xpfe/components/find/src/Makefile
|
||||
|
@ -74,10 +74,6 @@ ifneq (,$(MOZ_THUNDERBIRD)$(MOZ_SUITE)$(MOZ_SUNBIRD))
|
||||
DIRS += autocomplete
|
||||
endif
|
||||
|
||||
ifdef SUITE_USING_XPFE_DM
|
||||
DIRS += download-manager
|
||||
endif
|
||||
|
||||
ifdef MOZ_HAVE_BROWSER
|
||||
DIRS += \
|
||||
directory \
|
||||
|
@ -77,19 +77,6 @@ SHARED_LIBRARY_LIBS += ../../browser/src/$(LIB_PREFIX)mozbrwsr_s.$(LIB_SUFFIX)
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../../browser/src
|
||||
endif
|
||||
|
||||
# Suite xpfe download manager includes
|
||||
ifdef SUITE_USING_XPFE_DM
|
||||
REQUIRES += \
|
||||
downloadmanager \
|
||||
intl \
|
||||
widget \
|
||||
mimetype \
|
||||
$(NULL)
|
||||
|
||||
SHARED_LIBRARY_LIBS += ../download-manager/src/$(LIB_PREFIX)downloadmanager_s.$(LIB_SUFFIX)
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../download-manager/src
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,ole32 shell32)
|
||||
endif
|
||||
|
@ -45,11 +45,6 @@
|
||||
#include "nsRDFCID.h"
|
||||
#endif
|
||||
|
||||
#ifdef SUITE_USING_XPFE_DM
|
||||
#include "nsDownloadManager.h"
|
||||
#include "nsDownloadProxy.h"
|
||||
#endif
|
||||
|
||||
#if !defined(MOZ_MACBROWSER)
|
||||
#include "nsBrowserStatusFilter.h"
|
||||
#include "nsBrowserInstance.h"
|
||||
@ -68,11 +63,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserStatusFilter)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserInstance)
|
||||
#endif
|
||||
|
||||
#ifdef SUITE_USING_XPFE_DM
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDownloadManager, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadProxy)
|
||||
#endif
|
||||
|
||||
static NS_METHOD
|
||||
RegisterProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
@ -117,13 +107,6 @@ static const nsModuleComponentInfo components[] = {
|
||||
nsHTTPIndexConstructor },
|
||||
#endif
|
||||
|
||||
#ifdef SUITE_USING_XPFE_DM
|
||||
{ "Download Manager", NS_DOWNLOADMANAGER_CID, NS_DOWNLOADMANAGER_CONTRACTID,
|
||||
nsDownloadManagerConstructor },
|
||||
{ "Download", NS_DOWNLOAD_CID, NS_TRANSFER_CONTRACTID,
|
||||
nsDownloadProxyConstructor },
|
||||
#endif
|
||||
|
||||
#if !defined(MOZ_MACBROWSER)
|
||||
{ NS_BROWSERSTATUSFILTER_CLASSNAME,
|
||||
NS_BROWSERSTATUSFILTER_CID,
|
||||
|
@ -1,49 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = downloadmanager
|
||||
DIRS = public src resources
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,54 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = downloadmanager
|
||||
|
||||
XPIDLSRCS = nsIDownloadManager.idl \
|
||||
nsIDownloadProgressListener.idl \
|
||||
nsIDownload.idl \
|
||||
nsIProgressDialog.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,136 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsITransfer.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsILocalFile;
|
||||
interface nsIObserver;
|
||||
interface nsICancelable;
|
||||
interface nsIWebProgressListener;
|
||||
interface nsIMIMEInfo;
|
||||
|
||||
/**
|
||||
* Represents a download object.
|
||||
*
|
||||
* @note This object is no longer updated once it enters a completed state.
|
||||
* Completed states are the following:
|
||||
* nsIDownloadManager::DOWNLOAD_FINISHED
|
||||
* nsIDownloadManager::DOWNLOAD_FAILED
|
||||
* nsIDownloadManager::DOWNLOAD_CANCELED
|
||||
*/
|
||||
[scriptable, uuid(974db2c6-fbd2-4de1-8d24-f54ce4f3e8bc)]
|
||||
interface nsIDownload : nsITransfer {
|
||||
|
||||
/**
|
||||
* The target of a download is always a file on the local file system.
|
||||
*/
|
||||
readonly attribute nsILocalFile targetFile;
|
||||
|
||||
/**
|
||||
* The percentage of transfer completed.
|
||||
* If the file size is unknown it'll be -1 here.
|
||||
*/
|
||||
readonly attribute PRInt32 percentComplete;
|
||||
|
||||
/**
|
||||
* The amount of bytes downloaded so far.
|
||||
*/
|
||||
readonly attribute PRUint64 amountTransferred;
|
||||
|
||||
/**
|
||||
* The size of file in bytes.
|
||||
* Unknown size is represented by LL_MAXUINT.
|
||||
*/
|
||||
readonly attribute PRUint64 size;
|
||||
|
||||
/**
|
||||
* The source of the transfer.
|
||||
*/
|
||||
readonly attribute nsIURI source;
|
||||
|
||||
/**
|
||||
* The target of the transfer.
|
||||
*/
|
||||
readonly attribute nsIURI target;
|
||||
|
||||
/**
|
||||
* Object that can be used to cancel the download.
|
||||
* Will be null after the download is finished.
|
||||
*/
|
||||
readonly attribute nsICancelable cancelable;
|
||||
|
||||
/**
|
||||
* The user-readable description of the transfer.
|
||||
*/
|
||||
readonly attribute AString displayName;
|
||||
|
||||
/**
|
||||
* The time a transfer was started.
|
||||
*/
|
||||
readonly attribute long long startTime;
|
||||
|
||||
/**
|
||||
* The speed of the transfer in bytes/sec.
|
||||
*/
|
||||
readonly attribute double speed;
|
||||
|
||||
/**
|
||||
* Optional. If set, it will contain the target's relevant MIME information.
|
||||
* This includes its MIME Type, helper app, and whether that helper should be
|
||||
* executed.
|
||||
*/
|
||||
readonly attribute nsIMIMEInfo MIMEInfo;
|
||||
|
||||
/**
|
||||
* The id of the download that is stored in the database.
|
||||
*/
|
||||
readonly attribute unsigned long id;
|
||||
|
||||
/**
|
||||
* The state of the download.
|
||||
* @see nsIDownloadManager and nsIXPInstallManagerUI
|
||||
*/
|
||||
readonly attribute short state;
|
||||
};
|
||||
|
||||
%{C++
|
||||
// {E3FA9D0A-1DD1-11B2-BDEF-8C720B597445}
|
||||
#define NS_DOWNLOAD_CID \
|
||||
{ 0xe3fa9d0a, 0x1dd1, 0x11b2, { 0xbd, 0xef, 0x8c, 0x72, 0x0b, 0x59, 0x74, 0x45 } }
|
||||
%}
|
@ -1,211 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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>
|
||||
* Ben Goodger <ben@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Keeps track of ongoing downloads, in the form of nsIDownload's.
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
interface nsIURI;
|
||||
interface nsILocalFile;
|
||||
interface nsIDownload;
|
||||
interface nsICancelable;
|
||||
interface nsIMIMEInfo;
|
||||
|
||||
[scriptable, uuid(9cdfcea3-fbe4-4ba1-a0fd-fe273097ddfa)]
|
||||
interface nsIDownloadManager : nsISupports {
|
||||
|
||||
// Methods called by clients to carry out various managing functions
|
||||
|
||||
/**
|
||||
* Creates an nsIDownload and adds it to be managed by the download manager.
|
||||
*
|
||||
* @param aSource The source URI of the transfer. Must not be null.
|
||||
*
|
||||
* @param aTarget The target URI of the transfer. Must not be null.
|
||||
*
|
||||
* @param aDisplayName The user-readable description of the transfer.
|
||||
* Can be empty.
|
||||
*
|
||||
* @param aMIMEInfo The MIME info associated with the target,
|
||||
* including MIME type and helper app when appropriate.
|
||||
* This parameter is optional.
|
||||
*
|
||||
* @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.
|
||||
|
||||
* @return The newly created download item with the passed-in properties.
|
||||
*/
|
||||
nsIDownload addDownload(in nsIURI aSource,
|
||||
in nsIURI aTarget,
|
||||
in AString aDisplayName,
|
||||
in nsIMIMEInfo aMIMEInfo,
|
||||
in PRTime startTime,
|
||||
in nsILocalFile aTempFile,
|
||||
in nsICancelable aCancelable);
|
||||
|
||||
/**
|
||||
* Retrieves an in-progress download managed by the download manager.
|
||||
*
|
||||
* @param aTargetPath A UTF8-encoded path to the target file.
|
||||
*
|
||||
* @return The download with the specified path.
|
||||
*/
|
||||
nsIDownload getDownload(in AUTF8String aTargetPath);
|
||||
|
||||
/**
|
||||
* Cancels the download with the specified target path 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 aTargetPath The target path of the download to
|
||||
* be cancelled.
|
||||
*/
|
||||
void cancelDownload(in AUTF8String aTargetPath);
|
||||
|
||||
/**
|
||||
* Pause a download to allow later resumal. This may or may not close
|
||||
* the network connection. In either case, new data won't be received.
|
||||
*
|
||||
* @param aDownload Download to pause, as returned by getDownload or
|
||||
* addDownload.
|
||||
*
|
||||
* Trying to pause a download that is already paused will throw
|
||||
* NS_ERROR_NOT_AVAILABLE.
|
||||
* NS_ERROR_UNEXPECTED may be thrown to indicate an internal error.
|
||||
* Any exception defined by nsIRequest::Suspend may be thrown.
|
||||
* No other exceptions will be thrown.
|
||||
*/
|
||||
void pauseDownload(in nsIDownload aDownload);
|
||||
|
||||
/**
|
||||
* Resume a previously paused download.
|
||||
* @param aTargetPath Target path of the download to be resumed.
|
||||
*
|
||||
* @throws NS_ERROR_NOT_RESUMABLE If resuming is not supported for this
|
||||
* entity, or if the entity has changed since
|
||||
* the download was paused
|
||||
* @throws NS_ERROR_NOT_AVAILABLE If no such download exists, or if the
|
||||
* download was not paused, or if the
|
||||
* download is finished already.
|
||||
* In addition, this may throw NS_ERROR_OUT_OF_MEMORY, or any error defined by
|
||||
* nsIResumableChannel::setEntityID, nsIResumableChannel::asyncOpenAt,
|
||||
* nsIRequest::Resume, or nsIIOService::newChannel.
|
||||
* Also, NS_ERROR_UNEXPECTED may be thrown to indicate an internal error.
|
||||
*/
|
||||
void resumeDownload(in AUTF8String aTargetPath);
|
||||
|
||||
/**
|
||||
* Removes the download with the specified target path 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 aTargetPath The target path of the download to
|
||||
* be removed.
|
||||
*/
|
||||
void removeDownload(in AUTF8String aTargetPath);
|
||||
|
||||
// UI-related methods
|
||||
|
||||
/**
|
||||
* Opens the Download Manager front end.
|
||||
*
|
||||
* @param aParent The parent, or opener, of the front end (optional).
|
||||
* @param aDownload A download to pass to the manager window. Useful
|
||||
* if, for example, you want the window to select a
|
||||
* certain download (optional).
|
||||
*/
|
||||
void open(in nsIDOMWindow aParent, in nsIDownload aDownload);
|
||||
|
||||
/**
|
||||
* Opens an individual progress dialog displaying progress for the download.
|
||||
*
|
||||
* @param aDownload The download object to display progress for, as returned
|
||||
* by getDownload or addDownload.
|
||||
*
|
||||
* @param aParent The parent, or opener, of the front end (optional).
|
||||
*
|
||||
* @param aCancelDownloadOnClose Whether closing the dialog
|
||||
* should cancel the download.
|
||||
*/
|
||||
|
||||
void openProgressDialogFor(in nsIDownload aDownload,
|
||||
in nsIDOMWindow aParent,
|
||||
in boolean aCancelDownloadOnClose);
|
||||
|
||||
/**
|
||||
* Called when the download manager front end is closed. Useful for
|
||||
* third party managers to let us know when they've closed.
|
||||
*/
|
||||
|
||||
void onClose();
|
||||
|
||||
/**
|
||||
* Indicate that a batch update (e.g. mass removal) is about to start.
|
||||
*/
|
||||
|
||||
void startBatchUpdate();
|
||||
|
||||
/**
|
||||
* Indicate that a batch update is ending.
|
||||
*/
|
||||
|
||||
void endBatchUpdate();
|
||||
};
|
||||
|
||||
|
||||
%{C++
|
||||
#define NS_DOWNLOADMANAGER_CONTRACTID "@mozilla.org/download-manager;1"
|
||||
#define NS_DOWNLOADMANAGER_CLASSNAME "Mozilla Download Manager"
|
||||
// {EDB0490E-1DD1-11B2-83B8-DBF8D85906A6}
|
||||
#define NS_DOWNLOADMANAGER_CID \
|
||||
{ 0xedb0490e, 0x1dd1, 0x11b2, { 0x83, 0xb8, 0xdb, 0xf8, 0xd8, 0x59, 0x06, 0xa6 } }
|
||||
%}
|
@ -1,95 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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 of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* A minimally extended progress listener used by download manager
|
||||
* to update its default UI. This is implemented in nsDownloadProgressListener.js.
|
||||
* See nsIWebProgressListener for documentation, and use its constants. This isn't
|
||||
* too pretty, but the alternative is having this extend nsIWebProgressListener and
|
||||
* adding an |item| attribute, which would mean a separate nsIDownloadProgressListener
|
||||
* for every nsIDownloadItem, which is a waste...
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIWebProgress;
|
||||
interface nsIRequest;
|
||||
interface nsIURI;
|
||||
interface nsIDownload;
|
||||
interface nsIDOMDocument;
|
||||
|
||||
[scriptable, uuid(c7e22278-53a7-49d9-999f-0e7861738b50)]
|
||||
interface nsIDownloadProgressListener : nsISupports {
|
||||
|
||||
/**
|
||||
* document
|
||||
* The document of the download manager frontend.
|
||||
*/
|
||||
|
||||
attribute nsIDOMDocument document;
|
||||
|
||||
void onStateChange(in nsIWebProgress aWebProgress,
|
||||
in nsIRequest aRequest,
|
||||
in unsigned long aStateFlags,
|
||||
in nsresult aStatus,
|
||||
in nsIDownload aDownload);
|
||||
|
||||
void onProgressChange(in nsIWebProgress aWebProgress,
|
||||
in nsIRequest aRequest,
|
||||
in long long aCurSelfProgress,
|
||||
in long long aMaxSelfProgress,
|
||||
in long long aCurTotalProgress,
|
||||
in long long aMaxTotalProgress,
|
||||
in nsIDownload aDownload);
|
||||
|
||||
void onStatusChange(in nsIWebProgress aWebProgress,
|
||||
in nsIRequest aRequest,
|
||||
in nsresult aStatus,
|
||||
in wstring aMessage,
|
||||
in nsIDownload aDownload);
|
||||
|
||||
void onLocationChange(in nsIWebProgress aWebProgress,
|
||||
in nsIRequest aRequest,
|
||||
in nsIURI aLocation,
|
||||
in nsIDownload aDownload);
|
||||
|
||||
void onSecurityChange(in nsIWebProgress aWebProgress,
|
||||
in nsIRequest aRequest,
|
||||
in unsigned long aState,
|
||||
in nsIDownload aDownload);
|
||||
|
||||
};
|
@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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):
|
||||
* Bill Law law@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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDownload.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
interface nsIObserver;
|
||||
|
||||
/* nsIProgressDialog
|
||||
*
|
||||
* These objects are used to display progress notifications to the user.
|
||||
* They are displayed while files are being saved to disk, for example.
|
||||
*
|
||||
* Typical usage is to:
|
||||
* 1. Create an instance, via the component manager CreateInstance()
|
||||
* method.
|
||||
* 2. Set appropriate attributes that control the display and behavior
|
||||
* of the dialog.
|
||||
* 3. Open the dialog.
|
||||
* 4. Send progress notifications to the dialog, via its
|
||||
* nsIDownloadProgressListener methods.
|
||||
* 5. Close the dialog when the operation completes, or when the user
|
||||
* closes it manually.
|
||||
* 6. Release the instance. The instance will be referenced by
|
||||
* the dialog itself, so it won't get freed until the dialog closes.
|
||||
* The dialog will keep the instance alive, so typically one does
|
||||
* not need to hold a reference to it.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(20e790a2-76c6-462d-851a-22ab6cbbe48b)]
|
||||
interface nsIProgressDialog : nsIDownload {
|
||||
/**
|
||||
* Open the dialog
|
||||
*
|
||||
* @param aParent Parent window; optional (if null, then
|
||||
* a top-level window is created)
|
||||
*/
|
||||
void open( in nsIDOMWindow aParent );
|
||||
|
||||
/**
|
||||
* Whether the download should be cancelled when the progress
|
||||
* dialog is closed using the standard OS close box. This is
|
||||
* useful for showing the progress dialog as an information
|
||||
* window, which is what download manager does.
|
||||
*/
|
||||
attribute PRBool cancelDownloadOnClose;
|
||||
|
||||
/**
|
||||
* Observer for this dialog. If set, receives the following topics:
|
||||
* oncancel - observer should cancel the transfer
|
||||
* onpause - observer should suspend the transfer
|
||||
* onresume - observer should resume the suspended transfer
|
||||
* For each of those, the subject will be the nsIProgressDialog.
|
||||
*/
|
||||
attribute nsIObserver observer;
|
||||
|
||||
/**
|
||||
* The dialog object itself. This might be null if the dialog isn't
|
||||
* open yet, or has been closed.
|
||||
*/
|
||||
attribute nsIDOMWindow dialog;
|
||||
};
|
||||
|
||||
|
@ -1,50 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
DIRS = mac
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,462 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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):
|
||||
* Ben Goodger <ben@netscape.com> (Original Author)
|
||||
* Blake Ross <blakeross@telocity.com>
|
||||
* Jan Varga <varga@ku.sk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const NC_NS = "http://home.netscape.com/NC-rdf#";
|
||||
|
||||
var gDownloadView = null;
|
||||
var gDownloadManager = null;
|
||||
var gRDFService = null;
|
||||
var gNC_File = null;
|
||||
var gFileHandler = null;
|
||||
var gStatusBar = null;
|
||||
var gCannotLaunch = ((navigator.platform.indexOf("Win") == -1) &&
|
||||
(navigator.platform.indexOf("OS/2") == -1) &&
|
||||
(navigator.platform.indexOf("Mac") == -1) &&
|
||||
(navigator.platform.indexOf("BeOS") == -1));
|
||||
|
||||
const dlObserver = {
|
||||
observe: function(subject, topic, state) {
|
||||
if (topic != "download-starting") return;
|
||||
selectDownload(subject.QueryInterface(Components.interfaces.nsIDownload));
|
||||
}
|
||||
};
|
||||
|
||||
function selectDownload(aDownload)
|
||||
{
|
||||
var dlElt = document.getElementById(aDownload.targetFile.path);
|
||||
var dlIndex = gDownloadView.contentView.getIndexOfItem(dlElt);
|
||||
gDownloadView.view.selection.select(dlIndex);
|
||||
gDownloadView.treeBoxObject.ensureRowIsVisible(dlIndex);
|
||||
}
|
||||
|
||||
function DLManagerStartup()
|
||||
{
|
||||
if (!window.arguments.length)
|
||||
return;
|
||||
|
||||
try {
|
||||
var observerService = Components.classes[kObserverServiceProgID]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
observerService.addObserver(dlObserver, "download-starting", false);
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
const rdfSvcContractID = "@mozilla.org/rdf/rdf-service;1";
|
||||
const rdfSvcIID = Components.interfaces.nsIRDFService;
|
||||
gRDFService = Components.classes[rdfSvcContractID].getService(rdfSvcIID);
|
||||
|
||||
gNC_File = gRDFService.GetResource(NC_NS + "File");
|
||||
|
||||
gDownloadView = document.getElementById("downloadView");
|
||||
setSortVariables(gDownloadView);
|
||||
|
||||
const dlmgrContractID = "@mozilla.org/download-manager;1";
|
||||
const dlmgrIID = Components.interfaces.nsIDownloadManager;
|
||||
gDownloadManager = Components.classes[dlmgrContractID].getService(dlmgrIID);
|
||||
|
||||
const ioSvcContractID = "@mozilla.org/network/io-service;1";
|
||||
const ioSvcIID = Components.interfaces.nsIIOService;
|
||||
var ioService = Components.classes[ioSvcContractID].getService(ioSvcIID);
|
||||
|
||||
const fileHandlerIID = Components.interfaces.nsIFileProtocolHandler;
|
||||
gFileHandler = ioService.getProtocolHandler("file")
|
||||
.QueryInterface(fileHandlerIID);
|
||||
|
||||
var ds = window.arguments[0];
|
||||
gDownloadView.database.AddDataSource(ds);
|
||||
gDownloadView.builder.rebuild();
|
||||
window.setTimeout(onRebuild, 0);
|
||||
|
||||
// correct keybinding command attributes which don't do our business yet
|
||||
var key = document.getElementById("key_delete");
|
||||
if (key.getAttribute("command"))
|
||||
key.setAttribute("command", "cmd_remove");
|
||||
key = document.getElementById("key_delete2");
|
||||
if (key.getAttribute("command"))
|
||||
key.setAttribute("command", "cmd_remove");
|
||||
|
||||
document.getElementById("btn_openfile").hidden = gCannotLaunch;
|
||||
document.getElementById("downloadPaneContext-openfile").hidden = gCannotLaunch;
|
||||
}
|
||||
|
||||
function onRebuild() {
|
||||
gDownloadView.controllers.appendController(downloadViewController);
|
||||
gDownloadView.focus();
|
||||
|
||||
// If the window was opened automatically because
|
||||
// a download started, select the new download
|
||||
if (window.arguments.length > 1 && window.arguments[1]) {
|
||||
var dl = window.arguments[1];
|
||||
selectDownload(dl.QueryInterface(Components.interfaces.nsIDownload));
|
||||
}
|
||||
else if (gDownloadView.view && gDownloadView.view.rowCount > 0) {
|
||||
// Select the first item in the view, if any.
|
||||
gDownloadView.view.selection.select(0);
|
||||
}
|
||||
}
|
||||
|
||||
function onSelect(aEvent) {
|
||||
if (!gStatusBar)
|
||||
gStatusBar = document.getElementById("statusbar-text");
|
||||
|
||||
var selectionCount = gDownloadView.view.selection.count;
|
||||
if (selectionCount == 1)
|
||||
gStatusBar.label = createLocalFile(getSelectedItem().id).path;
|
||||
else
|
||||
gStatusBar.label = "";
|
||||
|
||||
window.updateCommands("tree-select");
|
||||
}
|
||||
|
||||
function onTrigger() {
|
||||
if (downloadViewController.isCommandEnabled('cmd_properties'))
|
||||
goDoCommand('cmd_properties');
|
||||
else if (downloadViewController.isCommandEnabled('cmd_openfile'))
|
||||
goDoCommand('cmd_openfile');
|
||||
else if (downloadViewController.isCommandEnabled('cmd_showinshell'))
|
||||
goDoCommand('cmd_showinshell');
|
||||
}
|
||||
|
||||
var downloadViewController = {
|
||||
supportsCommand: function dVC_supportsCommand (aCommand)
|
||||
{
|
||||
switch (aCommand) {
|
||||
case "cmd_properties":
|
||||
case "cmd_pause":
|
||||
case "cmd_cancel":
|
||||
case "cmd_remove":
|
||||
case "cmd_copyurl":
|
||||
case "cmd_openfile":
|
||||
case "cmd_showinshell":
|
||||
case "cmd_selectAll":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
isCommandEnabled: function dVC_isCommandEnabled (aCommand)
|
||||
{
|
||||
if (!gDownloadView.view || !gDownloadView.view.selection) return false;
|
||||
var selectionCount = gDownloadView.view.selection.count;
|
||||
if (!selectionCount) return false;
|
||||
|
||||
var selectedItem = getSelectedItem();
|
||||
var isDownloading = selectedItem && gDownloadManager.getDownload(selectedItem.id);
|
||||
|
||||
switch (aCommand) {
|
||||
case "cmd_openfile":
|
||||
if (gCannotLaunch)
|
||||
return false;
|
||||
case "cmd_showinshell":
|
||||
// we can't reveal until the download is complete, because we have not given
|
||||
// the file its final name until them.
|
||||
return selectionCount == 1 && !isDownloading && selectedItem &&
|
||||
createLocalFile(selectedItem.id).exists();
|
||||
case "cmd_properties":
|
||||
return selectionCount == 1 && isDownloading;
|
||||
case "cmd_pause":
|
||||
return false;
|
||||
case "cmd_cancel":
|
||||
// XXX check if selection is still in progress
|
||||
// how to handle multiple selection?
|
||||
return isDownloading;
|
||||
case "cmd_remove":
|
||||
// XXX ensure selection isn't still in progress
|
||||
// and how to handle multiple selection?
|
||||
return selectionCount > 0 && !isDownloading;
|
||||
case "cmd_copyurl":
|
||||
return selectionCount > 0;
|
||||
case "cmd_selectAll":
|
||||
return gDownloadView.view.rowCount != selectionCount;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function dVC_doCommand (aCommand)
|
||||
{
|
||||
var selectedItem, selectedItems;
|
||||
var file, i;
|
||||
|
||||
switch (aCommand) {
|
||||
case "cmd_properties":
|
||||
selectedItem = getSelectedItem();
|
||||
var dl;
|
||||
if (selectedItem)
|
||||
dl = gDownloadManager.getDownload(selectedItem.id);
|
||||
if (dl)
|
||||
gDownloadManager.openProgressDialogFor(dl, window, false);
|
||||
break;
|
||||
case "cmd_openfile":
|
||||
selectedItem = getSelectedItem();
|
||||
if (selectedItem) {
|
||||
file = createLocalFile(selectedItem.id);
|
||||
const kDontAskAgainPref = "browser.download.progressDnlgDialog.dontAskForLaunch";
|
||||
try {
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var dontAskAgain = pref.getBoolPref(kDontAskAgainPref);
|
||||
} catch (e) {
|
||||
// dontAskAgain not set - then we need to ask user
|
||||
dontAskAgain = false;
|
||||
}
|
||||
if (!dontAskAgain && file.isExecutable()) {
|
||||
try {
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
} catch (ex) {
|
||||
break;
|
||||
}
|
||||
var strBundle = document.getElementById("dlProgressDlgBundle");
|
||||
var title = strBundle.getFormattedString("openingAlertTitle", [file.leafName]);
|
||||
var msg = strBundle.getFormattedString("securityAlertMsg", [file.leafName]);
|
||||
var dontaskmsg = strBundle.getString("dontAskAgain");
|
||||
var checkbox = {value:0};
|
||||
var okToProceed = promptService.confirmCheck(window, title, msg, dontaskmsg, checkbox);
|
||||
try {
|
||||
if (checkbox.value != dontAskAgain)
|
||||
pref.setBoolPref(kDontAskAgainPref, checkbox.value);
|
||||
} catch (ex) {}
|
||||
if (!okToProceed)
|
||||
return;
|
||||
}
|
||||
file.launch();
|
||||
}
|
||||
break;
|
||||
case "cmd_showinshell":
|
||||
selectedItem = getSelectedItem();
|
||||
if (selectedItem) {
|
||||
file = createLocalFile(selectedItem.id);
|
||||
|
||||
// on unix, open a browser window rooted at the parent
|
||||
if ((navigator.platform.indexOf("Win") == -1) &&
|
||||
(navigator.platform.indexOf("Mac") == -1) &&
|
||||
(navigator.platform.indexOf("OS/2") == -1) &&
|
||||
(navigator.platform.indexOf("BeOS") == -1)) {
|
||||
var parent = file.parent;
|
||||
if (parent) {
|
||||
const browserURL = "chrome://navigator/content/navigator.xul";
|
||||
window.openDialog(browserURL, "_blank", "chrome,all,dialog=no", parent.path);
|
||||
}
|
||||
}
|
||||
else {
|
||||
file.reveal();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "cmd_pause":
|
||||
break;
|
||||
case "cmd_cancel":
|
||||
// XXX we should probably prompt the user
|
||||
selectedItems = getSelectedItems();
|
||||
for (i = 0; i < selectedItems.length; i++)
|
||||
gDownloadManager.cancelDownload(selectedItems[i].id);
|
||||
window.updateCommands("tree-select");
|
||||
break;
|
||||
case "cmd_remove":
|
||||
selectedItems = getSelectedItems();
|
||||
// Figure out where to place the selection after deletion
|
||||
var newSelectionPos = gDownloadView.contentView.getIndexOfItem(selectedItems[0]);
|
||||
gDownloadManager.startBatchUpdate();
|
||||
|
||||
// Notify the datasource that we're about to begin a batch operation
|
||||
var ds = window.arguments[0]
|
||||
.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
ds.beginUpdateBatch();
|
||||
for (i = 0; i <= selectedItems.length - 1; ++i) {
|
||||
gDownloadManager.removeDownload(selectedItems[i].id);
|
||||
}
|
||||
ds.endUpdateBatch();
|
||||
|
||||
gDownloadManager.endBatchUpdate();
|
||||
// If there's nothing on the panel now, skip setting the selection
|
||||
if (gDownloadView.treeBoxObject.view && gDownloadView.treeBoxObject.view.rowCount > 0) {
|
||||
// Select the item that replaced the first deleted one
|
||||
if (newSelectionPos >= gDownloadView.treeBoxObject.view.rowCount)
|
||||
newSelectionPos = gDownloadView.treeBoxObject.view.rowCount - 1;
|
||||
gDownloadView.view.selection.select(newSelectionPos);
|
||||
gDownloadView.treeBoxObject.ensureRowIsVisible(newSelectionPos);
|
||||
gStatusBar.label = createLocalFile(getSelectedItem().id).path;
|
||||
}
|
||||
else {
|
||||
// Nothing on the panel, so clear the Status Bar
|
||||
gStatusBar.label = "";
|
||||
}
|
||||
window.updateCommands("tree-select");
|
||||
break;
|
||||
case "cmd_selectAll":
|
||||
gDownloadView.view.selection.selectAll();
|
||||
break;
|
||||
case "cmd_copyurl":
|
||||
selectedItems = getSelectedItems();
|
||||
if (selectedItems.length > 0) {
|
||||
gStatusBar.label = copyToClipboard(selectedItems);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function dVC_onEvent (aEvent)
|
||||
{
|
||||
switch (aEvent) {
|
||||
case "tree-select":
|
||||
this.onCommandUpdate();
|
||||
}
|
||||
},
|
||||
|
||||
onCommandUpdate: function dVC_onCommandUpdate ()
|
||||
{
|
||||
var cmds = ["cmd_properties", "cmd_pause", "cmd_cancel", "cmd_remove",
|
||||
"cmd_copyurl", "cmd_openfile", "cmd_showinshell"];
|
||||
for (var command in cmds)
|
||||
goUpdateCommand(cmds[command]);
|
||||
}
|
||||
};
|
||||
|
||||
function getSelectedItem()
|
||||
{
|
||||
if (gDownloadView.currentIndex != -1)
|
||||
return gDownloadView.contentView.getItemAtIndex(gDownloadView.currentIndex);
|
||||
return null;
|
||||
}
|
||||
|
||||
function getSelectedItems()
|
||||
{
|
||||
var items = [];
|
||||
var k = 0;
|
||||
|
||||
var selection = gDownloadView.view.selection;
|
||||
var rangeCount = selection.getRangeCount();
|
||||
for (var i = 0; i < rangeCount; i++) {
|
||||
var startIndex = {};
|
||||
var endIndex = {};
|
||||
selection.getRangeAt(i, startIndex, endIndex);
|
||||
for (var j = startIndex.value; j <= endIndex.value; j++)
|
||||
items[k++] = gDownloadView.contentView.getItemAtIndex(j);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
function createLocalFile(aFilePath)
|
||||
{
|
||||
const lfIID = Components.interfaces.nsILocalFile;
|
||||
// XXXvarga We should fix the download manager to be consistent, that is,
|
||||
// use urls instead of local paths when adding new items to the list.
|
||||
// Once it's fixed, the code below can be removed.
|
||||
// See bug 208113 for more details.
|
||||
|
||||
var file;
|
||||
if (aFilePath.substring(0,5) == 'file:') {
|
||||
file = gFileHandler.getFileFromURLSpec(aFilePath)
|
||||
.QueryInterface(lfIID);
|
||||
}
|
||||
else {
|
||||
const lfContractID = "@mozilla.org/file/local;1";
|
||||
file = Components.classes[lfContractID].createInstance(lfIID);
|
||||
file.initWithPath(aFilePath);
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
function DLManagerShutdown()
|
||||
{
|
||||
try {
|
||||
var observerService = Components.classes[kObserverServiceProgID]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
observerService.removeObserver(dlObserver, "download-starting");
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
}
|
||||
|
||||
function setSortVariables(tree)
|
||||
{
|
||||
var node;
|
||||
for (node = document.getElementById("Name"); node; node = node.nextSibling) {
|
||||
if (node.getAttribute("sortActive") == "true")
|
||||
break;
|
||||
}
|
||||
if (!node) {
|
||||
node = document.getElementById("Progress");
|
||||
node.setAttribute("sortActive", "true");
|
||||
node.setAttribute("sortDirection", "descending");
|
||||
}
|
||||
|
||||
tree.setAttribute("sortActive", "true");
|
||||
tree.setAttribute("sortDirection", node.getAttribute("sortDirection"));
|
||||
tree.setAttribute("sortResource", node.getAttribute("resource"));
|
||||
}
|
||||
|
||||
function doSort(node)
|
||||
{
|
||||
if (node.localName != "treecol")
|
||||
return;
|
||||
|
||||
var sortResource = node.getAttribute("resource");
|
||||
|
||||
var sortDirection = node.getAttribute("sortDirection");
|
||||
sortDirection = sortDirection == "ascending" ? "descending" : "ascending";
|
||||
|
||||
try {
|
||||
var sortService = Components.classes["@mozilla.org/xul/xul-sort-service;1"]
|
||||
.getService(Components.interfaces.nsIXULSortService);
|
||||
sortService.sort(node, sortResource, sortDirection);
|
||||
}
|
||||
catch(ex) {
|
||||
}
|
||||
}
|
||||
|
||||
function copyToClipboard(selectedItems)
|
||||
{
|
||||
var urlArray = new Array(selectedItems.length);
|
||||
for (var i = 0; i < selectedItems.length; ++i) {
|
||||
urlArray[i] = selectedItems[i].firstChild.lastChild.getAttribute("label");
|
||||
}
|
||||
|
||||
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
||||
.getService(Components.interfaces.nsIClipboardHelper);
|
||||
clipboardHelper.copyString(urlArray.join("\n"));
|
||||
|
||||
return urlArray.join(" "); // for status text
|
||||
}
|
@ -1,267 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla 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/MPL/
|
||||
|
||||
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):
|
||||
Ben Goodger <ben@netscape.com> (Original Author)
|
||||
Blake Ross <blaker@netscape.com>
|
||||
Jan Varga <varga@ku.sk>
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % downloadManagerDTD SYSTEM "chrome://communicator/locale/downloadmanager/downloadmanager.dtd">
|
||||
%downloadManagerDTD;
|
||||
<!ENTITY % downloadProgressDTD SYSTEM "chrome://global/locale/nsProgressDialog.dtd" >
|
||||
%downloadProgressDTD;
|
||||
]>
|
||||
|
||||
<window id="downloadManager"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
windowtype="Download:Manager"
|
||||
width="500" height="300" screenX="10" screenY="10"
|
||||
persist="width height screenX screenY"
|
||||
title="&downloadManager.title;"
|
||||
onload="DLManagerStartup();"
|
||||
onunload="DLManagerShutdown();">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/downloadmanager/downloadmanager.js"/>
|
||||
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="dlMgrBundle"
|
||||
src="chrome://communicator/locale/downloadmanager/downloadmanager.properties"/>
|
||||
<stringbundle id="dlProgressDlgBundle"
|
||||
src="chrome://global/locale/nsProgressDialog.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
<data id="strings.confirmCancel">&confirmCancel;</data>
|
||||
<data id="strings.progressMsgNoRate">&progressMsgNoRate;</data>
|
||||
<data id="strings.rateMsg">&rateMsg;</data>
|
||||
<data id="strings.completeMsg">&completeMsg;</data>
|
||||
<data id="strings.percentMsg">&percentMsg;</data>
|
||||
<data id="strings.shortTimeFormat">&shortTimeFormat;</data>
|
||||
<data id="strings.longTimeFormat">&longTimeFormat;</data>
|
||||
<data id="strings.unknownTime">&unknownTime;</data>
|
||||
<data id="strings.pausedMsg">&pausedMsg;</data>
|
||||
|
||||
<commandset id="commands">
|
||||
<commandset id="commandUpdate_Downloads"
|
||||
commandupdater="true"
|
||||
events="focus,tree-select"
|
||||
oncommandupdate="downloadViewController.onCommandUpdate()"/>
|
||||
|
||||
<commandset id="downloadCommands">
|
||||
<command id="cmd_properties"
|
||||
oncommand="goDoCommand('cmd_properties');"/>
|
||||
<command id="cmd_pause"
|
||||
oncommand="goDoCommand('cmd_pause');"/>
|
||||
<command id="cmd_cancel"
|
||||
oncommand="goDoCommand('cmd_cancel');"/>
|
||||
<command id="cmd_remove"
|
||||
oncommand="goDoCommand('cmd_remove');"/>
|
||||
<command id="cmd_copyurl"
|
||||
oncommand="goDoCommand('cmd_copyurl');"/>
|
||||
<command id="cmd_openfile"
|
||||
oncommand="goDoCommand('cmd_openfile');"/>
|
||||
<command id="cmd_showinshell"
|
||||
oncommand="goDoCommand('cmd_showinshell');"/>
|
||||
</commandset>
|
||||
|
||||
<!-- File Menu -->
|
||||
<command id="cmd_newNavigator"/>
|
||||
<command id="cmd_close" oncommand="close()"/>
|
||||
<command id="cmd_quit"/>
|
||||
|
||||
</commandset>
|
||||
|
||||
<broadcasterset id="navBroadcasters"/>
|
||||
|
||||
<keyset id="tasksKeys">
|
||||
<!-- File Menu -->
|
||||
<key id="key_newNavigator"/>
|
||||
<key id="key_close"/>
|
||||
<key id="key_quit"/>
|
||||
|
||||
<!-- These keybindings do not have a command specified in the overlay,
|
||||
which is good, but we need to specify it ourselves here -->
|
||||
<key id="key_selectAll" command="cmd_selectAll"/>
|
||||
|
||||
<!-- These keybindings do have a command specified in the overlay,
|
||||
which we need to correct in our DLManagerStartup() function -->
|
||||
<key id="key_delete"/>
|
||||
<key id="key_delete2"/>
|
||||
|
||||
<key id="key_properties" key="&cmd.properties.keybinding;"
|
||||
command="cmd_properties" modifiers="accel"/>
|
||||
|
||||
<key id="key_copy" command="cmd_copyurl"/>
|
||||
</keyset>
|
||||
|
||||
<popup id="downloadPaneContext">
|
||||
<menuitem id="downloadPaneContext-properties"
|
||||
label="&cmd.properties.label;"
|
||||
accesskey="&cmd.properties.accesskey;"
|
||||
command="cmd_properties"/>
|
||||
<menuseparator id="downloadPaneContext-sep1"/>
|
||||
<menuitem id="downloadPaneContext-cancel"
|
||||
label="&cmd.cancel.label;"
|
||||
accesskey="&cmd.cancel.accesskey;"
|
||||
command="cmd_cancel"/>
|
||||
<menuitem id="downloadPaneContext-remove"
|
||||
label="&cmd.remove.label;"
|
||||
accesskey="&cmd.remove.accesskey;"
|
||||
command="cmd_remove"/>
|
||||
<menuitem id="downloadPaneContext-copyurl"
|
||||
label="&cmd.copyurl.label;"
|
||||
accesskey="&cmd.copyurl.accesskey;"
|
||||
command="cmd_copyurl"/>
|
||||
<menuseparator id="downloadPaneContext-sep2"/>
|
||||
<menuitem id="downloadPaneContext-openfile"
|
||||
label="&cmd.openfile.label;"
|
||||
accesskey="&cmd.openfile.accesskey;"
|
||||
command="cmd_openfile"/>
|
||||
<menuitem id="downloadPaneContext-showinshell"
|
||||
label="&cmd.showinshell.label;"
|
||||
accesskey="&cmd.showinshell.accesskey;"
|
||||
command="cmd_showinshell"/>
|
||||
</popup>
|
||||
|
||||
<toolbox id="toolbox">
|
||||
<toolbar id="download-toolbar" class="chromeclass-toolbar" persist="collapsed" grippytooltiptext="&dm.tooltip;">
|
||||
<toolbarbutton label="&cmd.properties.label;" accesskey="&cmd.properties.accesskey;"
|
||||
command="cmd_properties"/>
|
||||
<toolbarseparator/>
|
||||
<toolbarbutton label="&cmd.cancel.label;" accesskey="&cmd.cancel.accesskey;"
|
||||
command="cmd_cancel"/>
|
||||
<toolbarbutton label="&cmd.remove.label;" accesskey="&cmd.remove.accesskey;"
|
||||
command="cmd_remove"/>
|
||||
<toolbarbutton id="btn_copyurl" label="&cmd.copyurl.label;" accesskey="&cmd.copyurl.accesskey;"
|
||||
command="cmd_copyurl"/>
|
||||
<toolbarseparator/>
|
||||
<toolbarbutton id="btn_openfile" label="&cmd.openfile.label;" accesskey="&cmd.openfile.accesskey;"
|
||||
command="cmd_openfile"/>
|
||||
<toolbarbutton id="btn_showinshell" label="&cmd.showinshell.label;" accesskey="&cmd.showinshell.accesskey;"
|
||||
command="cmd_showinshell"/>
|
||||
</toolbar>
|
||||
</toolbox>
|
||||
|
||||
<tree id="downloadView" flex="1" class="plain" context="downloadPaneContext"
|
||||
datasources="rdf:null" ref="NC:DownloadsRoot" flags="dont-test-empty"
|
||||
enableColumnDrag="true" onselect="onSelect(event);"
|
||||
ondblclick="if (event.button == 0) onTrigger();"
|
||||
onkeypress="if ((event.keyCode == KeyEvent.DOM_VK_RETURN) ||
|
||||
(event.keyCode == KeyEvent.DOM_VK_ENTER)) onTrigger();">
|
||||
<treecols onclick="doSort(event.target)">
|
||||
<treecol id="Name" primary="true"
|
||||
label="&view.header.name.label;"
|
||||
class="sortDirectionIndicator" width="3*" flex="3"
|
||||
resource="http://home.netscape.com/NC-rdf#Name"
|
||||
persist="width sortActive sortDirection ordinal"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="Progress" type="progressmeter"
|
||||
label="&view.header.progress.label;"
|
||||
class="sortDirectionIndicator" width="3*" flex="3"
|
||||
resource="http://home.netscape.com/NC-rdf#ProgressPercent"
|
||||
persist="width hidden sortActive sortDirection ordinal"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="ProgressPercent" hidden="true"
|
||||
label="&view.header.progresstext.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
resource="http://home.netscape.com/NC-rdf#ProgressPercent"
|
||||
persist="width hidden sortActive sortDirection ordinal"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="TimeRemaining"
|
||||
label="&view.header.timeremaining.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
resource="http://home.netscape.com/NC-rdf#TimeRemaining"
|
||||
persist="width hidden sortActive sortDirection ordinal"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="Transferred"
|
||||
label="&view.header.transferred.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
resource="http://home.netscape.com/NC-rdf#Transferred"
|
||||
persist="width hidden sortActive sortDirection ordinal"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="TransferRate"
|
||||
label="&view.header.transferrate.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
resource="http://home.netscape.com/NC-rdf#TransferRate"
|
||||
persist="width hidden sortActive sortDirection ordinal"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="TimeElapsed" hidden="true"
|
||||
label="&view.header.timeelapsed.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
resource="http://home.netscape.com/NC-rdf#TimeElapsed"
|
||||
persist="width hidden sortActive sortDirection ordinal"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="Source" hidden="true"
|
||||
label="&view.header.source.label;"
|
||||
class="sortDirectionIndicator" width="1*" flex="1"
|
||||
resource="http://home.netscape.com/NC-rdf#URL"
|
||||
persist="width hidden sortActive sortDirection ordinal"/>
|
||||
</treecols>
|
||||
<template>
|
||||
<rule>
|
||||
<treechildren>
|
||||
<treeitem uri="rdf:*">
|
||||
<treerow>
|
||||
<treecell src="moz-icon:rdf:http://home.netscape.com/NC-rdf#File"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
<treecell mode="rdf:http://home.netscape.com/NC-rdf#ProgressMode"
|
||||
value="rdf:http://home.netscape.com/NC-rdf#ProgressPercent"
|
||||
label="rdf:http://home.netscape.com/NC-rdf#StatusText"/>
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#ProgressPercent"/>
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#TimeRemaining"/>
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#Transferred"/>
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#TransferRate"/>
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#TimeElapsed"/>
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#URL"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</rule>
|
||||
</template>
|
||||
</tree>
|
||||
|
||||
<statusbar id="status-bar" class="chromeclass-status">
|
||||
<statusbarpanel id="statusbar-text" label="" flex="1"/>
|
||||
</statusbar>
|
||||
|
||||
</window>
|
@ -1,7 +0,0 @@
|
||||
comm.jar:
|
||||
content/communicator/downloadmanager/downloadmanager.xul
|
||||
content/communicator/downloadmanager/downloadmanager.js
|
||||
|
||||
en-US.jar:
|
||||
locale/en-US/communicator/downloadmanager/downloadmanager.dtd (locale/en-US/downloadmanager.dtd)
|
||||
locale/en-US/communicator/downloadmanager/downloadmanager.properties (locale/en-US/downloadmanager.properties)
|
@ -1,31 +0,0 @@
|
||||
<!ENTITY view.header.name.label "Name">
|
||||
<!ENTITY view.header.progress.label "Progress">
|
||||
<!ENTITY view.header.status.label "Status">
|
||||
<!ENTITY view.header.timeremaining.label "Time Left">
|
||||
<!ENTITY view.header.transferred.label "Transferred">
|
||||
<!ENTITY view.header.transferrate.label "Speed">
|
||||
<!ENTITY view.header.timeelapsed.label "Time Elapsed">
|
||||
<!ENTITY view.header.progresstext.label "%">
|
||||
<!ENTITY view.header.source.label "Source">
|
||||
|
||||
<!ENTITY downloadManager.title "Download Manager">
|
||||
|
||||
<!ENTITY cmd.properties.label "Properties">
|
||||
<!ENTITY cmd.properties.accesskey "i">
|
||||
<!ENTITY cmd.properties.keybinding "i">
|
||||
<!ENTITY cmd.pause.label "Pause">
|
||||
<!ENTITY cmd.pause.accesskey "P">
|
||||
<!ENTITY cmd.remove.label "Remove from List">
|
||||
<!ENTITY cmd.remove.accesskey "R">
|
||||
<!ENTITY cmd.copyurl.label "Copy URL">
|
||||
<!ENTITY cmd.copyurl.accesskey "U">
|
||||
<!ENTITY cmd.cancel.label "Cancel">
|
||||
<!ENTITY cmd.cancel.accesskey "C">
|
||||
<!ENTITY cmd.openfile.label "Launch File">
|
||||
<!ENTITY cmd.openfile.accesskey "L">
|
||||
<!ENTITY cmd.showinshell.label "Show File Location">
|
||||
<!ENTITY cmd.showinshell.accesskey "F">
|
||||
<!ENTITY dm.tooltip "Toolbar">
|
||||
<!ENTITY confirmCancel "Are you sure you want to cancel the saving of this file?">
|
||||
<!ENTITY progressMsgNoRate "#1KB of #2KB">
|
||||
<!ENTITY rateMsg "#1KB/sec">
|
@ -1,13 +0,0 @@
|
||||
transferred=%1SKB of %2SKB
|
||||
downloading=Downloading
|
||||
notStarted=Not Started
|
||||
failed=Failed
|
||||
finished=Finished
|
||||
canceled=Canceled
|
||||
alertTitle=Download Error
|
||||
finishedTitle=Download Complete
|
||||
finishedText=%S has finished downloading
|
||||
|
||||
profileSwitchTitle=Downloads in progress
|
||||
profileSwitchText=Downloads are in progress. Switching profiles will stop them.
|
||||
profileSwitchContinue=C&ontinue
|
@ -1,45 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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) 2002
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -1,86 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
The contents of this file are subject to the Mozilla 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/MPL/
|
||||
|
||||
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):
|
||||
Simon Fraser <sfrase@netscape.com>
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
|
||||
***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<?xul-overlay href="chrome://navigator/content/navigatorOverlay.xul"?>
|
||||
|
||||
<overlay id="dlmanagermenuoverlay.xul"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<!-- JS from navigator.xul, to handle the menu commands -->
|
||||
<script type="application/x-javascript" src="chrome://navigator/content/browser.js"/>
|
||||
<script type="application/x-javascript" src="chrome://navigator/content/navigator.js"/>
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
function dmOverlayStartup() {
|
||||
pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService).getBranch(null);
|
||||
gNavigatorBundle = document.getElementById("bundle_navigator");
|
||||
}
|
||||
|
||||
addEventListener("load", dmOverlayStartup, false);
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="bundle_navigator" src="chrome://navigator/locale/navigator.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
<!-- keys are appended from the overlay -->
|
||||
<keyset id="tasksKeys">
|
||||
<keyset id="navKeys">
|
||||
<key id="showHideSidebar"/>
|
||||
</keyset>
|
||||
</keyset>
|
||||
|
||||
<!-- commands are appended from the overlay -->
|
||||
<commandset id="commands">
|
||||
<commandset id="tasksCommands"/>
|
||||
<commandset id="globalEditMenuItems"/>
|
||||
<commandset id="selectEditMenuItems"/>
|
||||
<commandset id="undoEditMenuItems"/>
|
||||
<commandset id="clipboardEditMenuItems"/>
|
||||
</commandset>
|
||||
|
||||
<broadcasterset id="navBroadcasters"/>
|
||||
|
||||
<toolbox id="toolbox" position="0">
|
||||
<menubar id="main-menubar" position="1"/>
|
||||
</toolbox>
|
||||
|
||||
</overlay>
|
@ -1,2 +0,0 @@
|
||||
comm.jar:
|
||||
content/communicator/downloadmanager/dlmanagermenuoverlay.xul (dlmanagermenuoverlay.xul)
|
@ -1,90 +0,0 @@
|
||||
#! gmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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) 2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Stuart Parmenter <pavlov@netscape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = downloadmanager
|
||||
LIBRARY_NAME = downloadmanager_s
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
rdf \
|
||||
uriloader \
|
||||
mimetype \
|
||||
necko \
|
||||
intl \
|
||||
windowwatcher \
|
||||
webbrowserpersist \
|
||||
appshell \
|
||||
dom \
|
||||
profile \
|
||||
widget \
|
||||
pref \
|
||||
embed_base \
|
||||
alerts \
|
||||
toolkitcomps \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsDownloadManager.cpp \
|
||||
$(NULL)
|
||||
|
||||
# Toolkit exports this from its download manager, so we need to as we're not
|
||||
# currently building the toolkit version, but other things need it.
|
||||
EXTRA_JS_MODULES = \
|
||||
../../../../toolkit/mozapps/downloads/src/DownloadUtils.jsm \
|
||||
../../../../toolkit/mozapps/downloads/src/DownloadLastDir.jsm \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_COMPONENTS = nsDownloadProgressListener.js
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,188 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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>
|
||||
* Ben Goodger <ben@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef downloadmanager___h___
|
||||
#define downloadmanager___h___
|
||||
|
||||
#include "nsIDownloadManager.h"
|
||||
#include "nsIDownloadProgressListener.h"
|
||||
#include "nsIDownload.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFRemoteDataSource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIProgressDialog.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "nsISound.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
enum DownloadState { NOTSTARTED = -1, DOWNLOADING, FINISHED, FAILED, CANCELED };
|
||||
|
||||
class nsDownload;
|
||||
|
||||
class nsDownloadManager : public nsIDownloadManager,
|
||||
public nsIDOMEventListener,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOWNLOADMANAGER
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
nsresult Init();
|
||||
|
||||
nsDownloadManager();
|
||||
~nsDownloadManager();
|
||||
|
||||
protected:
|
||||
nsresult GetDownloadsContainer(nsIRDFContainer** aResult);
|
||||
nsresult GetProfileDownloadsFileURL(nsCString& aDownloadsFileURL);
|
||||
nsresult GetInternalListener(nsIDownloadProgressListener** aInternalListener);
|
||||
nsresult GetDataSource(nsIRDFDataSource** aDataSource);
|
||||
nsresult AssertProgressInfo();
|
||||
nsresult AssertProgressInfoFor(const nsACString& aTargetPath);
|
||||
nsresult DownloadStarted(const nsACString& aTargetPath);
|
||||
nsresult DownloadEnded(const nsACString& aTargetPath, const PRUnichar* aMessage);
|
||||
PRBool MustUpdateUI() { if (mDocument) return PR_TRUE; return PR_FALSE; }
|
||||
|
||||
nsCOMPtr<nsISound> mSoundInterface;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIRDFDataSource> mDataSource;
|
||||
nsCOMPtr<nsIDOMDocument> mDocument;
|
||||
nsCOMPtr<nsIRDFContainer> mDownloadsContainer;
|
||||
nsCOMPtr<nsIDownloadProgressListener> mListener;
|
||||
nsCOMPtr<nsIRDFContainerUtils> mRDFContainerUtils;
|
||||
nsCOMPtr<nsIStringBundle> mBundle;
|
||||
PRInt32 mBatches;
|
||||
nsRefPtrHashtable<nsCStringHashKey, nsDownload> mCurrDownloads;
|
||||
|
||||
friend class nsDownload;
|
||||
};
|
||||
|
||||
class nsDownload : public nsIDownload,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER2
|
||||
NS_DECL_NSITRANSFER
|
||||
NS_DECL_NSIDOWNLOAD
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsDownload(nsDownloadManager* aManager, nsIURI* aTarget, nsIURI* aSource,
|
||||
nsICancelable* aCancelable);
|
||||
~nsDownload();
|
||||
|
||||
nsresult Cancel();
|
||||
nsresult Suspend();
|
||||
nsresult SetDisplayName(const PRUnichar* aDisplayName);
|
||||
nsresult SetTempFile(nsILocalFile* aTempFile);
|
||||
nsresult Resume();
|
||||
void DisplayDownloadFinishedAlert();
|
||||
|
||||
void SetDialogListener(nsIDownloadProgressListener* aInternalListener) {
|
||||
mDialogListener = aInternalListener;
|
||||
}
|
||||
void SetDialog(nsIProgressDialog* aDialog) {
|
||||
mDialog = aDialog;
|
||||
}
|
||||
// May return null
|
||||
nsIProgressDialog* GetDialog() {
|
||||
return mDialog;
|
||||
}
|
||||
|
||||
struct TransferInformation {
|
||||
PRInt64 mCurrBytes, mMaxBytes;
|
||||
TransferInformation(PRInt64 aCurr, PRInt64 aMax) :
|
||||
mCurrBytes(aCurr),
|
||||
mMaxBytes(aMax)
|
||||
{}
|
||||
};
|
||||
|
||||
TransferInformation GetTransferInformation() {
|
||||
return TransferInformation(mCurrBytes, mMaxBytes);
|
||||
}
|
||||
DownloadState GetDownloadState() {
|
||||
return mDownloadState;
|
||||
}
|
||||
void SetDownloadState(DownloadState aState) {
|
||||
mDownloadState = aState;
|
||||
}
|
||||
void SetMIMEInfo(nsIMIMEInfo* aMIMEInfo) {
|
||||
mMIMEInfo = aMIMEInfo;
|
||||
}
|
||||
void SetStartTime(PRInt64 aStartTime) {
|
||||
mStartTime = aStartTime;
|
||||
mLastUpdate = aStartTime;
|
||||
}
|
||||
private:
|
||||
nsRefPtr<nsDownloadManager> mDownloadManager;
|
||||
|
||||
nsString mDisplayName;
|
||||
|
||||
nsCOMPtr<nsIURI> mTarget;
|
||||
nsCOMPtr<nsIURI> mSource;
|
||||
nsCOMPtr<nsIDownloadProgressListener> mDialogListener;
|
||||
nsCOMPtr<nsICancelable> mCancelable;
|
||||
nsCOMPtr<nsIRequest> mRequest;
|
||||
nsCOMPtr<nsIProgressDialog> mDialog;
|
||||
nsCOMPtr<nsIMIMEInfo> mMIMEInfo;
|
||||
nsCOMPtr<nsILocalFile> mTempFile;
|
||||
DownloadState mDownloadState;
|
||||
|
||||
PRInt32 mPercentComplete;
|
||||
PRUint64 mCurrBytes;
|
||||
PRUint64 mMaxBytes;
|
||||
PRTime mStartTime;
|
||||
PRTime mLastUpdate;
|
||||
double mSpeed;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,314 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var gStrings = new Array;
|
||||
const interval = 500; // Update every 500 milliseconds.
|
||||
|
||||
function nsDownloadProgressListener() {
|
||||
}
|
||||
|
||||
nsDownloadProgressListener.prototype = {
|
||||
rateChanges: 0,
|
||||
rateChangeLimit: 0,
|
||||
priorRate: "",
|
||||
lastUpdate: -500,
|
||||
doc: null,
|
||||
get document() {
|
||||
return this.doc;
|
||||
},
|
||||
set document(newval) {
|
||||
return this.doc = newval;
|
||||
},
|
||||
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus, aDownload)
|
||||
{
|
||||
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
|
||||
{
|
||||
var aDownloadID = aDownload.targetFile.path;
|
||||
var elt = this.doc.getElementById(aDownloadID).firstChild.firstChild;
|
||||
|
||||
var timeRemainingCol = elt.nextSibling.nextSibling.nextSibling;
|
||||
timeRemainingCol.setAttribute("label", "");
|
||||
|
||||
var speedCol = timeRemainingCol.nextSibling.nextSibling;
|
||||
speedCol.setAttribute("label", "");
|
||||
|
||||
var elapsedCol = speedCol.nextSibling;
|
||||
elapsedCol.setAttribute("label", "");
|
||||
|
||||
// Fire an onselect event for the downloadView element
|
||||
// to update menu status
|
||||
var event = this.doc.createEvent('Events');
|
||||
event.initEvent('select', false, true);
|
||||
this.doc.getElementById("downloadView").dispatchEvent(event);
|
||||
}
|
||||
},
|
||||
|
||||
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
|
||||
aCurTotalProgress, aMaxTotalProgress, aDownload)
|
||||
{
|
||||
var overallProgress = aCurTotalProgress;
|
||||
// Get current time.
|
||||
var now = ( new Date() ).getTime();
|
||||
// If interval hasn't elapsed, ignore it.
|
||||
if ( now - this.lastUpdate < interval && aMaxTotalProgress != "-1" && parseInt(aCurTotalProgress) < parseInt(aMaxTotalProgress) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update this time.
|
||||
this.lastUpdate = now;
|
||||
|
||||
var aDownloadID = aDownload.targetFile.path
|
||||
var elt = this.doc.getElementById(aDownloadID).firstChild.firstChild;
|
||||
if (this.doc.getElementById("TimeElapsed").getAttribute("hidden") != "true") {
|
||||
elapsedCol = elt.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling;
|
||||
// Update elapsed time display.
|
||||
elapsedCol.setAttribute("label", formatSeconds( now / 1000 - aDownload.startTime / 1000000, this.doc ));
|
||||
}
|
||||
// Calculate percentage.
|
||||
var percent;
|
||||
var progressCol = elt.nextSibling;
|
||||
if ( aMaxTotalProgress > 0)
|
||||
{
|
||||
percent = Math.floor((overallProgress*100.0)/aMaxTotalProgress);
|
||||
if ( percent > 100 )
|
||||
percent = 100;
|
||||
|
||||
// Advance progress meter.
|
||||
progressCol.setAttribute( "value", percent );
|
||||
|
||||
progressCol.setAttribute("mode", "normal");
|
||||
}
|
||||
else
|
||||
{
|
||||
percent = -1;
|
||||
|
||||
// Progress meter should be barber-pole in this case.
|
||||
progressCol.setAttribute( "mode", "undetermined" );
|
||||
}
|
||||
|
||||
// now that we've set the progress and the time, update # bytes downloaded...
|
||||
// Update status (nnK of mmK bytes at xx.xK aCurTotalProgress/sec)
|
||||
var status = getString( "progressMsgNoRate", this.doc );
|
||||
|
||||
// Insert 1 is the number of kilobytes downloaded so far.
|
||||
status = replaceInsert( status, 1, parseInt( overallProgress/1024 + .5 ) );
|
||||
|
||||
// Insert 2 is the total number of kilobytes to be downloaded (if known).
|
||||
if ( aMaxTotalProgress != "-1" )
|
||||
status = replaceInsert( status, 2, parseInt( aMaxTotalProgress/1024 + .5 ) );
|
||||
else
|
||||
status = replaceInsert( status, 2, "??" );
|
||||
|
||||
var rateMsg = getString( "rateMsg", this.doc );
|
||||
var rate = aDownload.speed;
|
||||
if ( rate )
|
||||
{
|
||||
// rate is bytes/sec
|
||||
var kRate = (rate / 1024).toFixed(1); // kilobytes/sec
|
||||
|
||||
// Don't update too often!
|
||||
if ( kRate != this.priorRate )
|
||||
{
|
||||
if ( this.rateChanges++ == this.rateChangeLimit )
|
||||
{
|
||||
// Time to update download rate.
|
||||
this.priorRate = kRate;
|
||||
this.rateChanges = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stick with old rate for a bit longer.
|
||||
kRate = this.priorRate;
|
||||
}
|
||||
}
|
||||
else
|
||||
this.rateChanges = 0;
|
||||
|
||||
// Insert 3 is the download rate (in kilobytes/sec).
|
||||
rateMsg = replaceInsert( rateMsg, 1, kRate );
|
||||
}
|
||||
else
|
||||
rateMsg = replaceInsert( rateMsg, 1, "??.?" );
|
||||
|
||||
var timeRemainingCol = elt.nextSibling.nextSibling.nextSibling;
|
||||
|
||||
// Update status msg.
|
||||
var statusCol = timeRemainingCol.nextSibling;
|
||||
statusCol.setAttribute("label", status);
|
||||
|
||||
var speedCol = statusCol.nextSibling;
|
||||
speedCol.setAttribute("label", rateMsg);
|
||||
// Update percentage label on progress meter.
|
||||
if (this.doc.getElementById("ProgressPercent").getAttribute("hidden") != "true") {
|
||||
var progressText = elt.nextSibling.nextSibling;
|
||||
if (percent < 0)
|
||||
progressText.setAttribute("label", "");
|
||||
else {
|
||||
var percentMsg = getString( "percentMsg", this.doc );
|
||||
percentMsg = replaceInsert( percentMsg, 1, percent );
|
||||
progressText.setAttribute("label", percentMsg);
|
||||
}
|
||||
}
|
||||
// Update time remaining.
|
||||
if ( rate && (aMaxTotalProgress > 0) )
|
||||
{
|
||||
var rem = ( aMaxTotalProgress - aCurTotalProgress ) / rate;
|
||||
rem = parseInt( rem + .5 );
|
||||
timeRemainingCol.setAttribute("label", formatSeconds( rem, this.doc ));
|
||||
}
|
||||
else
|
||||
timeRemainingCol.setAttribute("label", getString( "unknownTime", this.doc ));
|
||||
},
|
||||
onLocationChange: function(aWebProgress, aRequest, aLocation, aDownload)
|
||||
{
|
||||
},
|
||||
onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage, aDownload)
|
||||
{
|
||||
},
|
||||
onSecurityChange: function(aWebProgress, aRequest, state, aDownload)
|
||||
{
|
||||
},
|
||||
QueryInterface : function(iid)
|
||||
{
|
||||
if (iid.equals(Components.interfaces.nsIDownloadProgressListener) ||
|
||||
iid.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
var nsDownloadProgressListenerFactory = {
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return (new nsDownloadProgressListener()).QueryInterface(iid);
|
||||
}
|
||||
};
|
||||
|
||||
var nsDownloadProgressListenerModule = {
|
||||
|
||||
registerSelf: function (compMgr, fileSpec, location, type)
|
||||
{
|
||||
var compReg = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
compReg.registerFactoryLocation(Components.ID("{09cddbea-1dd2-11b2-aa15-c41ffea19d79}"),
|
||||
"Download Progress Listener",
|
||||
"@mozilla.org/download-manager/listener;1",
|
||||
fileSpec, location, type);
|
||||
},
|
||||
canUnload: function(compMgr)
|
||||
{
|
||||
return true;
|
||||
},
|
||||
|
||||
getClassObject: function (compMgr, cid, iid) {
|
||||
if (!cid.equals(Components.ID("{09cddbea-1dd2-11b2-aa15-c41ffea19d79}")))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsIFactory))
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return nsDownloadProgressListenerFactory;
|
||||
}
|
||||
};
|
||||
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return nsDownloadProgressListenerModule;
|
||||
}
|
||||
|
||||
function replaceInsert( text, index, value ) {
|
||||
var result = text;
|
||||
var regExp = new RegExp( "#"+index );
|
||||
result = result.replace( regExp, value );
|
||||
return result;
|
||||
}
|
||||
|
||||
function getString( stringId, doc ) {
|
||||
// Check if we've fetched this string already.
|
||||
if ( !gStrings[ stringId ] ) {
|
||||
// Try to get it.
|
||||
var elem = doc.getElementById( "strings."+stringId );
|
||||
try {
|
||||
if ( elem
|
||||
&&
|
||||
elem.childNodes
|
||||
&&
|
||||
elem.childNodes[0]
|
||||
&&
|
||||
elem.childNodes[0].nodeValue ) {
|
||||
gStrings[ stringId ] = elem.childNodes[0].nodeValue;
|
||||
} else {
|
||||
// If unable to fetch string, use an empty string.
|
||||
gStrings[ stringId ] = "";
|
||||
}
|
||||
} catch (e) { gStrings[ stringId ] = ""; }
|
||||
}
|
||||
return gStrings[ stringId ];
|
||||
}
|
||||
|
||||
function formatSeconds( secs, doc )
|
||||
{
|
||||
// Round the number of seconds to remove fractions.
|
||||
secs = parseInt( secs + .5 );
|
||||
var hours = parseInt( secs/3600 );
|
||||
secs -= hours*3600;
|
||||
var mins = parseInt( secs/60 );
|
||||
secs -= mins*60;
|
||||
var result;
|
||||
if ( hours )
|
||||
result = getString( "longTimeFormat", doc );
|
||||
else
|
||||
result = getString( "shortTimeFormat", doc );
|
||||
|
||||
if ( hours < 10 )
|
||||
hours = "0" + hours;
|
||||
if ( mins < 10 )
|
||||
mins = "0" + mins;
|
||||
if ( secs < 10 )
|
||||
secs = "0" + secs;
|
||||
|
||||
// Insert hours, minutes, and seconds into result string.
|
||||
result = replaceInsert( result, 1, hours );
|
||||
result = replaceInsert( result, 2, mins );
|
||||
result = replaceInsert( result, 3, secs );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1,99 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 MPL, 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 MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef downloadproxy___h___
|
||||
#define downloadproxy___h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDownload.h"
|
||||
#include "nsIDownloadManager.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
|
||||
#define DOWNLOAD_MANAGER_BEHAVIOR_PREF "browser.downloadmanager.behavior"
|
||||
|
||||
class nsDownloadProxy : public nsITransfer
|
||||
{
|
||||
public:
|
||||
|
||||
nsDownloadProxy() { }
|
||||
virtual ~nsDownloadProxy() { }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_FORWARD_SAFE_NSIWEBPROGRESSLISTENER(mInner)
|
||||
NS_FORWARD_SAFE_NSIWEBPROGRESSLISTENER2(mInner)
|
||||
|
||||
NS_IMETHODIMP Init(nsIURI* aSource,
|
||||
nsIURI* aTarget,
|
||||
const nsAString& aDisplayName,
|
||||
nsIMIMEInfo *aMIMEInfo,
|
||||
PRTime aStartTime,
|
||||
nsILocalFile* aTempFile,
|
||||
nsICancelable* aCancelable) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDownloadManager> dm = do_GetService("@mozilla.org/download-manager;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = dm->AddDownload(aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime,
|
||||
aTempFile, aCancelable, getter_AddRefs(mInner));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRInt32 behavior;
|
||||
nsCOMPtr<nsIPrefBranch> branch = do_GetService("@mozilla.org/preferences-service;1", &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = branch->GetIntPref(DOWNLOAD_MANAGER_BEHAVIOR_PREF, &behavior);
|
||||
if (NS_FAILED(rv))
|
||||
behavior = 0;
|
||||
|
||||
if (behavior == 0)
|
||||
rv = dm->Open(nsnull, mInner);
|
||||
else if (behavior == 1)
|
||||
rv = dm->OpenProgressDialogFor(mInner, nsnull, PR_TRUE);
|
||||
return rv;
|
||||
}
|
||||
private:
|
||||
nsCOMPtr<nsIDownload> mInner;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsDownloadProxy, nsITransfer,
|
||||
nsIWebProgressListener, nsIWebProgressListener2)
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user