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/StringUtils.jsm");
58 Cu.import(
"resource://app/jsmodules/SBUtils.jsm");
60 if (typeof(
XUL_NS) ==
"undefined")
61 var
XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
83 initialize:
function DeviceMgmtTabs_initialize(aWidget) {
85 this._widget = aWidget;
88 this._deviceID = this._widget.deviceID;
89 this._device = this._widget.device;
91 var toolsBox = this._getElement(
"device_tools");
92 var settingsBox = this._getElement(
"device_summary_settings");
93 var tabBox = this._getElement(
"device_management_tabbox");
95 toolsBox.addEventListener(
"DOMAttrModified", this.tabListener,
false);
97 settingsBox.addEventListener(
"DOMAttrModified", this.tabListener,
false);
99 tabBox.addEventListener(
"DOMAttrModified", this.tabListener,
false);
105 var deviceEventTarget = this._device;
106 deviceEventTarget.QueryInterface(Ci.sbIDeviceEventTarget);
107 deviceEventTarget.addEventListener(
this);
111 tabListener:
function DeviceMgmtTabs_tabDisableListener(
event) {
112 switch (
event.attrName) {
114 var
target =
event.target;
115 var
id = target.getAttribute(
"sbid");
116 if (
event.newValue ==
"true") {
117 if (
id ==
"device_tools") {
118 DeviceMgmtTabs._widget.setAttribute(
"hideToolsTab",
"true");
119 }
else if (
id ==
"device_summary_settings") {
120 DeviceMgmtTabs._widget.setAttribute(
"hideSettingsTab",
"true");
123 if (
id ==
"device_tools") {
124 DeviceMgmtTabs._widget.removeAttribute(
"hideToolsTab");
125 }
else if (
id ==
"device_summary_settings") {
126 DeviceMgmtTabs._widget.removeAttribute(
"hideSettingsTab");
131 case "selectedIndex":
132 if (
event.newValue ==
"2") {
133 DeviceMgmtTabs._dispatchImageTabEvent();
139 _update:
function DeviceMgmtTabs_update() {
142 var sbIDC = Ci.sbIDeviceCapabilities;
144 if (!this._deviceSupportsContent(sbIDC.CONTENT_AUDIO,
145 sbIDC.FUNCTION_AUDIO_PLAYBACK)) {
146 this._toggleTab(
"music",
true);
150 if (!this._deviceSupportsContent(sbIDC.CONTENT_VIDEO,
151 sbIDC.FUNCTION_VIDEO_PLAYBACK)) {
152 this._toggleTab(
"video",
true);
156 if (!this._deviceSupportsContent(sbIDC.CONTENT_IMAGE,
157 sbIDC.FUNCTION_IMAGE_DISPLAY)) {
158 this._toggleTab(
"image",
true);
166 finalize:
function DeviceMgmtTabs_finalize() {
168 var deviceEventTarget = this._device;
169 deviceEventTarget.QueryInterface(Ci.sbIDeviceEventTarget);
170 deviceEventTarget.removeEventListener(
this);
173 var toolsBox = this._getElement(
"device_tools");
174 var settingsBox = this._getElement(
"device_summary_settings");
176 toolsBox.removeEventListener(
"DOMAttrModified", this.tabListener,
false);
178 settingsBox.removeEventListener(
"DOMAttrModified",
183 this._deviceID =
null;
187 onDeviceEvent:
function DeviceMgmtTabs_onDeviceEvent(aEvent) {
188 switch (aEvent.type) {
189 case Ci.sbIDeviceEvent.EVENT_DEVICE_MEDIA_INSERTED:
190 case Ci.sbIDeviceEvent.EVENT_DEVICE_MEDIA_REMOVED:
191 case Ci.sbIDeviceEvent.EVENT_DEVICE_MOUNTING_END:
201 _dispatchImageTabEvent:
function DeviceMgmtTabs__dispatchImageTabEvent() {
202 let
event = document.createEvent(
"UIEvents");
203 event.initUIEvent(
"image-tab-selected",
false,
false,
window,
null);
204 document.dispatchEvent(
event);
214 _checkFunctionSupport:
215 function DeviceMgmtTabs__checkFunctionSupport(aFunctionType) {
217 var functionTypes = this._device
219 .getSupportedFunctionTypes({});
220 for (var
i in functionTypes) {
221 if (functionTypes[
i] == aFunctionType) {
228 switch (aFunctionType) {
229 case Ci.sbIDeviceCapabilities.FUNCTION_DEVICE:
230 strFunctionType =
"Device";
232 case Ci.sbIDeviceCapabilities.FUNCTION_AUDIO_PLAYBACK:
233 strFunctionType =
"Audio Playback";
235 case Ci.sbIDeviceCapabilities.FUNCTION_AUDIO_CAPTURE:
236 strFunctionType =
"Audio Capture";
238 case Ci.sbIDeviceCapabilities.FUNCTION_IMAGE_DISPLAY:
239 strFunctionType =
"Image Display";
241 case Ci.sbIDeviceCapabilities.FUNCTION_IMAGE_CAPTURE:
242 strFunctionType =
"Image Capture";
244 case Ci.sbIDeviceCapabilities.FUNCTION_VIDEO_PLAYBACK:
245 strFunctionType =
"Video Playback";
247 case Ci.sbIDeviceCapabilities.FUNCTION_VIDEO_CAPTURE:
248 strFunctionType =
"Video Capture";
251 strFunctionType =
"Unknown";
254 Cu.reportError(
"Unable to determine if device supports function type: "+
255 strFunctionType +
" [" + err +
"]");
270 _deviceSupportsContent:
271 function DeviceMgmtTabs__deviceSupportsContent(aContentType,
274 if (!this._checkFunctionSupport(aFunctionType)) {
294 var sbIDC = Ci.sbIDeviceCapabilities;
295 if (aContentType == sbIDC.CONTENT_IMAGE)
299 if (aFunctionType >= 0) {
301 var contentTypes = this._device
303 .getSupportedContentTypes(aFunctionType, {});
304 for (var
i in contentTypes) {
305 if (contentTypes[
i] == aContentType) {
312 switch (aContentType) {
313 case sbIDC.CONTENT_AUDIO:
314 strContentType =
"Audio";
316 case sbIDC.CONTENT_VIDEO:
317 strContentType =
"Video";
319 case sbIDC.CONTENT_IMAGE:
320 strContentType =
"Image";
323 strContentType =
"Unknown";
326 Cu.reportError(
"Unable to determine if device supports content: "+
327 strContentType +
" [" + err +
"]");
343 _toggleTab:
function DeviceMgmtTabs__toggleTab(aTabType, shouldHide) {
344 var
tab = this._getElement(
"device_management_" + aTabType +
"_sync_tab");
347 tab.setAttribute(
"hidden",
true);
350 tab.removeAttribute(
"hidden");
369 _getElement:
function DeviceMgmtTabs__getElement(aElementID) {
370 return document.getAnonymousElementByAttribute(this._widget,
_getSelectedPageStyle s i