Bug 734145 - B2G RIL: Support USSD codes. Part 3: DOMEvent. r=bent
authorFernando Jiménez <ferjmoreno@gmail.com>
Sat, 09 Jun 2012 17:07:18 -0400
changeset 101091 fed1cc9763919b56e5d91615ca102fc6fedc3b32
parent 101090 6a82222e6d5b00b2a3f258eb1509f17c607254a4
child 101092 8e8cda8abd8d80c622dd6c079daeed859973bb7b
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs734145
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 734145 - B2G RIL: Support USSD codes. Part 3: DOMEvent. r=bent
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/network/src/Makefile.in
dom/network/src/USSDReceivedEvent.cpp
dom/network/src/USSDReceivedEvent.h
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -501,16 +501,17 @@ using mozilla::dom::indexedDB::IDBWrappe
 #include "nsIDOMSmsMessage.h"
 #include "nsIDOMSmsEvent.h"
 #include "nsIDOMSmsRequest.h"
 #include "nsIDOMSmsFilter.h"
 #include "nsIDOMSmsCursor.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIDOMConnection.h"
 #include "nsIDOMMobileConnection.h"
+#include "USSDReceivedEvent.h"
 #include "mozilla/dom/network/Utils.h"
 
 #ifdef MOZ_B2G_RIL
 #include "Telephony.h"
 #include "TelephonyCall.h"
 #include "CallEvent.h"
 #endif
 
@@ -1468,16 +1469,19 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozConnection, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   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,
                            ARRAY_SCRIPTABLE_FLAGS)
 
 #if defined(MOZ_MEDIA)
   NS_DEFINE_CLASSINFO_DATA(HTMLVideoElement, nsElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
@@ -4175,16 +4179,21 @@ nsDOMClassInfo::Init()
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozMobileConnection, nsIDOMMozMobileConnection)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileConnection)
      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
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSFontFaceStyleDecl,
                                       nsIDOMCSSStyleDeclaration)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
   DOM_CLASSINFO_MAP_END
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -409,16 +409,18 @@ DOMCI_CLASS(MozSmsMessage)
 DOMCI_CLASS(MozSmsEvent)
 DOMCI_CLASS(MozSmsRequest)
 DOMCI_CLASS(MozSmsFilter)
 DOMCI_CLASS(MozSmsCursor)
 
 DOMCI_CLASS(MozConnection)
 DOMCI_CLASS(MozMobileConnection)
 
+DOMCI_CLASS(USSDReceivedEvent)
+
 // @font-face in CSS
 DOMCI_CLASS(CSSFontFaceRule)
 DOMCI_CLASS(CSSFontFaceStyleDecl)
 
 #if defined(MOZ_MEDIA)
 // WhatWG Video Element
 DOMCI_CLASS(HTMLVideoElement)
 DOMCI_CLASS(HTMLSourceElement)
--- a/dom/network/src/Makefile.in
+++ b/dom/network/src/Makefile.in
@@ -22,16 +22,17 @@ EXPORTS_mozilla/dom/network = \
   Types.h \
   Constants.h \
   $(NULL)
 
 CPPSRCS = \
   Connection.cpp \
   MobileConnection.cpp \
   Utils.cpp \
+  USSDReceivedEvent.cpp \
   $(NULL)
 
 LOCAL_INCLUDES = \
   -I$(topsrcdir)/content/events/src \
   $(NULL)
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
new file mode 100644
--- /dev/null
+++ b/dom/network/src/USSDReceivedEvent.cpp
@@ -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;
+}
+
+}
+}
+}
new file mode 100644
--- /dev/null
+++ b/dom/network/src/USSDReceivedEvent.h
@@ -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