46 if (typeof(
Cc) ==
"undefined")
47 var
Cc = Components.classes;
48 if (typeof(
Ci) ==
"undefined")
49 var
Ci = Components.interfaces;
50 if (typeof(
Cr) ==
"undefined")
51 var
Cr = Components.results;
52 if (typeof(
Cu) ==
"undefined")
53 var
Cu = Components.utils;
55 Cu.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
56 Cu.import(
"resource://app/jsmodules/sbProperties.jsm");
57 Cu.import(
"resource://app/jsmodules/sbProperties.jsm");
58 Cu.import(
"resource://app/jsmodules/ArrayConverter.jsm");
59 Cu.import(
"resource://app/jsmodules/DOMUtils.jsm");
61 if (typeof(
XUL_NS) ==
"undefined")
62 var
XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
80 _settingsChanged:
false,
83 _deviceMgmtSettings:
null,
84 _deviceGeneralSettings:
null,
85 _domEventListenerSet:
null,
94 initialize:
function DeviceSummarySettings_initialize(aWidget) {
96 this._widget = aWidget;
99 this._device = this._widget.device;
101 if ((this._device && this._device.defaultLibrary) ||
102 !
this._getElement(
"device_general_settings").hidden) {
103 this._widget.removeAttribute(
"disabledTab");
106 this._widget.setAttribute(
"disabledTab",
"true");
110 var deviceEventTarget =
111 this._device.QueryInterface(Ci.sbIDeviceEventTarget);
112 deviceEventTarget.addEventListener(
this);
114 this._saveButton = this._getElement(
"device_settings_button_save");
115 this._cancelButton = this._getElement(
"device_settings_button_cancel");
116 this._deviceMgmtSettings = this._getElement(
"device_management_settings");
117 this._deviceGeneralSettings = this._getElement(
"device_general_settings");
119 this._saveButton.setAttribute(
"disabled",
"true");
120 this._cancelButton.setAttribute(
"disabled",
"true");
127 var func =
function(aEvent) {
self._onSettingsChangeEvent(); };
128 this._domEventListenerSet.add(document,
134 this.updateBusyState();
141 finalize:
function DeviceSummarySettings_finalize() {
143 if (this._domEventListenerSet) {
144 this._domEventListenerSet.removeAll();
145 this._domEventListenerSet =
null;
150 var deviceEventTarget =
151 this._device.QueryInterface(Ci.sbIDeviceEventTarget);
152 deviceEventTarget.removeEventListener(
this);
157 this._settingsChanged =
false;
158 this._saveButton =
null;
159 this._cancelButton =
null;
160 this._deviceMgmtSettings =
null;
161 this._deviceGeneralSettings =
null;
167 updateBusyState:
function DeviceSummarySettings_updateBusyState() {
168 let isBusy = this._device && this._device.isBusy;
169 if (isBusy || !this._settingsChanged) {
170 this._saveButton.setAttribute(
"disabled",
"true");
171 this._cancelButton.setAttribute(
"disabled",
"true");
174 this._saveButton.removeAttribute(
"disabled");
175 this._cancelButton.removeAttribute(
"disabled");
179 this._deviceMgmtSettings.setAttribute(
"disabled",
"true");
180 this._deviceGeneralSettings.setAttribute(
"disabled",
"true");
183 this._deviceMgmtSettings.removeAttribute(
"disabled");
184 this._deviceGeneralSettings.removeAttribute(
"disabled");
199 save:
function DeviceSummarySettings_save() {
200 this._settingsChanged =
false;
201 this._saveButton.setAttribute(
"disabled",
"true");
202 this._cancelButton.setAttribute(
"disabled",
"true");
203 this._deviceMgmtSettings.save();
204 if (!this._deviceGeneralSettings.hidden)
205 this._deviceGeneralSettings.save();
212 reset:
function DeviceSummarySettings_reset() {
213 this._settingsChanged =
false;
214 this._saveButton.setAttribute(
"disabled",
"true");
215 this._cancelButton.setAttribute(
"disabled",
"true");
216 this._deviceMgmtSettings.reset();
217 if (!this._deviceGeneralSettings.hidden)
218 this._deviceGeneralSettings.reset();
231 onDeviceEvent:
function DeviceSummarySettings_onDeviceEvent(aEvent) {
235 case Ci.sbIDeviceEvent.EVENT_DEVICE_STATE_CHANGED:
236 this.updateBusyState();
253 _onSettingsChangeEvent:
254 function DeviceSummarySettings__onSettingsChangeEvent(aEvent) {
255 this._settingsChanged =
true;
256 this._saveButton.removeAttribute(
"disabled");
257 this._cancelButton.removeAttribute(
"disabled");
269 _getElement:
function DeviceSummarySettings__getElement(aElementID) {
270 return document.getAnonymousElementByAttribute(this._widget,
function DOMEventListenerSet()
var DeviceSummarySettings