1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bluetooth/BluetoothProfileManagerBase.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__ 1.11 +#define mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__ 1.12 + 1.13 +/** 1.14 + * Error Messages used in Bluetooth profiles 1.15 + * 1.16 + * These error messages would be sent to Gaia as an argument of onError event. 1.17 + */ 1.18 +#define ERR_ALREADY_CONNECTED "AlreadyConnectedError" 1.19 +#define ERR_ALREADY_DISCONNECTED "AlreadyDisconnectedError" 1.20 +#define ERR_CONNECTION_FAILED "ConnectionFailedError" 1.21 +#define ERR_DISCONNECTION_FAILED "DisconnectionFailedError" 1.22 +#define ERR_NO_AVAILABLE_RESOURCE "NoAvailableResourceError" 1.23 +#define ERR_REACHED_CONNECTION_LIMIT "ReachedConnectionLimitError" 1.24 +#define ERR_SERVICE_CHANNEL_NOT_FOUND "DeviceChannelRetrievalError" 1.25 +#define ERR_UNKNOWN_PROFILE "UnknownProfileError" 1.26 +#define ERR_OPERATION_TIMEOUT "OperationTimeout" 1.27 + 1.28 +#include "BluetoothCommon.h" 1.29 +#include "nsIObserver.h" 1.30 + 1.31 +BEGIN_BLUETOOTH_NAMESPACE 1.32 +class BluetoothProfileController; 1.33 + 1.34 +class BluetoothProfileManagerBase : public nsIObserver 1.35 +{ 1.36 +public: 1.37 + virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, 1.38 + const nsAString& aServiceUuid, 1.39 + int aChannel) = 0; 1.40 + virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) = 0; 1.41 + 1.42 + /** 1.43 + * Returns the address of the connected device. 1.44 + */ 1.45 + virtual void GetAddress(nsAString& aDeviceAddress) = 0; 1.46 + 1.47 + /** 1.48 + * Returns true if the profile is connected. 1.49 + */ 1.50 + virtual bool IsConnected() = 0; 1.51 + 1.52 + /** 1.53 + * Connect to a specific remote device. When it has been done, the 1.54 + * callback "OnConnect" will be invoked. 1.55 + */ 1.56 + virtual void Connect(const nsAString& aDeviceAddress, 1.57 + BluetoothProfileController* aController) = 0; 1.58 + 1.59 + /** 1.60 + * Close the socket and then invoke the callback "OnDisconnect". 1.61 + */ 1.62 + virtual void Disconnect(BluetoothProfileController* aController) = 0; 1.63 + 1.64 + /** 1.65 + * If it establishes/releases a connection successfully, the error string 1.66 + * will be empty. Otherwise, the error string shows the failure reason. 1.67 + */ 1.68 + virtual void OnConnect(const nsAString& aErrorStr) = 0; 1.69 + virtual void OnDisconnect(const nsAString& aErrorStr) = 0; 1.70 + 1.71 + /** 1.72 + * Clean up profile resources and set mController as null. 1.73 + */ 1.74 + virtual void Reset() = 0; 1.75 + 1.76 + /** 1.77 + * Returns string of profile name. 1.78 + */ 1.79 + virtual void GetName(nsACString& aName) = 0; 1.80 +}; 1.81 + 1.82 +#define BT_DECL_PROFILE_MGR_BASE \ 1.83 +public: \ 1.84 + NS_DECL_ISUPPORTS \ 1.85 + NS_DECL_NSIOBSERVER \ 1.86 + virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \ 1.87 + const nsAString& aServiceUuid, \ 1.88 + int aChannel) MOZ_OVERRIDE; \ 1.89 + virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE; \ 1.90 + virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE; \ 1.91 + virtual bool IsConnected() MOZ_OVERRIDE; \ 1.92 + virtual void Connect(const nsAString& aDeviceAddress, \ 1.93 + BluetoothProfileController* aController) MOZ_OVERRIDE; \ 1.94 + virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE; \ 1.95 + virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE; \ 1.96 + virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE; \ 1.97 + virtual void Reset() MOZ_OVERRIDE; 1.98 + 1.99 +END_BLUETOOTH_NAMESPACE 1.100 + 1.101 +#endif //#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__