dom/bluetooth/BluetoothAdapter.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

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_bluetoothadapter_h__
michael@0 8 #define mozilla_dom_bluetooth_bluetoothadapter_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 "nsCOMPtr.h"
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 namespace dom {
michael@0 18 class DOMRequest;
michael@0 19 struct MediaMetaData;
michael@0 20 struct MediaPlayStatus;
michael@0 21 }
michael@0 22 }
michael@0 23
michael@0 24 BEGIN_BLUETOOTH_NAMESPACE
michael@0 25
michael@0 26 class BluetoothDevice;
michael@0 27 class BluetoothSignal;
michael@0 28 class BluetoothNamedValue;
michael@0 29 class BluetoothValue;
michael@0 30
michael@0 31 class BluetoothAdapter : public DOMEventTargetHelper
michael@0 32 , public BluetoothSignalObserver
michael@0 33 , public BluetoothPropertyContainer
michael@0 34 {
michael@0 35 public:
michael@0 36 NS_DECL_ISUPPORTS_INHERITED
michael@0 37
michael@0 38 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothAdapter,
michael@0 39 DOMEventTargetHelper)
michael@0 40
michael@0 41 static already_AddRefed<BluetoothAdapter>
michael@0 42 Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
michael@0 43
michael@0 44 void Notify(const BluetoothSignal& aParam);
michael@0 45
michael@0 46 void Unroot();
michael@0 47 virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
michael@0 48
michael@0 49 virtual void DisconnectFromOwner() MOZ_OVERRIDE;
michael@0 50
michael@0 51 void GetAddress(nsString& aAddress) const
michael@0 52 {
michael@0 53 aAddress = mAddress;
michael@0 54 }
michael@0 55
michael@0 56 uint32_t
michael@0 57 Class() const
michael@0 58 {
michael@0 59 return mClass;
michael@0 60 }
michael@0 61
michael@0 62 void
michael@0 63 GetName(nsString& aName) const
michael@0 64 {
michael@0 65 aName = mName;
michael@0 66 }
michael@0 67
michael@0 68 bool
michael@0 69 Discovering() const
michael@0 70 {
michael@0 71 return mDiscovering;
michael@0 72 }
michael@0 73
michael@0 74 bool
michael@0 75 Discoverable() const
michael@0 76 {
michael@0 77 return mDiscoverable;
michael@0 78 }
michael@0 79
michael@0 80 uint32_t
michael@0 81 DiscoverableTimeout() const
michael@0 82 {
michael@0 83 return mDiscoverableTimeout;
michael@0 84 }
michael@0 85
michael@0 86 void GetDevices(JSContext* aContext, JS::MutableHandle<JS::Value> aDevices,
michael@0 87 ErrorResult& aRv);
michael@0 88 void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids,
michael@0 89 ErrorResult& aRv);
michael@0 90
michael@0 91 already_AddRefed<mozilla::dom::DOMRequest>
michael@0 92 SetName(const nsAString& aName, ErrorResult& aRv);
michael@0 93
michael@0 94 already_AddRefed<DOMRequest>
michael@0 95 SetDiscoverable(bool aDiscoverable, ErrorResult& aRv);
michael@0 96 already_AddRefed<DOMRequest>
michael@0 97 SetDiscoverableTimeout(uint32_t aTimeout, ErrorResult& aRv);
michael@0 98 already_AddRefed<DOMRequest> StartDiscovery(ErrorResult& aRv);
michael@0 99 already_AddRefed<DOMRequest> StopDiscovery(ErrorResult& aRv);
michael@0 100
michael@0 101 already_AddRefed<DOMRequest>
michael@0 102 Pair(const nsAString& aDeviceAddress, ErrorResult& aRv);
michael@0 103 already_AddRefed<DOMRequest>
michael@0 104 Unpair(const nsAString& aDeviceAddress, ErrorResult& aRv);
michael@0 105 already_AddRefed<DOMRequest>
michael@0 106 GetPairedDevices(ErrorResult& aRv);
michael@0 107 already_AddRefed<DOMRequest>
michael@0 108 SetPinCode(const nsAString& aDeviceAddress, const nsAString& aPinCode,
michael@0 109 ErrorResult& aRv);
michael@0 110 already_AddRefed<DOMRequest>
michael@0 111 SetPasskey(const nsAString& aDeviceAddress, uint32_t aPasskey,
michael@0 112 ErrorResult& aRv);
michael@0 113 already_AddRefed<DOMRequest>
michael@0 114 SetPairingConfirmation(const nsAString& aDeviceAddress, bool aConfirmation,
michael@0 115 ErrorResult& aRv);
michael@0 116 already_AddRefed<DOMRequest>
michael@0 117 SetAuthorization(const nsAString& aDeviceAddress, bool aAllow,
michael@0 118 ErrorResult& aRv);
michael@0 119
michael@0 120 already_AddRefed<DOMRequest>
michael@0 121 Connect(BluetoothDevice& aDevice,
michael@0 122 const Optional<short unsigned int>& aServiceUuid, ErrorResult& aRv);
michael@0 123 already_AddRefed<DOMRequest>
michael@0 124 Disconnect(BluetoothDevice& aDevice,
michael@0 125 const Optional<short unsigned int>& aServiceUuid,
michael@0 126 ErrorResult& aRv);
michael@0 127 already_AddRefed<DOMRequest>
michael@0 128 GetConnectedDevices(uint16_t aServiceUuid, ErrorResult& aRv);
michael@0 129
michael@0 130 already_AddRefed<DOMRequest>
michael@0 131 SendFile(const nsAString& aDeviceAddress, nsIDOMBlob* aBlob,
michael@0 132 ErrorResult& aRv);
michael@0 133 already_AddRefed<DOMRequest>
michael@0 134 StopSendingFile(const nsAString& aDeviceAddress, ErrorResult& aRv);
michael@0 135 already_AddRefed<DOMRequest>
michael@0 136 ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirmation,
michael@0 137 ErrorResult& aRv);
michael@0 138
michael@0 139 already_AddRefed<DOMRequest> ConnectSco(ErrorResult& aRv);
michael@0 140 already_AddRefed<DOMRequest> DisconnectSco(ErrorResult& aRv);
michael@0 141 already_AddRefed<DOMRequest> IsScoConnected(ErrorResult& aRv);
michael@0 142
michael@0 143 already_AddRefed<DOMRequest> AnswerWaitingCall(ErrorResult& aRv);
michael@0 144 already_AddRefed<DOMRequest> IgnoreWaitingCall(ErrorResult& aRv);
michael@0 145 already_AddRefed<DOMRequest> ToggleCalls(ErrorResult& aRv);
michael@0 146
michael@0 147 already_AddRefed<DOMRequest>
michael@0 148 SendMediaMetaData(const MediaMetaData& aMediaMetaData, ErrorResult& aRv);
michael@0 149 already_AddRefed<DOMRequest>
michael@0 150 SendMediaPlayStatus(const MediaPlayStatus& aMediaPlayStatus, ErrorResult& aRv);
michael@0 151
michael@0 152 IMPL_EVENT_HANDLER(devicefound);
michael@0 153 IMPL_EVENT_HANDLER(a2dpstatuschanged);
michael@0 154 IMPL_EVENT_HANDLER(hfpstatuschanged);
michael@0 155 IMPL_EVENT_HANDLER(pairedstatuschanged);
michael@0 156 IMPL_EVENT_HANDLER(requestmediaplaystatus);
michael@0 157 IMPL_EVENT_HANDLER(scostatuschanged);
michael@0 158
michael@0 159 nsPIDOMWindow* GetParentObject() const
michael@0 160 {
michael@0 161 return GetOwner();
michael@0 162 }
michael@0 163
michael@0 164 virtual JSObject*
michael@0 165 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 166
michael@0 167 private:
michael@0 168 BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
michael@0 169 ~BluetoothAdapter();
michael@0 170
michael@0 171 void Root();
michael@0 172
michael@0 173 already_AddRefed<mozilla::dom::DOMRequest>
michael@0 174 StartStopDiscovery(bool aStart, ErrorResult& aRv);
michael@0 175 already_AddRefed<mozilla::dom::DOMRequest>
michael@0 176 PairUnpair(bool aPair, const nsAString& aDeviceAddress, ErrorResult& aRv);
michael@0 177
michael@0 178 JS::Heap<JSObject*> mJsUuids;
michael@0 179 JS::Heap<JSObject*> mJsDeviceAddresses;
michael@0 180 nsString mAddress;
michael@0 181 nsString mName;
michael@0 182 bool mDiscoverable;
michael@0 183 bool mDiscovering;
michael@0 184 bool mPairable;
michael@0 185 bool mPowered;
michael@0 186 uint32_t mPairableTimeout;
michael@0 187 uint32_t mDiscoverableTimeout;
michael@0 188 uint32_t mClass;
michael@0 189 nsTArray<nsString> mDeviceAddresses;
michael@0 190 nsTArray<nsString> mUuids;
michael@0 191 bool mIsRooted;
michael@0 192 };
michael@0 193
michael@0 194 END_BLUETOOTH_NAMESPACE
michael@0 195
michael@0 196 #endif

mercurial