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