michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__ michael@0: #define mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__ michael@0: michael@0: /** michael@0: * Error Messages used in Bluetooth profiles michael@0: * michael@0: * These error messages would be sent to Gaia as an argument of onError event. michael@0: */ michael@0: #define ERR_ALREADY_CONNECTED "AlreadyConnectedError" michael@0: #define ERR_ALREADY_DISCONNECTED "AlreadyDisconnectedError" michael@0: #define ERR_CONNECTION_FAILED "ConnectionFailedError" michael@0: #define ERR_DISCONNECTION_FAILED "DisconnectionFailedError" michael@0: #define ERR_NO_AVAILABLE_RESOURCE "NoAvailableResourceError" michael@0: #define ERR_REACHED_CONNECTION_LIMIT "ReachedConnectionLimitError" michael@0: #define ERR_SERVICE_CHANNEL_NOT_FOUND "DeviceChannelRetrievalError" michael@0: #define ERR_UNKNOWN_PROFILE "UnknownProfileError" michael@0: #define ERR_OPERATION_TIMEOUT "OperationTimeout" michael@0: michael@0: #include "BluetoothCommon.h" michael@0: #include "nsIObserver.h" michael@0: michael@0: BEGIN_BLUETOOTH_NAMESPACE michael@0: class BluetoothProfileController; michael@0: michael@0: class BluetoothProfileManagerBase : public nsIObserver michael@0: { michael@0: public: michael@0: virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, michael@0: const nsAString& aServiceUuid, michael@0: int aChannel) = 0; michael@0: virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) = 0; michael@0: michael@0: /** michael@0: * Returns the address of the connected device. michael@0: */ michael@0: virtual void GetAddress(nsAString& aDeviceAddress) = 0; michael@0: michael@0: /** michael@0: * Returns true if the profile is connected. michael@0: */ michael@0: virtual bool IsConnected() = 0; michael@0: michael@0: /** michael@0: * Connect to a specific remote device. When it has been done, the michael@0: * callback "OnConnect" will be invoked. michael@0: */ michael@0: virtual void Connect(const nsAString& aDeviceAddress, michael@0: BluetoothProfileController* aController) = 0; michael@0: michael@0: /** michael@0: * Close the socket and then invoke the callback "OnDisconnect". michael@0: */ michael@0: virtual void Disconnect(BluetoothProfileController* aController) = 0; michael@0: michael@0: /** michael@0: * If it establishes/releases a connection successfully, the error string michael@0: * will be empty. Otherwise, the error string shows the failure reason. michael@0: */ michael@0: virtual void OnConnect(const nsAString& aErrorStr) = 0; michael@0: virtual void OnDisconnect(const nsAString& aErrorStr) = 0; michael@0: michael@0: /** michael@0: * Clean up profile resources and set mController as null. michael@0: */ michael@0: virtual void Reset() = 0; michael@0: michael@0: /** michael@0: * Returns string of profile name. michael@0: */ michael@0: virtual void GetName(nsACString& aName) = 0; michael@0: }; michael@0: michael@0: #define BT_DECL_PROFILE_MGR_BASE \ michael@0: public: \ michael@0: NS_DECL_ISUPPORTS \ michael@0: NS_DECL_NSIOBSERVER \ michael@0: virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \ michael@0: const nsAString& aServiceUuid, \ michael@0: int aChannel) MOZ_OVERRIDE; \ michael@0: virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE; \ michael@0: virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE; \ michael@0: virtual bool IsConnected() MOZ_OVERRIDE; \ michael@0: virtual void Connect(const nsAString& aDeviceAddress, \ michael@0: BluetoothProfileController* aController) MOZ_OVERRIDE; \ michael@0: virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE; \ michael@0: virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE; \ michael@0: virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE; \ michael@0: virtual void Reset() MOZ_OVERRIDE; michael@0: michael@0: END_BLUETOOTH_NAMESPACE michael@0: michael@0: #endif //#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__