gecko-dev/dom/telephony/ipc/TelephonyChild.cpp

186 lines
4.9 KiB
C++
Raw Normal View History

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/. */
#include "TelephonyChild.h"
#include "TelephonyIPCService.h"
2013-09-07 06:19:53 +00:00
USING_TELEPHONY_NAMESPACE
/*******************************************************************************
* TelephonyChild
******************************************************************************/
TelephonyChild::TelephonyChild(TelephonyIPCService* aService)
: mService(aService)
{
MOZ_ASSERT(aService);
}
TelephonyChild::~TelephonyChild()
2013-09-07 06:19:53 +00:00
{
}
void
TelephonyChild::ActorDestroy(ActorDestroyReason aWhy)
{
if (mService) {
mService->NoteActorDestroyed();
mService = nullptr;
}
2013-09-07 06:19:53 +00:00
}
PTelephonyRequestChild*
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
TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId,
const int32_t& aCallIndex,
2013-09-07 06:19:53 +00:00
const nsString& aError)
{
MOZ_ASSERT(mService);
2013-09-07 06:19:53 +00:00
mService->NotifyError(aClientId, aCallIndex, aError);
2013-09-07 06:19:53 +00:00
return true;
}
bool
TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId,
const IPCCallStateData& aData)
2013-09-07 06:19:53 +00:00
{
MOZ_ASSERT(mService);
2013-09-07 06:19:53 +00:00
mService->CallStateChanged(aClientId,
aData.callIndex(),
2013-09-07 06:19:53 +00:00
aData.callState(),
aData.number(),
aData.isOutGoing(),
aData.isEmergency(),
aData.isConference(),
aData.isSwitchable(),
aData.isMergeable());
2013-09-07 06:19:53 +00:00
return true;
}
bool
TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId,
const nsString& aNumber)
2013-09-07 06:19:53 +00:00
{
MOZ_ASSERT(mService);
2013-09-07 06:19:53 +00:00
mService->NotifyCdmaCallWaiting(aClientId, aNumber);
2013-09-07 06:19:53 +00:00
return true;
}
bool
TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState)
{
MOZ_ASSERT(mService);
2013-09-07 06:19:53 +00:00
mService->ConferenceCallStateChanged(aCallState);
2013-09-07 06:19:53 +00:00
return true;
}
bool
TelephonyChild::RecvNotifyConferenceError(const nsString& aName,
const nsString& aMessage)
{
MOZ_ASSERT(mService);
mService->NotifyConferenceError(aName, aMessage);
return true;
}
2013-09-07 06:19:53 +00:00
bool
TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId,
const int32_t& aCallIndex,
2013-09-07 06:19:53 +00:00
const uint16_t& aNotification)
{
MOZ_ASSERT(mService);
2013-09-07 06:19:53 +00:00
mService->SupplementaryServiceNotification(aClientId, aCallIndex,
aNotification);
2013-09-07 06:19:53 +00:00
return true;
}
/*******************************************************************************
* TelephonyRequestChild
******************************************************************************/
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;
mCallback = nullptr;
2013-09-07 06:19:53 +00:00
}
bool
TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse)
2013-09-07 06:19:53 +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
TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId,
const IPCCallStateData& aData)
2013-09-07 06:19:53 +00:00
{
MOZ_ASSERT(mListener);
mListener->EnumerateCallState(aClientId,
aData.callIndex(),
2013-09-07 06:19:53 +00:00
aData.callState(),
aData.number(),
aData.isOutGoing(),
aData.isEmergency(),
aData.isConference(),
aData.isSwitchable(),
aData.isMergeable());
2013-09-07 06:19:53 +00:00
return true;
}
bool
TelephonyRequestChild::RecvNotifyDialError(const nsString& aError)
{
MOZ_ASSERT(mCallback);
mCallback->NotifyDialError(aError);
return true;
}
bool
TelephonyRequestChild::RecvNotifyDialSuccess(const uint32_t& aCallIndex)
{
MOZ_ASSERT(mCallback);
mCallback->NotifyDialSuccess(aCallIndex);
return true;
}