2013-06-01 10:53:06 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
#include "Telephony.h"
|
2014-06-11 05:23:34 +04:00
|
|
|
#include "mozilla/dom/CallEvent.h"
|
2013-07-15 12:27:19 +04:00
|
|
|
#include "mozilla/dom/TelephonyBinding.h"
|
2014-02-27 10:12:30 +04:00
|
|
|
#include "mozilla/dom/Promise.h"
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2013-01-28 11:39:50 +04:00
|
|
|
#include "nsIPermissionManager.h"
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-07-06 14:24:55 +04:00
|
|
|
#include "mozilla/dom/UnionTypes.h"
|
2013-10-31 16:05:51 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-02-24 17:14:37 +04:00
|
|
|
#include "nsCharSeparatedTokenizer.h"
|
2012-01-10 02:28:47 +04:00
|
|
|
#include "nsContentUtils.h"
|
2012-02-24 17:14:37 +04:00
|
|
|
#include "nsNetUtil.h"
|
2013-01-28 11:39:50 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2013-05-09 14:44:13 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
#include "CallsList.h"
|
2012-01-10 02:28:47 +04:00
|
|
|
#include "TelephonyCall.h"
|
2013-07-06 14:24:55 +04:00
|
|
|
#include "TelephonyCallGroup.h"
|
2014-04-10 10:25:42 +04:00
|
|
|
#include "TelephonyCallId.h"
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-05-09 14:44:13 +04:00
|
|
|
using namespace mozilla::dom;
|
2013-09-07 10:19:53 +04:00
|
|
|
using mozilla::ErrorResult;
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-03-06 13:53:23 +04:00
|
|
|
class Telephony::Listener : public nsITelephonyListener
|
|
|
|
{
|
|
|
|
Telephony* mTelephony;
|
|
|
|
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~Listener() {}
|
|
|
|
|
2013-03-06 13:53:23 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_FORWARD_SAFE_NSITELEPHONYLISTENER(mTelephony)
|
|
|
|
|
2014-09-02 02:26:43 +04:00
|
|
|
explicit Listener(Telephony* aTelephony)
|
2013-03-06 13:53:23 +04:00
|
|
|
: mTelephony(aTelephony)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mTelephony);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Disconnect()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mTelephony);
|
|
|
|
mTelephony = nullptr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-27 10:12:30 +04:00
|
|
|
class Telephony::Callback : public nsITelephonyCallback
|
|
|
|
{
|
|
|
|
nsRefPtr<Telephony> mTelephony;
|
|
|
|
nsRefPtr<Promise> mPromise;
|
|
|
|
uint32_t mServiceId;
|
|
|
|
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~Callback() {}
|
|
|
|
|
2014-02-27 10:12:30 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2014-08-19 03:26:00 +04:00
|
|
|
Callback(Telephony* aTelephony, Promise* aPromise, uint32_t aServiceId)
|
2014-08-13 07:51:00 +04:00
|
|
|
: mTelephony(aTelephony), mPromise(aPromise), mServiceId(aServiceId)
|
2014-02-27 10:12:30 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mTelephony);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
NotifyDialError(const nsAString& aError)
|
|
|
|
{
|
2014-06-03 19:38:38 +04:00
|
|
|
mPromise->MaybeRejectBrokenly(aError);
|
2014-02-27 10:12:30 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-08-13 07:51:00 +04:00
|
|
|
NotifyDialSuccess(uint32_t aCallIndex, const nsAString& aNumber)
|
2014-02-27 10:12:30 +04:00
|
|
|
{
|
2014-08-13 07:51:00 +04:00
|
|
|
nsRefPtr<TelephonyCallId> id = mTelephony->CreateCallId(aNumber);
|
2014-02-27 10:12:30 +04:00
|
|
|
nsRefPtr<TelephonyCall> call =
|
2014-06-24 14:52:00 +04:00
|
|
|
mTelephony->CreateCall(id, mServiceId, aCallIndex,
|
|
|
|
nsITelephonyService::CALL_STATE_DIALING);
|
2014-02-27 10:12:30 +04:00
|
|
|
|
|
|
|
mPromise->MaybeResolve(call);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-05-09 14:44:13 +04:00
|
|
|
class Telephony::EnumerationAck : public nsRunnable
|
|
|
|
{
|
|
|
|
nsRefPtr<Telephony> mTelephony;
|
2014-07-21 21:17:00 +04:00
|
|
|
nsString mType;
|
2013-05-09 14:44:13 +04:00
|
|
|
|
|
|
|
public:
|
2014-07-21 21:17:00 +04:00
|
|
|
EnumerationAck(Telephony* aTelephony, const nsAString& aType)
|
|
|
|
: mTelephony(aTelephony), mType(aType)
|
2013-05-09 14:44:13 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mTelephony);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
2014-07-21 21:17:00 +04:00
|
|
|
mTelephony->NotifyEvent(mType);
|
2013-05-09 14:44:13 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-07 06:53:23 +04:00
|
|
|
Telephony::Telephony(nsPIDOMWindow* aOwner)
|
2014-06-13 03:34:00 +04:00
|
|
|
: DOMEventTargetHelper(aOwner), mEnumerated(false)
|
2012-02-24 17:14:37 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-10 02:28:47 +04:00
|
|
|
Telephony::~Telephony()
|
|
|
|
{
|
2013-08-20 11:57:19 +04:00
|
|
|
Shutdown();
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2013-08-20 11:57:19 +04:00
|
|
|
void
|
|
|
|
Telephony::Shutdown()
|
|
|
|
{
|
|
|
|
if (mListener) {
|
|
|
|
mListener->Disconnect();
|
|
|
|
|
2014-06-03 18:15:30 +04:00
|
|
|
if (mService) {
|
|
|
|
mService->UnregisterListener(mListener);
|
|
|
|
mService = nullptr;
|
2013-08-20 11:57:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mListener = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
Telephony::WrapObject(JSContext* aCx)
|
2013-07-15 12:27:19 +04:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-09 02:27:17 +04:00
|
|
|
return TelephonyBinding::Wrap(aCx, this);
|
2013-07-15 12:27:19 +04:00
|
|
|
}
|
|
|
|
|
2012-01-10 02:28:47 +04:00
|
|
|
// static
|
|
|
|
already_AddRefed<Telephony>
|
2013-07-12 18:36:13 +04:00
|
|
|
Telephony::Create(nsPIDOMWindow* aOwner, ErrorResult& aRv)
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aOwner, "Null owner!");
|
2013-07-12 18:36:13 +04:00
|
|
|
|
2014-06-03 18:15:25 +04:00
|
|
|
nsCOMPtr<nsITelephonyService> ril =
|
|
|
|
do_GetService(TELEPHONY_SERVICE_CONTRACTID);
|
2013-07-12 18:36:13 +04:00
|
|
|
if (!ril) {
|
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aOwner);
|
2013-07-12 18:36:13 +04:00
|
|
|
if (!sgo) {
|
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptContext> scriptContext = sgo->GetContext();
|
2013-07-12 18:36:13 +04:00
|
|
|
if (!scriptContext) {
|
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2014-01-07 06:53:23 +04:00
|
|
|
nsRefPtr<Telephony> telephony = new Telephony(aOwner);
|
2012-03-14 02:11:16 +04:00
|
|
|
|
2014-06-03 18:15:30 +04:00
|
|
|
telephony->mService = ril;
|
2013-03-06 13:53:23 +04:00
|
|
|
telephony->mListener = new Listener(telephony);
|
2013-07-15 12:27:19 +04:00
|
|
|
telephony->mCallsList = new CallsList(telephony);
|
2013-07-06 14:24:55 +04:00
|
|
|
telephony->mGroup = TelephonyCallGroup::Create(telephony);
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-07-12 18:36:13 +04:00
|
|
|
nsresult rv = ril->EnumerateCalls(telephony->mListener);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
return telephony.forget();
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
// static
|
|
|
|
bool
|
|
|
|
Telephony::IsValidNumber(const nsAString& aNumber)
|
|
|
|
{
|
|
|
|
return !aNumber.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
// static
|
|
|
|
uint32_t
|
|
|
|
Telephony::GetNumServices() {
|
|
|
|
return mozilla::Preferences::GetInt("ril.numRadioInterfaces", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
bool
|
|
|
|
Telephony::IsValidServiceId(uint32_t aServiceId)
|
|
|
|
{
|
|
|
|
return aServiceId < GetNumServices();
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
// static
|
|
|
|
bool
|
|
|
|
Telephony::IsActiveState(uint16_t aCallState) {
|
2014-06-03 18:15:25 +04:00
|
|
|
return aCallState == nsITelephonyService::CALL_STATE_DIALING ||
|
|
|
|
aCallState == nsITelephonyService::CALL_STATE_ALERTING ||
|
2014-06-13 03:34:00 +04:00
|
|
|
aCallState == nsITelephonyService::CALL_STATE_HOLDING ||
|
|
|
|
aCallState == nsITelephonyService::CALL_STATE_DISCONNECTING ||
|
2014-06-03 18:15:25 +04:00
|
|
|
aCallState == nsITelephonyService::CALL_STATE_CONNECTED;
|
2013-10-31 16:05:51 +04:00
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
uint32_t
|
|
|
|
Telephony::ProvidedOrDefaultServiceId(const Optional<uint32_t>& aServiceId)
|
|
|
|
{
|
|
|
|
if (aServiceId.WasPassed()) {
|
|
|
|
return aServiceId.Value();
|
|
|
|
} else {
|
|
|
|
uint32_t serviceId = 0;
|
2014-06-03 18:15:30 +04:00
|
|
|
mService->GetDefaultServiceId(&serviceId);
|
2013-10-31 16:05:51 +04:00
|
|
|
return serviceId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
bool
|
|
|
|
Telephony::HasDialingCall()
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mCalls.Length(); i++) {
|
|
|
|
const nsRefPtr<TelephonyCall>& call = mCalls[i];
|
2014-06-03 18:15:25 +04:00
|
|
|
if (call->CallState() > nsITelephonyService::CALL_STATE_UNKNOWN &&
|
|
|
|
call->CallState() < nsITelephonyService::CALL_STATE_CONNECTED) {
|
2013-10-31 16:05:51 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-27 10:12:30 +04:00
|
|
|
already_AddRefed<Promise>
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::DialInternal(uint32_t aServiceId, const nsAString& aNumber,
|
2014-07-19 05:31:11 +04:00
|
|
|
bool aEmergency, ErrorResult& aRv)
|
2012-07-20 16:08:24 +04:00
|
|
|
{
|
2014-02-27 10:12:30 +04:00
|
|
|
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
|
|
|
|
if (!global) {
|
2014-02-26 23:27:54 +04:00
|
|
|
return nullptr;
|
2014-02-26 23:03:56 +04:00
|
|
|
}
|
|
|
|
|
2014-07-19 05:31:11 +04:00
|
|
|
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-02-27 10:12:30 +04:00
|
|
|
|
|
|
|
if (!IsValidNumber(aNumber) || !IsValidServiceId(aServiceId)) {
|
2014-06-03 19:38:38 +04:00
|
|
|
promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
2014-02-27 10:12:30 +04:00
|
|
|
return promise.forget();
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
// We only support one outgoing call at a time.
|
|
|
|
if (HasDialingCall()) {
|
2014-06-03 19:38:38 +04:00
|
|
|
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
|
2014-02-27 10:12:30 +04:00
|
|
|
return promise.forget();
|
2012-07-20 16:08:24 +04:00
|
|
|
}
|
|
|
|
|
2014-02-27 10:12:30 +04:00
|
|
|
nsCOMPtr<nsITelephonyCallback> callback =
|
2014-08-19 03:26:00 +04:00
|
|
|
new Callback(this, promise, aServiceId);
|
2014-06-24 14:52:00 +04:00
|
|
|
nsresult rv = mService->Dial(aServiceId, aNumber, aEmergency, callback);
|
2013-07-15 12:27:19 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2014-06-03 19:38:38 +04:00
|
|
|
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
|
2014-02-27 10:12:30 +04:00
|
|
|
return promise.forget();
|
2014-02-26 23:27:54 +04:00
|
|
|
}
|
|
|
|
|
2014-02-27 10:12:30 +04:00
|
|
|
return promise.forget();
|
2012-07-20 16:08:24 +04:00
|
|
|
}
|
|
|
|
|
2014-06-24 14:52:00 +04:00
|
|
|
already_AddRefed<TelephonyCallId>
|
|
|
|
Telephony::CreateCallId(const nsAString& aNumber, uint16_t aNumberPresentation,
|
|
|
|
const nsAString& aName, uint16_t aNamePresentation)
|
|
|
|
{
|
|
|
|
nsRefPtr<TelephonyCallId> id =
|
|
|
|
new TelephonyCallId(GetOwner(), aNumber, aNumberPresentation,
|
|
|
|
aName, aNamePresentation);
|
|
|
|
|
|
|
|
return id.forget();
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
already_AddRefed<TelephonyCall>
|
2014-06-24 14:52:00 +04:00
|
|
|
Telephony::CreateCall(TelephonyCallId* aId, uint32_t aServiceId,
|
|
|
|
uint32_t aCallIndex, uint16_t aCallState,
|
|
|
|
bool aEmergency, bool aConference,
|
|
|
|
bool aSwitchable, bool aMergeable)
|
2013-10-31 16:05:51 +04:00
|
|
|
{
|
2014-06-24 14:52:00 +04:00
|
|
|
// We don't have to create an already ended call.
|
|
|
|
if (aCallState == nsITelephonyService::CALL_STATE_DISCONNECTED) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
nsRefPtr<TelephonyCall> call =
|
2014-06-24 14:52:00 +04:00
|
|
|
TelephonyCall::Create(this, aId, aServiceId, aCallIndex, aCallState,
|
|
|
|
aEmergency, aConference, aSwitchable, aMergeable);
|
2013-10-31 16:05:51 +04:00
|
|
|
|
2014-06-24 14:52:00 +04:00
|
|
|
NS_ASSERTION(call, "This should never fail!");
|
|
|
|
NS_ASSERTION(aConference ? mGroup->CallsArray().Contains(call)
|
|
|
|
: mCalls.Contains(call),
|
|
|
|
"Should have auto-added new call!");
|
2013-10-31 16:05:51 +04:00
|
|
|
|
|
|
|
return call.forget();
|
|
|
|
}
|
|
|
|
|
2014-07-21 21:17:00 +04:00
|
|
|
nsresult
|
|
|
|
Telephony::NotifyEvent(const nsAString& aType)
|
|
|
|
{
|
|
|
|
return DispatchCallEvent(aType, nullptr);
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
nsresult
|
|
|
|
Telephony::NotifyCallsChanged(TelephonyCall* aCall)
|
|
|
|
{
|
|
|
|
return DispatchCallEvent(NS_LITERAL_STRING("callschanged"), aCall);
|
|
|
|
}
|
|
|
|
|
2013-07-06 14:24:55 +04:00
|
|
|
already_AddRefed<TelephonyCall>
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::GetCall(uint32_t aServiceId, uint32_t aCallIndex)
|
2013-07-06 14:24:55 +04:00
|
|
|
{
|
|
|
|
nsRefPtr<TelephonyCall> call;
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
for (uint32_t i = 0; i < mCalls.Length(); i++) {
|
|
|
|
nsRefPtr<TelephonyCall>& tempCall = mCalls[i];
|
|
|
|
if (tempCall->ServiceId() == aServiceId &&
|
|
|
|
tempCall->CallIndex() == aCallIndex) {
|
2013-07-06 14:24:55 +04:00
|
|
|
call = tempCall;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return call.forget();
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
already_AddRefed<TelephonyCall>
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex)
|
2013-10-31 16:05:51 +04:00
|
|
|
{
|
2013-10-31 16:05:51 +04:00
|
|
|
nsRefPtr<TelephonyCall> call = GetCall(aServiceId, aCallIndex);
|
2013-10-31 16:05:51 +04:00
|
|
|
|
|
|
|
if (!call) {
|
2013-10-31 16:05:51 +04:00
|
|
|
call = mGroup->GetCall(aServiceId, aCallIndex);
|
2013-07-06 14:24:55 +04:00
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
return call.forget();
|
2013-07-06 14:24:55 +04:00
|
|
|
}
|
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(Telephony)
|
|
|
|
|
2012-01-10 02:28:47 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(Telephony,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2013-07-15 12:27:19 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCalls)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallsList)
|
2013-07-06 14:24:55 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGroup)
|
2012-01-10 02:28:47 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(Telephony,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2013-08-20 11:57:19 +04:00
|
|
|
tmp->Shutdown();
|
2013-07-15 12:27:19 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCalls)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallsList)
|
2013-07-06 14:24:55 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGroup)
|
2012-01-10 02:28:47 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Telephony)
|
2014-08-20 05:01:49 +04:00
|
|
|
// Telephony does not expose nsITelephonyListener. mListener is the exposed
|
|
|
|
// nsITelephonyListener and forwards the calls it receives to us.
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(Telephony, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(Telephony, DOMEventTargetHelper)
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(Telephony::Listener, nsITelephonyListener)
|
|
|
|
NS_IMPL_ISUPPORTS(Telephony::Callback, nsITelephonyCallback)
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
// Telephony WebIDL
|
2013-05-09 14:44:13 +04:00
|
|
|
|
2014-02-27 10:12:30 +04:00
|
|
|
already_AddRefed<Promise>
|
2014-07-19 05:31:11 +04:00
|
|
|
Telephony::Dial(const nsAString& aNumber, const Optional<uint32_t>& aServiceId,
|
|
|
|
ErrorResult& aRv)
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2013-10-31 16:05:51 +04:00
|
|
|
uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId);
|
2014-07-19 05:31:11 +04:00
|
|
|
nsRefPtr<Promise> promise = DialInternal(serviceId, aNumber, false, aRv);
|
2014-02-27 10:12:30 +04:00
|
|
|
return promise.forget();
|
2012-07-20 16:08:24 +04:00
|
|
|
}
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2014-02-27 10:12:30 +04:00
|
|
|
already_AddRefed<Promise>
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::DialEmergency(const nsAString& aNumber,
|
2014-07-19 05:31:11 +04:00
|
|
|
const Optional<uint32_t>& aServiceId,
|
|
|
|
ErrorResult& aRv)
|
2012-07-20 16:08:24 +04:00
|
|
|
{
|
2013-10-31 16:05:51 +04:00
|
|
|
uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId);
|
2014-07-19 05:31:11 +04:00
|
|
|
nsRefPtr<Promise> promise = DialInternal(serviceId, aNumber, true, aRv);
|
2014-02-27 10:12:30 +04:00
|
|
|
return promise.forget();
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
void
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::StartTone(const nsAString& aDTMFChar,
|
|
|
|
const Optional<uint32_t>& aServiceId,
|
|
|
|
ErrorResult& aRv)
|
2013-10-31 16:05:51 +04:00
|
|
|
{
|
2013-10-31 16:05:51 +04:00
|
|
|
uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId);
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
if (aDTMFChar.IsEmpty()) {
|
|
|
|
NS_WARNING("Empty tone string will be ignored");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
if (aDTMFChar.Length() > 1 || !IsValidServiceId(serviceId)) {
|
2013-10-31 16:05:51 +04:00
|
|
|
aRv.Throw(NS_ERROR_INVALID_ARG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-03 18:15:30 +04:00
|
|
|
aRv = mService->StartTone(serviceId, aDTMFChar);
|
2013-10-31 16:05:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::StopTone(const Optional<uint32_t>& aServiceId, ErrorResult& aRv)
|
2013-10-31 16:05:51 +04:00
|
|
|
{
|
2013-10-31 16:05:51 +04:00
|
|
|
uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId);
|
|
|
|
|
|
|
|
if (!IsValidServiceId(serviceId)) {
|
|
|
|
aRv.Throw(NS_ERROR_INVALID_ARG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-03 18:15:30 +04:00
|
|
|
aRv = mService->StopTone(serviceId);
|
2013-10-31 16:05:51 +04:00
|
|
|
}
|
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
bool
|
|
|
|
Telephony::GetMuted(ErrorResult& aRv) const
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2013-07-15 12:27:19 +04:00
|
|
|
bool muted = false;
|
2014-06-03 18:15:30 +04:00
|
|
|
aRv = mService->GetMicrophoneMuted(&muted);
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
return muted;
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
void
|
|
|
|
Telephony::SetMuted(bool aMuted, ErrorResult& aRv)
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2014-06-03 18:15:30 +04:00
|
|
|
aRv = mService->SetMicrophoneMuted(aMuted);
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
bool
|
|
|
|
Telephony::GetSpeakerEnabled(ErrorResult& aRv) const
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2013-07-15 12:27:19 +04:00
|
|
|
bool enabled = false;
|
2014-06-03 18:15:30 +04:00
|
|
|
aRv = mService->GetSpeakerEnabled(&enabled);
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
return enabled;
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
void
|
|
|
|
Telephony::SetSpeakerEnabled(bool aEnabled, ErrorResult& aRv)
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2014-06-03 18:15:30 +04:00
|
|
|
aRv = mService->SetSpeakerEnabled(aEnabled);
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2013-07-06 14:24:55 +04:00
|
|
|
void
|
2013-09-17 19:16:02 +04:00
|
|
|
Telephony::GetActive(Nullable<OwningTelephonyCallOrTelephonyCallGroup>& aValue)
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2014-06-13 03:34:00 +04:00
|
|
|
if (mGroup->CallState() == nsITelephonyService::CALL_STATE_CONNECTED) {
|
2013-07-06 14:24:55 +04:00
|
|
|
aValue.SetValue().SetAsTelephonyCallGroup() = mGroup;
|
|
|
|
} else {
|
2014-06-13 03:34:00 +04:00
|
|
|
// Search the first active call.
|
|
|
|
for (uint32_t i = 0; i < mCalls.Length(); i++) {
|
|
|
|
if (IsActiveState(mCalls[i]->CallState())) {
|
|
|
|
aValue.SetValue().SetAsTelephonyCall() = mCalls[i];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-07-06 14:24:55 +04:00
|
|
|
aValue.SetNull();
|
|
|
|
}
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
already_AddRefed<CallsList>
|
|
|
|
Telephony::Calls() const
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2013-07-15 12:27:19 +04:00
|
|
|
nsRefPtr<CallsList> list = mCallsList;
|
|
|
|
return list.forget();
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2013-07-06 14:24:55 +04:00
|
|
|
already_AddRefed<TelephonyCallGroup>
|
|
|
|
Telephony::ConferenceGroup() const
|
|
|
|
{
|
|
|
|
nsRefPtr<TelephonyCallGroup> group = mGroup;
|
|
|
|
return group.forget();
|
|
|
|
}
|
|
|
|
|
2013-05-24 21:22:20 +04:00
|
|
|
// EventTarget
|
2013-05-09 14:44:13 +04:00
|
|
|
|
|
|
|
void
|
2013-05-24 21:22:20 +04:00
|
|
|
Telephony::EventListenerAdded(nsIAtom* aType)
|
2013-05-09 14:44:13 +04:00
|
|
|
{
|
2013-05-24 21:22:20 +04:00
|
|
|
if (aType == nsGkAtoms::oncallschanged) {
|
2013-05-09 14:44:13 +04:00
|
|
|
// Fire oncallschanged on the next tick if the calls array is ready.
|
2014-07-21 21:17:00 +04:00
|
|
|
EnqueueEnumerationAck(NS_LITERAL_STRING("callschanged"));
|
|
|
|
} else if (aType == nsGkAtoms::onready) {
|
|
|
|
EnqueueEnumerationAck(NS_LITERAL_STRING("ready"));
|
2013-05-09 14:44:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsITelephonyListener
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::CallStateChanged(uint32_t aServiceId, uint32_t aCallIndex,
|
|
|
|
uint16_t aCallState, const nsAString& aNumber,
|
2014-04-10 10:25:42 +04:00
|
|
|
uint16_t aNumberPresentation, const nsAString& aName,
|
|
|
|
uint16_t aNamePresentation, bool aIsOutgoing,
|
|
|
|
bool aIsEmergency, bool aIsConference,
|
|
|
|
bool aIsSwitchable, bool aIsMergeable)
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2013-10-31 16:05:51 +04:00
|
|
|
nsRefPtr<TelephonyCall> modifiedCall
|
2013-10-31 16:05:51 +04:00
|
|
|
= GetCallFromEverywhere(aServiceId, aCallIndex);
|
2013-07-06 14:24:55 +04:00
|
|
|
|
|
|
|
if (modifiedCall) {
|
2014-05-26 21:08:00 +04:00
|
|
|
modifiedCall->UpdateEmergency(aIsEmergency);
|
2014-02-21 13:52:13 +04:00
|
|
|
modifiedCall->UpdateSwitchable(aIsSwitchable);
|
|
|
|
modifiedCall->UpdateMergeable(aIsMergeable);
|
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
if (modifiedCall->CallState() != aCallState) {
|
|
|
|
// We don't fire the statechange event on a call in conference here.
|
|
|
|
// Instead, the event will be fired later in
|
|
|
|
// TelephonyCallGroup::ChangeState(). Thus the sequence of firing the
|
|
|
|
// statechange events is guaranteed: first on TelephonyCallGroup then on
|
|
|
|
// individual TelephonyCall objects.
|
|
|
|
bool fireEvent = !aIsConference;
|
|
|
|
modifiedCall->ChangeStateInternal(aCallState, fireEvent);
|
2012-01-12 06:17:26 +04:00
|
|
|
}
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
nsRefPtr<TelephonyCallGroup> group = modifiedCall->GetGroup();
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2013-10-31 16:05:51 +04:00
|
|
|
if (!group && aIsConference) {
|
|
|
|
// Add to conference.
|
|
|
|
NS_ASSERTION(mCalls.Contains(modifiedCall), "Should in mCalls");
|
|
|
|
mGroup->AddCall(modifiedCall);
|
|
|
|
RemoveCall(modifiedCall);
|
|
|
|
} else if (group && !aIsConference) {
|
|
|
|
// Remove from conference.
|
|
|
|
NS_ASSERTION(mGroup->CallsArray().Contains(modifiedCall), "Should in mGroup");
|
|
|
|
mGroup->RemoveCall(modifiedCall);
|
|
|
|
AddCall(modifiedCall);
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
2012-01-12 06:17:26 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
2012-01-10 02:28:47 +04:00
|
|
|
}
|
|
|
|
|
2014-06-24 14:52:00 +04:00
|
|
|
nsRefPtr<TelephonyCallId> id = CreateCallId(aNumber, aNumberPresentation,
|
|
|
|
aName, aNamePresentation);
|
2012-01-10 02:28:47 +04:00
|
|
|
nsRefPtr<TelephonyCall> call =
|
2014-06-24 14:52:00 +04:00
|
|
|
CreateCall(id, aServiceId, aCallIndex, aCallState,
|
|
|
|
aIsEmergency, aIsConference, aIsSwitchable, aIsMergeable);
|
2012-01-10 02:28:47 +04:00
|
|
|
|
2014-06-24 14:52:00 +04:00
|
|
|
if (call && aCallState == nsITelephonyService::CALL_STATE_INCOMING) {
|
2013-01-28 11:39:50 +04:00
|
|
|
nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("incoming"), call);
|
2012-10-25 14:31:37 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-07-06 14:24:55 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
Telephony::ConferenceCallStateChanged(uint16_t aCallState)
|
|
|
|
{
|
|
|
|
mGroup->ChangeState(aCallState);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-09 14:44:13 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
Telephony::EnumerateCallStateComplete()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mEnumerated);
|
|
|
|
|
2014-09-04 08:45:00 +04:00
|
|
|
// Set conference state.
|
|
|
|
if (mGroup->CallsArray().Length() >= 2) {
|
|
|
|
const nsTArray<nsRefPtr<TelephonyCall> > &calls = mGroup->CallsArray();
|
|
|
|
|
|
|
|
uint16_t callState = calls[0]->CallState();
|
|
|
|
for (uint32_t i = 1; i < calls.Length(); i++) {
|
|
|
|
if (calls[i]->CallState() != callState) {
|
|
|
|
callState = nsITelephonyService::CALL_STATE_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mGroup->ChangeState(callState);
|
|
|
|
}
|
|
|
|
|
2013-05-09 14:44:13 +04:00
|
|
|
mEnumerated = true;
|
|
|
|
|
2014-07-21 21:17:00 +04:00
|
|
|
if (NS_FAILED(NotifyEvent(NS_LITERAL_STRING("ready")))) {
|
|
|
|
NS_WARNING("Failed to notify ready!");
|
|
|
|
}
|
|
|
|
|
2013-05-09 14:44:13 +04:00
|
|
|
if (NS_FAILED(NotifyCallsChanged(nullptr))) {
|
|
|
|
NS_WARNING("Failed to notify calls changed!");
|
|
|
|
}
|
2014-03-05 16:19:38 +04:00
|
|
|
|
2014-06-03 18:15:30 +04:00
|
|
|
if (NS_FAILED(mService->RegisterListener(mListener))) {
|
2014-03-05 16:19:38 +04:00
|
|
|
NS_WARNING("Failed to register listener!");
|
|
|
|
}
|
2013-05-09 14:44:13 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-10 02:28:47 +04:00
|
|
|
NS_IMETHODIMP
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::EnumerateCallState(uint32_t aServiceId, uint32_t aCallIndex,
|
|
|
|
uint16_t aCallState, const nsAString& aNumber,
|
2014-04-10 10:25:42 +04:00
|
|
|
uint16_t aNumberPresentation, const nsAString& aName,
|
|
|
|
uint16_t aNamePresentation, bool aIsOutgoing,
|
|
|
|
bool aIsEmergency, bool aIsConference,
|
|
|
|
bool aIsSwitchable, bool aIsMergeable)
|
2012-01-10 02:28:47 +04:00
|
|
|
{
|
2013-07-06 14:24:55 +04:00
|
|
|
// We request calls enumeration in constructor, and the asynchronous result
|
|
|
|
// will be sent back through the callback function EnumerateCallState().
|
|
|
|
// However, it is likely to have call state changes, i.e. CallStateChanged()
|
|
|
|
// being called, before the enumeration result comes back. We'd make sure
|
|
|
|
// we don't somehow add duplicates due to the race condition.
|
2014-06-24 14:52:00 +04:00
|
|
|
nsRefPtr<TelephonyCall> call = GetCallFromEverywhere(aServiceId, aCallIndex);
|
2013-07-06 14:24:55 +04:00
|
|
|
if (call) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Didn't know anything about this call before now.
|
2014-06-24 14:52:00 +04:00
|
|
|
nsRefPtr<TelephonyCallId> id = CreateCallId(aNumber, aNumberPresentation,
|
|
|
|
aName, aNamePresentation);
|
|
|
|
CreateCall(id, aServiceId, aCallIndex, aCallState,
|
|
|
|
aIsEmergency, aIsConference, aIsSwitchable, aIsMergeable);
|
2012-01-10 02:28:47 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-06 00:28:14 +04:00
|
|
|
NS_IMETHODIMP
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::SupplementaryServiceNotification(uint32_t aServiceId,
|
|
|
|
int32_t aCallIndex,
|
2013-08-06 00:28:14 +04:00
|
|
|
uint16_t aNotification)
|
|
|
|
{
|
|
|
|
nsRefPtr<TelephonyCall> associatedCall;
|
2014-02-27 10:12:30 +04:00
|
|
|
if (!mCalls.IsEmpty()) {
|
2013-10-31 16:05:51 +04:00
|
|
|
associatedCall = GetCall(aServiceId, aCallIndex);
|
2013-08-06 00:28:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
switch (aNotification) {
|
2014-06-03 18:15:25 +04:00
|
|
|
case nsITelephonyService::NOTIFICATION_REMOTE_HELD:
|
2013-08-06 00:28:14 +04:00
|
|
|
rv = DispatchCallEvent(NS_LITERAL_STRING("remoteheld"), associatedCall);
|
|
|
|
break;
|
2014-06-03 18:15:25 +04:00
|
|
|
case nsITelephonyService::NOTIFICATION_REMOTE_RESUMED:
|
2013-08-06 00:28:14 +04:00
|
|
|
rv = DispatchCallEvent(NS_LITERAL_STRING("remoteresumed"), associatedCall);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("Got a bad notification!");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-15 08:13:06 +04:00
|
|
|
NS_IMETHODIMP
|
2013-10-31 16:05:51 +04:00
|
|
|
Telephony::NotifyError(uint32_t aServiceId,
|
|
|
|
int32_t aCallIndex,
|
2012-06-21 07:00:52 +04:00
|
|
|
const nsAString& aError)
|
2012-05-15 08:13:06 +04:00
|
|
|
{
|
2013-10-31 16:05:51 +04:00
|
|
|
if (mCalls.IsEmpty()) {
|
|
|
|
NS_ERROR("No existing call!");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2013-10-30 23:48:39 +04:00
|
|
|
}
|
2013-10-30 23:06:41 +04:00
|
|
|
|
2014-02-27 10:12:30 +04:00
|
|
|
nsRefPtr<TelephonyCall> callToNotify = GetCall(aServiceId, aCallIndex);
|
2012-06-21 07:00:52 +04:00
|
|
|
if (!callToNotify) {
|
|
|
|
NS_ERROR("Don't call me with a bad call index!");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2012-05-15 08:13:06 +04:00
|
|
|
}
|
|
|
|
|
2012-06-21 07:00:52 +04:00
|
|
|
// Set the call state to 'disconnected' and remove it from the calls list.
|
|
|
|
callToNotify->NotifyError(aError);
|
|
|
|
|
2012-05-15 08:13:06 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:08:53 +04:00
|
|
|
NS_IMETHODIMP
|
2014-04-10 10:25:42 +04:00
|
|
|
Telephony::NotifyCdmaCallWaiting(uint32_t aServiceId, const nsAString& aNumber,
|
|
|
|
uint16_t aNumberPresentation,
|
|
|
|
const nsAString& aName,
|
|
|
|
uint16_t aNamePresentation)
|
2013-07-30 13:08:53 +04:00
|
|
|
{
|
2014-01-15 18:41:50 +04:00
|
|
|
MOZ_ASSERT(mCalls.Length() == 1);
|
|
|
|
|
|
|
|
nsRefPtr<TelephonyCall> callToNotify = mCalls[0];
|
|
|
|
MOZ_ASSERT(callToNotify && callToNotify->ServiceId() == aServiceId);
|
2013-07-30 13:08:53 +04:00
|
|
|
|
2014-04-10 10:25:42 +04:00
|
|
|
nsRefPtr<TelephonyCallId> id =
|
|
|
|
new TelephonyCallId(GetOwner(), aNumber, aNumberPresentation, aName,
|
|
|
|
aNamePresentation);
|
|
|
|
callToNotify->UpdateSecondId(id);
|
2013-07-30 13:08:53 +04:00
|
|
|
DispatchCallEvent(NS_LITERAL_STRING("callschanged"), callToNotify);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-28 10:43:14 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
Telephony::NotifyConferenceError(const nsAString& aName,
|
|
|
|
const nsAString& aMessage)
|
|
|
|
{
|
|
|
|
mGroup->NotifyError(aName, aMessage);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-28 11:39:50 +04:00
|
|
|
nsresult
|
|
|
|
Telephony::DispatchCallEvent(const nsAString& aType,
|
2013-07-15 12:27:19 +04:00
|
|
|
TelephonyCall* aCall)
|
2013-01-28 11:39:50 +04:00
|
|
|
{
|
2014-07-21 21:17:00 +04:00
|
|
|
// If it is an incoming event, the call should not be null.
|
|
|
|
MOZ_ASSERT(!aType.EqualsLiteral("incoming") || aCall);
|
2013-01-28 11:39:50 +04:00
|
|
|
|
2014-06-11 05:23:34 +04:00
|
|
|
CallEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mCall = aCall;
|
|
|
|
|
|
|
|
nsRefPtr<CallEvent> event = CallEvent::Constructor(this, aType, init);
|
2013-01-28 11:39:50 +04:00
|
|
|
|
2013-07-15 12:27:19 +04:00
|
|
|
return DispatchTrustedEvent(event);
|
2013-01-28 11:39:50 +04:00
|
|
|
}
|
|
|
|
|
2013-05-09 14:44:13 +04:00
|
|
|
void
|
2014-07-21 21:17:00 +04:00
|
|
|
Telephony::EnqueueEnumerationAck(const nsAString& aType)
|
2013-05-09 14:44:13 +04:00
|
|
|
{
|
|
|
|
if (!mEnumerated) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-21 21:17:00 +04:00
|
|
|
nsCOMPtr<nsIRunnable> task = new EnumerationAck(this, aType);
|
2013-05-09 14:44:13 +04:00
|
|
|
if (NS_FAILED(NS_DispatchToCurrentThread(task))) {
|
|
|
|
NS_WARNING("Failed to dispatch to current thread!");
|
|
|
|
}
|
|
|
|
}
|