dom/bluetooth/BluetoothProfileManagerBase.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__
michael@0 8 #define mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__
michael@0 9
michael@0 10 /**
michael@0 11 * Error Messages used in Bluetooth profiles
michael@0 12 *
michael@0 13 * These error messages would be sent to Gaia as an argument of onError event.
michael@0 14 */
michael@0 15 #define ERR_ALREADY_CONNECTED "AlreadyConnectedError"
michael@0 16 #define ERR_ALREADY_DISCONNECTED "AlreadyDisconnectedError"
michael@0 17 #define ERR_CONNECTION_FAILED "ConnectionFailedError"
michael@0 18 #define ERR_DISCONNECTION_FAILED "DisconnectionFailedError"
michael@0 19 #define ERR_NO_AVAILABLE_RESOURCE "NoAvailableResourceError"
michael@0 20 #define ERR_REACHED_CONNECTION_LIMIT "ReachedConnectionLimitError"
michael@0 21 #define ERR_SERVICE_CHANNEL_NOT_FOUND "DeviceChannelRetrievalError"
michael@0 22 #define ERR_UNKNOWN_PROFILE "UnknownProfileError"
michael@0 23 #define ERR_OPERATION_TIMEOUT "OperationTimeout"
michael@0 24
michael@0 25 #include "BluetoothCommon.h"
michael@0 26 #include "nsIObserver.h"
michael@0 27
michael@0 28 BEGIN_BLUETOOTH_NAMESPACE
michael@0 29 class BluetoothProfileController;
michael@0 30
michael@0 31 class BluetoothProfileManagerBase : public nsIObserver
michael@0 32 {
michael@0 33 public:
michael@0 34 virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
michael@0 35 const nsAString& aServiceUuid,
michael@0 36 int aChannel) = 0;
michael@0 37 virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) = 0;
michael@0 38
michael@0 39 /**
michael@0 40 * Returns the address of the connected device.
michael@0 41 */
michael@0 42 virtual void GetAddress(nsAString& aDeviceAddress) = 0;
michael@0 43
michael@0 44 /**
michael@0 45 * Returns true if the profile is connected.
michael@0 46 */
michael@0 47 virtual bool IsConnected() = 0;
michael@0 48
michael@0 49 /**
michael@0 50 * Connect to a specific remote device. When it has been done, the
michael@0 51 * callback "OnConnect" will be invoked.
michael@0 52 */
michael@0 53 virtual void Connect(const nsAString& aDeviceAddress,
michael@0 54 BluetoothProfileController* aController) = 0;
michael@0 55
michael@0 56 /**
michael@0 57 * Close the socket and then invoke the callback "OnDisconnect".
michael@0 58 */
michael@0 59 virtual void Disconnect(BluetoothProfileController* aController) = 0;
michael@0 60
michael@0 61 /**
michael@0 62 * If it establishes/releases a connection successfully, the error string
michael@0 63 * will be empty. Otherwise, the error string shows the failure reason.
michael@0 64 */
michael@0 65 virtual void OnConnect(const nsAString& aErrorStr) = 0;
michael@0 66 virtual void OnDisconnect(const nsAString& aErrorStr) = 0;
michael@0 67
michael@0 68 /**
michael@0 69 * Clean up profile resources and set mController as null.
michael@0 70 */
michael@0 71 virtual void Reset() = 0;
michael@0 72
michael@0 73 /**
michael@0 74 * Returns string of profile name.
michael@0 75 */
michael@0 76 virtual void GetName(nsACString& aName) = 0;
michael@0 77 };
michael@0 78
michael@0 79 #define BT_DECL_PROFILE_MGR_BASE \
michael@0 80 public: \
michael@0 81 NS_DECL_ISUPPORTS \
michael@0 82 NS_DECL_NSIOBSERVER \
michael@0 83 virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \
michael@0 84 const nsAString& aServiceUuid, \
michael@0 85 int aChannel) MOZ_OVERRIDE; \
michael@0 86 virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE; \
michael@0 87 virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE; \
michael@0 88 virtual bool IsConnected() MOZ_OVERRIDE; \
michael@0 89 virtual void Connect(const nsAString& aDeviceAddress, \
michael@0 90 BluetoothProfileController* aController) MOZ_OVERRIDE; \
michael@0 91 virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE; \
michael@0 92 virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE; \
michael@0 93 virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE; \
michael@0 94 virtual void Reset() MOZ_OVERRIDE;
michael@0 95
michael@0 96 END_BLUETOOTH_NAMESPACE
michael@0 97
michael@0 98 #endif //#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__

mercurial