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_bluetoothdevice_h__ michael@0: #define mozilla_dom_bluetooth_bluetoothdevice_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 "nsString.h" michael@0: michael@0: BEGIN_BLUETOOTH_NAMESPACE michael@0: michael@0: class BluetoothNamedValue; michael@0: class BluetoothValue; michael@0: class BluetoothSignal; michael@0: class BluetoothSocket; michael@0: michael@0: class BluetoothDevice : 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(BluetoothDevice, michael@0: DOMEventTargetHelper) michael@0: michael@0: static already_AddRefed michael@0: Create(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath, michael@0: const BluetoothValue& aValue); michael@0: michael@0: void Notify(const BluetoothSignal& aParam); michael@0: michael@0: void GetAddress(nsString& aAddress) const michael@0: { michael@0: aAddress = mAddress; michael@0: } michael@0: michael@0: void GetName(nsString& aName) const michael@0: { michael@0: aName = mName; michael@0: } michael@0: michael@0: void GetIcon(nsString& aIcon) const michael@0: { michael@0: aIcon = mIcon; michael@0: } michael@0: michael@0: uint32_t Class() const michael@0: { michael@0: return mClass; michael@0: } michael@0: michael@0: bool Paired() const michael@0: { michael@0: return mPaired; michael@0: } michael@0: michael@0: bool Connected() const michael@0: { michael@0: return mConnected; michael@0: } michael@0: michael@0: void GetUuids(JSContext* aContext, JS::MutableHandle aUuids, michael@0: ErrorResult& aRv); michael@0: void GetServices(JSContext* aContext, JS::MutableHandle aServices, michael@0: ErrorResult& aRv); michael@0: michael@0: nsISupports* michael@0: ToISupports() michael@0: { michael@0: return static_cast(this); michael@0: } michael@0: michael@0: void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE; michael@0: michael@0: void Unroot(); 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: virtual void DisconnectFromOwner() MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: BluetoothDevice(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath, michael@0: const BluetoothValue& aValue); michael@0: ~BluetoothDevice(); michael@0: void Root(); michael@0: michael@0: JS::Heap mJsUuids; michael@0: JS::Heap mJsServices; michael@0: michael@0: nsString mAdapterPath; michael@0: nsString mAddress; michael@0: nsString mName; michael@0: nsString mIcon; michael@0: uint32_t mClass; michael@0: bool mConnected; michael@0: bool mPaired; michael@0: bool mIsRooted; michael@0: nsTArray mUuids; michael@0: nsTArray mServices; michael@0: michael@0: }; michael@0: michael@0: END_BLUETOOTH_NAMESPACE michael@0: michael@0: #endif