dom/bluetooth/BluetoothDevice.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_bluetooth_bluetoothdevice_h__
     8 #define mozilla_dom_bluetooth_bluetoothdevice_h__
    10 #include "mozilla/Attributes.h"
    11 #include "mozilla/DOMEventTargetHelper.h"
    12 #include "BluetoothCommon.h"
    13 #include "BluetoothPropertyContainer.h"
    14 #include "nsString.h"
    16 BEGIN_BLUETOOTH_NAMESPACE
    18 class BluetoothNamedValue;
    19 class BluetoothValue;
    20 class BluetoothSignal;
    21 class BluetoothSocket;
    23 class BluetoothDevice : public DOMEventTargetHelper
    24                       , public BluetoothSignalObserver
    25                       , public BluetoothPropertyContainer
    26 {
    27 public:
    28   NS_DECL_ISUPPORTS_INHERITED
    30   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothDevice,
    31                                                          DOMEventTargetHelper)
    33   static already_AddRefed<BluetoothDevice>
    34   Create(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
    35          const BluetoothValue& aValue);
    37   void Notify(const BluetoothSignal& aParam);
    39   void GetAddress(nsString& aAddress) const
    40   {
    41     aAddress = mAddress;
    42   }
    44   void GetName(nsString& aName) const
    45   {
    46     aName = mName;
    47   }
    49   void GetIcon(nsString& aIcon) const
    50   {
    51     aIcon = mIcon;
    52   }
    54   uint32_t Class() const
    55   {
    56     return mClass;
    57   }
    59   bool Paired() const
    60   {
    61     return mPaired;
    62   }
    64   bool Connected() const
    65   {
    66     return mConnected;
    67   }
    69   void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids,
    70                 ErrorResult& aRv);
    71   void GetServices(JSContext* aContext, JS::MutableHandle<JS::Value> aServices,
    72                    ErrorResult& aRv);
    74   nsISupports*
    75   ToISupports()
    76   {
    77     return static_cast<EventTarget*>(this);
    78   }
    80   void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
    82   void Unroot();
    84   nsPIDOMWindow* GetParentObject() const
    85   {
    86      return GetOwner();
    87   }
    89   virtual JSObject*
    90     WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    92   virtual void DisconnectFromOwner() MOZ_OVERRIDE;
    94 private:
    95   BluetoothDevice(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
    96                   const BluetoothValue& aValue);
    97   ~BluetoothDevice();
    98   void Root();
   100   JS::Heap<JSObject*> mJsUuids;
   101   JS::Heap<JSObject*> mJsServices;
   103   nsString mAdapterPath;
   104   nsString mAddress;
   105   nsString mName;
   106   nsString mIcon;
   107   uint32_t mClass;
   108   bool mConnected;
   109   bool mPaired;
   110   bool mIsRooted;
   111   nsTArray<nsString> mUuids;
   112   nsTArray<nsString> mServices;
   114 };
   116 END_BLUETOOTH_NAMESPACE
   118 #endif

mercurial