|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "mozilla/dom/telephony/TelephonyChild.h" |
|
7 |
|
8 USING_TELEPHONY_NAMESPACE |
|
9 |
|
10 /******************************************************************************* |
|
11 * TelephonyChild |
|
12 ******************************************************************************/ |
|
13 |
|
14 TelephonyChild::TelephonyChild(nsITelephonyListener* aListener) |
|
15 : mListener(aListener) |
|
16 { |
|
17 MOZ_ASSERT(aListener); |
|
18 } |
|
19 |
|
20 void |
|
21 TelephonyChild::ActorDestroy(ActorDestroyReason aWhy) |
|
22 { |
|
23 mListener = nullptr; |
|
24 } |
|
25 |
|
26 PTelephonyRequestChild* |
|
27 TelephonyChild::AllocPTelephonyRequestChild(const IPCTelephonyRequest& aRequest) |
|
28 { |
|
29 MOZ_CRASH("Caller is supposed to manually construct a request!"); |
|
30 } |
|
31 |
|
32 bool |
|
33 TelephonyChild::DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) |
|
34 { |
|
35 delete aActor; |
|
36 return true; |
|
37 } |
|
38 |
|
39 bool |
|
40 TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId, |
|
41 const int32_t& aCallIndex, |
|
42 const nsString& aError) |
|
43 { |
|
44 MOZ_ASSERT(mListener); |
|
45 |
|
46 mListener->NotifyError(aClientId, aCallIndex, aError); |
|
47 return true; |
|
48 } |
|
49 |
|
50 bool |
|
51 TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId, |
|
52 const IPCCallStateData& aData) |
|
53 { |
|
54 MOZ_ASSERT(mListener); |
|
55 |
|
56 mListener->CallStateChanged(aClientId, |
|
57 aData.callIndex(), |
|
58 aData.callState(), |
|
59 aData.number(), |
|
60 aData.isActive(), |
|
61 aData.isOutGoing(), |
|
62 aData.isEmergency(), |
|
63 aData.isConference(), |
|
64 aData.isSwitchable(), |
|
65 aData.isMergeable()); |
|
66 return true; |
|
67 } |
|
68 |
|
69 bool |
|
70 TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, |
|
71 const nsString& aNumber) |
|
72 { |
|
73 MOZ_ASSERT(mListener); |
|
74 |
|
75 mListener->NotifyCdmaCallWaiting(aClientId, aNumber); |
|
76 return true; |
|
77 } |
|
78 |
|
79 bool |
|
80 TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) |
|
81 { |
|
82 MOZ_ASSERT(mListener); |
|
83 |
|
84 mListener->ConferenceCallStateChanged(aCallState); |
|
85 return true; |
|
86 } |
|
87 |
|
88 bool |
|
89 TelephonyChild::RecvNotifyConferenceError(const nsString& aName, |
|
90 const nsString& aMessage) |
|
91 { |
|
92 MOZ_ASSERT(mListener); |
|
93 |
|
94 mListener->NotifyConferenceError(aName, aMessage); |
|
95 return true; |
|
96 } |
|
97 |
|
98 bool |
|
99 TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId, |
|
100 const int32_t& aCallIndex, |
|
101 const uint16_t& aNotification) |
|
102 { |
|
103 MOZ_ASSERT(mListener); |
|
104 |
|
105 mListener->SupplementaryServiceNotification(aClientId, aCallIndex, |
|
106 aNotification); |
|
107 return true; |
|
108 } |
|
109 |
|
110 /******************************************************************************* |
|
111 * TelephonyRequestChild |
|
112 ******************************************************************************/ |
|
113 |
|
114 TelephonyRequestChild::TelephonyRequestChild(nsITelephonyListener* aListener, |
|
115 nsITelephonyCallback* aCallback) |
|
116 : mListener(aListener), mCallback(aCallback) |
|
117 { |
|
118 } |
|
119 |
|
120 void |
|
121 TelephonyRequestChild::ActorDestroy(ActorDestroyReason aWhy) |
|
122 { |
|
123 mListener = nullptr; |
|
124 mCallback = nullptr; |
|
125 } |
|
126 |
|
127 bool |
|
128 TelephonyRequestChild::Recv__delete__(const IPCTelephonyResponse& aResponse) |
|
129 { |
|
130 switch (aResponse.type()) { |
|
131 case IPCTelephonyResponse::TEnumerateCallsResponse: |
|
132 mListener->EnumerateCallStateComplete(); |
|
133 break; |
|
134 case IPCTelephonyResponse::TDialResponse: |
|
135 // Do nothing. |
|
136 break; |
|
137 default: |
|
138 MOZ_CRASH("Unknown type!"); |
|
139 } |
|
140 |
|
141 return true; |
|
142 } |
|
143 |
|
144 bool |
|
145 TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId, |
|
146 const IPCCallStateData& aData) |
|
147 { |
|
148 MOZ_ASSERT(mListener); |
|
149 |
|
150 mListener->EnumerateCallState(aClientId, |
|
151 aData.callIndex(), |
|
152 aData.callState(), |
|
153 aData.number(), |
|
154 aData.isActive(), |
|
155 aData.isOutGoing(), |
|
156 aData.isEmergency(), |
|
157 aData.isConference(), |
|
158 aData.isSwitchable(), |
|
159 aData.isMergeable()); |
|
160 return true; |
|
161 } |
|
162 |
|
163 bool |
|
164 TelephonyRequestChild::RecvNotifyDialError(const nsString& aError) |
|
165 { |
|
166 MOZ_ASSERT(mCallback); |
|
167 |
|
168 mCallback->NotifyDialError(aError); |
|
169 return true; |
|
170 } |
|
171 |
|
172 bool |
|
173 TelephonyRequestChild::RecvNotifyDialSuccess() |
|
174 { |
|
175 MOZ_ASSERT(mCallback); |
|
176 |
|
177 mCallback->NotifyDialSuccess(); |
|
178 return true; |
|
179 } |