Bug 833278 - Part 2/2: Implement MozVoicemailEvent using codegenerator. r=gwagner,smaug

This commit is contained in:
Vicamo Yang 2013-02-05 17:02:18 +08:00
parent 157aebae18
commit 206ac2e59c
8 changed files with 20 additions and 124 deletions

View File

@ -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)

View File

@ -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

View File

@ -25,7 +25,6 @@ EXPORTS_mozilla/dom = \
CPPSRCS = \
Voicemail.cpp \
VoicemailEvent.cpp \
$(NULL)
XPIDLSRCS = \

View File

@ -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<VoicemailEvent> event = new VoicemailEvent(nullptr, nullptr);
nsresult rv = event->InitVoicemailEvent(NS_LITERAL_STRING("statuschanged"),
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMMozVoicemailEvent(getter_AddRefs(event), nullptr, nullptr);
nsCOMPtr<nsIDOMMozVoicemailEvent> ce = do_QueryInterface(event);
nsresult rv = ce->InitMozVoicemailEvent(NS_LITERAL_STRING("statuschanged"),
false, false, aStatus);
NS_ENSURE_SUCCESS(rv, rv);
return DispatchTrustedEvent(static_cast<nsIDOMMozVoicemailEvent*>(event));
return DispatchTrustedEvent(ce);
}
} // namespace dom

View File

@ -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);
}
}

View File

@ -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<nsIDOMMozVoicemailStatus> mStatus;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_voicemail_VoicemailEvent_h__

View File

@ -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;
};

View File

@ -33,6 +33,7 @@ simple_events = [
'MozWifiStatusChangeEvent',
'MozWifiConnectionInfoEvent',
'MozCellBroadcastEvent',
'MozVoicemailEvent',
#endif
'DeviceStorageChangeEvent',
'PopupBlockedEvent'