|
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_dom_bluetooth_bluetoothdbusservice_h__ |
|
8 #define mozilla_dom_bluetooth_bluetoothdbusservice_h__ |
|
9 |
|
10 #include "mozilla/Attributes.h" |
|
11 #include "BluetoothCommon.h" |
|
12 #include "mozilla/ipc/RawDBusConnection.h" |
|
13 #include "BluetoothService.h" |
|
14 #include "nsIThread.h" |
|
15 |
|
16 class DBusMessage; |
|
17 |
|
18 BEGIN_BLUETOOTH_NAMESPACE |
|
19 |
|
20 /** |
|
21 * BluetoothDBusService is the implementation of BluetoothService for DBus on |
|
22 * linux/android/B2G. Function comments are in BluetoothService.h |
|
23 */ |
|
24 |
|
25 class BluetoothDBusService : public BluetoothService |
|
26 { |
|
27 public: |
|
28 /** |
|
29 * For DBus Control method of "UpdateNotification", event id should be |
|
30 * specified as following: |
|
31 * (Please see specification of AVRCP 1.3, Table 5.28 for more details.) |
|
32 */ |
|
33 enum ControlEventId { |
|
34 EVENT_PLAYBACK_STATUS_CHANGED = 0x01, |
|
35 EVENT_TRACK_CHANGED = 0x02, |
|
36 EVENT_TRACK_REACHED_END = 0x03, |
|
37 EVENT_TRACK_REACHED_START = 0x04, |
|
38 EVENT_PLAYBACK_POS_CHANGED = 0x05, |
|
39 EVENT_BATT_STATUS_CHANGED = 0x06, |
|
40 EVENT_SYSTEM_STATUS_CHANGED = 0x07, |
|
41 EVENT_PLAYER_APPLICATION_SETTING_CHANGED = 0x08, |
|
42 EVENT_UNKNOWN |
|
43 }; |
|
44 |
|
45 BluetoothDBusService(); |
|
46 ~BluetoothDBusService(); |
|
47 |
|
48 bool IsReady(); |
|
49 |
|
50 virtual nsresult StartInternal() MOZ_OVERRIDE; |
|
51 |
|
52 virtual nsresult StopInternal() MOZ_OVERRIDE; |
|
53 |
|
54 virtual nsresult GetDefaultAdapterPathInternal( |
|
55 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
56 |
|
57 virtual nsresult GetConnectedDevicePropertiesInternal(uint16_t aServiceUuid, |
|
58 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
59 |
|
60 virtual nsresult GetPairedDevicePropertiesInternal( |
|
61 const nsTArray<nsString>& aDeviceAddresses, |
|
62 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
63 |
|
64 virtual nsresult StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
65 |
|
66 virtual nsresult StopDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
67 |
|
68 virtual nsresult |
|
69 SetProperty(BluetoothObjectType aType, |
|
70 const BluetoothNamedValue& aValue, |
|
71 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
72 |
|
73 virtual nsresult |
|
74 GetServiceChannel(const nsAString& aDeviceAddress, |
|
75 const nsAString& aServiceUuid, |
|
76 BluetoothProfileManagerBase* aManager) MOZ_OVERRIDE; |
|
77 |
|
78 virtual bool |
|
79 UpdateSdpRecords(const nsAString& aDeviceAddress, |
|
80 BluetoothProfileManagerBase* aManager) MOZ_OVERRIDE; |
|
81 |
|
82 virtual nsresult |
|
83 CreatePairedDeviceInternal(const nsAString& aDeviceAddress, |
|
84 int aTimeout, |
|
85 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
86 |
|
87 virtual nsresult |
|
88 RemoveDeviceInternal(const nsAString& aDeviceObjectPath, |
|
89 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
90 |
|
91 virtual bool |
|
92 SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode, |
|
93 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
94 |
|
95 virtual bool |
|
96 SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey, |
|
97 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
98 |
|
99 virtual bool |
|
100 SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm, |
|
101 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
102 |
|
103 virtual void |
|
104 Connect(const nsAString& aDeviceAddress, |
|
105 uint32_t aCod, |
|
106 uint16_t aServiceUuid, |
|
107 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
108 |
|
109 virtual bool |
|
110 IsConnected(uint16_t aServiceUuid) MOZ_OVERRIDE; |
|
111 |
|
112 virtual void |
|
113 Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid, |
|
114 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
115 |
|
116 virtual void |
|
117 SendFile(const nsAString& aDeviceAddress, |
|
118 BlobParent* aBlobParent, |
|
119 BlobChild* aBlobChild, |
|
120 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
121 |
|
122 virtual void |
|
123 SendFile(const nsAString& aDeviceAddress, |
|
124 nsIDOMBlob* aBlob, |
|
125 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
126 |
|
127 virtual void |
|
128 StopSendingFile(const nsAString& aDeviceAddress, |
|
129 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
130 |
|
131 virtual void |
|
132 ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm, |
|
133 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
134 |
|
135 virtual void |
|
136 ConnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
137 |
|
138 virtual void |
|
139 DisconnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
140 |
|
141 virtual void |
|
142 IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
143 |
|
144 #ifdef MOZ_B2G_RIL |
|
145 virtual void |
|
146 AnswerWaitingCall(BluetoothReplyRunnable* aRunnable); |
|
147 |
|
148 virtual void |
|
149 IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable); |
|
150 |
|
151 virtual void |
|
152 ToggleCalls(BluetoothReplyRunnable* aRunnable); |
|
153 #endif |
|
154 |
|
155 virtual void |
|
156 SendMetaData(const nsAString& aTitle, |
|
157 const nsAString& aArtist, |
|
158 const nsAString& aAlbum, |
|
159 int64_t aMediaNumber, |
|
160 int64_t aTotalMediaCount, |
|
161 int64_t aDuration, |
|
162 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
163 |
|
164 virtual void |
|
165 SendPlayStatus(int64_t aDuration, |
|
166 int64_t aPosition, |
|
167 const nsAString& aPlayStatus, |
|
168 BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; |
|
169 |
|
170 virtual void |
|
171 UpdatePlayStatus(uint32_t aDuration, |
|
172 uint32_t aPosition, |
|
173 ControlPlayStatus aPlayStatus) MOZ_OVERRIDE; |
|
174 |
|
175 virtual nsresult |
|
176 SendSinkMessage(const nsAString& aDeviceAddresses, |
|
177 const nsAString& aMessage) MOZ_OVERRIDE; |
|
178 |
|
179 virtual nsresult |
|
180 SendInputMessage(const nsAString& aDeviceAddresses, |
|
181 const nsAString& aMessage) MOZ_OVERRIDE; |
|
182 private: |
|
183 nsresult SendGetPropertyMessage(const nsAString& aPath, |
|
184 const char* aInterface, |
|
185 void (*aCB)(DBusMessage *, void *), |
|
186 BluetoothReplyRunnable* aRunnable); |
|
187 |
|
188 nsresult SendDiscoveryMessage(const char* aMessageName, |
|
189 BluetoothReplyRunnable* aRunnable); |
|
190 |
|
191 nsresult SendSetPropertyMessage(const char* aInterface, |
|
192 const BluetoothNamedValue& aValue, |
|
193 BluetoothReplyRunnable* aRunnable); |
|
194 |
|
195 void UpdateNotification(ControlEventId aEventId, uint64_t aData); |
|
196 |
|
197 nsresult SendAsyncDBusMessage(const nsAString& aObjectPath, |
|
198 const char* aInterface, |
|
199 const nsAString& aMessage, |
|
200 mozilla::ipc::DBusReplyCallback aCallback); |
|
201 }; |
|
202 |
|
203 END_BLUETOOTH_NAMESPACE |
|
204 |
|
205 #endif |