mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 777271 - Re-implement nsIDOMCallEvent using event implementation codegen. r=bent,vicamo,hsinyi
This commit is contained in:
parent
ef1378f2db
commit
f5a63e01fb
@ -464,7 +464,6 @@ using mozilla::dom::workers::ResolveWorkerClasses;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#include "Telephony.h"
|
||||
#include "TelephonyCall.h"
|
||||
#include "CallEvent.h"
|
||||
#include "nsIDOMVoicemail.h"
|
||||
#include "nsIDOMVoicemailEvent.h"
|
||||
#include "nsIDOMIccManager.h"
|
||||
@ -1500,8 +1499,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(TelephonyCall, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CallEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(MozVoicemail, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(MozVoicemailEvent, nsDOMGenericSH,
|
||||
@ -3911,11 +3908,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CallEvent, nsIDOMCallEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCallEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MozVoicemail, nsIDOMMozVoicemail)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozVoicemail)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
|
@ -431,7 +431,6 @@ DOMCI_CLASS(MediaQueryList)
|
||||
#ifdef MOZ_B2G_RIL
|
||||
DOMCI_CLASS(Telephony)
|
||||
DOMCI_CLASS(TelephonyCall)
|
||||
DOMCI_CLASS(CallEvent)
|
||||
DOMCI_CLASS(MozVoicemail)
|
||||
DOMCI_CLASS(MozVoicemailEvent)
|
||||
DOMCI_CLASS(MozIccManager)
|
||||
|
@ -1,49 +0,0 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=40: */
|
||||
/* 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 "CallEvent.h"
|
||||
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
||||
#include "Telephony.h"
|
||||
#include "TelephonyCall.h"
|
||||
|
||||
USING_TELEPHONY_NAMESPACE
|
||||
|
||||
// static
|
||||
already_AddRefed<CallEvent>
|
||||
CallEvent::Create(TelephonyCall* aCall)
|
||||
{
|
||||
NS_ASSERTION(aCall, "Null pointer!");
|
||||
|
||||
nsRefPtr<CallEvent> event = new CallEvent();
|
||||
|
||||
event->mCall = aCall;
|
||||
|
||||
return event.forget();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(CallEvent,
|
||||
nsDOMEvent,
|
||||
mCall)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CallEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCallEvent)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CallEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(CallEvent, nsDOMEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(CallEvent, nsDOMEvent)
|
||||
|
||||
DOMCI_DATA(CallEvent, CallEvent)
|
||||
|
||||
NS_IMETHODIMP
|
||||
CallEvent::GetCall(nsIDOMTelephonyCall** aCall)
|
||||
{
|
||||
nsCOMPtr<nsIDOMTelephonyCall> call = mCall.get();
|
||||
call.forget(aCall);
|
||||
return NS_OK;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=40: */
|
||||
/* 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_telephony_callevent_h__
|
||||
#define mozilla_dom_telephony_callevent_h__
|
||||
|
||||
#include "TelephonyCommon.h"
|
||||
|
||||
#include "nsIDOMCallEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
||||
#include "nsDOMEvent.h"
|
||||
|
||||
BEGIN_TELEPHONY_NAMESPACE
|
||||
|
||||
class CallEvent : public nsDOMEvent,
|
||||
public nsIDOMCallEvent
|
||||
{
|
||||
nsRefPtr<TelephonyCall> mCall;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
NS_DECL_NSIDOMCALLEVENT
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CallEvent, nsDOMEvent)
|
||||
|
||||
static already_AddRefed<CallEvent>
|
||||
Create(TelephonyCall* aCall);
|
||||
|
||||
nsresult
|
||||
Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
|
||||
{
|
||||
NS_ASSERTION(aTarget, "Null pointer!");
|
||||
NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
|
||||
|
||||
nsresult rv = InitEvent(aEventType, false, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
SetTrusted(true);
|
||||
|
||||
nsDOMEvent* thisEvent = this;
|
||||
|
||||
bool dummy;
|
||||
rv = aTarget->DispatchEvent(thisEvent, &dummy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
CallEvent()
|
||||
: nsDOMEvent(nullptr, nullptr)
|
||||
{ }
|
||||
|
||||
~CallEvent()
|
||||
{ }
|
||||
};
|
||||
|
||||
END_TELEPHONY_NAMESPACE
|
||||
|
||||
#endif // mozilla_dom_telephony_callevent_h__
|
@ -21,7 +21,6 @@ include $(topsrcdir)/dom/dom-config.mk
|
||||
CPPSRCS = \
|
||||
Telephony.cpp \
|
||||
TelephonyCall.cpp \
|
||||
CallEvent.cpp \
|
||||
Voicemail.cpp \
|
||||
VoicemailEvent.cpp \
|
||||
$(NULL)
|
||||
|
@ -7,20 +7,20 @@
|
||||
#include "Telephony.h"
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIDOMCallEvent.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
|
||||
#include "GeneratedEvents.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsRadioInterfaceLayer.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsTArrayHelpers.h"
|
||||
|
||||
#include "CallEvent.h"
|
||||
#include "TelephonyCall.h"
|
||||
|
||||
USING_TELEPHONY_NAMESPACE
|
||||
@ -121,9 +121,6 @@ Telephony::NoteDialedCallFromOtherInstance(const nsAString& aNumber)
|
||||
nsresult
|
||||
Telephony::NotifyCallsChanged(TelephonyCall* aCall)
|
||||
{
|
||||
nsRefPtr<CallEvent> event = CallEvent::Create(aCall);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
if (aCall->CallState() == nsIRadioInterfaceLayer::CALL_STATE_DIALING ||
|
||||
aCall->CallState() == nsIRadioInterfaceLayer::CALL_STATE_ALERTING ||
|
||||
aCall->CallState() == nsIRadioInterfaceLayer::CALL_STATE_CONNECTED) {
|
||||
@ -133,11 +130,7 @@ Telephony::NotifyCallsChanged(TelephonyCall* aCall)
|
||||
mActiveCall = nullptr;
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("callschanged"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
return DispatchCallEvent(NS_LITERAL_STRING("callschanged"), aCall);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -411,12 +404,7 @@ Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
|
||||
NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!");
|
||||
|
||||
if (aCallState == nsIRadioInterfaceLayer::CALL_STATE_INCOMING) {
|
||||
// Dispatch incoming event.
|
||||
nsRefPtr<CallEvent> event = CallEvent::Create(call);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
nsresult rv =
|
||||
event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("incoming"));
|
||||
nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("incoming"), call);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -484,6 +472,24 @@ Telephony::NotifyError(int32_t aCallIndex,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Telephony::DispatchCallEvent(const nsAString& aType,
|
||||
nsIDOMTelephonyCall* aCall)
|
||||
{
|
||||
MOZ_ASSERT(aCall);
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMCallEvent(getter_AddRefs(event), nullptr, nullptr);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
nsCOMPtr<nsIDOMCallEvent> callEvent = do_QueryInterface(event);
|
||||
MOZ_ASSERT(callEvent);
|
||||
nsresult rv = callEvent->InitCallEvent(aType, false, false, aCall);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return DispatchTrustedEvent(callEvent);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewTelephony(nsPIDOMWindow* aWindow, nsIDOMTelephony** aTelephony)
|
||||
{
|
||||
|
@ -100,6 +100,10 @@ private:
|
||||
const nsAString& aNumber,
|
||||
nsIDOMTelephonyCall** aResult);
|
||||
|
||||
nsresult
|
||||
DispatchCallEvent(const nsAString& aType,
|
||||
nsIDOMTelephonyCall* aCall);
|
||||
|
||||
class RILTelephonyCallback : public nsIRILTelephonyCallback
|
||||
{
|
||||
Telephony* mTelephony;
|
||||
|
@ -6,11 +6,12 @@
|
||||
|
||||
#include "TelephonyCall.h"
|
||||
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsIDOMCallEvent.h"
|
||||
|
||||
#include "CallEvent.h"
|
||||
#include "Telephony.h"
|
||||
#include "DOMError.h"
|
||||
#include "GeneratedEvents.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "Telephony.h"
|
||||
|
||||
USING_TELEPHONY_NAMESPACE
|
||||
|
||||
@ -98,27 +99,40 @@ TelephonyCall::ChangeStateInternal(uint16_t aCallState, bool aFireEvents)
|
||||
}
|
||||
|
||||
if (aFireEvents) {
|
||||
nsRefPtr<CallEvent> event = CallEvent::Create(this);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
if (NS_FAILED(event->Dispatch(ToIDOMEventTarget(),
|
||||
NS_LITERAL_STRING("statechange")))) {
|
||||
NS_WARNING("Failed to dispatch statechange event!");
|
||||
nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("statechange"), this);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch specific event!");
|
||||
}
|
||||
|
||||
// This can change if the statechange handler called back here... Need to
|
||||
// figure out something smarter.
|
||||
if (mCallState == aCallState) {
|
||||
event = CallEvent::Create(this);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
if (NS_FAILED(event->Dispatch(ToIDOMEventTarget(), stateString))) {
|
||||
rv = DispatchCallEvent(stateString, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch specific event!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
TelephonyCall::DispatchCallEvent(const nsAString& aType,
|
||||
nsIDOMTelephonyCall* aCall)
|
||||
{
|
||||
MOZ_ASSERT(aCall);
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMCallEvent(getter_AddRefs(event), nullptr, nullptr);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
nsCOMPtr<nsIDOMCallEvent> callEvent = do_QueryInterface(event);
|
||||
MOZ_ASSERT(callEvent);
|
||||
nsresult rv = callEvent->InitCallEvent(aType, false, false, aCall);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return DispatchTrustedEvent(callEvent);
|
||||
}
|
||||
|
||||
void
|
||||
TelephonyCall::NotifyError(const nsAString& aError)
|
||||
{
|
||||
@ -130,12 +144,8 @@ TelephonyCall::NotifyError(const nsAString& aError)
|
||||
// Do the state transitions
|
||||
ChangeStateInternal(nsIRadioInterfaceLayer::CALL_STATE_DISCONNECTED, true);
|
||||
|
||||
// Notify the error event
|
||||
nsRefPtr<CallEvent> event = CallEvent::Create(this);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
if (NS_FAILED(event->Dispatch(ToIDOMEventTarget(),
|
||||
NS_LITERAL_STRING("error")))) {
|
||||
nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("error"), this);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch error event!");
|
||||
}
|
||||
}
|
||||
@ -215,10 +225,10 @@ TelephonyCall::Hold()
|
||||
NS_WARNING("Hold non-connected call ignored!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult rv = mTelephony->RIL()->HoldCall(mCallIndex);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
ChangeStateInternal(nsIRadioInterfaceLayer::CALL_STATE_HOLDING, true);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -230,10 +240,10 @@ TelephonyCall::Resume()
|
||||
NS_WARNING("Resume non-held call ignored!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult rv = mTelephony->RIL()->ResumeCall(mCallIndex);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
|
||||
ChangeStateInternal(nsIRadioInterfaceLayer::CALL_STATE_RESUMING, true);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -100,6 +100,10 @@ private:
|
||||
|
||||
void
|
||||
ChangeStateInternal(uint16_t aCallState, bool aFireEvents);
|
||||
|
||||
nsresult
|
||||
DispatchCallEvent(const nsAString& aType,
|
||||
nsIDOMTelephonyCall* aCall);
|
||||
};
|
||||
|
||||
END_TELEPHONY_NAMESPACE
|
||||
|
@ -8,8 +8,17 @@
|
||||
|
||||
interface nsIDOMTelephonyCall;
|
||||
|
||||
[scriptable, builtinclass, uuid(21c233f9-721b-4985-bb2b-585f978ceee5)]
|
||||
[scriptable, builtinclass, uuid(476aacec-661e-44ec-80b4-4b7292b927b5)]
|
||||
interface nsIDOMCallEvent : nsIDOMEvent
|
||||
{
|
||||
readonly attribute nsIDOMTelephonyCall call;
|
||||
[noscript] void initCallEvent(in DOMString aType,
|
||||
in boolean aCanBubble,
|
||||
in boolean aCancelable,
|
||||
in nsIDOMTelephonyCall aCall);
|
||||
};
|
||||
|
||||
dictionary CallEventInit : EventInit
|
||||
{
|
||||
nsIDOMTelephonyCall call;
|
||||
};
|
||||
|
@ -28,6 +28,7 @@ simple_events = [
|
||||
'BluetoothDeviceAddressEvent',
|
||||
#endif
|
||||
#ifdef MOZ_B2G_RIL
|
||||
'CallEvent',
|
||||
'ICCCardLockErrorEvent',
|
||||
'MozWifiStatusChangeEvent',
|
||||
'MozWifiConnectionInfoEvent',
|
||||
|
Loading…
Reference in New Issue
Block a user