47 if (typeof(
Cc) ==
"undefined")
48 var
Cc = Components.classes;
49 if (typeof(
Ci) ==
"undefined")
50 var
Ci = Components.interfaces;
51 if (typeof(
Cr) ==
"undefined")
52 var
Cr = Components.results;
53 if (typeof(
Cu) ==
"undefined")
54 var
Cu = Components.utils;
71 this._widget = aWidget;
91 _autoLaunchSupported:
false,
92 _autoFirmwareCheckSupported:
false,
105 initialize:
function deviceGeneralSettingsSvc_initialize() {
107 this._device = this._widget.device;
112 this._getSupportedSettings();
115 if (!this._autoLaunchSupported && !this._autoFirmwareCheckSupported) {
116 this._widget.hidden =
true;
121 this._initializeUI();
129 finalize:
function deviceGeneralSettingsSvc_finalize() {
139 save:
function deviceGeneralSettingsSvc_save() {
141 this._setDeviceSettingsFromUISettings();
149 reset:
function deviceGeneralSettingsSvc_reset() {
151 this._setUISettingsFromDeviceSettings();
165 _getSupportedSettings:
166 function deviceGeneralSettingsSvc__getSupportedSettings() {
168 var propertyName =
"http://songbirdnest.com/device/1.0#supportsAutoLaunch";
169 if (this._device.properties.properties.hasKey(propertyName)) {
170 this._autoLaunchSupported =
171 this._device.properties.properties.getProperty(propertyName);
175 var updater = Cc[
'@songbirdnest.com/Songbird/Device/Firmware/Updater;1']
176 .getService(Ci.sbIDeviceFirmwareUpdater);
177 this._autoFirmwareCheckSupported = updater.hasHandler(this._device, 0, 0);
185 _initializeUI:
function deviceGeneralSettingsSvc__initializeUI() {
187 var autoLaunchCheckbox = this._getElement(
"auto_launch_checkbox");
188 autoLaunchCheckbox.hidden = !this._autoLaunchSupported;
191 var autoFirmwareCheckCheckbox =
192 this._getElement(
"auto_firmware_check_checkbox");
193 autoFirmwareCheckCheckbox.hidden = !this._autoFirmwareCheckSupported;
196 this._setUISettingsFromDeviceSettings();
208 _setUISettingsFromDeviceSettings:
function
209 deviceGeneralSettingsSvc__setUISettingsFromDeviceSettings(aSettingID) {
211 var allSettings = (aSettingID ?
false :
true);
214 if (this._autoLaunchSupported &&
215 (allSettings || (aSettingID ==
"auto_launch_checkbox"))) {
217 var autoLaunchEnabled = this._device.getPreference(
"auto_launch_enabled");
218 if (autoLaunchEnabled ==
null)
219 autoLaunchEnabled =
true;
222 var autoLaunchCheckbox = this._getElement(
"auto_launch_checkbox");
223 autoLaunchCheckbox.checked = autoLaunchEnabled;
227 if (this._autoFirmwareCheckSupported &&
228 (allSettings || (aSettingID ==
"auto_firmware_check_checkbox"))) {
231 var deviceAutoFirmwarePref =
232 this._device.getPreference(
"firmware.update.enabled");
234 var autoFirmwareCheckEnabled =
235 (deviceAutoFirmwarePref ==
null) ?
false : deviceAutoFirmwarePref;
238 var autoFirmwareCheckCheckbox =
239 this._getElement(
"auto_firmware_check_checkbox");
240 autoFirmwareCheckCheckbox.checked = autoFirmwareCheckEnabled;
253 _setDeviceSettingsFromUISettings:
function
254 deviceGeneralSettingsSvc__setDeviceSettingsFromUISettings(aSettingID) {
256 var allSettings = (aSettingID ?
false :
true);
259 if (this._autoLaunchSupported &&
260 (allSettings || (aSettingID ==
"auto_launch_checkbox"))) {
262 var autoLaunchCheckbox = this._getElement(
"auto_launch_checkbox");
263 var autoLaunchEnabled = autoLaunchCheckbox.checked;
266 this._device.setPreference(
"auto_launch_enabled", autoLaunchEnabled);
270 if (this._autoFirmwareCheckSupported &&
271 (allSettings || (aSettingID ==
"auto_firmware_check_checkbox"))) {
273 var autoFirmwareCheckCheckbox =
274 this._getElement(
"auto_firmware_check_checkbox");
275 var autoFirmwareCheckEnabled = autoFirmwareCheckCheckbox.checked;
278 this._device.setPreference(
"firmware.update.enabled",
279 autoFirmwareCheckEnabled);
287 dispatchSettingsChangeEvent:
288 function deviceGeneralSettingsSvc_dispatchSettingsChangeEvent() {
289 let
event = document.createEvent(
"UIEvents");
290 event.initUIEvent(
"settings-changed",
false,
false,
window,
null);
291 document.dispatchEvent(
event);
303 _getElement:
function deviceGeneralSettingsSvc__getElement(aElementID) {
304 return document.getAnonymousElementByAttribute(this._widget,
DataRemote prototype constructor
function deviceGeneralSettingsSvc(aWidget)