From 206ac2e59c08517551f18956cea423179e4bbbb8 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 5 Feb 2013 17:02:18 +0800 Subject: [PATCH] Bug 833278 - Part 2/2: Implement MozVoicemailEvent using codegenerator. r=gwagner,smaug --- dom/base/nsDOMClassInfo.cpp | 8 --- dom/base/nsDOMClassInfoClasses.h | 1 - dom/voicemail/Makefile.in | 1 - dom/voicemail/Voicemail.cpp | 13 +++-- dom/voicemail/VoicemailEvent.cpp | 66 ----------------------- dom/voicemail/VoicemailEvent.h | 42 --------------- dom/voicemail/nsIDOMMozVoicemailEvent.idl | 12 ++++- js/xpconnect/src/event_impl_gen.conf.in | 1 + 8 files changed, 20 insertions(+), 124 deletions(-) delete mode 100644 dom/voicemail/VoicemailEvent.cpp delete mode 100644 dom/voicemail/VoicemailEvent.h diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 14bec27cbef..dbd59d18e3c 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -438,7 +438,6 @@ using mozilla::dom::workers::ResolveWorkerClasses; #include "Telephony.h" #include "TelephonyCall.h" #include "nsIDOMMozVoicemail.h" -#include "nsIDOMMozVoicemailEvent.h" #include "nsIDOMIccManager.h" #include "StkCommandEvent.h" #include "nsIDOMMozCellBroadcast.h" @@ -1424,8 +1423,6 @@ static nsDOMClassInfoData sClassInfoData[] = { EVENTTARGET_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(MozVoicemail, nsEventTargetSH, EVENTTARGET_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(MozVoicemailEvent, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(MozIccManager, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(MozStkCommandEvent, nsDOMGenericSH, @@ -3683,11 +3680,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(MozVoicemailEvent, nsIDOMMozVoicemailEvent) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozVoicemailEvent) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(MozIccManager, nsIDOMMozIccManager) DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozIccManager) DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 40131791846..09cc45092d6 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -407,7 +407,6 @@ DOMCI_CLASS(MediaQueryList) DOMCI_CLASS(Telephony) DOMCI_CLASS(TelephonyCall) DOMCI_CLASS(MozVoicemail) -DOMCI_CLASS(MozVoicemailEvent) DOMCI_CLASS(MozIccManager) DOMCI_CLASS(MozStkCommandEvent) #endif diff --git a/dom/voicemail/Makefile.in b/dom/voicemail/Makefile.in index e2ffb82b125..27194107fe3 100644 --- a/dom/voicemail/Makefile.in +++ b/dom/voicemail/Makefile.in @@ -25,7 +25,6 @@ EXPORTS_mozilla/dom = \ CPPSRCS = \ Voicemail.cpp \ - VoicemailEvent.cpp \ $(NULL) XPIDLSRCS = \ diff --git a/dom/voicemail/Voicemail.cpp b/dom/voicemail/Voicemail.cpp index 8cbc38d721c..74898befc0b 100644 --- a/dom/voicemail/Voicemail.cpp +++ b/dom/voicemail/Voicemail.cpp @@ -6,14 +6,14 @@ #include "Voicemail.h" #include "nsIDOMMozVoicemailStatus.h" +#include "nsIDOMMozVoicemailEvent.h" #include "mozilla/Services.h" #include "nsContentUtils.h" #include "nsDOMClassInfo.h" #include "nsRadioInterfaceLayer.h" #include "nsServiceManagerUtils.h" - -#include "VoicemailEvent.h" +#include "GeneratedEvents.h" DOMCI_DATA(MozVoicemail, mozilla::dom::Voicemail) @@ -93,12 +93,15 @@ NS_IMPL_EVENT_HANDLER(Voicemail, statuschanged) NS_IMETHODIMP Voicemail::VoicemailNotification(nsIDOMMozVoicemailStatus* aStatus) { - nsRefPtr event = new VoicemailEvent(nullptr, nullptr); - nsresult rv = event->InitVoicemailEvent(NS_LITERAL_STRING("statuschanged"), + nsCOMPtr event; + NS_NewDOMMozVoicemailEvent(getter_AddRefs(event), nullptr, nullptr); + + nsCOMPtr ce = do_QueryInterface(event); + nsresult rv = ce->InitMozVoicemailEvent(NS_LITERAL_STRING("statuschanged"), false, false, aStatus); NS_ENSURE_SUCCESS(rv, rv); - return DispatchTrustedEvent(static_cast(event)); + return DispatchTrustedEvent(ce); } } // namespace dom diff --git a/dom/voicemail/VoicemailEvent.cpp b/dom/voicemail/VoicemailEvent.cpp deleted file mode 100644 index 3222ff5df47..00000000000 --- a/dom/voicemail/VoicemailEvent.cpp +++ /dev/null @@ -1,66 +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 "VoicemailEvent.h" -#include "nsDOMClassInfo.h" -#include "nsIDOMMozVoicemailStatus.h" - -DOMCI_DATA(MozVoicemailEvent, mozilla::dom::VoicemailEvent) - -namespace mozilla { -namespace dom { - -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(VoicemailEvent, nsDOMEvent) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mStatus) -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(VoicemailEvent, nsDOMEvent) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStatus) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(VoicemailEvent) - NS_INTERFACE_MAP_ENTRY(nsIDOMMozVoicemailEvent) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozVoicemailEvent) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent) - -NS_IMPL_ADDREF_INHERITED(VoicemailEvent, nsDOMEvent) -NS_IMPL_RELEASE_INHERITED(VoicemailEvent, nsDOMEvent) - -nsresult -VoicemailEvent::InitVoicemailEvent(const nsAString& aEventTypeArg, - bool aCanBubbleArg, bool aCancelableArg, - nsIDOMMozVoicemailStatus* aStatus) -{ - nsresult rv = nsDOMEvent::InitEvent(aEventTypeArg, aCanBubbleArg, - aCancelableArg); - NS_ENSURE_SUCCESS(rv, rv); - - mStatus = aStatus; - return NS_OK; -} - -NS_IMETHODIMP -VoicemailEvent::GetStatus(nsIDOMMozVoicemailStatus** aStatus) -{ - NS_IF_ADDREF(*aStatus = mStatus); - return NS_OK; -} - -} // namespace dom -} // namespace mozilla - -namespace { - -nsresult -NS_NewDOMVoicemailEvent(nsIDOMEvent** aInstancePtrResult, - nsPresContext* aPresContext, - nsEvent* aEvent) -{ - return CallQueryInterface( - new mozilla::dom::VoicemailEvent(aPresContext, aEvent), - aInstancePtrResult); -} - -} diff --git a/dom/voicemail/VoicemailEvent.h b/dom/voicemail/VoicemailEvent.h deleted file mode 100644 index 11f5a953756..00000000000 --- a/dom/voicemail/VoicemailEvent.h +++ /dev/null @@ -1,42 +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 mozilla_dom_voicemail_VoicemailEvent_h__ -#define mozilla_dom_voicemail_VoicemailEvent_h__ - -#include "nsIDOMMozVoicemailEvent.h" -#include "nsDOMEvent.h" - -class nsIDOMMozVoicemailStatus; - -namespace mozilla { -namespace dom { - -class VoicemailEvent : public nsIDOMMozVoicemailEvent, - public nsDOMEvent -{ -public: - VoicemailEvent(nsPresContext* aPresContext, nsEvent* aEvent) - : nsDOMEvent(aPresContext, aEvent) { } - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMMOZVOICEMAILEVENT - - NS_FORWARD_TO_NSDOMEVENT - - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VoicemailEvent, nsDOMEvent) - - nsresult InitVoicemailEvent(const nsAString& aEventTypeArg, - bool aCanBubbleArg, bool aCancelableArg, - nsIDOMMozVoicemailStatus* aStatus); - -private: - nsCOMPtr mStatus; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_voicemail_VoicemailEvent_h__ diff --git a/dom/voicemail/nsIDOMMozVoicemailEvent.idl b/dom/voicemail/nsIDOMMozVoicemailEvent.idl index 9d9478d89ef..c8ebc3eafec 100644 --- a/dom/voicemail/nsIDOMMozVoicemailEvent.idl +++ b/dom/voicemail/nsIDOMMozVoicemailEvent.idl @@ -8,11 +8,21 @@ interface nsIDOMMozVoicemailStatus; -[scriptable, builtinclass, uuid(8fd09b8e-1572-48ff-8719-f8f179afef4b)] +[scriptable, builtinclass, uuid(63e42e5f-0742-4c8f-bd52-938a7e03d2c9)] interface nsIDOMMozVoicemailEvent : nsIDOMEvent { /** * The voicemail status that caused this event to fire */ readonly attribute nsIDOMMozVoicemailStatus status; + + [noscript] void initMozVoicemailEvent(in DOMString aType, + in boolean aCanBubble, + in boolean aCancelable, + in nsIDOMMozVoicemailStatus aStatus); +}; + +dictionary MozVoicemailEventInit : EventInit +{ + nsIDOMMozVoicemailStatus status; }; diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index bc8f3f34209..a7d3561830c 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -33,6 +33,7 @@ simple_events = [ 'MozWifiStatusChangeEvent', 'MozWifiConnectionInfoEvent', 'MozCellBroadcastEvent', + 'MozVoicemailEvent', #endif 'DeviceStorageChangeEvent', 'PopupBlockedEvent'