0
|
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: This class is the main interface to the TelephonyAudioRoutingServer.
|
|
15 |
* It implements the client-side session.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include <e32math.h>
|
|
22 |
#include <s32mem.h>
|
|
23 |
#include "TelephonyAudioRoutingClientServer.h"
|
|
24 |
#include "TelephonyAudioRoutingSession.h"
|
|
25 |
#include "TelephonyAudioRoutingRequest.h"
|
|
26 |
#include "TelephonyAudioRoutingPolicyRequest.h"
|
|
27 |
|
|
28 |
const TInt KReqSetOutput = 0;
|
|
29 |
const TInt KReqNotifyIfOutputChanged = 1;
|
|
30 |
const TInt KReqNotifyIfAvailOutputsChanged = 2;
|
|
31 |
const TInt KReqMaxSize = 3;
|
|
32 |
|
|
33 |
// -----------------------------------------------------------------------------
|
|
34 |
// RTelephonyAudioRoutingSession::RTelephonyAudioRoutingSession
|
|
35 |
// C++ default constructor can NOT contain any code, that
|
|
36 |
// might leave.
|
|
37 |
// -----------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
EXPORT_C RTelephonyAudioRoutingSession::RTelephonyAudioRoutingSession()
|
|
40 |
: RSessionBase(), iConnected(EFalse)
|
|
41 |
{
|
|
42 |
// No implementation required
|
|
43 |
|
|
44 |
}
|
|
45 |
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
// RTelephonyAudioRoutingSession::ConnectL
|
|
48 |
// Connects a client to the server
|
|
49 |
// (other items were commented in a header).
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
EXPORT_C TInt RTelephonyAudioRoutingSession::ConnectL(
|
|
53 |
CTelephonyAudioRouting& aAudioRouting,
|
|
54 |
MTelephonyAudioRoutingObserver& aObserver)
|
|
55 |
{
|
|
56 |
|
|
57 |
TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t TelephonyAudioRoutingSession::ConnectL "));
|
|
58 |
|
|
59 |
TInt retry=2;
|
|
60 |
TInt err = KErrGeneral;
|
|
61 |
|
|
62 |
|
|
63 |
for (;;)
|
|
64 |
{
|
|
65 |
err=CreateSession(KTelAudRtngServName,TVersion(0,0,0));
|
|
66 |
if (err!=KErrNotFound && err!=KErrServerTerminated && err!=KErrPermissionDenied)
|
|
67 |
break;
|
|
68 |
|
|
69 |
if (--retry==0)
|
|
70 |
break;
|
|
71 |
}
|
|
72 |
|
|
73 |
if ( err == KErrNone )
|
|
74 |
{
|
|
75 |
// Create active object receive handlers and add it to scheduler
|
|
76 |
TRAP(err, StartRequestHandlersL(aAudioRouting, aObserver));
|
|
77 |
if ( err == KErrNone )
|
|
78 |
{
|
|
79 |
iConnected = ETrue;
|
|
80 |
}
|
|
81 |
|
|
82 |
SendReceive(ETelAudRtngServInitialize, TIpcArgs());
|
|
83 |
|
|
84 |
}
|
|
85 |
|
|
86 |
return err;
|
|
87 |
|
|
88 |
}
|
|
89 |
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
// RTelephonyAudioRoutingSession::Close
|
|
92 |
// Closes connection to the server.
|
|
93 |
// (other items were commented in a header).
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
EXPORT_C void RTelephonyAudioRoutingSession::Close()
|
|
97 |
{
|
|
98 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::Close "),this);
|
|
99 |
if ( iConnected )
|
|
100 |
{
|
|
101 |
|
|
102 |
for (TInt i = 0; i < KReqMaxSize; i++)
|
|
103 |
{
|
|
104 |
delete iRequests[i];
|
|
105 |
}
|
|
106 |
iRequests.Close();
|
|
107 |
iAvailableOutputs.Close();
|
|
108 |
RSessionBase::Close();
|
|
109 |
iConnected = EFalse;
|
|
110 |
|
|
111 |
}
|
|
112 |
|
|
113 |
}
|
|
114 |
|
|
115 |
// -----------------------------------------------------------------------------
|
|
116 |
// RTelephonyAudioRoutingSession::Version
|
|
117 |
// Gets the client side version number.
|
|
118 |
// (other items were commented in a header).
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
EXPORT_C TVersion RTelephonyAudioRoutingSession::Version() const
|
|
122 |
{
|
|
123 |
return(TVersion(0,0,0));
|
|
124 |
}
|
|
125 |
|
|
126 |
// -----------------------------------------------------------------------------
|
|
127 |
// RTelephonyAudioRoutingSession::GetDefaultValues
|
|
128 |
// Gets default values for current audio output, previous audio output, and
|
|
129 |
// show note mode from the server.
|
|
130 |
// (other items were commented in a header).
|
|
131 |
// -----------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
EXPORT_C void RTelephonyAudioRoutingSession::GetDefaultValuesL()
|
|
134 |
{
|
|
135 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::GetDefaultValuesL "),this);
|
|
136 |
|
|
137 |
User::LeaveIfError( SendReceive(ETelAudRtngServGetDefaultValues, TIpcArgs(&iDefaultValuePkg)) );
|
|
138 |
|
|
139 |
// Set session attributes with values retrieved from Server:
|
|
140 |
TTelephonyAudioRoutingDefaultParams defParams = iDefaultValuePkg();
|
|
141 |
|
|
142 |
CTelephonyAudioRouting::TAudioOutput currentAudioOutput = defParams.iCurrentAudio;
|
|
143 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t GetDefaultValuesL: current audio output = %d "), currentAudioOutput);
|
|
144 |
iCurrentAudioOutputPkg() = currentAudioOutput;
|
|
145 |
|
|
146 |
CTelephonyAudioRouting::TAudioOutput previousAudioOutput = defParams.iPreviousAudio;
|
|
147 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t GetDefaultValuesL: Previous audio output = %d "), previousAudioOutput);
|
|
148 |
iPreviousAudioOutputPkg() = previousAudioOutput;
|
|
149 |
|
|
150 |
TBool showNoteMode = defParams.iShowNoteMode;
|
|
151 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t GetDefaultValuesL: showNoteMode = %d "), showNoteMode);
|
|
152 |
iShowNoteModePkg() = showNoteMode;
|
|
153 |
|
|
154 |
}
|
|
155 |
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
// RTelephonyAudioRoutingSession::SetOutput
|
|
158 |
// Send a SetOutput request to server.
|
|
159 |
// (other items were commented in a header).
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
EXPORT_C void RTelephonyAudioRoutingSession::SetOutput(
|
|
163 |
CTelephonyAudioRouting::TAudioOutput aOutput, TBool aShowNote)
|
|
164 |
{
|
|
165 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::SetOutput "),this);
|
|
166 |
|
|
167 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession::SetOutput: ShowNote = %d "), aShowNote);
|
|
168 |
|
|
169 |
iRequests[KReqSetOutput]->Cancel();
|
|
170 |
|
|
171 |
iCurrentAudioOutputPkg() = aOutput;
|
|
172 |
iPreviousAudioOutputPkg() = CTelephonyAudioRouting::ENone;
|
|
173 |
iErrPkg() = KErrNone;
|
|
174 |
iShowNoteModePkg() = aShowNote;
|
|
175 |
|
|
176 |
iRequests[KReqSetOutput]->SetActive();
|
|
177 |
SendReceive(ETelAudRtngServDoSetOutput, TIpcArgs(&iCurrentAudioOutputPkg, &iPreviousAudioOutputPkg, &iErrPkg, &iShowNoteModePkg), iRequests[KReqSetOutput]->iStatus);
|
|
178 |
|
|
179 |
}
|
|
180 |
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
// RTelephonyAudioRoutingSession::GetAvailableOutputsL
|
|
183 |
// Get the available audio outputs from the server.
|
|
184 |
// (other items were commented in a header).
|
|
185 |
// -----------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
EXPORT_C void RTelephonyAudioRoutingSession::GetAvailableOutputsL()
|
|
188 |
{
|
|
189 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::GetAvailableOutputsL"),this);
|
|
190 |
iAvailableOutputs.Reset();
|
|
191 |
|
|
192 |
TPckgBuf<TInt> numOfOutputs;
|
|
193 |
User::LeaveIfError(SendReceive(ETelAudRtngServGetNoOutputs, TIpcArgs(&numOfOutputs)));
|
|
194 |
HBufC8* buf = HBufC8::NewLC(numOfOutputs()*sizeof(CTelephonyAudioRouting::TAudioOutput));
|
|
195 |
TPtr8 ptr = buf->Des();
|
|
196 |
|
|
197 |
User::LeaveIfError(SendReceive(ETelAudRtngServGetAvailableOutputs, TIpcArgs(&ptr)));
|
|
198 |
RDesReadStream stream(ptr);
|
|
199 |
CleanupClosePushL(stream);
|
|
200 |
|
|
201 |
for (TInt i=0; i<numOfOutputs(); i++)
|
|
202 |
{
|
|
203 |
TInt err = iAvailableOutputs.Append((CTelephonyAudioRouting::TAudioOutput)stream.ReadInt32L());
|
|
204 |
if (err)
|
|
205 |
{
|
|
206 |
iAvailableOutputs.Reset();
|
|
207 |
User::Leave(err);
|
|
208 |
}
|
|
209 |
}
|
|
210 |
|
|
211 |
CleanupStack::PopAndDestroy(2, buf);//stream, buf
|
|
212 |
|
|
213 |
}
|
|
214 |
|
|
215 |
// -----------------------------------------------------------------------------
|
|
216 |
// RTelephonyAudioRoutingSession::NotifyIfOutputChanged
|
|
217 |
// Send a request to server to receive notification whenever current audio output changes.
|
|
218 |
// (other items were commented in a header).
|
|
219 |
// -----------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
EXPORT_C void RTelephonyAudioRoutingSession::NotifyIfOutputChanged()
|
|
222 |
{
|
|
223 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::NotifyIfOutputChanged"),this);
|
|
224 |
|
|
225 |
iRequests[KReqNotifyIfOutputChanged]->Cancel();
|
|
226 |
|
|
227 |
SendReceive(ETelAudRtngServNotifyIfOutputChanged, TIpcArgs(&iCurrentAudioOutputPkg, &iPreviousAudioOutputPkg, &iErrPkg, &iShowNoteModePkg), iRequests[KReqNotifyIfOutputChanged]->iStatus);
|
|
228 |
iRequests[KReqNotifyIfOutputChanged]->SetActive();
|
|
229 |
|
|
230 |
}
|
|
231 |
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
// RTelephonyAudioRoutingSession::NotifyIfAvailableOutputsChanged
|
|
234 |
// Send a request to server to receive notification whenever available audio output changes.
|
|
235 |
// (other items were commented in a header).
|
|
236 |
// -----------------------------------------------------------------------------
|
|
237 |
//
|
|
238 |
EXPORT_C void RTelephonyAudioRoutingSession::NotifyIfAvailableOutputsChanged()
|
|
239 |
{
|
|
240 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::NotifyIfAvailbleOutputsChanged"),this);
|
|
241 |
iRequests[KReqNotifyIfAvailOutputsChanged]->Cancel();
|
|
242 |
|
|
243 |
SendReceive(ETelAudRtngServNotifyIfAvailOutputsChanged, TIpcArgs(&iCurrentAudioOutputPkg), iRequests[KReqNotifyIfAvailOutputsChanged]->iStatus);
|
|
244 |
iRequests[KReqNotifyIfAvailOutputsChanged]->SetActive();
|
|
245 |
|
|
246 |
}
|
|
247 |
|
|
248 |
// -----------------------------------------------------------------------------
|
|
249 |
// RTelephonyAudioRoutingSession::CancelRequest
|
|
250 |
// Cancel a previously sent request.
|
|
251 |
// aRequestOpcode = index into array as to which request object to cancel.
|
|
252 |
// (other items were commented in a header).
|
|
253 |
// -----------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
EXPORT_C void RTelephonyAudioRoutingSession::CancelRequest(TTelAudRtngServRqst aRequestOpcode)
|
|
256 |
{
|
|
257 |
TPckgBuf<TInt> request;
|
|
258 |
request() = aRequestOpcode;
|
|
259 |
|
|
260 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t CTelephonyAudioRoutingSession::CancelRequest Number: %d"), aRequestOpcode);
|
|
261 |
SendReceive(ETelAudRtngServCancelRequest, TIpcArgs(&request));
|
|
262 |
|
|
263 |
}
|
|
264 |
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
// RTelephonyAudioRoutingSession::CurrentAudioOutputPkg
|
|
267 |
// Accessor method returns iCurrentAudioOutputPkg to caller.
|
|
268 |
// (other items were commented in a header).
|
|
269 |
// -----------------------------------------------------------------------------
|
|
270 |
//
|
|
271 |
EXPORT_C TPckgBuf<CTelephonyAudioRouting::TAudioOutput>& RTelephonyAudioRoutingSession::CurrentAudioOutputPkg()
|
|
272 |
{
|
|
273 |
return iCurrentAudioOutputPkg;
|
|
274 |
}
|
|
275 |
|
|
276 |
// -----------------------------------------------------------------------------
|
|
277 |
// RTelephonyAudioRoutingSession::PreviousAudioOutputPkg
|
|
278 |
// Accessor method returns iPreviousAudioOutputPkg to caller.
|
|
279 |
// (other items were commented in a header).
|
|
280 |
// -----------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
EXPORT_C TPckgBuf<CTelephonyAudioRouting::TAudioOutput>& RTelephonyAudioRoutingSession::PreviousAudioOutputPkg()
|
|
283 |
{
|
|
284 |
return iPreviousAudioOutputPkg;
|
|
285 |
}
|
|
286 |
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
// RTelephonyAudioRoutingSession::ErrPkg
|
|
289 |
// Accessor method returns iErrPkg to caller.
|
|
290 |
// (other items were commented in a header).
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
//
|
|
293 |
EXPORT_C TPckgBuf<TInt>& RTelephonyAudioRoutingSession::ErrPkg()
|
|
294 |
{
|
|
295 |
return iErrPkg;
|
|
296 |
}
|
|
297 |
|
|
298 |
// -----------------------------------------------------------------------------
|
|
299 |
// RTelephonyAudioRoutingSession::AvailableOutputs
|
|
300 |
// Accessor method returns iAvailableOutputs to caller.
|
|
301 |
// (other items were commented in a header).
|
|
302 |
// -----------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
EXPORT_C RArray<CTelephonyAudioRouting::TAudioOutput>& RTelephonyAudioRoutingSession::AvailableOutputs()
|
|
305 |
{
|
|
306 |
return iAvailableOutputs;
|
|
307 |
}
|
|
308 |
|
|
309 |
// -----------------------------------------------------------------------------
|
|
310 |
// RTelephonyAudioRoutingSession::StartRequestHandlersL
|
|
311 |
// Start asynchronous request handlers.
|
|
312 |
// (other items were commented in a header).
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
void RTelephonyAudioRoutingSession::StartRequestHandlersL(
|
|
316 |
CTelephonyAudioRouting& aAudioRouting,
|
|
317 |
MTelephonyAudioRoutingObserver& aObserver )
|
|
318 |
{
|
|
319 |
|
|
320 |
CTelephonyAudioRoutingRequest* req = NULL;
|
|
321 |
|
|
322 |
req = CTelephonyAudioRoutingRequest::NewL(*this, aObserver, aAudioRouting, ETelAudRtngServDoSetOutput);
|
|
323 |
User::LeaveIfError( iRequests.Append(req) );
|
|
324 |
|
|
325 |
req = CTelephonyAudioRoutingRequest::NewL(*this, aObserver, aAudioRouting, ETelAudRtngServNotifyIfOutputChanged);
|
|
326 |
User::LeaveIfError( iRequests.Append(req) );
|
|
327 |
|
|
328 |
req = CTelephonyAudioRoutingRequest::NewL(*this, aObserver, aAudioRouting, ETelAudRtngServNotifyIfAvailOutputsChanged);
|
|
329 |
User::LeaveIfError( iRequests.Append(req) );
|
|
330 |
|
|
331 |
}
|
|
332 |
|
|
333 |
// -----------------------------------------------------------------------------
|
|
334 |
// RTelephonyAudioRoutingSession::SetShowNoteMode
|
|
335 |
// Sets session flag iOkToGetShowNoteMode to indicate that it is OK to retrieve value of
|
|
336 |
// iShowNoteMode from the server.
|
|
337 |
// (other items were commented in a header).
|
|
338 |
// -----------------------------------------------------------------------------
|
|
339 |
//
|
|
340 |
EXPORT_C void RTelephonyAudioRoutingSession::SetShowNoteMode()
|
|
341 |
{
|
|
342 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::SetShowNoteMode"),this);
|
|
343 |
iOkToGetShowNoteMode = ETrue;
|
|
344 |
}
|
|
345 |
|
|
346 |
// -----------------------------------------------------------------------------
|
|
347 |
// RTelephonyAudioRoutingSession::ShowNoteMode
|
|
348 |
// Provide caller with value of iShowNoteModePkg from server
|
|
349 |
// (other items were commented in a header).
|
|
350 |
// -----------------------------------------------------------------------------
|
|
351 |
//
|
|
352 |
EXPORT_C TPckgBuf<TBool>& RTelephonyAudioRoutingSession::ShowNoteMode()
|
|
353 |
{
|
|
354 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::ShowNoteMode"),this);
|
|
355 |
|
|
356 |
return iShowNoteModePkg;
|
|
357 |
}
|
|
358 |
|
|
359 |
|
|
360 |
// -----------------------------------------------------------------------------
|
|
361 |
// RTelephonyAudioRoutingSession::ResetShowNoteMode
|
|
362 |
// Resets the session flag iOkToGetShowNoteMode to indicate it's not ok to retrieve
|
|
363 |
// value of iSetShowNoteMode from server. (Client can only retrieve it once after a
|
|
364 |
// SetOutputComplete call). (But it can be set internally from an OutputChanged call).
|
|
365 |
// (other items were commented in a header).
|
|
366 |
// -----------------------------------------------------------------------------
|
|
367 |
//
|
|
368 |
EXPORT_C void RTelephonyAudioRoutingSession::ResetShowNoteMode()
|
|
369 |
{
|
|
370 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingSession[%x]::ResetShowNoteMode"),this);
|
|
371 |
iOkToGetShowNoteMode = EFalse;
|
|
372 |
}
|
|
373 |
// -----------------------------------------------------------------------------
|
|
374 |
// RTelephonyAudioRoutingSession::OkToGetShowNoteMode
|
|
375 |
// Provide caller with value of iOkToGetShowNoteMode
|
|
376 |
// (other items were commented in a header).
|
|
377 |
// -----------------------------------------------------------------------------
|
|
378 |
//
|
|
379 |
EXPORT_C TBool RTelephonyAudioRoutingSession::OkToGetShowNoteMode()
|
|
380 |
{
|
|
381 |
return iOkToGetShowNoteMode;
|
|
382 |
}
|
|
383 |
// End of File
|