2013-09-07 06:19:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
2014-05-08 18:41:58 +00:00
|
|
|
#include "TelephonyChild.h"
|
2014-09-22 05:34:00 +00:00
|
|
|
|
2014-10-15 06:50:00 +00:00
|
|
|
#include "mozilla/dom/telephony/TelephonyDialCallback.h"
|
2014-06-03 14:15:25 +00:00
|
|
|
#include "TelephonyIPCService.h"
|
2013-09-07 06:19:53 +00:00
|
|
|
|
|
|
|
USING_TELEPHONY_NAMESPACE
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* TelephonyChild
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-06-03 14:15:30 +00:00
|
|
|
TelephonyChild::TelephonyChild(TelephonyIPCService* aService)
|
|
|
|
: mService(aService)
|
2014-05-08 18:41:58 +00:00
|
|
|
{
|
2014-06-03 14:15:30 +00:00
|
|
|
MOZ_ASSERT(aService);
|
2014-05-08 18:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TelephonyChild::~TelephonyChild()
|
2013-09-07 06:19:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TelephonyChild::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
2014-06-03 14:15:30 +00:00
|
|
|
if (mService) {
|
|
|
|
mService->NoteActorDestroyed();
|
|
|
|
mService = nullptr;
|
2014-05-08 18:41:58 +00:00
|
|
|
}
|
2013-09-07 06:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PTelephonyRequestChild*
|
2014-02-27 06:12:30 +00:00
|
|
|
TelephonyChild::AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest)
|
2013-09-07 06:19:53 +00:00
|
|
|
{
|
|
|
|
MOZ_CRASH("Caller is supposed to manually construct a request!");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TelephonyChild::DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-10-31 12:05:51 +00:00
|
|
|
TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId,
|
|
|
|
const int32_t& aCallIndex,
|
2013-09-07 06:19:53 +00:00
|
|
|
const nsString& aError)
|
|
|
|
{
|
2014-06-03 14:15:30 +00:00
|
|
|
MOZ_ASSERT(mService);
|
2013-09-07 06:19:53 +00:00
|
|
|
|
2014-06-03 14:15:30 +00:00
|
|
|
mService->NotifyError(aClientId, aCallIndex, aError);
|
2013-09-07 06:19:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-10-31 12:05:51 +00:00
|
|
|
TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId,
|
|
|
|
const IPCCallStateData& aData)
|
2013-09-07 06:19:53 +00:00
|
|
|
{
|
2014-06-03 14:15:30 +00:00
|
|
|
MOZ_ASSERT(mService);
|
2013-09-07 06:19:53 +00:00
|
|
|
|
2014-06-03 14:15:30 +00:00
|
|
|
mService->CallStateChanged(aClientId,
|
2013-10-31 12:05:51 +00:00
|
|
|
aData.callIndex(),
|
2013-09-07 06:19:53 +00:00
|
|
|
aData.callState(),
|
|
|
|
aData.number(),
|
2014-04-10 06:25:42 +00:00
|
|
|
aData.numberPresentation(),
|
|
|
|
aData.name(),
|
|
|
|
aData.namePresentation(),
|
2013-09-07 06:19:53 +00:00
|
|
|
aData.isOutGoing(),
|
|
|
|
aData.isEmergency(),
|
2014-02-21 09:52:13 +00:00
|
|
|
aData.isConference(),
|
|
|
|
aData.isSwitchable(),
|
|
|
|
aData.isMergeable());
|
2013-09-07 06:19:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-10-31 12:05:51 +00:00
|
|
|
TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId,
|
2014-04-10 06:25:42 +00:00
|
|
|
const IPCCdmaWaitingCallData& aData)
|
2013-09-07 06:19:53 +00:00
|
|
|
{
|
2014-06-03 14:15:30 +00:00
|
|
|
MOZ_ASSERT(mService);
|
2013-09-07 06:19:53 +00:00
|
|
|
|
2014-04-10 06:25:42 +00:00
|
|
|
mService->NotifyCdmaCallWaiting(aClientId,
|
|
|
|
aData.number(),
|
|
|
|
aData.numberPresentation(),
|
|
|
|
aData.name(),
|
|
|
|
aData.namePresentation());
|
2013-09-07 06:19:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState)
|
|
|
|
{
|
2014-06-03 14:15:30 +00:00
|
|
|
MOZ_ASSERT(mService);
|
2013-09-07 06:19:53 +00:00
|
|
|
|
2014-06-03 14:15:30 +00:00
|
|
|
mService->ConferenceCallStateChanged(aCallState);
|
2013-09-07 06:19:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-28 06:43:14 +00:00
|
|
|
bool
|
|
|
|
TelephonyChild::RecvNotifyConferenceError(const nsString& aName,
|
|
|
|
const nsString& aMessage)
|
|
|
|
{
|
2014-06-03 14:15:30 +00:00
|
|
|
MOZ_ASSERT(mService);
|
2013-10-28 06:43:14 +00:00
|
|
|
|
2014-06-03 14:15:30 +00:00
|
|
|
mService->NotifyConferenceError(aName, aMessage);
|
2013-10-28 06:43:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-07 06:19:53 +00:00
|
|
|
bool
|
2013-10-31 12:05:51 +00:00
|
|
|
TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId,
|
|
|
|
const int32_t& aCallIndex,
|
2013-09-07 06:19:53 +00:00
|
|
|
const uint16_t& aNotification)
|
|
|
|
{
|
2014-06-03 14:15:30 +00:00
|
|
|
MOZ_ASSERT(mService);
|
2013-09-07 06:19:53 +00:00
|
|
|
|
2014-06-03 14:15:30 +00:00
|
|
|
mService->SupplementaryServiceNotification(aClientId, aCallIndex,
|
2013-10-31 12:05:51 +00:00
|
|
|
aNotification);
|
2013-09-07 06:19:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* TelephonyRequestChild
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-02-27 06:12:30 +00:00
|
|
|
TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener,
|
|
|
|
nsITelephonyCallback* aCallback)
|
|
|
|
: mListener(aListener), mCallback(aCallback)
|
2013-09-07 06:19:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TelephonyRequestChild::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
mListener = nullptr;
|
2014-02-27 06:12:30 +00:00
|
|
|
mCallback = nullptr;
|
2013-09-07 06:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-02-27 06:12:30 +00:00
|
|
|
TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse)
|
2013-09-07 06:19:53 +00:00
|
|
|
{
|
2014-02-27 06:12:30 +00:00
|
|
|
switch (aResponse.type()) {
|
|
|
|
case IPCTelephonyResponse::TEnumerateCallsResponse:
|
|
|
|
mListener->EnumerateCallStateComplete();
|
|
|
|
break;
|
2014-10-15 06:50:00 +00:00
|
|
|
case IPCTelephonyResponse::TSuccessResponse:
|
|
|
|
return DoResponse(aResponse.get_SuccessResponse());
|
|
|
|
case IPCTelephonyResponse::TErrorResponse:
|
|
|
|
return DoResponse(aResponse.get_ErrorResponse());
|
2014-09-22 05:34:00 +00:00
|
|
|
case IPCTelephonyResponse::TDialResponseCallSuccess:
|
|
|
|
return DoResponse(aResponse.get_DialResponseCallSuccess());
|
2014-09-22 05:35:00 +00:00
|
|
|
case IPCTelephonyResponse::TDialResponseMMISuccess:
|
|
|
|
return DoResponse(aResponse.get_DialResponseMMISuccess());
|
|
|
|
case IPCTelephonyResponse::TDialResponseMMIError:
|
|
|
|
return DoResponse(aResponse.get_DialResponseMMIError());
|
2014-02-27 06:12:30 +00:00
|
|
|
default:
|
|
|
|
MOZ_CRASH("Unknown type!");
|
|
|
|
}
|
2013-09-07 06:19:53 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-10-31 12:05:51 +00:00
|
|
|
TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId,
|
|
|
|
const IPCCallStateData& aData)
|
2013-09-07 06:19:53 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mListener);
|
|
|
|
|
2013-10-31 12:05:51 +00:00
|
|
|
mListener->EnumerateCallState(aClientId,
|
|
|
|
aData.callIndex(),
|
2013-09-07 06:19:53 +00:00
|
|
|
aData.callState(),
|
|
|
|
aData.number(),
|
2014-04-10 06:25:42 +00:00
|
|
|
aData.numberPresentation(),
|
|
|
|
aData.name(),
|
|
|
|
aData.namePresentation(),
|
2013-09-07 06:19:53 +00:00
|
|
|
aData.isOutGoing(),
|
|
|
|
aData.isEmergency(),
|
2014-02-21 09:52:13 +00:00
|
|
|
aData.isConference(),
|
|
|
|
aData.isSwitchable(),
|
|
|
|
aData.isMergeable());
|
2013-09-07 06:19:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-02-27 06:12:30 +00:00
|
|
|
|
2014-09-22 05:35:00 +00:00
|
|
|
bool
|
|
|
|
TelephonyRequestChild::RecvNotifyDialMMI(const nsString& aServiceCode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCallback);
|
2014-10-15 06:50:00 +00:00
|
|
|
nsCOMPtr<nsITelephonyDialCallback> callback = do_QueryInterface(mCallback);
|
|
|
|
callback->NotifyDialMMI(aServiceCode);
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-22 05:35:00 +00:00
|
|
|
|
2014-10-15 06:50:00 +00:00
|
|
|
bool
|
|
|
|
TelephonyRequestChild::DoResponse(const SuccessResponse& aResponse)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCallback);
|
|
|
|
mCallback->NotifySuccess();
|
2014-09-22 05:35:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-27 06:12:30 +00:00
|
|
|
bool
|
2014-10-15 06:50:00 +00:00
|
|
|
TelephonyRequestChild::DoResponse(const ErrorResponse& aResponse)
|
2014-02-27 06:12:30 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCallback);
|
2014-10-15 06:50:00 +00:00
|
|
|
mCallback->NotifyError(aResponse.name());
|
2014-02-27 06:12:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-09-22 05:34:00 +00:00
|
|
|
TelephonyRequestChild::DoResponse(const DialResponseCallSuccess& aResponse)
|
2014-02-27 06:12:30 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCallback);
|
2014-10-15 06:50:00 +00:00
|
|
|
nsCOMPtr<nsITelephonyDialCallback> callback = do_QueryInterface(mCallback);
|
|
|
|
callback->NotifyDialCallSuccess(aResponse.callIndex(), aResponse.number());
|
2014-02-27 06:12:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-09-22 05:35:00 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
TelephonyRequestChild::DoResponse(const DialResponseMMISuccess& aResponse)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCallback);
|
2014-11-06 02:20:53 +00:00
|
|
|
nsCOMPtr<nsITelephonyDialCallback> callback = do_QueryInterface(mCallback);
|
2014-09-22 05:35:00 +00:00
|
|
|
|
|
|
|
nsAutoString statusMessage(aResponse.statusMessage());
|
|
|
|
AdditionalInformation info(aResponse.additionalInformation());
|
|
|
|
|
|
|
|
switch (info.type()) {
|
|
|
|
case AdditionalInformation::Tvoid_t:
|
|
|
|
callback->NotifyDialMMISuccess(statusMessage);
|
|
|
|
break;
|
2014-11-06 02:20:53 +00:00
|
|
|
case AdditionalInformation::Tuint16_t:
|
|
|
|
callback->NotifyDialMMISuccessWithInteger(statusMessage, info.get_uint16_t());
|
|
|
|
break;
|
|
|
|
case AdditionalInformation::TArrayOfnsString: {
|
|
|
|
uint32_t count = info.get_ArrayOfnsString().Length();
|
|
|
|
const nsTArray<nsString>& additionalInformation = info.get_ArrayOfnsString();
|
|
|
|
|
|
|
|
nsAutoArrayPtr<const char16_t*> additionalInfoPtrs(new const char16_t*[count]);
|
|
|
|
for (size_t i = 0; i < count; ++i) {
|
|
|
|
additionalInfoPtrs[i] = additionalInformation[i].get();
|
|
|
|
}
|
|
|
|
|
|
|
|
callback->NotifyDialMMISuccessWithStrings(statusMessage, count, additionalInfoPtrs);
|
2014-09-22 05:35:00 +00:00
|
|
|
break;
|
2014-11-06 02:20:53 +00:00
|
|
|
}
|
|
|
|
case AdditionalInformation::TArrayOfnsMobileCallForwardingOptions: {
|
|
|
|
uint32_t count = info.get_ArrayOfnsMobileCallForwardingOptions().Length();
|
|
|
|
|
|
|
|
nsTArray<nsCOMPtr<nsIMobileCallForwardingOptions>> results;
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
|
|
|
// Use dont_AddRef here because these instances are already AddRef-ed in
|
|
|
|
// MobileConnectionIPCSerializer.h
|
|
|
|
nsCOMPtr<nsIMobileCallForwardingOptions> item = dont_AddRef(
|
|
|
|
info.get_ArrayOfnsMobileCallForwardingOptions()[i]);
|
|
|
|
results.AppendElement(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
callback->NotifyDialMMISuccessWithCallForwardingOptions(statusMessage, count,
|
|
|
|
const_cast<nsIMobileCallForwardingOptions**>(info.get_ArrayOfnsMobileCallForwardingOptions().Elements()));
|
2014-09-22 05:35:00 +00:00
|
|
|
break;
|
2014-11-06 02:20:53 +00:00
|
|
|
}
|
2014-09-22 05:35:00 +00:00
|
|
|
default:
|
|
|
|
MOZ_CRASH("Received invalid type!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TelephonyRequestChild::DoResponse(const DialResponseMMIError& aResponse)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCallback);
|
2014-10-15 06:50:00 +00:00
|
|
|
nsCOMPtr<nsITelephonyDialCallback> callback = do_QueryInterface(mCallback);
|
2014-09-22 05:35:00 +00:00
|
|
|
|
|
|
|
nsAutoString name(aResponse.name());
|
|
|
|
AdditionalInformation info(aResponse.additionalInformation());
|
|
|
|
|
|
|
|
switch (info.type()) {
|
|
|
|
case AdditionalInformation::Tvoid_t:
|
2014-10-15 06:50:00 +00:00
|
|
|
callback->NotifyDialMMIError(name);
|
2014-09-22 05:35:00 +00:00
|
|
|
break;
|
|
|
|
case AdditionalInformation::Tuint16_t:
|
2014-10-15 06:50:00 +00:00
|
|
|
callback->NotifyDialMMIErrorWithInfo(name, info.get_uint16_t());
|
2014-09-22 05:35:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("Received invalid type!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|