33 const Cc = Components.classes;
34 const Ci = Components.interfaces;
35 const Cr = Components.results;
36 const Ce = Components.Exception;
58 return this.
data[this.index++];
66 if (this.index < this.
data.length)
77 if (!iid.equals(
Ci.nsISimpleEnumerator) &&
78 !iid.equals(
Ci.nsIStringEnumerator) &&
79 !iid.equals(
Ci.nsISupports))
80 throw Components.results.NS_ERROR_NO_INTERFACE;
96 function FaceplatePane(aID,
aName, aBindingURL)
100 this._bindingURL = aBindingURL;
102 this._observers = [];
104 FaceplatePane.prototype = {
114 get id() {
return this._id; },
115 get name() {
return this._name; },
116 get bindingURL() {
return this._bindingURL; },
122 setData:
function FaceplatePane_setData(aKey,
aValue) {
124 throw Components.results.NS_ERROR_INVALID_ARG;
127 this._data[aKey] =
aValue;
131 getData:
function FaceplatePane_getData(aKey) {
132 return this._data[aKey];
135 getKeys:
function FaceplatePane_getKeys() {
140 addObserver:
function FaceplatePane_addObserver(aObserver) {
141 if (! (aObserver instanceof
Ci.nsIObserver)) {
142 throw Components.results.NS_ERROR_INVALID_ARG;
144 if (this._observers.indexOf(aObserver) == -1) {
145 this._observers.push(aObserver);
149 removeObserver:
function FaceplatePane_removeObserver(aObserver) {
150 var index = this._observers.indexOf(aObserver);
152 this._observers.splice(index,1);
156 _notify:
function FaceplatePane_notify(
topic) {
158 this._observers.forEach(
function (
observer) {
165 if (!iid.equals(Components.interfaces.sbIFaceplatePane) &&
166 !iid.equals(Components.interfaces.nsISupports))
167 throw Components.results.NS_ERROR_NO_INTERFACE;
182 function FaceplateManager() {
184 var
os = Components.classes[
"@mozilla.org/observer-service;1"]
185 .getService(Components.interfaces.nsIObserverService);
188 os.addObserver(
this,
'songbird-library-manager-ready',
false);
191 os.addObserver(
this,
"songbird-library-manager-before-shutdown",
false);
193 this._listeners = [];
197 FaceplateManager.prototype = {
207 _defaultPaneID:
null,
213 _init:
function init() {
216 var
strings =
Cc[
"@mozilla.org/intl/stringbundle;1"]
217 .getService(
Ci.nsIStringBundleService)
218 .createBundle(
"chrome://songbird/locale/songbird.properties");
219 var getString =
function(aStringId, aDefault) {
221 return strings.GetStringFromName(aStringId);
226 var introName = getString(
"faceplate.pane.intro.name",
"Intro");
227 var dashboardName = getString(
"faceplate.pane.dashboard.name",
"Dashboard");
235 "@songbirdnest.com/Songbird/DataRemote;1",
236 Components.interfaces.sbIDataRemote,
"init");
239 this._playbackDataRemote.bindObserver(
this,
true);
245 _deinit:
function deinit() {
246 this._listeners =
null;
248 if (this._playbackDataRemote) {
249 this._playbackDataRemote.unbind();
250 this._playbackDataRemote =
null;
260 return this._paneCount;
263 createPane:
function FaceplateManager_createPane(aID,
aName, aBindingURL) {
264 if (!aID || !
aName || !aBindingURL) {
265 throw Components.results.NS_ERROR_INVALID_ARG;
267 if (this._panes[aID]) {
268 throw Components.results.NS_ERROR_FAILURE;
271 var pane =
new FaceplatePane(aID,
aName, aBindingURL);
272 this._panes[aID] = pane;
278 this._onCreate(pane);
283 showPane:
function FaceplateManager_showPane(aPane) {
284 if (!aPane || !aPane.id || !
this._panes[aPane.id]) {
285 throw Components.results.NS_ERROR_INVALID_ARG;
287 this._defaultPaneID = aPane.id;
288 this._onShow(this._panes[aPane.id]);
291 destroyPane:
function FaceplateManager_destroyPane(aPane) {
292 if (!aPane || !aPane.id || !
this._panes[aPane.id]) {
293 throw Components.results.NS_ERROR_INVALID_ARG;
295 var pane = this._panes[aPane.id];
296 delete this._panes[pane.id];
298 this._onDestroy(pane);
301 getPane:
function FaceplateManager_getPane(aID) {
302 return this._panes[aID];
305 getPanes:
function FaceplateManager_getPanes() {
310 getDefaultPane:
function FaceplateManager_getDefaultPane() {
311 var pane = this.getPane(this._defaultPaneID);
313 pane = this.getPane(
"songbird-intro");
318 addListener:
function FaceplateManager_addListener(aListener) {
319 if (! (aListener instanceof
Ci.sbIFaceplateManagerListener)) {
320 throw Components.results.NS_ERROR_INVALID_ARG;
322 if (this._listeners.indexOf(aListener) == -1) {
323 this._listeners.push(aListener);
327 removeListener:
function FaceplateManager_removeListener(aListener) {
328 var index = this._listeners.indexOf(aListener);
330 this._listeners.splice(index,1);
338 _onCreate:
function FaceplateManager__onCreate(aFaceplatePane) {
339 aFaceplatePane = aFaceplatePane.QueryInterface(
Ci.sbIFaceplatePane);
340 this._listeners.forEach(
function (
listener) {
341 listener.onCreatePane(aFaceplatePane);
348 _onShow:
function FaceplateManager__onShow(aFaceplatePane) {
349 aFaceplatePane = aFaceplatePane.QueryInterface(
Ci.sbIFaceplatePane);
350 this._listeners.forEach(
function (
listener) {
351 listener.onShowPane(aFaceplatePane);
358 _onDestroy:
function FaceplateManager__onDestroy(aFaceplatePane) {
359 aFaceplatePane = aFaceplatePane.QueryInterface(
Ci.sbIFaceplatePane);
360 this._listeners.forEach(
function (
listener) {
361 listener.onDestroyPane(aFaceplatePane);
371 _showDashboardPane:
function FaceplateManager__showDashboardPane() {
372 var pane = this.getPane(
"songbird-dashboard");
376 dump(
"FaceplateManager__showDashboardPane: dashboard not found\n");
385 var os = Components.classes[
"@mozilla.org/observer-service;1"]
386 .getService(Components.interfaces.nsIObserverService);
389 case "songbird-library-manager-ready":
390 os.removeObserver(
this,
"songbird-library-manager-ready");
393 case "songbird-library-manager-before-shutdown":
394 os.removeObserver(
this,
"songbird-library-manager-before-shutdown");
400 if (this._playbackDataRemote.boolValue) {
401 this._playbackDataRemote.unbind();
402 this._playbackDataRemote =
null;
403 this._showDashboardPane();
412 if (!iid.equals(Components.interfaces.sbIFaceplateManager) &&
413 !iid.equals(Components.interfaces.nsIObserver) &&
414 !iid.equals(Components.interfaces.nsISupports))
415 throw Components.results.NS_ERROR_NO_INTERFACE;
429 return function (comMgr, fileSpec) {
431 registerSelf :
function (compMgr, fileSpec, location, type) {
432 compMgr.QueryInterface(
Ci.nsIComponentRegistrar);
433 compMgr.registerFactoryLocation(
CID,
439 if (CATEGORIES && CATEGORIES.length) {
440 var catman =
Cc[
"@mozilla.org/categorymanager;1"]
441 .getService(
Ci.nsICategoryManager);
442 for (var
i=0;
i<CATEGORIES.length;
i++) {
443 var e = CATEGORIES[
i];
444 catman.addCategoryEntry(e.category, e.entry, e.value,
451 if (!cid.equals(
CID)) {
452 throw Cr.NS_ERROR_NO_INTERFACE;
455 if (!iid.equals(
Ci.nsIFactory)) {
456 throw Cr.NS_ERROR_NOT_IMPLEMENTED;
459 return this._factory;
465 throw Cr.NS_ERROR_NO_AGGREGATION;
471 unregisterSelf :
function (compMgr, location, type) {
472 compMgr.QueryInterface(
Ci.nsIComponentRegistrar);
473 compMgr.unregisterFactoryLocation(
CID, location);
474 if (CATEGORIES && CATEGORIES.length) {
475 var catman =
Cc[
"@mozilla.org/categorymanager;1"]
476 .getService(
Ci.nsICategoryManager);
477 for (var
i=0;
i<CATEGORIES.length;
i++) {
478 var e = CATEGORIES[
i];
479 catman.deleteCategoryEntry(e.category, e.entry,
true);
484 canUnload :
function (compMgr) {
489 if ( !iid.equals(
Ci.nsIModule) ||
490 !iid.equals(
Ci.nsISupports) )
491 throw Cr.NS_ERROR_NO_INTERFACE;
501 Components.ID(
"{eb5c665a-bfe2-49f0-a747-cd3554e55606}"),
502 "Songbird Faceplate Pane Manager Service",
503 "@songbirdnest.com/faceplate/manager;1",
505 category:
'app-startup',
506 entry:
'faceplate-pane-manager',
507 value:
'service,@songbirdnest.com/faceplate/manager;1'
const DATAREMOTE_PLAYBACK
function ArrayEnumerator(array)
const URL_BINDING_DASHBOARD_PANE
prefs removeObserver(PREF_SELECTED_ACTION, this)
SafebrowsingApplicationMod prototype registerSelf
Wraps a js array in an nsISimpleEnumerator.
sbOSDControlService prototype QueryInterface
SafebrowsingApplicationMod prototype getClassObject
const URL_BINDING_DEFAULT_PANE
DataRemote prototype constructor
historySvc addObserver(this, false)
SimpleArrayEnumerator prototype hasMoreElements
StringArrayEnumerator prototype hasMore
function makeGetModule(CONSTRUCTOR, CID, CLASSNAME, CONTRACTID, CATEGORIES)
XPCOM initialization code.
_getSelectedPageStyle s i
sbDeviceFirmwareAutoCheckForUpdate prototype observe