sbSmartPlaylistPropertyRegistrar.js
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2010 POTI, Inc.
7  * http://www.songbirdnest.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 SONGBIRD GPL
23  */
24 
25 const Cc = Components.classes;
26 const Ci = Components.interfaces;
27 const Cr = Components.results;
28 const Ce = Components.Exception;
29 
30 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
31 Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
32 Components.utils.import("resource://app/jsmodules/ArrayConverter.jsm");
33 
35  this._maps = {};
36 
37  var context = "default";
38 
39  // it'd be nice to have currying as a generic operation
40  function register(id, width, direction)
41  {
42  this.registerPropertyToContext(context, SBProperties[id], width, direction);
43  }
44 
45  var props = [
46  ["albumName", 220, "a"],
47  ["albumArtistName", 220, "a"],
48  ["artistName", 220, "a"],
49  ["bitRate", 40, "d"],
50  ["bpm", 40, "d"],
51  ["comment", 120, "a"],
52  ["composerName", 150, "a"],
53  ["created", 122, "d"],
54  ["updated", 122, "d"],
55  ["discNumber", 40, "d"],
56  ["contentURL", 220, "a"],
57  ["genre", 70, "a"],
58  ["lastPlayTime", 122, "d"],
59  ["lastSkipTime", 122, "d"],
60  ["playCount", 40, "d"],
61  ["rating", 85, "d"],
62  ["sampleRate", 75, "d"],
63  ["contentLength", 50, "d"],
64  ["skipCount", 40, "d"],
65  ["originURL", 220, "a"],
66  ["originPage", 220, "a"],
67  ["originPageTitle", 150, "a"],
68  ["duration", 55, "d"],
69  ["trackName", 220, "a"],
70  ["trackNumber", 40, "d"],
71  ["year", 50, "d"],
72  ["keywords", 220, "a"],
73  ["description", 220, "a"],
74  ["showName", 220, "a"],
75  ["episodeNumber", 40, "a"],
76  ["seasonNumber", 40, "a"],
77  ["contentType", 40, "a"],
78  ];
79 
80  for each (p in props)
81  {
82  register.apply(this, p);
83  }
84 
85  this.registerPropertyToContext(context,
86  "http://songbirdnest.com/dummy/smartmedialists/1.0#playlist",
87  0,
88  "");
89 }
90 
93  classDescription: "Songbird SmartPlaylist Property Registrar Interface",
94  classID : Components.ID("{4b6a6c23-e247-419e-b629-3c2ef5f5876d}"),
95  contractID : "@songbirdnest.com/Songbird/SmartPlaylistPropertyRegistrar;1",
96 
101  getPropertiesForContext: function
102  SmartPlaylistPropertyRegistrar_getPropertyForContext(aContextID) {
103  return ArrayConverter.enumerator(this._maps[aContextID]);
104  },
105 
109  registerPropertyToContext: function
110  SmartPlaylistPropertyRegistrar_registerPropertyToContext(aContextID,
111  aPropertyID,
112  aColWidth,
113  aSortDir) {
114  if (!(aContextID in this._maps)) {
115  this._maps[aContextID] = [];
116  }
117  var smartPlaylistProperty = {
118  propertyID : aPropertyID,
119  defaultColumnWidth : aColWidth,
120  defaultSortDirection : aSortDir,
121  QueryInterface : XPCOMUtils.generateQI([Ci.sbISmartPlaylistProperty])
122  };
123  this._maps[aContextID].push(smartPlaylistProperty);
124  },
125 
130  XPCOMUtils.generateQI([Ci.sbISmartPlaylistPropertyRegistrar])
131 }; // SmartPlaylistPropertyRegistrar.prototype
132 
133 function postRegister(aCompMgr, aFileSpec, aLocation) {
134  XPCOMUtils.categoryManager
135  .addCategoryEntry('app-startup',
136  'smartplaylist-property-registrar',
137  'service,@songbirdnest.com/Songbird/SmartPlaylistPropertyRegistrar;1',
138  true,
139  true);
140 }
141 
143  XPCOMUtils.generateNSGetModule([SmartPlaylistPropertyRegistrar],
144  postRegister);
145 
menuItem id
Definition: FeedWriter.js:971
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function width(ele) rect(ele).width
function postRegister(aCompMgr, aFileSpec, aLocation)
DataRemote prototype constructor
function SmartPlaylistPropertyRegistrar()
sbDeviceFirmwareAutoCheckForUpdate prototype classID