1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/voicemail/Voicemail.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=40: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_voicemail_voicemail_h__ 1.11 +#define mozilla_dom_voicemail_voicemail_h__ 1.12 + 1.13 +#include "mozilla/Attributes.h" 1.14 +#include "mozilla/DOMEventTargetHelper.h" 1.15 +#include "mozilla/ErrorResult.h" 1.16 +#include "nsIVoicemailProvider.h" 1.17 + 1.18 +class JSObject; 1.19 +struct JSContext; 1.20 + 1.21 +class nsPIDOMWindow; 1.22 +class nsIDOMMozVoicemailStatus; 1.23 + 1.24 +namespace mozilla { 1.25 +namespace dom { 1.26 + 1.27 +class Voicemail MOZ_FINAL : public DOMEventTargetHelper 1.28 +{ 1.29 + /** 1.30 + * Class Voicemail doesn't actually inherit nsIVoicemailListener. Instead, it 1.31 + * owns an nsIVoicemailListener derived instance mListener and passes it to 1.32 + * nsIVoicemailProvider. The onreceived events are first delivered to 1.33 + * mListener and then forwarded to its owner, Voicemail. See also bug 775997 1.34 + * comment #51. 1.35 + */ 1.36 + class Listener; 1.37 + 1.38 +public: 1.39 + NS_DECL_NSIVOICEMAILLISTENER 1.40 + 1.41 + NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) 1.42 + 1.43 + Voicemail(nsPIDOMWindow* aWindow, nsIVoicemailProvider* aProvider); 1.44 + 1.45 + virtual ~Voicemail(); 1.46 + 1.47 + nsPIDOMWindow* 1.48 + GetParentObject() const 1.49 + { 1.50 + return GetOwner(); 1.51 + } 1.52 + 1.53 + virtual JSObject* 1.54 + WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.55 + 1.56 + already_AddRefed<nsIDOMMozVoicemailStatus> 1.57 + GetStatus(const Optional<uint32_t>& aServiceId, ErrorResult& aRv) const; 1.58 + 1.59 + void 1.60 + GetNumber(const Optional<uint32_t>& aServiceId, nsString& aNumber, 1.61 + ErrorResult& aRv) const; 1.62 + 1.63 + void 1.64 + GetDisplayName(const Optional<uint32_t>& aServiceId, nsString& aDisplayName, 1.65 + ErrorResult& aRv) const; 1.66 + 1.67 + IMPL_EVENT_HANDLER(statuschanged) 1.68 + 1.69 +private: 1.70 + nsCOMPtr<nsIVoicemailProvider> mProvider; 1.71 + nsRefPtr<Listener> mListener; 1.72 + 1.73 + bool 1.74 + IsValidServiceId(uint32_t aServiceId) const; 1.75 + 1.76 + bool 1.77 + PassedOrDefaultServiceId(const Optional<uint32_t>& aServiceId, 1.78 + uint32_t& aResult) const; 1.79 +}; 1.80 + 1.81 +} // namespace dom 1.82 +} // namespace mozilla 1.83 + 1.84 +nsresult 1.85 +NS_NewVoicemail(nsPIDOMWindow* aWindow, 1.86 + mozilla::dom::Voicemail** aVoicemail); 1.87 + 1.88 +#endif // mozilla_dom_voicemail_voicemail_h__