dom/telephony/TelephonyCallGroup.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:ee8bf587f7e1
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=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/. */
6
7 #ifndef mozilla_dom_telephony_telephonycallgroup_h__
8 #define mozilla_dom_telephony_telephonycallgroup_h__
9
10 #include "mozilla/dom/telephony/TelephonyCommon.h"
11
12 namespace mozilla {
13 namespace dom {
14
15 class TelephonyCallGroup MOZ_FINAL : public DOMEventTargetHelper
16 {
17 nsRefPtr<Telephony> mTelephony;
18
19 nsTArray<nsRefPtr<TelephonyCall> > mCalls;
20
21 nsRefPtr<CallsList> mCallsList;
22
23 nsString mState;
24
25 uint16_t mCallState;
26
27 public:
28 NS_DECL_ISUPPORTS_INHERITED
29 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCallGroup,
30 DOMEventTargetHelper)
31
32 nsPIDOMWindow*
33 GetParentObject() const
34 {
35 return GetOwner();
36 }
37
38 // WrapperCache
39 virtual JSObject*
40 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
41
42 // WebIDL interface
43 already_AddRefed<CallsList>
44 Calls() const;
45
46 void
47 Add(TelephonyCall& aCall, ErrorResult& aRv);
48
49 void
50 Add(TelephonyCall& aCall, TelephonyCall& aSecondCall, ErrorResult& aRv);
51
52 void
53 Remove(TelephonyCall& aCall, ErrorResult& aRv);
54
55 void
56 Hold(ErrorResult& aRv);
57
58 void
59 Resume(ErrorResult& aRv);
60
61 void
62 GetState(nsString& aState) const
63 {
64 aState = mState;
65 }
66
67 IMPL_EVENT_HANDLER(statechange)
68 IMPL_EVENT_HANDLER(connected)
69 IMPL_EVENT_HANDLER(holding)
70 IMPL_EVENT_HANDLER(held)
71 IMPL_EVENT_HANDLER(resuming)
72 IMPL_EVENT_HANDLER(callschanged)
73 IMPL_EVENT_HANDLER(error)
74
75 static already_AddRefed<TelephonyCallGroup>
76 Create(Telephony* aTelephony);
77
78 void
79 AddCall(TelephonyCall* aCall);
80
81 void
82 RemoveCall(TelephonyCall* aCall);
83
84 already_AddRefed<TelephonyCall>
85 GetCall(uint32_t aServiceId, uint32_t aCallIndex);
86
87 const nsTArray<nsRefPtr<TelephonyCall> >&
88 CallsArray() const
89 {
90 return mCalls;
91 }
92
93 void
94 ChangeState(uint16_t aCallState);
95
96 uint16_t
97 CallState() const
98 {
99 return mCallState;
100 }
101
102 nsresult
103 NotifyError(const nsAString& aName, const nsAString& aMessage);
104
105 private:
106 TelephonyCallGroup(nsPIDOMWindow* aOwner);
107 ~TelephonyCallGroup();
108
109 nsresult
110 NotifyCallsChanged(TelephonyCall* aCall);
111
112 nsresult
113 DispatchCallEvent(const nsAString& aType,
114 TelephonyCall* aCall);
115
116 bool CanConference(const TelephonyCall& aCall, TelephonyCall* aSecondCall);
117 };
118
119 } // namespace dom
120 } // namespace mozilla
121
122 #endif // mozilla_dom_telephony_telephonycallgroup_h__

mercurial