Bug 827280 - Part 2: DOMEvent. r=philikon a=tef+

This commit is contained in:
Jose Antonio Olivera Ortega 2013-01-25 19:45:16 +01:00
parent 7baa538701
commit 28fdf7755d
8 changed files with 185 additions and 0 deletions

View File

@ -647,6 +647,7 @@ GK_ATOM(oncached, "oncached")
GK_ATOM(oncallschanged, "oncallschanged")
GK_ATOM(oncancel, "oncancel")
GK_ATOM(oncardstatechange, "oncardstatechange")
GK_ATOM(oncfstatechange, "oncfstatechange")
GK_ATOM(onchange, "onchange")
GK_ATOM(onchargingchange, "onchargingchange")
GK_ATOM(onchargingtimechange, "onchargingtimechange")

View File

@ -472,6 +472,7 @@ using mozilla::dom::workers::ResolveWorkerClasses;
#include "StkCommandEvent.h"
#include "nsIDOMMozCellBroadcast.h"
#include "nsIDOMMozCellBroadcastEvent.h"
#include "CFStateChangeEvent.h"
#endif // MOZ_B2G_RIL
#ifdef MOZ_B2G_FM
@ -1378,6 +1379,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(MozCellBroadcast, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CFStateChangeEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#endif
NS_DEFINE_CLASSINFO_DATA(USSDReceivedEvent, nsDOMGenericSH,
@ -3667,6 +3671,11 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCellBroadcastEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(CFStateChangeEvent, nsIDOMCFStateChangeEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCFStateChangeEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
DOM_CLASSINFO_MAP_END
#endif // MOZ_B2G_RIL
DOM_CLASSINFO_MAP_BEGIN(USSDReceivedEvent, nsIDOMUSSDReceivedEvent)

View File

@ -352,6 +352,7 @@ DOMCI_CLASS(MozConnection)
#ifdef MOZ_B2G_RIL
DOMCI_CLASS(MozMobileConnection)
DOMCI_CLASS(MozCellBroadcast)
DOMCI_CLASS(CFStateChangeEvent)
#endif
DOMCI_CLASS(USSDReceivedEvent)

View File

@ -0,0 +1,90 @@
/* 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 "CFStateChangeEvent.h"
#include "nsIDOMClassInfo.h"
#include "nsDOMClassInfoID.h"
#include "nsContentUtils.h"
DOMCI_DATA(CFStateChangeEvent, mozilla::dom::network::CFStateChangeEvent)
namespace mozilla {
namespace dom {
namespace network {
already_AddRefed<CFStateChangeEvent>
CFStateChangeEvent::Create(bool aSuccess,
uint16_t aAction,
uint16_t aReason,
nsAString& aNumber,
uint16_t aTimeSeconds,
uint16_t aServiceClass)
{
NS_ASSERTION(!aNumber.IsEmpty(), "Empty number!");
nsRefPtr<CFStateChangeEvent> event = new CFStateChangeEvent();
event->mSuccess = aSuccess;
event->mAction = aAction;
event->mReason = aReason;
event->mNumber = aNumber;
event->mTimeSeconds = aTimeSeconds;
event->mServiceClass = aServiceClass;
return event.forget();
}
NS_IMPL_ADDREF_INHERITED(CFStateChangeEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(CFStateChangeEvent, nsDOMEvent)
NS_INTERFACE_MAP_BEGIN(CFStateChangeEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMCFStateChangeEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CFStateChangeEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMETHODIMP
CFStateChangeEvent::GetSuccess(bool* aSuccess)
{
*aSuccess = mSuccess;
return NS_OK;
}
NS_IMETHODIMP
CFStateChangeEvent::GetAction(uint16_t* aAction)
{
*aAction = mAction;
return NS_OK;
}
NS_IMETHODIMP
CFStateChangeEvent::GetReason(uint16_t* aReason)
{
*aReason = mReason;
return NS_OK;
}
NS_IMETHODIMP
CFStateChangeEvent::GetNumber(nsAString& aNumber)
{
aNumber.Assign(mNumber);
return NS_OK;
}
NS_IMETHODIMP
CFStateChangeEvent::GetTimeSeconds(uint16_t* aTimeSeconds)
{
*aTimeSeconds = mTimeSeconds;
return NS_OK;
}
NS_IMETHODIMP
CFStateChangeEvent::GetServiceClass(uint16_t* aServiceClass)
{
*aServiceClass = mServiceClass;
return NS_OK;
}
}
}
}

View File

@ -0,0 +1,70 @@
/* 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_network_cfstatechangeevent_h
#define mozilla_dom_network_cfstatechangeevent_h
#include "nsIDOMCFStateChangeEvent.h"
#include "nsDOMEvent.h"
namespace mozilla {
namespace dom {
namespace network {
class CFStateChangeEvent : public nsDOMEvent,
public nsIDOMCFStateChangeEvent
{
bool mSuccess;
uint16_t mAction;
uint16_t mReason;
nsString mNumber;
uint16_t mTimeSeconds;
uint16_t mServiceClass;
public:
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_TO_NSDOMEVENT
NS_DECL_NSIDOMCFSTATECHANGEEVENT
static already_AddRefed<CFStateChangeEvent>
Create(bool aSuccess,
uint16_t aAction,
uint16_t aReason,
nsAString& aNumber,
uint16_t aTimeSeconds,
uint16_t aServiceClass);
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:
CFStateChangeEvent()
: nsDOMEvent(nullptr, nullptr)
{ }
~CFStateChangeEvent()
{ }
};
}
}
}
#endif // mozilla_dom_network_cfstatechangeevent_h

View File

@ -58,6 +58,7 @@ CPPSRCS = \
ifdef MOZ_B2G_RIL
CPPSRCS += \
MobileConnection.cpp \
CFStateChangeEvent.cpp \
$(NULL)
endif

View File

@ -0,0 +1,12 @@
/* 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/. */
dictionary CFStateChangeEventDict {
boolean success = false;
short action = -1;
short reason = -1;
DOMString? number = null;
short timeSeconds = -1;
short serviceClass = -1;
};

View File

@ -198,6 +198,7 @@ endif
ifdef MOZ_B2G_RIL
webidl_files += \
USSDReceivedEvent.webidl \
CFStateChangeEvent.webidl \
$(NULL)
endif