home *** CD-ROM | disk | FTP | other *** search
/ Freelog 112 / FreelogNo112-NovembreDecembre2012.iso / Multimedia / Songbird / Songbird_2.0.0-2311_windows-i686-msvc8.exe / jsmodules / sbProperties.jsm < prev    next >
Text File  |  2012-06-08  |  11KB  |  204 lines

  1. /*
  2. //
  3. // BEGIN SONGBIRD GPL
  4. //
  5. // This file is part of the Songbird web player.
  6. //
  7. // Copyright(c) 2005-2008 POTI, Inc.
  8. // http://songbirdnest.com
  9. //
  10. // This file may be licensed under the terms of of the
  11. // GNU General Public License Version 2 (the "GPL").
  12. //
  13. // Software distributed under the License is distributed
  14. // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
  15. // express or implied. See the GPL for the specific language
  16. // governing rights and limitations.
  17. //
  18. // You should have received a copy of the GPL along with this
  19. // program. If not, go to http://www.gnu.org/licenses/gpl.html
  20. // or write to the Free Software Foundation, Inc.,
  21. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. //
  23. // END SONGBIRD GPL
  24. //
  25. */
  26.  
  27. /**
  28.  * Property constants for use with the Songbird property system. Import into a
  29.  * JS file or component using:
  30.  *
  31.  *   'Components.utils.import("resource://app/jsmodules/sbProperties.jsm");'
  32.  *
  33.  */
  34.  
  35. EXPORTED_SYMBOLS = ["SBProperties"];
  36.  
  37. var SBProperties = {
  38.  
  39.   _base: "http://songbirdnest.com/data/1.0#",
  40.  
  41.   get base() { return this._base; },
  42.  
  43.   get storageGUID             () { return this._base + "storageGUID"; },
  44.   get created                 () { return this._base + "created"; },
  45.   get updated                 () { return this._base + "updated"; },
  46.   get contentURL              () { return this._base + "contentURL"; },
  47.   get contentType             () { return this._base + "contentType"; },
  48.   get contentLength           () { return this._base + "contentLength"; },
  49.   get hash                    () { return this._base + "hash"; },
  50.   get metadataHashIdentity    () { return this._base + "metadataHashIdentity"; },
  51.   get trackName               () { return this._base + "trackName"; },
  52.   get albumName               () { return this._base + "albumName"; },
  53.   get artistName              () { return this._base + "artistName"; },
  54.   get trackType               () { return this._base + "trackType"; },
  55.   get duration                () { return this._base + "duration"; },
  56.   get genre                   () { return this._base + "genre"; },
  57.   get trackNumber             () { return this._base + "trackNumber"; },
  58.   get year                    () { return this._base + "year"; },
  59.   get discNumber              () { return this._base + "discNumber"; },
  60.   get totalDiscs              () { return this._base + "totalDiscs"; },
  61.   get totalTracks             () { return this._base + "totalTracks"; },
  62.   get isPartOfCompilation     () { return this._base + "isPartOfCompilation"; },
  63.   get producerName            () { return this._base + "producerName"; },
  64.   get composerName            () { return this._base + "composerName"; },
  65.   get conductorName           () { return this._base + "conductorName"; },
  66.   get lyricistName            () { return this._base + "lyricistName"; },
  67.   get lyrics                  () { return this._base + "lyrics"; },
  68.   get recordLabelName         () { return this._base + "recordLabelName"; },
  69.   get primaryImageURL         () { return this._base + "primaryImageURL"; },
  70.   get lastPlayTime            () { return this._base + "lastPlayTime"; },
  71.   get playCount               () { return this._base + "playCount"; },
  72.   get lastPlayPosition        () { return this._base + "lastPlayPosition"; },
  73.   get lastSkipTime            () { return this._base + "lastSkipTime"; },
  74.   get skipCount               () { return this._base + "skipCount"; },
  75.   get rating                  () { return this._base + "rating"; },
  76.   get bitRate                 () { return this._base + "bitRate"; },
  77.   get channels                () { return this._base + "channels"; },
  78.   get sampleRate              () { return this._base + "sampleRate"; },
  79.   get bpm                     () { return this._base + "bpm"; },
  80.   get key                     () { return this._base + "key"; },
  81.   get language                () { return this._base + "language"; },
  82.   get comment                 () { return this._base + "comment"; },
  83.   get copyright               () { return this._base + "copyright"; },
  84.   get copyrightURL            () { return this._base + "copyrightURL"; },
  85.   get subtitle                () { return this._base + "subtitle"; },
  86.   get metadataUUID            () { return this._base + "metadataUUID"; },
  87.   get softwareVendor          () { return this._base + "softwareVendor"; },
  88.   get originURL               () { return this._base + "originURL"; },
  89.   get originPage              () { return this._base + "originPage"; },
  90.   get originPageImage         () { return this._base + "originPageImage"; },
  91.   get originPageTitle         () { return this._base + "originPageTitle"; },
  92.   get originLibraryGuid       () { return this._base + "originLibraryGuid"; },
  93.   get originItemGuid          () { return this._base + "originItemGuid"; },
  94.   get GUID                    () { return this._base + "GUID"; },
  95.   get hidden                  () { return this._base + "hidden"; },
  96.   get isList                  () { return this._base + "isList"; },
  97.   get listType                () { return this._base + "listType"; },
  98.   get isReadOnly              () { return this._base + "isReadOnly"; },
  99.   get isContentReadOnly       () { return this._base + "isContentReadOnly"; },
  100.   get ordinal                 () { return this._base + "ordinal"; },
  101.   get mediaListName           () { return this._base + "mediaListName"; },
  102.   get columnSpec              () { return this._base + "columnSpec"; },
  103.   get defaultColumnSpec       () { return this._base + "defaultColumnSpec"; },
  104.   get customType              () { return this._base + "customType"; },
  105.   get destination             () { return this._base + "destination"; },
  106.   get downloadButton          () { return this._base + "downloadButton"; },
  107.   get downloadStatusTarget    () { return this._base + "downloadStatusTarget"; },
  108.   get downloadDetails         () { return this._base + "downloadDetails"; },
  109.   get isSortable              () { return this._base + "isSortable"; },
  110.   get rapiScopeURL            () { return this._base + "rapiScopeURL"; },
  111.   get rapiSiteID              () { return this._base + "rapiSiteID"; },
  112.   get enableAutoDownload      () { return this._base + "enableAutoDownload"; },
  113.   get transferPolicy          () { return this._base + "transferPolicy"; },
  114.   get defaultMediaPageURL     () { return this._base + "defaultMediaPageURL"; },
  115.   get onlyCustomMediaPages    () { return this._base + "onlyCustomMediaPages"; },
  116.   get availability            () { return this._base + "availability"; },
  117.   get albumArtistName         () { return this._base + "albumArtistName"; },
  118.   get outerGUID               () { return this._base + "outerGUID"; },
  119.   get albumDetailImage        () { return this._base + "albumDetailImage"; },
  120.   get artistDetailImage       () { return this._base + "artistDetailImage"; },
  121.   get albumDetailUrl          () { return this._base + "albumDetailUrl"; },
  122.   get artistDetailUrl         () { return this._base + "artistDetailUrl"; },
  123.   get excludeFromHistory      () { return this._base + "excludeFromHistory"; },
  124.   get disableDownload         () { return this._base + "disableDownload"; },
  125.   get isSubscription          () { return this._base + "isSubscription"; },
  126.   get cdRipStatus             () { return this._base + "cdRipStatus"; },
  127.   get cdDiscHash              () { return this._base + "cdDiscHash"; },
  128.   get shouldRip               () { return this._base + "shouldRip"; },
  129.   get isDRMProtected          () { return this._base + "isDRMProtected"; },
  130.   get dontWriteMetadata       () { return this._base + "dontWriteMetadata"; },
  131.   get importType              () { return this._base + "importType"; },
  132.   get deviceId                () { return this._base + "deviceId"; },
  133.   get playCount_AtLastSync    () { return this._base + "playCount_AtLastSync"; },
  134.   get skipCount_AtLastSync    () { return this._base + "skipCount_AtLastSync"; },
  135.   get lastSyncTime            () { return this._base + "lastSyncTime"; },
  136.   get originIsInMainLibrary   () { return this._base + "originIsInMainLibrary"; },
  137.   get smartMediaListState     () { return this._base + "smartMediaListState"; },
  138.   get createdFirstRunSmartPlaylists() { return this._base + "createdFirstRunSmartPlaylists"; },
  139.   get downloadMediaListGUID   () { return this._base + "downloadMediaListGUID"; },
  140.   get playQueueMediaListGUID  () { return this._base + "playQueueMediaListGUID"; },
  141.   get deviceLibraryGuid       () { return this._base + "deviceLibraryGuid"; },
  142.   get iTunesGUID              () { return this._base + "iTunesGUID"; },
  143.   get keywords                () { return this._base + "keywords"; },
  144.   get description             () { return this._base + "description"; },
  145.   get showName                () { return this._base + "showName"; },
  146.   get episodeNumber           () { return this._base + "episodeNumber"; },
  147.   get seasonNumber            () { return this._base + "seasonNumber"; },
  148.   get playlistURL             () { return this._base + "playlistURL"; },
  149.   get attemptedRemoteArtFetch () { return this._base + "attemptedRemoteArtFetch"; },
  150.  
  151.   /**
  152.    * Create a property array from a js object such as [[id,value], ..] or {id:value}.
  153.    * Pass strict=true to ensure that all property values are valid.
  154.    */
  155.   createArray: function(properties, strict) {
  156.     var propertyArray =
  157.       Components.classes["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
  158.                 .createInstance(Components.interfaces.sbIMutablePropertyArray);
  159.     if (arguments.length > 1) {
  160.       propertyArray.strict = arguments[1];
  161.     }
  162.     if (properties) {
  163.       this.addToArray(properties, propertyArray);
  164.     }
  165.     return propertyArray;
  166.   },
  167.   
  168.   /**
  169.    * Add properties (as [[id,value], ..] or {id:value})
  170.    * to the given property array
  171.    */
  172.   addToArray: function(properties, propertyArray) {
  173.     if (properties) {
  174.       // If properties are passed as an array, assume [[id,value], ..]
  175.       if (properties.length !== undefined) {
  176.         properties.forEach(function(e) {
  177.           if (e.length == 2) {
  178.             propertyArray.appendProperty(e[0], e[1]);
  179.           }
  180.         });
  181.       // Otherwise assume an object with {id:value}
  182.       } else {
  183.         for (var prop in properties) {
  184.           propertyArray.appendProperty(prop, properties[prop]);
  185.         }
  186.       }
  187.     }
  188.   },
  189.   
  190.   /**
  191.    * Convert the given property array into a javascript map like {id:value}
  192.    */
  193.   arrayToJSObject: function(propArray) {
  194.     var enumerator = propArray.enumerate();
  195.     var property;
  196.     var propMap = {};
  197.     while (enumerator.hasMoreElements()) {
  198.       property = enumerator.getNext().QueryInterface(Components.interfaces.sbIProperty);
  199.       propMap[property.id] = property.value;
  200.     }
  201.     return propMap;
  202.   }
  203. }
  204.