2012-07-17 20:41:54 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-08-16 19:53:45 -07:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-07-17 20:41:54 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_bluetooth_bluetoothdbuseventservice_h__
|
|
|
|
#define mozilla_dom_bluetooth_bluetoothdbuseventservice_h__
|
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-17 20:41:54 -07:00
|
|
|
#include "BluetoothCommon.h"
|
|
|
|
#include "mozilla/ipc/RawDBusConnection.h"
|
|
|
|
#include "BluetoothService.h"
|
|
|
|
|
|
|
|
class DBusMessage;
|
|
|
|
|
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
/**
|
2012-07-31 21:49:59 -07:00
|
|
|
* BluetoothDBusService is the implementation of BluetoothService for DBus on
|
|
|
|
* linux/android/B2G. Function comments are in BluetoothService.h
|
2012-07-17 20:41:54 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
class BluetoothDBusService : public BluetoothService
|
|
|
|
, private mozilla::ipc::RawDBusConnection
|
|
|
|
{
|
|
|
|
public:
|
2012-11-30 01:46:55 -08:00
|
|
|
bool IsReady();
|
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
virtual nsresult StartInternal() MOZ_OVERRIDE;
|
2012-09-20 23:17:35 -07:00
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
virtual nsresult StopInternal() MOZ_OVERRIDE;
|
2012-09-20 23:17:35 -07:00
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
virtual bool IsEnabledInternal() MOZ_OVERRIDE;
|
2013-04-15 20:02:23 -07:00
|
|
|
|
2013-04-26 03:48:21 -07:00
|
|
|
virtual nsresult GetDefaultAdapterPathInternal(
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-09-20 23:17:35 -07:00
|
|
|
|
2013-04-26 03:48:21 -07:00
|
|
|
virtual nsresult GetConnectedDevicePropertiesInternal(uint16_t aProfileId,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2013-04-26 03:48:21 -07:00
|
|
|
|
|
|
|
virtual nsresult GetPairedDevicePropertiesInternal(
|
|
|
|
const nsTArray<nsString>& aDeviceAddresses,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-09-20 23:17:35 -07:00
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
virtual nsresult StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-09-20 23:17:35 -07:00
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
virtual nsresult StopDiscoveryInternal(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-09-20 23:17:35 -07:00
|
|
|
|
2012-09-16 23:39:47 -07:00
|
|
|
virtual nsresult
|
2012-07-31 21:49:59 -07:00
|
|
|
SetProperty(BluetoothObjectType aType,
|
|
|
|
const BluetoothNamedValue& aValue,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-09-20 23:17:35 -07:00
|
|
|
|
2012-07-31 21:49:59 -07:00
|
|
|
virtual bool
|
|
|
|
GetDevicePath(const nsAString& aAdapterPath,
|
|
|
|
const nsAString& aDeviceAddress,
|
2013-06-05 09:15:48 -07:00
|
|
|
nsAString& aDevicePath) MOZ_OVERRIDE;
|
2012-07-17 20:41:54 -07:00
|
|
|
|
2012-09-13 21:27:45 -07:00
|
|
|
static bool
|
2013-03-15 00:15:47 -07:00
|
|
|
AddReservedServicesInternal(const nsTArray<uint32_t>& aServices,
|
2012-09-07 00:56:12 -07:00
|
|
|
nsTArray<uint32_t>& aServiceHandlesContainer);
|
2012-08-09 20:17:06 -07:00
|
|
|
|
2012-09-13 21:27:45 -07:00
|
|
|
static bool
|
2013-03-15 00:15:47 -07:00
|
|
|
RemoveReservedServicesInternal(const nsTArray<uint32_t>& aServiceHandles);
|
2012-08-09 20:17:06 -07:00
|
|
|
|
2012-09-29 02:39:05 -07:00
|
|
|
virtual nsresult
|
|
|
|
GetScoSocket(const nsAString& aObjectPath,
|
|
|
|
bool aAuth,
|
|
|
|
bool aEncrypt,
|
2013-06-05 09:15:48 -07:00
|
|
|
mozilla::ipc::UnixSocketConsumer* aConsumer) MOZ_OVERRIDE;
|
2012-09-29 02:39:05 -07:00
|
|
|
|
2012-09-05 20:06:20 -07:00
|
|
|
virtual nsresult
|
2013-05-22 04:08:17 -07:00
|
|
|
GetServiceChannel(const nsAString& aDeviceAddress,
|
2013-05-09 23:39:12 -07:00
|
|
|
const nsAString& aServiceUuid,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothProfileManagerBase* aManager) MOZ_OVERRIDE;
|
2012-09-05 20:06:20 -07:00
|
|
|
|
2013-05-22 04:08:17 -07:00
|
|
|
virtual bool
|
|
|
|
UpdateSdpRecords(const nsAString& aDeviceAddress,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothProfileManagerBase* aManager) MOZ_OVERRIDE;
|
2013-05-22 04:08:17 -07:00
|
|
|
|
2012-08-17 03:35:59 -07:00
|
|
|
virtual nsresult
|
2013-03-15 00:15:47 -07:00
|
|
|
CreatePairedDeviceInternal(const nsAString& aDeviceAddress,
|
2012-08-17 03:35:59 -07:00
|
|
|
int aTimeout,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-08-17 03:35:59 -07:00
|
|
|
|
|
|
|
virtual nsresult
|
2013-03-15 00:15:47 -07:00
|
|
|
RemoveDeviceInternal(const nsAString& aDeviceObjectPath,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-08-17 03:35:59 -07:00
|
|
|
|
|
|
|
virtual bool
|
2012-09-19 16:37:42 -07:00
|
|
|
SetPinCodeInternal(const nsAString& aDeviceAddress, const nsAString& aPinCode,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-08-17 03:35:59 -07:00
|
|
|
|
|
|
|
virtual bool
|
2012-09-19 16:37:42 -07:00
|
|
|
SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-08-17 03:35:59 -07:00
|
|
|
|
2012-09-20 06:22:02 -07:00
|
|
|
virtual bool
|
2012-09-19 16:37:42 -07:00
|
|
|
SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-08-17 03:35:59 -07:00
|
|
|
|
2012-09-20 06:22:02 -07:00
|
|
|
virtual bool
|
2012-09-19 16:37:42 -07:00
|
|
|
SetAuthorizationInternal(const nsAString& aDeviceAddress, bool aAllow,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-08-17 03:35:59 -07:00
|
|
|
|
2012-11-16 02:46:08 -08:00
|
|
|
virtual void
|
2012-10-05 03:48:05 -07:00
|
|
|
Connect(const nsAString& aDeviceAddress,
|
|
|
|
const uint16_t aProfileId,
|
|
|
|
BluetoothReplyRunnable* aRunnable);
|
2012-09-29 03:26:46 -07:00
|
|
|
|
2012-11-07 10:12:41 -08:00
|
|
|
virtual bool
|
2013-06-05 09:15:48 -07:00
|
|
|
IsConnected(uint16_t aProfileId) MOZ_OVERRIDE;
|
2012-11-07 10:12:41 -08:00
|
|
|
|
2012-09-29 03:26:46 -07:00
|
|
|
virtual void
|
2012-10-05 03:48:05 -07:00
|
|
|
Disconnect(const uint16_t aProfileId, BluetoothReplyRunnable* aRunnable);
|
2012-09-29 03:26:46 -07:00
|
|
|
|
2012-11-02 18:36:43 -07:00
|
|
|
virtual void
|
2012-09-28 03:59:12 -07:00
|
|
|
SendFile(const nsAString& aDeviceAddress,
|
|
|
|
BlobParent* aBlobParent,
|
|
|
|
BlobChild* aBlobChild,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-09-28 03:59:12 -07:00
|
|
|
|
2012-11-02 18:36:43 -07:00
|
|
|
virtual void
|
2012-10-03 00:09:27 -07:00
|
|
|
StopSendingFile(const nsAString& aDeviceAddress,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-10-03 00:09:27 -07:00
|
|
|
|
2012-10-18 23:16:13 -07:00
|
|
|
virtual void
|
|
|
|
ConfirmReceivingFile(const nsAString& aDeviceAddress, bool aConfirm,
|
2013-06-05 09:15:48 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2012-10-18 23:16:13 -07:00
|
|
|
|
2013-05-10 03:58:59 -07:00
|
|
|
virtual void
|
2013-06-05 09:15:48 -07:00
|
|
|
ConnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2013-05-10 03:58:59 -07:00
|
|
|
|
|
|
|
virtual void
|
2013-06-05 09:15:48 -07:00
|
|
|
DisconnectSco(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2013-05-10 03:58:59 -07:00
|
|
|
|
|
|
|
virtual void
|
2013-06-05 09:15:48 -07:00
|
|
|
IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
2013-05-10 03:58:59 -07:00
|
|
|
|
2013-07-29 02:32:34 -07:00
|
|
|
virtual void
|
|
|
|
SendMetaData(const nsAString& aTitle,
|
|
|
|
const nsAString& aArtist,
|
|
|
|
const nsAString& aAlbum,
|
2013-07-29 02:32:35 -07:00
|
|
|
int64_t aMediaNumber,
|
|
|
|
int64_t aTotalMediaCount,
|
|
|
|
int64_t aDuration,
|
2013-07-29 02:32:34 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void
|
2013-07-29 02:32:35 -07:00
|
|
|
SendPlayStatus(int64_t aDuration,
|
|
|
|
int64_t aPosition,
|
2013-07-29 02:32:34 -07:00
|
|
|
const nsAString& aPlayStatus,
|
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
|
|
|
|
2013-07-29 02:32:34 -07:00
|
|
|
virtual void
|
|
|
|
UpdatePlayStatus(uint32_t aDuration,
|
|
|
|
uint32_t aPosition,
|
|
|
|
ControlPlayStatus aPlayStatus) MOZ_OVERRIDE;
|
|
|
|
|
2013-06-08 08:25:18 -07:00
|
|
|
virtual nsresult
|
|
|
|
SendSinkMessage(const nsAString& aDeviceAddresses,
|
|
|
|
const nsAString& aMessage) MOZ_OVERRIDE;
|
|
|
|
|
2013-08-12 02:32:25 -07:00
|
|
|
virtual nsresult
|
|
|
|
SendInputMessage(const nsAString& aDeviceAddresses,
|
|
|
|
const nsAString& aMessage,
|
|
|
|
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
|
|
|
|
|
2012-07-17 20:41:54 -07:00
|
|
|
private:
|
2013-07-29 02:32:34 -07:00
|
|
|
/**
|
|
|
|
* For DBus Control method of "UpdateNotification", event id should be
|
|
|
|
* specified as following:
|
|
|
|
* (Please see specification of AVRCP 1.3, Table 5.28 for more details.)
|
|
|
|
*/
|
|
|
|
enum ControlEventId {
|
|
|
|
EVENT_PLAYBACK_STATUS_CHANGED = 0x01,
|
|
|
|
EVENT_TRACK_CHANGED = 0x02,
|
|
|
|
EVENT_TRACK_REACHED_END = 0x03,
|
|
|
|
EVENT_TRACK_REACHED_START = 0x04,
|
|
|
|
EVENT_PLAYBACK_POS_CHANGED = 0x05,
|
|
|
|
EVENT_BATT_STATUS_CHANGED = 0x06,
|
|
|
|
EVENT_SYSTEM_STATUS_CHANGED = 0x07,
|
|
|
|
EVENT_PLAYER_APPLICATION_SETTING_CHANGED = 0x08,
|
|
|
|
EVENT_UNKNOWN
|
|
|
|
};
|
|
|
|
|
2012-07-31 21:49:59 -07:00
|
|
|
nsresult SendGetPropertyMessage(const nsAString& aPath,
|
|
|
|
const char* aInterface,
|
|
|
|
void (*aCB)(DBusMessage *, void *),
|
|
|
|
BluetoothReplyRunnable* aRunnable);
|
2013-07-29 02:32:34 -07:00
|
|
|
|
2013-03-15 00:15:47 -07:00
|
|
|
nsresult SendDiscoveryMessage(const char* aMessageName,
|
2012-07-17 20:41:54 -07:00
|
|
|
BluetoothReplyRunnable* aRunnable);
|
2013-07-29 02:32:34 -07:00
|
|
|
|
2013-03-15 00:15:47 -07:00
|
|
|
nsresult SendSetPropertyMessage(const char* aInterface,
|
2012-07-31 21:49:59 -07:00
|
|
|
const BluetoothNamedValue& aValue,
|
|
|
|
BluetoothReplyRunnable* aRunnable);
|
2013-02-14 07:16:37 -08:00
|
|
|
|
2013-07-29 02:32:34 -07:00
|
|
|
void UpdateNotification(ControlEventId aEventId, uint64_t aData);
|
|
|
|
|
2013-02-14 07:16:37 -08:00
|
|
|
void DisconnectAllAcls(const nsAString& aAdapterPath);
|
2013-07-29 02:32:34 -07:00
|
|
|
|
2012-07-17 20:41:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|