Menu
Home
Blog
Add-ons
Forum
Wiki
Developers
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
extensions
apple-remote
chrome
content
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
82
function
ToggleAppleRemote
()
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
menuItem
var menuItem
Definition:
FeedWriter.js:970
onPrefPaneLoad
function onPrefPaneLoad()
Definition:
overlay.js:97
Ci
var Ci
Definition:
overlay.js:28
gRemoteControlService
var gRemoteControlService
Definition:
overlay.js:32
isListening
var isListening
Definition:
overlay.js:30
Cc
var Cc
Definition:
overlay.js:27
ToggleAppleRemote
function ToggleAppleRemote()
Definition:
overlay.js:82
setTimeout
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
gPrefService
var gPrefService
Definition:
overlay.js:34
shouldAutoEnable
var shouldAutoEnable
Definition:
overlay.js:40