Bumping manifests a=b2g-bump
[gecko.git] / dom / bluetooth2 / BluetoothProfileManagerBase.h
blobc63b7dfbe3123f394b9399bf699a61ac3baafe66
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
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"
23 #define ERR_OPERATION_TIMEOUT "OperationTimeout"
25 #include "BluetoothCommon.h"
26 #include "nsIObserver.h"
28 BEGIN_BLUETOOTH_NAMESPACE
29 class BluetoothProfileController;
31 class BluetoothProfileResultHandler
33 public:
34 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BluetoothProfileResultHandler);
36 virtual ~BluetoothProfileResultHandler() { }
38 virtual void OnError(nsresult aResult) { }
39 virtual void Init() { }
40 virtual void Deinit() { }
43 class BluetoothProfileManagerBase : public nsIObserver
45 public:
46 virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
47 const nsAString& aServiceUuid,
48 int aChannel) = 0;
49 virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) = 0;
51 /**
52 * Returns the address of the connected device.
54 virtual void GetAddress(nsAString& aDeviceAddress) = 0;
56 /**
57 * Returns true if the profile is connected.
59 virtual bool IsConnected() = 0;
61 /**
62 * Connect to a specific remote device. When it has been done, the
63 * callback "OnConnect" will be invoked.
65 virtual void Connect(const nsAString& aDeviceAddress,
66 BluetoothProfileController* aController) = 0;
68 /**
69 * Close the socket and then invoke the callback "OnDisconnect".
71 virtual void Disconnect(BluetoothProfileController* aController) = 0;
73 /**
74 * If it establishes/releases a connection successfully, the error string
75 * will be empty. Otherwise, the error string shows the failure reason.
77 virtual void OnConnect(const nsAString& aErrorStr) = 0;
78 virtual void OnDisconnect(const nsAString& aErrorStr) = 0;
80 /**
81 * Clean up profile resources and set mController as null.
83 virtual void Reset() = 0;
85 /**
86 * Returns string of profile name.
88 virtual void GetName(nsACString& aName) = 0;
91 #define BT_DECL_PROFILE_MGR_BASE \
92 public: \
93 NS_DECL_ISUPPORTS \
94 NS_DECL_NSIOBSERVER \
95 virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \
96 const nsAString& aServiceUuid, \
97 int aChannel) MOZ_OVERRIDE; \
98 virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE; \
99 virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE; \
100 virtual bool IsConnected() MOZ_OVERRIDE; \
101 virtual void Connect(const nsAString& aDeviceAddress, \
102 BluetoothProfileController* aController) MOZ_OVERRIDE; \
103 virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE; \
104 virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE; \
105 virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE; \
106 virtual void Reset() MOZ_OVERRIDE;
108 END_BLUETOOTH_NAMESPACE
110 #endif //#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__