From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/mailnews/base/content/shutdownWindow.js | 97 ++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 comm/mailnews/base/content/shutdownWindow.js (limited to 'comm/mailnews/base/content/shutdownWindow.js') diff --git a/comm/mailnews/base/content/shutdownWindow.js b/comm/mailnews/base/content/shutdownWindow.js new file mode 100644 index 0000000000..68c7f6b6f0 --- /dev/null +++ b/comm/mailnews/base/content/shutdownWindow.js @@ -0,0 +1,97 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var curTaskIndex = 0; +var numTasks = 0; +var stringBundle; + +var msgShutdownService = Cc[ + "@mozilla.org/messenger/msgshutdownservice;1" +].getService(Ci.nsIMsgShutdownService); + +window.addEventListener("DOMContentLoaded", onLoad); +document.addEventListener("dialogcancel", onCancel); + +function onLoad() { + numTasks = msgShutdownService.getNumTasks(); + + stringBundle = document.getElementById("bundle_shutdown"); + document.title = stringBundle.getString("shutdownDialogTitle"); + + updateTaskProgressLabel(1); + updateProgressMeter(0); + + msgShutdownService.startShutdownTasks(); +} + +function updateProgressLabel(inTaskName) { + var curTaskLabel = document.getElementById("shutdownStatus_label"); + curTaskLabel.value = inTaskName; +} + +function updateTaskProgressLabel(inCurTaskNum) { + var taskProgressLabel = document.getElementById("shutdownTask_label"); + taskProgressLabel.value = stringBundle.getFormattedString("taskProgress", [ + inCurTaskNum, + numTasks, + ]); +} + +function updateProgressMeter(inPercent) { + var taskProgressmeter = document.getElementById("shutdown_progressmeter"); + taskProgressmeter.value = inPercent; +} + +function onCancel() { + msgShutdownService.cancelShutdownTasks(); +} + +function nsMsgShutdownTaskListener() { + msgShutdownService.setShutdownListener(this); +} + +nsMsgShutdownTaskListener.prototype = { + QueryInterface: ChromeUtils.generateQI([ + "nsIWebProgressListener", + "nsISupportsWeakReference", + ]), + + onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { + if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) { + window.close(); + } + }, + + onProgressChange( + aWebProgress, + aRequest, + aCurSelfProgress, + aMaxSelfProgress, + aCurTotalProgress, + aMaxTotalProgress + ) { + updateProgressMeter((aCurTotalProgress / aMaxTotalProgress) * 100); + updateTaskProgressLabel(aCurTotalProgress + 1); + }, + + onLocationChange(aWebProgress, aRequest, aLocation, aFlags) { + // we can ignore this notification + }, + + onStatusChange(aWebProgress, aRequest, aStatus, aMessage) { + if (aMessage) { + updateProgressLabel(aMessage); + } + }, + + onSecurityChange(aWebProgress, aRequest, state) { + // we can ignore this notification + }, + + onContentBlockingEvent(aWebProgress, aRequest, aEvent) { + // we can ignore this notification + }, +}; + +var MsgShutdownTaskListener = new nsMsgShutdownTaskListener(); -- cgit v1.2.3