25 const Cc = Components.classes;
26 const Ci = Components.interfaces;
27 const Cu = Components.utils;
29 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
30 Cu.import(
"resource://app/jsmodules/SBJobUtils.jsm");
31 Cu.import(
"resource://app/jsmodules/ArrayConverter.jsm");
32 Cu.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
33 Cu.import(
"resource://app/jsmodules/StringUtils.jsm");
34 Cu.import(
"resource://app/jsmodules/GeneratorThread.jsm");
45 throw Components.results.NS_ERROR_INVALID_ARG;
49 SBJobUtils.JobBase.call(
this);
51 this._owner = aHelper;
52 this._mediaItems = ArrayConverter.JSArray(aItems);
54 this._titleText =
SBString(
"watchfolders.remove.title");
55 this._statusText =
SBString(
"watchfolders.remove.processing");
58 this._canCancel =
true;
62 __proto__: SBJobUtils.JobBase.prototype,
65 [
Ci.sbIJobProgress,
Ci.sbIJobProgressListener,
66 Ci.sbIJobCancelable,
Ci.nsIClassInfo]),
71 Ci.sbIJobCancelable,
Ci.nsIClassInfo,
73 count.value = interfaces.length;
91 BATCHREMOVE_SIZE: 300,
96 begin:
function RemoveJob_begin() {
100 this._thread.start();
109 _process:
function RemoveJob_process() {
110 this._total = this._mediaItems.length;
113 var library = this._mediaItems[0].library;
116 while (this._nextItemIndex < this._mediaItems.length) {
118 this._currentBatchSize = Math.min(this.BATCHREMOVE_SIZE,
119 this._mediaItems.length -
this._nextItemIndex);
120 var endIndex = this._nextItemIndex + this._currentBatchSize;
121 var items = this._mediaItems.slice(this._nextItemIndex, endIndex);
122 this._nextItemIndex = endIndex;
123 library.removeSome(ArrayConverter.enumerator(items));
124 this._progress += this._currentBatchSize;
125 this.notifyJobProgressListeners();
139 return this._progress;
151 return this._titleText;
155 cancel:
function RemoveJob_cancel() {
156 if (!this.canCancel) {
157 throw new Error(
"RemovedJob not currently cancelable");
166 complete:
function RemoveJob_complete() {
168 this._status =
Ci.sbIJobProgress.STATUS_SUCCEEDED;
169 this._statusText =
SBString(
"watchfolders.remove.complete");
170 this.notifyJobProgressListeners();
172 this._owner.onJobComplete();
180 function RemoveHelper() {
184 RemoveHelper.prototype = {
186 classID: Components.ID(
"{b44bf03e-fe28-4ad4-ba7e-6112cdced7a4}"),
187 contractID:
"@songbirdnest.com/Songbird/RemoveHelper;1",
197 remove:
function RemoveHelper_remove(aItems) {
200 this._jobs.push(job);
204 if (this._jobs.length == 1) {
207 var sip =
Cc[
"@mozilla.org/supports-interface-pointer;1"]
208 .createInstance(
Ci.nsISupportsInterfacePointer);
214 SBJobUtils.showProgressDialog(sip.data,
null, 0);
222 onJobComplete:
function RemoveHelper_onJobComplete() {
224 if (this._jobs.length > 0) {
225 this._jobs[0].begin();
233 return XPCOMUtils.generateModule([RemoveHelper]);
function GeneratorThread(aEntryPoint)
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function SBString(aKey, aDefault, aStringBundle)
function RemoveJob(aItems, aHelper)
sbDeviceFirmwareAutoCheckForUpdate prototype classID
Javascript wrappers for common library tasks.
sbDeviceFirmwareAutoCheckForUpdate prototype getInterfaces
sbDeviceFirmwareAutoCheckForUpdate prototype interfaces