From 3922bae1fb444d1ba5990f3acf77ae85657ad94b Mon Sep 17 00:00:00 2001 From: Ben Hsu Date: Mon, 18 May 2015 01:03:00 -0400 Subject: [PATCH] Bug 1147736 - Part 1: Extend TelephonyCallInfo. r=aknow --HG-- extra : rebase_source : 92be87ade27902ff3cdd451d97586ea2f35095ed --- dom/telephony/TelephonyCallInfo.cpp | 13 +++++++++ dom/telephony/TelephonyCallInfo.h | 24 +++++++++++---- dom/telephony/gonk/TelephonyService.js | 6 ++++ dom/telephony/ipc/TelephonyIPCSerializer.h | 34 +++++++++++++++++++--- dom/telephony/nsITelephonyCallInfo.idl | 10 ++++++- 5 files changed, 76 insertions(+), 11 deletions(-) diff --git a/dom/telephony/TelephonyCallInfo.cpp b/dom/telephony/TelephonyCallInfo.cpp index fe45afc523d5..8ad6923f8c21 100644 --- a/dom/telephony/TelephonyCallInfo.cpp +++ b/dom/telephony/TelephonyCallInfo.cpp @@ -15,10 +15,13 @@ NS_IMPL_ISUPPORTS(TelephonyCallInfo, nsITelephonyCallInfo) TelephonyCallInfo::TelephonyCallInfo(uint32_t aClientId, uint32_t aCallIndex, uint16_t aCallState, + const nsAString& aDisconnectedReason, + const nsAString& aNumber, uint16_t aNumberPresentation, const nsAString& aName, uint16_t aNamePresentation, + bool aIsOutgoing, bool aIsEmergency, bool aIsConference, @@ -27,10 +30,13 @@ TelephonyCallInfo::TelephonyCallInfo(uint32_t aClientId, : mClientId(aClientId), mCallIndex(aCallIndex), mCallState(aCallState), + mDisconnectedReason(aDisconnectedReason), + mNumber(aNumber), mNumberPresentation(aNumberPresentation), mName(aName), mNamePresentation(aNamePresentation), + mIsOutgoing(aIsOutgoing), mIsEmergency(aIsEmergency), mIsConference(aIsConference), @@ -60,6 +66,13 @@ TelephonyCallInfo::GetCallState(uint16_t* aCallState) return NS_OK; } +NS_IMETHODIMP +TelephonyCallInfo::GetDisconnectedReason(nsAString& aDisconnectedReason) +{ + aDisconnectedReason = mDisconnectedReason; + return NS_OK; +} + NS_IMETHODIMP TelephonyCallInfo::GetNumber(nsAString& aNumber) { diff --git a/dom/telephony/TelephonyCallInfo.h b/dom/telephony/TelephonyCallInfo.h index 689cca44579c..81be49aa5b6b 100644 --- a/dom/telephony/TelephonyCallInfo.h +++ b/dom/telephony/TelephonyCallInfo.h @@ -21,12 +21,21 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSITELEPHONYCALLINFO - TelephonyCallInfo(uint32_t aClientId, uint32_t aCallIndex, - uint16_t aCallState, const nsAString& aNumber, - uint16_t aNumberPresentation, const nsAString& aName, - uint16_t aNamePresentation, bool aIsOutgoing, - bool aIsEmergency, bool aIsConference, - bool aIsSwitchable, bool aIsMergeable); + TelephonyCallInfo(uint32_t aClientId, + uint32_t aCallIndex, + uint16_t aCallState, + const nsAString& aDisconnectedReason, + + const nsAString& aNumber, + uint16_t aNumberPresentation, + const nsAString& aName, + uint16_t aNamePresentation, + + bool aIsOutgoing, + bool aIsEmergency, + bool aIsConference, + bool aIsSwitchable, + bool aIsMergeable); private: // Don't try to use the default constructor. @@ -37,10 +46,13 @@ private: uint32_t mClientId; uint32_t mCallIndex; uint16_t mCallState; + nsString mDisconnectedReason; + nsString mNumber; uint16_t mNumberPresentation; nsString mName; uint16_t mNamePresentation; + bool mIsOutgoing; bool mIsEmergency; bool mIsConference; diff --git a/dom/telephony/gonk/TelephonyService.js b/dom/telephony/gonk/TelephonyService.js index 9e741d329ff1..6b9563077807 100644 --- a/dom/telephony/gonk/TelephonyService.js +++ b/dom/telephony/gonk/TelephonyService.js @@ -124,10 +124,13 @@ function TelephonyCallInfo(aCall) { this.clientId = aCall.clientId; this.callIndex = aCall.callIndex; this.callState = aCall.state; + this.disconnectedReason = aCall.disconnectedReason || ""; + this.number = aCall.number; this.numberPresentation = aCall.numberPresentation; this.name = aCall.name; this.namePresentation = aCall.namePresentation; + this.isOutgoing = aCall.isOutgoing; this.isEmergency = aCall.isEmergency; this.isConference = aCall.isConference; @@ -148,10 +151,13 @@ TelephonyCallInfo.prototype = { clientId: 0, callIndex: 0, callState: nsITelephonyService.CALL_STATE_UNKNOWN, + disconnectedReason: "", + number: "", numberPresentation: nsITelephonyService.CALL_PRESENTATION_ALLOWED, name: "", namePresentation: nsITelephonyService.CALL_PRESENTATION_ALLOWED, + isOutgoing: true, isEmergency: false, isConference: false, diff --git a/dom/telephony/ipc/TelephonyIPCSerializer.h b/dom/telephony/ipc/TelephonyIPCSerializer.h index 54a439aa2f08..a0f22d741892 100644 --- a/dom/telephony/ipc/TelephonyIPCSerializer.h +++ b/dom/telephony/ipc/TelephonyIPCSerializer.h @@ -37,10 +37,13 @@ struct ParamTraits uint32_t clientId; uint32_t callIndex; uint16_t callState; + nsString disconnectedReason; + nsString number; uint16_t numberPresentation; nsString name; uint16_t namePresentation; + bool isOutgoing; bool isEmergency; bool isConference; @@ -50,10 +53,13 @@ struct ParamTraits aParam->GetClientId(&clientId); aParam->GetCallIndex(&callIndex); aParam->GetCallState(&callState); + aParam->GetDisconnectedReason(disconnectedReason); + aParam->GetNumber(number); aParam->GetNumberPresentation(&numberPresentation); aParam->GetName(name); aParam->GetNamePresentation(&namePresentation); + aParam->GetIsOutgoing(&isOutgoing); aParam->GetIsEmergency(&isEmergency); aParam->GetIsConference(&isConference); @@ -63,10 +69,13 @@ struct ParamTraits WriteParam(aMsg, clientId); WriteParam(aMsg, callIndex); WriteParam(aMsg, callState); + WriteParam(aMsg, disconnectedReason); + WriteParam(aMsg, number); WriteParam(aMsg, numberPresentation); WriteParam(aMsg, name); WriteParam(aMsg, namePresentation); + WriteParam(aMsg, isOutgoing); WriteParam(aMsg, isEmergency); WriteParam(aMsg, isConference); @@ -90,10 +99,13 @@ struct ParamTraits uint32_t clientId; uint32_t callIndex; uint16_t callState; + nsString disconnectedReason; + nsString number; uint16_t numberPresentation; nsString name; uint16_t namePresentation; + bool isOutgoing; bool isEmergency; bool isConference; @@ -104,10 +116,13 @@ struct ParamTraits if (!(ReadParam(aMsg, aIter, &clientId) && ReadParam(aMsg, aIter, &callIndex) && ReadParam(aMsg, aIter, &callState) && + ReadParam(aMsg, aIter, &disconnectedReason) && + ReadParam(aMsg, aIter, &number) && ReadParam(aMsg, aIter, &numberPresentation) && ReadParam(aMsg, aIter, &name) && ReadParam(aMsg, aIter, &namePresentation) && + ReadParam(aMsg, aIter, &isOutgoing) && ReadParam(aMsg, aIter, &isEmergency) && ReadParam(aMsg, aIter, &isConference) && @@ -117,10 +132,21 @@ struct ParamTraits } nsCOMPtr info = - new TelephonyCallInfo(clientId, callIndex, callState, number, - numberPresentation, name, namePresentation, - isOutgoing, isEmergency, isConference, - isSwitchable, isMergeable); + new TelephonyCallInfo(clientId, + callIndex, + callState, + disconnectedReason, + + number, + numberPresentation, + name, + namePresentation, + + isOutgoing, + isEmergency, + isConference, + isSwitchable, + isMergeable); info.forget(aResult); diff --git a/dom/telephony/nsITelephonyCallInfo.idl b/dom/telephony/nsITelephonyCallInfo.idl index 3561ec4e0668..e179b7006049 100644 --- a/dom/telephony/nsITelephonyCallInfo.idl +++ b/dom/telephony/nsITelephonyCallInfo.idl @@ -4,7 +4,7 @@ #include "nsISupports.idl" -[scriptable, uuid(3ea2d155-8ea2-42be-85d7-bd8ede8afc40)] +[scriptable, uuid(e5e1be26-a3d4-49b3-8d9f-c1df5192b364)] interface nsITelephonyCallInfo : nsISupports { /** @@ -22,6 +22,14 @@ interface nsITelephonyCallInfo : nsISupports */ readonly attribute unsigned short callState; + /** + * The disconnectedReason of a call is defualt to an empty string when the + * call is "not disconnected", but once the call becomes "disconnected" the + * disconnectedReason should be a non-empty string no matter the call is + * disconnected for a noraml reason or an error. + */ + readonly attribute DOMString disconnectedReason; + /** * Number of the other party. */