diff --git a/xulmus/content/config.js b/xulmus/content/config.js index f4a2d06e..48b90fad 100644 --- a/xulmus/content/config.js +++ b/xulmus/content/config.js @@ -1,4 +1,6 @@ -// Copyright (c) 2006-2009 by Martin Stubenschrott +// Copyright (c) 2009 by Martin Stubenschrott +// Copyright (c) 2009 by Prathyush Thota +// Copyright (c) 2009 by Doug Kearns // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -195,7 +197,7 @@ const Config = Module("config", ConfigBase, { this.showServicePane(true); else { let pane = document.getElementById(id); - let manager = Cc['@songbirdnest.com/Songbird/DisplayPane/Manager;1'].getService(Ci.sbIDisplayPaneManager); + let manager = services.get("displayPaneManager"); let paneinfo = manager.getPaneInfo(pane._lastURL.stringValue); if (!paneinfo) @@ -300,6 +302,11 @@ const Config = Module("config", ConfigBase, { }, getter: function () !services.get("io").offline }); + }, + services: function () { + services.addClass("mutablePropertyArray", "@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1", + Ci.sbIMutablePropertyArray); + services.add("displayPaneManager", "@songbirdnest.com/Songbird/DisplayPane/Manager;1", Ci.sbIDisplayPaneManager); } }); diff --git a/xulmus/content/library.js b/xulmus/content/library.js index 9b633bdb..a71f539d 100644 --- a/xulmus/content/library.js +++ b/xulmus/content/library.js @@ -1,4 +1,5 @@ // Copyright (c) 2009 by Prathyush Thota +// Copyright (c) 2009 by Doug Kearns // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -9,7 +10,7 @@ const Library = Module("library", { this.MAIN_LIBRARY = LibraryUtils.mainLibrary; }, - _toJSArray: function (enum) ArrayConverter.JSArray(enum), + _toJSArray: function _toJSArray(enum) ArrayConverter.JSArray(enum), // TODO: return some actually useful objects. ;-) /** @@ -42,8 +43,7 @@ const Library = Module("library", { * @returns {string[]} */ getTracks: function getTracks(artist, album) { - const properties = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"] - .createInstance(Ci.sbIMutablePropertyArray); + let properties = services.create("mutablePropertyArray"); properties.appendProperty(SBProperties.artistName, artist); properties.appendProperty(SBProperties.albumName, album); diff --git a/xulmus/content/player.js b/xulmus/content/player.js index ab297339..5e7cefdb 100644 --- a/xulmus/content/player.js +++ b/xulmus/content/player.js @@ -1,11 +1,12 @@ // Copyright (c) 2009 by Prathyush Thota +// Copyright (c) 2009 by Doug Kearns // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. const Player = Module("player", { - init: function () { + init: function init() { this._lastSearchString = ""; this._lastSearchIndex = 0; this._lastSearchView = _SBGetCurrentView(); @@ -15,17 +16,17 @@ const Player = Module("player", { gMM.addListener(this._mediaCoreListener); }, - destroy: function () { + destroy: function destroy() { gMM.removeListener(this._mediaCoreListener); }, // interval (milliseconds) - _seek: function (interval, direction) { + _seek: function _seek(interval, direction) { let position = gMM.playbackControl ? gMM.playbackControl.position : 0; player.seekTo(position + (direction ? interval : -interval)); }, - _focusTrack: function (mediaItem) { + _focusTrack: function _focusTrack(mediaItem) { SBGetBrowser().mediaTab.mediaPage.highlightItem(_SBGetCurrentView().getIndexForItem(mediaItem)); }, @@ -184,7 +185,7 @@ const Player = Module("player", { gMM.volumeControl.volume = gMM.volumeControl.volume * 0.9; }, - focusPlayingTrack :function focusPlayingTrack() { + focusPlayingTrack: function focusPlayingTrack() { this._focusTrack(gMM.sequencer.currentItem); }, @@ -264,7 +265,7 @@ const Player = Module("player", { * * @param {string} str The contents of the search dialog. */ - onSearchKeyPress: function (str) { + onSearchKeyPress: function onSearchKeyPress(str) { if (options["incsearch"]) this.searchView(str); }, @@ -274,14 +275,14 @@ const Player = Module("player", { * * @param {string} str The contents of the search dialog. */ - onSearchSubmit: function (str) { + onSearchSubmit: function onSearchSubmit(str) { this.searchView(str); }, /** * The search dialog cancel callback. */ - onSearchCancel: function () { + onSearchCancel: function onSearchCancel() { // TODO: restore the view state if altered by an 'incsearch' search }, @@ -343,26 +344,25 @@ const Player = Module("player", { }, sortBy: function sortBy(property, order) { - let pa = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"].createInstance(Ci.sbIMutablePropertyArray); - liberator.dump("Property: " + property); + let properties = services.create("mutablePropertyArray"); switch (property.string) { case "#": case "Title": - pa.appendProperty(SBProperties.trackName, "a"); + properties.appendProperty(SBProperties.trackName, "a"); break; case "Rating": - pa.appendProperty(SBProperties.rating, 1); + properties.appendProperty(SBProperties.rating, 1); break; case "Album": - pa.appendProperty(SBProperties.albumName, "a"); + properties.appendProperty(SBProperties.albumName, "a"); break; default: - pa.appendProperty(SBProperties.trackName, "a"); + properties.appendProperty(SBProperties.trackName, "a"); break; } - _SBGetCurrentView().setSort(pa); + _SBGetCurrentView().setSort(properties); } }, { }, { @@ -518,23 +518,22 @@ const Player = Module("player", { // let prev_view = gMM.status.view; let library = LibraryUtils.mainLibrary; let mainView = library.createView(); - let customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"] - .createInstance(Ci.sbIMutablePropertyArray); + let properties = services.create("mutablePropertyArray"); // args switch (args.length) { case 3: - customProps.appendProperty(SBProperties.trackName, args[2]); + properties.appendProperty(SBProperties.trackName, args[2]); case 2: - customProps.appendProperty(SBProperties.albumName, args[1]); + properties.appendProperty(SBProperties.albumName, args[1]); case 1: - customProps.appendProperty(SBProperties.artistName, args[0]); + properties.appendProperty(SBProperties.artistName, args[0]); break; default: break; } - gMM.sequencer.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(customProps).queryElementAt(0, Ci.sbIMediaItem))); + gMM.sequencer.playView(mainView, mainView.getIndexForItem(library.getItemsByProperties(properties).queryElementAt(0, Ci.sbIMediaItem))); player.focusPlayingTrack(); }, {