Bug 956240 - WebMobileConnection: Use webidl event generator for the event that is dispatched by mozMobileConnection. r=smaug

This commit is contained in:
Edgar Chen 2014-01-03 13:55:27 +08:00
parent 89e3e0a9c1
commit 5238d6a834
14 changed files with 109 additions and 243 deletions

View File

@ -18,12 +18,7 @@ XPIDL_SOURCES += [
if CONFIG['MOZ_B2G_RIL']:
XPIDL_SOURCES += [
'nsIDOMCFStateChangeEvent.idl',
'nsIDOMDataErrorEvent.idl',
'nsIDOMMobileConnection.idl',
'nsIDOMMozEmergencyCbModeEvent.idl',
'nsIDOMMozOtaStatusEvent.idl',
'nsIDOMUSSDReceivedEvent.idl',
'nsIMobileConnectionProvider.idl',
]

View File

@ -1,74 +0,0 @@
/* 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 "nsIDOMEvent.idl"
[scriptable, builtinclass, uuid(905348f1-3d06-443c-8762-567e7e4b6696)]
interface nsIDOMCFStateChangeEvent : nsIDOMEvent
{
/**
* Indicates about errors while setting up the Call forwarding rule.
*/
readonly attribute boolean success;
/**
* Indicates what to do with the rule.
*
* One of the CALL_FORWARD_ACTION_* constants. It will be either disable (0),
* enable (1), query status (2), registration (3), or erasure (4).
*
* @see 3GPP nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_* values.
* @see 3GPP TS 27.007 7.11 "mode".
*/
readonly attribute unsigned short action;
/**
* Indicates the reason the call is being forwarded.
*
* One of the CALL_FORWARD_REASON_* constants. It will be either
* unconditional (0), mobile busy (1), no reply (2), not reachable (3),
* all call forwarding (4), or all conditional call forwarding (5).
*
* @see 3GPP nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_* values.
* @see 3GPP TS 27.007 7.11 "reason".
*/
readonly attribute unsigned short reason;
/**
* Phone number of forwarding address.
*/
readonly attribute DOMString number;
/**
* When "no reply" is enabled or queried, this gives the time in
* seconds to wait before call is forwarded.
*/
readonly attribute unsigned short timeSeconds;
/**
* Service for which the call forward is set up. It should be one of the
* nsIDOMMozMobileConnectionInfo.ICC_SERVICE_CLASS_* values.
*/
readonly attribute unsigned short serviceClass;
[noscript] void initCFStateChangeEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in boolean aSuccess,
in unsigned short aAction,
in unsigned short aReason,
in DOMString aNumber,
in unsigned short aTimeSeconds,
in unsigned short aServiceClass);
};
dictionary CFStateChangeEventInit : EventInit
{
boolean success;
unsigned short action;
unsigned short reason;
DOMString number;
unsigned short timeSeconds;
unsigned short serviceClass;
};

View File

@ -1,21 +0,0 @@
/* 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 "nsIDOMEvent.idl"
[scriptable, builtinclass, uuid(8b4ed443-a6b0-4445-aab0-9aa9fd5f6c1e)]
interface nsIDOMDataErrorEvent : nsIDOMEvent
{
readonly attribute DOMString message;
[noscript] void initDataErrorEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in DOMString aMessage);
};
dictionary DataErrorEventInit : EventInit
{
DOMString message;
};

View File

@ -1,31 +0,0 @@
/* 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 "nsIDOMEvent.idl"
[scriptable, builtinclass, uuid(15cc1010-f051-11e2-945c-60a44c237d2b)]
interface nsIDOMMozEmergencyCbModeEvent : nsIDOMEvent
{
/**
* Whether the mode is activated.
*/
readonly attribute boolean active;
/**
* Automatically exit the mode after the timeoutMs ms.
*/
readonly attribute unsigned long timeoutMs;
[noscript] void initMozEmergencyCbModeEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in boolean aActive,
in unsigned long aTimeoutMs);
};
dictionary MozEmergencyCbModeEventInit : EventInit
{
boolean active;
unsigned long timeoutMs;
};

View File

@ -1,21 +0,0 @@
/* 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 "nsIDOMEvent.idl"
[scriptable, builtinclass, uuid(d3592cdc-c5cf-4c24-a27c-6f789ac94959)]
interface nsIDOMMozOtaStatusEvent : nsIDOMEvent
{
readonly attribute DOMString status;
[noscript] void initMozOtaStatusEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in DOMString aStatus);
};
dictionary MozOtaStatusEventInit : EventInit
{
DOMString status;
};

View File

@ -1,24 +0,0 @@
/* 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 "nsIDOMEvent.idl"
[scriptable, builtinclass, uuid(d26880c8-0468-4abb-94a6-9143defb5545)]
interface nsIDOMUSSDReceivedEvent : nsIDOMEvent
{
readonly attribute DOMString message;
[infallible] readonly attribute boolean sessionEnded;
[noscript] void initUSSDReceivedEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in DOMString aMessage,
in boolean aSessionEnded);
};
dictionary USSDReceivedEventInit : EventInit
{
DOMString? message;
boolean sessionEnded;
};

View File

@ -5,15 +5,15 @@
#include "mozilla/dom/network/MobileConnection.h"
#include "GeneratedEvents.h"
#include "mozilla/dom/CFStateChangeEvent.h"
#include "mozilla/dom/DataErrorEvent.h"
#include "mozilla/dom/MozEmergencyCbModeEvent.h"
#include "mozilla/dom/MozOtaStatusEvent.h"
#include "mozilla/dom/USSDReceivedEvent.h"
#include "mozilla/Preferences.h"
#include "nsDOMEvent.h"
#include "nsIDOMCFStateChangeEvent.h"
#include "nsIDOMClassInfo.h"
#include "nsIDOMDOMRequest.h"
#include "nsIDOMDataErrorEvent.h"
#include "nsIDOMMozEmergencyCbModeEvent.h"
#include "nsIDOMMozOtaStatusEvent.h"
#include "nsIDOMUSSDReceivedEvent.h"
#include "nsIPermissionManager.h"
#include "nsJSUtils.h"
@ -610,16 +610,16 @@ MobileConnection::NotifyUssdReceived(const nsAString& aMessage,
return NS_OK;
}
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMUSSDReceivedEvent(getter_AddRefs(event), this, nullptr, nullptr);
USSDReceivedEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mMessage = aMessage;
init.mSessionEnded = aSessionEnded;
nsCOMPtr<nsIDOMUSSDReceivedEvent> ce = do_QueryInterface(event);
nsresult rv = ce->InitUSSDReceivedEvent(NS_LITERAL_STRING("ussdreceived"),
false, false,
aMessage, aSessionEnded);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<USSDReceivedEvent> event =
USSDReceivedEvent::Constructor(this, NS_LITERAL_STRING("ussdreceived"), init);
return DispatchTrustedEvent(ce);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
@ -629,15 +629,15 @@ MobileConnection::NotifyDataError(const nsAString& aMessage)
return NS_OK;
}
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMDataErrorEvent(getter_AddRefs(event), this, nullptr, nullptr);
DataErrorEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mMessage = aMessage;
nsCOMPtr<nsIDOMDataErrorEvent> ce = do_QueryInterface(event);
nsresult rv = ce->InitDataErrorEvent(NS_LITERAL_STRING("dataerror"),
false, false, aMessage);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<DataErrorEvent> event =
DataErrorEvent::Constructor(this, NS_LITERAL_STRING("dataerror"), init);
return DispatchTrustedEvent(ce);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
@ -652,17 +652,20 @@ MobileConnection::NotifyCFStateChange(bool aSuccess,
return NS_OK;
}
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMCFStateChangeEvent(getter_AddRefs(event), this, nullptr, nullptr);
CFStateChangeEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mSuccess = aSuccess;
init.mAction = aAction;
init.mReason = aReason;
init.mNumber = aNumber;
init.mTimeSeconds = aSeconds;
init.mServiceClass = aServiceClass;
nsCOMPtr<nsIDOMCFStateChangeEvent> ce = do_QueryInterface(event);
nsresult rv = ce->InitCFStateChangeEvent(NS_LITERAL_STRING("cfstatechange"),
false, false,
aSuccess, aAction, aReason, aNumber,
aSeconds, aServiceClass);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<CFStateChangeEvent> event =
CFStateChangeEvent::Constructor(this, NS_LITERAL_STRING("cfstatechange"), init);
return DispatchTrustedEvent(ce);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
@ -673,18 +676,16 @@ MobileConnection::NotifyEmergencyCbModeChanged(bool aActive,
return NS_OK;
}
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMMozEmergencyCbModeEvent(getter_AddRefs(event), this, nullptr,
nullptr);
MOZ_ASSERT(event);
MozEmergencyCbModeEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mActive = aActive;
init.mTimeoutMs = aTimeoutMs;
nsCOMPtr<nsIDOMMozEmergencyCbModeEvent> ce = do_QueryInterface(event);
nsresult rv = ce->InitMozEmergencyCbModeEvent(
NS_LITERAL_STRING("emergencycbmodechange"), false, false,
aActive, aTimeoutMs);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<MozEmergencyCbModeEvent> event =
MozEmergencyCbModeEvent::Constructor(this, NS_LITERAL_STRING("emergencycbmodechange"), init);
return DispatchTrustedEvent(ce);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP
@ -694,16 +695,15 @@ MobileConnection::NotifyOtaStatusChanged(const nsAString& aStatus)
return NS_OK;
}
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMMozOtaStatusEvent(getter_AddRefs(event), this, nullptr, nullptr);
MOZ_ASSERT(event);
MozOtaStatusEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mStatus = aStatus;
nsCOMPtr<nsIDOMMozOtaStatusEvent> ce = do_QueryInterface(event);
nsresult rv = ce->InitMozOtaStatusEvent(NS_LITERAL_STRING("otastatuschange"),
false, false, aStatus);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<MozOtaStatusEvent> event =
MozOtaStatusEvent::Constructor(this, NS_LITERAL_STRING("otastatuschange"), init);
return DispatchTrustedEvent(ce);
return DispatchTrustedEvent(event);
}
NS_IMETHODIMP

View File

@ -4,14 +4,53 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type, optional CFStateChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
[Pref="dom.mobileconnection.enabled",
Constructor(DOMString type, optional CFStateChangeEventInit eventInitDict)]
interface CFStateChangeEvent : Event
{
/**
* Indicates about errors while setting up the Call forwarding rule.
*/
readonly attribute boolean success;
/**
* Indicates what to do with the rule.
*
* One of the CALL_FORWARD_ACTION_* constants. It will be either disable (0),
* enable (1), query status (2), registration (3), or erasure (4).
*
* @see 3GPP nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_* values.
* @see 3GPP TS 27.007 7.11 "mode".
*/
readonly attribute unsigned short action;
/**
* Indicates the reason the call is being forwarded.
*
* One of the CALL_FORWARD_REASON_* constants. It will be either
* unconditional (0), mobile busy (1), no reply (2), not reachable (3),
* all call forwarding (4), or all conditional call forwarding (5).
*
* @see 3GPP nsIDOMMozMobileCFInfo.CALL_FORWARD_REASON_* values.
* @see 3GPP TS 27.007 7.11 "reason".
*/
readonly attribute unsigned short reason;
/**
* Phone number of forwarding address.
*/
readonly attribute DOMString? number;
/**
* When "no reply" is enabled or queried, this gives the time in
* seconds to wait before call is forwarded.
*/
readonly attribute unsigned short timeSeconds;
/**
* Service for which the call forward is set up. It should be one of the
* nsIDOMMozMobileConnectionInfo.ICC_SERVICE_CLASS_* values.
*/
readonly attribute unsigned short serviceClass;
};

View File

@ -4,7 +4,8 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type, optional DataErrorEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
[Pref="dom.mobileconnection.enabled",
Constructor(DOMString type, optional DataErrorEventInit eventInitDict)]
interface DataErrorEvent : Event
{
readonly attribute DOMString? message;

View File

@ -4,13 +4,19 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type,
optional MozEmergencyCbModeEventInit eventInitDict),
HeaderFile="GeneratedEventClasses.h"]
[Pref="dom.mobileconnection.enabled",
Constructor(DOMString type, optional MozEmergencyCbModeEventInit eventInitDict)]
interface MozEmergencyCbModeEvent : Event
{
readonly attribute boolean active;
readonly attribute unsigned long timeoutMs;
/**
* Whether the mode is activated.
*/
readonly attribute boolean active;
/**
* Automatically exit the mode after the timeoutMs ms.
*/
readonly attribute unsigned long timeoutMs;
};
dictionary MozEmergencyCbModeEventInit : EventInit

View File

@ -4,8 +4,8 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type, optional MozOtaStatusEventInit eventInitDict),
HeaderFile="GeneratedEventClasses.h"]
[Pref="dom.mobileconnection.enabled",
Constructor(DOMString type, optional MozOtaStatusEventInit eventInitDict)]
interface MozOtaStatusEvent : Event
{
/**

View File

@ -4,7 +4,8 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type, optional USSDReceivedEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h", Pref="dom.icc.enabled"]
[Pref="dom.mobileconnection.enabled",
Constructor(DOMString type, optional USSDReceivedEventInit eventInitDict)]
interface USSDReceivedEvent : Event
{
readonly attribute DOMString? message;

View File

@ -515,18 +515,13 @@ if CONFIG['MOZ_B2G_BT']:
if CONFIG['MOZ_B2G_RIL']:
WEBIDL_FILES += [
'CFStateChangeEvent.webidl',
'DataErrorEvent.webidl',
'IccCardLockError.webidl',
'MozCellBroadcast.webidl',
'MozCellBroadcastEvent.webidl',
'MozEmergencyCbModeEvent.webidl',
'MozIcc.webidl',
'MozMobileConnectionArray.webidl',
'MozOtaStatusEvent.webidl',
'MozVoicemail.webidl',
'MozVoicemailEvent.webidl',
'USSDReceivedEvent.webidl',
]
if CONFIG['MOZ_NFC']:
@ -558,6 +553,8 @@ if CONFIG['MOZ_B2G_FM']:
GENERATED_EVENTS_WEBIDL_FILES = [
'BlobEvent.webidl',
'CallGroupErrorEvent.webidl',
'CFStateChangeEvent.webidl',
'DataErrorEvent.webidl',
'DataStoreChangeEvent.webidl',
'DeviceLightEvent.webidl',
'DeviceProximityEvent.webidl',
@ -566,12 +563,15 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'IccChangeEvent.webidl',
'MediaStreamEvent.webidl',
'MozContactChangeEvent.webidl',
'MozEmergencyCbModeEvent.webidl',
'MozInterAppMessageEvent.webidl',
'MozOtaStatusEvent.webidl',
'MozStkCommandEvent.webidl',
'RTCDataChannelEvent.webidl',
'RTCPeerConnectionIceEvent.webidl',
'TrackEvent.webidl',
'UserProximityEvent.webidl',
'USSDReceivedEvent.webidl',
]
if CONFIG['MOZ_GAMEPAD']:

View File

@ -32,13 +32,8 @@ simple_events = [
'BluetoothStatusChangedEvent',
#endif
#ifdef MOZ_B2G_RIL
'CFStateChangeEvent',
'DataErrorEvent',
'MozEmergencyCbModeEvent',
'MozOtaStatusEvent',
'MozCellBroadcastEvent',
'MozVoicemailEvent',
'USSDReceivedEvent',
#endif
'ElementReplaceEvent',
'MozSmsEvent',