26 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
27 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
28 Components.utils.import(
"resource://app/jsmodules/WindowUtils.jsm");
29 Components.utils.import(
"resource://app/jsmodules/StringUtils.jsm");
30 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
39 function _SBGetCurrentView()
42 var mediaPage = browser.currentMediaPage;
44 Components.utils.reportError(
"_SBGetCurrentView - Cannot return a view without a mediaPage");
47 var view = mediaPage.mediaListView;
49 Components.utils.reportError(
"_SBGetCurrentView - Cannot return a view");
55 function SBFileOpen( )
59 var fp = Components.classes[
"@mozilla.org/filepicker;1"]
60 .createInstance(nsIFilePicker);
66 fp.init(
window, sel, nsIFilePicker.modeOpen);
72 if (!
Application.prefs.getValue(
"songbird.mediascan.enableVideo",
false)) {
76 var exts = ArrayConverter.JSArray(extensions);
79 var filters = exts.map(
function(x){
return "*." + x});
82 fp.appendFilters(nsIFilePicker.filterAll);
84 fp.appendFilters(nsIFilePicker.filterHTML);
86 fp.appendFilter(mediafiles, filters.join(
";"));
93 [exts[
i].toUpperCase(), filters[
i]]);
94 fp.appendFilter(filetype, filters[
i]);
98 var fp_status = fp.show();
99 if ( fp_status == nsIFilePicker.returnOK )
102 var
ios = Components.classes[
"@mozilla.org/network/io-service;1"]
103 .getService(Components.interfaces.nsIIOService);
110 if (fp.file instanceof Components.interfaces.nsILocalFile) {
113 var spec =
"file://" + escape(fp.file.persistentDescriptor);
119 if ( isXPI( uri.spec ) )
121 installXPI( uri.spec );
125 if (fp.file instanceof Components.interfaces.nsILocalFile) {
126 if (!fp.file.exists()) {
127 gBrowser.addTab(uri.spec);
137 var item = SBImportURLIntoMainLibrary(uri);
142 var librarySPS =
Cc[
'@songbirdnest.com/servicepane/library;1']
143 .getService(
Ci.sbILibraryServicePaneService);
144 var
node = librarySPS.getNodeForLibraryResource(
146 item.getProperty(SBProperties.contentType));
152 var interval = setInterval(
function() {
157 view = _SBGetCurrentView();
158 index = view.getIndexForItem(item);
160 catch (e
if Components.lastResult ==
Cr.NS_ERROR_NOT_AVAILABLE) {
168 clearInterval(interval);
171 clearInterval(interval);
174 gBrowser.showIndexInView(view, index);
176 index = view.getIndexForItem(item);
178 gMM.sequencer.playView(view, index);
185 gBrowser.loadURI( uri.spec );
190 function MediaUriCheckerObserver(uri) {
194 MediaUriCheckerObserver.prototype.onStartRequest =
195 function MediaUriCheckerObserver_onStartRequest(aRequest, aContext)
199 MediaUriCheckerObserver.prototype.onStopRequest =
200 function MediaUriCheckerObserver_onStopRequest(aRequest, aContext, aStatusCode)
202 if (!Components.isSuccessCode(aStatusCode)) {
204 .getService(
Ci.sbILibraryManager);
206 library = libraryManager.mainLibrary;
209 "http://songbirdnest.com/data/1.0#contentURL",
212 library.remove(mediaItem);
214 gBrowser.addTab(this._uri.spec);
220 function SBUrlOpen( parentWindow )
223 var url_open_data =
new Object();
225 url_open_data.retval =
"";
227 SBOpenModalDialog(
"chrome://songbird/content/xul/openURL.xul",
"open_url",
"chrome,centerscreen", url_open_data, parentWindow );
228 if ( url_open_data.retval ==
"ok" )
233 var ios = Components.classes[
"@mozilla.org/network/io-service;1"]
234 .getService(Components.interfaces.nsIIOService);
235 var
url = url_open_data.URL;
241 isLocal = /^.:/.test(url);
244 isLocal = (url[0] ==
'/');
249 var
file = Components.classes[
"@mozilla.org/file/local;1"]
250 .createInstance(
Ci.nsILocalFile);
251 file.initWithPath(url);
252 uri = ios.newFileURI(file);
259 Components.utils.reportError(e);
264 if ( isXPI( uri.spec ) )
266 installXPI( uri.spec );
270 if (uri.scheme ==
"file") {
271 var pFileURL = uri.QueryInterface(
Ci.nsIFileURL);
272 if (pFileURL.file && !pFileURL.file.exists()) {
273 gBrowser.addTab(uri.spec);
278 if (uri.scheme ==
"http") {
279 var checker =
Cc[
"@mozilla.org/network/urichecker;1"]
280 .createInstance(
Ci.nsIURIChecker);
282 checker.asyncCheck(
new MediaUriCheckerObserver(uri),
null);
288 if (uri.scheme !=
"file")
289 item = SBImportURLIntoWebLibrary(uri);
292 item = SBImportURLIntoMainLibrary(uri);
297 var librarySPS =
Cc[
'@songbirdnest.com/servicepane/library;1']
298 .getService(
Ci.sbILibraryServicePaneService);
299 var node = librarySPS.getNodeForLibraryResource(
301 item.getProperty(SBProperties.contentType));
307 var interval = setInterval(
function() {
312 view = _SBGetCurrentView();
313 index = view.getIndexForItem(item);
315 catch (e
if Components.lastResult ==
Cr.NS_ERROR_NOT_AVAILABLE) {
323 clearInterval(interval);
326 clearInterval(interval);
329 gBrowser.showIndexInView(view, index);
331 index = view.getIndexForItem(item);
333 gMM.sequencer.playView(view, index);
340 gBrowser.loadURI( uri.spec );
345 function SBPlaylistOpen()
349 var aPlaylistReaderManager =
350 Components.classes[
"@songbirdnest.com/Songbird/PlaylistReaderManager;1"]
351 .getService(Components.interfaces.sbIPlaylistReaderManager);
354 var nsIFilePicker = Components.interfaces.nsIFilePicker;
355 var fp = Components.classes[
"@mozilla.org/filepicker;1"]
356 .createInstance(nsIFilePicker);
359 var sel =
SBString(
"faceplate.open.playlist",
"Open Playlist",
363 fp.init(
window, sel, nsIFilePicker.modeOpenMultiple);
365 var playlistfiles =
SBString(
"open.playlistfiles",
"Playlist Files",
369 var exts =
new Array();
370 var extensionCount =
new Object;
371 var extensions = aPlaylistReaderManager.supportedFileExtensions(extensionCount);
373 for (
i in extensions)
381 var filters = exts.map(
function(x){
return "*." + x});
384 fp.appendFilters(nsIFilePicker.filterAll);
386 fp.appendFilter(playlistfiles, filters.join(
";"));
393 [exts[
i].toUpperCase(), filters[
i]]);
394 fp.appendFilter(filetype, filters[
i]);
398 var fp_status = fp.show();
399 if ( fp_status == nsIFilePicker.returnOK )
401 var aFile, aURI, allFiles = fp.files;
402 var
ioService = Components.classes[
"@mozilla.org/network/io-service;1"]
403 .getService(Components.interfaces.nsIIOService)
404 while(allFiles.hasMoreElements()) {
405 aFile = allFiles.getNext().QueryInterface(Components.interfaces.nsIFile);
406 aURI = ioService.newFileURI(aFile);
409 var
name = aFile.leafName;
410 var
p = name.lastIndexOf(
".");
412 ext = name.slice(p + 1, name.length);
413 if (exts.indexOf(ext) > -1) {
414 name = name.slice(0, p);
417 SBOpenPlaylistURI(aURI, name);
427 function SBOpenPlaylistURI(aURI,
aName) {
429 if(!(aURI instanceof Components.interfaces.nsIURI)) {
435 var p = name.lastIndexOf(
".");
436 if (p != -1) name = name.slice(0, p);
437 p = name.lastIndexOf(
"/");
438 if (p != -1) name = name.slice(p+1);
440 var aPlaylistReaderManager =
441 Components.classes[
"@songbirdnest.com/Songbird/PlaylistReaderManager;1"]
442 .getService(Components.interfaces.sbIPlaylistReaderManager);
444 var library = Components.classes[
"@songbirdnest.com/Songbird/library/Manager;1"]
445 .getService(Components.interfaces.sbILibraryManager).mainLibrary;
448 var mediaList = library.createMediaList(
"simple");
449 mediaList.name =
name;
450 mediaList.setProperty(
"http://songbirdnest.com/data/1.0#originURL", uri.spec);
452 aPlaylistReaderManager.originalURI =
uri;
453 var success = aPlaylistReaderManager.loadPlaylist(uri, mediaList,
null,
false,
null);
456 var
array = Components.classes[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"]
457 .createInstance(Components.interfaces.nsIMutableArray);
458 for (var
i = 0;
i < mediaList.length;
i++) {
459 array.appendElement(mediaList.getItemByIndex(
i),
false);
462 var metadataService =
463 Components.classes[
"@songbirdnest.com/Songbird/FileMetadataService;1"]
464 .getService(Components.interfaces.sbIFileMetadataService);
465 var metadataJob = metadataService.read(array);
469 if (typeof gBrowser !=
'undefined') {
470 gBrowser.loadMediaList(mediaList);
473 library.remove(mediaList);
479 function SBLibraryOpen( parentWindow, silent )
482 var libraryImporterManager =
483 Cc[
"@songbirdnest.com/Songbird/LibraryImporterManager;1"]
484 .getService(
Ci.sbILibraryImporterManager);
485 var libraryImporter = libraryImporterManager.defaultLibraryImporter;
486 if (!libraryImporter)
490 "songbird.library_importer.import_tracks",
false);
492 "songbird.library_importer.import_playlists",
false);
493 if (!importTracks && !importPlaylists)
500 WindowUtils.openModalDialog
502 "chrome://songbird/content/xul/importLibrary.xul",
504 "chrome,centerscreen",
507 doImport = doImport.value ==
"true" ?
true :
false;
516 (
"songbird.library_importer.library_file_path",
518 job = libraryImporter.import(libraryFilePath,
"songbird",
false);
519 SBJobUtils.showProgressDialog(job,
window, 0,
true);
526 var consoleService = Components.classes[
'@mozilla.org/consoleservice;1']
527 .getService(Components.interfaces.nsIConsoleService);
528 consoleService.logStringMessage(
str );
537 function SBBrowserOpenURLInNewWindow( the_url ) {
538 SBOpenURLInDefaultBrowser(the_url);
542 function SBOpenURLInDefaultBrowser( the_url ) {
543 var externalLoader = (Components
544 .classes[
"@mozilla.org/uriloader/external-protocol-service;1"]
545 .getService(Components.interfaces.nsIExternalProtocolService));
546 var nsURI = (Components
547 .classes[
"@mozilla.org/network/io-service;1"]
548 .getService(Components.interfaces.nsIIOService)
550 externalLoader.loadURI(nsURI,
null);
556 var helpitem = document.getElementById(
"menuitem_help_topics");
560 function SBOpenEqualizer()
563 var equalizerControl = document.getElementById(
"menu_equalizer");
564 if (equalizerControl.getAttribute(
"disabled"))
567 var features =
"chrome,titlebar,toolbar,centerscreen,resizable=no";
568 SBOpenWindow(
"chrome://songbird/content/xul/mediacore/mediacoreEqualizer.xul",
"Equalizer", features);
571 function SBOpenPreferences(paneID, parentWindow)
573 if (!parentWindow) parentWindow =
window;
579 var instantApply = navigator.userAgent.indexOf(
"Windows") == -1;
584 var features =
"chrome,titlebar,resizable,toolbar,centerscreen" + (instantApply ?
",dialog=no" :
"");
586 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
587 var
win = wm.getMostRecentWindow(
"Browser:Preferences");
591 var pane = win.document.getElementById(paneID);
592 win.document.documentElement.showPane(pane);
596 return parentWindow.openDialog(
"chrome://browser/content/preferences/preferences.xul",
"Preferences", features, paneID);
603 function SBOpenDownloadManager()
605 var dlmgr =
Cc[
'@mozilla.org/download-manager;1'].getService();
606 dlmgr = dlmgr.QueryInterface(
Ci.nsIDownloadManager);
608 var windowMediator =
Cc[
'@mozilla.org/appshell/window-mediator;1']
610 windowMediator = windowMediator.QueryInterface(
Ci.nsIWindowMediator);
612 var dlmgrWindow = windowMediator.getMostRecentWindow(
"Download:Manager");
617 window.openDialog(
"chrome://mozapps/content/downloads/downloads.xul",
619 "chrome,centerscreen,dialog=no,resizable",
624 function SBScanMedia( aParentWindow, aScanDirectory )
626 var scanDirectory = aScanDirectory;
628 if ( !scanDirectory ) {
629 const nsIFilePicker = Components.interfaces.nsIFilePicker;
630 const CONTRACTID_FILE_PICKER =
"@mozilla.org/filepicker;1";
631 var fp = Components.classes[CONTRACTID_FILE_PICKER].createInstance(nsIFilePicker);
633 fp.init(
window, scan, nsIFilePicker.modeGetFolder );
635 var defaultDirectory =
636 Components.classes[
"@mozilla.org/file/directory_service;1"]
637 .getService(Components.interfaces.nsIProperties)
638 .get(
"Home", Components.interfaces.nsIFile);
639 defaultDirectory.append(
"Music");
640 fp.displayDirectory = defaultDirectory;
643 if ( res != nsIFilePicker.returnOK )
645 scanDirectory = fp.file;
648 if ( scanDirectory && !scanDirectory.exists() ) {
650 .getService(
Ci.nsIPromptService);
651 var strTitle =
SBString(
"media_scan.error.non_existent_directory.title");
653 (
"media_scan.error.non_existent_directory.msg",
654 [scanDirectory.path]);
655 promptService.alert(
window, strTitle, strMsg);
661 var
importer =
Cc[
'@songbirdnest.com/Songbird/DirectoryImportService;1']
662 .getService(
Ci.sbIDirectoryImportService);
663 if (typeof(ArrayConverter) ==
"undefined") {
664 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
666 if (typeof(SBJobUtils) ==
"undefined") {
667 Components.utils.import(
"resource://app/jsmodules/SBJobUtils.jsm");
669 var directoryArray = ArrayConverter.nsIArray([scanDirectory]);
670 var job = importer.import(directoryArray);
671 SBJobUtils.showProgressDialog(job,
window, 0);
678 function SBNewPlaylist(aEnumerator, aAllowDevicePlaylist)
680 var playlist = makeNewPlaylist(
"simple", aAllowDevicePlaylist);
683 playlist.addSome(aEnumerator);
688 function SBNewSmartPlaylist(aAllowDevicePlaylist)
690 var obj = { newSmartPlaylist:
null,
691 newPlaylistFunction:
function() {
692 return makeNewPlaylist(
"smart", aAllowDevicePlaylist);
696 SBOpenModalDialog(
"chrome://songbird/content/xul/smartPlaylist.xul",
697 "Songbird:SmartPlaylist",
698 "chrome,dialog=yes,centerscreen,modal,titlebar=no",
701 return obj.newSmartPlaylist;
711 function makeNewPlaylist(mediaListType, allowDevicePlaylist) {
712 var servicePane =
null;
715 var librarySPS =
Cc[
'@songbirdnest.com/servicepane/library;1']
716 .getService(
Ci.sbILibraryServicePaneService);
717 if (allowDevicePlaylist) {
719 var selectedNode =
null;
721 selectedNode = servicePane.activeNode;
726 var library = librarySPS.suggestLibraryForNewList(mediaListType,
734 throw(
"Could not find a library supporting lists of type " + mediaListType);
739 if (!library.userEditable ||
740 !library.userEditableContent) {
741 var libraryManager =
Cc[
"@songbirdnest.com/Songbird/library/Manager;1"]
742 .getService(
Ci.sbILibraryManager);
744 library = libraryManager.mainLibrary;
748 var name = librarySPS.suggestNameForNewPlaylist(library);
750 Cc[
"@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
751 .createInstance(
Ci.sbIMutablePropertyArray);
752 properties.appendProperty(SBProperties.mediaListName, name);
754 var mediaList = library.createMediaList(mediaListType, properties);
759 var node = librarySPS.getNodeForLibraryResource(mediaList);
762 for (let parent = node.parentNode; parent; parent = parent.parentNode)
764 parent.isOpen =
true;
768 servicePane.startEditingNode(node);
770 throw(
"Error: Couldn't find a service pane node for the list we just created\n");
775 var promptService =
Cc[
"@mozilla.org/embedcomp/prompt-service;1" ]
776 .getService(
Ci.nsIPromptService);
778 var input = {
value: mediaList.name};
779 var title =
SBString(
"newPlaylist.title",
"Create New Playlist");
780 var
prompt =
SBString(
"newPlaylist.prompt",
"Enter the name of the new playlist.");
782 if (promptService.prompt(
window, title, prompt, input,
null, {})) {
783 mediaList.name = input.value;
787 #ifdef METRICS_ENABLED
788 var metrics =
Cc[
"@songbirdnest.com/Songbird/Metrics;1"]
789 .createInstance(
Ci.sbIMetrics);
790 metrics.metricsInc(
"medialist",
"create", mediaListType);
800 function SBDeleteMediaList(aMediaList)
802 var mediaList = aMediaList;
804 mediaList = _SBGetCurrentView().mediaList;
809 mediaList.getProperty(SBProperties.outerGUID);
811 mediaList = mediaList.library.getMediaItem(outerListGuid);
815 var listType = mediaList.getProperty(SBProperties.customType);
816 if (mediaList.userEditable &&
817 listType !=
"download" &&
818 !(mediaList instanceof
Ci.sbILibrary)) {
819 const BYPASSKEY =
"playlist.deletewarning.bypass";
820 const STRINGROOT =
"playlist.deletewarning.";
822 var promptService =
Cc[
"@mozilla.org/embedcomp/prompt-service;1"]
823 .getService(
Ci.nsIPromptService);
826 var sbs =
Cc[
"@mozilla.org/intl/stringbundle;1"]
827 .getService(
Ci.nsIStringBundleService);
828 var songbirdStrings = sbs.createBundle(
"chrome://songbird/locale/songbird.properties");
829 var strTitle =
SBString(STRINGROOT +
"title");
832 var strCheck =
SBString(STRINGROOT +
"check");
834 var r = promptService.confirmEx(
window,
837 Ci.nsIPromptService.STD_YES_NO_BUTTONS,
843 if (check.value ==
true) {
852 mediaList.library.remove(mediaList);
854 Components.utils.reportError(
"SBDeleteMediaList - Medialist is not user editable");
858 function SBExtensionsManagerOpen( parentWindow )
860 if (!parentWindow) parentWindow =
window;
861 const EM_TYPE =
"Extension:Manager";
863 var wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
864 .getService(Components.interfaces.nsIWindowMediator);
865 var theEMWindow = wm.getMostRecentWindow(EM_TYPE);
871 const EM_URL =
"chrome://mozapps/content/extensions/extensions.xul?type=extensions";
872 const EM_FEATURES =
"chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
873 parentWindow.openDialog(EM_URL,
"", EM_FEATURES);
876 function SBTrackEditorOpen( initialTab, parentWindow ) {
880 if (typeof SBGetBrowser ==
'function')
881 browser = SBGetBrowser();
883 if (browser.currentMediaPage) {
884 var view = browser.currentMediaPage.mediaListView;
886 var numSelected = view.selection.count;
887 if (numSelected > 1) {
888 const BYPASSKEY =
"trackeditor.multiplewarning.bypass";
889 const STRINGROOT =
"trackeditor.multiplewarning.";
891 var promptService = Components.classes[
"@mozilla.org/embedcomp/prompt-service;1"]
892 .getService(Components.interfaces.nsIPromptService);
893 var check = {
value:
false };
895 var sbs = Components.classes[
"@mozilla.org/intl/stringbundle;1"]
896 .getService(Components.interfaces.nsIStringBundleService);
897 var songbirdStrings = sbs.createBundle(
"chrome://songbird/locale/songbird.properties");
898 var strTitle = songbirdStrings.GetStringFromName(STRINGROOT +
"title");
899 var strMsg = songbirdStrings.formatStringFromName(STRINGROOT +
"message", [numSelected], 1);
900 var strCheck = songbirdStrings.GetStringFromName(STRINGROOT +
"check");
902 var r = promptService.confirmEx(
window,
905 Ci.nsIPromptService.STD_YES_NO_BUTTONS,
911 if (check.value ==
true) {
918 }
else if (numSelected < 1) {
923 var isVideo = view.selection.currentMediaItem.getProperty(SBProperties.contentType) ==
"video";
924 SBOpenModalDialog((isVideo ?
"chrome://songbird/content/xul/trackEditorVideo.xul"
925 :
"chrome://songbird/content/xul/trackEditor.xul"),
926 "Songbird:TrackEditor",
"chrome,centerscreen",
927 initialTab, parentWindow);
933 function SBGetArtworkOpen() {
934 var browser = SBGetBrowser();
936 if (browser && browser.currentMediaPage) {
937 view = browser.currentMediaPage.mediaListView;
943 var artworkScanner =
Cc[
"@songbirdnest.com/Songbird/album-art/scanner;1"]
944 .createInstance(
Ci.sbIAlbumArtScanner);
945 artworkScanner.scanListForArtwork(view.mediaList);
946 SBJobUtils.showProgressDialog(artworkScanner,
window, 0);
949 function SBRevealFile( initialTab, parentWindow ) {
950 if (!parentWindow) parentWindow =
window;
952 var view = _SBGetCurrentView();
953 if (!view) {
return; }
955 var numSelected = view.selection.count;
956 if (numSelected != 1) {
return; }
959 var selection = view.selection.selectedIndexedMediaItems;
960 item = selection.getNext().QueryInterface(
Ci.sbIIndexedMediaItem).mediaItem;
963 Cu.reportError(
"Failed to get media item to reveal.")
967 var uri = item.contentSrc;
968 if (!uri || uri.scheme !=
"file") {
return; }
970 let f = uri.QueryInterface(
Ci.nsIFileURL).file;
973 f.QueryInterface(
Ci.nsILocalFile);
978 let parent = f.parent.QueryInterface(
Ci.nsILocalFile);
988 var parentUri =
Cc[
"@mozilla.org/network/io-service;1"]
989 .getService(
Ci.nsIIOService).newFileURI(parent);
991 var protocolSvc =
Cc[
"@mozilla.org/uriloader/external-protocol-service;1"]
992 .getService(
Ci.nsIExternalProtocolService);
993 protocolSvc.loadURI(parentUri);
998 function SBSubscribe(mediaList, defaultUrl, parentWindow)
1002 if (!(mediaList instanceof Components.interfaces.sbIMediaList))
1003 throw Components.results.NS_ERROR_INVALID_ARG;
1005 var isSubscription =
1006 mediaList.getProperty(
"http://songbirdnest.com/data/1.0#isSubscription");
1007 if (isSubscription !=
"1")
1008 throw Components.results.NS_ERROR_INVALID_ARG;
1011 if (defaultUrl && !(defaultUrl instanceof Components.interfaces.nsIURI))
1012 throw Components.results.NS_ERROR_INVALID_ARG;
1014 var params = Components.classes[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"]
1015 .createInstance(Components.interfaces.nsIMutableArray);
1016 params.appendElement(mediaList,
false);
1017 params.appendElement(defaultUrl,
false);
1020 SBOpenModalDialog(
"chrome://songbird/content/xul/subscribe.xul",
1022 "chrome,centerscreen",
1027 function SBNewPodcast()
1029 WindowUtils.openModalDialog
1031 "chrome://songbird/content/xul/podcast/podcastCreationDialog.xul",
1033 "chrome,centerscreen");
1037 function About( parentWindow )
1040 var about_data =
new Object();
1041 about_data.retval =
"";
1043 SBOpenModalDialog(
"chrome://songbird/content/xul/about.xul",
"about",
"chrome,centerscreen", about_data, parentWindow );
1044 if ( about_data.retval ==
"ok" )
1055 Components.classes[
"@mozilla.org/updates/update-manager;1"].
1056 getService(Components.interfaces.nsIUpdateManager);
1058 Components.classes[
"@mozilla.org/updates/update-prompt;1"].
1064 if (um.activeUpdate && um.activeUpdate.state ==
"pending")
1065 prompter.showUpdateDownloaded(um.activeUpdate);
1067 prompter.checkForUpdates();
1073 Components.classes[
"@mozilla.org/updates/update-service;1"].
1074 getService(Components.interfaces.nsIApplicationUpdateService);
1076 Components.classes[
"@mozilla.org/updates/update-manager;1"].
1077 getService(Components.interfaces.nsIUpdateManager);
1082 var canUpdate = updates.canUpdate;
1083 checkForUpdates.setAttribute(
"disabled", !canUpdate);
1087 var
strings = document.getElementById(
"songbird_strings");
1088 var activeUpdate = um.activeUpdate;
1092 function getStringWithUpdateName(
key) {
1093 if (activeUpdate && activeUpdate.name)
1094 return strings.getFormattedString(
key, [activeUpdate.name]);
1095 return strings.getString(
key +
"Fallback");
1099 var
key =
"default";
1101 switch (activeUpdate.state) {
1106 key = updates.isDownloading ?
"downloading" :
"resume";
1115 checkForUpdates.label = getStringWithUpdateName(
"updateCmd_" + key);
1118 function buildFileMenu() {
1119 var closeTabItem = document.getElementById(
"menuitem_file_closetab");
1122 if (gBrowser.mediaTab == gBrowser.selectedTab) {
1123 closeTabItem.setAttribute(
"disabled",
"true");
1125 closeTabItem.removeAttribute(
"disabled");
1129 function buildControlsMenu() {
1130 var equalizerControl = document.getElementById(
"menu_equalizer");
1131 var mm =
Cc[
"@songbirdnest.com/Songbird/Mediacore/Manager;1"]
1132 .getService(
Ci.sbIMediacoreManager);
1133 var equalizerEnabled =
false;
1138 if (!mm.primaryCore ||
1139 mm.primaryCore.QueryInterface(
Ci.sbIMediacoreMultibandEqualizer))
1141 equalizerEnabled =
true;
1148 if (!equalizerEnabled) {
1149 equalizerControl.setAttribute(
"disabled",
"true");
1151 equalizerControl.removeAttribute(
"disabled");
1155 function buildViewMenu() {
1159 var fullscreenItem = document.getElementById(
"menuitem-video-fullscreen");
1160 if(fullscreenItem) {
1161 fullscreenItem.setAttribute(
"checked", !disabled && fullscreen);
1162 fullscreenItem.setAttribute(
"disabled", disabled);
1165 var videoToFrontItem = document.getElementById(
"menuitem-video-to-front");
1166 if(videoToFrontItem) {
1167 videoToFrontItem.setAttribute(
"disabled", disabled);
1171 function javascriptConsole() {
1172 window.open(
"chrome://global/content/console.xul",
"global:console",
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar,titlebar");
1176 function isXPI(filename) {
1177 return /\.(xpi|jar)$/
i.test(filename);
1181 function installXPI(localFilename)
1183 var
inst = { xpi: localFilename };
1184 InstallTrigger.install( inst );
1190 function installXPIArray(aXPIArray)
1192 InstallTrigger.install(aXPIArray);
1201 function SBImportURLIntoMainLibrary(url) {
1202 var libraryManager = Components.classes[
"@songbirdnest.com/Songbird/library/Manager;1"]
1203 .getService(Components.interfaces.sbILibraryManager);
1205 var library = libraryManager.mainLibrary;
1207 if (url instanceof Components.interfaces.nsIURI) url = url.spec;
1211 var ioService = Components.classes[
"@mozilla.org/network/io-service;1"]
1212 .getService(Components.interfaces.nsIIOService);
1216 if( typeof(url.spec) ==
"undefined" ) {
1217 uri = ioService.newURI(url,
null,
null);
1238 mediaItem = library.createMediaItem(uri);
1249 var items = Components.classes[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"]
1250 .createInstance(Components.interfaces.nsIMutableArray);
1252 items.appendElement(mediaItem,
false);
1254 var metadataService =
1255 Components.classes[
"@songbirdnest.com/Songbird/FileMetadataService;1"]
1256 .getService(Components.interfaces.sbIFileMetadataService);
1257 var metadataJob = metadataService.read(items);
1262 function SBImportURLIntoWebLibrary(url) {
1264 var ioService = Components.classes[
"@mozilla.org/network/io-service;1"]
1265 .getService(Components.interfaces.nsIIOService);
1269 if( typeof(url.spec) ==
"undefined" ) {
1270 uri = ioService.newURI(url,
null,
null);
1285 var mediaItem =
null;
1287 mediaItem = library.createMediaItem(uri);
1298 var items = Components.classes[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"]
1299 .createInstance(Components.interfaces.nsIMutableArray);
1301 items.appendElement(mediaItem,
false);
1303 var metadataService =
1304 Components.classes[
"@songbirdnest.com/Songbird/FileMetadataService;1"]
1305 .getService(Components.interfaces.sbIFileMetadataService);
1306 var metadataJob = metadataService.read(items);
1316 onEnumerationBegin:
function() {
1318 onEnumeratedItem:
function(list, item) {
1320 return Components.interfaces.sbIMediaListEnumerationListener.CANCEL;
1322 onEnumerationEnd:
function() {
1326 aMediaList.enumerateItemsByProperty(aProperty,
1330 return listener.item;
1333 function toggleFullscreenVideo() {
1337 function bringVideoWindowToFront() {
1338 var wm =
Cc[
"@mozilla.org/appshell/window-mediator;1"]
1339 .getService(
Ci.nsIWindowMediator);
1341 var coreEnum = wm.getEnumerator(
"Songbird:Core");
1342 while(coreEnum.hasMoreElements()) {
1343 let win = coreEnum.getNext();
1344 if(win.document.documentElement.getAttribute(
"id") ==
"video_window") {
function checkForUpdates()
function getFirstItemByProperty(aMediaList, aProperty, aValue)
function SBFormattedString(aKey, aParams, aDefault, aStringBundle)
function getPlatformString()
Get the name of the platform we are running on.
function SBDataGetStringValue(aKey)
Get the value of the data in string format.
getService(Ci.sbIFaceplateManager)
function SBString(aKey, aDefault, aStringBundle)
function SBDataGetBoolValue(aKey)
Get the value of the data in boolean format.
function SBDataSetBoolValue(aKey, aBoolValue)
Set a boolean value. Changes the value of the data remote to the boolean passed in, regardless of its value before.
function newURI(aURLString)
Javascript wrappers for common library tasks.
function SBDataSetStringValue(aKey, aStringValue)
Set a string value. Changes the value of the data remote to the boolean passed in, regardless of its value before.
_getSelectedPageStyle s i