mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 914175 - Reply error when no profile is connected, r=echou
This commit is contained in:
parent
7d5c8440ff
commit
f80a3771d9
@ -21,9 +21,10 @@ BluetoothProfileController::BluetoothProfileController(
|
||||
const nsAString& aDeviceAddress,
|
||||
BluetoothReplyRunnable* aRunnable,
|
||||
BluetoothProfileControllerCallback aCallback)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
: mCallback(aCallback)
|
||||
, mDeviceAddress(aDeviceAddress)
|
||||
, mRunnable(aRunnable)
|
||||
, mCallback(aCallback)
|
||||
, mSuccess(false)
|
||||
{
|
||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||
MOZ_ASSERT(aRunnable);
|
||||
@ -152,7 +153,12 @@ BluetoothProfileController::ConnectNext()
|
||||
|
||||
// The action has been completed, so the dom request is replied and then
|
||||
// the callback is invoked
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
|
||||
if (mSuccess) {
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
|
||||
} else {
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(),
|
||||
NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
}
|
||||
mCallback();
|
||||
}
|
||||
|
||||
@ -163,6 +169,8 @@ BluetoothProfileController::OnConnect(const nsAString& aErrorStr)
|
||||
|
||||
if (!aErrorStr.IsEmpty()) {
|
||||
BT_WARNING(NS_ConvertUTF16toUTF8(aErrorStr).get());
|
||||
} else {
|
||||
mSuccess = true;
|
||||
}
|
||||
|
||||
ConnectNext();
|
||||
@ -203,7 +211,12 @@ BluetoothProfileController::DisconnectNext()
|
||||
|
||||
// The action has been completed, so the dom request is replied and then
|
||||
// the callback is invoked
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
|
||||
if (mSuccess) {
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString());
|
||||
} else {
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(),
|
||||
NS_LITERAL_STRING(ERR_DISCONNECTION_FAILED));
|
||||
}
|
||||
mCallback();
|
||||
}
|
||||
|
||||
@ -214,6 +227,8 @@ BluetoothProfileController::OnDisconnect(const nsAString& aErrorStr)
|
||||
|
||||
if (!aErrorStr.IsEmpty()) {
|
||||
BT_WARNING(NS_ConvertUTF16toUTF8(aErrorStr).get());
|
||||
} else {
|
||||
mSuccess = true;
|
||||
}
|
||||
|
||||
DisconnectNext();
|
||||
|
@ -93,10 +93,11 @@ private:
|
||||
int8_t mProfilesIndex;
|
||||
nsTArray<BluetoothProfileManagerBase*> mProfiles;
|
||||
|
||||
BluetoothProfileControllerCallback mCallback;
|
||||
uint32_t mCod;
|
||||
nsString mDeviceAddress;
|
||||
nsRefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
BluetoothProfileControllerCallback mCallback;
|
||||
bool mSuccess;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -14,6 +14,8 @@
|
||||
*/
|
||||
#define ERR_ALREADY_CONNECTED "AlreadyConnectedError"
|
||||
#define ERR_ALREADY_DISCONNECTED "AlreadyDisconnectedError"
|
||||
#define ERR_CONNECTION_FAILED "ConnectionFailedError"
|
||||
#define ERR_DISCONNECTION_FAILED "DisconnectionFailedError"
|
||||
#define ERR_NO_AVAILABLE_RESOURCE "NoAvailableResourceError"
|
||||
#define ERR_REACHED_CONNECTION_LIMIT "ReachedConnectionLimitError"
|
||||
#define ERR_SERVICE_CHANNEL_NOT_FOUND "DeviceChannelRetrievalError"
|
||||
|
@ -106,6 +106,10 @@ interface BluetoothAdapter : EventTarget {
|
||||
* device (CoD). If it isn't passed when calling Disconnect, all connected
|
||||
* profiles are going to be closed.
|
||||
*
|
||||
* Reply success if the connection of any profile is successfully
|
||||
* established/released; reply error if we failed to connect/disconnect all
|
||||
* of the planned profiles.
|
||||
*
|
||||
* @param device Remote device
|
||||
* @param profile 2-octets service UUID. This is optional.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user