sbDownloadDeviceServicePaneModule.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-2010 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 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
26 Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
27 
28 const Ci = Components.interfaces;
29 const Cc = Components.classes;
30 const Cr = Components.results;
31 
33 {
34  this._servicePaneNode = null;
35  this._downloadDevice = null;
36  this._currentState = Ci.sbIDeviceBase.STATE_IDLE;
37 }
38 
40 {
41  classDescription: "Songbird Download Device Service Pane Module",
42  classID: Components.ID("{ee93796b-090e-4703-982a-1d27bea552c3}"),
43  contractID: "@songbirdnest.com/Songbird/DownloadDeviceServicePaneModule;1",
44  QueryInterface: XPCOMUtils.generateQI([Ci.sbIServicePaneModule,
45  Ci.sbIDeviceBaseCallback])
46 }
47 
48 // sbIServicePaneModule
49 sbDownloadDeviceServicePaneModule.prototype.servicePaneInit =
50 function sbDownloadDeviceServicePaneModule_servicePaneInit(aServicePaneModule)
51 {
52  var devMgr = Cc["@songbirdnest.com/Songbird/DeviceManager;1"]
53  .getService(Ci.sbIDeviceManager);
54  var downloadCat = "Songbird Download Device";
55  if (devMgr.hasDeviceForCategory(downloadCat)) {
56  this._downloadDevice = devMgr.getDeviceByCategory(downloadCat)
57  .QueryInterface(Ci.sbIDownloadDevice);
58  }
59  this._downloadDevice.addCallback(this);
60  this._currentState = this._downloadDevice.getDeviceState("download");
61  this._updateState();
62 }
63 
64 sbDownloadDeviceServicePaneModule.prototype.fillContextMenu =
65 function sbDownloadDeviceServicePaneModule_fillContextMenu(aNode,
66  aContextMenu,
67  aParentWindow)
68 {
69 }
70 
71 sbDownloadDeviceServicePaneModule.prototype.fillNewItemMenu =
72 function sbDownloadDeviceServicePaneModule_fillNewItemMenu(aNode,
73  aContextMenu,
74  aParentWindow)
75 {
76 }
77 
78 sbDownloadDeviceServicePaneModule.prototype.onSelectionChanged =
79 function sbDownloadDeviceServicePaneModule_onSelectionChanged(aNode,
80  aContainer,
81  aParentWindow)
82 {
83 }
84 
85 sbDownloadDeviceServicePaneModule.prototype.canDrop =
86 function sbDownloadDeviceServicePaneModule_canDrop(aNode,
87  aDragSession,
88  aOrientation,
89  aWindow)
90 {
91 }
92 
93 sbDownloadDeviceServicePaneModule.prototype.onDrop =
94 function sbDownloadDeviceServicePaneModule_onDrop(aNode,
95  aDragSession,
96  aOrientation,
97  aWindow)
98 {
99 }
100 
101 sbDownloadDeviceServicePaneModule.prototype.onDragGesture =
102 function sbDownloadDeviceServicePaneModule_onDragGesture(aNode,
103  aDataTransfer)
104 {
105 }
106 
107 sbDownloadDeviceServicePaneModule.prototype.onBeforeRename =
108 function sbDownloadDeviceServicePaneModule_onBeforeRename(aNode)
109 {
110 }
111 
112 sbDownloadDeviceServicePaneModule.prototype.onRename =
113 function sbDownloadDeviceServicePaneModule_onRename(aNode,
114  aNewName)
115 {
116 }
117 
118 sbDownloadDeviceServicePaneModule.prototype.__defineGetter__("stringBundle",
119 function sbDownloadDeviceServicePaneModule_get_stringBundle()
120 {
121 });
122 
124 function sbDownloadDeviceServicePaneModule_shutdown()
125 {
126  if (this._downloadDevice) {
127  this._downloadDevice.removeCallback(this);
128  }
129 }
130 
131 // sbIDeviceBaseCallback
132 sbDownloadDeviceServicePaneModule.prototype.onDeviceConnect =
133 function sbDownloadDeviceServicePaneModule_onDeviceConnect(aDeviceIdentifier)
134 {
135 }
136 
137 sbDownloadDeviceServicePaneModule.prototype.onDeviceDisconnect =
138 function sbDownloadDeviceServicePaneModule_onDeviceDisconnect(aDeviceIdentifier)
139 {
140 }
141 
142 sbDownloadDeviceServicePaneModule.prototype.onTransferStart =
143 function sbDownloadDeviceServicePaneModule_onTransferStart(aSourceURL,
144  aDestinationURL)
145 {
146 }
147 
148 sbDownloadDeviceServicePaneModule.prototype.onTransferComplete =
149 function sbDownloadDeviceServicePaneModule_onTransferComplete(aSourceURL,
150  aDestinationURL)
151 {
152 }
153 
154 sbDownloadDeviceServicePaneModule.prototype.onStateChanged =
155 function sbDownloadDeviceServicePaneModule_onStateChanged(aDeviceIdentifier,
156  aState)
157 {
158  this._currentState = aState;
159  this._updateState();
160 }
161 
162 sbDownloadDeviceServicePaneModule.prototype.__defineGetter__("_node",
163 function sbDownloadDeviceServicePaneModule_get_node()
164 {
165  if (!this._servicePaneNode) {
166  var lsps = Cc["@songbirdnest.com/servicepane/library;1"]
167  .getService(Ci.sbILibraryServicePaneService);
168  this._servicePaneNode =
169  lsps.getNodeForLibraryResource(this._downloadDevice.downloadMediaList);
170  }
171  return this._servicePaneNode;
172 });
173 
174 sbDownloadDeviceServicePaneModule.prototype._updateState =
175 function sbDownloadDeviceServicePaneModule_onStateChanged()
176 {
177  if (this._node) {
178  var a = this._node.className.split(" ");
179 
180  // Remove the "progress" property from the array, if any
181  a = a.filter(function(property) {
182  return property != "downloading";
183  });
184 
185  if (this._currentState == Ci.sbIDeviceBase.STATE_DOWNLOADING) {
186  a.push("downloading");
187  }
188 
189  this._node.className = a.join(" ");
190  }
191 }
192 
193 function NSGetModule(compMgr, fileSpec) {
194  var module = XPCOMUtils.generateModule(
196  function(aCompMgr, aFileSpec, aLocation) {
197  XPCOMUtils.categoryManager.addCategoryEntry(
198  "service-pane",
199  "z-download-device-service-pane-module",
200  sbDownloadDeviceServicePaneModule.prototype.contractID,
201  true,
202  true);
203  }
204  );
205  return module;
206 }
207 
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
const module
Definition: httpd.js:4659
function sbDownloadDeviceServicePaneModule()
return null
Definition: FeedWriter.js:1143
sbDeviceFirmwareAutoCheckForUpdate prototype classID
restoreWindow aState