41 Components.utils.import(
"resource://app/jsmodules/sbSmartMediaListColumnSpecUpdater.jsm");
42 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
48 mainWinInit.init_once = 0;
49 mainWinInit.deinit_once = 0;
50 mainWinInit.onLoad =
function()
52 if (mainWinInit.init_once++) { dump(
"WARNING: mainWinInit double init!!\n");
return; }
55 mainWinInit.onUnload =
function()
57 if (mainWinInit.deinit_once++) { dump(
"WARNING: mainWinInit double deinit!!\n");
return; }
58 window.removeEventListener(
"load", mainWinInit.onLoad,
false);
59 window.removeEventListener(
"unload", mainWinInit.onUnload,
false);
69 function checkFirstRun()
71 var firstRunDoImportLibrary =
72 Application.prefs.getValue(
"songbird.firstrun.do_import_library",
74 if (firstRunDoImportLibrary) {
75 Application.prefs.setValue(
"songbird.firstrun.skip_load_default_page",
82 window.addEventListener(
"load", mainWinInit.onLoad,
false);
83 window.addEventListener(
"unload", mainWinInit.onUnload,
false);
97 initializeDocumentPlatformAttribute();
105 if (
window.addEventListener)
106 window.addEventListener(
"keydown", checkQuitKey,
true);
110 alert(
"mainWinInit.js - SBInitialize - " + err);
121 window.removeEventListener(
"keydown", checkQuitKey,
true);
132 GetMinWidth:
function()
137 GetMinHeight:
function()
142 GetMaxWidth:
function()
147 GetMaxHeight:
function()
152 OnWindowClose:
function()
159 if (!aIID.equals(Components.interfaces.sbIWindowMinMaxCallback) &&
160 !aIID.equals(Components.interfaces.nsISupportsWeakReference) &&
161 !aIID.equals(Components.interfaces.nsISupports))
163 throw Components.results.NS_ERROR_NO_INTERFACE;
176 if (platfrom ==
"Windows_NT") {
177 var windowMinMax = Components.classes[
"@songbirdnest.com/Songbird/WindowMinMax;1"];
178 var
service = windowMinMax.getService(Components.interfaces.sbIWindowMinMax);
180 service.setCallback(
window, SBWindowMinMaxCB);
187 dump(
"Error. songbird_hack.js:setMinMaxCallback() \n " + err +
"\n");
199 if (platform ==
"Windows_NT") {
200 var windowMinMax = Components.classes[
"@songbirdnest.com/Songbird/WindowMinMax;1"];
201 var
service = windowMinMax.getService(Components.interfaces.sbIWindowMinMax);
202 service.resetCallback(
window);
209 dump(
"Error. songbird_hack.js: SBUnitialize() \n" + err +
"\n");
235 var loadMLInBackground =
236 Application.prefs.getValue(
"songbird.firstrun.load_ml_in_background",
false);
239 let obs = Components.classes[
"@mozilla.org/observer-service;1"]
240 .getService(Components.interfaces.nsIObserverService);
247 function onJobComplete() {
252 LibraryUtils.mainLibrary, [SBProperties.contentType,
"audio"]);
253 gBrowser.loadMediaListViewWithFlags(mediaListView,
263 obs.notifyObservers(
null,
"songbird-main-library-ready",
null);
265 if (job.status !=
Ci.sbIJobProgress.STATUS_RUNNING)
268 job.addJobProgressListener(
function firstRunLibraryHider(){
270 if (job.status ==
Ci.sbIJobProgress.STATUS_RUNNING) {
274 job.removeJobProgressListener(
arguments.callee);
284 Application.prefs.getValue(
"songbird.firstrun.is_session",
false);
287 LibraryUtils.mainLibrary, [SBProperties.contentType,
"audio"]);
289 const placeholderURL =
"chrome://songbird/content/mediapages/firstrun.xul";
290 var currentURI = gBrowser.mediaTab.linkedBrowser.currentURI.spec;
291 if (currentURI == placeholderURL || currentURI ==
"about:blank") {
293 gBrowser.loadMediaListViewWithFlags(mediaListView,
301 obs.notifyObservers(
null,
"songbird-main-library-ready",
null);
308 var firstRunDoScanDirectory =
309 Application.prefs.getValue(
"songbird.firstrun.do_scan_directory",
311 if (!firstRunDoScanDirectory) {
316 Application.prefs.setValue(
"songbird.firstrun.do_scan_directory",
false);
317 var prefService =
Cc[
"@mozilla.org/preferences-service;1"]
318 .getService(
Ci.nsIPrefService);
319 prefService.savePrefFile(
null);
322 var firstRunScanDirectoryPath =
323 Application.prefs.getValue(
"songbird.firstrun.scan_directory_path",
"");
324 var firstRunScanDirectory =
Cc[
"@mozilla.org/file/local;1"]
325 .createInstance(
Ci.nsILocalFile);
327 firstRunScanDirectory.initWithPath(firstRunScanDirectoryPath);
329 firstRunScanDirectory =
null;
335 if (firstRunScanDirectory && firstRunScanDirectory.exists()) {
336 job = SBScanMedia(
null, firstRunScanDirectory);
338 Cu.reportError(
"Scan directory does not exist: \"" +
339 firstRunScanDirectoryPath +
"\"\n");
347 var firstRunDoImportLibrary =
348 Application.prefs.getValue(
"songbird.firstrun.do_import_library",
350 if (!firstRunDoImportLibrary)
354 Application.prefs.setValue(
"songbird.firstrun.do_import_library",
false);
355 var prefService =
Cc[
"@mozilla.org/preferences-service;1"]
356 .getService(
Ci.nsIPrefService);
357 prefService.savePrefFile(
null);
360 return SBLibraryOpen(
null,
true);
367 Components.classes[
"@songbirdnest.com/Songbird/library/Manager;1"]
368 .getService(Components.interfaces.sbILibraryManager);
369 var library = libraryManager.mainLibrary;
370 if (library.getProperty(SBProperties.createdFirstRunSmartPlaylists) ==
"1")
376 if (defaultSmartPlaylists) {
377 library.setProperty(SBProperties.createdFirstRunSmartPlaylists,
"1");
381 library.setProperty(SBProperties.createdFirstRunSmartPlaylists,
"1");
386 var defaultSmartPlaylists = [];
388 var propertyManager =
389 Cc[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
390 .getService(
Ci.sbIPropertyManager);
392 propertyManager.getPropertyInfo(SBProperties.playCount);
394 propertyManager.getPropertyInfo(SBProperties.rating);
396 propertyManager.getPropertyInfo(SBProperties.created);
398 propertyManager.getPropertyInfo(SBProperties.contentType);
400 const sbILDSML = Components.interfaces.sbILocalDatabaseSmartMediaList;
402 datePI.QueryInterface(Components.interfaces.sbIDatetimePropertyInfo);
407 defaultSmartPlaylists = [
409 name:
"&smart.defaultlist.highestrated",
412 property : SBProperties.rating,
413 operator : ratingPI.getOperator(ratingPI.OPERATOR_GREATER),
419 property : SBProperties.contentType,
420 operator : typePI.getOperator(typePI.OPERATOR_NOTEQUALS),
426 matchType : sbILDSML.MATCH_TYPE_ALL,
427 limitType : sbILDSML.LIMIT_TYPE_NONE,
429 selectPropertyID : SBProperties.rating,
430 selectDirection :
false,
431 randomSelection :
false,
435 name:
"&smart.defaultlist.recentlyadded",
438 property : SBProperties.created,
439 operator : datePI.getOperator(datePI.OPERATOR_INTHELAST),
440 leftValue : 1000*60*60*24*30,
445 property : SBProperties.contentType,
446 operator : typePI.getOperator(typePI.OPERATOR_NOTEQUALS),
452 matchType : sbILDSML.MATCH_TYPE_ALL,
453 limitType : sbILDSML.LIMIT_TYPE_NONE,
455 selectPropertyID : SBProperties.created,
456 selectDirection :
false,
457 randomSelection :
false,
461 name:
"&smart.defaultlist.recentlyplayed",
464 property : SBProperties.lastPlayTime,
465 operator : datePI.getOperator(datePI.OPERATOR_INTHELAST),
466 leftValue : 1000*60*60*24*7,
471 property : SBProperties.contentType,
472 operator : typePI.getOperator(typePI.OPERATOR_NOTEQUALS),
478 matchType : sbILDSML.MATCH_TYPE_ALL,
479 limitType : sbILDSML.LIMIT_TYPE_NONE,
481 selectPropertyID : SBProperties.lastPlayTime,
482 selectDirection :
false,
483 randomSelection :
false,
488 for each (var item
in defaultSmartPlaylists) {
495 Components.classes[
"@songbirdnest.com/Songbird/library/Manager;1"]
496 .getService(Components.interfaces.sbILibraryManager);
498 library = libraryManager.mainLibrary;
499 var mediaList = library.createMediaList(
"smart");
500 for (var prop in aItem) {
501 if (prop ==
"conditions") {
502 for each (var condition
in aItem.conditions) {
503 mediaList.appendCondition(condition.property,
506 condition.rightValue,
507 condition.displayUnit);
510 mediaList[prop] = aItem[prop];
513 SmartMediaListColumnSpecUpdater.update(mediaList);
function getPlatformString()
Get the name of the platform we are running on.
function SBFirstRunScanDirectories()
function addSmartPlaylist(aItem)
function SBDataGetIntValue(aKey)
Get the value of the data in integer format.
function SBFirstRunImportLibrary()
sbOSDControlService prototype QueryInterface
function SBPostOverlayLoad()
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
function SBUninitialize()
Uninitialize the main window.
function SBInitialize()
Initialize the main window.
function createDefaultSmartPlaylists()
return!aWindow arguments!aWindow arguments[0]
function resetMinMaxCallback()
Javascript wrappers for common library tasks.
function SBFirstRunSmartPlaylists()
function setMinMaxCallback(evt)