2012-02-20 15:15:19 +00:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-08-17 02:53:45 +00:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-02-20 15:15:19 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_bluetooth_bluetoothadapter_h__
|
|
|
|
#define mozilla_dom_bluetooth_bluetoothadapter_h__
|
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-02-20 15:15:19 +00:00
|
|
|
#include "BluetoothCommon.h"
|
2012-08-01 04:53:04 +00:00
|
|
|
#include "BluetoothPropertyContainer.h"
|
2012-07-18 03:41:54 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2012-02-23 15:55:48 +00:00
|
|
|
#include "nsDOMEventTargetHelper.h"
|
2013-08-12 08:32:53 +00:00
|
|
|
#include "nsIDOMBluetoothDevice.h"
|
2012-02-20 15:15:19 +00:00
|
|
|
|
2013-08-12 08:32:53 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class DOMRequest;
|
|
|
|
struct MediaMetaData;
|
|
|
|
struct MediaPlayStatus;
|
|
|
|
}
|
|
|
|
}
|
2012-03-05 03:54:01 +00:00
|
|
|
|
2012-02-20 15:15:19 +00:00
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
2013-08-12 08:34:28 +00:00
|
|
|
class BluetoothDevice;
|
2012-07-18 03:41:54 +00:00
|
|
|
class BluetoothSignal;
|
|
|
|
class BluetoothNamedValue;
|
2012-08-08 17:47:09 +00:00
|
|
|
class BluetoothValue;
|
2012-07-18 03:41:54 +00:00
|
|
|
|
2012-03-28 17:29:14 +00:00
|
|
|
class BluetoothAdapter : public nsDOMEventTargetHelper
|
2012-07-18 03:41:54 +00:00
|
|
|
, public BluetoothSignalObserver
|
2012-08-01 04:53:04 +00:00
|
|
|
, public BluetoothPropertyContainer
|
2012-02-20 15:15:19 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-05-24 04:02:23 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-02-23 15:55:48 +00:00
|
|
|
|
2012-08-01 04:53:04 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothAdapter,
|
|
|
|
nsDOMEventTargetHelper)
|
|
|
|
|
2012-06-02 18:23:16 +00:00
|
|
|
static already_AddRefed<BluetoothAdapter>
|
2012-08-08 17:47:09 +00:00
|
|
|
Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
|
2012-07-18 03:41:54 +00:00
|
|
|
|
|
|
|
void Notify(const BluetoothSignal& aParam);
|
|
|
|
|
2013-08-12 08:32:53 +00:00
|
|
|
void Unroot();
|
|
|
|
virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
void GetAddress(nsString& aAddress) const
|
2013-08-12 08:32:53 +00:00
|
|
|
{
|
2013-08-12 08:32:53 +00:00
|
|
|
aAddress = mAddress;
|
2013-08-12 08:32:53 +00:00
|
|
|
}
|
|
|
|
|
2013-08-12 08:32:53 +00:00
|
|
|
uint32_t
|
|
|
|
Class() const
|
|
|
|
{
|
|
|
|
return mClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetName(nsString& aName) const
|
|
|
|
{
|
|
|
|
aName = mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Discovering() const
|
|
|
|
{
|
|
|
|
return mDiscovering;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Discoverable() const
|
|
|
|
{
|
|
|
|
return mDiscoverable;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
DiscoverableTimeout() const
|
|
|
|
{
|
|
|
|
return mDiscoverableTimeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::Value GetDevices(JSContext* aContext, ErrorResult& aRv);
|
|
|
|
JS::Value GetUuids(JSContext* aContext, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<mozilla::dom::DOMRequest>
|
|
|
|
SetName(const nsAString& aName, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetDiscoverable(bool aDiscoverable, ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetDiscoverableTimeout(uint32_t aTimeout, ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest> StartDiscovery(ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest> StopDiscovery(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
2013-11-15 09:19:31 +00:00
|
|
|
Pair(const nsAString& aDeviceAddress, ErrorResult& aRv);
|
2013-08-12 08:32:53 +00:00
|
|
|
already_AddRefed<DOMRequest>
|
2013-11-15 09:19:31 +00:00
|
|
|
Unpair(const nsAString& aDeviceAddress, ErrorResult& aRv);
|
2013-08-12 08:32:53 +00:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
GetPairedDevices(ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetPinCode(const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetPasskey(const nsAString& aDeviceAddress, uint32_t aPasskey,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetPairingConfirmation(const nsAString& aDeviceAddress, bool aConfirmation,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SetAuthorization(const nsAString& aDeviceAddress, bool aAllow,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
2013-09-06 11:19:46 +00:00
|
|
|
Connect(BluetoothDevice& aDevice,
|
|
|
|
const Optional<short unsigned int>& aServiceUuid, ErrorResult& aRv);
|
2013-08-12 08:32:53 +00:00
|
|
|
already_AddRefed<DOMRequest>
|
2013-09-06 11:19:46 +00:00
|
|
|
Disconnect(BluetoothDevice& aDevice,
|
|
|
|
const Optional<short unsigned int>& aServiceUuid,
|
|
|
|
ErrorResult& aRv);
|
2013-08-12 08:32:53 +00:00
|
|
|
already_AddRefed<DOMRequest>
|
2013-09-06 11:19:46 +00:00
|
|
|
GetConnectedDevices(uint16_t aServiceUuid, ErrorResult& aRv);
|
2013-08-12 08:32:53 +00:00
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SendFile(const nsAString& aDeviceAddress, nsIDOMBlob* aBlob,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
StopSendingFile(const nsAString& aDeviceAddress, ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirmation,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest> ConnectSco(ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest> DisconnectSco(ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest> IsScoConnected(ErrorResult& aRv);
|
|
|
|
|
2013-10-16 02:38:13 +00:00
|
|
|
already_AddRefed<DOMRequest> AnswerWaitingCall(ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest> IgnoreWaitingCall(ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest> ToggleCalls(ErrorResult& aRv);
|
|
|
|
|
2013-08-12 08:32:53 +00:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SendMediaMetaData(const MediaMetaData& aMediaMetaData, ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SendMediaPlayStatus(const MediaPlayStatus& aMediaPlayStatus, ErrorResult& aRv);
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(devicefound);
|
2013-11-30 12:20:17 +00:00
|
|
|
IMPL_EVENT_HANDLER(discoverystatechanged);
|
2013-08-12 08:32:53 +00:00
|
|
|
IMPL_EVENT_HANDLER(a2dpstatuschanged);
|
|
|
|
IMPL_EVENT_HANDLER(hfpstatuschanged);
|
|
|
|
IMPL_EVENT_HANDLER(pairedstatuschanged);
|
2013-09-04 02:40:01 +00:00
|
|
|
IMPL_EVENT_HANDLER(requestmediaplaystatus);
|
2013-08-12 08:32:53 +00:00
|
|
|
IMPL_EVENT_HANDLER(scostatuschanged);
|
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
2013-08-12 16:08:03 +00:00
|
|
|
|
2013-08-12 08:32:53 +00:00
|
|
|
private:
|
2012-08-08 17:47:09 +00:00
|
|
|
BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
|
2012-06-02 18:23:16 +00:00
|
|
|
~BluetoothAdapter();
|
2012-07-18 03:41:54 +00:00
|
|
|
|
2012-08-01 04:53:04 +00:00
|
|
|
void Root();
|
2013-08-12 08:32:53 +00:00
|
|
|
|
|
|
|
already_AddRefed<mozilla::dom::DOMRequest>
|
|
|
|
StartStopDiscovery(bool aStart, ErrorResult& aRv);
|
|
|
|
already_AddRefed<mozilla::dom::DOMRequest>
|
2013-11-15 09:19:31 +00:00
|
|
|
PairUnpair(bool aPair, const nsAString& aDeviceAddress, ErrorResult& aRv);
|
2013-08-12 08:32:53 +00:00
|
|
|
|
|
|
|
JS::Heap<JSObject*> mJsUuids;
|
|
|
|
JS::Heap<JSObject*> mJsDeviceAddresses;
|
2012-07-18 03:41:54 +00:00
|
|
|
nsString mAddress;
|
|
|
|
nsString mName;
|
|
|
|
bool mDiscoverable;
|
|
|
|
bool mDiscovering;
|
|
|
|
bool mPairable;
|
|
|
|
bool mPowered;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mPairableTimeout;
|
|
|
|
uint32_t mDiscoverableTimeout;
|
|
|
|
uint32_t mClass;
|
2012-07-18 03:41:54 +00:00
|
|
|
nsTArray<nsString> mDeviceAddresses;
|
|
|
|
nsTArray<nsString> mUuids;
|
2012-08-01 04:53:04 +00:00
|
|
|
bool mIsRooted;
|
2012-02-20 15:15:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
2012-03-27 23:17:35 +00:00
|
|
|
|
2012-02-20 15:15:19 +00:00
|
|
|
#endif
|