already_AddRefed<Promise> TelephonyCallGroup::Remove(TelephonyCall& aCall, ErrorResult& aRv) { MOZ_ASSERT(!mCalls.IsEmpty()); RefPtr<Promise> promise = CreatePromise(aRv); if (!promise) { return nullptr; } if (mState != TelephonyCallGroupState::Connected) { NS_WARNING("Remove call from a non-connected call group. Ignore!"); promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR); return promise.forget(); } uint32_t serviceId = aCall.ServiceId(); uint32_t callIndex = aCall.CallIndex(); RefPtr<TelephonyCall> call = GetCall(serviceId, callIndex); if (!call) { NS_WARNING("Didn't have this call. Ignore!"); promise->MaybeReject(NS_ERROR_NOT_AVAILABLE); return promise.forget(); } nsCOMPtr<nsITelephonyCallback> callback = new TelephonyCallback(promise); aRv = mTelephony->Service()->SeparateCall(serviceId, callIndex, callback); NS_ENSURE_TRUE(!aRv.Failed(), nullptr); return promise.forget(); }
void TelephonyCallGroup::Remove(TelephonyCall& aCall, ErrorResult& aRv) { if (mCallState != nsITelephonyProvider::CALL_STATE_CONNECTED) { NS_WARNING("Remove call from a non-connected call group. Ignore!"); return; } uint32_t serviceId = aCall.ServiceId(); uint32_t callIndex = aCall.CallIndex(); nsRefPtr<TelephonyCall> call; call = GetCall(serviceId, callIndex); if (call) { aRv = mTelephony->Provider()->SeparateCall(serviceId, callIndex); } else { NS_WARNING("Didn't have this call. Ignore!"); } }