dom/voicemail/Voicemail.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:c377a53e03e8
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* vim: set ts=2 et sw=2 tw=40: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef mozilla_dom_voicemail_voicemail_h__
8 #define mozilla_dom_voicemail_voicemail_h__
9
10 #include "mozilla/Attributes.h"
11 #include "mozilla/DOMEventTargetHelper.h"
12 #include "mozilla/ErrorResult.h"
13 #include "nsIVoicemailProvider.h"
14
15 class JSObject;
16 struct JSContext;
17
18 class nsPIDOMWindow;
19 class nsIDOMMozVoicemailStatus;
20
21 namespace mozilla {
22 namespace dom {
23
24 class Voicemail MOZ_FINAL : public DOMEventTargetHelper
25 {
26 /**
27 * Class Voicemail doesn't actually inherit nsIVoicemailListener. Instead, it
28 * owns an nsIVoicemailListener derived instance mListener and passes it to
29 * nsIVoicemailProvider. The onreceived events are first delivered to
30 * mListener and then forwarded to its owner, Voicemail. See also bug 775997
31 * comment #51.
32 */
33 class Listener;
34
35 public:
36 NS_DECL_NSIVOICEMAILLISTENER
37
38 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
39
40 Voicemail(nsPIDOMWindow* aWindow, nsIVoicemailProvider* aProvider);
41
42 virtual ~Voicemail();
43
44 nsPIDOMWindow*
45 GetParentObject() const
46 {
47 return GetOwner();
48 }
49
50 virtual JSObject*
51 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
52
53 already_AddRefed<nsIDOMMozVoicemailStatus>
54 GetStatus(const Optional<uint32_t>& aServiceId, ErrorResult& aRv) const;
55
56 void
57 GetNumber(const Optional<uint32_t>& aServiceId, nsString& aNumber,
58 ErrorResult& aRv) const;
59
60 void
61 GetDisplayName(const Optional<uint32_t>& aServiceId, nsString& aDisplayName,
62 ErrorResult& aRv) const;
63
64 IMPL_EVENT_HANDLER(statuschanged)
65
66 private:
67 nsCOMPtr<nsIVoicemailProvider> mProvider;
68 nsRefPtr<Listener> mListener;
69
70 bool
71 IsValidServiceId(uint32_t aServiceId) const;
72
73 bool
74 PassedOrDefaultServiceId(const Optional<uint32_t>& aServiceId,
75 uint32_t& aResult) const;
76 };
77
78 } // namespace dom
79 } // namespace mozilla
80
81 nsresult
82 NS_NewVoicemail(nsPIDOMWindow* aWindow,
83 mozilla::dom::Voicemail** aVoicemail);
84
85 #endif // mozilla_dom_voicemail_voicemail_h__

mercurial