|
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_bluetoothdevice_h__ |
|
8 #define mozilla_dom_bluetooth_bluetoothdevice_h__ |
|
9 |
|
10 #include "mozilla/Attributes.h" |
|
11 #include "mozilla/DOMEventTargetHelper.h" |
|
12 #include "BluetoothCommon.h" |
|
13 #include "BluetoothPropertyContainer.h" |
|
14 #include "nsString.h" |
|
15 |
|
16 BEGIN_BLUETOOTH_NAMESPACE |
|
17 |
|
18 class BluetoothNamedValue; |
|
19 class BluetoothValue; |
|
20 class BluetoothSignal; |
|
21 class BluetoothSocket; |
|
22 |
|
23 class BluetoothDevice : public DOMEventTargetHelper |
|
24 , public BluetoothSignalObserver |
|
25 , public BluetoothPropertyContainer |
|
26 { |
|
27 public: |
|
28 NS_DECL_ISUPPORTS_INHERITED |
|
29 |
|
30 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothDevice, |
|
31 DOMEventTargetHelper) |
|
32 |
|
33 static already_AddRefed<BluetoothDevice> |
|
34 Create(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath, |
|
35 const BluetoothValue& aValue); |
|
36 |
|
37 void Notify(const BluetoothSignal& aParam); |
|
38 |
|
39 void GetAddress(nsString& aAddress) const |
|
40 { |
|
41 aAddress = mAddress; |
|
42 } |
|
43 |
|
44 void GetName(nsString& aName) const |
|
45 { |
|
46 aName = mName; |
|
47 } |
|
48 |
|
49 void GetIcon(nsString& aIcon) const |
|
50 { |
|
51 aIcon = mIcon; |
|
52 } |
|
53 |
|
54 uint32_t Class() const |
|
55 { |
|
56 return mClass; |
|
57 } |
|
58 |
|
59 bool Paired() const |
|
60 { |
|
61 return mPaired; |
|
62 } |
|
63 |
|
64 bool Connected() const |
|
65 { |
|
66 return mConnected; |
|
67 } |
|
68 |
|
69 void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids, |
|
70 ErrorResult& aRv); |
|
71 void GetServices(JSContext* aContext, JS::MutableHandle<JS::Value> aServices, |
|
72 ErrorResult& aRv); |
|
73 |
|
74 nsISupports* |
|
75 ToISupports() |
|
76 { |
|
77 return static_cast<EventTarget*>(this); |
|
78 } |
|
79 |
|
80 void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE; |
|
81 |
|
82 void Unroot(); |
|
83 |
|
84 nsPIDOMWindow* GetParentObject() const |
|
85 { |
|
86 return GetOwner(); |
|
87 } |
|
88 |
|
89 virtual JSObject* |
|
90 WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
91 |
|
92 virtual void DisconnectFromOwner() MOZ_OVERRIDE; |
|
93 |
|
94 private: |
|
95 BluetoothDevice(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath, |
|
96 const BluetoothValue& aValue); |
|
97 ~BluetoothDevice(); |
|
98 void Root(); |
|
99 |
|
100 JS::Heap<JSObject*> mJsUuids; |
|
101 JS::Heap<JSObject*> mJsServices; |
|
102 |
|
103 nsString mAdapterPath; |
|
104 nsString mAddress; |
|
105 nsString mName; |
|
106 nsString mIcon; |
|
107 uint32_t mClass; |
|
108 bool mConnected; |
|
109 bool mPaired; |
|
110 bool mIsRooted; |
|
111 nsTArray<nsString> mUuids; |
|
112 nsTArray<nsString> mServices; |
|
113 |
|
114 }; |
|
115 |
|
116 END_BLUETOOTH_NAMESPACE |
|
117 |
|
118 #endif |