32 const Cc = Components.classes;
33 const Ci = Components.interfaces;
34 const Cr = Components.results;
35 const Ce = Components.Exception;
36 const Cu = Components.utils;
38 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
39 Cu.import(
"resource://app/jsmodules/ArrayConverter.jsm");
40 Cu.import(
"resource://app/jsmodules/WindowUtils.jsm");
41 Cu.import(
"resource://app/jsmodules/SBTimer.jsm");
61 showProgressDialog:
function(aJobProgress, aWindow, aTimeout, aNonModal) {
62 if (!(aJobProgress instanceof
Ci.sbIJobProgress)) {
63 throw new Error(
"showProgressDialog requires an object implementing sbIJobProgress");
66 function showDialog() {
73 if (aJobProgress.status ==
Ci.sbIJobProgress.STATUS_SUCCEEDED) {
79 if (!aNonModal && aJobProgress.blocked) {
84 if (!aWindow || aWindow.closed) {
85 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
86 .getService(Components.interfaces.nsIWindowMediator);
87 aWindow = wm.getMostRecentWindow(
"Songbird:Main");
89 WindowUtils.openDialog(
91 "chrome://songbird/content/xul/jobProgress.xul",
92 "job_progress_dialog",
93 "chrome,centerscreen",
100 if (aTimeout ==
null) {
109 timer =
new SBTimer(showDialog, aTimeout,
Ci.nsITimer.TYPE_ONE_SHOT);
128 SBJobUtils.JobBase =
function() {
129 this._errorMessages = [];
130 this._listeners = [];
132 SBJobUtils.JobBase.prototype = {
134 [
Ci.sbIJobProgress,
Ci.sbIJobCancelable,
135 Ci.sbIJobProgressListener,
Ci.nsIClassInfo]),
142 flags :
Ci.nsIClassInfo.MAIN_THREAD_ONLY,
148 Ci.sbIJobProgressListener,
152 count.value = interfaces.length;
157 _status :
Ci.sbIJobProgress.STATUS_RUNNING,
165 _errorMessages :
null,
174 _jobProgressDelegate :
null,
186 return (this._jobProgressDelegate) ?
187 this._jobProgressDelegate.blocked : this._blocked;
191 return (this._jobProgressDelegate) ?
192 this._jobProgressDelegate.statusText : this._statusText;
196 return (this._jobProgressDelegate) ?
197 this._jobProgressDelegate.titleText : this._titleText;
201 return (this._jobProgressDelegate) ?
202 this._jobProgressDelegate.progress : this._progress;
206 return (this._jobProgressDelegate) ?
207 this._jobProgressDelegate.total : this._total;
211 return (this._jobProgressDelegate) ?
212 this._jobProgressDelegate.errorCount : this._errorMessages.length;
215 getErrorMessages:
function Job_getErrorMessages() {
216 return (this._jobProgressDelegate) ?
217 this._jobProgressDelegate.getErrorMessages() :
218 ArrayConverter.enumerator(this._errorMessages);
221 addJobProgressListener:
function Job_addJobProgressListener(aListener) {
222 aListener.QueryInterface(
Ci.sbIJobProgressListener);
223 this._listeners.push(aListener);
226 removeJobProgressListener:
function Job_removeJobProgressListener(aListener){
227 var index = this._listeners.indexOf(aListener);
229 this._listeners.splice(index,1);
238 return (this._jobProgressDelegate &&
239 this._jobProgressDelegate instanceof
Ci.sbIJobCancelable) ?
240 this._jobProgressDelegate.canCancel : this._canCancel;
243 cancel:
function Job_cancel() {
245 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
256 delegateJobProgress:
function Job_delegateJobProgress(aJob) {
257 if (aJob !=
null && !(aJob.QueryInterface(
Ci.sbIJobProgress))) {
258 throw Components.results.NS_ERROR_INVALID_ARG;
261 if (this._jobProgressDelegate) {
262 this._jobProgressDelegate.removeJobProgressListener(
this);
265 this._jobProgressDelegate = aJob;
267 if (this._jobProgressDelegate) {
268 this._jobProgressDelegate.addJobProgressListener(
this);
277 onJobProgress:
function Job_onJobProgress(aJob) {
279 if ((!this._jobProgressDelegate) || this._jobProgressDelegate != aJob) {
282 Cu.reportError(
"Job_onJobProgress called with invalid _jobProgressDelegate state!");
286 this.notifyJobProgressListeners();
289 if (this._jobProgressDelegate.status !=
Ci.sbIJobProgress.STATUS_RUNNING) {
290 this.onJobDelegateCompleted();
303 onJobDelegateCompleted:
function Job_onJobDelegateCompleted() {
305 this.delegateJobProgress(
null);
312 notifyJobProgressListeners:
function Job_notifyJobProgressListeners() {
316 var listeners = [].concat(this._listeners);
317 listeners.forEach(
function (
listener) {
sbDeviceFirmwareAutoCheckForUpdate prototype flags
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
sbDeviceFirmwareAutoCheckForUpdate prototype getHelperForLanguage
const PROGRESS_DEFAULT_DIALOG_DELAY
sbDeviceFirmwareAutoCheckForUpdate prototype classID
sbDeviceFirmwareAutoCheckForUpdate prototype getInterfaces
sbDeviceFirmwareAutoCheckForUpdate prototype interfaces
classDescription implementationLanguage