Bumping manifests a=b2g-bump
[gecko.git] / dom / voicemail / Voicemail.h
blobf3d13f173cac0d3263fdca54fb2118100a86607f
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
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/. */
7 #ifndef mozilla_dom_voicemail_voicemail_h__
8 #define mozilla_dom_voicemail_voicemail_h__
10 #include "mozilla/Attributes.h"
11 #include "mozilla/DOMEventTargetHelper.h"
12 #include "mozilla/ErrorResult.h"
13 #include "nsIVoicemailService.h"
15 class JSObject;
16 struct JSContext;
18 class nsPIDOMWindow;
20 namespace mozilla {
21 namespace dom {
23 class VoicemailStatus;
25 class Voicemail MOZ_FINAL : public DOMEventTargetHelper,
26 private nsIVoicemailListener
28 /**
29 * Class Voicemail doesn't actually expose nsIVoicemailListener. Instead, it
30 * owns an nsIVoicemailListener derived instance mListener and passes it to
31 * nsIVoicemailService. The onreceived events are first delivered to
32 * mListener and then forwarded to its owner, Voicemail. See also bug 775997
33 * comment #51.
35 class Listener;
37 public:
38 NS_DECL_ISUPPORTS_INHERITED
39 NS_DECL_NSIVOICEMAILLISTENER
41 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(Voicemail,
42 DOMEventTargetHelper)
44 static already_AddRefed<Voicemail>
45 Create(nsPIDOMWindow* aOwner,
46 ErrorResult& aRv);
48 void
49 Shutdown();
51 nsPIDOMWindow*
52 GetParentObject() const
54 return GetOwner();
57 virtual JSObject*
58 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
60 already_AddRefed<VoicemailStatus>
61 GetStatus(const Optional<uint32_t>& aServiceId,
62 ErrorResult& aRv);
64 void
65 GetNumber(const Optional<uint32_t>& aServiceId,
66 nsString& aNumber,
67 ErrorResult& aRv) const;
69 void
70 GetDisplayName(const Optional<uint32_t>& aServiceId,
71 nsString& aDisplayName,
72 ErrorResult& aRv) const;
74 IMPL_EVENT_HANDLER(statuschanged)
76 private:
77 Voicemail(nsPIDOMWindow* aWindow,
78 nsIVoicemailService* aService);
80 // MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
81 ~Voicemail();
83 private:
84 nsCOMPtr<nsIVoicemailService> mService;
85 nsRefPtr<Listener> mListener;
87 // |mStatuses| keeps all instantiated VoicemailStatus objects as well as the
88 // empty slots for not interested ones. The length of |mStatuses| is decided
89 // in the constructor and is never changed ever since.
90 nsAutoTArray<nsRefPtr<VoicemailStatus>, 1> mStatuses;
92 // Return a nsIVoicemailProvider instance based on the requests from external
93 // components. Return nullptr if aOptionalServiceId contains an invalid
94 // service id or the default one is just not available.
95 already_AddRefed<nsIVoicemailProvider>
96 GetItemByServiceId(const Optional<uint32_t>& aOptionalServiceId,
97 uint32_t& aActualServiceId) const;
99 // Request for a valid VoicemailStatus object based on given service id and
100 // provider. It's the callee's responsibility to ensure the validity of the
101 // two parameters.
102 already_AddRefed<VoicemailStatus>
103 GetOrCreateStatus(uint32_t aServiceId,
104 nsIVoicemailProvider* aProvider);
107 } // namespace dom
108 } // namespace mozilla
110 #endif // mozilla_dom_voicemail_voicemail_h__