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-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(),
|
|
|
|
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-06-17 07:37:31 +00:00
|
|
|
const nsString& aNumber)
|
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-17 07:37:31 +00:00
|
|
|
mService->NotifyCdmaCallWaiting(aClientId, aNumber);
|
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;
|
|
|
|
case IPCTelephonyResponse::TDialResponse:
|
|
|
|
// Do nothing.
|
|
|
|
break;
|
|
|
|
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(),
|
|
|
|
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
|
|
|
|
|
|
|
bool
|
|
|
|
TelephonyRequestChild::RecvNotifyDialError(const nsString& aError)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCallback);
|
|
|
|
|
|
|
|
mCallback->NotifyDialError(aError);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-05-26 17:08:00 +00:00
|
|
|
TelephonyRequestChild::RecvNotifyDialSuccess(const uint32_t& aCallIndex)
|
2014-02-27 06:12:30 +00:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCallback);
|
|
|
|
|
2014-05-26 17:08:00 +00:00
|
|
|
mCallback->NotifyDialSuccess(aCallIndex);
|
2014-02-27 06:12:30 +00:00
|
|
|
return true;
|
|
|
|
}
|