|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Handles client-side telephony audio routing requests. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <e32svr.h> |
|
23 #include <e32std.h> |
|
24 |
|
25 #include "TelephonyAudioRouting.h" |
|
26 #include "TelephonyAudioRoutingProxy.h" |
|
27 #include "TelephonyAudioRoutingClientServer.h" |
|
28 #include "TelephonyAudioRoutingSession.h" |
|
29 #include "MTelephonyAudioRoutingObserver.h" |
|
30 |
|
31 |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // C++ default constructor can NOT contain any code, that |
|
36 // might leave. |
|
37 // |
|
38 CTelephonyAudioRoutingProxy::CTelephonyAudioRoutingProxy( |
|
39 MTelephonyAudioRoutingObserver& aObserver) |
|
40 : iObserver(aObserver), |
|
41 iAvailableOutputs(0, NULL, NULL) |
|
42 { |
|
43 |
|
44 } |
|
45 |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CTelephonyAudioRoutingProxy::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CTelephonyAudioRoutingProxy::ConstructL() |
|
53 { |
|
54 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::ConstructL"),this); |
|
55 User::LeaveIfError(iSession.ConnectL(*this, iObserver)); |
|
56 |
|
57 // Make sure session is set up with default values from server for its local variables: |
|
58 iSession.GetDefaultValuesL(); |
|
59 |
|
60 CTelephonyAudioRouting::TAudioOutput audioOutput = Output(); |
|
61 |
|
62 // Get stored values for audio output and array and store values in local variables: |
|
63 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::ConstructL, current iAudioOutput retrieved from server: %d"), audioOutput); |
|
64 |
|
65 TArray<CTelephonyAudioRouting::TAudioOutput> availableOutputArray = AvailableOutputs(); |
|
66 TInt count = availableOutputArray.Count(); |
|
67 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t ConstructL: Count = %d "), count); |
|
68 for(TInt i = 0; i < count; i++) |
|
69 { |
|
70 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t ConstructL: availableOutputs[i] = %d "),availableOutputArray[i]); |
|
71 } |
|
72 |
|
73 iSession.NotifyIfOutputChanged(); |
|
74 iSession.NotifyIfAvailableOutputsChanged(); |
|
75 |
|
76 } |
|
77 |
|
78 // Two-phased constructor. |
|
79 EXPORT_C CTelephonyAudioRoutingProxy* CTelephonyAudioRoutingProxy::NewL(MTelephonyAudioRoutingObserver& aObserver) |
|
80 { |
|
81 CTelephonyAudioRoutingProxy* self = new(ELeave) CTelephonyAudioRoutingProxy(aObserver); |
|
82 CleanupStack::PushL(self); |
|
83 self->ConstructL(); |
|
84 CleanupStack::Pop(self); |
|
85 return self; |
|
86 } |
|
87 |
|
88 |
|
89 // Destructor |
|
90 CTelephonyAudioRoutingProxy::~CTelephonyAudioRoutingProxy() |
|
91 { |
|
92 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::~CTelephonyAudioRoutingProxy[%x]"),this); |
|
93 iSession.Close(); |
|
94 } |
|
95 |
|
96 |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CTelephonyAudioRoutingProxy::AvailableOutputs |
|
100 // Provides caller with an array of available audio outputs |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 const TArray<CTelephonyAudioRouting::TAudioOutput>& CTelephonyAudioRoutingProxy::AvailableOutputs() |
|
104 { |
|
105 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::AvailableOutputs"),this); |
|
106 |
|
107 TRAP_IGNORE(iSession.GetAvailableOutputsL()); // Session will get values from Server and store in its iAvailableOutputs |
|
108 |
|
109 TInt count = (iSession.AvailableOutputs()).Count(); |
|
110 |
|
111 iAvailableOutputs = (iSession.AvailableOutputs()).Array(); |
|
112 |
|
113 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::AvailableOutputs: Count = %d "), count); |
|
114 for(TInt i = 0; i < count; i++) |
|
115 { |
|
116 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::AvailableOutputs: availableOutputs[i] = %d "),iAvailableOutputs[i]); |
|
117 } |
|
118 return iAvailableOutputs; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CTelephonyAudioRoutingProxy::Output |
|
123 // Provides caller with the current audio output setting. |
|
124 // (other items were commented in a header). |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 CTelephonyAudioRouting::TAudioOutput CTelephonyAudioRoutingProxy::Output() |
|
128 { |
|
129 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::Output"),this); |
|
130 |
|
131 TAudioOutput audioOutput = (iSession.CurrentAudioOutputPkg())(); |
|
132 |
|
133 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::Output: iSession's Audio Output = %d"),audioOutput); |
|
134 return audioOutput; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------- |
|
138 // CTelephonyAudioRoutingProxy::SetOutputL |
|
139 // Allows caller to set audio output to a particular value. |
|
140 // (other items were commented in a header). |
|
141 // --------------------------------------------------------- |
|
142 // |
|
143 |
|
144 void CTelephonyAudioRoutingProxy::SetOutputL(TAudioOutput aOutput) |
|
145 { |
|
146 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::SetOutput"),this); |
|
147 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::SetOutput with: %d"), aOutput); |
|
148 |
|
149 TBool validOutput = ETrue; |
|
150 // Verify request is valid: (not necessary for ENone or ENotActive) |
|
151 if ((aOutput != CTelephonyAudioRouting::ENotActive) && (aOutput != CTelephonyAudioRouting::ENone)) |
|
152 { |
|
153 validOutput = ValidateOutputRequest(aOutput); |
|
154 } |
|
155 |
|
156 if (validOutput) |
|
157 { |
|
158 iSession.SetOutput(aOutput, iShowNote); |
|
159 // Reset iShowNote once it's sent |
|
160 iShowNote = EFalse; |
|
161 } |
|
162 else |
|
163 { |
|
164 TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::SetOutput: Error: Requested output not in array")); |
|
165 // reset session's iOkToGetShowNoteMode flag, since it errored |
|
166 iSession.ResetShowNoteMode(); |
|
167 User::Leave(KErrHardwareNotAvailable); |
|
168 } |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------- |
|
172 // CTelephonyAudioRoutingProxy::PreviousOutput |
|
173 // Provides caller with current value of previous audio output value. |
|
174 // (other items were commented in a header). |
|
175 // --------------------------------------------------------- |
|
176 // |
|
177 |
|
178 CTelephonyAudioRouting::TAudioOutput CTelephonyAudioRoutingProxy::PreviousOutput() |
|
179 { |
|
180 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::PreviousOutput"), this); |
|
181 TAudioOutput prevOutput = (iSession.PreviousAudioOutputPkg())(); |
|
182 |
|
183 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::PreviousOutput: iSession's Previous Audio Output = %d"),prevOutput); |
|
184 return prevOutput; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // CTelephonyAudioRoutingProxy::ValidateOutputRequest |
|
189 // Checks that output requested is in list of available outputs. |
|
190 // (other items were commented in a header). |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 |
|
194 TBool CTelephonyAudioRoutingProxy::ValidateOutputRequest(TAudioOutput aOutput) |
|
195 { |
|
196 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::ValidateOutputRequest"),this); |
|
197 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::ValidateOutputRequest for: %d"),aOutput); |
|
198 |
|
199 TArray<CTelephonyAudioRouting::TAudioOutput> availableOutputs = (iSession.AvailableOutputs()).Array(); |
|
200 |
|
201 TBool found = EFalse; |
|
202 TInt count = availableOutputs.Count(); |
|
203 for(TInt i = 0; i < count; i++) |
|
204 { |
|
205 if (aOutput == availableOutputs[i]) |
|
206 { |
|
207 found = ETrue; |
|
208 break; |
|
209 } |
|
210 } |
|
211 return found; |
|
212 } |
|
213 |
|
214 |
|
215 // --------------------------------------------------------- |
|
216 // CTelephonyAudioRoutingProxy::ShowNoteMode |
|
217 // Provides caller with the current ShowNoteMode setting in server. |
|
218 // (other items were commented in a header). |
|
219 // --------------------------------------------------------- |
|
220 // |
|
221 TBool CTelephonyAudioRoutingProxy::ShowNoteMode() |
|
222 { |
|
223 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::ShowNoteMode"),this); |
|
224 |
|
225 TPckgBuf<TBool> showNoteModePkg = iSession.ShowNoteMode(); |
|
226 TBool showNoteMode = showNoteModePkg(); |
|
227 |
|
228 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::ShowNoteMode: = %d"), showNoteMode); |
|
229 return showNoteMode; |
|
230 } |
|
231 |
|
232 |
|
233 // --------------------------------------------------------- |
|
234 // CTelephonyAudioRoutingProxy::SetShowNote |
|
235 // |
|
236 // (other items were commented in a header). |
|
237 // --------------------------------------------------------- |
|
238 // |
|
239 |
|
240 TInt CTelephonyAudioRoutingProxy::SetShowNote( TBool aMode ) |
|
241 { |
|
242 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::SetShowNote"),this); |
|
243 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::SetShowNote With: %d"),aMode); |
|
244 |
|
245 // Note: Will set aMode on a GetShowNote call after SetOutputComplete called |
|
246 iShowNote = aMode; |
|
247 return KErrNone; |
|
248 } |
|
249 // --------------------------------------------------------- |
|
250 // CTelephonyAudioRoutingProxy::GetShowNote |
|
251 // |
|
252 // (other items were commented in a header). |
|
253 // --------------------------------------------------------- |
|
254 // |
|
255 |
|
256 TInt CTelephonyAudioRoutingProxy::GetShowNote( TBool& aMode ) |
|
257 { |
|
258 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy[%x]::GetShowNote"),this); |
|
259 |
|
260 // Check with session if Ok to retrieve iShowNoteMode from server: |
|
261 TBool okToGetShowNoteMode = iSession.OkToGetShowNoteMode(); |
|
262 |
|
263 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t GetShowNote: Session: Ok to get show note = %d"),okToGetShowNoteMode); |
|
264 |
|
265 if (okToGetShowNoteMode) |
|
266 { |
|
267 aMode = ShowNoteMode(); |
|
268 } |
|
269 else |
|
270 { |
|
271 aMode = EFalse; |
|
272 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::GetShowNote: (Not OK to Get Value from Server) Returning ShowNoteMode = %d"), aMode); |
|
273 } |
|
274 |
|
275 // reset session's iOkToGetShowNoteMode flag once it has been retrieved |
|
276 iSession.ResetShowNoteMode(); |
|
277 |
|
278 TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingProxy::GetShowNote: Returning ShowNoteMode = %d"), aMode); |
|
279 |
|
280 return KErrNone; |
|
281 } |
|
282 // End of File |