home *** CD-ROM | disk | FTP | other *** search
/ Freelog 112 / FreelogNo112-NovembreDecembre2012.iso / Multimedia / Songbird / Songbird_2.0.0-2311_windows-i686-msvc8.exe / components / sbHotkeyActions.js < prev    next >
Text File  |  2012-06-08  |  3KB  |  92 lines

  1. /*
  2.  *=BEGIN SONGBIRD GPL
  3.  *
  4.  * This file is part of the Songbird web player.
  5.  *
  6.  * Copyright(c) 2005-2009 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 Cu = Components.utils;
  28. const Cr = Components.results;
  29.  
  30. Cu.import("resource://gre/modules/XPCOMUtils.jsm");
  31.  
  32. const SONGBIRD_HOTKEYACTIONS_CONTRACTID = "@songbirdnest.com/Songbird/HotkeyActions;1";
  33. const SONGBIRD_HOTKEYACTIONS_CLASSNAME = "Songbird Hotkey Actions Service Interface";
  34. const SONGBIRD_HOTKEYACTIONS_CID = Components.ID("{0BB80965-77C8-4212-866C-F22677F75A2C}");
  35.  
  36. function HotkeyActions() {
  37.   this._bundles = new Array();
  38.   Cc["@mozilla.org/observer-service;1"]
  39.     .getService(Ci.nsIObserverService)
  40.     .addObserver(this, "quit-application", true);
  41. }
  42.  
  43. HotkeyActions.prototype = {
  44.   
  45.   registerHotkeyActionBundle: function (bundle) {
  46.     this._bundles.push(bundle);
  47.   },
  48.   
  49.   unregisterHotkeyActionBundle: function (bundle) {
  50.     var idx = this._bundles.indexOf(bundle);
  51.     while (idx != -1) {
  52.       this._bundles.splice(idx, 1);
  53.       idx = this._bundles.indexOf(bundle, idx);
  54.     }
  55.   },
  56.   
  57.   get bundleCount () {
  58.     return this._bundles.length;
  59.   },
  60.   
  61.   enumBundle: function (idx) {
  62.     return this._bundles[idx];
  63.   },
  64.  
  65.   /**
  66.    * nsIObserver
  67.    */
  68.   observe: function HotkeyActions_observe (aSubject, aTopic, aData) {
  69.     switch (aTopic) {
  70.       case "quit-application": {
  71.         this._bundles = [];
  72.         Cc["@mozilla.org/observer-service;1"]
  73.           .getService(Ci.nsIObserverService)
  74.           .removeObserver(this, aTopic);
  75.       }
  76.     }
  77.   },
  78.  
  79.   /**
  80.    * See nsISupports.idl
  81.    */
  82.   QueryInterface: XPCOMUtils.generateQI([Ci.sbIHotkeyActions,
  83.                                          Ci.nsIObserver,
  84.                                          Ci.nsISupportsWeakReference]),
  85.   
  86.   classDescription: SONGBIRD_HOTKEYACTIONS_CLASSNAME,
  87.   classID: SONGBIRD_HOTKEYACTIONS_CID,
  88.   contractID: SONGBIRD_HOTKEYACTIONS_CONTRACTID
  89. }; // HotkeyActions.prototype
  90.  
  91. var NSGetModule = XPCOMUtils.generateNSGetModule([HotkeyActions]);
  92.