50 Components.utils.import(
"resource://app/jsmodules/DOMUtils.jsm");
51 Components.utils.import(
"resource://app/jsmodules/FolderUtils.jsm");
61 if (typeof(
Cc) ==
"undefined")
62 var
Cc = Components.classes;
63 if (typeof(
Ci) ==
"undefined")
64 var
Ci = Components.interfaces;
65 if (typeof(
Cr) ==
"undefined")
66 var
Cr = Components.results;
67 if (typeof(
Cu) ==
"undefined")
68 var
Cu = Components.utils;
85 this._widget = aWidget;
101 _watchFolderAvailable:
false,
114 initialize:
function firstRunImportMediaSvc_initialize() {
116 this._selectDefaultScanDirectory();
119 var watchFolderService = Cc[
"@songbirdnest.com/watch-folder-service;1"]
120 .getService(Ci.sbIWatchFolderService);
121 this._watchFolderAvailable = watchFolderService.isSupported;
132 finalize:
function firstRunImportMediaSvc_finalize() {
142 saveSettings:
function firstRunImportMediaSvc_saveSettings() {
144 var importRadioGroupElem = this._getElement(
"import_radiogroup");
145 var metricsImportType;
146 switch (importRadioGroupElem.value) {
147 case "scan_directories" :
148 this._saveScanDirectoriesSettings();
149 metricsImportType =
"filescan";
153 metricsImportType =
"none";
157 #ifdef METRICS_ENABLED
158 var metrics = Cc[
"@songbirdnest.com/Songbird/Metrics;1"]
159 .createInstance(Ci.sbIMetrics);
160 metrics.metricsInc(
"firstrun",
"mediaimport", metricsImportType);
176 doCommand:
function firstRunImportMediaSvc_doCommand(aEvent) {
178 var action = aEvent.target.getAttribute(
"action");
180 case "browse_scan_directory" :
181 this._doBrowseScanDirectory();
197 _doBrowseScanDirectory:
function
198 firstRunImportMediaSvc__browseScanDirectory() {
200 var scanDirectoryTextBox = this._getElement(
"scan_directory_textbox");
201 var scanPath = scanDirectoryTextBox.value;
204 scanDir = Cc[
"@mozilla.org/file/local;1"]
205 .createInstance(Ci.nsILocalFile);
206 scanDir.initWithPath(scanPath);
210 var filePicker = Cc[
"@mozilla.org/filepicker;1"]
211 .createInstance(Ci.nsIFilePicker);
213 SBString(
"first_run.media_scan_browser.title"),
214 Ci.nsIFilePicker.modeGetFolder);
215 if (scanDir && scanDir.exists())
216 filePicker.displayDirectory = scanDir;
219 var result = filePicker.show();
222 if (result == Ci.nsIFilePicker.returnOK)
223 scanDirectoryTextBox.value = filePicker.file.path;
237 _update:
function firstRunImportMediaSvc__update() {
239 var importRadioGroupElem = this._getElement(
"import_radiogroup");
242 this._checkImportEnabled();
245 if (importRadioGroupElem.selectedIndex < 0)
246 this._selectDefaultImport();
249 var selectedRadioElem = importRadioGroupElem.selectedItem;
250 var selectedRadioElemID = selectedRadioElem.getAttribute(
"anonid");
253 var radioChildList = DOMUtils.getElementsByAttribute(importRadioGroupElem,
258 for (var
i = 0;
i < radioChildList.length;
i++) {
260 var child = radioChildList[
i];
261 if (child.getAttribute(
"parentradio") == selectedRadioElemID)
262 child.removeAttribute(
"disabled");
264 child.setAttribute(
"disabled",
"true");
273 _checkImportEnabled:
function firstRunImportMediaSvc__checkImportEnabled() {
276 if (!this._watchFolderAvailable) {
277 var scanDirectoriesWatchCheckBox =
278 this._getElement(
"scan_directories_watch_checkbox");
279 scanDirectoriesWatchCheckBox.hidden =
true;
288 _saveScanDirectoriesSettings:
289 function firstRunImportMediaSvc__savScanDirectoriesSettings() {
291 var scanDirectoryTextBox = this._getElement(
"scan_directory_textbox");
292 var scanDirectoryPath = scanDirectoryTextBox.value;
295 Application.prefs.setValue(
"songbird.firstrun.scan_directory_path",
297 Application.prefs.setValue(
"songbird.firstrun.do_scan_directory",
true);
301 if (this._watchFolderAvailable) {
303 var scanDirectoriesWatchCheckBox =
304 this._getElement(
"scan_directories_watch_checkbox");
305 var enableWatchFolder = scanDirectoriesWatchCheckBox.checked;
308 Application.prefs.setValue(
"songbird.watch_folder.enable",
310 if (enableWatchFolder) {
311 Application.prefs.setValue(
"songbird.watch_folder.path",
322 _selectDefaultImport:
function firstRunImportMediaSvc__selectDefaultImport() {
324 var importRadioGroupElem = this._getElement(
"import_radiogroup");
327 var scanDirectoriesElem = this._getElement(
"scan_directories_radio");
328 importRadioGroupElem.selectedItem = scanDirectoriesElem;
336 _selectDefaultScanDirectory:
337 function firstRunImportMediaSvc__selectDefaultScanDirectory() {
339 var scanDirectoryTextBox = this._getElement(
"scan_directory_textbox");
340 scanDirectoryTextBox.value = FolderUtils.musicFolder.path;
353 _getElement:
function firstRunImportMediaSvc__getElement(aElementID) {
354 return document.getAnonymousElementByAttribute(this._widget,
function SBString(aKey, aDefault, aStringBundle)
DataRemote prototype constructor
_getSelectedPageStyle s i