[PATCH] Bug 765684 - WebTelephony: invalid argument in

From 21d83598fcec9b69a1b8ed87b502415342582995 Mon Sep 17 00:00:00 2001
 Telephony::NotifyError
---
 dom/telephony/Telephony.cpp |   37 ++++++++++++++++++++++---------------
 1 files changed, 22 insertions(+), 15 deletions(-)
This commit is contained in:
Hsinyi Tsai 2012-06-21 11:00:52 +08:00
Родитель fd3f60f61a
Коммит fcb6299461
1 изменённых файлов: 23 добавлений и 16 удалений

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

@ -478,26 +478,33 @@ Telephony::EnumerateCallState(PRUint32 aCallIndex, PRUint16 aCallState,
NS_IMETHODIMP
Telephony::NotifyError(PRInt32 aCallIndex,
const nsAString& aError)
const nsAString& aError)
{
PRInt32 index = -1;
PRInt32 length = mCalls.Length();
nsRefPtr<TelephonyCall> callToNotify;
if (!mCalls.IsEmpty()) {
// The connection is not established yet. Get the latest call object.
if (aCallIndex == -1) {
callToNotify = mCalls[mCalls.Length() - 1];
} else {
// The connection has been established. Get the failed call.
for (PRUint32 index = 0; index < mCalls.Length(); index++) {
nsRefPtr<TelephonyCall>& call = mCalls[index];
if (call->CallIndex() == aCallIndex) {
callToNotify = call;
break;
}
}
}
}
// The connection is not established yet, remove the latest call object
if (aCallIndex == -1) {
if (length > 0) {
index = length - 1;
}
} else {
if (aCallIndex < 0 || aCallIndex >= length) {
return NS_ERROR_INVALID_ARG;
}
index = aCallIndex;
}
if (index != -1) {
mCalls[index]->NotifyError(aError);
if (!callToNotify) {
NS_ERROR("Don't call me with a bad call index!");
return NS_ERROR_UNEXPECTED;
}
// Set the call state to 'disconnected' and remove it from the calls list.
callToNotify->NotifyError(aError);
return NS_OK;
}