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_bluetoothprofilemanagerbase_h__
8 #define mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__
11 * Error Messages used in Bluetooth profiles
13 * These error messages would be sent to Gaia as an argument of onError event.
15 #define ERR_ALREADY_CONNECTED "AlreadyConnectedError"
16 #define ERR_ALREADY_DISCONNECTED "AlreadyDisconnectedError"
17 #define ERR_CONNECTION_FAILED "ConnectionFailedError"
18 #define ERR_DISCONNECTION_FAILED "DisconnectionFailedError"
19 #define ERR_NO_AVAILABLE_RESOURCE "NoAvailableResourceError"
20 #define ERR_REACHED_CONNECTION_LIMIT "ReachedConnectionLimitError"
21 #define ERR_SERVICE_CHANNEL_NOT_FOUND "DeviceChannelRetrievalError"
22 #define ERR_UNKNOWN_PROFILE "UnknownProfileError"
24 #include "BluetoothCommon.h"
25 #include "nsIObserver.h"
27 BEGIN_BLUETOOTH_NAMESPACE
28 class BluetoothProfileController
;
30 class BluetoothProfileManagerBase
: public nsIObserver
33 virtual void OnGetServiceChannel(const nsAString
& aDeviceAddress
,
34 const nsAString
& aServiceUuid
,
36 virtual void OnUpdateSdpRecords(const nsAString
& aDeviceAddress
) = 0;
39 * Returns the address of the connected device.
41 virtual void GetAddress(nsAString
& aDeviceAddress
) = 0;
44 * Returns true if the profile is connected.
46 virtual bool IsConnected() = 0;
49 * Connect to a specific remote device. When it has been done, the
50 * callback "OnConnect" will be invoked.
52 virtual void Connect(const nsAString
& aDeviceAddress
,
53 BluetoothProfileController
* aController
) = 0;
56 * Close the socket and then invoke the callback "OnDisconnect".
58 virtual void Disconnect(BluetoothProfileController
* aController
) = 0;
61 * If it establishes/releases a connection successfully, the error string
62 * will be empty. Otherwise, the error string shows the failure reason.
64 virtual void OnConnect(const nsAString
& aErrorStr
) = 0;
65 virtual void OnDisconnect(const nsAString
& aErrorStr
) = 0;
68 * Returns string of profile name
70 virtual void GetName(nsACString
& aName
) = 0;
73 #define BT_DECL_PROFILE_MGR_BASE \
75 virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \
76 const nsAString& aServiceUuid, \
77 int aChannel) MOZ_OVERRIDE; \
78 virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE; \
79 virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE; \
80 virtual bool IsConnected() MOZ_OVERRIDE; \
81 virtual void Connect(const nsAString& aDeviceAddress, \
82 BluetoothProfileController* aController) MOZ_OVERRIDE; \
83 virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE; \
84 virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE; \
85 virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE; \
87 END_BLUETOOTH_NAMESPACE
89 #endif //#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__