|
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_bluetoothmanager_h__ |
|
8 #define mozilla_dom_bluetooth_bluetoothmanager_h__ |
|
9 |
|
10 #include "mozilla/Attributes.h" |
|
11 #include "mozilla/DOMEventTargetHelper.h" |
|
12 #include "mozilla/Observer.h" |
|
13 #include "BluetoothCommon.h" |
|
14 #include "BluetoothPropertyContainer.h" |
|
15 #include "nsISupportsImpl.h" |
|
16 |
|
17 namespace mozilla { |
|
18 namespace dom { |
|
19 class DOMRequest; |
|
20 } |
|
21 } |
|
22 |
|
23 BEGIN_BLUETOOTH_NAMESPACE |
|
24 |
|
25 class BluetoothNamedValue; |
|
26 |
|
27 class BluetoothManager : public DOMEventTargetHelper |
|
28 , public BluetoothSignalObserver |
|
29 , public BluetoothPropertyContainer |
|
30 { |
|
31 public: |
|
32 NS_DECL_ISUPPORTS_INHERITED |
|
33 |
|
34 // Never returns null |
|
35 static already_AddRefed<BluetoothManager> |
|
36 Create(nsPIDOMWindow* aWindow); |
|
37 static bool CheckPermission(nsPIDOMWindow* aWindow); |
|
38 void Notify(const BluetoothSignal& aData); |
|
39 virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE; |
|
40 |
|
41 bool GetEnabled(ErrorResult& aRv); |
|
42 bool IsConnected(uint16_t aProfileId, ErrorResult& aRv); |
|
43 |
|
44 already_AddRefed<DOMRequest> GetDefaultAdapter(ErrorResult& aRv); |
|
45 |
|
46 IMPL_EVENT_HANDLER(enabled); |
|
47 IMPL_EVENT_HANDLER(disabled); |
|
48 IMPL_EVENT_HANDLER(adapteradded); |
|
49 |
|
50 nsPIDOMWindow* GetParentObject() const |
|
51 { |
|
52 return GetOwner(); |
|
53 } |
|
54 |
|
55 virtual JSObject* |
|
56 WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
57 |
|
58 virtual void DisconnectFromOwner() MOZ_OVERRIDE; |
|
59 |
|
60 private: |
|
61 BluetoothManager(nsPIDOMWindow* aWindow); |
|
62 ~BluetoothManager(); |
|
63 }; |
|
64 |
|
65 END_BLUETOOTH_NAMESPACE |
|
66 |
|
67 #endif |