Bug 1131047 - Part 2: Obsolete some events (DOM). r=aknow

This commit is contained in:
brian37ful 2015-04-20 07:19:00 -04:00
Родитель 2445e6232d
Коммит b170b7869a
3 изменённых файлов: 43 добавлений и 39 удалений

Просмотреть файл

@ -87,7 +87,11 @@ TelephonyCall::ChangeStateInternal(uint16_t aCallState, bool aFireEvents)
{
nsRefPtr<TelephonyCall> kungFuDeathGrip(this);
nsString stateString;
// Update the internal state.
mCallState = aCallState;
// Indicate whether the external state have been changed.
bool externalStateChanged = true;
switch (aCallState) {
// These states are used internally to mark this call is currently being
// controlled, and we should block consecutive requests of the same type
@ -96,36 +100,32 @@ TelephonyCall::ChangeStateInternal(uint16_t aCallState, bool aFireEvents)
case nsITelephonyService::CALL_STATE_DISCONNECTING:
case nsITelephonyService::CALL_STATE_HOLDING:
case nsITelephonyService::CALL_STATE_RESUMING:
externalStateChanged = false;
break;
// These states will be translated into literal strings which are used to
// show the current status of this call.
case nsITelephonyService::CALL_STATE_DIALING:
stateString.AssignLiteral("dialing");
mState.AssignLiteral("dialing");
break;
case nsITelephonyService::CALL_STATE_ALERTING:
stateString.AssignLiteral("alerting");
mState.AssignLiteral("alerting");
break;
case nsITelephonyService::CALL_STATE_CONNECTED:
stateString.AssignLiteral("connected");
mState.AssignLiteral("connected");
break;
case nsITelephonyService::CALL_STATE_HELD:
stateString.AssignLiteral("held");
mState.AssignLiteral("held");
break;
case nsITelephonyService::CALL_STATE_DISCONNECTED:
stateString.AssignLiteral("disconnected");
mState.AssignLiteral("disconnected");
break;
case nsITelephonyService::CALL_STATE_INCOMING:
stateString.AssignLiteral("incoming");
mState.AssignLiteral("incoming");
break;
default:
NS_NOTREACHED("Unknown state!");
}
mCallState = aCallState;
if (!stateString.IsEmpty()) {
mState = stateString;
}
if (aCallState == nsITelephonyService::CALL_STATE_DISCONNECTED) {
NS_ASSERTION(mLive, "Should be live!");
mLive = false;
@ -144,7 +144,7 @@ TelephonyCall::ChangeStateInternal(uint16_t aCallState, bool aFireEvents)
}
}
if (aFireEvents) {
if (aFireEvents && externalStateChanged) {
nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("statechange"), this);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch specific event!");
@ -153,7 +153,7 @@ TelephonyCall::ChangeStateInternal(uint16_t aCallState, bool aFireEvents)
// This can change if the statechange handler called back here... Need to
// figure out something smarter.
if (mCallState == aCallState) {
rv = DispatchCallEvent(stateString, this);
rv = DispatchCallEvent(mState, this);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch specific event!");
}

Просмотреть файл

@ -87,41 +87,47 @@ TelephonyCallGroup::ChangeState(uint16_t aCallState)
if (mCallState == aCallState) {
return;
}
// Update the internal state.
mCallState = aCallState;
nsString stateString;
// Indicate whether the external state should be changed.
bool externalStateChanged = true;
switch (aCallState) {
// These states are used internally to mark this CallGroup is currently
// being controlled, and we should block consecutive requests of the same
// type according to these states.
case nsITelephonyService::CALL_STATE_HOLDING:
case nsITelephonyService::CALL_STATE_RESUMING:
externalStateChanged = false;
break;
// These states will be translated into literal strings which are used to
// show the current status of this CallGroup.
case nsITelephonyService::CALL_STATE_UNKNOWN:
mState.AssignLiteral("");
break;
case nsITelephonyService::CALL_STATE_CONNECTED:
stateString.AssignLiteral("connected");
break;
case nsITelephonyService::CALL_STATE_HOLDING:
stateString.AssignLiteral("holding");
mState.AssignLiteral("connected");
break;
case nsITelephonyService::CALL_STATE_HELD:
stateString.AssignLiteral("held");
break;
case nsITelephonyService::CALL_STATE_RESUMING:
stateString.AssignLiteral("resuming");
mState.AssignLiteral("held");
break;
default:
NS_NOTREACHED("Unknown state!");
}
mState = stateString;
mCallState = aCallState;
nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("statechange"), nullptr);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch specific event!");
}
if (!stateString.IsEmpty()) {
// This can change if the statechange handler called back here... Need to
// figure out something smarter.
if (mCallState == aCallState) {
rv = DispatchCallEvent(stateString, nullptr);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch specific event!");
if (externalStateChanged) {
nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("statechange"), nullptr);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch specific event!");
}
if (!mState.IsEmpty()) {
// This can change if the statechange handler called back here... Need to
// figure out something smarter.
if (mCallState == aCallState) {
rv = DispatchCallEvent(mState, nullptr);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch specific event!");
}
}
}
}

Просмотреть файл

@ -70,9 +70,7 @@ public:
IMPL_EVENT_HANDLER(statechange)
IMPL_EVENT_HANDLER(connected)
IMPL_EVENT_HANDLER(holding)
IMPL_EVENT_HANDLER(held)
IMPL_EVENT_HANDLER(resuming)
IMPL_EVENT_HANDLER(callschanged)
IMPL_EVENT_HANDLER(error)