47 Components.utils.import(
"resource://app/jsmodules/DOMUtils.jsm");
48 Components.utils.import(
"resource://app/jsmodules/SBUtils.jsm");
57 if (typeof(
Cc) ==
"undefined")
58 var
Cc = Components.classes;
59 if (typeof(
Ci) ==
"undefined")
60 var
Ci = Components.interfaces;
61 if (typeof(
Cr) ==
"undefined")
62 var
Cr = Components.results;
63 if (typeof(
Cu) ==
"undefined")
64 var
Cu = Components.utils;
67 DEFAULT_LOCALE:
"en-US",
70 getCountry:
function() {
75 var localeVal = SBLanguage.DEFAULT_LOCALE;
76 var regCountryVal =
"1033";
106 var wrk = Cc[
"@mozilla.org/windows-registry-key;1"]
107 .createInstance(Ci.nsIWindowsRegKey);
109 wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
110 "SOFTWARE\\Songbird",
112 if (wrk.hasValue(
"Installer Country")) {
113 regCountryVal = wrk.readStringValue(
"Installer Country");
123 if ( !isNaN(regCountryVal)) {
124 localeVal = langLocaleMap[
"" + regCountryVal];
138 onDownloadComplete:
function(
bundle) {
140 for (var
i=0;
i <
bundle.bundleExtensionCount;
i++) {
141 var thisLocale =
bundle.getExtensionAttribute(
i,
"languageTag");
142 if (thisLocale == SBLanguage.locale) {
143 for (var x = 0; x <
bundle.bundleExtensionCount; x++) {
144 bundle.setExtensionInstallFlag(x, x ==
i);
148 if (res ==
bundle.BUNDLE_INSTALL_SUCCESS) {
149 SBLanguage.firstRunWizard._markFirstRunComplete =
false;
150 switchLocale(SBLanguage.locale,
false);
155 SBString(
"locales.installfailed.title",
"Language Download" ),
156 SBString(
"locales.installfailed.msg",
"Language installation failed, check your network connectivity!" ) );
164 dump(
"Exception: " + e.toString() +
"\n");
167 onError:
function(
bundle) { dump(
"DWB: Error downloading bundles\n"); },
169 if (!aIID.equals(Components.interfaces.sbIBundleDataListener) &&
170 !aIID.equals(Components.interfaces.nsISupports))
172 throw Components.results.NS_ERROR_NO_INTERFACE;
177 loadLocaleFromRegistry :
function(firstRunWizard) {
178 SBLanguage.firstRunWizard = firstRunWizard;
180 SBLanguage.locale = SBLanguage.getCountry();
181 var prefLocaleVal =
Application.prefs.getValue(
"general.useragent.locale" ,
"");
182 var prefLocaleFirstRun =
Application.prefs.getValue(
"general.useragent.locale.firstrun",
true);
183 Application.prefs.setValue(
"general.useragent.locale.firstrun",
false);
187 if (prefLocaleFirstRun && SBLanguage.locale != prefLocaleVal) {
188 switchLocale(SBLanguage.locale);
190 var
sbIBundle =
new Components.Constructor(
"@songbirdnest.com/Songbird/Bundle;1",
"sbIBundle");
197 SB_LOG(
"initLocalesBundle",
"" + err );
203 dump(
"Exception:" + e.toString() +
"\n");
214 var firstRunWizard = {
224 restartWizard:
false,
239 _domEventListenerSet:
null,
240 _savedSettings:
false,
241 _markFirstRunComplete:
false,
242 _connectionErrorHandled:
false,
258 if (!this._wizardElem)
259 this._wizardElem = document.getElementById(
"first_run_wizard");
260 return this._wizardElem;
274 doLoad:
function firstRunWizard_doLoad() {
284 doUnload:
function firstRunWizard_doUnload() {
286 if (this._markFirstRunComplete) {
288 Application.prefs.setValue(
"songbird.firstrun.check.0.3",
true);
289 var prefService = Cc[
"@mozilla.org/preferences-service;1"]
290 .getService(Ci.nsIPrefService);
291 prefService.savePrefFile(
null);
295 this._firstRunData.onComplete(this.restartWizard);
310 doFinish:
function firstRunWizard_doFinish() {
313 var timingService = Cc[
"@songbirdnest.com/Songbird/TimingService;1"]
314 .getService(Ci.sbITimingService);
315 timingService.startPerfTimer(
"CSPerfEndEULA");
316 timingService.stopPerfTimer(
"CSPerfEndEULA");
318 dump(
"Timing service exception: " + e);
323 this._saveSettings();
331 doCancel:
function firstRunWizard_doCancel() {
339 doQuit:
function firstRunWizard_doQuit() {
344 SBUtils.deferFunction(quitApp);
352 doPageShow:
function firstRunWizard_doPageShow() {
365 _getNextProxyImport:
function
366 firstRunWizard_getNextProxyImport(aProxyImport, aLastImportId) {
367 var importSources = aProxyImport.importSources.enumerate();
368 while (importSources.hasMoreElements()) {
369 var
id = importSources.getNext()
370 .QueryInterface(Ci.nsISupportsString) +
'';
373 if (
id == aLastImportId) {
374 if (importSources.hasMoreElements())
375 return importSources.getNext()
376 .QueryInterface(Ci.nsISupportsString) +
'';
388 _tryNextProxyImport:
function firstRunWizard_tryNextProxyImport() {
389 var proxyImport = Cc[
"@songbirdnest.com/Songbird/NetworkProxyImport;1"]
390 .getService(Ci.sbINetworkProxyImport);
391 var lastImportId = this._lastProxyImport;
395 importId = this._getNextProxyImport(proxyImport, lastImportId);
398 success = proxyImport.importProxySettings(importId);
400 this._lastProxyImport = importId;
408 _resetProxySettings:
function firstRunWizard_resetProxySettings() {
410 [
"network.proxy.autoconfig_url",
""],
411 [
"network.proxy.type", 0],
412 [
"network.proxy.ftp",
""],
413 [
"network.proxy.ftp_port", 0],
414 [
"network.proxy.gopher",
""],
415 [
"network.proxy.gopher_port", 0],
416 [
"network.proxy.http",
""],
417 [
"network.proxy.http_port", 0],
418 [
"network.proxy.ssl",
""],
419 [
"network.proxy.ssl_port", 0],
420 [
"network.proxy.socks",
""],
421 [
"network.proxy.socks_port", 0],
422 [
"network.proxy.share_proxy_settings",
false],
423 [
"network.proxy.no_proxies_on",
"127.0.0.1;localhost"]
425 for (var
i in proxyData) {
426 Application.prefs.setValue(proxyData[
i][0], proxyData[i][1]);
436 handleConnectionError:
function firstRunWizard_handleConnectionError() {
438 if (this._connectionErrorHandled)
445 var func =
function() { _this._handleConnectionError(); };
451 _handleConnectionError:
function firstRunWizard__handleConnectionError() {
453 if (this._connectionErrorHandled)
456 if (this._tryNextProxyImport()) {
458 var
event = document.createEvent(
"Events");
459 event.initEvent(
"firstRunConnectionReset",
true,
true);
460 this.wizardElem.dispatchEvent(
event);
462 this.wizardElem.goTo(this.wizardElem.currentPage.pageid);
465 this._resetProxySettings();
468 this._connectionErrorHandled =
true;
472 var func =
function(aEvent) { aEvent.stopPropagation(); };
473 this._domEventListenerSet.add(this.wizardElem,
480 this.wizardElem.canAdvance =
true;
481 this.wizardElem.advance(
"first_run_connection_page");
484 this._connectionErrorHandled =
true;
498 update:
function firstRunWizard_update() {
500 var currentPage = this.wizardElem.currentPage;
503 if (currentPage.id ==
"first_run_welcome_page")
504 this._markFirstRunComplete =
true;
507 if (
window.arguments[0].perfTest &&
this._markFirstRunComplete) {
508 finishButton.click();
517 openURL:
function firstRunWizard_openURL(aURL) {
519 if (aURL instanceof Ci.nsIURI) {
523 uri = Cc[
"@mozilla.org/network/io-service;1"]
524 .getService(Ci.nsIIOService)
527 Cc[
"@mozilla.org/uriloader/external-protocol-service;1"]
528 .getService(Ci.nsIExternalProtocolService)
542 _initialize:
function firstRunWizard__initialize() {
544 if (this._initialized)
547 SBLanguage.loadLocaleFromRegistry(
this);
550 this.wizardElem = document.getElementById(
"first_run_wizard");
557 window.arguments[0].QueryInterface(Ci.nsIDialogParamBlock);
562 .queryElementAt(0, Ci.nsISupportsInterfacePointer)
567 this._initialized =
true;
568 var skipToPage =
Application.prefs.getValue(
"songbird.firstrun.goto",
null);
570 Application.prefs.get(
"songbird.firstrun.goto").reset();
571 this.wizardElem.advance(skipToPage);
577 Application.prefs.setValue(
"songbird.eulacheck",
true);
586 _finalize:
function firstRunWizard__finalize() {
588 if (this._domEventListenerSet)
589 this._domEventListenerSet.removeAll();
590 this._domEventListenerSet =
null;
598 _saveSettings:
function firstRunWizard__saveSettings() {
600 if (this._savedSettings)
604 var firstRunWizardPageElemList =
605 DOMUtils.getElementsByAttribute(this.wizardElem,
606 "firstrunwizardpage",
610 for (var
i = 0;
i < firstRunWizardPageElemList.length;
i++) {
612 var firstRunWizardPageElem = firstRunWizardPageElemList[
i];
613 if (typeof(firstRunWizardPageElem.saveSettings) ==
"function")
614 firstRunWizardPageElem.saveSettings();
617 this._savedSettings =
true;
function getPlatformString()
Get the name of the platform we are running on.
sbOSDControlService prototype QueryInterface
function DOMEventListenerSet()
function SB_LOG(scopeStr, msg)
function SBString(aKey, aDefault, aStringBundle)
var menubar_locales_bundle
var menubarLocalesBundleCB
Locales Bundle listener. Handles download completion and errors.
const MENUBAR_LOCALESBUNDLE_TIMEOUT
Songbird Bundle Interface This is the main bundle management interface, used to get the bundle data...
_getSelectedPageStyle s i