overlay.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN NIGHTINGALE GPL
4 //
5 // This file is part of the Nightingale Media Player.
6 //
7 // Copyright(c) 2014
8 // http://getnightingale.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 NIGHTINGALE GPL
24 //
25  */
26 
27 var Cc = Components.classes;
28 var Ci = Components.interfaces;
29 
30 var isListening = false;
31 
32 var gRemoteControlService = Cc["@songbirdnest.com/mac-remote-service;1"]
33  .getService(Ci.sbIAppleRemoteService);
34 var gPrefService = Cc["@mozilla.org/preferences-service;1"]
35  .getService(Ci.nsIPrefBranch2);
36 
37 //------------------------------------------------------------------------------
38 // Handle autolaunching of the remote control
39 
40 var shouldAutoEnable = false;
41 try {
42  shouldAutoEnable =
43  gPrefService.getBoolPref("extensions.apple-remote.autoenable");
44 
45  if (shouldAutoEnable && gRemoteControlService.isSupported) {
46  gRemoteControlService.startListening();
47  isListening = true;
48 
49  setTimeout(
50  function() {
51  var menuItem = document.getElementById("mac_remote_menuitem");
52  if (menuItem) {
53  menuItem.setAttribute("checked", "true");
54  }
55  },
56  1000
57  );
58  }
59 }
60 catch (e) {
61  dump("\n\n\n\n ERROR: " + e + "\n\n\n\n");
62 }
63 
64 //------------------------------------------------------------------------------
65 // If the current machine doesn't support the apple remote, don't
66 // enable the menu item.
67 
68 if (!gRemoteControlService.isSupported) {
69  // HACK: Set a timeout to find the menuitem..
70  setTimeout(
71  function() {
72  var menuItem = document.getElementById("mac_remote_menuitem");
73  if (menuItem) {
74  menuItem.setAttribute("disabled", "true");
75  }
76  }, 1000);
77 }
78 
79 //------------------------------------------------------------------------------
80 // Callback function from menuitem.
81 
83 {
84  if (isListening) {
85  gRemoteControlService.stopListening();
86  isListening = false;
87  }
88  else {
89  gRemoteControlService.startListening();
90  isListening = true;
91  }
92 }
93 
94 //------------------------------------------------------------------------------
95 // Loading callback method when the pref pane loads
96 
97 function onPrefPaneLoad()
98 {
99 }
100 
var menuItem
Definition: FeedWriter.js:970
function onPrefPaneLoad()
Definition: overlay.js:97
var Ci
Definition: overlay.js:28
var gRemoteControlService
Definition: overlay.js:32
var isListening
Definition: overlay.js:30
var Cc
Definition: overlay.js:27
function ToggleAppleRemote()
Definition: overlay.js:82
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
var gPrefService
Definition: overlay.js:34
var shouldAutoEnable
Definition: overlay.js:40