Thu, 22 Jan 2015 13:21:57 +0100
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_bluetoothprofilemanagerbase_h__
8 #define mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__
10 /**
11 * Error Messages used in Bluetooth profiles
12 *
13 * These error messages would be sent to Gaia as an argument of onError event.
14 */
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"
23 #define ERR_OPERATION_TIMEOUT "OperationTimeout"
25 #include "BluetoothCommon.h"
26 #include "nsIObserver.h"
28 BEGIN_BLUETOOTH_NAMESPACE
29 class BluetoothProfileController;
31 class BluetoothProfileManagerBase : public nsIObserver
32 {
33 public:
34 virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
35 const nsAString& aServiceUuid,
36 int aChannel) = 0;
37 virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) = 0;
39 /**
40 * Returns the address of the connected device.
41 */
42 virtual void GetAddress(nsAString& aDeviceAddress) = 0;
44 /**
45 * Returns true if the profile is connected.
46 */
47 virtual bool IsConnected() = 0;
49 /**
50 * Connect to a specific remote device. When it has been done, the
51 * callback "OnConnect" will be invoked.
52 */
53 virtual void Connect(const nsAString& aDeviceAddress,
54 BluetoothProfileController* aController) = 0;
56 /**
57 * Close the socket and then invoke the callback "OnDisconnect".
58 */
59 virtual void Disconnect(BluetoothProfileController* aController) = 0;
61 /**
62 * If it establishes/releases a connection successfully, the error string
63 * will be empty. Otherwise, the error string shows the failure reason.
64 */
65 virtual void OnConnect(const nsAString& aErrorStr) = 0;
66 virtual void OnDisconnect(const nsAString& aErrorStr) = 0;
68 /**
69 * Clean up profile resources and set mController as null.
70 */
71 virtual void Reset() = 0;
73 /**
74 * Returns string of profile name.
75 */
76 virtual void GetName(nsACString& aName) = 0;
77 };
79 #define BT_DECL_PROFILE_MGR_BASE \
80 public: \
81 NS_DECL_ISUPPORTS \
82 NS_DECL_NSIOBSERVER \
83 virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \
84 const nsAString& aServiceUuid, \
85 int aChannel) MOZ_OVERRIDE; \
86 virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE; \
87 virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE; \
88 virtual bool IsConnected() MOZ_OVERRIDE; \
89 virtual void Connect(const nsAString& aDeviceAddress, \
90 BluetoothProfileController* aController) MOZ_OVERRIDE; \
91 virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE; \
92 virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE; \
93 virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE; \
94 virtual void Reset() MOZ_OVERRIDE;
96 END_BLUETOOTH_NAMESPACE
98 #endif //#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__