dom/bluetooth/bluez/BluetoothDBusService.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_bluetoothdbusservice_h__
     8 #define mozilla_dom_bluetooth_bluetoothdbusservice_h__
    10 #include "mozilla/Attributes.h"
    11 #include "BluetoothCommon.h"
    12 #include "mozilla/ipc/RawDBusConnection.h"
    13 #include "BluetoothService.h"
    14 #include "nsIThread.h"
    16 class DBusMessage;
    18 BEGIN_BLUETOOTH_NAMESPACE
    20 /**
    21  * BluetoothDBusService is the implementation of BluetoothService for DBus on
    22  * linux/android/B2G. Function comments are in BluetoothService.h
    23  */
    25 class BluetoothDBusService : public BluetoothService
    26 {
    27 public:
    28   /**
    29    * For DBus Control method of "UpdateNotification", event id should be
    30    * specified as following:
    31    * (Please see specification of AVRCP 1.3, Table 5.28 for more details.)
    32    */
    33   enum ControlEventId {
    34     EVENT_PLAYBACK_STATUS_CHANGED            = 0x01,
    35     EVENT_TRACK_CHANGED                      = 0x02,
    36     EVENT_TRACK_REACHED_END                  = 0x03,
    37     EVENT_TRACK_REACHED_START                = 0x04,
    38     EVENT_PLAYBACK_POS_CHANGED               = 0x05,
    39     EVENT_BATT_STATUS_CHANGED                = 0x06,
    40     EVENT_SYSTEM_STATUS_CHANGED              = 0x07,
    41     EVENT_PLAYER_APPLICATION_SETTING_CHANGED = 0x08,
    42     EVENT_UNKNOWN
    43   };
    45   BluetoothDBusService();
    46   ~BluetoothDBusService();
    48   bool IsReady();
    50   virtual nsresult StartInternal() MOZ_OVERRIDE;
    52   virtual nsresult StopInternal() MOZ_OVERRIDE;
    54   virtual nsresult GetDefaultAdapterPathInternal(
    55                                              BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    57   virtual nsresult GetConnectedDevicePropertiesInternal(uint16_t aServiceUuid,
    58                                              BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    60   virtual nsresult GetPairedDevicePropertiesInternal(
    61                                      const nsTArray<nsString>& aDeviceAddresses,
    62                                      BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    64   virtual nsresult StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    66   virtual nsresult StopDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    68   virtual nsresult
    69   SetProperty(BluetoothObjectType aType,
    70               const BluetoothNamedValue& aValue,
    71               BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    73   virtual nsresult
    74   GetServiceChannel(const nsAString& aDeviceAddress,
    75                     const nsAString& aServiceUuid,
    76                     BluetoothProfileManagerBase* aManager) MOZ_OVERRIDE;
    78   virtual bool
    79   UpdateSdpRecords(const nsAString& aDeviceAddress,
    80                    BluetoothProfileManagerBase* aManager) MOZ_OVERRIDE;
    82   virtual nsresult
    83   CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
    84                              int aTimeout,
    85                              BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    87   virtual nsresult
    88   RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
    89                        BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    91   virtual bool
    92   SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
    93                      BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    95   virtual bool
    96   SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
    97                      BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
    99   virtual bool
   100   SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
   101                                  BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   103   virtual void
   104   Connect(const nsAString& aDeviceAddress,
   105           uint32_t aCod,
   106           uint16_t aServiceUuid,
   107           BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   109   virtual bool
   110   IsConnected(uint16_t aServiceUuid) MOZ_OVERRIDE;
   112   virtual void
   113   Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid,
   114              BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   116   virtual void
   117   SendFile(const nsAString& aDeviceAddress,
   118            BlobParent* aBlobParent,
   119            BlobChild* aBlobChild,
   120            BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   122   virtual void
   123   SendFile(const nsAString& aDeviceAddress,
   124            nsIDOMBlob* aBlob,
   125            BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   127   virtual void
   128   StopSendingFile(const nsAString& aDeviceAddress,
   129                   BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   131   virtual void
   132   ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
   133                        BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   135   virtual void
   136   ConnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   138   virtual void
   139   DisconnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   141   virtual void
   142   IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   144 #ifdef MOZ_B2G_RIL
   145   virtual void
   146   AnswerWaitingCall(BluetoothReplyRunnable* aRunnable);
   148   virtual void
   149   IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable);
   151   virtual void
   152   ToggleCalls(BluetoothReplyRunnable* aRunnable);
   153 #endif
   155   virtual void
   156   SendMetaData(const nsAString& aTitle,
   157                const nsAString& aArtist,
   158                const nsAString& aAlbum,
   159                int64_t aMediaNumber,
   160                int64_t aTotalMediaCount,
   161                int64_t aDuration,
   162                BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   164   virtual void
   165   SendPlayStatus(int64_t aDuration,
   166                  int64_t aPosition,
   167                  const nsAString& aPlayStatus,
   168                  BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
   170   virtual void
   171   UpdatePlayStatus(uint32_t aDuration,
   172                    uint32_t aPosition,
   173                    ControlPlayStatus aPlayStatus) MOZ_OVERRIDE;
   175   virtual nsresult
   176   SendSinkMessage(const nsAString& aDeviceAddresses,
   177                   const nsAString& aMessage) MOZ_OVERRIDE;
   179   virtual nsresult
   180   SendInputMessage(const nsAString& aDeviceAddresses,
   181                    const nsAString& aMessage) MOZ_OVERRIDE;
   182 private:
   183   nsresult SendGetPropertyMessage(const nsAString& aPath,
   184                                   const char* aInterface,
   185                                   void (*aCB)(DBusMessage *, void *),
   186                                   BluetoothReplyRunnable* aRunnable);
   188   nsresult SendDiscoveryMessage(const char* aMessageName,
   189                                 BluetoothReplyRunnable* aRunnable);
   191   nsresult SendSetPropertyMessage(const char* aInterface,
   192                                   const BluetoothNamedValue& aValue,
   193                                   BluetoothReplyRunnable* aRunnable);
   195   void UpdateNotification(ControlEventId aEventId, uint64_t aData);
   197   nsresult SendAsyncDBusMessage(const nsAString& aObjectPath,
   198                                 const char* aInterface,
   199                                 const nsAString& aMessage,
   200                                 mozilla::ipc::DBusReplyCallback aCallback);
   201 };
   203 END_BLUETOOTH_NAMESPACE
   205 #endif

mercurial