michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_bluetooth_bluetoothadapter_h__ michael@0: #define mozilla_dom_bluetooth_bluetoothadapter_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "BluetoothCommon.h" michael@0: #include "BluetoothPropertyContainer.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: class DOMRequest; michael@0: struct MediaMetaData; michael@0: struct MediaPlayStatus; michael@0: } michael@0: } michael@0: michael@0: BEGIN_BLUETOOTH_NAMESPACE michael@0: michael@0: class BluetoothDevice; michael@0: class BluetoothSignal; michael@0: class BluetoothNamedValue; michael@0: class BluetoothValue; michael@0: michael@0: class BluetoothAdapter : public DOMEventTargetHelper michael@0: , public BluetoothSignalObserver michael@0: , public BluetoothPropertyContainer michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothAdapter, michael@0: DOMEventTargetHelper) michael@0: michael@0: static already_AddRefed michael@0: Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue); michael@0: michael@0: void Notify(const BluetoothSignal& aParam); michael@0: michael@0: void Unroot(); michael@0: virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE; michael@0: michael@0: virtual void DisconnectFromOwner() MOZ_OVERRIDE; michael@0: michael@0: void GetAddress(nsString& aAddress) const michael@0: { michael@0: aAddress = mAddress; michael@0: } michael@0: michael@0: uint32_t michael@0: Class() const michael@0: { michael@0: return mClass; michael@0: } michael@0: michael@0: void michael@0: GetName(nsString& aName) const michael@0: { michael@0: aName = mName; michael@0: } michael@0: michael@0: bool michael@0: Discovering() const michael@0: { michael@0: return mDiscovering; michael@0: } michael@0: michael@0: bool michael@0: Discoverable() const michael@0: { michael@0: return mDiscoverable; michael@0: } michael@0: michael@0: uint32_t michael@0: DiscoverableTimeout() const michael@0: { michael@0: return mDiscoverableTimeout; michael@0: } michael@0: michael@0: void GetDevices(JSContext* aContext, JS::MutableHandle aDevices, michael@0: ErrorResult& aRv); michael@0: void GetUuids(JSContext* aContext, JS::MutableHandle aUuids, michael@0: ErrorResult& aRv); michael@0: michael@0: already_AddRefed michael@0: SetName(const nsAString& aName, ErrorResult& aRv); michael@0: michael@0: already_AddRefed michael@0: SetDiscoverable(bool aDiscoverable, ErrorResult& aRv); michael@0: already_AddRefed michael@0: SetDiscoverableTimeout(uint32_t aTimeout, ErrorResult& aRv); michael@0: already_AddRefed StartDiscovery(ErrorResult& aRv); michael@0: already_AddRefed StopDiscovery(ErrorResult& aRv); michael@0: michael@0: already_AddRefed michael@0: Pair(const nsAString& aDeviceAddress, ErrorResult& aRv); michael@0: already_AddRefed michael@0: Unpair(const nsAString& aDeviceAddress, ErrorResult& aRv); michael@0: already_AddRefed michael@0: GetPairedDevices(ErrorResult& aRv); michael@0: already_AddRefed michael@0: SetPinCode(const nsAString& aDeviceAddress, const nsAString& aPinCode, michael@0: ErrorResult& aRv); michael@0: already_AddRefed michael@0: SetPasskey(const nsAString& aDeviceAddress, uint32_t aPasskey, michael@0: ErrorResult& aRv); michael@0: already_AddRefed michael@0: SetPairingConfirmation(const nsAString& aDeviceAddress, bool aConfirmation, michael@0: ErrorResult& aRv); michael@0: already_AddRefed michael@0: SetAuthorization(const nsAString& aDeviceAddress, bool aAllow, michael@0: ErrorResult& aRv); michael@0: michael@0: already_AddRefed michael@0: Connect(BluetoothDevice& aDevice, michael@0: const Optional& aServiceUuid, ErrorResult& aRv); michael@0: already_AddRefed michael@0: Disconnect(BluetoothDevice& aDevice, michael@0: const Optional& aServiceUuid, michael@0: ErrorResult& aRv); michael@0: already_AddRefed michael@0: GetConnectedDevices(uint16_t aServiceUuid, ErrorResult& aRv); michael@0: michael@0: already_AddRefed michael@0: SendFile(const nsAString& aDeviceAddress, nsIDOMBlob* aBlob, michael@0: ErrorResult& aRv); michael@0: already_AddRefed michael@0: StopSendingFile(const nsAString& aDeviceAddress, ErrorResult& aRv); michael@0: already_AddRefed michael@0: ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirmation, michael@0: ErrorResult& aRv); michael@0: michael@0: already_AddRefed ConnectSco(ErrorResult& aRv); michael@0: already_AddRefed DisconnectSco(ErrorResult& aRv); michael@0: already_AddRefed IsScoConnected(ErrorResult& aRv); michael@0: michael@0: already_AddRefed AnswerWaitingCall(ErrorResult& aRv); michael@0: already_AddRefed IgnoreWaitingCall(ErrorResult& aRv); michael@0: already_AddRefed ToggleCalls(ErrorResult& aRv); michael@0: michael@0: already_AddRefed michael@0: SendMediaMetaData(const MediaMetaData& aMediaMetaData, ErrorResult& aRv); michael@0: already_AddRefed michael@0: SendMediaPlayStatus(const MediaPlayStatus& aMediaPlayStatus, ErrorResult& aRv); michael@0: michael@0: IMPL_EVENT_HANDLER(devicefound); michael@0: IMPL_EVENT_HANDLER(a2dpstatuschanged); michael@0: IMPL_EVENT_HANDLER(hfpstatuschanged); michael@0: IMPL_EVENT_HANDLER(pairedstatuschanged); michael@0: IMPL_EVENT_HANDLER(requestmediaplaystatus); michael@0: IMPL_EVENT_HANDLER(scostatuschanged); michael@0: michael@0: nsPIDOMWindow* GetParentObject() const michael@0: { michael@0: return GetOwner(); michael@0: } michael@0: michael@0: virtual JSObject* michael@0: WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue); michael@0: ~BluetoothAdapter(); michael@0: michael@0: void Root(); michael@0: michael@0: already_AddRefed michael@0: StartStopDiscovery(bool aStart, ErrorResult& aRv); michael@0: already_AddRefed michael@0: PairUnpair(bool aPair, const nsAString& aDeviceAddress, ErrorResult& aRv); michael@0: michael@0: JS::Heap mJsUuids; michael@0: JS::Heap mJsDeviceAddresses; michael@0: nsString mAddress; michael@0: nsString mName; michael@0: bool mDiscoverable; michael@0: bool mDiscovering; michael@0: bool mPairable; michael@0: bool mPowered; michael@0: uint32_t mPairableTimeout; michael@0: uint32_t mDiscoverableTimeout; michael@0: uint32_t mClass; michael@0: nsTArray mDeviceAddresses; michael@0: nsTArray mUuids; michael@0: bool mIsRooted; michael@0: }; michael@0: michael@0: END_BLUETOOTH_NAMESPACE michael@0: michael@0: #endif