1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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();
|