dom/bluetooth/BluetoothDevice.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/bluetooth/BluetoothDevice.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,118 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_bluetooth_bluetoothdevice_h__
    1.11 +#define mozilla_dom_bluetooth_bluetoothdevice_h__
    1.12 +
    1.13 +#include "mozilla/Attributes.h"
    1.14 +#include "mozilla/DOMEventTargetHelper.h"
    1.15 +#include "BluetoothCommon.h"
    1.16 +#include "BluetoothPropertyContainer.h"
    1.17 +#include "nsString.h"
    1.18 +
    1.19 +BEGIN_BLUETOOTH_NAMESPACE
    1.20 +
    1.21 +class BluetoothNamedValue;
    1.22 +class BluetoothValue;
    1.23 +class BluetoothSignal;
    1.24 +class BluetoothSocket;
    1.25 +
    1.26 +class BluetoothDevice : public DOMEventTargetHelper
    1.27 +                      , public BluetoothSignalObserver
    1.28 +                      , public BluetoothPropertyContainer
    1.29 +{
    1.30 +public:
    1.31 +  NS_DECL_ISUPPORTS_INHERITED
    1.32 +
    1.33 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothDevice,
    1.34 +                                                         DOMEventTargetHelper)
    1.35 +
    1.36 +  static already_AddRefed<BluetoothDevice>
    1.37 +  Create(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
    1.38 +         const BluetoothValue& aValue);
    1.39 +
    1.40 +  void Notify(const BluetoothSignal& aParam);
    1.41 +
    1.42 +  void GetAddress(nsString& aAddress) const
    1.43 +  {
    1.44 +    aAddress = mAddress;
    1.45 +  }
    1.46 +
    1.47 +  void GetName(nsString& aName) const
    1.48 +  {
    1.49 +    aName = mName;
    1.50 +  }
    1.51 +
    1.52 +  void GetIcon(nsString& aIcon) const
    1.53 +  {
    1.54 +    aIcon = mIcon;
    1.55 +  }
    1.56 +
    1.57 +  uint32_t Class() const
    1.58 +  {
    1.59 +    return mClass;
    1.60 +  }
    1.61 +
    1.62 +  bool Paired() const
    1.63 +  {
    1.64 +    return mPaired;
    1.65 +  }
    1.66 +
    1.67 +  bool Connected() const
    1.68 +  {
    1.69 +    return mConnected;
    1.70 +  }
    1.71 +
    1.72 +  void GetUuids(JSContext* aContext, JS::MutableHandle<JS::Value> aUuids,
    1.73 +                ErrorResult& aRv);
    1.74 +  void GetServices(JSContext* aContext, JS::MutableHandle<JS::Value> aServices,
    1.75 +                   ErrorResult& aRv);
    1.76 +
    1.77 +  nsISupports*
    1.78 +  ToISupports()
    1.79 +  {
    1.80 +    return static_cast<EventTarget*>(this);
    1.81 +  }
    1.82 +
    1.83 +  void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
    1.84 +
    1.85 +  void Unroot();
    1.86 +
    1.87 +  nsPIDOMWindow* GetParentObject() const
    1.88 +  {
    1.89 +     return GetOwner();
    1.90 +  }
    1.91 +
    1.92 +  virtual JSObject*
    1.93 +    WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.94 +
    1.95 +  virtual void DisconnectFromOwner() MOZ_OVERRIDE;
    1.96 +
    1.97 +private:
    1.98 +  BluetoothDevice(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
    1.99 +                  const BluetoothValue& aValue);
   1.100 +  ~BluetoothDevice();
   1.101 +  void Root();
   1.102 +
   1.103 +  JS::Heap<JSObject*> mJsUuids;
   1.104 +  JS::Heap<JSObject*> mJsServices;
   1.105 +
   1.106 +  nsString mAdapterPath;
   1.107 +  nsString mAddress;
   1.108 +  nsString mName;
   1.109 +  nsString mIcon;
   1.110 +  uint32_t mClass;
   1.111 +  bool mConnected;
   1.112 +  bool mPaired;
   1.113 +  bool mIsRooted;
   1.114 +  nsTArray<nsString> mUuids;
   1.115 +  nsTArray<nsString> mServices;
   1.116 +
   1.117 +};
   1.118 +
   1.119 +END_BLUETOOTH_NAMESPACE
   1.120 +
   1.121 +#endif

mercurial