ngDefaultPresetProvider.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN NIGHTINGALE GPL
4 //
5 // This file is part of the Nightingale web player.
6 //
7 // http://getnightingale.com
8 //
9 // This file may be licensed under the terms of of the
10 // GNU General Public License Version 2 (the "GPL").
11 //
12 // Software distributed under the License is distributed
13 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
14 // express or implied. See the GPL for the specific language
15 // governing rights and limitations.
16 //
17 // You should have received a copy of the GPL along with this
18 // program. If not, go to http://www.gnu.org/licenses/gpl.html
19 // or write to the Free Software Foundation, Inc.,
20 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 //
22 // END NIGHTINGALE GPL
23 //
24 */
25 
26 "use strict";
27 
28 const Cc = Components.classes;
29 const Cu = Components.utils;
30 const Ci = Components.interfaces;
31 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
32 Cu.import("resource://app/jsmodules/ArrayConverter.jsm");
33 Cu.import("resource://app/jsmodules/DebugUtils.jsm");
34 
35 const LOG = DebugUtils.generateLogFunction("ngDefaultPresetProvider", 2);
36 
44  LOG("Constructing");
45 
46  var stringBundle = Cc["@mozilla.org/intl/stringbundle;1"]
47  .getService(Ci.nsIStringBundleService)
48  .createBundle("chrome://songbird/locale/songbird.properties");
49  this._presets = [];
50 
51  this._presets.push(this._createPreset("songbird.eq.currentPreset", stringBundle, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
52  this._presets.push(this._createPreset("equalizer.preset.classical", stringBundle, [0, 0, 0, 0, 0, 0, -0.2, -0.2, -0.2, -0.4]));
53  this._presets.push(this._createPreset("equalizer.preset.club", stringBundle, [0, 0, 0.15, 0.2, 0.2, 0.2, 0.15, 0, 0, 0]));
54  this._presets.push(this._createPreset("equalizer.preset.dance", stringBundle, [0.5, 0.25, 0.05, 0, 0, -0.2, -0.3, -0.3, 0, 0]));
55  this._presets.push(this._createPreset("equalizer.preset.full_bass", stringBundle, [0.4, 0.4, 0.4, 0.2, 0, -0.2, -0.3, -0.35, -0.4, -0.4]));
56  this._presets.push(this._createPreset("equalizer.preset.full_treble", stringBundle, [-0.4, -0.4, -0.4, -0.15, 0.1, 0.4, 0.8, 0.8, 0.8, 0.8]));
57  this._presets.push(this._createPreset("equalizer.preset.small_speakers", stringBundle, [0.2, 0.4, 0.2, -0.2, -0.15, 0, 0.2, 0.4, 0.6, 0.7]));
58  this._presets.push(this._createPreset("equalizer.preset.large_hall", stringBundle, [0.45, 0.45, 0.2, 0.2, 0, -0.2, -0.2, -0.2, 0, 0]));
59  this._presets.push(this._createPreset("equalizer.preset.live", stringBundle, [-0.2, 0, 0.15, 0.2, 0.2, 0.2, 0.1, 0.05, 0.05, 0]));
60  this._presets.push(this._createPreset("equalizer.preset.party", stringBundle, [0.25, 0.25, 0, 0, 0, 0, 0, 0, 0.25, 0.25]));
61  this._presets.push(this._createPreset("equalizer.preset.pop", stringBundle, [-0.15, 0.15, 0.2, 0.25, 0.15, -0.15, -0.15, -0.15, -0.1, -0.1]));
62  this._presets.push(this._createPreset("equalizer.preset.reggae", stringBundle, [0, 0, -0.1, -0.2, 0, 0.2, 0.2, 0, 0, 0]));
63  this._presets.push(this._createPreset("equalizer.preset.rock", stringBundle, [0.3, 0.15, -0.2, -0.3, -0.1, 0.15, 0.3, 0.35, 0.35, 0.35]));
64  this._presets.push(this._createPreset("equalizer.preset.ska", stringBundle, [-0.1, -0.15, -0.12, -0.05, 0.15, 0.2, 0.3, 0.3, 0.4, 0.3]));
65  this._presets.push(this._createPreset("equalizer.preset.soft", stringBundle, [0.2, 0, -0.1, -0.15, -0.1, 0.2, 0.3, 0.35, 0.4, 0.5]));
66  this._presets.push(this._createPreset("equalizer.preset.soft_rock", stringBundle, [0.2, 0.2, 0, -0.1, -0.2, -0.3, -0.2, -0.1, 0.2, 0.4]));
67  this._presets.push(this._createPreset("equalizer.preset.techno", stringBundle, [0.3, 0.25, 0, -0.25, -0.2, 0, 0.3, 0.35, 0.35, 0.3]));
68 }
69 
71  classDescription: "Preset provider that provides the default equalizer presets",
72  classID: Components.ID("{1f3b39da-c169-49df-af70-eaec9c10640a}"),
73  contractID: "@getnightingale.com/equalizer-presets/defaults;1",
74  QueryInterface: XPCOMUtils.generateQI([Ci.ngIEqualizerPresetProvider]),
75 
76  _presets: null,
77 
78  _createPreset: function(property, strBundle, values) {
79  LOG("_createPreset("+property+", "+strBundle+", "+values+")");
80  var preset = Cc["@getnightingale.com/equalizer-presets/localizable;1"]
81  .createInstance(Ci.ngILocalizableEqualizerPreset);
82  preset.stringBundle = strBundle;
83  preset.property = property;
84  preset.setValues(ArrayConverter.nsIArray(
85  this._makeArraySupportDouble(values)));
86 
87  return preset;
88  },
89  _makeArraySupportDouble: function(array) {
90  return array.map(function(item) {
91  var double = Cc["@mozilla.org/supports-double;1"]
92  .createInstance(Ci.nsISupportsDouble);
93  double.data = item;
94  return double;
95  });
96  },
97 
98  get presets() {
99  LOG("presets");
100  if(this._presets)
101  return ArrayConverter.nsIArray(this._presets);
102  else
103  throw Components.results.NS_ERROR_UNEXPECTED;
104  }
105 };
106 
107 var NSGetModule = XPCOMUtils.generateNSGetModule([ngDefaultPresetProvider]);
inArray array
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function ngDefaultPresetProvider()
return null
Definition: FeedWriter.js:1143
sbDeviceFirmwareAutoCheckForUpdate prototype classID