michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=40: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_voicemail_voicemail_h__ michael@0: #define mozilla_dom_voicemail_voicemail_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "mozilla/ErrorResult.h" michael@0: #include "nsIVoicemailProvider.h" michael@0: michael@0: class JSObject; michael@0: struct JSContext; michael@0: michael@0: class nsPIDOMWindow; michael@0: class nsIDOMMozVoicemailStatus; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class Voicemail MOZ_FINAL : public DOMEventTargetHelper michael@0: { michael@0: /** michael@0: * Class Voicemail doesn't actually inherit nsIVoicemailListener. Instead, it michael@0: * owns an nsIVoicemailListener derived instance mListener and passes it to michael@0: * nsIVoicemailProvider. The onreceived events are first delivered to michael@0: * mListener and then forwarded to its owner, Voicemail. See also bug 775997 michael@0: * comment #51. michael@0: */ michael@0: class Listener; michael@0: michael@0: public: michael@0: NS_DECL_NSIVOICEMAILLISTENER michael@0: michael@0: NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) michael@0: michael@0: Voicemail(nsPIDOMWindow* aWindow, nsIVoicemailProvider* aProvider); michael@0: michael@0: virtual ~Voicemail(); michael@0: michael@0: nsPIDOMWindow* michael@0: GetParentObject() const michael@0: { michael@0: return GetOwner(); michael@0: } michael@0: michael@0: virtual JSObject* michael@0: WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: already_AddRefed michael@0: GetStatus(const Optional& aServiceId, ErrorResult& aRv) const; michael@0: michael@0: void michael@0: GetNumber(const Optional& aServiceId, nsString& aNumber, michael@0: ErrorResult& aRv) const; michael@0: michael@0: void michael@0: GetDisplayName(const Optional& aServiceId, nsString& aDisplayName, michael@0: ErrorResult& aRv) const; michael@0: michael@0: IMPL_EVENT_HANDLER(statuschanged) michael@0: michael@0: private: michael@0: nsCOMPtr mProvider; michael@0: nsRefPtr mListener; michael@0: michael@0: bool michael@0: IsValidServiceId(uint32_t aServiceId) const; michael@0: michael@0: bool michael@0: PassedOrDefaultServiceId(const Optional& aServiceId, michael@0: uint32_t& aResult) const; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: nsresult michael@0: NS_NewVoicemail(nsPIDOMWindow* aWindow, michael@0: mozilla::dom::Voicemail** aVoicemail); michael@0: michael@0: #endif // mozilla_dom_voicemail_voicemail_h__