29 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
30 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
31 Components.utils.import(
"resource://app/jsmodules/StringUtils.jsm");
33 const Ci = Components.interfaces;
34 const Cc = Components.classes;
46 hasSpaceForWrite:
function BaseDeviceHelper_hasSpaceForWrite(
47 aSpaceNeeded, aLibrary, aDevice, aSpaceRemaining)
52 const deviceMgr =
Cc[
"@songbirdnest.com/Songbird/DeviceManager;2"]
53 .getService(
Ci.sbIDeviceRegistrar);
55 for (device in ArrayConverter.JSArray(deviceMgr.devices)) {
56 for (var library in ArrayConverter.JSArray(device.content.libraries)) {
57 if (library.equals(aLibrary)) {
66 throw Components.Exception(
"Failed to find device for library");
74 .getPropertyAsInt64(
"http://songbirdnest.com/device/1.0#freeSpace");
75 if (aSpaceRemaining) {
76 aSpaceRemaining.value = spaceRemaining;
80 if (aSpaceNeeded < spaceRemaining)
84 var messageKeyPrefix = this._getMessageKeyPrefix(aLibrary);
87 Cc[
"@songbirdnest.com/Songbird/Properties/UnitConverter/Storage;1"]
88 .createInstance(
Ci.sbIPropertyUnitConverter);
91 storageConverter.autoFormat(aSpaceNeeded, -1, 1),
92 storageConverter.autoFormat(spaceRemaining, -1, 1)
97 const prompter =
Cc[
"@songbirdnest.com/Songbird/Prompter;1"]
98 .getService(
Ci.sbIPrompter);
99 var neverPromptAgain = {
value:
false };
100 var abortRequest = prompter.confirmEx(
null,
101 SBString(messageKeyPrefix +
".title"),
103 Ci.nsIPromptService.STD_YES_NO_BUTTONS,
107 return (!abortRequest);
117 queryUserSpaceExceeded:
function BaseDeviceHelper_queryUserSpaceExceeded
125 var messageKeyPrefix = this._getMessageKeyPrefix(aLibrary);
128 Cc[
"@songbirdnest.com/Songbird/Properties/UnitConverter/Storage;1"]
129 .createInstance(
Ci.sbIPropertyUnitConverter);
131 (messageKeyPrefix +
".message",
133 storageConverter.autoFormat(aSpaceNeeded, -1, 1),
134 storageConverter.autoFormat(aSpaceAvailable, -1, 1) ]);
136 var buttonFlags = (
Ci.nsIPromptService.BUTTON_POS_0 *
137 Ci.nsIPromptService.BUTTON_TITLE_IS_STRING) +
138 (
Ci.nsIPromptService.BUTTON_POS_1 *
139 Ci.nsIPromptService.BUTTON_TITLE_IS_STRING);
140 var prompter =
Cc[
"@songbirdnest.com/Songbird/Prompter;1"]
141 .getService(
Ci.sbIPrompter);
142 var neverPromptAgain = {
value:
false };
143 var abortRequest = prompter.confirmEx
145 SBString(messageKeyPrefix +
".title"),
148 SBString(messageKeyPrefix +
".confirm_button"),
149 SBString(messageKeyPrefix +
".cancel_button"),
154 return !abortRequest;
157 _getMessageKeyPrefix:
158 function BaseDeviceHelper__getMessageKeyPrefix(aLibrary) {
159 var messageKeyPrefix =
"device.error.not_enough_freespace.prompt.";
160 messageKeyPrefix +=
"manual";
162 return messageKeyPrefix;
165 contractID:
"@songbirdnest.com/Songbird/Device/Base/Helper;1",
167 classID: Components.ID(
"{ebe6e08a-0604-44fd-a3d7-2be556b96b24}"),
169 Components.interfaces.sbIDeviceHelper
function SBFormattedString(aKey, aParams, aDefault, aStringBundle)
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function SBString(aKey, aDefault, aStringBundle)
sbDeviceFirmwareAutoCheckForUpdate prototype classID
function BaseDeviceHelper()