Bug 780142 - Rewrite WifiStatusChangeEvent. r=smaug

This commit is contained in:
Chuck Lee 2012-10-22 17:17:18 +08:00
Родитель 4aca8b75c6
Коммит c686d1e157
11 изменённых файлов: 37 добавлений и 127 удалений

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

@ -8,77 +8,6 @@
#include "DictionaryHelpers.h"
#include "nsDOMClassInfoID.h"
// nsDOMMozWifiStatusChangeEvent
DOMCI_DATA(MozWifiStatusChangeEvent, nsDOMMozWifiStatusChangeEvent)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMozWifiStatusChangeEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNetwork)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNetwork)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN(nsDOMMozWifiStatusChangeEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozWifiStatusChangeEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozWifiStatusChangeEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
NS_IMETHODIMP
nsDOMMozWifiStatusChangeEvent::GetNetwork(nsIVariant** aNetwork)
{
NS_IF_ADDREF(*aNetwork = mNetwork);
return NS_OK;
}
NS_IMETHODIMP
nsDOMMozWifiStatusChangeEvent::GetStatus(nsAString& aStatus)
{
aStatus = mStatus;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMozWifiStatusChangeEvent::InitMozWifiStatusChangeEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIVariant* aNetwork,
const nsAString& aStatus)
{
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
mNetwork = aNetwork;
mStatus = aStatus;
return NS_OK;
}
nsresult
nsDOMMozWifiStatusChangeEvent::InitFromCtor(const nsAString& aType,
JSContext* aCx, jsval* aVal)
{
mozilla::dom::MozWifiStatusChangeEventInit d;
nsresult rv = d.Init(aCx, aVal);
NS_ENSURE_SUCCESS(rv, rv);
return InitMozWifiStatusChangeEvent(aType, d.bubbles, d.cancelable, d.network, d.status);
}
nsresult
NS_NewDOMMozWifiStatusChangeEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsEvent* aEvent)
{
nsDOMMozWifiStatusChangeEvent* e = new nsDOMMozWifiStatusChangeEvent(aPresContext, aEvent);
return CallQueryInterface(e, aInstancePtrResult);
}
// nsDOMMozWifiConnectionInfoEvent
DOMCI_DATA(MozWifiConnectionInfoEvent, nsDOMMozWifiConnectionInfoEvent)

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

@ -10,27 +10,6 @@
#include "nsIWifiEventInits.h"
#include "nsDOMEvent.h"
class nsDOMMozWifiStatusChangeEvent : public nsDOMEvent,
public nsIDOMMozWifiStatusChangeEvent
{
public:
nsDOMMozWifiStatusChangeEvent(nsPresContext* aPresContext, nsEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent) {}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
// Forward to base class
NS_FORWARD_TO_NSDOMEVENT
NS_DECL_NSIDOMMOZWIFISTATUSCHANGEEVENT
virtual nsresult InitFromCtor(const nsAString& aType,
JSContext* aCx, jsval* aVal);
private:
nsCOMPtr<nsIVariant> mNetwork;
nsString mStatus;
};
class nsDOMMozWifiConnectionInfoEvent : public nsDOMEvent,
public nsIDOMMozWifiConnectionInfoEvent
{

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

@ -1619,8 +1619,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#ifdef MOZ_B2G_RIL
NS_DEFINE_CLASSINFO_DATA(MozWifiStatusChangeEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozWifiConnectionInfoEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Telephony, nsEventTargetSH,
@ -1734,7 +1732,6 @@ NS_DEFINE_EVENT_CTOR(UIEvent)
NS_DEFINE_EVENT_CTOR(MouseEvent)
NS_DEFINE_EVENT_CTOR(WheelEvent)
#ifdef MOZ_B2G_RIL
NS_DEFINE_EVENT_CTOR(MozWifiStatusChangeEvent)
NS_DEFINE_EVENT_CTOR(MozWifiConnectionInfoEvent)
#endif

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

@ -488,7 +488,6 @@ DOMCI_CLASS(MutationObserver)
DOMCI_CLASS(MutationRecord)
#ifdef MOZ_B2G_RIL
DOMCI_CLASS(MozWifiStatusChangeEvent)
DOMCI_CLASS(MozWifiConnectionInfoEvent)
DOMCI_CLASS(Telephony)
DOMCI_CLASS(TelephonyCall)

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

@ -329,8 +329,6 @@ NS_NewDOMSmsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext,
nsresult
NS_NewDOMMozSettingsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMMozWifiStatusChangeEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMMozWifiConnectionInfoEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMMozApplicationEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);

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

@ -8,12 +8,6 @@
interface nsIVariant;
dictionary MozWifiStatusChangeEventInit : EventInit
{
nsIVariant network;
DOMString status;
};
dictionary MozWifiConnectionInfoEventInit : EventInit
{
nsIVariant network;

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

@ -19,6 +19,7 @@ include $(topsrcdir)/dom/dom-config.mk
XPIDLSRCS = \
nsIWifi.idl \
nsIDOMMozWifiStatusChangeEvent.idl \
$(NULL)
EXTRA_COMPONENTS = \

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

@ -0,0 +1,35 @@
/* 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"
interface nsIVariant;
[scriptable, builtinclass, uuid(f3ef70b0-b2d3-4eb5-8ea4-008f8d330cd6)]
interface nsIDOMMozWifiStatusChangeEvent : nsIDOMEvent
{
/**
* Network object with a SSID field describing the network affected by
* this change. This might be null.
*/
readonly attribute nsIVariant network;
/**
* String describing the current status of the wifi manager. See above for
* the possible values.
*/
readonly attribute DOMString status;
[noscript] void initMozWifiStatusChangeEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in nsIVariant aNetwork,
in DOMString aStatus);
};
dictionary MozWifiStatusChangeEventInit : EventInit
{
nsIVariant network;
DOMString status;
};

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

@ -187,28 +187,6 @@ interface nsIDOMWifiManager : nsISupports
attribute nsIDOMEventListener ondisabled;
};
[scriptable, builtinclass, uuid(f3ef70b0-b2d3-4eb5-8ea4-008f8d330cd6)]
interface nsIDOMMozWifiStatusChangeEvent : nsIDOMEvent
{
/**
* Network object with a SSID field describing the network affected by
* this change. This might be null.
*/
readonly attribute nsIVariant network;
/**
* String describing the current status of the wifi manager. See above for
* the possible values.
*/
readonly attribute DOMString status;
[noscript] void initMozWifiStatusChangeEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in nsIVariant aNetwork,
in DOMString status);
};
[scriptable, builtinclass, uuid(1717f9d9-5fd8-43d8-a098-55924c6d37de)]
interface nsIDOMMozWifiConnectionInfoEvent : nsIDOMEvent
{

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

@ -12,7 +12,6 @@ dictionaries = [
[ 'IDBIndexParameters', 'nsIIDBObjectStore.idl' ],
[ 'MutationObserverInit', 'nsIDOMMutationObserver.idl' ],
[ 'WifiConnectionInfoEventInit', 'nsIWifiEventInits.idl' ],
[ 'WifiStatusChangeEventInit', 'nsIWifiEventInits.idl' ],
[ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl' ],
[ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ],
[ 'XMLHttpRequestParameters', 'nsIXMLHttpRequest.idl' ],

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

@ -28,6 +28,7 @@ simple_events = [
#endif
#ifdef MOZ_B2G_RIL
'ICCCardLockErrorEvent',
'MozWifiStatusChangeEvent',
#endif
'DeviceStorageChangeEvent',
'PopupBlockedEvent'