52 Components.utils.import(
"resource://app/jsmodules/AddOnUtils.jsm");
53 Components.utils.import(
"resource://app/jsmodules/ObserverUtils.jsm");
54 Components.utils.import(
"resource://app/jsmodules/SBUtils.jsm");
55 Components.utils.import(
"resource://app/jsmodules/WindowUtils.jsm");
56 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
65 if (typeof(
Cc) ==
"undefined")
66 var
Cc = Components.classes;
67 if (typeof(
Ci) ==
"undefined")
68 var
Ci = Components.interfaces;
69 if (typeof(
Cr) ==
"undefined")
70 var
Cr = Components.results;
71 if (typeof(
Cu) ==
"undefined")
72 var
Cu = Components.utils;
100 className:
"Songbird Add-on Bundle Update Service",
101 cid: Components.ID(
"{927d9849-8565-4bc4-805a-f3a6ad1b25ec}"),
102 contractID:
"@songbirdnest.com/AddOnBundleUpdateService;1",
103 ifList: [ Ci.sbIAddOnBundleUpdateService, Ci.nsIObserver ],
105 updateEnabledPref:
"songbird.recommended_addons.update.enabled",
106 updateIntervalPref:
"songbird.recommended_addons.update.interval",
107 updatePrevAppVersionPref:
108 "songbird.recommended_addons.update.prev_app_version",
109 defaultUpdateEnabled:
false,
110 defaultUpdateInterval: 86400
113 sbAddOnBundleUpdateServiceCfg.categoryList = [
115 category:
"app-startup",
116 entry: sbAddOnBundleUpdateServiceCfg.className,
117 value:
"service," + sbAddOnBundleUpdateServiceCfg.contractID
163 classID: sbAddOnBundleUpdateServiceCfg.cid,
164 contractID: sbAddOnBundleUpdateServiceCfg.contractID,
168 _isInitialized:
false,
170 _prefsAvailable:
false,
171 _networkAvailable:
false,
172 _updateEnabled:
false,
173 _checkedFirstRunHasCompleted:
false,
174 _firstRunHasCompleted:
false,
175 _addOnBundleLoader:
null,
188 restartRequired:
false,
195 checkForUpdates:
function sbAddOnBundleUpdateService_checkForUpdates() {
200 if (this._updateEnabled) {
203 if (this._getApplicationWasUpdated())
204 this._updateAddOnBundleCache(
true);
207 this._presentNewAddOns();
226 observe:
function sbAddOnBundleUpdateService_observe(aSubject,
232 this._handleAppStartup();
235 case "profile-after-change" :
236 this._handleProfileAfterChange();
239 case "final-ui-startup" :
240 this._handleFinalUIStartup();
243 case "quit-application" :
244 this._handleAppQuit();
259 QueryInterface: XPCOMUtils.generateQI(sbAddOnBundleUpdateServiceCfg.ifList),
272 _handleAppStartup:
function sbAddOnBundleUpdateService__handleAppStartup() {
282 _handleProfileAfterChange:
283 function sbAddOnBundleUpdateService__handleProfileAfterChange() {
285 this._prefsAvailable =
true;
296 _handleFinalUIStartup:
297 function sbAddOnBundleUpdateService__handleFinalUIStartup() {
301 this._networkAvailable =
true;
312 _handleAppQuit:
function sbAddOnBundleUpdateService__handleAppQuit() {
322 _handleAddOnUpdateTimer:
323 function sbAddOnBundleUpdateService__handleAddOnUpdateTimer(aTimer) {
325 this._updateAddOnBundleCache(
false);
339 _initialize:
function sbAddOnBundleUpdateService__initialize() {
341 if (this._isInitialized)
345 if (!this._observerSet) {
346 this._observerSet =
new ObserverSet();
347 this._observerSet.add(
this,
"quit-application",
false,
false);
348 this._observerSet.add(
this,
"profile-after-change",
false,
true);
349 this._observerSet.add(
this,
"final-ui-startup",
false,
true);
353 if (!this._prefsAvailable)
359 if (!this._checkedFirstRunHasCompleted) {
360 this._firstRunHasCompleted =
SBUtils.hasFirstRunCompleted();
361 if (!this._firstRunHasCompleted)
362 this._updatePrevAppVersion();
363 this._checkedFirstRunHasCompleted =
true;
367 if (!this._networkAvailable)
371 this._isInitialized =
true;
374 if (!this._firstRunHasCompleted)
378 var
Application = Cc[
"@mozilla.org/fuel/application;1"]
379 .getService(Ci.fuelIApplication);
382 this._updateEnabled =
383 Application.prefs.getValue(this._cfg.updateEnabledPref,
384 this._cfg.defaultUpdateEnabled);
385 if (!this._updateEnabled)
390 Application.prefs.getValue(this._cfg.updateIntervalPref,
391 this._cfg.defaultUpdateInterval);
395 var updateTimerMgr = Cc[
"@mozilla.org/updates/timer-manager;1"]
396 .createInstance(Ci.nsIUpdateTimerManager);
398 var func =
function(aTimer) { _this._handleAddOnUpdateTimer(aTimer); };
399 updateTimerMgr.registerTimer(
"add-on-bundle-update-timer",
409 _finalize:
function sbAddOnBundleUpdateService__finalize() {
411 if (this._addOnBundleLoader) {
412 this._addOnBundleLoader.cancel();
413 this._addOnBundleLoader =
null;
417 if (this._observerSet) {
418 this._observerSet.removeAll();
419 this._observerSet =
null;
429 function sbAddOnBundleUpdateService__presentNewAddOns() {
431 var addOnBundle = this._loadNewAddOns();
434 if (!addOnBundle || (addOnBundle.bundleExtensionCount == 0))
438 var restartRequired = {};
439 WindowUtils.openModalDialog
441 "chrome://songbird/content/xul/recommendedAddOnsWizard.xul",
443 "chrome,modal=yes,centerscreen",
445 [ restartRequired ]);
446 this.restartRequired = (restartRequired.value ==
"true");
456 _loadNewAddOns:
function sbAddOnBundleUpdateService__loadNewAddOns() {
465 addOnBundleLoader.filterInstalledAddOns =
true;
466 addOnBundleLoader.filterBlacklistedAddOns =
true;
467 addOnBundleLoader.readFromCache =
true;
468 addOnBundleLoader.start(
null);
471 if (!addOnBundleLoader.complete ||
472 !Components.isSuccessCode(addOnBundleLoader.result))
475 return addOnBundleLoader.addOnBundle;
486 _updateAddOnBundleCache:
487 function sbAddOnBundleUpdateService__updateAddOnBundleCache(aSync) {
489 if (!this._addOnBundleLoader) {
495 var func =
function() { _this._updateAddOnBundleCacheContinue(); }
496 this._addOnBundleLoader.start(func);
502 var threadManager = Cc[
"@mozilla.org/thread-manager;1"]
503 .getService(Ci.nsIThreadManager);
507 while (this._addOnBundleLoader && !this._addOnBundleLoader.complete) {
518 _updateAddOnBundleCacheContinue:
519 function sbAddOnBundleUpdateService__updateAddOnBundleCacheContinue() {
521 if (this._addOnBundleLoader.complete)
522 this._addOnBundleLoader =
null;
532 _getApplicationWasUpdated:
533 function sbAddOnBundleUpdateService__getApplicationWasUpdated() {
537 var
Application = Cc[
"@mozilla.org/fuel/application;1"]
538 .getService(Ci.fuelIApplication);
541 var appInfo = Cc[
"@mozilla.org/xre/app-info;1"]
542 .getService(Ci.nsIXULAppInfo);
543 var appVersion = appInfo.version;
547 Application.prefs.getValue(this._cfg.updatePrevAppVersionPref,
"");
553 if (!prevAppVersion || (prevAppVersion != appVersion))
557 Application.prefs.setValue(this._cfg.updatePrevAppVersionPref, appVersion);
568 _updatePrevAppVersion:
569 function sbAddOnBundleUpdateService__updatePrevAppVersion() {
571 var appInfo = Cc[
"@mozilla.org/xre/app-info;1"]
572 .getService(Ci.nsIXULAppInfo);
573 var appVersion = appInfo.version;
576 var
Application = Cc[
"@mozilla.org/fuel/application;1"]
577 .getService(Ci.fuelIApplication);
578 Application.prefs.setValue(this._cfg.updatePrevAppVersionPref, appVersion);
GeneratorThread currentThread
function checkForUpdates()
sbOSDControlService prototype className
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
function sbAddOnBundleUpdateService()
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
var sbAddOnBundleUpdateServiceCfg
function NSGetModule(compMgr, fileSpec)
DataRemote prototype constructor
sbDeviceFirmwareAutoCheckForUpdate prototype classID
sbWindowsAutoPlayServiceCfg _xpcom_categories
function AddOnBundleLoader()
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe