25 var
Cc = Components.classes;
26 var
Ci = Components.interfaces;
27 var
Cu = Components.utils;
50 const MOCK_DEVICE_ID = Components.ID(
"{3572E6FC-4954-4458-AFE7-0D0A65BF5F55}");
66 _buttonMockDeviceConnect:
null,
67 _buttonMockDeviceCfu:
null,
68 _buttonMockDeviceDownload:
null,
69 _buttonMockDeviceWrite:
null,
70 _buttonMockDeviceInstall:
null,
71 _buttonMockDeviceBusy:
null,
73 onDialogLoad:
function()
75 this._buttonMockDeviceConnect =
76 document.getElementById(
"mock-device-connect-button");
78 this._buttonMockDeviceCfu =
79 document.getElementById(
"mock-device-cfu-button");
86 this._buttonMockDeviceWrite =
87 document.getElementById(
"mock-device-write-button");
89 this._buttonMockDeviceInstall =
90 document.getElementById(
"mock-device-install-button");
92 this._buttonMockDeviceRecovery =
93 document.getElementById(
"mock-device-recovery-button");
95 this._buttonMockDeviceBusy =
96 document.getElementById(
"mock-device-busy-button");
101 onMockDeviceCheckForUpdateButton:
function()
119 onMockDeviceDownloadButton:
function()
129 this._buttonMockDeviceDownload.label = DOWNLOAD_FAIL_LABEL;
133 this._buttonMockDeviceDownload.label = DOWNLOAD_SUCCESS_LABEL;
137 onMockDeviceWriteButton:
function()
155 onMockDeviceInstallButton:
function()
173 onMockDeviceRecoveryButton:
function()
191 onMockDeviceBusyButton:
function()
209 onMockDeviceConnectButton:
function()
211 if(this._device ==
null) {
212 this._createMockDevice();
215 this._destroyMockDevice();
222 var devMan = this._getDevMan();
229 this._device = device;
230 this._deviceId = device.id;
279 this._buttonMockDeviceCfu.disabled =
true;
281 this._buttonMockDeviceWrite.disabled =
true;
282 this._buttonMockDeviceInstall.disabled =
true;
283 this._buttonMockDeviceRecovery.disabled =
true;
284 this._buttonMockDeviceBusy.disabled =
true;
288 _createMockDevice:
function()
291 Cc[
"@songbirdnest.com/Songbird/Device/DeviceTester/MockDevice;1"]
292 .createInstance(
Ci.sbIDevice);
295 Cc[
"@songbirdnest.com/Songbird/DeviceManager;2"]
296 .getService(
Ci.sbIDeviceManager2);
297 devMan.registerDevice(device);
300 Cc[
"@songbirdnest.com/Songbird/Variant;1"]
301 .createInstance(
Ci.nsIWritableVariant);
302 data.setAsISupports(device.QueryInterface(Components.interfaces.nsISupports));
305 devMan.createEvent(
Ci.sbIDeviceEvent.EVENT_DEVICE_ADDED, device);
306 devMan.dispatchEvent(ev);
308 device.setPreference(
"testing.busy",
false);
310 this._device = device;
311 this._deviceId = device.id;
315 this._buttonMockDeviceCfu.disabled =
false;
317 this._buttonMockDeviceWrite.disabled =
false;
318 this._buttonMockDeviceInstall.disabled =
false;
319 this._buttonMockDeviceRecovery.disabled =
false;
320 this._buttonMockDeviceBusy.disabled =
false;
323 _destroyMockDevice:
function()
325 var devMan = this._getDevMan();
328 Cc[
"@songbirdnest.com/Songbird/Variant;1"]
329 .createInstance(
Ci.nsIWritableVariant);
330 data.setAsISupports(this._device.QueryInterface(
Ci.nsISupports));
333 devMan.createEvent(
Ci.sbIDeviceEvent.EVENT_DEVICE_REMOVED,
this._device);
334 devMan.dispatchEvent(ev);
336 devMan.unregisterDevice(this._device);
339 this._deviceId =
null;
343 this._buttonMockDeviceCfu.disabled =
true;
345 this._buttonMockDeviceWrite.disabled =
true;
346 this._buttonMockDeviceInstall.disabled =
true;
347 this._buttonMockDeviceRecovery.disabled =
true;
348 this._buttonMockDeviceBusy.disabled =
true;
351 _getDevMan:
function()
354 Cc[
"@songbirdnest.com/Songbird/DeviceManager;2"]
355 .getService(
Ci.sbIDeviceManager2);
const PREF_MOCK_DEVICE_BUSY
const DISCONNECT_BUTTON_LABEL
const PREF_MOCK_DEVICE_CFU_FAIL
var DeviceDialogController
const WRITE_SUCCESS_LABEL
const PREF_MOCK_DEVICE_WRITE_FAIL
const RECOVERY_ENABLE_LABEL
const RECOVERY_DISABLE_LABEL
const PREF_MOCK_DEVICE_NEED_RECOVERY
const PREF_MOCK_DEVICE_DOWNLOAD_FAIL
const PREF_MOCK_DEVICE_INSTALL_FAIL
const INSTALL_SUCCESS_LABEL
const CONNECT_BUTTON_LABEL