Bug 780142 - Rewrite MozWifiConnectionInfoEvent. r=smaug

This commit is contained in:
Chuck Lee 2012-10-22 18:18:26 +08:00
Родитель c686d1e157
Коммит 6a13b77a08
13 изменённых файлов: 57 добавлений и 218 удалений

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

@ -64,12 +64,6 @@ CPPSRCS = \
TextComposition.cpp \
$(NULL)
ifdef MOZ_B2G_RIL
CPPSRCS += \
nsDOMWifiEvent.cpp \
$(NULL)
endif
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1

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

@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsDOMWifiEvent.h"
#include "nsContentUtils.h"
#include "DictionaryHelpers.h"
#include "nsDOMClassInfoID.h"
// nsDOMMozWifiConnectionInfoEvent
DOMCI_DATA(MozWifiConnectionInfoEvent, nsDOMMozWifiConnectionInfoEvent)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMozWifiConnectionInfoEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNetwork)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNetwork)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN(nsDOMMozWifiConnectionInfoEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozWifiConnectionInfoEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozWifiConnectionInfoEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
NS_IMETHODIMP
nsDOMMozWifiConnectionInfoEvent::GetNetwork(nsIVariant** aNetwork)
{
NS_IF_ADDREF(*aNetwork = mNetwork);
return NS_OK;
}
NS_IMETHODIMP
nsDOMMozWifiConnectionInfoEvent::GetSignalStrength(int16_t* aSignalStrength)
{
*aSignalStrength = mSignalStrength;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMozWifiConnectionInfoEvent::GetRelSignalStrength(int16_t* aRelSignalStrength)
{
*aRelSignalStrength = mRelSignalStrength;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMozWifiConnectionInfoEvent::GetLinkSpeed(int32_t* aLinkSpeed)
{
*aLinkSpeed = mLinkSpeed;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMozWifiConnectionInfoEvent::GetIpAddress(nsAString& aIpAddress)
{
aIpAddress = mIpAddress;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMozWifiConnectionInfoEvent::InitMozWifiConnectionInfoEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIVariant *aNetwork,
int16_t aSignalStrength,
int16_t aRelSignalStrength,
int32_t aLinkSpeed,
const nsAString &aIpAddress)
{
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
mNetwork = aNetwork;
mSignalStrength = aSignalStrength;
mRelSignalStrength = aRelSignalStrength;
mLinkSpeed = aLinkSpeed;
mIpAddress = aIpAddress;
return NS_OK;
}
nsresult
nsDOMMozWifiConnectionInfoEvent::InitFromCtor(const nsAString& aType,
JSContext* aCx, jsval* aVal)
{
mozilla::dom::MozWifiConnectionInfoEventInit d;
nsresult rv = d.Init(aCx, aVal);
NS_ENSURE_SUCCESS(rv, rv);
return InitMozWifiConnectionInfoEvent(aType, d.bubbles, d.cancelable, d.network,
d.signalStrength, d.relSignalStrength, d.linkSpeed,
d.ipAddress);
}
nsresult
NS_NewDOMMozWifiConnectionInfoEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsEvent* aEvent)
{
nsDOMMozWifiConnectionInfoEvent* e = new nsDOMMozWifiConnectionInfoEvent(aPresContext, aEvent);
return CallQueryInterface(e, aInstancePtrResult);
}

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

@ -1,37 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 nsDOMWifiEvent_h__
#define nsDOMWifiEvent_h__
#include "nsIWifi.h"
#include "nsIWifiEventInits.h"
#include "nsDOMEvent.h"
class nsDOMMozWifiConnectionInfoEvent : public nsDOMEvent,
public nsIDOMMozWifiConnectionInfoEvent
{
public:
nsDOMMozWifiConnectionInfoEvent(nsPresContext* aPresContext, nsEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent) {}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMMozWifiConnectionInfoEvent, nsDOMEvent)
// Forward to base class
NS_FORWARD_TO_NSDOMEVENT
NS_DECL_NSIDOMMOZWIFICONNECTIONINFOEVENT
virtual nsresult InitFromCtor(const nsAString& aType,
JSContext* aCx, jsval* aVal);
private:
nsCOMPtr<nsIVariant> mNetwork;
int16_t mSignalStrength;
int16_t mRelSignalStrength;
int32_t mLinkSpeed;
nsString mIpAddress;
};
#endif // nsDOMWifiEvent_h__

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

@ -179,7 +179,6 @@
#ifdef MOZ_B2G_RIL
#include "nsIWifi.h"
#include "nsIWifiEventInits.h"
#endif
// includes needed for the prototype chain interfaces
@ -1619,8 +1618,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#ifdef MOZ_B2G_RIL
NS_DEFINE_CLASSINFO_DATA(MozWifiConnectionInfoEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Telephony, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(TelephonyCall, nsEventTargetSH,
@ -1731,9 +1728,6 @@ NS_DEFINE_EVENT_CTOR(Event)
NS_DEFINE_EVENT_CTOR(UIEvent)
NS_DEFINE_EVENT_CTOR(MouseEvent)
NS_DEFINE_EVENT_CTOR(WheelEvent)
#ifdef MOZ_B2G_RIL
NS_DEFINE_EVENT_CTOR(MozWifiConnectionInfoEvent)
#endif
#define MOZ_GENERATED_EVENT_LIST
#define MOZ_GENERATED_EVENT(_event_interface) \

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

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

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

@ -57,7 +57,6 @@ XPIDLSRCS = \
nsIDOMCustomEvent.idl \
nsIDOMCompositionEvent.idl \
nsIDOMWheelEvent.idl \
nsIWifiEventInits.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -329,7 +329,5 @@ NS_NewDOMSmsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext,
nsresult
NS_NewDOMMozSettingsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMMozWifiConnectionInfoEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMMozApplicationEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
%}

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

@ -1,18 +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 "nsISupports.idl"
#include "nsIDOMEventTarget.idl"
#include "nsIDOMEvent.idl"
interface nsIVariant;
dictionary MozWifiConnectionInfoEventInit : EventInit
{
nsIVariant network;
short signalStrength;
short relSignalStrength;
long linkSpeed;
DOMString ipAddress;
};

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

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

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

@ -0,0 +1,55 @@
/* 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(1717f9d9-5fd8-43d8-a098-55924c6d37de)]
interface nsIDOMMozWifiConnectionInfoEvent : nsIDOMEvent
{
/**
* Network object with an SSID field.
*/
readonly attribute nsIVariant network;
/**
* Strength of the signal to network, in dBm between -55 and -100 dBm.
*/
readonly attribute short signalStrength;
/**
* Relative signal strength between 0 and 100.
*/
readonly attribute short relSignalStrength;
/**
* Link speed in Mb/s.
*/
readonly attribute long linkSpeed;
/**
* IP address in the dotted quad format.
*/
readonly attribute DOMString ipAddress;
[noscript] void initMozWifiConnectionInfoEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in nsIVariant aNetwork,
in short signalStrength,
in short relSignalStrength,
in long linkSpeed,
in DOMString ipAddress);
};
dictionary MozWifiConnectionInfoEventInit : EventInit
{
nsIVariant network;
short signalStrength;
short relSignalStrength;
long linkSpeed;
DOMString ipAddress;
};

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

@ -186,41 +186,3 @@ interface nsIDOMWifiManager : nsISupports
attribute nsIDOMEventListener onenabled;
attribute nsIDOMEventListener ondisabled;
};
[scriptable, builtinclass, uuid(1717f9d9-5fd8-43d8-a098-55924c6d37de)]
interface nsIDOMMozWifiConnectionInfoEvent : nsIDOMEvent
{
/**
* Network object with an SSID field.
*/
readonly attribute nsIVariant network;
/**
* Strength of the signal to network, in dBm between -55 and -100 dBm.
*/
readonly attribute short signalStrength;
/**
* Relative signal strength between 0 and 100.
*/
readonly attribute short relSignalStrength;
/**
* Link speed in Mb/s.
*/
readonly attribute long linkSpeed;
/**
* IP address in the dotted quad format.
*/
readonly attribute DOMString ipAddress;
[noscript] void initMozWifiConnectionInfoEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in nsIVariant aNetwork,
in short signalStrength,
in short relSignalStrength,
in long linkSpeed,
in DOMString ipAddress);
};

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

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

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

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