Backed out changeset 598098217e1f (bug 981519) for causing regression bug 1026081

This commit is contained in:
Hsin-Yi Tsai 2014-06-17 15:37:31 +08:00
parent 06e8f97805
commit 3b9d73c70e
13 changed files with 46 additions and 289 deletions

View File

@ -25,7 +25,6 @@
#include "CallsList.h"
#include "TelephonyCall.h"
#include "TelephonyCallGroup.h"
#include "TelephonyCallId.h"
using namespace mozilla::dom;
using mozilla::ErrorResult;
@ -277,9 +276,6 @@ Telephony::CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber,
{
nsRefPtr<TelephonyCall> call =
TelephonyCall::Create(this, aServiceId, aNumber,
nsITelephonyService::CALL_PRESENTATION_ALLOWED,
EmptyString(),
nsITelephonyService::CALL_PRESENTATION_ALLOWED,
nsITelephonyService::CALL_STATE_DIALING, aCallIndex);
NS_ASSERTION(call, "This should never fail!");
@ -478,10 +474,8 @@ Telephony::EventListenerAdded(nsIAtom* aType)
NS_IMETHODIMP
Telephony::CallStateChanged(uint32_t aServiceId, 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)
bool aIsOutgoing, bool aIsEmergency,
bool aIsConference, bool aIsSwitchable, bool aIsMergeable)
{
nsRefPtr<TelephonyCall> modifiedCall
= GetCallFromEverywhere(aServiceId, aCallIndex);
@ -526,10 +520,9 @@ Telephony::CallStateChanged(uint32_t aServiceId, uint32_t aCallIndex,
// Didn't find this call in mCalls or mGroup. Create a new call.
nsRefPtr<TelephonyCall> call =
TelephonyCall::Create(this, aServiceId, aNumber, aNumberPresentation,
aName, aNamePresentation, aCallState, aCallIndex,
aIsEmergency, aIsConference, aIsSwitchable,
aIsMergeable);
TelephonyCall::Create(this, aServiceId, aNumber, aCallState, aCallIndex,
aIsEmergency, aIsConference, aIsSwitchable,
aIsMergeable);
NS_ASSERTION(call, "This should never fail!");
NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) :
@ -571,10 +564,8 @@ Telephony::EnumerateCallStateComplete()
NS_IMETHODIMP
Telephony::EnumerateCallState(uint32_t aServiceId, 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)
bool aIsOutgoing, bool aIsEmergency,
bool aIsConference, bool aIsSwitchable, bool aIsMergeable)
{
nsRefPtr<TelephonyCall> call;
@ -589,8 +580,7 @@ Telephony::EnumerateCallState(uint32_t aServiceId, uint32_t aCallIndex,
}
// Didn't know anything about this call before now.
call = TelephonyCall::Create(this, aServiceId, aNumber, aNumberPresentation,
aName, aNamePresentation, aCallState,
call = TelephonyCall::Create(this, aServiceId, aNumber, aCallState,
aCallIndex, aIsEmergency, aIsConference,
aIsSwitchable, aIsMergeable);
NS_ASSERTION(call, "This should never fail!");
@ -652,20 +642,14 @@ Telephony::NotifyError(uint32_t aServiceId,
}
NS_IMETHODIMP
Telephony::NotifyCdmaCallWaiting(uint32_t aServiceId, const nsAString& aNumber,
uint16_t aNumberPresentation,
const nsAString& aName,
uint16_t aNamePresentation)
Telephony::NotifyCdmaCallWaiting(uint32_t aServiceId, const nsAString& aNumber)
{
MOZ_ASSERT(mCalls.Length() == 1);
nsRefPtr<TelephonyCall> callToNotify = mCalls[0];
MOZ_ASSERT(callToNotify && callToNotify->ServiceId() == aServiceId);
nsRefPtr<TelephonyCallId> id =
new TelephonyCallId(GetOwner(), aNumber, aNumberPresentation, aName,
aNamePresentation);
callToNotify->UpdateSecondId(id);
callToNotify->UpdateSecondNumber(aNumber);
DispatchCallEvent(NS_LITERAL_STRING("callschanged"), callToNotify);
return NS_OK;
}

View File

@ -19,29 +19,25 @@ using mozilla::ErrorResult;
// static
already_AddRefed<TelephonyCall>
TelephonyCall::Create(Telephony* aTelephony, uint32_t aServiceId,
const nsAString& aNumber, uint16_t aNumberPresentation,
const nsAString& aName, uint16_t aNamePresentation,
uint16_t aCallState, uint32_t aCallIndex, bool aEmergency,
bool aIsConference, bool aSwitchable, bool aMergeable)
const nsAString& aNumber, uint16_t aCallState,
uint32_t aCallIndex, bool aEmergency, bool aIsConference,
bool aSwitchable, bool aMergeable)
{
NS_ASSERTION(aTelephony, "Null pointer!");
NS_ASSERTION(!aNumber.IsEmpty(), "Empty number!");
NS_ASSERTION(aCallIndex >= 1, "Invalid call index!");
nsRefPtr<TelephonyCall> call = new TelephonyCall(aTelephony->GetOwner());
nsRefPtr<TelephonyCallId> id = new TelephonyCallId(aTelephony->GetOwner(),
aNumber, aNumberPresentation,
aName, aNamePresentation);
call->mTelephony = aTelephony;
call->mServiceId = aServiceId;
call->mNumber = aNumber;
call->mCallIndex = aCallIndex;
call->mError = nullptr;
call->mEmergency = aEmergency;
call->mGroup = aIsConference ? aTelephony->ConferenceGroup() : nullptr;
call->mSwitchable = aSwitchable;
call->mMergeable = aMergeable;
call->mId = id;
call->ChangeStateInternal(aCallState, false);
@ -191,9 +187,7 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(TelephonyCall,
DOMEventTargetHelper,
mTelephony,
mError,
mGroup,
mId,
mSecondId);
mGroup);
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TelephonyCall)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
@ -203,20 +197,6 @@ NS_IMPL_RELEASE_INHERITED(TelephonyCall, DOMEventTargetHelper)
// TelephonyCall WebIDL
already_AddRefed<TelephonyCallId>
TelephonyCall::Id() const
{
nsRefPtr<TelephonyCallId> id = mId;
return id.forget();
}
already_AddRefed<TelephonyCallId>
TelephonyCall::GetSecondId() const
{
nsRefPtr<TelephonyCallId> id = mSecondId;
return id.forget();
}
already_AddRefed<DOMError>
TelephonyCall::GetError() const
{
@ -292,7 +272,7 @@ TelephonyCall::Hold(ErrorResult& aRv)
return;
}
if (mSecondId) {
if (!mSecondNumber.IsEmpty()) {
// No state transition when we switch two numbers within one TelephonyCall
// object. Otherwise, the state here will be inconsistent with the backend
// RIL and will never be right.

View File

@ -11,8 +11,6 @@
#include "mozilla/dom/DOMError.h"
#include "TelephonyCallId.h"
class nsPIDOMWindow;
namespace mozilla {
@ -23,10 +21,9 @@ class TelephonyCall MOZ_FINAL : public DOMEventTargetHelper
nsRefPtr<Telephony> mTelephony;
nsRefPtr<TelephonyCallGroup> mGroup;
nsRefPtr<TelephonyCallId> mId;
nsRefPtr<TelephonyCallId> mSecondId;
uint32_t mServiceId;
nsString mNumber;
nsString mSecondNumber;
nsString mState;
bool mEmergency;
nsRefPtr<DOMError> mError;
@ -42,6 +39,7 @@ public:
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCall,
DOMEventTargetHelper)
friend class Telephony;
nsPIDOMWindow*
@ -55,11 +53,17 @@ public:
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// WebIDL
already_AddRefed<TelephonyCallId>
Id() const;
void
GetNumber(nsString& aNumber) const
{
aNumber.Assign(mNumber);
}
already_AddRefed<TelephonyCallId>
GetSecondId() const;
void
GetSecondNumber(nsString& aSecondNumber) const
{
aSecondNumber.Assign(mSecondNumber);
}
void
GetState(nsString& aState) const
@ -118,9 +122,7 @@ public:
static already_AddRefed<TelephonyCall>
Create(Telephony* aTelephony, uint32_t aServiceId,
const nsAString& aNumber, uint16_t aNumberPresentation,
const nsAString& aName, uint16_t aNamePresentation,
uint16_t aCallState, uint32_t aCallIndex,
const nsAString& aNumber, uint16_t aCallState, uint32_t aCallIndex,
bool aEmergency = false, bool aIsConference = false,
bool aSwitchable = true, bool aMergeable = true);
@ -154,6 +156,12 @@ public:
mEmergency = aEmergency;
}
void
UpdateSecondNumber(const nsAString& aNumber)
{
mSecondNumber = aNumber;
}
void
UpdateSwitchable(bool aSwitchable) {
mSwitchable = aSwitchable;
@ -164,11 +172,6 @@ public:
mMergeable = aMergeable;
}
void
UpdateSecondId(TelephonyCallId* aId) {
mSecondId = aId;
}
void
NotifyError(const nsAString& aError);

View File

@ -1,77 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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 "TelephonyCallId.h"
#include "nsITelephonyService.h"
namespace mozilla {
namespace dom {
TelephonyCallId::TelephonyCallId(nsPIDOMWindow* aWindow,
const nsAString& aNumber,
uint16_t aNumberPresentation,
const nsAString& aName,
uint16_t aNamePresentation)
: mWindow(aWindow), mNumber(aNumber), mNumberPresentation(aNumberPresentation),
mName(aName), mNamePresentation(aNamePresentation)
{
SetIsDOMBinding();
}
TelephonyCallId::~TelephonyCallId()
{
}
JSObject*
TelephonyCallId::WrapObject(JSContext* aCx)
{
return TelephonyCallIdBinding::Wrap(aCx, this);
}
CallIdPresentation
TelephonyCallId::GetPresentationStr(uint16_t aPresentation) const
{
switch (aPresentation) {
case nsITelephonyService::CALL_PRESENTATION_ALLOWED:
return CallIdPresentation::Allowed;
case nsITelephonyService::CALL_PRESENTATION_RESTRICTED:
return CallIdPresentation::Restricted;
case nsITelephonyService::CALL_PRESENTATION_UNKNOWN:
return CallIdPresentation::Unknown;
case nsITelephonyService::CALL_PRESENTATION_PAYPHONE:
return CallIdPresentation::Payphone;
default:
MOZ_ASSUME_UNREACHABLE("Bad presentation!");
}
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(TelephonyCallId, mWindow)
NS_IMPL_CYCLE_COLLECTING_ADDREF(TelephonyCallId)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TelephonyCallId)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TelephonyCallId)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
// WebIDL
CallIdPresentation
TelephonyCallId::NumberPresentation() const
{
return GetPresentationStr(mNumberPresentation);
}
CallIdPresentation
TelephonyCallId::NamePresentation() const
{
return GetPresentationStr(mNamePresentation);
}
} // namespace dom
} // namespace mozilla

View File

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */
#ifndef mozilla_dom_TelephonyCallId_h
#define mozilla_dom_TelephonyCallId_h
#include "mozilla/dom/TelephonyCallIdBinding.h"
#include "mozilla/dom/telephony/TelephonyCommon.h"
#include "nsWrapperCache.h"
class nsPIDOMWindow;
namespace mozilla {
namespace dom {
class TelephonyCallId MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TelephonyCallId)
TelephonyCallId(nsPIDOMWindow* aWindow, const nsAString& aNumber,
uint16_t aNumberPresentation, const nsAString& aName,
uint16_t aNamePresentation);
nsPIDOMWindow*
GetParentObject() const
{
return mWindow;
}
virtual JSObject*
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// WebIDL
void
GetNumber(nsString& aNumber) const
{
aNumber.Assign(mNumber);
}
CallIdPresentation
NumberPresentation() const;
void
GetName(nsString& aName) const
{
aName.Assign(mName);
}
CallIdPresentation
NamePresentation() const;
private:
~TelephonyCallId();
nsCOMPtr<nsPIDOMWindow> mWindow;
nsString mNumber;
uint16_t mNumberPresentation;
nsString mName;
uint16_t mNamePresentation;
CallIdPresentation
GetPresentationStr(uint16_t aPresentation) const;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_TelephonyCallId_h

View File

@ -39,7 +39,7 @@ child:
NotifyCallStateChanged(uint32_t aClientId, IPCCallStateData aData);
NotifyCdmaCallWaiting(uint32_t aClientId, IPCCdmaWaitingCallData aData);
NotifyCdmaCallWaiting(uint32_t aClientId, nsString aNumber);
NotifyConferenceCallStateChanged(uint16_t aCallState);

View File

@ -65,9 +65,6 @@ TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId,
aData.callIndex(),
aData.callState(),
aData.number(),
aData.numberPresentation(),
aData.name(),
aData.namePresentation(),
aData.isOutGoing(),
aData.isEmergency(),
aData.isConference(),
@ -78,15 +75,11 @@ TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId,
bool
TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId,
const IPCCdmaWaitingCallData& aData)
const nsString& aNumber)
{
MOZ_ASSERT(mService);
mService->NotifyCdmaCallWaiting(aClientId,
aData.number(),
aData.numberPresentation(),
aData.name(),
aData.namePresentation());
mService->NotifyCdmaCallWaiting(aClientId, aNumber);
return true;
}
@ -165,9 +158,6 @@ TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId,
aData.callIndex(),
aData.callState(),
aData.number(),
aData.numberPresentation(),
aData.name(),
aData.namePresentation(),
aData.isOutGoing(),
aData.isEmergency(),
aData.isConference(),

View File

@ -42,7 +42,7 @@ protected:
virtual bool
RecvNotifyCdmaCallWaiting(const uint32_t& aClientId,
const IPCCdmaWaitingCallData& aData) MOZ_OVERRIDE;
const nsString& aNumber) MOZ_OVERRIDE;
virtual bool
RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) MOZ_OVERRIDE;

View File

@ -355,9 +355,6 @@ TelephonyIPCService::CallStateChanged(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,
@ -366,7 +363,6 @@ TelephonyIPCService::CallStateChanged(uint32_t aClientId,
{
for (uint32_t i = 0; i < mListeners.Length(); i++) {
mListeners[i]->CallStateChanged(aClientId, aCallIndex, aCallState, aNumber,
aNumberPresentation, aName, aNamePresentation,
aIsOutgoing, aIsEmergency, aIsConference,
aIsSwitchable, aIsMergeable);
}
@ -393,9 +389,6 @@ TelephonyIPCService::EnumerateCallState(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,
@ -407,14 +400,10 @@ TelephonyIPCService::EnumerateCallState(uint32_t aClientId,
NS_IMETHODIMP
TelephonyIPCService::NotifyCdmaCallWaiting(uint32_t aClientId,
const nsAString& aNumber,
uint16_t aNumberPresentation,
const nsAString& aName,
uint16_t aNamePresentation)
const nsAString& aNumber)
{
for (uint32_t i = 0; i < mListeners.Length(); i++) {
mListeners[i]->NotifyCdmaCallWaiting(aClientId, aNumber, aNumberPresentation,
aName, aNamePresentation);
mListeners[i]->NotifyCdmaCallWaiting(aClientId, aNumber);
}
return NS_OK;
}

View File

@ -283,9 +283,6 @@ TelephonyParent::CallStateChanged(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,
@ -295,7 +292,6 @@ TelephonyParent::CallStateChanged(uint32_t aClientId,
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber),
aNumberPresentation, nsString(aName), aNamePresentation,
aIsOutgoing, aIsEmergency, aIsConference,
aIsSwitchable, aIsMergeable);
return SendNotifyCallStateChanged(aClientId, data) ? NS_OK : NS_ERROR_FAILURE;
@ -321,9 +317,6 @@ TelephonyParent::EnumerateCallState(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,
@ -335,16 +328,12 @@ TelephonyParent::EnumerateCallState(uint32_t aClientId,
NS_IMETHODIMP
TelephonyParent::NotifyCdmaCallWaiting(uint32_t aClientId,
const nsAString& aNumber,
uint16_t aNumberPresentation,
const nsAString& aName,
uint16_t aNamePresentation)
const nsAString& aNumber)
{
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
IPCCdmaWaitingCallData data(nsString(aNumber), aNumberPresentation,
nsString(aName), aNamePresentation);
return SendNotifyCdmaCallWaiting(aClientId, data) ? NS_OK : NS_ERROR_FAILURE;
return SendNotifyCdmaCallWaiting(aClientId, nsString(aNumber))
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -441,9 +430,6 @@ TelephonyRequestParent::CallStateChanged(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,
@ -472,9 +458,6 @@ TelephonyRequestParent::EnumerateCallState(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,
@ -484,7 +467,6 @@ TelephonyRequestParent::EnumerateCallState(uint32_t aClientId,
NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);
IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber),
aNumberPresentation, nsString(aName), aNamePresentation,
aIsOutgoing, aIsEmergency, aIsConference,
aIsSwitchable, aIsMergeable);
return SendNotifyEnumerateCallState(aClientId, data) ? NS_OK
@ -493,10 +475,7 @@ TelephonyRequestParent::EnumerateCallState(uint32_t aClientId,
NS_IMETHODIMP
TelephonyRequestParent::NotifyCdmaCallWaiting(uint32_t aClientId,
const nsAString& aNumber,
uint16_t aNumberPresentation,
const nsAString& aName,
uint16_t aNamePresentation)
const nsAString& aNumber)
{
MOZ_CRASH("Not a TelephonyParent!");
}

View File

@ -13,9 +13,6 @@ struct IPCCallStateData
uint32_t callIndex;
uint16_t callState;
nsString number;
uint16_t numberPresentation;
nsString name;
uint16_t namePresentation;
bool isOutGoing;
bool isEmergency;
bool isConference;
@ -23,14 +20,6 @@ struct IPCCallStateData
bool isMergeable;
};
struct IPCCdmaWaitingCallData
{
nsString number;
uint16_t numberPresentation;
nsString name;
uint16_t namePresentation;
};
} /* namespace telephony */
} /* namespace dom */
} /* namespace mozilla */

View File

@ -15,7 +15,6 @@ EXPORTS.mozilla.dom += [
'Telephony.h',
'TelephonyCall.h',
'TelephonyCallGroup.h',
'TelephonyCallId.h',
]
EXPORTS.mozilla.dom.telephony += [
@ -33,7 +32,6 @@ UNIFIED_SOURCES += [
'Telephony.cpp',
'TelephonyCall.cpp',
'TelephonyCallGroup.cpp',
'TelephonyCallId.cpp',
'TelephonyFactory.cpp',
]

View File

@ -1112,8 +1112,6 @@ var interfaceNamesInGlobalScope =
{name: "TelephonyCall", b2g: true, pref: "dom.telephony.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "TelephonyCallGroup", b2g: true, pref: "dom.telephony.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "TelephonyCallId", b2g: true, pref: "dom.telephony.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
"Text",
// IMPORTANT: Do not change this list without review from a DOM peer!