27 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
28 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
30 const Cc = Components.classes;
31 const Ci = Components.interfaces;
32 const Cr = Components.results;
33 const Cu = Components.utils;
41 doCDLookUp:
function(aDevice) {
43 var bag =
Cc[
"@mozilla.org/hash-property-bag;1"]
44 .createInstance(
Ci.nsIPropertyBag2);
45 aDevice.submitRequest(
Ci.sbICDDeviceEvent.REQUEST_CDLOOKUP, bag);
52 doCDRip:
function(aDevice) {
53 var deviceLibrary = this._getDeviceLibrary(aDevice);
56 var addItems = deviceLibrary.getItemsByProperty(SBProperties.shouldRip,
60 var ripItemsEnum = addItems.enumerate();
61 while (ripItemsEnum.hasMoreElements()) {
62 var ripItem = ripItemsEnum.getNext();
63 ripItem.setProperty(SBProperties.cdRipStatus,
null);
69 Cu.reportError(
"Error occurred when trying to rip tracks from CD: " + err);
78 _getDeviceLibrary:
function _getDeviceLibrary(aDevice, aIndex) {
79 if (typeof(aIndex) ==
"undefined") {
84 var libraries = aDevice.content.libraries;
85 if (libraries.length < 1) {
87 Cu.reportError(
"Device " + aDevice.id +
" has no libraries!");
92 var deviceLibrary = libraries.queryElementAt(aIndex,
Ci.sbIMediaList);
94 Cu.reportError(
"Unable to get library " + aIndex +
" for device: " +
Javascript wrappers for common library tasks.