49 if (typeof(
Cc) ==
"undefined")
50 var
Cc = Components.classes;
51 if (typeof(
Ci) ==
"undefined")
52 var
Ci = Components.interfaces;
53 if (typeof(
Cr) ==
"undefined")
54 var
Cr = Components.results;
55 if (typeof(
Cu) ==
"undefined")
56 var
Cu = Components.utils;
59 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
78 classID: Components.ID(
"{f93a67e4-d97d-4607-971e-00ae2bf8ef8f}"),
79 contractID:
"@songbirdnest.com/Songbird/FileDownloader;1",
80 ifList: [ Ci.sbIFileDownloader, Ci.nsIWebProgressListener ],
113 classID: sbFileDownloaderCfg.classID,
126 _webBrowserPersist:
null,
197 destinationFile:
null,
205 destinationFileExtension:
null,
212 temporaryFileFactory:
null,
221 start:
function sbFileDownloader_start() {
223 this._webBrowserPersist =
224 Cc[
"@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
225 .createInstance(Ci.nsIWebBrowserPersist);
226 this._webBrowserPersist.progressListener =
this;
227 this._webBrowserPersist.persistFlags =
228 Ci.nsIWebBrowserPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES |
229 Ci.nsIWebBrowserPersist.PERSIST_FLAGS_NO_CONVERSION |
230 Ci.nsIWebBrowserPersist.PERSIST_FLAGS_BYPASS_CACHE;
233 if (!this.sourceURI && this.sourceURISpec) {
234 var
ioService = Cc[
"@mozilla.org/network/io-service;1"]
235 .getService(Ci.nsIIOService);
236 this.sourceURI = ioService.newURI(this.sourceURISpec,
null,
null);
241 throw Cr.NS_ERROR_INVALID_ARG;
246 if (!this.destinationFile) {
247 if (this.temporaryFileFactory) {
248 this.destinationFile =
249 this.temporaryFileFactory.createFile(Ci.nsIFile.NORMAL_FILE_TYPE,
251 this.destinationFileExtension);
254 var temporaryFileService =
255 Cc[
"@songbirdnest.com/Songbird/TemporaryFileService;1"]
256 .getService(Ci.sbITemporaryFileService);
257 this.destinationFile =
258 temporaryFileService.createFile(Ci.nsIFile.NORMAL_FILE_TYPE,
260 this.destinationFileExtension);
265 this._webBrowserPersist.saveURI(this.sourceURI,
270 this.destinationFile);
278 cancel:
function sbFileDownloader_cancel() {
280 this._webBrowserPersist.cancelSave();
319 onStateChange:
function sbFileDownloader_onStateChange(aWebProgress,
324 this.request = aRequest;
328 if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
330 this.complete =
true;
333 var httpChannelFailed =
false;
335 var httpChannel = aRequest.QueryInterface(Ci.nsIHttpChannel);
336 httpChannelFailed = (httpChannel.requestSucceeded ?
false :
true);
341 if ((aStatus == Cr.NS_OK) && !httpChannelFailed)
347 if (this.destinationFile)
348 this.destinationFile = this.destinationFile.clone();
352 this.destinationFile.remove(
false);
353 this.destinationFile =
null;
357 this._webBrowserPersist.progressListener =
null;
395 function sbFileDownloader_onProgressChange(aWebProgress,
402 this.bytesToDownload = aMaxSelfProgress;
403 this.bytesDownloaded = aCurSelfProgress;
404 this.percentComplete =
405 Math.floor((this.bytesDownloaded / this.bytesToDownload) * 100);
429 onLocationChange:
function sbFileDownloader_onLocationChange(aWebProgress,
453 onStatusChange:
function sbFileDownloader_onStatusChange(aWebProgress,
479 onSecurityChange:
function sbFileDownloader_onSecurityChange(aWebProgress,
function succeeded(ch, cx, status, data)
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function NSGetModule(compMgr, fileSpec)
DataRemote prototype constructor
function sbFileDownloader()
sbDeviceFirmwareAutoCheckForUpdate prototype classID
ContinuingWebProgressListener prototype onStateChange
sbWindowsAutoPlayServiceCfg _xpcom_categories