dom/bluetooth/ipc/BluetoothParent.cpp

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 #include "base/basictypes.h"
michael@0 8
michael@0 9 #include "BluetoothParent.h"
michael@0 10
michael@0 11 #include "mozilla/Assertions.h"
michael@0 12 #include "mozilla/unused.h"
michael@0 13 #include "nsDebug.h"
michael@0 14 #include "nsISupportsImpl.h"
michael@0 15 #include "nsThreadUtils.h"
michael@0 16
michael@0 17 #include "BluetoothReplyRunnable.h"
michael@0 18 #include "BluetoothService.h"
michael@0 19
michael@0 20 using mozilla::unused;
michael@0 21 USING_BLUETOOTH_NAMESPACE
michael@0 22
michael@0 23 /*******************************************************************************
michael@0 24 * BluetoothRequestParent::ReplyRunnable
michael@0 25 ******************************************************************************/
michael@0 26
michael@0 27 class BluetoothRequestParent::ReplyRunnable : public BluetoothReplyRunnable
michael@0 28 {
michael@0 29 BluetoothRequestParent* mRequest;
michael@0 30
michael@0 31 public:
michael@0 32 ReplyRunnable(BluetoothRequestParent* aRequest)
michael@0 33 : BluetoothReplyRunnable(nullptr), mRequest(aRequest)
michael@0 34 {
michael@0 35 MOZ_ASSERT(NS_IsMainThread());
michael@0 36 MOZ_ASSERT(aRequest);
michael@0 37 }
michael@0 38
michael@0 39 NS_IMETHOD
michael@0 40 Run() MOZ_OVERRIDE
michael@0 41 {
michael@0 42 MOZ_ASSERT(NS_IsMainThread());
michael@0 43 MOZ_ASSERT(mReply);
michael@0 44
michael@0 45 if (mRequest) {
michael@0 46 // Must do this first because Send__delete__ will delete mRequest.
michael@0 47 mRequest->RequestComplete();
michael@0 48
michael@0 49 if (!mRequest->Send__delete__(mRequest, *mReply)) {
michael@0 50 BT_WARNING("Failed to send response to child process!");
michael@0 51 return NS_ERROR_FAILURE;
michael@0 52 }
michael@0 53 }
michael@0 54
michael@0 55 ReleaseMembers();
michael@0 56 return NS_OK;
michael@0 57 }
michael@0 58
michael@0 59 void
michael@0 60 Revoke()
michael@0 61 {
michael@0 62 MOZ_ASSERT(NS_IsMainThread());
michael@0 63 mRequest = nullptr;
michael@0 64 }
michael@0 65
michael@0 66 virtual bool
michael@0 67 ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) MOZ_OVERRIDE
michael@0 68 {
michael@0 69 MOZ_CRASH("This should never be called!");
michael@0 70 }
michael@0 71 };
michael@0 72
michael@0 73 /*******************************************************************************
michael@0 74 * BluetoothParent
michael@0 75 ******************************************************************************/
michael@0 76
michael@0 77 BluetoothParent::BluetoothParent()
michael@0 78 : mShutdownState(Running)
michael@0 79 {
michael@0 80 MOZ_COUNT_CTOR(BluetoothParent);
michael@0 81 }
michael@0 82
michael@0 83 BluetoothParent::~BluetoothParent()
michael@0 84 {
michael@0 85 MOZ_COUNT_DTOR(BluetoothParent);
michael@0 86 MOZ_ASSERT(!mService);
michael@0 87 MOZ_ASSERT(mShutdownState == Dead);
michael@0 88 }
michael@0 89
michael@0 90 void
michael@0 91 BluetoothParent::BeginShutdown()
michael@0 92 {
michael@0 93 // Only do something here if we haven't yet begun the shutdown sequence.
michael@0 94 if (mShutdownState == Running) {
michael@0 95 unused << SendBeginShutdown();
michael@0 96 mShutdownState = SentBeginShutdown;
michael@0 97 }
michael@0 98 }
michael@0 99
michael@0 100 bool
michael@0 101 BluetoothParent::InitWithService(BluetoothService* aService)
michael@0 102 {
michael@0 103 MOZ_ASSERT(aService);
michael@0 104 MOZ_ASSERT(!mService);
michael@0 105
michael@0 106 if (!SendEnabled(aService->IsEnabled())) {
michael@0 107 return false;
michael@0 108 }
michael@0 109
michael@0 110 mService = aService;
michael@0 111 return true;
michael@0 112 }
michael@0 113
michael@0 114 void
michael@0 115 BluetoothParent::UnregisterAllSignalHandlers()
michael@0 116 {
michael@0 117 MOZ_ASSERT(mService);
michael@0 118 mService->UnregisterAllSignalHandlers(this);
michael@0 119 }
michael@0 120
michael@0 121 void
michael@0 122 BluetoothParent::ActorDestroy(ActorDestroyReason aWhy)
michael@0 123 {
michael@0 124 if (mService) {
michael@0 125 UnregisterAllSignalHandlers();
michael@0 126 #ifdef DEBUG
michael@0 127 mService = nullptr;
michael@0 128 #endif
michael@0 129 }
michael@0 130
michael@0 131 #ifdef DEBUG
michael@0 132 mShutdownState = Dead;
michael@0 133 #endif
michael@0 134 }
michael@0 135
michael@0 136 bool
michael@0 137 BluetoothParent::RecvRegisterSignalHandler(const nsString& aNode)
michael@0 138 {
michael@0 139 MOZ_ASSERT(mService);
michael@0 140 mService->RegisterBluetoothSignalHandler(aNode, this);
michael@0 141 return true;
michael@0 142 }
michael@0 143
michael@0 144 bool
michael@0 145 BluetoothParent::RecvUnregisterSignalHandler(const nsString& aNode)
michael@0 146 {
michael@0 147 MOZ_ASSERT(mService);
michael@0 148 mService->UnregisterBluetoothSignalHandler(aNode, this);
michael@0 149 return true;
michael@0 150 }
michael@0 151
michael@0 152 bool
michael@0 153 BluetoothParent::RecvStopNotifying()
michael@0 154 {
michael@0 155 MOZ_ASSERT(mService);
michael@0 156
michael@0 157 if (mShutdownState != Running && mShutdownState != SentBeginShutdown) {
michael@0 158 MOZ_ASSERT(false, "Bad state!");
michael@0 159 return false;
michael@0 160 }
michael@0 161
michael@0 162 mShutdownState = ReceivedStopNotifying;
michael@0 163
michael@0 164 UnregisterAllSignalHandlers();
michael@0 165
michael@0 166 if (SendNotificationsStopped()) {
michael@0 167 mShutdownState = SentNotificationsStopped;
michael@0 168 return true;
michael@0 169 }
michael@0 170
michael@0 171 return false;
michael@0 172 }
michael@0 173
michael@0 174 bool
michael@0 175 BluetoothParent::RecvPBluetoothRequestConstructor(
michael@0 176 PBluetoothRequestParent* aActor,
michael@0 177 const Request& aRequest)
michael@0 178 {
michael@0 179 BluetoothRequestParent* actor = static_cast<BluetoothRequestParent*>(aActor);
michael@0 180
michael@0 181 #ifdef DEBUG
michael@0 182 actor->mRequestType = aRequest.type();
michael@0 183 #endif
michael@0 184
michael@0 185 switch (aRequest.type()) {
michael@0 186 case Request::TDefaultAdapterPathRequest:
michael@0 187 return actor->DoRequest(aRequest.get_DefaultAdapterPathRequest());
michael@0 188 case Request::TSetPropertyRequest:
michael@0 189 return actor->DoRequest(aRequest.get_SetPropertyRequest());
michael@0 190 case Request::TStartDiscoveryRequest:
michael@0 191 return actor->DoRequest(aRequest.get_StartDiscoveryRequest());
michael@0 192 case Request::TStopDiscoveryRequest:
michael@0 193 return actor->DoRequest(aRequest.get_StopDiscoveryRequest());
michael@0 194 case Request::TPairRequest:
michael@0 195 return actor->DoRequest(aRequest.get_PairRequest());
michael@0 196 case Request::TUnpairRequest:
michael@0 197 return actor->DoRequest(aRequest.get_UnpairRequest());
michael@0 198 case Request::TPairedDevicePropertiesRequest:
michael@0 199 return actor->DoRequest(aRequest.get_PairedDevicePropertiesRequest());
michael@0 200 case Request::TConnectedDevicePropertiesRequest:
michael@0 201 return actor->DoRequest(aRequest.get_ConnectedDevicePropertiesRequest());
michael@0 202 case Request::TSetPinCodeRequest:
michael@0 203 return actor->DoRequest(aRequest.get_SetPinCodeRequest());
michael@0 204 case Request::TSetPasskeyRequest:
michael@0 205 return actor->DoRequest(aRequest.get_SetPasskeyRequest());
michael@0 206 case Request::TConfirmPairingConfirmationRequest:
michael@0 207 return actor->DoRequest(aRequest.get_ConfirmPairingConfirmationRequest());
michael@0 208 case Request::TDenyPairingConfirmationRequest:
michael@0 209 return actor->DoRequest(aRequest.get_DenyPairingConfirmationRequest());
michael@0 210 case Request::TConnectRequest:
michael@0 211 return actor->DoRequest(aRequest.get_ConnectRequest());
michael@0 212 case Request::TDisconnectRequest:
michael@0 213 return actor->DoRequest(aRequest.get_DisconnectRequest());
michael@0 214 case Request::TSendFileRequest:
michael@0 215 return actor->DoRequest(aRequest.get_SendFileRequest());
michael@0 216 case Request::TStopSendingFileRequest:
michael@0 217 return actor->DoRequest(aRequest.get_StopSendingFileRequest());
michael@0 218 case Request::TConfirmReceivingFileRequest:
michael@0 219 return actor->DoRequest(aRequest.get_ConfirmReceivingFileRequest());
michael@0 220 case Request::TDenyReceivingFileRequest:
michael@0 221 return actor->DoRequest(aRequest.get_DenyReceivingFileRequest());
michael@0 222 case Request::TConnectScoRequest:
michael@0 223 return actor->DoRequest(aRequest.get_ConnectScoRequest());
michael@0 224 case Request::TDisconnectScoRequest:
michael@0 225 return actor->DoRequest(aRequest.get_DisconnectScoRequest());
michael@0 226 case Request::TIsScoConnectedRequest:
michael@0 227 return actor->DoRequest(aRequest.get_IsScoConnectedRequest());
michael@0 228 #ifdef MOZ_B2G_RIL
michael@0 229 case Request::TAnswerWaitingCallRequest:
michael@0 230 return actor->DoRequest(aRequest.get_AnswerWaitingCallRequest());
michael@0 231 case Request::TIgnoreWaitingCallRequest:
michael@0 232 return actor->DoRequest(aRequest.get_IgnoreWaitingCallRequest());
michael@0 233 case Request::TToggleCallsRequest:
michael@0 234 return actor->DoRequest(aRequest.get_ToggleCallsRequest());
michael@0 235 #endif
michael@0 236 case Request::TSendMetaDataRequest:
michael@0 237 return actor->DoRequest(aRequest.get_SendMetaDataRequest());
michael@0 238 case Request::TSendPlayStatusRequest:
michael@0 239 return actor->DoRequest(aRequest.get_SendPlayStatusRequest());
michael@0 240 default:
michael@0 241 MOZ_CRASH("Unknown type!");
michael@0 242 }
michael@0 243
michael@0 244 MOZ_CRASH("Should never get here!");
michael@0 245 }
michael@0 246
michael@0 247 PBluetoothRequestParent*
michael@0 248 BluetoothParent::AllocPBluetoothRequestParent(const Request& aRequest)
michael@0 249 {
michael@0 250 MOZ_ASSERT(mService);
michael@0 251 return new BluetoothRequestParent(mService);
michael@0 252 }
michael@0 253
michael@0 254 bool
michael@0 255 BluetoothParent::DeallocPBluetoothRequestParent(PBluetoothRequestParent* aActor)
michael@0 256 {
michael@0 257 delete aActor;
michael@0 258 return true;
michael@0 259 }
michael@0 260
michael@0 261 void
michael@0 262 BluetoothParent::Notify(const BluetoothSignal& aSignal)
michael@0 263 {
michael@0 264 unused << SendNotify(aSignal);
michael@0 265 }
michael@0 266
michael@0 267 /*******************************************************************************
michael@0 268 * BluetoothRequestParent
michael@0 269 ******************************************************************************/
michael@0 270
michael@0 271 BluetoothRequestParent::BluetoothRequestParent(BluetoothService* aService)
michael@0 272 : mService(aService)
michael@0 273 #ifdef DEBUG
michael@0 274 , mRequestType(Request::T__None)
michael@0 275 #endif
michael@0 276 {
michael@0 277 MOZ_COUNT_CTOR(BluetoothRequestParent);
michael@0 278 MOZ_ASSERT(aService);
michael@0 279
michael@0 280 mReplyRunnable = new ReplyRunnable(this);
michael@0 281 }
michael@0 282
michael@0 283 BluetoothRequestParent::~BluetoothRequestParent()
michael@0 284 {
michael@0 285 MOZ_COUNT_DTOR(BluetoothRequestParent);
michael@0 286
michael@0 287 // mReplyRunnable will be automatically revoked.
michael@0 288 }
michael@0 289
michael@0 290 void
michael@0 291 BluetoothRequestParent::ActorDestroy(ActorDestroyReason aWhy)
michael@0 292 {
michael@0 293 mReplyRunnable.Revoke();
michael@0 294 }
michael@0 295
michael@0 296 void
michael@0 297 BluetoothRequestParent::RequestComplete()
michael@0 298 {
michael@0 299 MOZ_ASSERT(NS_IsMainThread());
michael@0 300 MOZ_ASSERT(mReplyRunnable.IsPending());
michael@0 301
michael@0 302 mReplyRunnable.Forget();
michael@0 303 }
michael@0 304
michael@0 305 bool
michael@0 306 BluetoothRequestParent::DoRequest(const DefaultAdapterPathRequest& aRequest)
michael@0 307 {
michael@0 308 MOZ_ASSERT(mService);
michael@0 309 MOZ_ASSERT(mRequestType == Request::TDefaultAdapterPathRequest);
michael@0 310
michael@0 311 nsresult rv = mService->GetDefaultAdapterPathInternal(mReplyRunnable.get());
michael@0 312 NS_ENSURE_SUCCESS(rv, false);
michael@0 313
michael@0 314 return true;
michael@0 315 }
michael@0 316
michael@0 317 bool
michael@0 318 BluetoothRequestParent::DoRequest(const SetPropertyRequest& aRequest)
michael@0 319 {
michael@0 320 MOZ_ASSERT(mService);
michael@0 321 MOZ_ASSERT(mRequestType == Request::TSetPropertyRequest);
michael@0 322
michael@0 323 nsresult rv =
michael@0 324 mService->SetProperty(aRequest.type(), aRequest.value(),
michael@0 325 mReplyRunnable.get());
michael@0 326 NS_ENSURE_SUCCESS(rv, false);
michael@0 327
michael@0 328 return true;
michael@0 329 }
michael@0 330
michael@0 331 bool
michael@0 332 BluetoothRequestParent::DoRequest(const StartDiscoveryRequest& aRequest)
michael@0 333 {
michael@0 334 MOZ_ASSERT(mService);
michael@0 335 MOZ_ASSERT(mRequestType == Request::TStartDiscoveryRequest);
michael@0 336
michael@0 337 nsresult rv =
michael@0 338 mService->StartDiscoveryInternal(mReplyRunnable.get());
michael@0 339 NS_ENSURE_SUCCESS(rv, false);
michael@0 340
michael@0 341 return true;
michael@0 342 }
michael@0 343
michael@0 344 bool
michael@0 345 BluetoothRequestParent::DoRequest(const StopDiscoveryRequest& aRequest)
michael@0 346 {
michael@0 347 MOZ_ASSERT(mService);
michael@0 348 MOZ_ASSERT(mRequestType == Request::TStopDiscoveryRequest);
michael@0 349
michael@0 350 nsresult rv =
michael@0 351 mService->StopDiscoveryInternal(mReplyRunnable.get());
michael@0 352 NS_ENSURE_SUCCESS(rv, false);
michael@0 353
michael@0 354 return true;
michael@0 355 }
michael@0 356
michael@0 357 bool
michael@0 358 BluetoothRequestParent::DoRequest(const PairRequest& aRequest)
michael@0 359 {
michael@0 360 MOZ_ASSERT(mService);
michael@0 361 MOZ_ASSERT(mRequestType == Request::TPairRequest);
michael@0 362
michael@0 363 nsresult rv =
michael@0 364 mService->CreatePairedDeviceInternal(aRequest.address(),
michael@0 365 aRequest.timeoutMS(),
michael@0 366 mReplyRunnable.get());
michael@0 367 NS_ENSURE_SUCCESS(rv, false);
michael@0 368
michael@0 369 return true;
michael@0 370 }
michael@0 371
michael@0 372 bool
michael@0 373 BluetoothRequestParent::DoRequest(const UnpairRequest& aRequest)
michael@0 374 {
michael@0 375 MOZ_ASSERT(mService);
michael@0 376 MOZ_ASSERT(mRequestType == Request::TUnpairRequest);
michael@0 377
michael@0 378 nsresult rv =
michael@0 379 mService->RemoveDeviceInternal(aRequest.address(),
michael@0 380 mReplyRunnable.get());
michael@0 381 NS_ENSURE_SUCCESS(rv, false);
michael@0 382
michael@0 383 return true;
michael@0 384 }
michael@0 385
michael@0 386 bool
michael@0 387 BluetoothRequestParent::DoRequest(const PairedDevicePropertiesRequest& aRequest)
michael@0 388 {
michael@0 389 MOZ_ASSERT(mService);
michael@0 390 MOZ_ASSERT(mRequestType == Request::TPairedDevicePropertiesRequest);
michael@0 391
michael@0 392 nsresult rv =
michael@0 393 mService->GetPairedDevicePropertiesInternal(aRequest.addresses(),
michael@0 394 mReplyRunnable.get());
michael@0 395 NS_ENSURE_SUCCESS(rv, false);
michael@0 396 return true;
michael@0 397 }
michael@0 398
michael@0 399 bool
michael@0 400 BluetoothRequestParent::DoRequest(const ConnectedDevicePropertiesRequest& aRequest)
michael@0 401 {
michael@0 402 MOZ_ASSERT(mService);
michael@0 403 MOZ_ASSERT(mRequestType == Request::TConnectedDevicePropertiesRequest);
michael@0 404 nsresult rv =
michael@0 405 mService->GetConnectedDevicePropertiesInternal(aRequest.serviceUuid(),
michael@0 406 mReplyRunnable.get());
michael@0 407 NS_ENSURE_SUCCESS(rv, false);
michael@0 408
michael@0 409 return true;
michael@0 410 }
michael@0 411
michael@0 412 bool
michael@0 413 BluetoothRequestParent::DoRequest(const SetPinCodeRequest& aRequest)
michael@0 414 {
michael@0 415 MOZ_ASSERT(mService);
michael@0 416 MOZ_ASSERT(mRequestType == Request::TSetPinCodeRequest);
michael@0 417
michael@0 418 bool result =
michael@0 419 mService->SetPinCodeInternal(aRequest.path(),
michael@0 420 aRequest.pincode(),
michael@0 421 mReplyRunnable.get());
michael@0 422
michael@0 423 NS_ENSURE_TRUE(result, false);
michael@0 424
michael@0 425 return true;
michael@0 426 }
michael@0 427
michael@0 428 bool
michael@0 429 BluetoothRequestParent::DoRequest(const SetPasskeyRequest& aRequest)
michael@0 430 {
michael@0 431 MOZ_ASSERT(mService);
michael@0 432 MOZ_ASSERT(mRequestType == Request::TSetPasskeyRequest);
michael@0 433
michael@0 434 bool result =
michael@0 435 mService->SetPasskeyInternal(aRequest.path(),
michael@0 436 aRequest.passkey(),
michael@0 437 mReplyRunnable.get());
michael@0 438
michael@0 439 NS_ENSURE_TRUE(result, false);
michael@0 440
michael@0 441 return true;
michael@0 442 }
michael@0 443
michael@0 444 bool
michael@0 445 BluetoothRequestParent::DoRequest(const ConfirmPairingConfirmationRequest&
michael@0 446 aRequest)
michael@0 447 {
michael@0 448 MOZ_ASSERT(mService);
michael@0 449 MOZ_ASSERT(mRequestType == Request::TConfirmPairingConfirmationRequest);
michael@0 450
michael@0 451 bool result =
michael@0 452 mService->SetPairingConfirmationInternal(aRequest.path(),
michael@0 453 true,
michael@0 454 mReplyRunnable.get());
michael@0 455
michael@0 456 NS_ENSURE_TRUE(result, false);
michael@0 457
michael@0 458 return true;
michael@0 459 }
michael@0 460
michael@0 461 bool
michael@0 462 BluetoothRequestParent::DoRequest(const DenyPairingConfirmationRequest&
michael@0 463 aRequest)
michael@0 464 {
michael@0 465 MOZ_ASSERT(mService);
michael@0 466 MOZ_ASSERT(mRequestType == Request::TDenyPairingConfirmationRequest);
michael@0 467
michael@0 468 bool result =
michael@0 469 mService->SetPairingConfirmationInternal(aRequest.path(),
michael@0 470 false,
michael@0 471 mReplyRunnable.get());
michael@0 472
michael@0 473 NS_ENSURE_TRUE(result, false);
michael@0 474
michael@0 475 return true;
michael@0 476 }
michael@0 477
michael@0 478 bool
michael@0 479 BluetoothRequestParent::DoRequest(const ConnectRequest& aRequest)
michael@0 480 {
michael@0 481 MOZ_ASSERT(mService);
michael@0 482 MOZ_ASSERT(mRequestType == Request::TConnectRequest);
michael@0 483
michael@0 484 mService->Connect(aRequest.address(),
michael@0 485 aRequest.cod(),
michael@0 486 aRequest.serviceUuid(),
michael@0 487 mReplyRunnable.get());
michael@0 488
michael@0 489 return true;
michael@0 490 }
michael@0 491
michael@0 492 bool
michael@0 493 BluetoothRequestParent::DoRequest(const DisconnectRequest& aRequest)
michael@0 494 {
michael@0 495 MOZ_ASSERT(mService);
michael@0 496 MOZ_ASSERT(mRequestType == Request::TDisconnectRequest);
michael@0 497
michael@0 498 mService->Disconnect(aRequest.address(),
michael@0 499 aRequest.serviceUuid(),
michael@0 500 mReplyRunnable.get());
michael@0 501
michael@0 502 return true;
michael@0 503 }
michael@0 504
michael@0 505 bool
michael@0 506 BluetoothRequestParent::DoRequest(const SendFileRequest& aRequest)
michael@0 507 {
michael@0 508 MOZ_ASSERT(mService);
michael@0 509 MOZ_ASSERT(mRequestType == Request::TSendFileRequest);
michael@0 510
michael@0 511 mService->SendFile(aRequest.devicePath(),
michael@0 512 (BlobParent*)aRequest.blobParent(),
michael@0 513 (BlobChild*)aRequest.blobChild(),
michael@0 514 mReplyRunnable.get());
michael@0 515
michael@0 516 return true;
michael@0 517 }
michael@0 518
michael@0 519 bool
michael@0 520 BluetoothRequestParent::DoRequest(const StopSendingFileRequest& aRequest)
michael@0 521 {
michael@0 522 MOZ_ASSERT(mService);
michael@0 523 MOZ_ASSERT(mRequestType == Request::TStopSendingFileRequest);
michael@0 524
michael@0 525 mService->StopSendingFile(aRequest.devicePath(),
michael@0 526 mReplyRunnable.get());
michael@0 527
michael@0 528 return true;
michael@0 529 }
michael@0 530
michael@0 531 bool
michael@0 532 BluetoothRequestParent::DoRequest(const ConfirmReceivingFileRequest& aRequest)
michael@0 533 {
michael@0 534 MOZ_ASSERT(mService);
michael@0 535 MOZ_ASSERT(mRequestType == Request::TConfirmReceivingFileRequest);
michael@0 536
michael@0 537 mService->ConfirmReceivingFile(aRequest.devicePath(),
michael@0 538 true,
michael@0 539 mReplyRunnable.get());
michael@0 540 return true;
michael@0 541 }
michael@0 542
michael@0 543 bool
michael@0 544 BluetoothRequestParent::DoRequest(const DenyReceivingFileRequest& aRequest)
michael@0 545 {
michael@0 546 MOZ_ASSERT(mService);
michael@0 547 MOZ_ASSERT(mRequestType == Request::TDenyReceivingFileRequest);
michael@0 548
michael@0 549 mService->ConfirmReceivingFile(aRequest.devicePath(),
michael@0 550 false,
michael@0 551 mReplyRunnable.get());
michael@0 552 return true;
michael@0 553 }
michael@0 554
michael@0 555 bool
michael@0 556 BluetoothRequestParent::DoRequest(const ConnectScoRequest& aRequest)
michael@0 557 {
michael@0 558 MOZ_ASSERT(mService);
michael@0 559 MOZ_ASSERT(mRequestType == Request::TConnectScoRequest);
michael@0 560
michael@0 561 mService->ConnectSco(mReplyRunnable.get());
michael@0 562 return true;
michael@0 563 }
michael@0 564
michael@0 565 bool
michael@0 566 BluetoothRequestParent::DoRequest(const DisconnectScoRequest& aRequest)
michael@0 567 {
michael@0 568 MOZ_ASSERT(mService);
michael@0 569 MOZ_ASSERT(mRequestType == Request::TDisconnectScoRequest);
michael@0 570
michael@0 571 mService->DisconnectSco(mReplyRunnable.get());
michael@0 572 return true;
michael@0 573 }
michael@0 574
michael@0 575 bool
michael@0 576 BluetoothRequestParent::DoRequest(const IsScoConnectedRequest& aRequest)
michael@0 577 {
michael@0 578 MOZ_ASSERT(mService);
michael@0 579 MOZ_ASSERT(mRequestType == Request::TIsScoConnectedRequest);
michael@0 580
michael@0 581 mService->IsScoConnected(mReplyRunnable.get());
michael@0 582 return true;
michael@0 583 }
michael@0 584
michael@0 585 #ifdef MOZ_B2G_RIL
michael@0 586 bool
michael@0 587 BluetoothRequestParent::DoRequest(const AnswerWaitingCallRequest& aRequest)
michael@0 588 {
michael@0 589 MOZ_ASSERT(mService);
michael@0 590 MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
michael@0 591
michael@0 592 mService->AnswerWaitingCall(mReplyRunnable.get());
michael@0 593
michael@0 594 return true;
michael@0 595 }
michael@0 596
michael@0 597 bool
michael@0 598 BluetoothRequestParent::DoRequest(const IgnoreWaitingCallRequest& aRequest)
michael@0 599 {
michael@0 600 MOZ_ASSERT(mService);
michael@0 601 MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
michael@0 602
michael@0 603 mService->IgnoreWaitingCall(mReplyRunnable.get());
michael@0 604
michael@0 605 return true;
michael@0 606 }
michael@0 607
michael@0 608 bool
michael@0 609 BluetoothRequestParent::DoRequest(const ToggleCallsRequest& aRequest)
michael@0 610 {
michael@0 611 MOZ_ASSERT(mService);
michael@0 612 MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
michael@0 613
michael@0 614 mService->ToggleCalls(mReplyRunnable.get());
michael@0 615
michael@0 616 return true;
michael@0 617 }
michael@0 618 #endif // MOZ_B2G_RIL
michael@0 619
michael@0 620 bool
michael@0 621 BluetoothRequestParent::DoRequest(const SendMetaDataRequest& aRequest)
michael@0 622 {
michael@0 623 MOZ_ASSERT(mService);
michael@0 624 MOZ_ASSERT(mRequestType == Request::TSendMetaDataRequest);
michael@0 625
michael@0 626 mService->SendMetaData(aRequest.title(),
michael@0 627 aRequest.artist(),
michael@0 628 aRequest.album(),
michael@0 629 aRequest.mediaNumber(),
michael@0 630 aRequest.totalMediaCount(),
michael@0 631 aRequest.duration(),
michael@0 632 mReplyRunnable.get());
michael@0 633 return true;
michael@0 634 }
michael@0 635
michael@0 636 bool
michael@0 637 BluetoothRequestParent::DoRequest(const SendPlayStatusRequest& aRequest)
michael@0 638 {
michael@0 639 MOZ_ASSERT(mService);
michael@0 640 MOZ_ASSERT(mRequestType == Request::TSendPlayStatusRequest);
michael@0 641
michael@0 642 mService->SendPlayStatus(aRequest.duration(),
michael@0 643 aRequest.position(),
michael@0 644 aRequest.playStatus(),
michael@0 645 mReplyRunnable.get());
michael@0 646 return true;
michael@0 647 }

mercurial