mockCDController.js
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2009 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 var Cc = Components.classes;
26 var Ci = Components.interfaces;
27 var Cu = Components.utils;
28 
29 const INSERT_LABEL = "Insert Into Drive ";
30 const EJECT_LABEL = "Eject Drive ";
31 
32 
34 {
35  // sbICDDevice instances
36  _device1: null,
37  _device2: null,
38 
39  // XUL Elements
40  _buttonDevice1: null,
41  _buttonDevice2: null,
42  _albumRadioGroup: null,
43 
44  onDialogLoad: function()
45  {
46  var mockCDService =
47  Cc["@songbirdnest.com/device/cd/mock-cddevice-service;1"]
48  .getService(Ci.sbICDDeviceService);
49 
50  this._device1 = mockCDService.getDevice(0);
51  this._device2 = mockCDService.getDevice(1);
52 
53  mockCDService.registerListener(this);
54 
55  this._buttonDevice1 = document.getElementById("mockcd-drive1-button");
56  this._buttonDevice2 = document.getElementById("mockcd-drive2-button");
57  this._albumRadioGroup = document.getElementById("album-radiogroup");
58 
59  this._update();
60  },
61 
62  onDriveAction: function(aDeviceNum)
63  {
64  var device = (aDeviceNum == 1 ? this._device1 : this._device2);
65  this._handleDriveAction(device);
66  },
67 
68  _handleDriveAction: function(aDevice)
69  {
70  var mockCDService =
71  Cc["@songbirdnest.com/device/cd/mock-cddevice-service;1"]
72  .getService(Ci.sbICDDeviceService)
73  .QueryInterface(Ci.sbIMockCDDeviceController);
74 
75  if (aDevice.isDiscInserted) {
76  mockCDService.ejectMedia(aDevice);
77  }
78  else {
79  // Insert the disc TOC based on the value of the selected radio item
80  var mediaIndex = parseInt(this._albumRadioGroup.selectedItem.value);
81  mockCDService.insertMedia(aDevice, mediaIndex);
82  }
83  },
84 
85  _update: function()
86  {
87  // Update button labels
88  if (this._device1.isDiscInserted) {
89  this._buttonDevice1.setAttribute("label", EJECT_LABEL + "1");
90  }
91  else {
92  this._buttonDevice1.setAttribute("label", INSERT_LABEL + "1");
93  }
94  if (this._device2.isDiscInserted) {
95  this._buttonDevice2.setAttribute("label", EJECT_LABEL + "2");
96  }
97  else {
98  this._buttonDevice2.setAttribute("label", INSERT_LABEL + "2");
99  }
100  },
101 
102  // sbICDDeviceListener
103  onDeviceRemoved: function(aCDDevice)
104  {
105  },
106 
107  onMediaInserted: function(aCDDevice)
108  {
109  dump("\n\n\n onMediaInserted: " + aCDDevice.name + "\n\n\n");
110  this._update();
111  },
112 
113  onMediaEjected: function(aCDDevice)
114  {
115  dump("\n\n\n onMediaEjected: " + aCDDevice.name + "\n\n\n");
116  this._update();
117  },
118 };
119 
const INSERT_LABEL
var DialogController
var Cc
var Ci
return null
Definition: FeedWriter.js:1143
const EJECT_LABEL
var Cu