2012-09-19 16:37:49 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-09-13 09:37:14 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
|
|
|
#include "BluetoothParent.h"
|
|
|
|
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/unused.h"
|
|
|
|
#include "mozilla/Util.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsTraceRefcnt.h"
|
|
|
|
|
|
|
|
#include "BluetoothReplyRunnable.h"
|
|
|
|
#include "BluetoothService.h"
|
|
|
|
|
|
|
|
using mozilla::unused;
|
|
|
|
USING_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* BluetoothRequestParent::ReplyRunnable
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class BluetoothRequestParent::ReplyRunnable : public BluetoothReplyRunnable
|
|
|
|
{
|
|
|
|
BluetoothRequestParent* mRequest;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ReplyRunnable(BluetoothRequestParent* aRequest)
|
|
|
|
: BluetoothReplyRunnable(nullptr), mRequest(aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
Run() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mReply);
|
|
|
|
|
|
|
|
if (mRequest) {
|
|
|
|
// Must do this first because Send__delete__ will delete mRequest.
|
|
|
|
mRequest->RequestComplete();
|
|
|
|
|
|
|
|
if (!mRequest->Send__delete__(mRequest, *mReply)) {
|
2013-09-13 15:51:00 -07:00
|
|
|
BT_WARNING("Failed to send response to child process!");
|
2012-09-13 09:37:14 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseMembers();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Revoke()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
mRequest = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
2013-04-02 16:06:14 -07:00
|
|
|
ParseSuccessfulReply(JS::Value* aValue) MOZ_OVERRIDE
|
2012-09-13 09:37:14 -07:00
|
|
|
{
|
2013-06-28 18:38:30 -07:00
|
|
|
MOZ_CRASH("This should never be called!");
|
2012-09-13 09:37:14 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* BluetoothParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
BluetoothParent::BluetoothParent()
|
|
|
|
: mShutdownState(Running)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(BluetoothParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
BluetoothParent::~BluetoothParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(BluetoothParent);
|
|
|
|
MOZ_ASSERT(!mService);
|
|
|
|
MOZ_ASSERT(mShutdownState == Dead);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BluetoothParent::BeginShutdown()
|
|
|
|
{
|
|
|
|
// Only do something here if we haven't yet begun the shutdown sequence.
|
|
|
|
if (mShutdownState == Running) {
|
|
|
|
unused << SendBeginShutdown();
|
|
|
|
mShutdownState = SentBeginShutdown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothParent::InitWithService(BluetoothService* aService)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aService);
|
|
|
|
MOZ_ASSERT(!mService);
|
|
|
|
|
|
|
|
if (!SendEnabled(aService->IsEnabled())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
mService = aService;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BluetoothParent::UnregisterAllSignalHandlers()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
mService->UnregisterAllSignalHandlers(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BluetoothParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
if (mService) {
|
|
|
|
UnregisterAllSignalHandlers();
|
|
|
|
#ifdef DEBUG
|
|
|
|
mService = nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
mShutdownState = Dead;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothParent::RecvRegisterSignalHandler(const nsString& aNode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
mService->RegisterBluetoothSignalHandler(aNode, this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothParent::RecvUnregisterSignalHandler(const nsString& aNode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
mService->UnregisterBluetoothSignalHandler(aNode, this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothParent::RecvStopNotifying()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
|
|
|
|
if (mShutdownState != Running && mShutdownState != SentBeginShutdown) {
|
|
|
|
MOZ_ASSERT(false, "Bad state!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
mShutdownState = ReceivedStopNotifying;
|
|
|
|
|
|
|
|
UnregisterAllSignalHandlers();
|
|
|
|
|
|
|
|
if (SendNotificationsStopped()) {
|
|
|
|
mShutdownState = SentNotificationsStopped;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothParent::RecvPBluetoothRequestConstructor(
|
|
|
|
PBluetoothRequestParent* aActor,
|
|
|
|
const Request& aRequest)
|
|
|
|
{
|
|
|
|
BluetoothRequestParent* actor = static_cast<BluetoothRequestParent*>(aActor);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
actor->mRequestType = aRequest.type();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (aRequest.type()) {
|
2012-09-19 16:37:49 -07:00
|
|
|
case Request::TDefaultAdapterPathRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_DefaultAdapterPathRequest());
|
|
|
|
case Request::TSetPropertyRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetPropertyRequest());
|
|
|
|
case Request::TStartDiscoveryRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_StartDiscoveryRequest());
|
|
|
|
case Request::TStopDiscoveryRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_StopDiscoveryRequest());
|
|
|
|
case Request::TPairRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_PairRequest());
|
|
|
|
case Request::TUnpairRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_UnpairRequest());
|
2013-04-26 03:48:21 -07:00
|
|
|
case Request::TPairedDevicePropertiesRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_PairedDevicePropertiesRequest());
|
|
|
|
case Request::TConnectedDevicePropertiesRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_ConnectedDevicePropertiesRequest());
|
2012-09-19 16:37:49 -07:00
|
|
|
case Request::TSetPinCodeRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetPinCodeRequest());
|
|
|
|
case Request::TSetPasskeyRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetPasskeyRequest());
|
|
|
|
case Request::TConfirmPairingConfirmationRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_ConfirmPairingConfirmationRequest());
|
|
|
|
case Request::TDenyPairingConfirmationRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_DenyPairingConfirmationRequest());
|
2012-10-05 03:48:05 -07:00
|
|
|
case Request::TConnectRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_ConnectRequest());
|
|
|
|
case Request::TDisconnectRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_DisconnectRequest());
|
2012-09-28 04:42:04 -07:00
|
|
|
case Request::TSendFileRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SendFileRequest());
|
2012-10-03 00:09:27 -07:00
|
|
|
case Request::TStopSendingFileRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_StopSendingFileRequest());
|
2012-10-18 23:16:13 -07:00
|
|
|
case Request::TConfirmReceivingFileRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_ConfirmReceivingFileRequest());
|
|
|
|
case Request::TDenyReceivingFileRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_DenyReceivingFileRequest());
|
2013-05-10 03:58:59 -07:00
|
|
|
case Request::TConnectScoRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_ConnectScoRequest());
|
|
|
|
case Request::TDisconnectScoRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_DisconnectScoRequest());
|
|
|
|
case Request::TIsScoConnectedRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_IsScoConnectedRequest());
|
2013-07-29 02:32:34 -07:00
|
|
|
case Request::TSendMetaDataRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SendMetaDataRequest());
|
|
|
|
case Request::TSendPlayStatusRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SendPlayStatusRequest());
|
2012-09-19 16:37:49 -07:00
|
|
|
default:
|
2013-06-28 18:38:30 -07:00
|
|
|
MOZ_CRASH("Unknown type!");
|
2012-09-13 09:37:14 -07:00
|
|
|
}
|
|
|
|
|
2013-06-28 18:38:30 -07:00
|
|
|
MOZ_CRASH("Should never get here!");
|
2012-09-13 09:37:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
PBluetoothRequestParent*
|
2013-07-08 08:48:39 -07:00
|
|
|
BluetoothParent::AllocPBluetoothRequestParent(const Request& aRequest)
|
2012-09-13 09:37:14 -07:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
return new BluetoothRequestParent(mService);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 08:48:39 -07:00
|
|
|
BluetoothParent::DeallocPBluetoothRequestParent(PBluetoothRequestParent* aActor)
|
2012-09-13 09:37:14 -07:00
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BluetoothParent::Notify(const BluetoothSignal& aSignal)
|
|
|
|
{
|
|
|
|
unused << SendNotify(aSignal);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* BluetoothRequestParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
BluetoothRequestParent::BluetoothRequestParent(BluetoothService* aService)
|
|
|
|
: mService(aService)
|
|
|
|
#ifdef DEBUG
|
|
|
|
, mRequestType(Request::T__None)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(BluetoothRequestParent);
|
|
|
|
MOZ_ASSERT(aService);
|
|
|
|
|
|
|
|
mReplyRunnable = new ReplyRunnable(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
BluetoothRequestParent::~BluetoothRequestParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(BluetoothRequestParent);
|
|
|
|
|
|
|
|
// mReplyRunnable will be automatically revoked.
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BluetoothRequestParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
mReplyRunnable.Revoke();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BluetoothRequestParent::RequestComplete()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(mReplyRunnable.IsPending());
|
|
|
|
|
|
|
|
mReplyRunnable.Forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const DefaultAdapterPathRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TDefaultAdapterPathRequest);
|
|
|
|
|
|
|
|
nsresult rv = mService->GetDefaultAdapterPathInternal(mReplyRunnable.get());
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const SetPropertyRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TSetPropertyRequest);
|
|
|
|
|
|
|
|
nsresult rv =
|
2013-03-15 00:15:47 -07:00
|
|
|
mService->SetProperty(aRequest.type(), aRequest.value(),
|
2012-09-13 09:37:14 -07:00
|
|
|
mReplyRunnable.get());
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const StartDiscoveryRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TStartDiscoveryRequest);
|
|
|
|
|
|
|
|
nsresult rv =
|
2013-03-15 00:15:47 -07:00
|
|
|
mService->StartDiscoveryInternal(mReplyRunnable.get());
|
2012-09-13 09:37:14 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const StopDiscoveryRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TStopDiscoveryRequest);
|
|
|
|
|
|
|
|
nsresult rv =
|
2013-03-15 00:15:47 -07:00
|
|
|
mService->StopDiscoveryInternal(mReplyRunnable.get());
|
2012-09-13 09:37:14 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const PairRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TPairRequest);
|
|
|
|
|
|
|
|
nsresult rv =
|
2013-03-15 00:15:47 -07:00
|
|
|
mService->CreatePairedDeviceInternal(aRequest.address(),
|
2012-09-13 09:37:14 -07:00
|
|
|
aRequest.timeoutMS(),
|
|
|
|
mReplyRunnable.get());
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const UnpairRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TUnpairRequest);
|
|
|
|
|
|
|
|
nsresult rv =
|
2013-03-15 00:15:47 -07:00
|
|
|
mService->RemoveDeviceInternal(aRequest.address(),
|
2012-09-13 09:37:14 -07:00
|
|
|
mReplyRunnable.get());
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-26 03:48:21 -07:00
|
|
|
BluetoothRequestParent::DoRequest(const PairedDevicePropertiesRequest& aRequest)
|
2012-09-13 09:37:14 -07:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
2013-04-26 03:48:21 -07:00
|
|
|
MOZ_ASSERT(mRequestType == Request::TPairedDevicePropertiesRequest);
|
2012-09-13 09:37:14 -07:00
|
|
|
|
|
|
|
nsresult rv =
|
2012-12-18 17:16:06 -08:00
|
|
|
mService->GetPairedDevicePropertiesInternal(aRequest.addresses(),
|
2012-09-13 09:37:14 -07:00
|
|
|
mReplyRunnable.get());
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2013-04-26 03:48:21 -07:00
|
|
|
return true;
|
|
|
|
}
|
2013-09-06 04:19:46 -07:00
|
|
|
|
2013-04-26 03:48:21 -07:00
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const ConnectedDevicePropertiesRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TConnectedDevicePropertiesRequest);
|
|
|
|
nsresult rv =
|
2013-09-06 04:19:46 -07:00
|
|
|
mService->GetConnectedDevicePropertiesInternal(aRequest.serviceUuid(),
|
2013-04-26 03:48:21 -07:00
|
|
|
mReplyRunnable.get());
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2012-09-13 09:37:14 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-09-19 16:37:49 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const SetPinCodeRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TSetPinCodeRequest);
|
|
|
|
|
2012-09-21 10:21:36 -07:00
|
|
|
bool result =
|
2012-09-19 16:37:49 -07:00
|
|
|
mService->SetPinCodeInternal(aRequest.path(),
|
|
|
|
aRequest.pincode(),
|
|
|
|
mReplyRunnable.get());
|
|
|
|
|
2012-09-21 10:21:36 -07:00
|
|
|
NS_ENSURE_TRUE(result, false);
|
2012-09-19 16:37:49 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const SetPasskeyRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TSetPasskeyRequest);
|
|
|
|
|
2012-09-21 10:21:36 -07:00
|
|
|
bool result =
|
2012-09-19 16:37:49 -07:00
|
|
|
mService->SetPasskeyInternal(aRequest.path(),
|
|
|
|
aRequest.passkey(),
|
|
|
|
mReplyRunnable.get());
|
|
|
|
|
2012-09-21 10:21:36 -07:00
|
|
|
NS_ENSURE_TRUE(result, false);
|
2012-09-19 16:37:49 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const ConfirmPairingConfirmationRequest&
|
|
|
|
aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TConfirmPairingConfirmationRequest);
|
|
|
|
|
2012-09-21 10:21:36 -07:00
|
|
|
bool result =
|
2012-09-19 16:37:49 -07:00
|
|
|
mService->SetPairingConfirmationInternal(aRequest.path(),
|
|
|
|
true,
|
|
|
|
mReplyRunnable.get());
|
|
|
|
|
2012-09-21 10:21:36 -07:00
|
|
|
NS_ENSURE_TRUE(result, false);
|
2012-09-19 16:37:49 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const DenyPairingConfirmationRequest&
|
|
|
|
aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TDenyPairingConfirmationRequest);
|
|
|
|
|
2012-09-21 10:21:36 -07:00
|
|
|
bool result =
|
2012-09-19 16:37:49 -07:00
|
|
|
mService->SetPairingConfirmationInternal(aRequest.path(),
|
|
|
|
false,
|
|
|
|
mReplyRunnable.get());
|
|
|
|
|
2012-09-21 10:21:36 -07:00
|
|
|
NS_ENSURE_TRUE(result, false);
|
2012-09-19 16:37:49 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-29 03:26:46 -07:00
|
|
|
bool
|
2012-10-05 03:48:05 -07:00
|
|
|
BluetoothRequestParent::DoRequest(const ConnectRequest& aRequest)
|
2012-09-29 03:26:46 -07:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
2012-10-05 03:48:05 -07:00
|
|
|
MOZ_ASSERT(mRequestType == Request::TConnectRequest);
|
2012-09-29 03:26:46 -07:00
|
|
|
|
2012-11-16 02:46:08 -08:00
|
|
|
mService->Connect(aRequest.address(),
|
2013-09-06 04:19:46 -07:00
|
|
|
aRequest.cod(),
|
|
|
|
aRequest.serviceUuid(),
|
2012-11-16 02:46:08 -08:00
|
|
|
mReplyRunnable.get());
|
|
|
|
|
|
|
|
return true;
|
2012-09-29 03:26:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-10-05 03:48:05 -07:00
|
|
|
BluetoothRequestParent::DoRequest(const DisconnectRequest& aRequest)
|
2012-09-29 03:26:46 -07:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
2012-10-05 03:48:05 -07:00
|
|
|
MOZ_ASSERT(mRequestType == Request::TDisconnectRequest);
|
2012-09-29 03:26:46 -07:00
|
|
|
|
2013-09-06 04:19:46 -07:00
|
|
|
mService->Disconnect(aRequest.address(),
|
|
|
|
aRequest.serviceUuid(),
|
2012-10-05 03:48:05 -07:00
|
|
|
mReplyRunnable.get());
|
2012-09-29 03:26:46 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-09-28 04:42:04 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const SendFileRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TSendFileRequest);
|
|
|
|
|
2012-11-02 18:36:43 -07:00
|
|
|
mService->SendFile(aRequest.devicePath(),
|
|
|
|
(BlobParent*)aRequest.blobParent(),
|
|
|
|
(BlobChild*)aRequest.blobChild(),
|
|
|
|
mReplyRunnable.get());
|
|
|
|
|
|
|
|
return true;
|
2012-09-28 04:42:04 -07:00
|
|
|
}
|
2012-10-03 00:09:27 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const StopSendingFileRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TStopSendingFileRequest);
|
|
|
|
|
2012-11-02 18:36:43 -07:00
|
|
|
mService->StopSendingFile(aRequest.devicePath(),
|
|
|
|
mReplyRunnable.get());
|
|
|
|
|
|
|
|
return true;
|
2012-10-03 00:09:27 -07:00
|
|
|
}
|
2012-10-18 23:16:13 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const ConfirmReceivingFileRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TConfirmReceivingFileRequest);
|
|
|
|
|
|
|
|
mService->ConfirmReceivingFile(aRequest.devicePath(),
|
|
|
|
true,
|
|
|
|
mReplyRunnable.get());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const DenyReceivingFileRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TDenyReceivingFileRequest);
|
|
|
|
|
|
|
|
mService->ConfirmReceivingFile(aRequest.devicePath(),
|
|
|
|
false,
|
|
|
|
mReplyRunnable.get());
|
|
|
|
return true;
|
|
|
|
}
|
2013-05-10 03:58:59 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const ConnectScoRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TConnectScoRequest);
|
|
|
|
|
|
|
|
mService->ConnectSco(mReplyRunnable.get());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const DisconnectScoRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TDisconnectScoRequest);
|
|
|
|
|
|
|
|
mService->DisconnectSco(mReplyRunnable.get());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const IsScoConnectedRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TIsScoConnectedRequest);
|
|
|
|
|
|
|
|
mService->IsScoConnected(mReplyRunnable.get());
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-29 02:32:34 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const SendMetaDataRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TSendMetaDataRequest);
|
|
|
|
|
|
|
|
mService->SendMetaData(aRequest.title(),
|
|
|
|
aRequest.artist(),
|
|
|
|
aRequest.album(),
|
|
|
|
aRequest.mediaNumber(),
|
|
|
|
aRequest.totalMediaCount(),
|
|
|
|
aRequest.duration(),
|
|
|
|
mReplyRunnable.get());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BluetoothRequestParent::DoRequest(const SendPlayStatusRequest& aRequest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mService);
|
|
|
|
MOZ_ASSERT(mRequestType == Request::TSendPlayStatusRequest);
|
|
|
|
|
|
|
|
mService->SendPlayStatus(aRequest.duration(),
|
|
|
|
aRequest.position(),
|
|
|
|
aRequest.playStatus(),
|
|
|
|
mReplyRunnable.get());
|
|
|
|
return true;
|
|
|
|
}
|