diff --git a/dom/telephony/ipc/PTelephonyRequest.ipdl b/dom/telephony/ipc/PTelephonyRequest.ipdl index d1ded479d2a2..579dfd213337 100644 --- a/dom/telephony/ipc/PTelephonyRequest.ipdl +++ b/dom/telephony/ipc/PTelephonyRequest.ipdl @@ -16,15 +16,23 @@ struct EnumerateCallsResponse // empty. }; -struct DialResponse +struct DialResponseError { - // empty. + nsString name; +}; + +struct DialResponseCallSuccess +{ + uint32_t callIndex; + nsString number; }; union IPCTelephonyResponse { EnumerateCallsResponse; - DialResponse; + // dial + DialResponseError; + DialResponseCallSuccess; }; protocol PTelephonyRequest @@ -34,10 +42,6 @@ protocol PTelephonyRequest child: NotifyEnumerateCallState(uint32_t aClientId, IPCCallStateData aData); - NotifyDialError(nsString aError); - - NotifyDialCallSuccess(uint32_t aCallIndex, nsString aNumber); - /** * Sent when the asynchronous request has completed. */ diff --git a/dom/telephony/ipc/TelephonyChild.cpp b/dom/telephony/ipc/TelephonyChild.cpp index 9a28d0fea9e8..344dbca247e1 100644 --- a/dom/telephony/ipc/TelephonyChild.cpp +++ b/dom/telephony/ipc/TelephonyChild.cpp @@ -4,6 +4,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "TelephonyChild.h" + #include "TelephonyIPCService.h" USING_TELEPHONY_NAMESPACE @@ -145,9 +146,10 @@ TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse) case IPCTelephonyResponse::TEnumerateCallsResponse: mListener->EnumerateCallStateComplete(); break; - case IPCTelephonyResponse::TDialResponse: - // Do nothing. - break; + case IPCTelephonyResponse::TDialResponseError: + return DoResponse(aResponse.get_DialResponseError()); + case IPCTelephonyResponse::TDialResponseCallSuccess: + return DoResponse(aResponse.get_DialResponseCallSuccess()); default: MOZ_CRASH("Unknown type!"); } @@ -177,20 +179,17 @@ TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId, } bool -TelephonyRequestChild::RecvNotifyDialError(const nsString& aError) +TelephonyRequestChild::DoResponse(const DialResponseError& aResponse) { MOZ_ASSERT(mCallback); - - mCallback->NotifyDialError(aError); + mCallback->NotifyDialError(aResponse.name()); return true; } bool -TelephonyRequestChild::RecvNotifyDialCallSuccess(const uint32_t& aCallIndex, - const nsString& aNumber) +TelephonyRequestChild::DoResponse(const DialResponseCallSuccess& aResponse) { MOZ_ASSERT(mCallback); - - mCallback->NotifyDialCallSuccess(aCallIndex, aNumber); + mCallback->NotifyDialCallSuccess(aResponse.callIndex(), aResponse.number()); return true; } diff --git a/dom/telephony/ipc/TelephonyChild.h b/dom/telephony/ipc/TelephonyChild.h index ecb8d3f4833f..3f07bf8183db 100644 --- a/dom/telephony/ipc/TelephonyChild.h +++ b/dom/telephony/ipc/TelephonyChild.h @@ -79,14 +79,13 @@ protected: RecvNotifyEnumerateCallState(const uint32_t& aClientId, const IPCCallStateData& aData) MOZ_OVERRIDE; - virtual bool - RecvNotifyDialError(const nsString& aError) MOZ_OVERRIDE; - - virtual bool - RecvNotifyDialCallSuccess(const uint32_t& aCallIndex, - const nsString& aNumber) MOZ_OVERRIDE; - private: + bool + DoResponse(const DialResponseError& aResponse); + + bool + DoResponse(const DialResponseCallSuccess& aResponse); + nsCOMPtr mListener; nsCOMPtr mCallback; }; diff --git a/dom/telephony/ipc/TelephonyParent.cpp b/dom/telephony/ipc/TelephonyParent.cpp index 6a936ed6e509..75c5879a4d97 100644 --- a/dom/telephony/ipc/TelephonyParent.cpp +++ b/dom/telephony/ipc/TelephonyParent.cpp @@ -434,6 +434,14 @@ TelephonyRequestParent::DoRequest(const DialRequest& aRequest) return true; } +nsresult +TelephonyRequestParent::SendResponse(const IPCTelephonyResponse& aResponse) +{ + NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); + + return Send__delete__(this, aResponse) ? NS_OK : NS_ERROR_FAILURE; +} + // nsITelephonyListener NS_IMETHODIMP @@ -529,18 +537,12 @@ TelephonyRequestParent::SupplementaryServiceNotification(uint32_t aClientId, NS_IMETHODIMP TelephonyRequestParent::NotifyDialError(const nsAString& aError) { - NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - - return (SendNotifyDialError(nsString(aError)) && - Send__delete__(this, DialResponse())) ? NS_OK : NS_ERROR_FAILURE; + return SendResponse(DialResponseError(nsAutoString(aError))); } NS_IMETHODIMP TelephonyRequestParent::NotifyDialCallSuccess(uint32_t aCallIndex, const nsAString& aNumber) { - NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - - return (SendNotifyDialCallSuccess(aCallIndex, nsString(aNumber)) && - Send__delete__(this, DialResponse())) ? NS_OK : NS_ERROR_FAILURE; + return SendResponse(DialResponseCallSuccess(aCallIndex, nsAutoString(aNumber))); } diff --git a/dom/telephony/ipc/TelephonyParent.h b/dom/telephony/ipc/TelephonyParent.h index c23e7f8b2f2a..5989a6b45796 100644 --- a/dom/telephony/ipc/TelephonyParent.h +++ b/dom/telephony/ipc/TelephonyParent.h @@ -114,6 +114,9 @@ protected: virtual void ActorDestroy(ActorDestroyReason why); + nsresult + SendResponse(const IPCTelephonyResponse& aResponse); + private: bool mActorDestroyed;