2012-07-17 20:41:54 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-08-20 20:21:24 -07:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-07-17 20:41:54 -07: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_bluetoothdevice_h__
|
|
|
|
#define mozilla_dom_bluetooth_bluetoothdevice_h__
|
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-17 20:41:54 -07:00
|
|
|
#include "BluetoothCommon.h"
|
2012-07-31 21:53:04 -07:00
|
|
|
#include "BluetoothPropertyContainer.h"
|
2012-07-17 20:41:54 -07:00
|
|
|
#include "nsDOMEventTargetHelper.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
class BluetoothNamedValue;
|
2012-07-31 21:53:04 -07:00
|
|
|
class BluetoothValue;
|
2012-07-17 20:41:54 -07:00
|
|
|
class BluetoothSignal;
|
2012-09-05 20:06:20 -07:00
|
|
|
class BluetoothSocket;
|
2012-07-17 20:41:54 -07:00
|
|
|
|
|
|
|
class BluetoothDevice : public nsDOMEventTargetHelper
|
2012-07-31 21:53:04 -07:00
|
|
|
, public BluetoothSignalObserver
|
|
|
|
, public BluetoothPropertyContainer
|
2012-07-17 20:41:54 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2012-07-31 21:53:04 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothDevice,
|
|
|
|
nsDOMEventTargetHelper)
|
2012-07-17 20:41:54 -07:00
|
|
|
|
|
|
|
static already_AddRefed<BluetoothDevice>
|
2012-07-31 21:53:04 -07:00
|
|
|
Create(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
|
|
|
|
const BluetoothValue& aValue);
|
|
|
|
|
|
|
|
void Notify(const BluetoothSignal& aParam);
|
2012-07-17 20:41:54 -07:00
|
|
|
|
2013-08-12 01:34:28 -07:00
|
|
|
void GetAddress(nsString& aAddress) const
|
|
|
|
{
|
|
|
|
aAddress = mAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetName(nsString& aName) const
|
|
|
|
{
|
|
|
|
aName = mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetIcon(nsString& aIcon) const
|
|
|
|
{
|
|
|
|
aIcon = mIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Class() const
|
|
|
|
{
|
|
|
|
return mClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Paired() const
|
|
|
|
{
|
|
|
|
return mPaired;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Connected() const
|
|
|
|
{
|
|
|
|
return mConnected;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::Value GetUuids(JSContext* aContext, ErrorResult& aRv);
|
|
|
|
JS::Value GetServices(JSContext* aContext, ErrorResult& aRv);
|
|
|
|
|
2012-07-17 20:41:54 -07:00
|
|
|
nsISupports*
|
2013-04-19 15:18:33 -07:00
|
|
|
ToISupports()
|
2012-07-17 20:41:54 -07:00
|
|
|
{
|
2013-04-19 15:18:33 -07:00
|
|
|
return static_cast<EventTarget*>(this);
|
2012-07-17 20:41:54 -07:00
|
|
|
}
|
2012-07-31 21:53:04 -07:00
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
|
2012-07-31 21:53:04 -07:00
|
|
|
|
|
|
|
void Unroot();
|
2013-08-12 01:34:28 -07:00
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual JSObject*
|
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
|
|
|
|
2012-07-31 21:53:04 -07:00
|
|
|
private:
|
|
|
|
BluetoothDevice(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
|
|
|
|
const BluetoothValue& aValue);
|
|
|
|
~BluetoothDevice();
|
|
|
|
void Root();
|
2013-04-19 15:18:33 -07:00
|
|
|
|
2013-06-18 03:00:38 -07:00
|
|
|
JS::Heap<JSObject*> mJsUuids;
|
|
|
|
JS::Heap<JSObject*> mJsServices;
|
2012-07-31 21:53:04 -07:00
|
|
|
|
|
|
|
nsString mAdapterPath;
|
2012-07-17 20:41:54 -07:00
|
|
|
nsString mAddress;
|
|
|
|
nsString mName;
|
2012-08-29 20:15:35 -07:00
|
|
|
nsString mIcon;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mClass;
|
2012-07-17 20:41:54 -07:00
|
|
|
bool mConnected;
|
|
|
|
bool mPaired;
|
2012-07-31 21:53:04 -07:00
|
|
|
bool mIsRooted;
|
2012-07-17 20:41:54 -07:00
|
|
|
nsTArray<nsString> mUuids;
|
2012-09-05 20:06:20 -07:00
|
|
|
nsTArray<nsString> mServices;
|
|
|
|
|
2012-07-17 20:41:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|