215467, Part I. New Download Manager.

This commit is contained in:
ben%bengoodger.com 2003-11-27 00:54:33 +00:00
parent 6ab7bfb8a3
commit 755fe67158
75 changed files with 5701 additions and 153 deletions

View File

@ -124,12 +124,12 @@ pref("accessibility.typeaheadfind.enabletimeout", true);
pref("accessibility.typeaheadfind.soundURL", "default");
pref("accessibility.typeaheadfind.enablesound", true);
pref("browser.download.progressDnldDialog.keepAlive", true); // keep the dnload progress dialog up after dnload is complete
pref("browser.download.progressDnldDialog.enable_launch_reveal_buttons", true);
pref("browser.download.useProgressDialogs", true);
pref("browser.download.openSidebar", false);
pref("browser.download.useDownloadDir", true);
pref("browser.download.folderList", 0);
pref("browser.download.retention", 2);
pref("browser.download.showWhenStarting", true);
pref("browser.download.closeWhenDone", true);
// pointer to the default engine name
pref("browser.search.defaultenginename", "chrome://browser-region/locale/region.properties");

View File

@ -124,12 +124,12 @@ pref("accessibility.typeaheadfind.enabletimeout", true);
pref("accessibility.typeaheadfind.soundURL", "default");
pref("accessibility.typeaheadfind.enablesound", true);
pref("browser.download.progressDnldDialog.keepAlive", true); // keep the dnload progress dialog up after dnload is complete
pref("browser.download.progressDnldDialog.enable_launch_reveal_buttons", true);
pref("browser.download.useProgressDialogs", true);
pref("browser.download.openSidebar", false);
pref("browser.download.useDownloadDir", true);
pref("browser.download.folderList", 0);
pref("browser.download.retention", 2);
pref("browser.download.showWhenStarting", true);
pref("browser.download.closeWhenDone", true);
// pointer to the default engine name
pref("browser.search.defaultenginename", "chrome://browser-region/locale/region.properties");

View File

@ -67,8 +67,8 @@ IDD_SPLASH DIALOGEX
STRINGTABLE DISCARDABLE
BEGIN
ID_DDE_APPLICATION_NAME, "Mozilla Firebird"
IDS_STARTMENU_APPNAME, "Mozilla Firebird"
ID_DDE_APPLICATION_NAME, "Mozilla Firebird Debug"
IDS_STARTMENU_APPNAME, "Mozilla Firebird Debug"
END
#ifdef MOZ_STATIC_BUILD

View File

@ -248,6 +248,8 @@
<menu label="&toolsMenu.label;" accesskey="&toolsMenu.accesskey;">
<menupopup id="menu_ToolsPopup">
<menuitem id="downloads" label="&downloads.label;" accesskey="&downloads.accesskey;"
oncommand="toDownloads();"/>
<menuitem id="javascriptConsole" label="&javaScriptConsoleCmd.label;" accesskey="&javaScriptConsoleCmd.accesskey;" oncommand="toJavaScriptConsole();"/>
<menuitem accesskey="&pageInfoCmd.accesskey;" label="&pageInfoCmd.label;" key="key_viewInfo" command="View:PageInfo"/>
#ifndef XP_MACOSX

View File

@ -1,4 +1,4 @@
<stringbundleset id="stringbundleset">
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_browser" src="chrome://browser/locale/browser.properties"/>
<stringbundle id="bundle_browser_region" src="chrome://browser-region/locale/region.properties"/>
<stringbundle id="findBundle" src="chrome://global/locale/finddialog.properties"/>
@ -93,17 +93,14 @@
<command id="cmd_textZoomEnlarge" oncommand="ZoomManager.prototype.getInstance().enlarge();"/>
<command id="Browser:OpenLocation" oncommand="openLocation();"/>
<command id="Tools:Downloads" oncommand="toOpenWindowByType('Download:Manager', 'chrome://mozapps/content/downloads/downloads.xul');"/>
#ifdef XP_MACOSX
<command id="minimizeWindow" label="&minimizeWindow.label;" disabled="true"/>
#endif
</commandset>
<broadcasterset id="mainBroadcasterSet">
<broadcaster id="viewDownloadsSidebar" autoCheck="false" label="&downloadsButton.label;"
type="checkbox" group="sidebar" sidebarurl="chrome://browser/content/downloads/downloadPanel.xul"
sidebartitle="&currentDownloads.label;"
oncommand="toggleSidebar('viewDownloadsSidebar');"/>
<broadcaster id="viewBookmarksSidebar" autoCheck="false" label="&bookmarksButton.label;"
type="checkbox" group="sidebar" sidebarurl="chrome://browser/content/bookmarks/bookmarksPanel.xul"
oncommand="toggleSidebar('viewBookmarksSidebar');"/>
@ -216,7 +213,7 @@
<key id="key_textZoomEnlarge" key="&textZoomEnlargeCmd.commandkey;" command="cmd_textZoomEnlarge" modifiers="accel"/>
<key key="&textZoomEnlargeCmd.commandkey2;" command="cmd_textZoomEnlarge" modifiers="accel"/>
<key key="&textZoomResetCmd.commandkey;" oncommand="ZoomManager.prototype.getInstance().reset();" modifiers="accel"/>
<key id="key_openDownloadsSidebar" key="&openDownloadsSidebar.commandkey;" command="viewDownloadsSidebar" modifiers="accel"/>
<key id="key_openDownloads" key="&downloads.commandkey;" command="Tools:Downloads" modifiers="accel"/>
#ifdef XP_MACOSX
<key id="key_minimizeWindow" command="minimizeWindow" key="&minimizeWindow.key;" modifiers="accel"/>

View File

@ -1806,6 +1806,11 @@ function deleteHistoryItems(aParent)
}
}
function toDownloads()
{
toOpenWindowByType("Download:Manager", "chrome://mozapps/content/downloads/downloads.xul");
}
function toJavaScriptConsole()
{
toOpenWindowByType("global:console", "chrome://global/content/console.xul");

View File

@ -36,7 +36,7 @@
# All DTD information is stored in a separate file so that it can be shared by
# hiddenWindow.xul.
#include browser-doctype.inc
<window id="main-window"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@ -459,8 +459,9 @@
</toolbaritem>
<toolbarbutton id="downloads-button" class="toolbarbutton-1"
observes="viewDownloadsSidebar"
tooltiptext="&downloadsButton.tooltip;"/>
observes="Tools:Downloads"
label="&downloads.label;"
tooltiptext="&downloads.tooltip;"/>
<toolbarbutton id="history-button" class="toolbarbutton-1"
observes="viewHistorySidebar"

View File

@ -106,9 +106,10 @@
<!ENTITY toolsMenu.label "Tools">
<!ENTITY toolsMenu.accesskey "T">
<!ENTITY downloadManagerCmd.label "Download Manager">
<!ENTITY downloadManagerCmd.accesskey "D">
<!ENTITY downloads.label "Downloads">
<!ENTITY downloads.tooltip "Displays the progress of ongoing downloads">
<!ENTITY downloads.accesskey "D">
<!ENTITY downloads.commandkey "E">
<!ENTITY javaConsoleCmd.label "Java Console">
<!ENTITY javaConsoleCmd.accesskey "J">
@ -253,9 +254,6 @@
<!ENTITY textZoomReduceCmd.commandkey "-">
<!ENTITY textZoomResetCmd.commandkey "0">
<!ENTITY downloadsButton.label "Downloads">
<!ENTITY downloadsButton.tooltip "Displays the progress of ongoing downloads">
<!ENTITY bookmarksButton.label "Bookmarks">
<!ENTITY bookmarksButton.tooltip "Displays your bookmarks">
@ -270,8 +268,6 @@
<!ENTITY pasteButton.tooltip "Paste">
<!ENTITY findOnSearchBarCmd.label "Find in this Page">
<!ENTITY currentDownloads.label "Current Downloads">
<!ENTITY openDownloadsSidebar.commandkey "E">
<!ENTITY quitApplicationCmdWin.label "Exit">
<!ENTITY quitApplicationCmdWin.accesskey "x">

View File

@ -42,6 +42,6 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = bookmarks downloads history prefwindow security sidebar cookieviewer build
DIRS = bookmarks history prefwindow security sidebar cookieviewer build
include $(topsrcdir)/config/rules.mk

View File

@ -20,15 +20,11 @@ REQUIRES = \
pref \
rdf \
intl \
downloads \
uriloader \
dom \
necko \
nkcache \
txmgr \
webbrowserpersist \
progressDlg \
mimetype \
bookmarks \
$(NULL)
@ -42,12 +38,10 @@ OS_LIBS += $(call EXPAND_LIBNAME,ole32 shell32)
endif
LOCAL_INCLUDES = \
-I$(srcdir)/../downloads/src \
-I$(srcdir)/../bookmarks/src \
$(NULL)
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)download_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)bookmarks_s.$(LIB_SUFFIX) \
$(NULL)

View File

@ -39,14 +39,10 @@
#include "nsIGenericFactory.h"
#include "nsBrowserCompsCID.h"
#include "nsDownloadManager.h"
#include "nsDownloadProxy.h"
#include "nsBookmarksService.h"
/////////////////////////////////////////////////////////////////////////////
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDownloadManager, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsBookmarksService, Init)
/////////////////////////////////////////////////////////////////////////////
@ -57,15 +53,7 @@ static const nsModuleComponentInfo components[] =
nsBookmarksServiceConstructor },
{ "Bookmarks", NS_BOOKMARKS_SERVICE_CID, NS_BOOKMARKS_DATASOURCE_CONTRACTID,
nsBookmarksServiceConstructor },
{ "Download Manager",
NS_DOWNLOADMANAGER_CID,
NS_DOWNLOADMANAGER_CONTRACTID,
nsDownloadManagerConstructor },
{ "Download",
NS_DOWNLOAD_CID,
NS_DOWNLOAD_CONTRACTID,
nsDownloadProxyConstructor }
};
NS_IMPL_NSGETMODULE(nsBrowserCompsModule, components)

View File

@ -41,7 +41,8 @@
var _elementIDs = ["histDay", "browserCacheDiskCache", "cookieBehavior", "enableCookies",
"enableCookiesForOriginatingSiteOnly", "enableCookiesForCurrentSessionOnly",
"enableCookiesButAskFirst", "enableFormFill", "enablePasswords"];
"enableCookiesButAskFirst", "enableFormFill", "enablePasswords",
"downloadsRetentionPolicy"];
function Startup() {
@ -97,11 +98,11 @@ function Startup() {
// the bound element. dbaron is helping me with this with a reduced test case, but in
// the meantime, I'm working around this bug by placing the menulist outside the bound element
// until it is completely initialized and then scooting it in, which is what this code does.
# var drb = document.getElementById("downloadsRetentionBox");
# var drp = document.getElementById("downloadsRetentionPolicy");
# drp.removeAttribute("hidden");
# document.documentElement.removeChild(drp);
# drb.appendChild(drp);
var drb = document.getElementById("downloadsRetentionBox");
var drp = document.getElementById("downloadsRetentionPolicy");
drp.removeAttribute("hidden");
document.documentElement.removeChild(drp);
drb.appendChild(drp);
}
function unload()

View File

@ -93,9 +93,9 @@
<expander id="downloads" label="&downloads.label;" clearlabel="&clearDownloads.label;" persist="open">
<description>&downloadsDescription.label;</description>
# <hbox align="center" id="downloadsRetentionBox">
# <description>&downloadsRetentionPolicy.label;</description>
# </hbox>
<hbox align="center" id="downloadsRetentionBox">
<description>&downloadsRetentionPolicy.label;</description>
</hbox>
</expander>
<!-- Cookies -->
@ -147,14 +147,14 @@
</hbox>
# <menulist id="downloadsRetentionPolicy" hidden="true"
# preftype="int" prefstring="browser.download.retention" prefdefval="0">
# <menupopup>
# <menuitem value="0" label="&downloadsRemoveImmediately.label;"/>
# <menuitem value="1" label="&downloadsRemoveExit.label;"/>
# <menuitem value="2" label="&downloadsRemoveManually.label;"/>
# </menupopup>
# </menulist>
<menulist id="downloadsRetentionPolicy" hidden="true"
preftype="int" prefstring="browser.download.retention" prefdefval="0">
<menupopup>
<menuitem value="0" label="&downloadsRemoveImmediately.label;"/>
<menuitem value="1" label="&downloadsRemoveExit.label;"/>
<menuitem value="2" label="&downloadsRemoveManually.label;"/>
</menupopup>
</menulist>
</page>

View File

@ -9,7 +9,7 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&prefWindow.title;"
style="&prefWindow.size;"
buttons="accept,cancel"
buttons="accept,cancel" windowtype="Browser:Options"
onload="Startup();" onunload="Shutdown();"
ondialogaccept="return hPrefWindow.onOK(event);"
ondialogcancel="return hPrefWindow.onCancel(event);"
@ -20,10 +20,13 @@
<![CDATA[
var hPrefWindow = null;
// If we're starting the Options dialog with a specific panel, we should do certain things
// like not remember the last panel the user visited.
var gUsingSpecifiedPage = false;
/** General startup routine for preferences dialog.
* Place all necessary modifications to pref tree here.
**/
// General startup routine for preferences dialog.
// Place all necessary modifications to pref tree here.
function Startup()
{
hPrefWindow = new nsPrefWindow("panelFrame");
@ -32,28 +35,42 @@
throw "failed to create prefwindow";
hPrefWindow.init();
if ("arguments" in window && window.arguments[0]) {
switchPage(window.arguments[0]);
gUsingSpecifiedPage = true;
document.getElementById("prefsCategories").removeAttribute("persist");
}
}
function Shutdown ()
{
var prefsCategories = document.getElementById("prefsCategories");
for (var i = 0; i < prefsCategories.childNodes.length; ++i) {
if (prefsCategories.childNodes[i].checked) {
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
pref.setIntPref("browser.preferences.lastpanel", i);
break;
if (!gUsingSpecifiedPage) {
var prefsCategories = document.getElementById("prefsCategories");
for (var i = 0; i < prefsCategories.childNodes.length; ++i) {
if (prefsCategories.childNodes[i].checked) {
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
pref.setIntPref("browser.preferences.lastpanel", i);
break;
}
}
document.persist("prefsDialog", "screenX screenY");
}
document.persist("prefsDialog", "screenX screenY");
}
function switchPage(aEvent)
function switchPage(aButtonID)
{
var newURL = aEvent.target.getAttribute("url");
if (hPrefWindow)
hPrefWindow.switchPage(newURL, "");
var button = document.getElementById(aButtonID);
if (button) {
var newURL = button.getAttribute("url");
if (hPrefWindow)
hPrefWindow.switchPage(newURL, "");
button.checked = true;
}
}
]]>
@ -65,7 +82,7 @@
<script type="application/x-javascript" src="chrome://browser/content/pref/nsPrefWindow.js"/>
<hbox flex="1">
<vbox id="prefsCategories" class="listBox buttonBox" oncommand="switchPage(event);" orient="vertical" lastpanel="1" persist="lastpanel">
<vbox id="prefsCategories" class="listBox buttonBox" oncommand="switchPage(event.target.id);" orient="vertical">
<button id="catGeneralButton" orient="vertical" class="buttonBoxButton" type="radio" group="categories" label="&general.label;"
url="chrome://browser/content/pref/pref-navigator.xul"/>
<button id="catPrivacyButton" orient="vertical" class="buttonBoxButton" type="radio" group="categories" label="&privacy.label;"

View File

@ -55,8 +55,14 @@ DIRS = \
satchel \
viewconfig \
viewsource \
build \
$(NULL)
ifeq ($(OS_ARCH),WINNT)
DIRS += alerts
endif
DIRS += downloads build
endif

View File

@ -0,0 +1,32 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,7 @@
toolkit.jar:
* content/global/alerts/alert.xul (resources/content/alert.xul)
* content/global/alerts/alert.js (resources/content/alert.js)
classic.jar:
skin/classic/global/alerts/alert.css (resources/skin/alert.css)

View File

@ -0,0 +1,35 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = alerts
XPIDL_MODULE=alerts
XPIDLSRCS = nsIAlertsService.idl \
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,68 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
/* nsIAlertsListener --> when a consumer asks the alerts service to put up an alert, they have the option
of passing in an alert listener as well. The alert listener gets notified when the alert has gone away.
*/
[scriptable, uuid(A840623B-5B87-4e99-A74A-9EF0886C11DD)]
interface nsIAlertListener : nsISupports
{
void onAlertFinished(in wstring aAlertCookie);
void onAlertClickCallback(in wstring aAlertCookie); // if the user clicks on the link and you wanted notified....
};
[scriptable, uuid(7E8B76C6-A70C-4075-81AA-D48B6152E1B4)]
interface nsIAlertsService : nsISupports
{
/* showAlertNotification: shows an animated alert icon
aImageUrl --> a url identifying an image to put in the alert.
aAlertTitle --> the title text for the alert (i.e. You have New Mail)
aAlertText --> the contents of the alert
alertTextClickable --> set to true if you wish to be notified if the user attempts to click
the alert text. Also causes the alert text to look like a link.
aAlertCookie --> a blind cookie the alert will pass back to the consumer during the alert listener callbacks
*/
void showAlertNotification(in string aImageUrl, in wstring aAlertTitle,
in wstring aAlertText, in boolean alertTextClickable,
in wstring aAlertCookie,
in nsIAlertListener aAlertListener );
};

View File

@ -0,0 +1,129 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var gCurrentHeight = 0;
var gFinalHeight = 50;
var gSlideIncrement = 1;
var gSlideTime = 10;
var gOpenTime = 3000; // total time the alert should stay up once we are done animating.
var gAlertListener = null;
var gAlertTextClickable = false;
var gAlertCookie = "";
function prefillAlertInfo()
{
// unwrap all the args....
// arguments[0] --> the image src url
// arguments[1] --> the alert title
// arguments[2] --> the alert text
// arguments[3] --> is the text clickable?
// arguments[4] --> the alert cookie to be passed back to the listener
// arguments[5] --> an optional callback listener (nsIAlertListener)
document.getElementById('alertImage').setAttribute('src', window.arguments[0]);
document.getElementById('alertTitleLabel').setAttribute('value', window.arguments[1]);
document.getElementById('alertTextLabel').setAttribute('value', window.arguments[2]);
gAlertTextClickable = window.arguments[3];
gAlertCookie = window.arguments[4];
if (gAlertTextClickable)
document.getElementById('alertTextLabel').setAttribute('clickable', true);
// the 5th argument is optional
if (window.arguments[5])
gAlertListener = window.arguments[5].QueryInterface(Components.interfaces.nsIAlertListener);
}
function onAlertLoad()
{
// read out our initial settings from prefs.
try
{
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService();
prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);
var prefBranch = prefService.getBranch(null);
gSlideIncrement = prefBranch.getIntPref("alerts.slideIncrement");
gSlideTime = prefBranch.getIntPref("alerts.slideIncrementTime");
gOpenTime = prefBranch.getIntPref("alerts.totalOpenTime");
} catch (ex) {}
sizeToContent();
gFinalHeight = window.outerHeight;
window.outerHeight = 0;
// be sure to offset the alert by 10 pixels from the far right edge of the screen
window.moveTo( (screen.availLeft + screen.availWidth - window.outerWidth) - 10, screen.availTop + screen.availHeight - window.outerHeight);
setTimeout(animateAlert, gSlideTime);
}
function animateAlert()
{
if (gCurrentHeight < gFinalHeight)
{
gCurrentHeight += gSlideIncrement;
window.screenY -= gSlideIncrement;
window.outerHeight += gSlideIncrement;
setTimeout(animateAlert, gSlideTime);
}
else
setTimeout(closeAlert, gOpenTime);
}
function closeAlert()
{
if (gCurrentHeight)
{
gCurrentHeight -= gSlideIncrement;
window.screenY += gSlideIncrement;
window.outerHeight -= gSlideIncrement;
setTimeout(closeAlert, gSlideTime);
}
else
{
if (gAlertListener)
gAlertListener.onAlertFinished(gAlertCookie);
window.close();
}
}
function onAlertClick()
{
if (gAlertListener && gAlertTextClickable)
gAlertListener.onAlertClickCallback(gAlertCookie);
}

View File

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-1999 Netscape Communications Corporation. All
Rights Reserved.
-->
<?xml-stylesheet href="chrome://global/skin/alerts/alert.css" type="text/css"?>
<window id="alertNotification"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
windowtype="alert:alert"
align="start"
onload="onAlertLoad()">
<script type="application/x-javascript" src="chrome://global/content/alerts/alert.js"/>
<hbox id="alertBox" class="alertBox">
<hbox class="alertImageBox" align="center" valign="center">
<image id="alertImage" autostretch="never"/>
</hbox>
<vbox id="alertTextBox" class="alertTextBox">
<label id="alertTitleLabel" class="alertTitle plain"/>
<label id="alertTextLabel" class="alertText plain" onclick="onAlertClick();"/>
</vbox>
</hbox>
<!-- This method is called inline because we want to make sure we establish the width
and height of the alert before we fire the onload handler. -->
<script type="application/x-javascript">prefillAlertInfo();</script>
</window>

View File

@ -0,0 +1,84 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* ===== alert.css =====================================================
== Styles specific to the alerts dialog.
======================================================================= */
@import url("chrome://global/skin/");
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
.alertBox {
border-right: 2px solid #7B969C;
border-bottom: 2px solid #7B969C;
border-top: 2px solid #7B969C;
border-left: 2px solid #7B969C;
background-color: -moz-Dialog;
min-height: 50px;
}
.alertImageBox {
margin-left: 4px;
margin-right: 6px;
min-height: 46px;
}
.alertTitle {
font-weight: bold;
}
.alertText {
margin-right: 6px;
}
.alertText[clickable="true"] {
cursor: pointer;
color: #1455D6;
text-decoration: underline;
}
.alertText[clickable="true"]:hover:active {
color: #424F63;
}
.alertTextBox
{
padding-right: 10px;
padding-top: 5px;
}

View File

@ -0,0 +1,48 @@
#! gmake
#
# 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 Netscape are
# Copyright (C) 2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = alerts
LIBRARY_NAME = alerts_s
REQUIRES = xpcom \
string \
windowwatcher \
dom \
$(NULL)
CPPSRCS = \
nsAlertsService.cpp \
$(NULL)
# 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)

View File

@ -0,0 +1,127 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAlertsService.h"
#include "nsISupportsArray.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIServiceManager.h"
#include "nsIDOMWindowInternal.h"
#include "nsIWindowWatcher.h"
#include "nsDependentString.h"
#define ALERT_CHROME_URL "chrome://global/content/alerts/alert.xul"
NS_IMPL_THREADSAFE_ADDREF(nsAlertsService)
NS_IMPL_THREADSAFE_RELEASE(nsAlertsService)
NS_INTERFACE_MAP_BEGIN(nsAlertsService)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAlertsService)
NS_INTERFACE_MAP_ENTRY(nsIAlertsService)
NS_INTERFACE_MAP_END_THREADSAFE
nsAlertsService::nsAlertsService()
{
}
nsAlertsService::~nsAlertsService()
{}
NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const char * aImageUrl, const PRUnichar * aAlertTitle,
const PRUnichar * aAlertText, PRBool aAlertTextClickable,
const PRUnichar * aAlertCookie,
nsIAlertListener * aAlertListener)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsCOMPtr<nsIDOMWindow> newWindow;
nsresult rv;
nsCOMPtr<nsISupportsArray> argsArray;
rv = NS_NewISupportsArray(getter_AddRefs(argsArray));
NS_ENSURE_SUCCESS(rv, rv);
// create scriptable versions of our strings that we can store in our nsISupportsArray....
nsCOMPtr<nsISupportsCString> scriptableImageUrl (do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
NS_ENSURE_TRUE(scriptableImageUrl, NS_ERROR_FAILURE);
scriptableImageUrl->SetData(nsDependentCString(aImageUrl));
argsArray->AppendElement(scriptableImageUrl);
nsCOMPtr<nsISupportsString> scriptableAlertTitle (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
NS_ENSURE_TRUE(scriptableAlertTitle, NS_ERROR_FAILURE);
scriptableAlertTitle->SetData(nsDependentString(aAlertTitle));
argsArray->AppendElement(scriptableAlertTitle);
nsCOMPtr<nsISupportsString> scriptableAlertText (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
NS_ENSURE_TRUE(scriptableAlertText, NS_ERROR_FAILURE);
scriptableAlertText->SetData(nsDependentString(aAlertText));
argsArray->AppendElement(scriptableAlertText);
nsCOMPtr<nsISupportsPRBool> scriptableIsClickable (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID));
NS_ENSURE_TRUE(scriptableIsClickable, NS_ERROR_FAILURE);
scriptableIsClickable->SetData(aAlertTextClickable);
argsArray->AppendElement(scriptableIsClickable);
nsCOMPtr<nsISupportsString> scriptableAlertCookie (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
NS_ENSURE_TRUE(scriptableAlertCookie, NS_ERROR_FAILURE);
scriptableAlertCookie->SetData(nsDependentString(aAlertCookie));
argsArray->AppendElement(scriptableAlertCookie);
if (aAlertListener)
{
nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupports> iSupports (do_QueryInterface(aAlertListener));
ifptr->SetData(iSupports);
ifptr->SetDataIID(&NS_GET_IID(nsISupports));
argsArray->AppendElement(ifptr);
#if 0
argsArray->AppendElement(aAlertListener);
#endif
}
rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",
"chrome,dialog=yes,titlebar=no,popup=yes", argsArray,
getter_AddRefs(newWindow));
return rv;
}

View File

@ -0,0 +1,57 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAlertsService_h__
#define nsAlertsService_h__
#include "nsIAlertsService.h"
#include "nsCOMPtr.h"
class nsAlertsService : public nsIAlertsService
{
public:
NS_DECL_NSIALERTSSERVICE
NS_DECL_ISUPPORTS
nsAlertsService();
virtual ~nsAlertsService();
protected:
};
#endif /* nsAlertsService_h__ */

View File

@ -44,6 +44,10 @@ REQUIRES = \
intl \
docshell \
autocomplete \
downloads \
mimetype \
webbrowserpersist \
progressDlg \
history \
satchel \
necko \
@ -51,24 +55,38 @@ REQUIRES = \
uriloader \
$(NULL)
ifeq ($(OS_ARCH),WINNT)
REQUIRES += alerts
endif
EXPORTS = nsToolkitCompsCID.h
CPPSRCS = nsModule.cpp
LOCAL_INCLUDES = \
-I$(srcdir)/../autocomplete/src \
-I$(srcdir)/../downloads/src \
-I$(srcdir)/../history/src \
-I$(srcdir)/../satchel/src \
-I$(srcdir)/../passwordmgr/base \
$(NULL)
ifeq ($(OS_ARCH),WINNT)
LOCAL_INCLUDES += -I$(srcdir)/../alerts/src
endif
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)autocomplete_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)download_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)history_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)satchel_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)passwordmgr_s.$(LIB_SUFFIX) \
$(NULL)
ifeq ($(OS_ARCH),WINNT)
SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)alerts_s.$(LIB_SUFFIX)
endif
EXTRA_DSO_LIBS = gkgfx
EXTRA_DSO_LDOPTS += \

View File

@ -37,9 +37,14 @@
#include "nsIGenericFactory.h"
#ifdef XP_WIN
#include "nsAlertsService.h"
#endif
#include "nsToolkitCompsCID.h"
#include "nsAutoCompleteController.h"
#include "nsAutoCompleteMdbResult.h"
#include "nsDownloadManager.h"
#include "nsDownloadProxy.h"
#include "nsFormHistory.h"
#include "nsFormFillController.h"
#include "nsGlobalHistory.h"
@ -48,8 +53,13 @@
/////////////////////////////////////////////////////////////////////////////
#ifdef XP_WIN
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAlertsService)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAutoCompleteController)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAutoCompleteMdbResult)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDownloadManager, Init)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsFormHistory, nsFormHistory::GetInstance)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFormFillController)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGlobalHistory, Init)
@ -69,6 +79,12 @@ static void PR_CALLBACK nsToolkitCompModuleDtor(nsIModule* self)
static const nsModuleComponentInfo components[] =
{
#ifdef XP_WIN
{ "Alerts Service",
NS_ALERTSSERVICE_CID,
NS_ALERTSERVICE_CONTRACTID,
nsAlertsServiceConstructor },
#endif
{ "AutoComplete Controller",
NS_AUTOCOMPLETECONTROLLER_CID,
NS_AUTOCOMPLETECONTROLLER_CONTRACTID,
@ -79,6 +95,16 @@ static const nsModuleComponentInfo components[] =
NS_AUTOCOMPLETEMDBRESULT_CONTRACTID,
nsAutoCompleteMdbResultConstructor },
{ "Download Manager",
NS_DOWNLOADMANAGER_CID,
NS_DOWNLOADMANAGER_CONTRACTID,
nsDownloadManagerConstructor },
{ "Download",
NS_DOWNLOAD_CID,
NS_DOWNLOAD_CONTRACTID,
nsDownloadProxyConstructor },
{ "HTML Form History",
NS_FORMHISTORY_CID,
NS_FORMHISTORY_CONTRACTID,

View File

@ -35,12 +35,21 @@
*
* ***** END LICENSE BLOCK ***** */
#define NS_ALERTSERVICE_CONTRACTID \
"@mozilla.org/alerts-service;1"
#define NS_AUTOCOMPLETECONTROLLER_CONTRACTID \
"@mozilla.org/autocomplete/controller;1"
#define NS_AUTOCOMPLETECONTROLLER_CONTRACTID \
"@mozilla.org/autocomplete/controller;1"
#define NS_AUTOCOMPLETEMDBRESULT_CONTRACTID \
"@mozilla.org/autocomplete/mdb-result;1"
#define NS_DOWNLOADMANAGER_CONTRACTID \
"@mozilla.org/download-manager;1"
#define NS_FORMHISTORY_CONTRACTID \
"@mozilla.org/satchel/form-history;1"
@ -55,6 +64,10 @@
/////////////////////////////////////////////////////////////////////////////
// {A0CCAAF8-09DA-44D8-B250-9AC3E93C8117}
#define NS_ALERTSSERVICE_CID \
{ 0xa0ccaaf8, 0x9da, 0x44d8, { 0xb2, 0x50, 0x9a, 0xc3, 0xe9, 0x3c, 0x81, 0x17 } }
// {F6D5EBBD-34F4-487d-9D10-3D34123E3EB9}
#define NS_AUTOCOMPLETECONTROLLER_CID \
{ 0xf6d5ebbd, 0x34f4, 0x487d, { 0x9d, 0x10, 0x3d, 0x34, 0x12, 0x3e, 0x3e, 0xb9 } }
@ -63,6 +76,9 @@
#define NS_AUTOCOMPLETEMDBRESULT_CID \
{ 0x7a6f70b6, 0x2bbd, 0x44b5, { 0x93, 0x4, 0x50, 0x13, 0x52, 0xd4, 0x4a, 0xb5 } }
#define NS_DOWNLOADMANAGER_CID \
{ 0xedb0490e, 0x1dd1, 0x11b2, { 0x83, 0xb8, 0xdb, 0xf8, 0xd8, 0x59, 0x06, 0xa6 } }
// {895DB6C7-DBDF-40ea-9F64-B175033243DC}
#define NS_FORMFILLCONTROLLER_CID \
{ 0x895db6c7, 0xdbdf, 0x40ea, { 0x9f, 0x64, 0xb1, 0x75, 0x3, 0x32, 0x43, 0xdc } }

View File

@ -0,0 +1,32 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,35 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = downloads
XPIDLSRCS = nsIDownloadManager.idl \
nsIDownloadProgressListener.idl \
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,197 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Blake Ross <blaker@netscape.com>
* Ben Goodger <ben@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// Keeps track of ongoing downloads, in the form of nsIDownload's.
#include "nsISupports.idl"
interface nsIDOMWindow;
interface nsIURI;
interface nsILocalFile;
interface nsIDownload;
interface nsIWebBrowserPersist;
interface nsIMIMEInfo;
interface nsIRDFDataSource;
interface nsIDownloadProgressListener;
interface nsISupportsArray;
[scriptable, uuid(9be66cc0-1dd1-11b2-8617-e3a3ed26e3b0)]
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 (nsIURI) of the download.
*
* @param aTarget The local file to which the download is being saved.
*
* @param aDisplayName The user-readable description of the download.
*
* @param aPersist The "persist" used to transfer the download. If set,
* the manager will set its listener to the download item
* and use it for cancellation. If not set, the client
* is expected to set the download item as the listener on
* whatever transfer component is being used, and to
* set an observer on the download item that listens for
* the "oncancel" topic and cancels the download.
*
* @return The newly created download item with the passed-in properties.
*/
nsIDownload addDownload(in nsIURI aSource,
in nsILocalFile aTarget,
in wstring aDisplayName,
in nsIMIMEInfo aMIMEInfo,
in long long startTime,
in nsIWebBrowserPersist aPersist);
/**
* Retrieves an in-progress download managed by the download manager.
*
* @param aPersistentDescriptor The unique identifier used to describe a
* a download, and an attribute of nsILocalFile.
* On Windows and Linux, this is just the path
* of the target, but on Mac this is guaranteed
* to be unique.
*
* @return The download with the specified persistent descriptor.
*/
nsIDownload getDownload(in wstring aPersistentDescriptor);
/**
* Cancels the download with the specified persistent descriptor if it's
* currently in progress. If a "persist" was specified for the download,
* nsIWebBrowserPersist::CancelSave will be called. If an observer was set
* on the nsIDownload, it will be notified with the "oncancel" topic. Clients
* that don't provide a "persist" must listen for this topic and cancel the
* download.
*
* @param aPersistentDescriptor The persistent descriptor of the download to
* be cancelled.
*/
void cancelDownload(in wstring aPersistentDescriptor);
/**
* Removes the download with the specified persistent descriptor if it's not
* currently in progress. Whereas cancelDownload simply cancels the transfer
* but retains information about it, removeDownload removes all knowledge of it.
*
* @param aPersistentDescriptor The persistent descriptor of the download to
* be removed.
*/
void removeDownload(in wstring aPersistentDescriptor);
/**
* Pause the specified download.
*/
void pauseDownload(in wstring aPersistentDescriptor);
/**
* Resume the specified download.
*/
void resumeDownload(in wstring aPersistentDescriptor);
// Front end and Front end update 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 widnow. Useful if,
* for example, you want the window to select a certain
* download (optional).
*/
void open(in nsIDOMWindow aParent, in wstring aPersistentDescriptor);
/**
* The Download Manager's progress listener.
*/
attribute nsIDownloadProgressListener listener;
/**
* Indicate that a batch update (e.g. mass removal) is about to start.
*/
void startBatchUpdate();
/**
* Indicate that a batch update is ending.
*/
void endBatchUpdate();
// Downloads list book-keeping
/**
* Whether or not there are downloads that can be cleaned up (removed)
* i.e. downloads that have completed, have failed or have been canceled.
*/
readonly attribute boolean canCleanUp;
/**
* Removes completed, failed, and canceled downloads from the list.
*/
void cleanUp();
/**
* The number of files currently being downloaded.
*/
readonly attribute long activeDownloadCount;
/**
* An enumeration of active downloads.
*/
readonly attribute nsISupportsArray activeDownloads;
/**
* Update the download datasource.
*/
void saveState();
/**
* Flush the download datasource to disk.
*/
void flush();
readonly attribute nsIRDFDataSource datasource;
};

View File

@ -0,0 +1,95 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Blake Ross <blaker@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* 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(09cddbea-1dd2-11b2-aa15-c41ffea19d79)]
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 aCurSelfProgress,
in long aMaxSelfProgress,
in long aCurTotalProgress,
in 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);
};

View File

@ -0,0 +1,67 @@
#! gmake
#
# 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 Netscape are
# Copyright (C) 2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Stuart Parmenter <pavlov@netscape.com>
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = downloads
LIBRARY_NAME = download_s
REQUIRES = xpcom \
string \
rdf \
uriloader \
mimetype \
necko \
pref \
progressDlg \
intl \
windowwatcher \
webbrowserpersist \
appshell \
dom \
toolkitcomps \
$(NULL)
ifeq ($(OS_ARCH),WINNT)
REQUIRES += alerts
endif
CPPSRCS = \
nsDownloadManager.cpp \
$(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

View File

@ -0,0 +1,184 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Blake Ross <blaker@netscape.com>
* Ben Goodger <ben@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#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 "nsIWebProgressListener.h"
#include "nsIURI.h"
#include "nsIWebBrowserPersist.h"
#include "nsILocalFile.h"
#include "nsHashtable.h"
#include "nsIRequest.h"
#include "nsIObserver.h"
#include "nsIStringBundle.h"
#include "nsIProgressDialog.h"
#include "nsIMIMEInfo.h"
#include "nsITimer.h"
#ifdef XP_WIN
#include "nsIAlertsService.h"
#endif
enum DownloadState { NOTSTARTED = -1, DOWNLOADING, FINISHED, FAILED, CANCELED, PAUSED };
class nsDownloadManager : public nsIDownloadManager,
public nsIObserver
#ifdef XP_WIN
, public nsIAlertListener
#endif
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOWNLOADMANAGER
NS_DECL_NSIOBSERVER
#ifdef XP_WIN
NS_DECL_NSIALERTLISTENER
#endif
nsresult Init();
nsDownloadManager();
virtual ~nsDownloadManager();
static PRInt32 PR_CALLBACK CancelAllDownloads(nsHashKey* aKey, void* aData, void* aClosure);
static PRInt32 PR_CALLBACK BuildActiveDownloadsList(nsHashKey* aKey, void* aData, void* aClosure);
nsresult DownloadEnded(const PRUnichar* aPersistentDescriptor, const PRUnichar* aMessage);
protected:
nsresult GetDownloadsContainer(nsIRDFContainer** aResult);
nsresult GetProfileDownloadsFileURL(nsCString& aDownloadsFileURL);
nsresult GetDataSource(nsIRDFDataSource** aDataSource);
nsresult DownloadStarted(const PRUnichar* aPersistentDescriptor);
nsresult AssertProgressInfoFor(const PRUnichar* aPersistentDescriptor);
nsresult GetInternalListener(nsIDownloadProgressListener** aListener);
nsresult PauseResumeDownload(const PRUnichar* aPath, PRBool aPause);
nsresult RemoveDownload(nsIRDFResource* aDownload);
nsresult ValidateDownloadsContainer();
static void OpenTimerCallback(nsITimer* aTimer, void* aClosure);
static nsresult OpenDownloadManager(PRBool aShouldFocus, nsIDownload* aDownload, nsIDOMWindow* aParent);
PRBool NeedsUIUpdate() { return mListener != nsnull; }
PRInt32 GetRetentionBehavior();
private:
nsCOMPtr<nsIDownloadProgressListener> mListener;
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsCOMPtr<nsIRDFContainer> mDownloadsContainer;
nsCOMPtr<nsIRDFContainerUtils> mRDFContainerUtils;
nsCOMPtr<nsIStringBundle> mBundle;
nsCOMPtr<nsITimer> mDMOpenTimer;
PRInt32 mBatches;
nsHashtable mCurrDownloads;
enum {
kDownloadWindowCacheDelay = 2000 // The delay before the Download Manager
// window pops up after a link, to prevent
// the window from showing if the download
// is instantaneous (e.g. from cache)
};
friend class nsDownload;
};
class nsDownload : public nsIDownload,
public nsIWebProgressListener
{
public:
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIDOWNLOAD
NS_DECL_ISUPPORTS
nsDownload();
virtual ~nsDownload();
protected:
nsresult SetDownloadManager(nsDownloadManager* aDownloadManager);
nsresult SetDialogListener(nsIWebProgressListener* aInternalListener);
nsresult GetDialogListener(nsIWebProgressListener** aInternalListener);
nsresult SetDialog(nsIProgressDialog* aDialog);
nsresult GetDialog(nsIProgressDialog** aDialog);
nsresult SetPersist(nsIWebBrowserPersist* aPersist);
nsresult SetTarget(nsILocalFile* aTarget);
nsresult SetSource(nsIURI* aSource);
nsresult GetTransferInformation(PRInt32* aCurr, PRInt32* aMax);
nsresult GetDownloadState(DownloadState* aState);
nsresult SetDownloadState(DownloadState aState);
nsresult SetMIMEInfo(nsIMIMEInfo* aMIMEInfo);
nsresult SetStartTime(PRInt64 aStartTime);
void Pause(PRBool aPaused);
PRBool IsPaused();
nsDownloadManager* mDownloadManager;
nsCOMPtr<nsILocalFile> mTarget;
private:
nsString mDisplayName;
nsCOMPtr<nsIURI> mSource;
nsCOMPtr<nsIWebProgressListener> mDialogListener;
nsCOMPtr<nsIWebBrowserPersist> mPersist;
nsCOMPtr<nsIRequest> mRequest;
nsCOMPtr<nsIProgressDialog> mDialog;
nsCOMPtr<nsIObserver> mObserver;
nsCOMPtr<nsIMIMEInfo> mMIMEInfo;
DownloadState mDownloadState;
PRBool mPaused;
PRInt32 mPercentComplete;
PRInt32 mCurrBytes;
PRInt32 mMaxBytes;
PRInt64 mStartTime;
PRTime mLastUpdate;
friend class nsDownloadManager;
};
#endif

View File

@ -0,0 +1,319 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Blake Ross <blaker@netscape.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var gStrings = new Array;
const interval = 500; // Update every 500 milliseconds.
function nsDownloadProgressListener() {
}
nsDownloadProgressListener.prototype = {
elapsed: 0,
rateChanges: 0,
rateChangeLimit: 0,
priorRate: 0,
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.target.persistentDescriptor;
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", "");
}
},
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;
// Update download rate.
this.elapsed = now - (aDownload.startTime / 1000);
var rate; // aCurTotalProgress/sec
if ( this.elapsed )
rate = ( aCurTotalProgress * 1000 ) / this.elapsed;
else
rate = 0;
var aDownloadID = aDownload.target.persistentDescriptor;
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( this.elapsed / 1000, 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 );
if ( rate )
{
// rate is bytes/sec
var kRate = rate / 1024; // K bytes/sec;
kRate = parseInt( kRate * 10 + .5 ); // xxx (3 digits)
// 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;
var fraction = kRate % 10;
kRate = parseInt( ( kRate - fraction ) / 10 );
// Insert 3 is the download rate (in kilobytes/sec).
rateMsg = replaceInsert( rateMsg, 1, kRate + "." + fraction );
}
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;
}

View File

@ -0,0 +1,207 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Blake Ross <blaker@netscape.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef downloadproxy___h___
#define downloadproxy___h___
#include "nsIDownload.h"
#include "nsIDownloadManager.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIMIMEInfo.h"
#define USE_PROGRESS_DIALOGS_PREF "browser.download.useProgressDialogs"
class nsDownloadProxy : public nsIDownload,
public nsIWebProgressListener
{
public:
nsDownloadProxy() { }
virtual ~nsDownloadProxy() { };
NS_DECL_ISUPPORTS
NS_IMETHODIMP Init(nsIURI* aSource,
nsILocalFile* aTarget,
const PRUnichar* aDisplayName,
nsIMIMEInfo *aMIMEInfo,
PRInt64 aStartTime,
nsIWebBrowserPersist* aPersist) {
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, aPersist, getter_AddRefs(mInner));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
PRBool useProgressDialogs = PR_TRUE;
branch->GetBoolPref(USE_PROGRESS_DIALOGS_PREF, &useProgressDialogs);
if (useProgressDialogs) {
nsAutoString path;
rv = aTarget->GetPath(path);
if (NS_FAILED(rv)) return rv;
return dm->Open(nsnull, path.get());
}
return rv;
}
NS_IMETHODIMP GetDisplayName(PRUnichar** aDisplayName)
{
return mInner->GetDisplayName(aDisplayName);
}
NS_IMETHODIMP SetDisplayName(const PRUnichar* aDisplayName)
{
return mInner->SetDisplayName(aDisplayName);
}
NS_IMETHODIMP GetMIMEInfo(nsIMIMEInfo** aMIMEInfo)
{
return mInner->GetMIMEInfo(aMIMEInfo);
}
NS_IMETHODIMP GetSource(nsIURI** aSource)
{
return mInner->GetSource(aSource);
}
NS_IMETHODIMP GetTarget(nsILocalFile** aTarget)
{
return mInner->GetTarget(aTarget);
}
NS_IMETHODIMP GetStartTime(PRInt64* aStartTime)
{
return mInner->GetStartTime(aStartTime);
}
NS_IMETHODIMP GetPercentComplete(PRInt32* aPercentComplete)
{
return mInner->GetPercentComplete(aPercentComplete);
}
NS_IMETHODIMP GetListener(nsIWebProgressListener** aListener)
{
return mInner->GetListener(aListener);
}
NS_IMETHODIMP SetListener(nsIWebProgressListener* aListener)
{
return mInner->SetListener(aListener);
}
NS_IMETHODIMP GetObserver(nsIObserver** aObserver)
{
return mInner->GetObserver(aObserver);
}
NS_IMETHODIMP SetObserver(nsIObserver* aObserver)
{
return mInner->SetObserver(aObserver);
}
NS_IMETHODIMP GetPersist(nsIWebBrowserPersist** aPersist)
{
return mInner->GetPersist(aPersist);
}
NS_IMETHODIMP OnStateChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest, PRUint32 aStateFlags,
PRUint32 aStatus)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
return NS_OK;
}
NS_IMETHODIMP OnStatusChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsresult aStatus,
const PRUnichar *aMessage)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
return NS_OK;
}
NS_IMETHODIMP OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *aLocation)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnLocationChange(aWebProgress, aRequest, aLocation);
return NS_OK;
}
NS_IMETHODIMP OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnProgressChange(aWebProgress, aRequest, aCurSelfProgress,
aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
return NS_OK;
}
NS_IMETHODIMP OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRUint32 aState)
{
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mInner);
if (listener)
return listener->OnSecurityChange(aWebProgress, aRequest, aState);
return NS_OK;
}
private:
nsCOMPtr<nsIDownload> mInner;
};
NS_IMPL_ISUPPORTS2(nsDownloadProxy, nsIDownload, nsIWebProgressListener)
#endif

View File

@ -0,0 +1,74 @@
/**
* Opens an individual progress dialog displaying progress for the download.
*
* @param aPersistentDescriptor The persistent descriptor of the download to
* display progress for.
*
* @param aParent The parent, or opener, of the front end (optional).
*/
void openProgressDialogFor(in wstring aPersistentDescriptor, in nsIDOMWindow aParent);
NS_IMETHODIMP
nsDownloadManager::OpenProgressDialogFor(const PRUnichar* aPath, nsIDOMWindow* aParent)
{
nsresult rv;
nsStringKey key(aPath);
if (!mCurrDownloads.Exists(&key))
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDownload> download;
nsDownload* internalDownload = NS_STATIC_CAST(nsDownload*, mCurrDownloads.Get(&key));
internalDownload->QueryInterface(NS_GET_IID(nsIDownload), (void**) getter_AddRefs(download));
if (!download)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIProgressDialog> oldDialog;
internalDownload->GetDialog(getter_AddRefs(oldDialog));
if (oldDialog) {
nsCOMPtr<nsIDOMWindow> window;
oldDialog->GetDialog(getter_AddRefs(window));
if (window) {
nsCOMPtr<nsIDOMWindowInternal> internalWin = do_QueryInterface(window);
internalWin->Focus();
return NS_OK;
}
}
nsCOMPtr<nsIProgressDialog> dialog(do_CreateInstance("@mozilla.org/progressdialog;1", &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDownload> dl = do_QueryInterface(dialog);
// now give the dialog the necessary context
// start time...
PRInt64 startTime = 0;
download->GetStartTime(&startTime);
// source...
nsCOMPtr<nsIURI> source;
download->GetSource(getter_AddRefs(source));
// target...
nsCOMPtr<nsILocalFile> target;
download->GetTarget(getter_AddRefs(target));
// helper app...
nsCOMPtr<nsIMIMEInfo> mimeInfo;
download->GetMIMEInfo(getter_AddRefs(mimeInfo));
dl->Init(source, target, nsnull, mimeInfo, startTime, nsnull);
dl->SetObserver(this);
// now set the listener so we forward notifications to the dialog
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(dialog);
internalDownload->SetDialogListener(listener);
internalDownload->SetDialog(dialog);
return dialog->Open(aParent);
}

View File

@ -6,7 +6,12 @@ function goQuitApplication()
{
try
{
ObserverService.notifyObservers(null, "quit-application-requested", null);
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"].createInstance(Components.interfaces.nsISupportsPRBool);
ObserverService.notifyObservers(cancelQuit, "quit-application-requested", null);
// Something aborted the quit process.
if (cancelQuit.data)
return;
}
catch (ex)
{

View File

@ -0,0 +1,264 @@
var gStrings = [];
const interval = 500; // Update every 500 milliseconds.
function DownloadProgressListener (aDocument, aStringBundle)
{
this.doc = aDocument;
this._statusFormat = aStringBundle.getString("statusFormat");
this._statusFormatKBMB = aStringBundle.getString("statusFormatKBMB");
this._statusFormatKBKB = aStringBundle.getString("statusFormatKBKB");
this._statusFormatMBMB = aStringBundle.getString("statusFormatMBMB");
this._longTimeFormat = aStringBundle.getString("longTimeFormat");
this._shortTimeFormat = aStringBundle.getString("shortTimeFormat");
}
DownloadProgressListener.prototype =
{
elapsed: 0,
rateChanges: 0,
rateChangeLimit: 0,
priorRate: 0,
lastUpdate: -500,
doc: null,
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus, aDownload)
{
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) {
var aDownloadID = aDownload.target.persistentDescriptor;
var download = this.doc.getElementById(aDownloadID);
if (download)
download.setAttribute("status", "");
}
},
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;
// Update download rate.
this.elapsed = now - (aDownload.startTime / 1000);
var rate; // aCurTotalProgress/sec
if (this.elapsed)
rate = (aCurTotalProgress * 1000) / this.elapsed;
else
rate = 0;
var aDownloadID = aDownload.target.persistentDescriptor;
var download = this.doc.getElementById(aDownloadID);
// Calculate percentage.
var percent;
if (aMaxTotalProgress > 0) {
percent = Math.floor((overallProgress*100.0)/aMaxTotalProgress);
if (percent > 100)
percent = 100;
// Advance progress meter.
if (download) {
download.setAttribute("progress", percent);
download.setAttribute("progressmode", "normal");
onUpdateProgress();
}
}
else {
percent = -1;
// Progress meter should be barber-pole in this case.
download.setAttribute("progressmode", "undetermined");
}
// Now that we've set the progress and the time, update the UI with
// all the the pertinent information (bytes transferred, bytes total,
// download rate, time remaining).
var status = this._statusFormat;
// Insert the progress so far using the formatting routine.
var KBProgress = parseInt(overallProgress/1024 + .5);
var KBTotal = parseInt(aMaxTotalProgress/1024 + .5);
var kbProgress = this._formatKBytes(KBProgress, KBTotal);
status = this._replaceInsert(status, 1, kbProgress);
if (download)
download.setAttribute("status-internal", kbProgress);
if (rate) {
// rate is bytes/sec
var kRate = rate / 1024; // K bytes/sec;
kRate = parseInt( kRate * 10 + .5 ); // xxx (3 digits)
// 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;
var fraction = kRate % 10;
kRate = parseInt((kRate - fraction) / 10);
// Insert 3 is the download rate (in kilobytes/sec).
status = this._replaceInsert(status, 2, kRate + "." + fraction);
}
else
status = this._replaceInsert(status, 2, "??.?");
// Update time remaining.
if (rate && (aMaxTotalProgress > 0)) {
var rem = (aMaxTotalProgress - aCurTotalProgress) / rate;
rem = parseInt(rem + .5);
status = this._replaceInsert(status, 3, this._formatSeconds(rem, this.doc));
}
else
status = this._replaceInsert(status, 3, "???");
if (download)
download.setAttribute("status", status);
},
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;
},
_replaceInsert: function ( text, index, value )
{
var result = text;
var regExp = new RegExp( "#"+index );
result = result.replace( regExp, value );
return result;
},
// aBytes aTotalKBytes returns:
// x, < 1MB y < 1MB x of y KB
// x, < 1MB y >= 1MB x KB of y MB
// x, >= 1MB y >= 1MB x of y MB
_formatKBytes: function (aKBytes, aTotalKBytes)
{
var progressHasMB = parseInt(aKBytes/1000) > 0;
var totalHasMB = parseInt(aTotalKBytes/1000) > 0;
var format = "";
if (!progressHasMB && !totalHasMB) {
format = this._statusFormatKBKB;
format = this._replaceInsert(format, 1, aKBytes);
format = this._replaceInsert(format, 2, aTotalKBytes);
}
else if (progressHasMB && totalHasMB) {
format = this._statusFormatMBMB;
format = this._replaceInsert(format, 1, (aKBytes / 1000).toFixed(1));
format = this._replaceInsert(format, 2, (aTotalKBytes / 1000).toFixed(1));
}
else if (totalHasMB && !progressHasMB) {
format = this._statusFormatKBMB;
format = this._replaceInsert(format, 1, aKBytes);
format = this._replaceInsert(format, 2, (aTotalKBytes / 1000).toFixed(1));
}
else {
// This is an undefined state!
dump("*** huh?!\n");
}
return format;
},
_formatSeconds: function (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 = hours ? this._longTimeFormat : this._shortTimeFormat;
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 = this._replaceInsert(result, 1, hours);
result = this._replaceInsert(result, 2, mins);
result = this._replaceInsert(result, 3, secs);
return result;
},
};
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# 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
# Doron Rosenberg.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Blake Ross <blakeross@telocity.com> (Original Author)
# Ben Goodger <ben@bengoodger.com> (v2.0)
#
# 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 *****

View File

@ -0,0 +1,458 @@
<?xml version="1.0"?>
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# 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
# Doron Rosenberg.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ben Goodger <ben@bengoodger.com> (v2.0)
# Blake Ross <blakeross@telocity.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 *****
<!DOCTYPE window [
<!ENTITY % downloadDTD SYSTEM "chrome://mozapps/locale/downloads/downloads.dtd" >
%downloadDTD;
]>
<bindings id="downloadBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<binding id="download-base">
<resources>
<stylesheet src="chrome://mozapps/skin/downloads/downloads.css"/>
</resources>
<implementation>
<method name="fireEvent">
<parameter name="aEventType"/>
<body>
<![CDATA[
var e = document.createEvent("Events");
e.initEvent("download-" + aEventType, false, true);
this.dispatchEvent(e);
]]>
</body>
</method>
<property name="paused">
<getter>
<![CDATA[
return this.getAttribute("state") == "4";
]]>
</getter>
</property>
<property name="openable">
<getter>
<![CDATA[
return this.getAttribute("state") == "1";
]]>
</getter>
</property>
<property name="inProgress">
<getter>
<![CDATA[
var state = this.getAttribute("state");
return state == "-1" || state == "0" || state == "4";
]]>
</getter>
</property>
<property name="removable">
<getter>
<![CDATA[
var state = this.getAttribute("state");
return state == "1" || state == "2" || state == "3";
]]>
</getter>
</property>
<property name="canceledOrFailed">
<getter>
<![CDATA[
var state = this.getAttribute("state");
return state == "2" || state == "3";
]]>
</getter>
</property>
<method name="pauseResume">
<body>
<![CDATA[
// Do nothing.
]]>
</body>
</method>
<constructor>
<![CDATA[
// This is a hack to circumvent the template builder, which eats every character
// after 'rdf:' and assumes it's part of the property name.
this.setAttribute("image", this.getAttribute("image") + "?size=32");
]]>
</constructor>
</implementation>
</binding>
<binding id="download-starting" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target" crop="middle"/>
<xul:label value="&starting.label;"/>
</xul:vbox>
<xul:vbox pack="start">
<xul:label value="&cancel.label;" class="link"
onclick="this.parentNode.parentNode.parentNode.fireEvent('cancel');"/>
</xul:vbox>
</xul:hbox>
</content>
</binding>
<binding id="download-downloading" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1" class="downloadContentBox" xbl:inherits="animated,animated-temp">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox flex="1">
<xul:label xbl:inherits="value=target" flex="1" crop="middle"/>
<xul:progressmeter mode="normal" value="0" flex="1"
xbl:inherits="value=progress,mode=progressmode"/>
<xul:hbox align="center" flex="1">
<xul:label value="&pause.label;" class="link"
onclick="this.parentNode.parentNode.parentNode.parentNode.fireEvent('pause');"/>
<xul:label xbl:inherits="value=status"/>
</xul:hbox>
</xul:vbox>
<xul:vbox pack="start">
<xul:label value="&cancel.label;" class="link"
onclick="this.parentNode.parentNode.parentNode.fireEvent('cancel');"/>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<!-- ANIMATE: Type Icon -->
<property name="_ati_kTimeout" onget="return 50;"/>
<property name="_ati_kUpperBounds" onget="return 90;"/>
<property name="_ati_kLowerBounds" onget="return 30;"/>
<property name="_ati_kIncrement" onget="return 5;"/>
<field name="_atiStep">0</field>
<field name="_atiIsIncrementing">true</field>
<field name="_atiInterval">-1</field>
<method name="_atiTimerCallback">
<parameter name="aDownload"/>
<parameter name="aIcon"/>
<body>
<![CDATA[
if (aDownload.getAttribute("state") != "0") {
clearInterval(aDownload._atiInterval)
return;
}
if (aDownload._atiIsIncrementing)
aDownload._atiStep += aDownload._ati_kIncrement;
else
aDownload._atiStep -= aDownload._ati_kIncrement;
if (aDownload._atiStep == aDownload._ati_kUpperBounds)
aDownload._atiIsIncrementing = false;
else if (aDownload._atiStep == aDownload._ati_kLowerBounds)
aDownload._atiIsIncrementing = true;
aIcon.setAttribute("style", "-moz-opacity: 0." + aDownload._atiStep );
]]>
</body>
</method>
<method name="_animateIcon">
<body>
<![CDATA[
this._atiStep = this._ati_kLowerBounds;
this._atiIsIncrementing = true;
var icon = document.getAnonymousElementByAttribute(this, "class", "downloadTypeIcon");
this._atiInterval = setInterval(this._atiTimerCallback, this._ati_kTimeout, this, icon);
]]>
</body>
</method>
<!-- ANIMATE: Download -->
<property name="_adl_kTimeout" onget="return 50;"/>
<property name="_adl_kUpperBounds" onget="return 1.00;"/>
<property name="_adl_kLowerBounds" onget="return 0.00;"/>
<property name="_adl_kIncrement" onget="return 0.05;"/>
<field name="_adlStep">0</field>
<method name="_adlTimerCallback">
<parameter name="aDownload"/>
<parameter name="aContent"/>
<body>
<![CDATA[
if (aDownload.getAttribute("state") != "0" ||
aDownload._adlStep > aDownload._adl_kUpperBounds) {
aDownload.fireEvent('animated');
return;
}
// Don't even bother if we're going away.
if (!aContent.ownerDocument)
return;
aDownload._adlStep += aDownload._adl_kIncrement;
aContent.setAttribute("style", "-moz-opacity: " + aDownload._adlStep + "!important;");
setTimeout(aDownload._adlTimerCallback, aDownload._adl_kTimeout, aDownload, aContent);
]]>
</body>
</method>
<method name="_animateDownload">
<body>
<![CDATA[
this._adlStep = this._adl_kLowerBounds;
var box = document.getAnonymousElementByAttribute(this, "class", "downloadContentBox");
setTimeout(this._adlTimerCallback, this._adl_kTimeout, this, box);
]]>
</body>
</method>
<method name="_shouldDownloadAnimate">
<body>
<![CDATA[
return this.getAttribute("animated") != "true";
]]>
</body>
</method>
<method name="pauseResume">
<body>
<![CDATA[
this.fireEvent("pause");
]]>
</body>
</method>
<constructor>
<![CDATA[
// this._animateIcon();
if (this._shouldDownloadAnimate())
this._animateDownload();
]]>
</constructor>
</implementation>
</binding>
<binding id="download-paused" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox flex="1">
<xul:label xbl:inherits="value=target" flex="1" crop="middle"/>
<xul:progressmeter mode="normal" value="0" flex="1"
xbl:inherits="value=progress,mode=progressmode"/>
<xul:hbox align="center" flex="1">
<xul:label value="&resume.label;" class="link"
onclick="this.parentNode.parentNode.parentNode.parentNode.fireEvent('resume');"/>
<xul:label xbl:inherits="value=status"/>
</xul:hbox>
</xul:vbox>
<xul:vbox pack="start">
<xul:label value="&cancel.label;" class="link"
onclick="this.parentNode.parentNode.parentNode.fireEvent('cancel');"/>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<method name="pauseResume">
<body>
<![CDATA[
this.fireEvent("resume");
]]>
</body>
</method>
</implementation>
</binding>
<binding id="download-done" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target" crop="middle"/>
<xul:label value="&done.label;"/>
</xul:vbox>
<xul:vbox pack="start">
<xul:label value="&show.label;" class="link"
onclick="this.parentNode.parentNode.parentNode.fireEvent('show');"/>
</xul:vbox>
</xul:hbox>
</content>
</binding>
<binding id="download-canceled" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target" crop="middle"/>
<xul:label value="&canceled.label;"/>
</xul:vbox>
<xul:vbox pack="start">
<xul:label value="&retry.label;" class="link"
onclick="this.parentNode.parentNode.parentNode.fireEvent('retry');"/>
</xul:vbox>
</xul:hbox>
</content>
</binding>
<binding id="download-failed" extends="chrome://mozapps/content/downloads/download.xml#download-base">
<content>
<xul:hbox flex="1">
#ifdef XP_WIN
<xul:vbox pack="start">
<xul:image class="downloadTypeIcon" style="width: 32px; max-width: 32px; height: 32px; max-height: 32px;" xbl:inherits="src=image"/>
</xul:vbox>
#endif
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target" crop="middle"/>
<xul:label value="&failed.label;"/>
</xul:vbox>
<xul:vbox pack="start">
<xul:label value="&retry.label;" class="link"
onclick="this.parentNode.parentNode.parentNode.fireEvent('retry');"/>
</xul:vbox>
</xul:hbox>
</content>
</binding>
<binding id="download-view">
<implementation>
<field name="_selected">null</field>
<property name="selected">
<setter>
<![CDATA[
if (this._selected)
this._selected.removeAttribute("selected");
this._selected = val;
if (this._selected)
this._selected.setAttribute("selected", "true");
]]>
</setter>
<getter>
<![CDATA[
return this._selected;
]]>
</getter>
</property>
<method name="selectionForward">
<parameter name="aEvent"/>
<body>
<![CDATA[
if (this.selected) {
if (this.selected.nextSibling &&
this.selected.nextSibling.localName == "download")
this.selected = this.selected.nextSibling;
}
else {
if (this.hasChildNodes())
this.selected = this.firstChild.nextSibling;
}
]]>
</body>
</method>
<method name="selectionBackward">
<parameter name="aEvent"/>
<body>
<![CDATA[
if (this.selected) {
if (this.selected.previousSibling &&
this.selected.previousSibling.localName == "download")
this.selected = this.selected.previousSibling;
}
else {
if (this.hasChildNodes())
this.selected = this.lastChild;
}
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="click">
<![CDATA[
if (event.ctrlKey) {
this.selected = null;
return;
}
this.selected = event.target;
]]>
</handler>
<handler event="keypress" keycode="vk_enter" action="if (this.selected) this.selected.fireEvent('open');"/>
<handler event="keypress" keycode="vk_return" action="if (this.selected) this.selected.fireEvent('open');"/>
<handler event="keypress" keycode="vk_up" action="this.selectionBackward(event);"/>
<handler event="keypress" keycode="vk_left" action="this.selectionBackward(event);"/>
<handler event="keypress" keycode="vk_down" action="this.selectionForward(event);"/>
<handler event="keypress" keycode="vk_right" action="this.selectionForward(event);"/>
<handler event="keypress" keycode="vk_up" modifiers="meta" action="this.selected = null"/>
<handler event="keypress" keycode="vk_down" modifiers="meta" action="this.selected = null"/>
<handler event="keypress" keycode="vk_left" modifiers="meta" action="this.selected = null"/>
<handler event="keypress" keycode="vk_right" modifiers="meta" action="this.selected = null"/>
<handler event="keypress" keycode="vk_delete" action="if (this.selected) this.selected.fireEvent('remove');"/>
<handler event="keypress" key=" " action="if (this.selected) { this.selected.pauseResume(); }"/>
</handlers>
</binding>
</bindings>

View File

@ -0,0 +1,60 @@
function Startup()
{
const NC_NS = "http://home.netscape.com/NC-rdf#";
const rdfSvcContractID = "@mozilla.org/rdf/rdf-service;1";
const rdfSvcIID = Components.interfaces.nsIRDFService;
var rdfService = Components.classes[rdfSvcContractID].getService(rdfSvcIID);
const dlmgrContractID = "@mozilla.org/download-manager;1";
const dlmgrIID = Components.interfaces.nsIDownloadManager;
var downloadMgr = Components.classes[dlmgrContractID].getService(dlmgrIID);
var ds = downloadMgr.datasource;
const dateTimeContractID = "@mozilla.org/intl/scriptabledateformat;1";
const dateTimeIID = Components.interfaces.nsIScriptableDateFormat;
var dateTimeService = Components.classes[dateTimeContractID].getService(dateTimeIID);
var resource = rdfService.GetUnicodeResource(window.arguments[0]);
var dateStartedRes = rdfService.GetResource(NC_NS + "DateStarted");
var dateEndedRes = rdfService.GetResource(NC_NS + "DateEnded");
var sourceRes = rdfService.GetResource(NC_NS + "URL");
var dateStartedField = document.getElementById("dateStarted");
var dateEndedField = document.getElementById("dateEnded");
var pathField = document.getElementById("path");
var sourceField = document.getElementById("source");
try {
var dateStarted = ds.GetTarget(resource, dateStartedRes, true).QueryInterface(Components.interfaces.nsIRDFDate).Value;
dateStarted = new Date(dateStarted/1000);
dateStarted = dateTimeService.FormatDateTime("", dateTimeService.dateFormatShort, dateTimeService.timeFormatSeconds, dateStarted.getFullYear(), dateStarted.getMonth()+1, dateStarted.getDate(), dateStarted.getHours(), dateStarted.getMinutes(), dateStarted.getSeconds());
dateStartedField.setAttribute("value", dateStarted);
}
catch (e) {
}
try {
var dateEnded = ds.GetTarget(resource, dateEndedRes, true).QueryInterface(Components.interfaces.nsIRDFDate).Value;
dateEnded = new Date(dateEnded/1000);
dateEnded = dateTimeService.FormatDateTime("", dateTimeService.dateFormatShort, dateTimeService.timeFormatSeconds, dateEnded.getFullYear(), dateEnded.getMonth()+1, dateEnded.getDate(), dateEnded.getHours(), dateEnded.getMinutes(), dateEnded.getSeconds());
dateEndedField.setAttribute("value", dateEnded);
}
catch (e) {
}
var source = ds.GetTarget(resource, sourceRes, true).QueryInterface(Components.interfaces.nsIRDFResource).Value;
pathField.value = window.arguments[0];
sourceField.value = source;
var dl = window.opener.gDownloadManager.getDownload(window.arguments[0]);
if (dl) {
document.getElementById("dateEndedRow").hidden = true;
document.getElementById("dateEndedSeparator").hidden = true;
}
document.documentElement.getButton("accept").label = document.documentElement.getAttribute("acceptbuttontext");
document.documentElement.getButton("accept").focus();
}

View File

@ -0,0 +1,56 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/skin/downloads/downloads.css"?>
<!DOCTYPE window [
<!ENTITY % downloadPropertiesDTD SYSTEM "chrome://mozapps/locale/downloads/downloadProperties.dtd">
%downloadPropertiesDTD;
]>
<dialog xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:nc="http://home.netscape.com/NC-rdf#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&window.title;"
onload="Startup();"
style="width: 30em;"
buttons="accept" acceptbuttontext="&acceptButton.label;">
<script type="application/x-javascript" src="chrome://mozapps/content/downloads/downloadProperties.js"/>
<grid flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<hbox pack="end">
<label value="&downloadedFrom.label;" class="bold"/>
</hbox>
<textbox id="source" readonly="true"/>
</row>
<separator class="thin"/>
<row align="center">
<hbox pack="end">
<label value="&path.label;" class="bold"/>
</hbox>
<textbox id="path" readonly="true"/>
</row>
<separator class="thin"/>
<row align="center">
<hbox pack="end">
<label value="&dateStarted.label;" class="bold"/>
</hbox>
<label id="dateStarted"/>
</row>
<separator class="thin" id="dateEndedSeparator"/>
<row align="center" id="dateEndedRow">
<hbox pack="end">
<label value="&dateEnded.label;" class="bold"/>
</hbox>
<label id="dateEnded"/>
</row>
</rows>
</grid>
<separator/>
</dialog>

View File

@ -0,0 +1,33 @@
download, download[state="-1"] {
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-starting');
-moz-box-orient: vertical;
}
download[state="-1"] {
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-starting');
}
download[state="0"] {
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-downloading');
}
download[state="1"] {
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-done');
}
download[state="2"] {
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-failed');
}
download[state="3"] {
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-canceled');
}
download[state="4"] {
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-paused');
}
#downloadView {
-moz-binding: url('chrome://mozapps/content/downloads/download.xml#download-view');
}

View File

@ -0,0 +1,477 @@
///////////////////////////////////////////////////////////////////////////////
// Globals
const kObserverServiceProgID = "@mozilla.org/observer-service;1";
const NC_NS = "http://home.netscape.com/NC-rdf#";
var gDownloadManager = null;
var gDownloadListener = null;
var gDownloadsView = null;
var gUserInterfered = false;
var gActiveDownloads = [];
///////////////////////////////////////////////////////////////////////////////
// Utility Functions
function setRDFProperty(aID, aProperty, aValue)
{
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
var db = gDownloadManager.datasource;
var propertyArc = rdf.GetResource(NC_NS + aProperty);
var res = rdf.GetResource(aID);
var node = db.GetTarget(res, propertyArc, true);
if (node)
db.Change(res, propertyArc, node, rdf.GetLiteral(aValue));
else
db.Assert(res, propertyArc, rdf.GetLiteral(aValue), true);
}
function getRDFProperty(aID, aProperty)
{
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
var db = gDownloadManager.datasource;
var propertyArc = rdf.GetResource(NC_NS + aProperty);
var res = rdf.GetResource(aID);
var node = db.GetTarget(res, propertyArc, true);
if (!node) return "";
try {
node = node.QueryInterface(Components.interfaces.nsIRDFLiteral);
return node.Value;
}
catch (e) {
try {
node = node.QueryInterface(Components.interfaces.nsIRDFInt);
return node.Value;
}
catch (e) {
node = node.QueryInterface(Components.interfaces.nsIRDFResource);
return node.Value;
}
}
return "";
}
function fireEventForElement(aElement, aEventType)
{
var e = document.createEvent("Events");
e.initEvent("download-" + aEventType, false, true);
aElement.dispatchEvent(e);
}
///////////////////////////////////////////////////////////////////////////////
// Start/Stop Observers
function downloadCompleted(aDownload)
{
// Wrap this in try...catch since this can be called while shutting down...
// it doesn't really matter if it fails then since well.. we're shutting down
// and there's no UI to update!
try {
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
var rdfc = Components.classes["@mozilla.org/rdf/container;1"].createInstance(Components.interfaces.nsIRDFContainer);
var db = gDownloadManager.datasource;
rdfc.Init(db, rdf.GetResource("NC:DownloadsRoot"));
var id = aDownload.target.persistentDescriptor;
var dlRes = rdf.GetUnicodeResource(id);
var insertIndex = gDownloadManager.activeDownloadCount + 1;
// Don't bother inserting the item into the same place!
if (insertIndex != rdfc.IndexOf(dlRes)) {
rdfc.RemoveElement(dlRes, true);
if (insertIndex == rdfc.GetCount() || insertIndex < 1)
rdfc.AppendElement(dlRes);
else
rdfc.InsertElementAt(dlRes, insertIndex, true);
}
// Remove the download from our book-keeping list and if the count
// falls to zero, update the title here, since we won't be getting
// any more progress notifications in which to do it.
for (var i = 0; i < gActiveDownloads.length; ++i) {
if (gActiveDownloads[i] == aDownload) {
gActiveDownloads.splice(i, 1);
break;
}
}
if (gActiveDownloads.length == 0)
window.title = document.documentElement.getAttribute("statictitle");
}
catch (e) {
}
}
function autoClose(aDownload)
{
if (gDownloadManager.activeDownloadCount == 0) {
// For the moment, just use the simple heuristic that if this window was
// opened by the download process, rather than by the user, it should auto-close
// if the pref is set that way. If the user opened it themselves, it should
// not close until they explicitly close it.
// We may like to revisit this in a bit more detail later, perhaps we want
// to keep it up if the user messes with it in a significant way.
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var autoClose = pref.getBoolPref("browser.download.closeWhenDone")
if (autoClose && (!window.opener || window.opener.location.href == window.location.href))
window.close();
}
}
var gDownloadObserver = {
observe: function (aSubject, aTopic, aState)
{
var dl = aSubject.QueryInterface(Components.interfaces.nsIDownload);
switch (aTopic) {
case "dl-done":
downloadCompleted(dl);
autoClose(dl);
break;
case "dl-failed":
case "dl-cancel":
downloadCompleted(dl);
break;
case "dl-start":
// Add this download to the percentage average tally
gActiveDownloads.push(dl);
break;
}
}
};
///////////////////////////////////////////////////////////////////////////////
// Download Event Handlers
function onDownloadCancel(aEvent)
{
gDownloadManager.cancelDownload(aEvent.target.id);
setRDFProperty(aEvent.target.id, "DownloadAnimated", "false");
// XXXben -
// If we got here because we resumed the download, we weren't using a temp file
// because we used saveURL instead. (this is because the proper download mechanism
// employed by the helper app service isn't fully accessible yet... should be fixed...
// talk to bz...)
// the upshot is we have to delete the file if it exists.
var f = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
f.initWithPath(aEvent.target.id);
if (f.exists())
f.remove(true);
gDownloadViewController.onCommandUpdate();
}
function onDownloadPause(aEvent)
{
var uri = aEvent.target.id;
gDownloadManager.pauseDownload(uri);
setRDFProperty(uri, "DownloadStatus", aEvent.target.getAttribute("status-internal"));
setRDFProperty(uri, "ProgressPercent", aEvent.target.getAttribute("progress"));
}
function onDownloadResume(aEvent)
{
gDownloadManager.resumeDownload(aEvent.target.id);
}
function onDownloadRemove(aEvent)
{
if (aEvent.target.removable) {
gDownloadManager.removeDownload(aEvent.target.id);
gDownloadViewController.onCommandUpdate();
}
}
function onDownloadShow(aEvent)
{
var f = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
f.initWithPath(aEvent.target.id);
if (f.exists()) {
#ifdef XP_UNIX
// on unix, open a browser window rooted at the parent
var parent = f.parent;
if (parent) {
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var browserURL = pref.getCharPref("browser.chromeURL");
window.openDialog(browserURL, "_blank", "chrome,all,dialog=no", parent.path);
}
#else
f.reveal();
#endif
}
}
function onDownloadOpen(aEvent)
{
var download = aEvent.target;
if (download.localName == "download") {
if (download.openable) {
var f = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
f.initWithPath(aEvent.target.id);
if (f.exists()) {
// XXXben security check!
f.launch();
}
}
else if(download.canceledOrFailed) {
// If the user canceled this download, double clicking tries again.
fireEventForElement(download, "retry")
}
}
}
function onDownloadOpenWith(aEvent)
{
}
function onDownloadProperties(aEvent)
{
window.openDialog("chrome://mozapps/content/downloads/downloadProperties.xul",
"_blank", "modal,centerscreen,chrome,resizable=no", aEvent.target.id);
}
function onDownloadAnimated(aEvent)
{
gDownloadViewController.onCommandUpdate();
setRDFProperty(aEvent.target.id, "DownloadAnimated", "true");
}
function onDownloadRetry(aEvent)
{
var download = aEvent.target;
if (download.localName == "download") {
var src = getRDFProperty(download.id, "URL");
saveURL(src, download.getAttribute("target"), null, true, true);
}
gDownloadViewController.onCommandUpdate();
}
// This is called by the progress listener. We don't actually use the event
// system here to minimize time wastage.
var gLastComputedMean = 0;
function onUpdateProgress()
{
var numActiveDownloads = gActiveDownloads.length;
if (numActiveDownloads == 0) {
window.title = document.documentElement.getAttribute("statictitle");
return;
}
var mean = 0;
for (var i = 0; i < numActiveDownloads; ++i) {
var dl = gActiveDownloads[i];
var progress = dl.percentComplete;
if (progress < 100)
mean += progress;
}
mean = Math.round(mean / numActiveDownloads);
if (mean != gLastComputedMean) {
gLastComputedMean = mean;
var strings = document.getElementById("downloadStrings");
var title;
if (numActiveDownloads > 1)
title = strings.getFormattedString("downloadsTitleMultiple", [mean, numActiveDownloads]);
else
title = strings.getFormattedString("downloadsTitle", [mean]);
window.title = title;
}
}
///////////////////////////////////////////////////////////////////////////////
// Startup, Shutdown
function Startup()
{
gDownloadsView = document.getElementById("downloadView");
const dlmgrContractID = "@mozilla.org/download-manager;1";
const dlmgrIID = Components.interfaces.nsIDownloadManager;
gDownloadManager = Components.classes[dlmgrContractID].getService(dlmgrIID);
// The DownloadProgressListener (DownloadProgressListener.js) handles progress
// notifications.
var downloadStrings = document.getElementById("downloadStrings");
gDownloadListener = new DownloadProgressListener(document, downloadStrings);
gDownloadManager.listener = gDownloadListener;
// The active downloads list is created by the front end only when the download starts,
// so we need to pre-populate it with any downloads that were already going.
var activeDownloads = gDownloadManager.activeDownloads;
var count = activeDownloads.Count();
for (var i = 0; i < count; ++i)
gActiveDownloads.push(activeDownloads.QueryElementAt(i, Components.interfaces.nsIDownload));
// Handlers for events generated by the UI (downloads, list view)
gDownloadsView.addEventListener("download-cancel", onDownloadCancel, false);
gDownloadsView.addEventListener("download-pause", onDownloadPause, false);
gDownloadsView.addEventListener("download-resume", onDownloadResume, false);
gDownloadsView.addEventListener("download-remove", onDownloadRemove, false);
gDownloadsView.addEventListener("download-show", onDownloadShow, false);
gDownloadsView.addEventListener("download-open", onDownloadOpen, false);
gDownloadsView.addEventListener("download-retry", onDownloadRetry, false);
gDownloadsView.addEventListener("download-animated", onDownloadAnimated, false);
gDownloadsView.addEventListener("download-properties", onDownloadProperties, false);
gDownloadsView.addEventListener("dblclick", onDownloadOpen, false);
// Handlers for events generated by the Download Manager (download events)
var observerService = Components.classes[kObserverServiceProgID]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(gDownloadObserver, "dl-done", false);
observerService.addObserver(gDownloadObserver, "dl-cancel", false);
observerService.addObserver(gDownloadObserver, "dl-failed", false);
observerService.addObserver(gDownloadObserver, "dl-start", false);
// This is for the "Clean Up" button, which requires there to be
// non-active downloads before it can be enabled.
gDownloadsView.controllers.appendController(gDownloadViewController);
// Finally, update the UI.
gDownloadsView.database.AddDataSource(gDownloadManager.datasource);
gDownloadsView.builder.rebuild();
gDownloadsView.focus();
}
function Shutdown()
{
gDownloadManager.listener = null;
// Assert the current progress for all the downloads in case the window is reopened
gDownloadManager.saveState();
var observerService = Components.classes[kObserverServiceProgID]
.getService(Components.interfaces.nsIObserverService);
observerService.removeObserver(gDownloadObserver, "dl-done");
observerService.removeObserver(gDownloadObserver, "dl-cancel");
observerService.removeObserver(gDownloadObserver, "dl-failed");
observerService.removeObserver(gDownloadObserver, "dl-start");
}
///////////////////////////////////////////////////////////////////////////////
// View Context Menus
var gContextMenus = [
["menuitem_pause", "menuitem_cancel", "menuseparator_properties", "menuitem_properties"],
["menuitem_open", "menuitem_show", "menuitem_remove", "menuseparator_properties", "menuitem_properties"],
["menuitem_retry", "menuitem_remove", "menuseparator_properties", "menuitem_properties"],
["menuitem_retry", "menuitem_remove", "menuseparator_properties", "menuitem_properties"],
["menuitem_resume", "menuitem_cancel", "menuseparator_properties", "menuitem_properties"]
];
function buildContextMenu(aEvent)
{
if (aEvent.target.id != "downloadContextMenu")
return;
var popup = document.getElementById("downloadContextMenu");
while (popup.hasChildNodes())
popup.removeChild(popup.firstChild);
if (gDownloadsView.selected) {
var idx = parseInt(gDownloadsView.selected.getAttribute("state"));
if (idx < 0)
idx = 0;
var menus = gContextMenus[idx];
for (var i = 0; i < menus.length; ++i)
popup.appendChild(document.getElementById(menus[i]).cloneNode(true));
return true;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
// Drag and Drop
var gDownloadDNDObserver =
{
onDragOver: function (aEvent, aFlavour, aDragSession)
{
aDragSession.canDrop = true;
},
onDrop: function(aEvent, aXferData, aDragSession)
{
var split = aXferData.data.split("\n");
var url = split[0];
if (url != aXferData.data) { //do nothing, not a valid URL
var name = split[1];
saveURL(url, name, null, true, true);
}
},
_flavourSet: null,
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
this._flavourSet.appendFlavour("text/x-moz-url");
this._flavourSet.appendFlavour("text/unicode");
}
return this._flavourSet;
}
}
///////////////////////////////////////////////////////////////////////////////
// Command Updating and Command Handlers
var gDownloadViewController = {
supportsCommand: function (aCommand)
{
return aCommand == "cmd_cleanUp";
},
isCommandEnabled: function (aCommand)
{
if (aCommand == "cmd_cleanUp")
return gDownloadManager.canCleanUp;
return false;
},
doCommand: function (aCommand)
{
if (aCommand == "cmd_cleanUp" && this.isCommandEnabled(aCommand)) {
gDownloadManager.cleanUp();
this.onCommandUpdate();
}
},
onCommandUpdate: function ()
{
var command = "cmd_cleanUp";
var enabled = this.isCommandEnabled(command);
goSetCommandEnabled(command, enabled);
}
};
function onDownloadShowOptions()
{
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
var topWindow = windowManagerInterface.getMostRecentWindow("Browser:Options");
if (topWindow) {
topWindow.focus();
topWindow.switchPage("catDownloadsButton");
}
else
openDialog("chrome://browser/content/pref/pref.xul", "PrefWindow",
"chrome,titlebar,resizable,modal", "catDownloadsButton");
}

View File

@ -0,0 +1,171 @@
<?xml version="1.0"?>
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# 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
# Doron Rosenberg.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ben Goodger <ben@bengoodger.com> (v2.0)
# Blake Ross <blakeross@telocity.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 *****
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/content/downloads/downloads.css"?>
<?xml-stylesheet href="chrome://mozapps/skin/downloads/downloads.css"?>
<!DOCTYPE window [
<!ENTITY % downloadManagerDTD SYSTEM "chrome://mozapps/locale/downloads/downloads.dtd">
%downloadManagerDTD;
]>
<window xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="downloadManager" windowtype="Download:Manager"
orient="vertical" title="&downloads.title;" statictitle="&downloads.title;"
width="400" height="300" screenX="10" screenY="10"
persist="width height screenX screenY sizeMode"
onload="Startup();" onunload="Shutdown();">
<script type="application/x-javascript" src="chrome://mozapps/content/downloads/DownloadProgressListener.js"/>
<script type="application/x-javascript" src="chrome://mozapps/content/downloads/downloads.js"/>
<script type="application/x-javascript" src="chrome://browser/content/contentAreaUtils.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<stringbundleset id="downloadSet">
<stringbundle id="downloadStrings" src="chrome://mozapps/locale/downloads/downloads.properties"/>
</stringbundleset>
<commandset id="downloadsCommands"
commandupdater="true"
oncommandupdate="gDownloadViewController.onCommandUpdate();">
<command id="cmd_cleanUp" oncommand="gDownloadViewController.doCommand('cmd_cleanUp');"/>
</commandset>
<keyset id="downloadKeys">
<key id="key_cleanUp" keycode="VK_DELETE" command="cmd_cleanUp" modifiers="accel,shift"/>
<key id="key_close" key="&cmd.close.commandKey;" oncommand="window.close();" modifiers="accel"/>
</keyset>
<vbox id="contextMenuPalette" hidden="true">
<menuitem id="menuitem_pause"
label="&cmd.pause.label;" accesskey="&cmd.pause.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'pause');"/>
<menuitem id="menuitem_resume"
label="&cmd.resume.label;" accesskey="&cmd.resume.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'resume');"/>
<menuitem id="menuitem_cancel"
label="&cmd.cancel.label;" accesskey="&cmd.cancel.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'cancel');"/>
<menuitem id="menuitem_open" default="true"
label="&cmd.open.label;" accesskey="&cmd.open.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'open');"/>
<menuitem id="menuitem_openWith"
label="&cmd.openWith.label;" accesskey="&cmd.openWith.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'openWith');"/>
<menuitem id="menuitem_show"
label="&cmd.show.label;" accesskey="&cmd.show.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'show');"/>
<menuitem id="menuitem_retry" default="true"
label="&cmd.retry.label;" accesskey="&cmd.retry.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'retry');"/>
<menuitem id="menuitem_remove"
label="&cmd.remove.label;" accesskey="&cmd.remove.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'remove');"/>
<menuseparator id="menuseparator_properties"/>
<menuitem id="menuitem_properties"
label="&cmd.properties.label;" accesskey="&cmd.properties.accesskey;"
oncommand="fireEventForElement(gDownloadsView.selected, 'properties');"/>
</vbox>
<popup id="downloadContextMenu" onpopupshowing="return buildContextMenu(event);"/>
<vbox id="downloadView" flex="1" style="overflow: auto;"
datasources="rdf:null" ref="NC:DownloadsRoot"
ondragover="nsDragAndDrop.dragOver(event, gDownloadDNDObserver);"
ondragdrop="nsDragAndDrop.drop(event, gDownloadDNDObserver);">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<member container="?uri" child="?download"/>
<triple subject="?download"
predicate="http://home.netscape.com/NC-rdf#File"
object="?file"/>
<triple subject="?download"
predicate="http://home.netscape.com/NC-rdf#Name"
object="?target"/>
<triple subject="?download"
predicate="http://home.netscape.com/NC-rdf#DownloadState"
object="?state"/>
</conditions>
<bindings>
<binding subject="?download"
predicate="http://home.netscape.com/NC-rdf#DownloadAnimated"
object="?animated"/>
<binding subject="?download"
predicate="http://home.netscape.com/NC-rdf#DownloadStatus"
object="?status"/>
<binding subject="?download"
predicate="http://home.netscape.com/NC-rdf#ProgressPercent"
object="?progress-percent"/>
</bindings>
<action>
<download uri="?download" context="downloadContextMenu"
image="moz-icon:?file" file="?file" target="?target" state="?state"
animated="?animated" status="?status" progress="?progress-percent"/>
</action>
</rule>
</template>
</vbox>
<hbox>
<hbox id="commandBar" flex="1">
<button id="cleanUpButton"
label="&cmd.cleanUp.label;" accesskey="&cmd.cleanUp.accesskey;" tooltiptext="&cmd.cleanUp.tooltip;"
command="cmd_cleanUp"/>
<separator id="commandBarSeparator"/>
<button id="optionsButton"
label="&cmd.options.label;" accesskey="&cmd.options.accesskey;"
oncommand="onDownloadShowOptions();"/>
</hbox>
<resizer dir="bottomright"/>
</hbox>
</window>

View File

@ -35,7 +35,7 @@
#
# ***** END LICENSE BLOCK *****
var _elementIDs = ["askOnSave", "downloadFolderList", "downloadFolder"];
var _elementIDs = ["askOnSave", "downloadFolderList", "downloadFolder", "showWhenStarting", "closeWhenDone"];
#if 0
, "showWhenStarting", "closeWhenDone"
@ -160,6 +160,8 @@ function Startup()
showFolder.parentNode.insertBefore(downloadFolderList, showFolder);
downloadFolderList.hidden = false;
toggleDMPrefUI(document.getElementById("showWhenStarting"));
setTimeout("postStart()", 0);
}
@ -321,8 +323,8 @@ function fileHandlerListSelectionChanged(aEvent)
for (var j = min.value; j <= max.value; ++j) {
var item = cv.getItemAtIndex(j);
var editable = getLiteralValue(item.id, "editable") == "true";
var handleInternal = getLiteralValue(item.id, "handleInternal");
var editable = gHelperApps.getLiteralValue(item.id, "editable") == "true";
var handleInternal = gHelperApps.getLiteralValue(item.id, "handleInternal");
if (!editable || handleInternal)
canRemove = false;
@ -423,3 +425,11 @@ function showPlugins()
openDialog("chrome://browser/content/pref/plugins.xul", "", "modal=yes");
}
function toggleDMPrefUI(aCheckbox)
{
if (aCheckbox.checked)
document.getElementById("closeWhenDone").removeAttribute("disabled");
else
document.getElementById("closeWhenDone").setAttribute("disabled", "true");
}

View File

@ -63,16 +63,15 @@
</radiogroup>
</groupbox>
#if 0
<groupbox>
<groupbox align="start">
<caption label="&downloadManagerWindow.label;"/>
<checkbox id="showWhenStarting" label="&showWhenStarting.label;"
prefstring="browser.download.showWhenStarting"/>
prefstring="browser.download.showWhenStarting"
oncommand="toggleDMPrefUI(event.target);"/>
<checkbox id="closeWhenDone" label="&closeWhenDone.label;" class="indent"
prefstring="browser.download.closeWhenDone"/>
</groupbox>
#endif
<groupbox flex="1">
<caption label="&fileTypes.label;"/>
@ -85,68 +84,70 @@
throwing "can't do open ended queries like that!" assertions for
no discernible reason -->
<vbox class="indent" flex="1">
<tree id="fileHandlersList" flex="1" hidecolumnpicker="true"
datasources="rdf:null"
onselect="fileHandlerListSelectionChanged();"
ondblclick="editFileHandler();">
<vbox flex="1" id="fileHandlersListContainer">
<tree id="fileHandlersList" flex="1" hidecolumnpicker="true"
datasources="rdf:null"
onselect="fileHandlerListSelectionChanged();"
ondblclick="editFileHandler();">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<triple subject="?uri"
predicate="http://home.netscape.com/NC-rdf#MIME-types"
object="?MIME-types"/>
<member container="?MIME-types" child="?type"/>
<triple subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileType"
object="?file-type"/>
<triple subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileHandler"
object="?file-handler"/>
<triple subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileIcon"
object="?file-icon"/>
<triple subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileHandleAuto"
object="true"/>
</conditions>
<bindings>
<binding subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileExtension"
object="?file-extension"/>
</bindings>
<action>
<treechildren class="extensionChildren">
<treeitem uri="?type">
<treerow>
<treecell label="?file-extension" src="?file-icon"/>
<treecell label="?file-type"/>
<treecell label="?file-handler"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
<treecols>
<treecol id="fileExtension"
class="sortDirectionIndicator" persist="width"
sort="rdf:http://home.netscape.com/NC-rdf#FileExtension"
sortActive="true" sortDirection="none" hideheader="true"/>
<treecol id="fileType" flex="1"
class="sortDirectionIndicator" persist="width"
sort="rdf:http://home.netscape.com/NC-rdf#FileType"
sortActive="false" sortDirection="none" hideheader="true"/>
<splitter class="tree-splitter" />
<treecol id="fileHandler" flex="1"
class="sortDirectionIndicator" persist="width"
sort="rdf:http://home.netscape.com/NC-rdf#FileHandler"
sortActive="false" sortDirection="none" hideheader="true"/>
</treecols> <!-- label="&fileHandlerColName.label;" label="&fileTypeColName.label;" -->
</tree>
<template>
<rule>
<conditions>
<content uri="?uri"/>
<triple subject="?uri"
predicate="http://home.netscape.com/NC-rdf#MIME-types"
object="?MIME-types"/>
<member container="?MIME-types" child="?type"/>
<triple subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileType"
object="?file-type"/>
<triple subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileHandler"
object="?file-handler"/>
<triple subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileIcon"
object="?file-icon"/>
<triple subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileHandleAuto"
object="true"/>
</conditions>
<bindings>
<binding subject="?type"
predicate="http://home.netscape.com/NC-rdf#FileExtension"
object="?file-extension"/>
</bindings>
<action>
<treechildren class="extensionChildren">
<treeitem uri="?type">
<treerow>
<treecell label="?file-extension" src="?file-icon"/>
<treecell label="?file-type"/>
<treecell label="?file-handler"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
<treecols>
<treecol id="fileExtension"
class="sortDirectionIndicator" persist="width"
sort="rdf:http://home.netscape.com/NC-rdf#FileExtension"
sortActive="true" sortDirection="none" hideheader="true"/>
<treecol id="fileType" flex="1"
class="sortDirectionIndicator" persist="width"
sort="rdf:http://home.netscape.com/NC-rdf#FileType"
sortActive="false" sortDirection="none" hideheader="true"/>
<splitter class="tree-splitter" />
<treecol id="fileHandler" flex="1"
class="sortDirectionIndicator" persist="width"
sort="rdf:http://home.netscape.com/NC-rdf#FileHandler"
sortActive="false" sortDirection="none" hideheader="true"/>
</treecols> <!-- label="&fileHandlerColName.label;" label="&fileTypeColName.label;" -->
</tree>
</vbox>
<separator class="thin"/>
<hbox>
<button label="&editFileHandler.label;" accesskey="&editFileHandler.accesskey;"

View File

@ -0,0 +1,7 @@
<!ENTITY dateStarted.label "Started:">
<!ENTITY dateEnded.label "Finished:">
<!ENTITY window.title "Properties">
<!ENTITY downloadedFrom.label "From:">
<!ENTITY path.label "To:">
<!ENTITY acceptButton.label "Close">

View File

@ -0,0 +1,58 @@
<!ENTITY name.label "Name">
<!ENTITY progress.label "Progress">
<!ENTITY status.label "Status">
<!ENTITY timeremaining.label "Time Remaining">
<!ENTITY transferred.label "Transferred">
<!ENTITY transferrate.label "Speed">
<!ENTITY timeelapsed.label "Time Elapsed">
<!ENTITY status.label "Status">
<!--<!ENTITY progresstext.label "&#37;">-->
<!ENTITY source.label "Source">
<!ENTITY done.label "Done">
<!ENTITY cancel.label "Cancel">
<!ENTITY canceled.label "Canceled">
<!ENTITY launch.label "Launch">
<!ENTITY divider.label "-">
<!ENTITY show.label "Show">
<!ENTITY open.label "Open">
<!ENTITY retry.label "Retry">
<!ENTITY remove.label "Remove">
<!ENTITY pause.label "Pause">
<!ENTITY resume.label "Resume">
<!ENTITY starting.label "Starting...">
<!ENTITY failed.label "Failed">
<!ENTITY downloads.title "Downloads">
<!ENTITY cmd.pause.label "Pause">
<!ENTITY cmd.pause.accesskey "p">
<!ENTITY cmd.resume.label "Resume">
<!ENTITY cmd.resume.accesskey "r">
<!ENTITY cmd.cancel.label "Cancel">
<!ENTITY cmd.cancel.accesskey "c">
<!ENTITY cmd.show.label "Show">
<!ENTITY cmd.show.accesskey "s">
<!ENTITY cmd.open.label "Open">
<!ENTITY cmd.open.accesskey "o">
<!ENTITY cmd.openWith.label "Open With...">
<!ENTITY cmd.openWith.accesskey "h">
<!ENTITY cmd.retry.label "Retry">
<!ENTITY cmd.retry.accesskey "r">
<!ENTITY cmd.remove.label "Remove">
<!ENTITY cmd.remove.accesskey "e">
<!ENTITY cmd.properties.label "Properties">
<!ENTITY cmd.properties.accesskey "i">
<!ENTITY cmd.close.commandKey "w">
<!ENTITY cmd.cleanUp.label "Clean Up">
<!ENTITY cmd.cleanUp.tooltip "Removes completed, canceled or failed downloads from the list">
<!ENTITY cmd.cleanUp.accesskey "a">
<!ENTITY cmd.options.label "Options">
<!ENTITY cmd.options.accesskey "o">
<!ENTITY closeWhenDone.label "Close when downloads complete">
<!ENTITY closeWhenDone.tooltip "Closes the Downloads window when all files are done downloading">

View File

@ -0,0 +1,35 @@
transferred=%1SKB of %2SKB
downloading=Downloading
notStarted=Not Started
failed=Failed
finished=Finished
canceled=Canceled
downloadErrorAlertTitle=Download Error
quitCancelDownloadsAlertTitle=Cancel All Downloads?
quitCancelDownloadsAlertMsg=If you exit now, 1 download will be canceled. Are you sure you want to exit?
quitCancelDownloadsAlertMsgMultiple=If you exit now, %S downloads will be canceled. Are you sure you want to exit?
quitCancelDownloadsAlertMsgMac=If you quit now, 1 download will be canceled. Are you sure you want to quit?
quitCancelDownloadsAlertMsgMacMultiple=If you quit now, %S downloads will be canceled. Are you sure you want to quit?
quitCancelDownloadsOKText=Cancel 1 Download
quitCancelDownloadsOKTextMultiple=Cancel %S Downloads
downloadsCompleteTitle=Downloads Complete
downloadsCompleteMsg=All files have finished downloading.
statusFormatKBKB=#1 of #2 KB
statusFormatKBMB=#1 KB of #2 MB
statusFormatMBMB=#1 of #2 MB
statusFormat=#1; #2 KB/sec
longTimeFormat=#1:#2:#3
shortTimeFormat=#2:#3
showInShellLabelWin=Show in Explorer
showInShellAccesskeyWin=E
showInShellLabelMac=Show in Finder
showInShellAccesskeyMac=F
showInShellLabelUnix=Show in Browser
showInShellAccesskeyUnix=B
chooseAppFilePickerTitle=Open With...
downloadsTitle=%S%% of 1 file - Downloads
downloadsTitleMultiple=%S%% of %S files - Downloads

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,100 @@
#downloadManager {
background-color: ThreeDFace;
}
/* Download View */
#downloadView {
-moz-binding: url("chrome://mozapps/skin/downloads/downloads.xml#download-view");
margin: 10px 10px 5px 10px;
-moz-appearance: listbox;
-moz-user-focus: normal;
}
.downloadViewInner2 {
background-image: url("chrome://mozapps/skin/downloads/viewFader.png");
padding: 0px;
}
.downloadViewInner1 {
background-color: Window;
background-image: url("chrome://mozapps/skin/downloads/downloadsBG.png");
background-attachment: fixed;
background-repeat: no-repeat;
background-position: bottom right;
}
/* Download Manager Command Bar */
#commandBar {
padding: 0px 10px 5px 10px;
}
#cleanUpButton {
margin: 0px;
-moz-user-focus: ignore;
list-style-image: url("chrome://mozapps/skin/downloads/downloadCleanup.png");
}
#optionsButton {
margin: 0px;
-moz-user-focus: ignore;
list-style-image: url("chrome://mozapps/skin/downloads/downloadOptions.png");
}
#cleanUpButton .button-icon, #optionsButton .button-icon {
margin: 0px 5px 0px 0px !important;
}
#cleanUpButton[disabled="true"] {
list-style-image: url("chrome://mozapps/skin/downloads/downloadCleanupDisabled.png");
}
#commandBarSeparator {
margin-left: 5px;
}
/* Download View Items */
download {
padding: 13px 10px 13px 13px;
min-height: 25px;
border-bottom: 1px dotted #C0C0C0;
}
download[selected="true"] {
background-image: url("chrome://mozapps/skin/downloads/downloadSelected.png") !important;
border-bottom: 1px dotted #7F9DB9;
}
download[state="0"], download[state="-1"], download[state="4"] {
background-color: transparent;
background-image: url("chrome://mozapps/skin/downloads/downloadFader.png");
}
/* Download View Items, implementation */
.downloadContentBox {
-moz-opacity: 0.0;
}
.downloadContentBox[animated="true"] {
-moz-opacity: 1.0;
}
.downloadTypeIcon {
margin-right: 10px;
}
.link {
text-decoration: underline;
color: blue;
cursor: pointer;
-moz-user-focus: normal;
border: 1px solid transparent;
}
.link:hover:active {
color: red;
}
.link:focus {
border: 1px dotted black;
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<bindings id="downloadSkinBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="download-view" extends="chrome://mozapps/content/downloads/download.xml#download-view">
<content>
<xul:vbox flex="1" class="downloadViewInner1">
<xul:vbox flex="1" class="downloadViewInner2">
<children/>
</xul:vbox>
</xul:vbox>
</content>
</binding>
</bindings>

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,2 +1,13 @@
classic.jar:
skin/classic/mozapps/downloads/unknownContentType.css
skin/classic/mozapps/downloads/unknownContentType.css
skin/classic/mozapps/downloads/viewFader.png
skin/classic/mozapps/downloads/downloadFader.png
skin/classic/mozapps/downloads/downloadSelected.png
skin/classic/mozapps/downloads/downloadsBG.png
skin/classic/mozapps/downloads/downloadIcon.png
skin/classic/mozapps/downloads/downloadCleanup.png
skin/classic/mozapps/downloads/downloadCleanupDisabled.png
skin/classic/mozapps/downloads/downloadOptions.png
skin/classic/mozapps/downloads/downloads.css
skin/classic/mozapps/downloads/downloads.xml

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,100 @@
#downloadManager {
background-color: ThreeDFace;
}
/* Download View */
#downloadView {
-moz-binding: url("chrome://mozapps/skin/downloads/downloads.xml#download-view");
margin: 10px 10px 5px 10px;
-moz-appearance: listbox;
-moz-user-focus: normal;
}
.downloadViewInner2 {
background-image: url("chrome://mozapps/skin/downloads/viewFader.png");
padding: 0px;
}
.downloadViewInner1 {
background-color: Window;
background-image: url("chrome://mozapps/skin/downloads/downloadsBG.png");
background-attachment: fixed;
background-repeat: no-repeat;
background-position: bottom right;
}
/* Download Manager Command Bar */
#commandBar {
padding: 0px 10px 5px 10px;
}
#cleanUpButton {
margin: 0px;
-moz-user-focus: ignore;
list-style-image: url("chrome://mozapps/skin/downloads/downloadCleanup.png");
}
#optionsButton {
margin: 0px;
-moz-user-focus: ignore;
list-style-image: url("chrome://mozapps/skin/downloads/downloadOptions.png");
}
#cleanUpButton .button-icon, #optionsButton .button-icon {
margin: 0px 5px 0px 0px !important;
}
#cleanUpButton[disabled="true"] {
list-style-image: url("chrome://mozapps/skin/downloads/downloadCleanupDisabled.png");
}
#commandBarSeparator {
margin-left: 5px;
}
/* Download View Items */
download {
padding: 13px 10px 13px 13px;
min-height: 25px;
border-bottom: 1px dotted #C0C0C0;
}
download[selected="true"] {
background-image: url("chrome://mozapps/skin/downloads/downloadSelected.png") !important;
border-bottom: 1px dotted #7F9DB9;
}
download[state="0"], download[state="-1"], download[state="4"] {
background-color: transparent;
background-image: url("chrome://mozapps/skin/downloads/downloadFader.png");
}
/* Download View Items, implementation */
.downloadContentBox {
-moz-opacity: 0.0;
}
.downloadContentBox[animated="true"] {
-moz-opacity: 1.0;
}
.downloadTypeIcon {
margin-right: 10px;
}
.link {
text-decoration: underline;
color: blue;
cursor: pointer;
-moz-user-focus: normal;
border: 1px solid transparent;
}
.link:hover:active {
color: red;
}
.link:focus {
border: 1px dotted black;
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<bindings id="downloadSkinBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="download-view" extends="chrome://mozapps/content/downloads/download.xml#download-view">
<content>
<xul:vbox flex="1" class="downloadViewInner1">
<xul:vbox flex="1" class="downloadViewInner2">
<children/>
</xul:vbox>
</xul:vbox>
</content>
</binding>
</bindings>

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,2 +1,13 @@
classic.jar:
skin/classic/mozapps/downloads/unknownContentType.css
skin/classic/mozapps/downloads/unknownContentType.css
skin/classic/mozapps/downloads/viewFader.png
skin/classic/mozapps/downloads/downloadFader.png
skin/classic/mozapps/downloads/downloadSelected.png
skin/classic/mozapps/downloads/downloadsBG.png
skin/classic/mozapps/downloads/downloadIcon.png
skin/classic/mozapps/downloads/downloadCleanup.png
skin/classic/mozapps/downloads/downloadCleanupDisabled.png
skin/classic/mozapps/downloads/downloadOptions.png
skin/classic/mozapps/downloads/downloads.css
skin/classic/mozapps/downloads/downloads.xml

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

View File

@ -6,6 +6,13 @@ toolkit.jar:
* content/mozapps/downloads/overrideHandler.js (downloads/content/overrideHandler.js)
* content/mozapps/downloads/editAction.xul (downloads/content/editAction.xul)
* content/mozapps/downloads/editAction.js (downloads/content/editAction.js)
* content/mozapps/downloads/downloads.xul (downloads/content/downloads.xul)
* content/mozapps/downloads/downloads.js (downloads/content/downloads.js)
* content/mozapps/downloads/DownloadProgressListener.js (downloads/content/DownloadProgressListener.js)
content/mozapps/downloads/downloads.css (downloads/content/downloads.css)
* content/mozapps/downloads/download.xml (downloads/content/download.xml)
* content/mozapps/downloads/downloadProperties.xul (downloads/content/downloadProperties.xul)
* content/mozapps/downloads/downloadProperties.js (downloads/content/downloadProperties.js)
content/mozapps/contents.rdf (contents-content.rdf)
en-US.jar:
@ -13,6 +20,9 @@ en-US.jar:
* locale/en-US/mozapps/downloads/unknownContentType.dtd (downloads/locale/unknownContentType.dtd)
locale/en-US/mozapps/downloads/pref-downloads.dtd (downloads/locale/pref-downloads.dtd)
locale/en-US/mozapps/downloads/editAction.dtd (downloads/locale/editAction.dtd)
locale/en-US/mozapps/downloads/downloads.dtd (downloads/locale/downloads.dtd)
locale/en-US/mozapps/downloads/downloads.properties (downloads/locale/downloads.properties)
locale/en-US/mozapps/downloads/downloadProperties.dtd (downloads/locale/downloadProperties.dtd)
locale/en-US/mozapps/contents.rdf (contents-locale.rdf)
classic.jar:

View File

@ -101,4 +101,12 @@
#defaultAppName {
margin-left: 6px !important;
}
} /* #fileHandlersListContainer { -moz-binding: url("chrome://mozapps/skin/downloads/downloads.xml#download-view");
-moz-appearance: listbox;
-moz-user-focus: normal;
} * We apply the background to both of these elements since the tree leaves a 2-3px * strip on its right side unpainted. We can't just paint the background layer either * because the tree erases its background with white, obscuring the bottom layer. #fileHandlersList, #fileHandlersListContainer > .downloadViewInner1 { background-image: url("chrome://mozapps/skin/downloads/downloadsBG.png");
background-attachment: fixed;
background-repeat: no-repeat;
background-position: bottom right; -moz-appearance: none; border: none;
}
*/