michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "mozilla/dom/telephony/TelephonyChild.h" michael@0: michael@0: USING_TELEPHONY_NAMESPACE michael@0: michael@0: /******************************************************************************* michael@0: * TelephonyChild michael@0: ******************************************************************************/ michael@0: michael@0: TelephonyChild::TelephonyChild(nsITelephonyListener* aListener) michael@0: : mListener(aListener) michael@0: { michael@0: MOZ_ASSERT(aListener); michael@0: } michael@0: michael@0: void michael@0: TelephonyChild::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: mListener = nullptr; michael@0: } michael@0: michael@0: PTelephonyRequestChild* michael@0: TelephonyChild::AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest) michael@0: { michael@0: MOZ_CRASH("Caller is supposed to manually construct a request!"); michael@0: } michael@0: michael@0: bool michael@0: TelephonyChild::DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) michael@0: { michael@0: delete aActor; michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId, michael@0: const int32_t& aCallIndex, michael@0: const nsString& aError) michael@0: { michael@0: MOZ_ASSERT(mListener); michael@0: michael@0: mListener->NotifyError(aClientId, aCallIndex, aError); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId, michael@0: const IPCCallStateData& aData) michael@0: { michael@0: MOZ_ASSERT(mListener); michael@0: michael@0: mListener->CallStateChanged(aClientId, michael@0: aData.callIndex(), michael@0: aData.callState(), michael@0: aData.number(), michael@0: aData.isActive(), michael@0: aData.isOutGoing(), michael@0: aData.isEmergency(), michael@0: aData.isConference(), michael@0: aData.isSwitchable(), michael@0: aData.isMergeable()); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, michael@0: const nsString& aNumber) michael@0: { michael@0: MOZ_ASSERT(mListener); michael@0: michael@0: mListener->NotifyCdmaCallWaiting(aClientId, aNumber); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) michael@0: { michael@0: MOZ_ASSERT(mListener); michael@0: michael@0: mListener->ConferenceCallStateChanged(aCallState); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyChild::RecvNotifyConferenceError(const nsString& aName, michael@0: const nsString& aMessage) michael@0: { michael@0: MOZ_ASSERT(mListener); michael@0: michael@0: mListener->NotifyConferenceError(aName, aMessage); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId, michael@0: const int32_t& aCallIndex, michael@0: const uint16_t& aNotification) michael@0: { michael@0: MOZ_ASSERT(mListener); michael@0: michael@0: mListener->SupplementaryServiceNotification(aClientId, aCallIndex, michael@0: aNotification); michael@0: return true; michael@0: } michael@0: michael@0: /******************************************************************************* michael@0: * TelephonyRequestChild michael@0: ******************************************************************************/ michael@0: michael@0: TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener, michael@0: nsITelephonyCallback* aCallback) michael@0: : mListener(aListener), mCallback(aCallback) michael@0: { michael@0: } michael@0: michael@0: void michael@0: TelephonyRequestChild::ActorDestroy(ActorDestroyReason aWhy) michael@0: { michael@0: mListener = nullptr; michael@0: mCallback = nullptr; michael@0: } michael@0: michael@0: bool michael@0: TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse) michael@0: { michael@0: switch (aResponse.type()) { michael@0: case IPCTelephonyResponse::TEnumerateCallsResponse: michael@0: mListener->EnumerateCallStateComplete(); michael@0: break; michael@0: case IPCTelephonyResponse::TDialResponse: michael@0: // Do nothing. michael@0: break; michael@0: default: michael@0: MOZ_CRASH("Unknown type!"); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId, michael@0: const IPCCallStateData& aData) michael@0: { michael@0: MOZ_ASSERT(mListener); michael@0: michael@0: mListener->EnumerateCallState(aClientId, michael@0: aData.callIndex(), michael@0: aData.callState(), michael@0: aData.number(), michael@0: aData.isActive(), michael@0: aData.isOutGoing(), michael@0: aData.isEmergency(), michael@0: aData.isConference(), michael@0: aData.isSwitchable(), michael@0: aData.isMergeable()); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyRequestChild::RecvNotifyDialError(const nsString& aError) michael@0: { michael@0: MOZ_ASSERT(mCallback); michael@0: michael@0: mCallback->NotifyDialError(aError); michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: TelephonyRequestChild::RecvNotifyDialSuccess() michael@0: { michael@0: MOZ_ASSERT(mCallback); michael@0: michael@0: mCallback->NotifyDialSuccess(); michael@0: return true; michael@0: }