diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/downloadProperties.dtd b/toolkit/locales/en-US/chrome/mozapps/downloads/downloadProperties.dtd deleted file mode 100644 index a512a16ecbf..00000000000 --- a/toolkit/locales/en-US/chrome/mozapps/downloads/downloadProperties.dtd +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.dtd b/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.dtd index 1a68696f714..6c46725163c 100644 --- a/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.dtd +++ b/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.dtd @@ -3,7 +3,6 @@ - @@ -28,8 +27,8 @@ - - + + @@ -42,5 +41,8 @@ - + + + + diff --git a/toolkit/locales/jar.mn b/toolkit/locales/jar.mn index 28d5a008dcc..7881a4d510d 100644 --- a/toolkit/locales/jar.mn +++ b/toolkit/locales/jar.mn @@ -70,7 +70,6 @@ * locale/@AB_CD@/mozapps/downloads/unknownContentType.dtd (%chrome/mozapps/downloads/unknownContentType.dtd) locale/@AB_CD@/mozapps/downloads/downloads.dtd (%chrome/mozapps/downloads/downloads.dtd) locale/@AB_CD@/mozapps/downloads/downloads.properties (%chrome/mozapps/downloads/downloads.properties) - locale/@AB_CD@/mozapps/downloads/downloadProperties.dtd (%chrome/mozapps/downloads/downloadProperties.dtd) locale/@AB_CD@/mozapps/extensions/extensions.dtd (%chrome/mozapps/extensions/extensions.dtd) locale/@AB_CD@/mozapps/extensions/extensions.properties (%chrome/mozapps/extensions/extensions.properties) locale/@AB_CD@/mozapps/extensions/about.dtd (%chrome/mozapps/extensions/about.dtd) diff --git a/toolkit/mozapps/downloads/content/DownloadProgressListener.js b/toolkit/mozapps/downloads/content/DownloadProgressListener.js index 595d9e2f60f..967bad17003 100644 --- a/toolkit/mozapps/downloads/content/DownloadProgressListener.js +++ b/toolkit/mozapps/downloads/content/DownloadProgressListener.js @@ -22,6 +22,8 @@ # Contributor(s): # Blake Ross (Original Author) # Ben Goodger (v2.0) +# Edward Lee +# Shawn Wilsher (v3.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 @@ -37,81 +39,112 @@ # # ***** END LICENSE BLOCK ***** -var gStrings = []; -const interval = 500; // Update every 500 milliseconds. - -function DownloadProgressListener (aDocument, aStringBundle) +function DownloadProgressListener() { - this.doc = aDocument; - - this._statusFormat = aStringBundle.getString("statusFormat2"); - this._transferSameUnits = aStringBundle.getString("transferSameUnits"); - this._transferDiffUnits = aStringBundle.getString("transferDiffUnits"); - this._transferNoTotal = aStringBundle.getString("transferNoTotal"); - this._timeLeft = aStringBundle.getString("timeLeft"); - this._timeLessMinute = aStringBundle.getString("timeLessMinute"); - this._timeUnknown = aStringBundle.getString("timeUnknown"); - this._units = [aStringBundle.getString("bytes"), - aStringBundle.getString("kilobyte"), - aStringBundle.getString("megabyte"), - aStringBundle.getString("gigabyte")]; + var sb = document.getElementById("downloadStrings"); + this._statusFormat = sb.getString("statusFormat2"); + this._transferSameUnits = sb.getString("transferSameUnits"); + this._transferDiffUnits = sb.getString("transferDiffUnits"); + this._transferNoTotal = sb.getString("transferNoTotal"); + this._timeLeft = sb.getString("timeLeft"); + this._timeLessMinute = sb.getString("timeLessMinute"); + this._timeUnknown = sb.getString("timeUnknown"); + this._units = [sb.getString("bytes"), + sb.getString("kilobyte"), + sb.getString("megabyte"), + sb.getString("gigabyte")]; } DownloadProgressListener.prototype = { - doc: null, - onDownloadStateChange: function dlPL_onDownloadStateChange(aState, aDownload) { - var downloadID = "dl" + aDownload.id; - var download = this.doc.getElementById(downloadID); - if (download) - download.setAttribute("state", aDownload.state); + var dl = getDownload(aDownload.id); + switch (aDownload.state) { + case Ci.nsIDownloadManager.DOWNLOAD_NOTSTARTED: + // We'll have at least one active download now + gDownloadsActiveLabel.hidden = false; + case Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING: + // if dl is non-null, the download is already added to the UI, so we + // just make sure it is where it is supposed to be + if (!dl) { + // We have to create the download object + let uri = Cc["@mozilla.org/network/util;1"]. + getService(Ci.nsIIOService). + newFileURI(aDownload.targetFile); + dl = createDownloadItem(aDownload.id, + uri.spec, + aDownload.displayName, + aDownload.source.spec, + aDownload.state, + "", + aDownload.percentComplete, + Math.round(aDownload.startTime / 1000)); + } + gDownloadsView.insertBefore(dl, gDownloadsActiveLabel.nextSibling); + break; + case Ci.nsIDownloadManager.DOWNLOAD_FAILED: + case Ci.nsIDownloadManager.DOWNLOAD_CANCELED: + downloadCompleted(aDownload); + break; + case Ci.nsIDownloadManager.DOWNLOAD_FINISHED: + downloadCompleted(aDownload); + + autoRemoveAndClose(aDownload); + break; + } + + // autoRemoveAndClose could have already closed our window... + try { + dl.setAttribute("state", aDownload.state); + gDownloadViewController.onCommandUpdate(); + } catch (e) { } }, onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus, aDownload) { if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) { - var downloadID = "dl" + aDownload.id; - var download = this.doc.getElementById(downloadID); - if (download) - download.setAttribute("status", ""); + let dl = getDownload(aDownload.id); + if (dl) + dl.setAttribute("status", ""); } }, onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress, aDownload) { - var overallProgress = aCurTotalProgress; - - var downloadID = "dl" + aDownload.id; - var download = this.doc.getElementById(downloadID); - - // 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"); + var download = getDownload(aDownload.id); + if (!download) { + // d'oh - why this happens is complicated, let's just add it in + let uri = Cc["@mozilla.org/network/util;1"]. + getService(Ci.nsIIOService).newFileURI(aDownload.targetFile); + let itm = createDownloadItem(aDownload.id, uri.spec, + aDownload.displayName, + aDownload.source.spec, + aDownload.state, + aDownload.percentComplete); + download = gDownloadsView.insertBefore(itm, gDownloadsActiveLabel.nextSibling); } - // 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). + // any activity means we should have active downloads! + gDownloadsActiveLabel.hidden = false; + + // Update this download's progressmeter + if (aDownload.percentComplete == -1) + download.setAttribute("progressmode", "undetermined"); + else { + download.setAttribute("progressmode", "normal"); + download.setAttribute("progress", aDownload.percentComplete); + } + + // Dispatch ValueChange for a11y + var event = document.createEvent("Events"); + event.initEvent("ValueChange", true, true); + document.getAnonymousElementByAttribute(download, "anonid", "progressmeter") + .dispatchEvent(event); + + // Update the rest of the UI (bytes transferred, bytes total, download rate, + // time remaining). let status = this._statusFormat; // Update the bytes transferred and bytes total @@ -133,8 +166,7 @@ DownloadProgressListener.prototype = // Insert 1 is the download progress status = this._replaceInsert(status, 1, transfer); - if (download) - download.setAttribute("status-internal", transfer); + download.setAttribute("status-internal", transfer); } // Update the download rate @@ -162,8 +194,7 @@ DownloadProgressListener.prototype = status = this._replaceInsert(status, 4, remain); } - if (download) - download.setAttribute("status", status); + download.setAttribute("status", status); }, onLocationChange: function(aWebProgress, aRequest, aLocation, aDownload) { @@ -178,9 +209,9 @@ DownloadProgressListener.prototype = { if (iid.equals(Components.interfaces.nsIDownloadProgressListener) || iid.equals(Components.interfaces.nsISupports)) - return this; + return this; - throw Components.results.NS_NOINTERFACE; + throw Cr.NS_NOINTERFACE; }, _replaceInsert: function ( text, index, value ) diff --git a/toolkit/mozapps/downloads/content/Makefile.in b/toolkit/mozapps/downloads/content/Makefile.in deleted file mode 100644 index 07d2cb16da6..00000000000 --- a/toolkit/mozapps/downloads/content/Makefile.in +++ /dev/null @@ -1,46 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -include $(topsrcdir)/config/rules.mk - diff --git a/toolkit/mozapps/downloads/content/download.xml b/toolkit/mozapps/downloads/content/download.xml index 3e688b5e3b5..6709645ecaf 100644 --- a/toolkit/mozapps/downloads/content/download.xml +++ b/toolkit/mozapps/downloads/content/download.xml @@ -24,6 +24,7 @@ # Contributor(s): # Ben Goodger (v2.0) # Blake Ross +# Shawn Wilsher (v3.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 @@ -57,25 +58,13 @@ + xmlns:xbl="http://www.mozilla.org/xbl"> - - - - - - - - - - - - @@ -137,16 +118,21 @@ #ifdef SHOW_ICONS - + #endif - - + + + + - - + + @@ -154,143 +140,33 @@ - + #ifdef SHOW_ICONS - + #endif - + + - - + - - - - - - - - + + + + + - - - - - - - - 0 - true - -1 - - - - - - - - - - - - - - - - - - - - 0 - - - - - - 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", "opacity: " + aDownload._adlStep + "!important;"); - - setTimeout(aDownload._adlTimerCallback, aDownload._adl_kTimeout, aDownload, aContent); - ]]> - - - - - - - - - - - - - - - - - - - - - - - - @@ -298,38 +174,30 @@ #ifdef SHOW_ICONS - + #endif - + + - - + - - - - - - - - + + + + + - - - - - - - @@ -337,18 +205,23 @@ #ifdef SHOW_ICONS - + #endif - - + + + - - - + + + + + @@ -359,18 +232,23 @@ #ifdef SHOW_ICONS - + #endif - - + + + - - - + + + + + @@ -381,106 +259,24 @@ #ifdef SHOW_ICONS - + #endif - - + + + - - + + - - - null - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toolkit/mozapps/downloads/content/downloadProperties.js b/toolkit/mozapps/downloads/content/downloadProperties.js deleted file mode 100644 index a35957bdc08..00000000000 --- a/toolkit/mozapps/downloads/content/downloadProperties.js +++ /dev/null @@ -1,101 +0,0 @@ -# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla.org Code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2001 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Blake Ross -# -# 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 ***** - -function Startup() -{ - const dlmgrContractID = "@mozilla.org/download-manager;1"; - const dlmgrIID = Components.interfaces.nsIDownloadManager; - var dm = Components.classes[dlmgrContractID].getService(dlmgrIID); - var db = dm.DBConnection; - - const dateTimeContractID = "@mozilla.org/intl/scriptabledateformat;1"; - const dateTimeIID = Components.interfaces.nsIScriptableDateFormat; - var dts = Components.classes[dateTimeContractID].getService(dateTimeIID); - - var dateStartedField = document.getElementById("dateStarted"); - var dateEndedField = document.getElementById("dateEnded"); - var pathField = document.getElementById("path"); - var sourceField = document.getElementById("source"); - - var dlid = window.arguments[0].replace(/^dl([0-9]+)$/, "$1"); - - var stmt = db.createStatement("SELECT startTime, endTime, target, source " + - "FROM moz_downloads " + - "WHERE id = ?1"); - stmt.bindInt64Parameter(0, dlid); - stmt.executeStep(); - - var dateStarted = new Date(stmt.getInt64(0) / 1000); - dateStarted = dts.FormatDateTime("", dts.dateFormatShort, - dts.timeFormatSeconds, - dateStarted.getFullYear(), - dateStarted.getMonth() + 1, - dateStarted.getDate(), - dateStarted.getHours(), - dateStarted.getMinutes(), - dateStarted.getSeconds()); - dateStartedField.setAttribute("value", dateStarted); - - var dateEnded = new Date(stmt.getInt64(1) / 1000); - dateEnded = dts.FormatDateTime("", dts.dateFormatShort, - dts.timeFormatSeconds, - dateEnded.getFullYear(), - dateEnded.getMonth() + 1, - dateEnded.getDate(), - dateEnded.getHours(), - dateEnded.getMinutes(), - dateEnded.getSeconds()); - dateEndedField.setAttribute("value", dateEnded); - - pathField.value = stmt.getUTF8String(2); - sourceField.value = stmt.getUTF8String(3); - stmt.reset(); - - var dl = dm.getDownload(dlid); - if (dl.state == dlmgrIID.DOWNLOAD_DOWNLOADING || - dl.state == dlmgrIID.DOWNLOAD_PAUSED || - dl.state == dlmgrIID.DOWNLOAD_NOTSTARTED) { - document.getElementById("dateEndedRow").hidden = true; - document.getElementById("dateEndedSeparator").hidden = true; - } - - document.documentElement.getButton("accept").label = document.documentElement.getAttribute("acceptbuttontext"); - - document.documentElement.getButton("accept").focus(); -} - \ No newline at end of file diff --git a/toolkit/mozapps/downloads/content/downloadProperties.xul b/toolkit/mozapps/downloads/content/downloadProperties.xul deleted file mode 100644 index 28612944ef9..00000000000 --- a/toolkit/mozapps/downloads/content/downloadProperties.xul +++ /dev/null @@ -1,100 +0,0 @@ - - -# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is Mozilla.org Code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2001 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Blake Ross -# -# 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 ***** - - - - - -%downloadPropertiesDTD; -]> - - - -