зеркало из https://github.com/mozilla/gecko-dev.git
Bug 734145 - B2G RIL: Support USSD codes. Part 3: DOMEvent. r=bent
This commit is contained in:
Родитель
1b531488d5
Коммит
f4ecbde1dc
|
@ -506,6 +506,7 @@ using mozilla::dom::indexedDB::IDBWrapperCache;
|
|||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMConnection.h"
|
||||
#include "nsIDOMMobileConnection.h"
|
||||
#include "USSDReceivedEvent.h"
|
||||
#include "mozilla/dom/network/Utils.h"
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
@ -1473,6 +1474,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CLASSINFO_DATA(MozMobileConnection, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(USSDReceivedEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
|
||||
|
@ -4180,6 +4184,11 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(USSDReceivedEvent, nsIDOMUSSDReceivedEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMUSSDReceivedEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
|
|
@ -414,6 +414,8 @@ DOMCI_CLASS(MozSmsCursor)
|
|||
DOMCI_CLASS(MozConnection)
|
||||
DOMCI_CLASS(MozMobileConnection)
|
||||
|
||||
DOMCI_CLASS(USSDReceivedEvent)
|
||||
|
||||
// @font-face in CSS
|
||||
DOMCI_CLASS(CSSFontFaceRule)
|
||||
DOMCI_CLASS(CSSFontFaceStyleDecl)
|
||||
|
|
|
@ -27,6 +27,7 @@ CPPSRCS = \
|
|||
Connection.cpp \
|
||||
MobileConnection.cpp \
|
||||
Utils.cpp \
|
||||
USSDReceivedEvent.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* 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 "USSDReceivedEvent.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
DOMCI_DATA(USSDReceivedEvent, mozilla::dom::network::USSDReceivedEvent)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace network {
|
||||
|
||||
already_AddRefed<USSDReceivedEvent>
|
||||
USSDReceivedEvent::Create(nsAString& aMessage)
|
||||
{
|
||||
NS_ASSERTION(!aMessage.IsEmpty(), "Empty message!");
|
||||
|
||||
nsRefPtr<USSDReceivedEvent> event = new USSDReceivedEvent();
|
||||
|
||||
event->mMessage = aMessage;
|
||||
|
||||
return event.forget();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(USSDReceivedEvent, nsDOMEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(USSDReceivedEvent, nsDOMEvent)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(USSDReceivedEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMUSSDReceivedEvent)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(USSDReceivedEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||
|
||||
NS_IMETHODIMP
|
||||
USSDReceivedEvent::GetMessage(nsAString& aMessage)
|
||||
{
|
||||
aMessage.Assign(mMessage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* 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_ussdreceivedevent_h
|
||||
#define mozilla_dom_network_ussdreceivedevent_h
|
||||
|
||||
#include "nsIDOMUSSDReceivedEvent.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace network {
|
||||
|
||||
class USSDReceivedEvent : public nsDOMEvent,
|
||||
public nsIDOMUSSDReceivedEvent
|
||||
{
|
||||
nsString mMessage;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
NS_DECL_NSIDOMUSSDRECEIVEDEVENT
|
||||
|
||||
static already_AddRefed<USSDReceivedEvent>
|
||||
Create(nsAString& aMessage);
|
||||
|
||||
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);
|
||||
|
||||
rv = SetTrusted(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIDOMEvent* thisEvent =
|
||||
static_cast<nsDOMEvent*>(const_cast<USSDReceivedEvent*>(this));
|
||||
|
||||
bool dummy;
|
||||
rv = aTarget->DispatchEvent(thisEvent, &dummy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
USSDReceivedEvent()
|
||||
: nsDOMEvent(nsnull, nsnull)
|
||||
{ }
|
||||
|
||||
~USSDReceivedEvent()
|
||||
{ }
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // mozilla_dom_network_ussdreceivedevent_h
|
Загрузка…
Ссылка в новой задаче