1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bluetooth/bluez/BluetoothDBusService.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,205 @@ 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_bluetoothdbusservice_h__ 1.11 +#define mozilla_dom_bluetooth_bluetoothdbusservice_h__ 1.12 + 1.13 +#include "mozilla/Attributes.h" 1.14 +#include "BluetoothCommon.h" 1.15 +#include "mozilla/ipc/RawDBusConnection.h" 1.16 +#include "BluetoothService.h" 1.17 +#include "nsIThread.h" 1.18 + 1.19 +class DBusMessage; 1.20 + 1.21 +BEGIN_BLUETOOTH_NAMESPACE 1.22 + 1.23 +/** 1.24 + * BluetoothDBusService is the implementation of BluetoothService for DBus on 1.25 + * linux/android/B2G. Function comments are in BluetoothService.h 1.26 + */ 1.27 + 1.28 +class BluetoothDBusService : public BluetoothService 1.29 +{ 1.30 +public: 1.31 + /** 1.32 + * For DBus Control method of "UpdateNotification", event id should be 1.33 + * specified as following: 1.34 + * (Please see specification of AVRCP 1.3, Table 5.28 for more details.) 1.35 + */ 1.36 + enum ControlEventId { 1.37 + EVENT_PLAYBACK_STATUS_CHANGED = 0x01, 1.38 + EVENT_TRACK_CHANGED = 0x02, 1.39 + EVENT_TRACK_REACHED_END = 0x03, 1.40 + EVENT_TRACK_REACHED_START = 0x04, 1.41 + EVENT_PLAYBACK_POS_CHANGED = 0x05, 1.42 + EVENT_BATT_STATUS_CHANGED = 0x06, 1.43 + EVENT_SYSTEM_STATUS_CHANGED = 0x07, 1.44 + EVENT_PLAYER_APPLICATION_SETTING_CHANGED = 0x08, 1.45 + EVENT_UNKNOWN 1.46 + }; 1.47 + 1.48 + BluetoothDBusService(); 1.49 + ~BluetoothDBusService(); 1.50 + 1.51 + bool IsReady(); 1.52 + 1.53 + virtual nsresult StartInternal() MOZ_OVERRIDE; 1.54 + 1.55 + virtual nsresult StopInternal() MOZ_OVERRIDE; 1.56 + 1.57 + virtual nsresult GetDefaultAdapterPathInternal( 1.58 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.59 + 1.60 + virtual nsresult GetConnectedDevicePropertiesInternal(uint16_t aServiceUuid, 1.61 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.62 + 1.63 + virtual nsresult GetPairedDevicePropertiesInternal( 1.64 + const nsTArray<nsString>& aDeviceAddresses, 1.65 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.66 + 1.67 + virtual nsresult StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.68 + 1.69 + virtual nsresult StopDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.70 + 1.71 + virtual nsresult 1.72 + SetProperty(BluetoothObjectType aType, 1.73 + const BluetoothNamedValue& aValue, 1.74 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.75 + 1.76 + virtual nsresult 1.77 + GetServiceChannel(const nsAString& aDeviceAddress, 1.78 + const nsAString& aServiceUuid, 1.79 + BluetoothProfileManagerBase* aManager) MOZ_OVERRIDE; 1.80 + 1.81 + virtual bool 1.82 + UpdateSdpRecords(const nsAString& aDeviceAddress, 1.83 + BluetoothProfileManagerBase* aManager) MOZ_OVERRIDE; 1.84 + 1.85 + virtual nsresult 1.86 + CreatePairedDeviceInternal(const nsAString& aDeviceAddress, 1.87 + int aTimeout, 1.88 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.89 + 1.90 + virtual nsresult 1.91 + RemoveDeviceInternal(const nsAString& aDeviceObjectPath, 1.92 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.93 + 1.94 + virtual bool 1.95 + SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode, 1.96 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.97 + 1.98 + virtual bool 1.99 + SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey, 1.100 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.101 + 1.102 + virtual bool 1.103 + SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm, 1.104 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.105 + 1.106 + virtual void 1.107 + Connect(const nsAString& aDeviceAddress, 1.108 + uint32_t aCod, 1.109 + uint16_t aServiceUuid, 1.110 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.111 + 1.112 + virtual bool 1.113 + IsConnected(uint16_t aServiceUuid) MOZ_OVERRIDE; 1.114 + 1.115 + virtual void 1.116 + Disconnect(const nsAString& aDeviceAddress, uint16_t aServiceUuid, 1.117 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.118 + 1.119 + virtual void 1.120 + SendFile(const nsAString& aDeviceAddress, 1.121 + BlobParent* aBlobParent, 1.122 + BlobChild* aBlobChild, 1.123 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.124 + 1.125 + virtual void 1.126 + SendFile(const nsAString& aDeviceAddress, 1.127 + nsIDOMBlob* aBlob, 1.128 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.129 + 1.130 + virtual void 1.131 + StopSendingFile(const nsAString& aDeviceAddress, 1.132 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.133 + 1.134 + virtual void 1.135 + ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm, 1.136 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.137 + 1.138 + virtual void 1.139 + ConnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.140 + 1.141 + virtual void 1.142 + DisconnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.143 + 1.144 + virtual void 1.145 + IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.146 + 1.147 +#ifdef MOZ_B2G_RIL 1.148 + virtual void 1.149 + AnswerWaitingCall(BluetoothReplyRunnable* aRunnable); 1.150 + 1.151 + virtual void 1.152 + IgnoreWaitingCall(BluetoothReplyRunnable* aRunnable); 1.153 + 1.154 + virtual void 1.155 + ToggleCalls(BluetoothReplyRunnable* aRunnable); 1.156 +#endif 1.157 + 1.158 + virtual void 1.159 + SendMetaData(const nsAString& aTitle, 1.160 + const nsAString& aArtist, 1.161 + const nsAString& aAlbum, 1.162 + int64_t aMediaNumber, 1.163 + int64_t aTotalMediaCount, 1.164 + int64_t aDuration, 1.165 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.166 + 1.167 + virtual void 1.168 + SendPlayStatus(int64_t aDuration, 1.169 + int64_t aPosition, 1.170 + const nsAString& aPlayStatus, 1.171 + BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; 1.172 + 1.173 + virtual void 1.174 + UpdatePlayStatus(uint32_t aDuration, 1.175 + uint32_t aPosition, 1.176 + ControlPlayStatus aPlayStatus) MOZ_OVERRIDE; 1.177 + 1.178 + virtual nsresult 1.179 + SendSinkMessage(const nsAString& aDeviceAddresses, 1.180 + const nsAString& aMessage) MOZ_OVERRIDE; 1.181 + 1.182 + virtual nsresult 1.183 + SendInputMessage(const nsAString& aDeviceAddresses, 1.184 + const nsAString& aMessage) MOZ_OVERRIDE; 1.185 +private: 1.186 + nsresult SendGetPropertyMessage(const nsAString& aPath, 1.187 + const char* aInterface, 1.188 + void (*aCB)(DBusMessage *, void *), 1.189 + BluetoothReplyRunnable* aRunnable); 1.190 + 1.191 + nsresult SendDiscoveryMessage(const char* aMessageName, 1.192 + BluetoothReplyRunnable* aRunnable); 1.193 + 1.194 + nsresult SendSetPropertyMessage(const char* aInterface, 1.195 + const BluetoothNamedValue& aValue, 1.196 + BluetoothReplyRunnable* aRunnable); 1.197 + 1.198 + void UpdateNotification(ControlEventId aEventId, uint64_t aData); 1.199 + 1.200 + nsresult SendAsyncDBusMessage(const nsAString& aObjectPath, 1.201 + const char* aInterface, 1.202 + const nsAString& aMessage, 1.203 + mozilla::ipc::DBusReplyCallback aCallback); 1.204 +}; 1.205 + 1.206 +END_BLUETOOTH_NAMESPACE 1.207 + 1.208 +#endif