46 this[
"Cc"] = Components.classes;
48 this[
"Ci"] = Components.interfaces;
50 this[
"Cr"] = Components.results;
52 this[
"Cu"] = Components.utils;
54 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
55 Cu.import(
"resource://app/jsmodules/DebugUtils.jsm");
65 get updateCheckState() this.mUpdateCheckState,
67 get update() this.mUpdate,
68 set update(
val) this.mUpdate =
val,
96 mUpdateCheckState:
null,
97 K_HAS_UPDATE_STATE_FALSE: 0,
98 K_HAS_UPDATE_STATE_TRUE: 1,
99 K_HAS_UPDATE_STATE_UNKNOWN: 2,
100 K_HAS_UPDATE_STATE_CHECKING: 3,
104 LOG: DebugUtils.generateLogFunction(
"firstRunAppUpdate", 3),
105 TRACE: DebugUtils.generateLogFunction(
"firstRunAppUpdate", 5),
112 getString:
function firstRunAppUpdate_getString(
key,
args) {
114 return this.mStringBundle.format(
key,
args);
116 return this.mStringBundle.get(
key);
122 init:
function firstRunAppUpdate_init() {
124 this.mUpdateCheckState = this.K_HAS_UPDATE_STATE_UNKNOWN;
125 this.wrappedJSObject =
this;
130 onUnload:
function firstRunAppUpdate_onUnload(aEvent) {
139 let currentPage = document.documentElement.currentPage;
140 let
id = currentPage.id.replace(/
_(.)/g,
141 function(x,
y)
y.toUpperCase());
143 firstRunAppUpdate.TRACE(
"on page show: " +
id);
144 firstRunAppUpdate[
"onPageShow_" +
id]();
151 onPageShow_firstRunWelcomePage:
function firstRunAppUpdate_WelcomePage() {
154 Application.prefs.getValue(
"songbird.firstrun.check.app-update",
false);
157 this.mUpdateCheckState = this.K_HAS_UPDATE_STATE_FALSE;
159 else if (this.mUpdateCheckState == this.K_HAS_UPDATE_STATE_UNKNOWN) {
160 this.checkForUpdate();
170 checkForUpdate:
function firstRunAppUpdate_checkForUpdate() {
172 if (!this.mUpdateService.canApplyUpdates) {
174 this.
TRACE(
"Can't apply updates, skipping");
175 this.mUpdateCheckState = this.K_HAS_UPDATE_STATE_FALSE;
176 this.onUpdateStateChange();
179 this.
TRACE(
"Checking for updates...");
180 this.mUpdateCheckState = this.K_HAS_UPDATE_STATE_CHECKING;
181 this.mUpdateChecker.checkForUpdates(
this,
true);
190 onProgress:
function firstRunAppUpdate_onProgress(aRequest,
197 onCheckComplete:
function firstRunAppUpdate_onCheckComplete(aRequest,
201 this.
LOG(
"update check complete: " + aUpdateCount +
" updates found");
202 var update = this.mUpdateService.selectUpdate(aUpdates, aUpdateCount);
204 this.mUpdate = update;
205 this.mUpdateCheckState = this.K_HAS_UPDATE_STATE_TRUE;
208 this.mUpdateCheckState = this.K_HAS_UPDATE_STATE_FALSE;
210 this.onUpdateStateChange();
213 onError:
function firstRunAppUpdate_onError(aRequest, aUpdate) {
214 this.
LOG(
"update check error");
215 let currentPage = document.documentElement.currentPage;
216 if (currentPage.id ==
"first_run_app_update_check_page") {
218 this.mUpdateCheckState = this.K_HAS_UPDATE_STATE_FALSE;
223 this.mUpdateCheckState = this.K_HAS_UPDATE_STATE_UNKNOWN;
226 this.onUpdateStateChange();
230 onUpdateStateChange:
function firstRunAppUpdate_onUpdateStateChange() {
231 let currentPage = document.documentElement.currentPage;
232 if (currentPage.id !=
"first_run_app_update_check_page") {
235 this.mUpdateChecker =
null;
237 if (this.mUpdateCheckState == this.K_HAS_UPDATE_STATE_TRUE) {
238 this.
TRACE(
"Update state change: found update");
239 nextId = currentPage.getAttribute(
"next");
243 this.
TRACE(
"Update state change: no update");
244 nextId = currentPage.getAttribute(
"next_skip");
248 document.documentElement.goTo(nextId);
259 XPCOMUtils.defineLazyServiceGetter(firstRunAppUpdate,
261 "@mozilla.org/updates/update-service;1",
262 "nsIApplicationUpdateService2");
263 XPCOMUtils.defineLazyGetter(firstRunAppUpdate,
266 return Cc[
"@mozilla.org/updates/update-checker;1"]
267 .createInstance(
Ci.nsIUpdateChecker);
269 XPCOMUtils.defineLazyGetter(firstRunAppUpdate,
272 return new SBStringBundle(
"chrome://mozapps/locale/update/updates.properties");
281 firstRunAppUpdate.init();
sbOSDControlService prototype QueryInterface
this _dialogInput val(dateText)
function SBStringBundle(aBundle)
return!aWindow arguments!aWindow arguments[0]
this removeEventListener("load", this.__SS_restore, true)
function onUnload()
onUnload - called when the cover preview window unloads.
addEventListener("load", function(aEvent){removeEventListener(aEvent.type, arguments.callee, false);firstRunAppUpdate.init();}, false)