Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_bluetooth_bluetoothdevice_h__ |
michael@0 | 8 | #define mozilla_dom_bluetooth_bluetoothdevice_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Attributes.h" |
michael@0 | 11 | #include "mozilla/DOMEventTargetHelper.h" |
michael@0 | 12 | #include "BluetoothCommon.h" |
michael@0 | 13 | #include "BluetoothPropertyContainer.h" |
michael@0 | 14 | #include "nsString.h" |
michael@0 | 15 | |
michael@0 | 16 | BEGIN_BLUETOOTH_NAMESPACE |
michael@0 | 17 | |
michael@0 | 18 | class BluetoothNamedValue; |
michael@0 | 19 | class BluetoothValue; |
michael@0 | 20 | class BluetoothSignal; |
michael@0 | 21 | class BluetoothSocket; |
michael@0 | 22 | |
michael@0 | 23 | class BluetoothDevice : public DOMEventTargetHelper |
michael@0 | 24 | , public BluetoothSignalObserver |
michael@0 | 25 | , public BluetoothPropertyContainer |
michael@0 | 26 | { |
michael@0 | 27 | public: |
michael@0 | 28 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 29 | |
michael@0 | 30 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothDevice, |
michael@0 | 31 | DOMEventTargetHelper) |
michael@0 | 32 | |
michael@0 | 33 | static already_AddRefed<BluetoothDevice> |
michael@0 | 34 | Create(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath, |
michael@0 | 35 | const BluetoothValue& aValue); |
michael@0 | 36 | |
michael@0 | 37 | void Notify(const BluetoothSignal& aParam); |
michael@0 | 38 | |
michael@0 | 39 | void GetAddress(nsString& aAddress) const |
michael@0 | 40 | { |
michael@0 | 41 | aAddress = mAddress; |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | void GetName(nsString& aName) const |
michael@0 | 45 | { |
michael@0 | 46 | aName = mName; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | void GetIcon(nsString& aIcon) const |
michael@0 | 50 | { |
michael@0 | 51 | aIcon = mIcon; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | uint32_t Class() const |
michael@0 | 55 | { |
michael@0 | 56 | return mClass; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | bool Paired() const |
michael@0 | 60 | { |
michael@0 | 61 | return mPaired; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | bool Connected() const |
michael@0 | 65 | { |
michael@0 | 66 | return mConnected; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids, |
michael@0 | 70 | ErrorResult& aRv); |
michael@0 | 71 | void GetServices(JSContext* aContext, JS::MutableHandle<JS::Value> aServices, |
michael@0 | 72 | ErrorResult& aRv); |
michael@0 | 73 | |
michael@0 | 74 | nsISupports* |
michael@0 | 75 | ToISupports() |
michael@0 | 76 | { |
michael@0 | 77 | return static_cast<EventTarget*>(this); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE; |
michael@0 | 81 | |
michael@0 | 82 | void Unroot(); |
michael@0 | 83 | |
michael@0 | 84 | nsPIDOMWindow* GetParentObject() const |
michael@0 | 85 | { |
michael@0 | 86 | return GetOwner(); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | virtual JSObject* |
michael@0 | 90 | WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 91 | |
michael@0 | 92 | virtual void DisconnectFromOwner() MOZ_OVERRIDE; |
michael@0 | 93 | |
michael@0 | 94 | private: |
michael@0 | 95 | BluetoothDevice(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath, |
michael@0 | 96 | const BluetoothValue& aValue); |
michael@0 | 97 | ~BluetoothDevice(); |
michael@0 | 98 | void Root(); |
michael@0 | 99 | |
michael@0 | 100 | JS::Heap<JSObject*> mJsUuids; |
michael@0 | 101 | JS::Heap<JSObject*> mJsServices; |
michael@0 | 102 | |
michael@0 | 103 | nsString mAdapterPath; |
michael@0 | 104 | nsString mAddress; |
michael@0 | 105 | nsString mName; |
michael@0 | 106 | nsString mIcon; |
michael@0 | 107 | uint32_t mClass; |
michael@0 | 108 | bool mConnected; |
michael@0 | 109 | bool mPaired; |
michael@0 | 110 | bool mIsRooted; |
michael@0 | 111 | nsTArray<nsString> mUuids; |
michael@0 | 112 | nsTArray<nsString> mServices; |
michael@0 | 113 | |
michael@0 | 114 | }; |
michael@0 | 115 | |
michael@0 | 116 | END_BLUETOOTH_NAMESPACE |
michael@0 | 117 | |
michael@0 | 118 | #endif |