2012-02-20 19:15:19 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-08-17 06:53:45 +04:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-02-20 19:15:19 +04: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 20:15:48 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2012-02-20 19:15:19 +04:00
|
|
|
#include "BluetoothCommon.h"
|
2012-08-01 08:53:04 +04:00
|
|
|
#include "BluetoothPropertyContainer.h"
|
2012-07-18 07:41:54 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2012-02-20 19:15:19 +04:00
|
|
|
|
2013-08-12 12:32:53 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class DOMRequest;
|
|
|
|
struct MediaMetaData;
|
|
|
|
struct MediaPlayStatus;
|
|
|
|
}
|
|
|
|
}
|
2012-03-05 07:54:01 +04:00
|
|
|
|
2012-02-20 19:15:19 +04:00
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
2013-08-12 12:34:28 +04:00
|
|
|
class BluetoothDevice;
|
2012-07-18 07:41:54 +04:00
|
|
|
class BluetoothSignal;
|
|
|
|
class BluetoothNamedValue;
|
2012-08-08 21:47:09 +04:00
|
|
|
class BluetoothValue;
|
2012-07-18 07:41:54 +04:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
class BluetoothAdapter : public DOMEventTargetHelper
|
2012-07-18 07:41:54 +04:00
|
|
|
, public BluetoothSignalObserver
|
2012-08-01 08:53:04 +04:00
|
|
|
, public BluetoothPropertyContainer
|
2012-02-20 19:15:19 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-05-24 08:02:23 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-02-23 19:55:48 +04:00
|
|
|
|
2012-08-01 08:53:04 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothAdapter,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2012-08-01 08:53:04 +04:00
|
|
|
|
2012-06-02 22:23:16 +04:00
|
|
|
static already_AddRefed<BluetoothAdapter>
|
2012-08-08 21:47:09 +04:00
|
|
|
Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
|
2012-07-18 07:41:54 +04:00
|
|
|
|
|
|
|
void Notify(const BluetoothSignal& aParam);
|
|
|
|
|
2013-08-12 12:32:53 +04:00
|
|
|
void Unroot();
|
|
|
|
virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
|
|
|
|
|
2014-04-01 16:58:56 +04:00
|
|
|
virtual void DisconnectFromOwner() MOZ_OVERRIDE;
|
|
|
|
|
2013-08-12 12:32:53 +04:00
|
|
|
void GetAddress(nsString& aAddress) const
|
2013-08-12 12:32:53 +04:00
|
|
|
{
|
2013-08-12 12:32:53 +04:00
|
|
|
aAddress = mAddress;
|
2013-08-12 12:32:53 +04:00
|
|
|
}
|
|
|
|
|
2013-08-12 12:32:53 +04: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;
|
|
|
|
}
|
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
void GetDevices(JSContext* aContext, JS::MutableHandle<JS::Value> aDevices,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids,
|
|
|
|
ErrorResult& aRv);
|
2013-08-12 12:32:53 +04:00
|
|
|
|
|
|
|
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 13:19:31 +04:00
|
|
|
Pair(const nsAString& aDeviceAddress, ErrorResult& aRv);
|
2013-08-12 12:32:53 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
2013-11-15 13:19:31 +04:00
|
|
|
Unpair(const nsAString& aDeviceAddress, ErrorResult& aRv);
|
2013-08-12 12:32:53 +04: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 15:19:46 +04:00
|
|
|
Connect(BluetoothDevice& aDevice,
|
2014-08-26 14:50:35 +04:00
|
|
|
const Optional<uint16_t>& aServiceUuid, ErrorResult& aRv);
|
2013-08-12 12:32:53 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
2013-09-06 15:19:46 +04:00
|
|
|
Disconnect(BluetoothDevice& aDevice,
|
2014-08-26 14:50:35 +04:00
|
|
|
const Optional<uint16_t>& aServiceUuid,
|
2013-09-06 15:19:46 +04:00
|
|
|
ErrorResult& aRv);
|
2014-08-26 14:50:35 +04:00
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
IsConnected(const uint16_t aServiceUuid,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2013-08-12 12:32:53 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
2013-09-06 15:19:46 +04:00
|
|
|
GetConnectedDevices(uint16_t aServiceUuid, ErrorResult& aRv);
|
2013-08-12 12:32:53 +04: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 06:38:13 +04:00
|
|
|
already_AddRefed<DOMRequest> AnswerWaitingCall(ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest> IgnoreWaitingCall(ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest> ToggleCalls(ErrorResult& aRv);
|
|
|
|
|
2013-08-12 12:32:53 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SendMediaMetaData(const MediaMetaData& aMediaMetaData, ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
SendMediaPlayStatus(const MediaPlayStatus& aMediaPlayStatus, ErrorResult& aRv);
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(devicefound);
|
2014-05-23 10:00:14 +04:00
|
|
|
IMPL_EVENT_HANDLER(discoverystatechanged);
|
2013-08-12 12:32:53 +04:00
|
|
|
IMPL_EVENT_HANDLER(a2dpstatuschanged);
|
|
|
|
IMPL_EVENT_HANDLER(hfpstatuschanged);
|
|
|
|
IMPL_EVENT_HANDLER(pairedstatuschanged);
|
2013-09-04 06:40:01 +04:00
|
|
|
IMPL_EVENT_HANDLER(requestmediaplaystatus);
|
2013-08-12 12:32:53 +04:00
|
|
|
IMPL_EVENT_HANDLER(scostatuschanged);
|
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-08-12 20:08:03 +04:00
|
|
|
|
2013-08-12 12:32:53 +04:00
|
|
|
private:
|
2012-08-08 21:47:09 +04:00
|
|
|
BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
|
2012-06-02 22:23:16 +04:00
|
|
|
~BluetoothAdapter();
|
2012-07-18 07:41:54 +04:00
|
|
|
|
2012-08-01 08:53:04 +04:00
|
|
|
void Root();
|
2013-08-12 12:32:53 +04:00
|
|
|
|
|
|
|
already_AddRefed<mozilla::dom::DOMRequest>
|
|
|
|
StartStopDiscovery(bool aStart, ErrorResult& aRv);
|
|
|
|
already_AddRefed<mozilla::dom::DOMRequest>
|
2013-11-15 13:19:31 +04:00
|
|
|
PairUnpair(bool aPair, const nsAString& aDeviceAddress, ErrorResult& aRv);
|
2013-08-12 12:32:53 +04:00
|
|
|
|
|
|
|
JS::Heap<JSObject*> mJsUuids;
|
|
|
|
JS::Heap<JSObject*> mJsDeviceAddresses;
|
2012-07-18 07:41:54 +04:00
|
|
|
nsString mAddress;
|
|
|
|
nsString mName;
|
|
|
|
bool mDiscoverable;
|
|
|
|
bool mDiscovering;
|
|
|
|
bool mPairable;
|
|
|
|
bool mPowered;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mPairableTimeout;
|
|
|
|
uint32_t mDiscoverableTimeout;
|
|
|
|
uint32_t mClass;
|
2012-07-18 07:41:54 +04:00
|
|
|
nsTArray<nsString> mDeviceAddresses;
|
|
|
|
nsTArray<nsString> mUuids;
|
2012-08-01 08:53:04 +04:00
|
|
|
bool mIsRooted;
|
2012-02-20 19:15:19 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
2012-03-28 03:17:35 +04:00
|
|
|
|
2012-02-20 19:15:19 +04:00
|
|
|
#endif
|