|
1 /* |
|
2 * Copyright (c) 2002-2004 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 RadioServer. It implements |
|
15 * the client-side session. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32math.h> |
|
23 #include "RadioSession.h" |
|
24 #include "RadioClientServer.h" |
|
25 #include "RadioRequest.h" |
|
26 #include "RadioEventHandler.h" |
|
27 #include "RadioDebug.h" |
|
28 |
|
29 // CONSTANTS |
|
30 // Index to list of asynchronous requests that generates response to MRadioObserver. |
|
31 const TInt KReqInternal = 0; |
|
32 const TInt KReqRequestTunerControl = 1; |
|
33 const TInt KReqSetFrequencyRange = 2; |
|
34 const TInt KReqSetFrequency = 3; |
|
35 const TInt KReqStationSeek = 4; |
|
36 const TInt KReqPlay = 5; |
|
37 const TInt KReqStationSeekByPTY = 6; |
|
38 const TInt KReqStationSeekByTA = 7; |
|
39 const TInt KReqStationSeekByTP = 8; |
|
40 |
|
41 // Max number of retries to start the server |
|
42 const TInt KRadioStartRetry = 2; |
|
43 // Minimum of one for each asynchronous message + one to allow cancel |
|
44 const TInt KRadioMessageSlots = 11; |
|
45 |
|
46 // ============================= LOCAL FUNCTIONS =============================== |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // StartServer |
|
50 // Static function to start the server process thread. |
|
51 // Start the server process/thread which lives in an EPOCEXE object. |
|
52 // Returns: TInt: KErrNone (0) if no error |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 static TInt StartServer() |
|
56 { |
|
57 RADIO_RDEBUG(_L("[RADIO-SESS] StartServer()")); |
|
58 |
|
59 const TUidType serverUid(KNullUid, KNullUid, KRadioServerUid3); |
|
60 |
|
61 // We just create a new server process. Simultaneous launching of two such |
|
62 // processes should be detected when the second one attempts to create |
|
63 // the server object, failing with KErrAlreadyExists. |
|
64 RProcess server; |
|
65 TInt r = server.Create(KRadioServerImg, KNullDesC, serverUid); |
|
66 |
|
67 if ( r != KErrNone ) |
|
68 { |
|
69 RADIO_RDEBUG_INT(_L("[RADIO-SESS] server.Create() failed [%d]"), r); |
|
70 return r; |
|
71 } |
|
72 TRequestStatus stat; |
|
73 server.Rendezvous(stat); |
|
74 if ( stat != KRequestPending ) |
|
75 { |
|
76 server.Kill(0); // abort startup |
|
77 } |
|
78 else |
|
79 { |
|
80 server.Resume(); // logon OK - start the server |
|
81 } |
|
82 User::WaitForRequest(stat); // wait for start or death |
|
83 // we can't use the 'exit reason' if the server panicked as this |
|
84 // is the panic 'reason' and may be '0' which cannot be distinguished |
|
85 // from KErrNone |
|
86 r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
|
87 server.Close(); |
|
88 return r; |
|
89 } |
|
90 |
|
91 // ============================ MEMBER FUNCTIONS =============================== |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // RRadioSession::RRadioSession |
|
95 // C++ default constructor can NOT contain any code, that |
|
96 // might leave. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C RRadioSession::RRadioSession() |
|
100 : iConnected(EFalse), |
|
101 iDestinationPckg(TMMFMessageDestination(KRadioServerInterfaceUid, KRadioServerObjectHandle)), |
|
102 iObserver(NULL), |
|
103 iPrimaryClient(EFalse), |
|
104 iRdsNotify(EFalse) |
|
105 { |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // RRadioSession::Connect |
|
110 // Create a client-side session. Start the server if not started already. |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C TInt RRadioSession::Connect( |
|
114 MRadioObserver& aObserver, |
|
115 TBool aPrimaryClient ) |
|
116 { |
|
117 RADIO_RDEBUG(_L("[RADIO-SESS] Connect() entry")); |
|
118 // check if already connected |
|
119 if ( iConnected ) |
|
120 { |
|
121 RADIO_RDEBUG(_L("[RADIO-SESS] Connect(): already connected")); |
|
122 return KErrAlreadyExists; |
|
123 } |
|
124 |
|
125 TInt retry = KRadioStartRetry; |
|
126 TInt err = KErrGeneral; |
|
127 TInt numMessageSlots = KRadioMessageSlots; |
|
128 for (;;) |
|
129 { |
|
130 // Try to create a new session with the server |
|
131 err = CreateSession(KRadioServerName, Version(), numMessageSlots); |
|
132 if ( (err != KErrNotFound) && (err != KErrServerTerminated) ) |
|
133 { |
|
134 break; // Connected to existing server - ok |
|
135 } |
|
136 if ( --retry == 0 ) |
|
137 { |
|
138 break; // Failed. |
|
139 } |
|
140 // Server not running, try to start it. |
|
141 err = StartServer(); |
|
142 if ( (err != KErrNone) && (err != KErrAlreadyExists) ) |
|
143 { |
|
144 break; // Server not launched - propagate error |
|
145 } |
|
146 } |
|
147 |
|
148 if ( err != KErrNone ) |
|
149 { |
|
150 RADIO_RDEBUG_INT(_L("[RADIO-SESS] Connect(): Unable to start server [%d]"), err); |
|
151 return err; |
|
152 } |
|
153 |
|
154 // Create active object request handlers and add it to scheduler |
|
155 TRAP(err, StartRequestHandlersL(aObserver)); |
|
156 if ( err == KErrNone ) |
|
157 { |
|
158 // Create active object event handlers and add it to scheduler |
|
159 TRAP(err, StartEventHandlersL(aObserver)); |
|
160 if ( err == KErrNone ) |
|
161 { |
|
162 iConnected = ETrue; |
|
163 iObserver = &aObserver; |
|
164 if ( aPrimaryClient ) |
|
165 { |
|
166 iPrimaryClient = ETrue; |
|
167 err = SendReceive(ERadioServAddPrimaryClient, TIpcArgs(&iDestinationPckg)); |
|
168 } |
|
169 } |
|
170 else |
|
171 { |
|
172 iRequests.ResetAndDestroy(); |
|
173 iEventHandlers.ResetAndDestroy(); |
|
174 } |
|
175 } |
|
176 else |
|
177 { |
|
178 iRequests.ResetAndDestroy(); |
|
179 } |
|
180 |
|
181 RADIO_RDEBUG_INT(_L("[RADIO-SESS] Connect() exit err=[%d]"), err); |
|
182 return err; |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // RRadioSession::Version |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 EXPORT_C TVersion RRadioSession::Version() const |
|
190 { |
|
191 return(TVersion(KRadioServerVersionMajor, KRadioServerVersionMinor, KRadioServerVersionBuild)); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // RRadioSession::Close |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 EXPORT_C void RRadioSession::Close() |
|
199 { |
|
200 RADIO_RDEBUG(_L("[RADIO-SESS] Close() entry")); |
|
201 iRequests.ResetAndDestroy(); |
|
202 iRequests.Close(); |
|
203 |
|
204 iEventHandlers.ResetAndDestroy(); |
|
205 iEventHandlers.Close(); |
|
206 |
|
207 iRdsEventHandlers.ResetAndDestroy(); |
|
208 iRdsEventHandlers.Close(); |
|
209 |
|
210 if ( iConnected ) |
|
211 { |
|
212 iConnected = EFalse; |
|
213 if ( iPrimaryClient ) |
|
214 { |
|
215 SendReceive(ERadioServRemovePrimaryClient, TIpcArgs(&iDestinationPckg)); |
|
216 } |
|
217 RSessionBase::Close(); |
|
218 } |
|
219 RADIO_RDEBUG(_L("[RADIO-SESS] Close() exit")); |
|
220 } |
|
221 |
|
222 //********** TunerUtility control begins |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // RRadioSession::RequestTunerControl |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C void RRadioSession::RequestTunerControl( |
|
229 TRsTuner aTuner ) |
|
230 { |
|
231 RADIO_RDEBUG(_L("[RADIO-SESS] RequestTunerControl()")); |
|
232 if ( iConnected ) |
|
233 { |
|
234 if ( iRequests[KReqRequestTunerControl]->IsActive() ) |
|
235 { |
|
236 iRequests[KReqRequestTunerControl]->Cancel(); |
|
237 } |
|
238 SendReceive(ERadioServRequestTunerControl, |
|
239 TIpcArgs(&iDestinationPckg, aTuner), |
|
240 iRequests[KReqRequestTunerControl]->iStatus); |
|
241 iRequests[KReqRequestTunerControl]->SetActive(); |
|
242 } |
|
243 else |
|
244 { |
|
245 iRequests[KReqInternal]->CompleteRequest(ERadioServRequestTunerControl, KErrDisconnected); |
|
246 } |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // RRadioSession::GetTunerCapabilities |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 EXPORT_C TInt RRadioSession::GetTunerCapabilities( |
|
254 TRsTunerCapabilities& aCaps ) const |
|
255 { |
|
256 RADIO_RDEBUG(_L("[RADIO-SESS] GetTunerCapabilities()")); |
|
257 if ( iConnected ) |
|
258 { |
|
259 TPckg<TRsTunerCapabilities> caps(aCaps); |
|
260 return SendReceive(ERadioServGetTunerCapabilities, |
|
261 TIpcArgs(&iDestinationPckg, &caps)); |
|
262 } |
|
263 else |
|
264 { |
|
265 return KErrDisconnected; |
|
266 } |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // RRadioSession::EnableTunerInOfflineMode |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C TInt RRadioSession::EnableTunerInOfflineMode( |
|
274 TBool aEnable ) |
|
275 { |
|
276 RADIO_RDEBUG_INT(_L("[RADIO-SESS] EnableTunerInOfflineMode() [%d]"), aEnable); |
|
277 if ( iConnected ) |
|
278 { |
|
279 return SendReceive(ERadioServEnableTunerInOfflineMode, |
|
280 TIpcArgs(&iDestinationPckg, aEnable)); |
|
281 } |
|
282 else |
|
283 { |
|
284 return KErrDisconnected; |
|
285 } |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // RRadioSession::SetFrequencyRange |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 EXPORT_C void RRadioSession::SetFrequencyRange( |
|
293 TRsFrequencyRange aRange ) |
|
294 { |
|
295 RADIO_RDEBUG_INT(_L("[RADIO-SESS] SetFrequencyRange() [%d]"), aRange); |
|
296 if ( iConnected ) |
|
297 { |
|
298 if ( iRequests[KReqSetFrequencyRange]->IsActive() ) |
|
299 { |
|
300 iRequests[KReqSetFrequencyRange]->Cancel(); |
|
301 } |
|
302 SendReceive(ERadioServSetFrequencyRange, |
|
303 TIpcArgs(&iDestinationPckg, aRange), |
|
304 iRequests[KReqSetFrequencyRange]->iStatus); |
|
305 iRequests[KReqSetFrequencyRange]->SetActive(); |
|
306 } |
|
307 else |
|
308 { |
|
309 iRequests[KReqInternal]->CompleteRequest(ERadioServSetFrequencyRange, KErrDisconnected); |
|
310 } |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // RRadioSession::CancelSetFrequencyRange |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 EXPORT_C void RRadioSession::CancelSetFrequencyRange() |
|
318 { |
|
319 RADIO_RDEBUG(_L("[RADIO-SESS] CancelSetFrequencyRange()")); |
|
320 if ( iConnected && iRequests[KReqSetFrequencyRange]->IsActive() ) |
|
321 { |
|
322 iRequests[KReqSetFrequencyRange]->Cancel(); |
|
323 } |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // RRadioSession::GetFrequencyRange |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 EXPORT_C TInt RRadioSession::GetFrequencyRange( |
|
331 TRsFrequencyRange& aRange, |
|
332 TInt& aMinFreq, |
|
333 TInt& aMaxFreq) const |
|
334 { |
|
335 RADIO_RDEBUG(_L("[RADIO-SESS] GetFrequencyRange()")); |
|
336 if ( iConnected ) |
|
337 { |
|
338 TPckg<TRsFrequencyRange> range(aRange); |
|
339 TPckg<TInt> min(aMinFreq); |
|
340 TPckg<TInt> max(aMaxFreq); |
|
341 return SendReceive(ERadioServGetFrequencyRange, |
|
342 TIpcArgs(&iDestinationPckg, &range, &min, &max)); |
|
343 } |
|
344 else |
|
345 { |
|
346 return KErrDisconnected; |
|
347 } |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // RRadioSession::SetFrequency |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 EXPORT_C void RRadioSession::SetFrequency( |
|
355 TInt aFrequency ) |
|
356 { |
|
357 RADIO_RDEBUG_INT(_L("[RADIO-SESS] SetFrequency() [%d]"), aFrequency); |
|
358 if ( iConnected ) |
|
359 { |
|
360 if ( iRequests[KReqSetFrequency]->IsActive() ) |
|
361 { |
|
362 iRequests[KReqSetFrequency]->Cancel(); |
|
363 } |
|
364 SendReceive(ERadioServSetFrequency, |
|
365 TIpcArgs(&iDestinationPckg, aFrequency), |
|
366 iRequests[KReqSetFrequency]->iStatus); |
|
367 iRequests[KReqSetFrequency]->SetActive(); |
|
368 } |
|
369 else |
|
370 { |
|
371 iRequests[KReqInternal]->CompleteRequest(ERadioServSetFrequency, KErrDisconnected); |
|
372 } |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // RRadioSession::CancelSetFrequency |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 EXPORT_C void RRadioSession::CancelSetFrequency() |
|
380 { |
|
381 RADIO_RDEBUG(_L("[RADIO-SESS] CancelSetFrequency()")); |
|
382 if ( iConnected && iRequests[KReqSetFrequency]->IsActive() ) |
|
383 { |
|
384 iRequests[KReqSetFrequency]->Cancel(); |
|
385 } |
|
386 } |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // RRadioSession::GetFrequency |
|
390 // ----------------------------------------------------------------------------- |
|
391 // |
|
392 EXPORT_C TInt RRadioSession::GetFrequency( |
|
393 TInt& aFrequency ) const |
|
394 { |
|
395 RADIO_RDEBUG(_L("[RADIO-SESS] GetFrequency()")); |
|
396 if ( iConnected ) |
|
397 { |
|
398 TPckg<TInt> frequency(aFrequency); |
|
399 return SendReceive(ERadioServGetFrequency, |
|
400 TIpcArgs(&iDestinationPckg, &frequency)); |
|
401 } |
|
402 else |
|
403 { |
|
404 return KErrDisconnected; |
|
405 } |
|
406 } |
|
407 |
|
408 // ----------------------------------------------------------------------------- |
|
409 // RRadioSession::StationSeek |
|
410 // ----------------------------------------------------------------------------- |
|
411 EXPORT_C void RRadioSession::StationSeek( |
|
412 TBool aUpwards ) |
|
413 { |
|
414 RADIO_RDEBUG_INT(_L("[RADIO-SESS] StationSeek() [%d]"), aUpwards); |
|
415 if ( iConnected ) |
|
416 { |
|
417 if ( iRequests[KReqStationSeek]->IsActive() ) |
|
418 { |
|
419 iRequests[KReqStationSeek]->Cancel(); |
|
420 } |
|
421 SendReceive(ERadioServStationSeek, |
|
422 TIpcArgs(&iDestinationPckg, aUpwards, &(iRequests[KReqStationSeek]->iIntPckg)), |
|
423 iRequests[KReqStationSeek]->iStatus); |
|
424 iRequests[KReqStationSeek]->SetActive(); |
|
425 } |
|
426 else |
|
427 { |
|
428 iRequests[KReqInternal]->CompleteRequest(ERadioServStationSeek, KErrDisconnected); |
|
429 } |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // RRadioSession::CancelStationSeek |
|
434 // ----------------------------------------------------------------------------- |
|
435 EXPORT_C void RRadioSession::CancelStationSeek() |
|
436 { |
|
437 RADIO_RDEBUG(_L("[RADIO-SESS] CancelStationSeek()")); |
|
438 if ( iConnected && iRequests[KReqStationSeek]->IsActive() ) |
|
439 { |
|
440 iRequests[KReqStationSeek]->Cancel(); |
|
441 } |
|
442 } |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // RRadioSession::GetSignalStrength |
|
446 // ----------------------------------------------------------------------------- |
|
447 EXPORT_C TInt RRadioSession::GetSignalStrength( |
|
448 TInt& aSignalStrength ) const |
|
449 { |
|
450 RADIO_RDEBUG(_L("[RADIO-SESS] GetSignalStrength()")); |
|
451 if ( iConnected ) |
|
452 { |
|
453 TPckg<TInt> strength(aSignalStrength); |
|
454 return SendReceive(ERadioServGetSignalStrength, |
|
455 TIpcArgs(&iDestinationPckg, &strength)); |
|
456 } |
|
457 else |
|
458 { |
|
459 return KErrDisconnected; |
|
460 } |
|
461 } |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // RRadioSession::GetMaxSignalStrength |
|
465 // ----------------------------------------------------------------------------- |
|
466 EXPORT_C TInt RRadioSession::GetMaxSignalStrength( |
|
467 TInt& aMaxSignalStrength ) const |
|
468 { |
|
469 RADIO_RDEBUG(_L("[RADIO-SESS] GetMaxSignalStrength()")); |
|
470 if ( iConnected ) |
|
471 { |
|
472 TPckg<TInt> maxStrength(aMaxSignalStrength); |
|
473 return SendReceive(ERadioServGetMaxSignalStrength, |
|
474 TIpcArgs(&iDestinationPckg, &maxStrength)); |
|
475 } |
|
476 else |
|
477 { |
|
478 return KErrDisconnected; |
|
479 } |
|
480 } |
|
481 |
|
482 // ----------------------------------------------------------------------------- |
|
483 // RRadioSession::GetStereoMode |
|
484 // ----------------------------------------------------------------------------- |
|
485 EXPORT_C TInt RRadioSession::GetStereoMode( |
|
486 TBool& aStereo ) const |
|
487 { |
|
488 RADIO_RDEBUG(_L("[RADIO-SESS] GetStereoMode()")); |
|
489 if ( iConnected ) |
|
490 { |
|
491 TPckg<TBool> stereo(aStereo); |
|
492 return SendReceive(ERadioServGetStereoMode, |
|
493 TIpcArgs(&iDestinationPckg, &stereo)); |
|
494 } |
|
495 else |
|
496 { |
|
497 return KErrDisconnected; |
|
498 } |
|
499 } |
|
500 |
|
501 // ----------------------------------------------------------------------------- |
|
502 // RRadioSession::ForceMonoReception |
|
503 // ----------------------------------------------------------------------------- |
|
504 EXPORT_C TInt RRadioSession::ForceMonoReception( |
|
505 TBool aForcedMono ) |
|
506 { |
|
507 RADIO_RDEBUG_INT(_L("[RADIO-SESS] ForceMonoReception() [%d]"), aForcedMono); |
|
508 if ( iConnected ) |
|
509 { |
|
510 return SendReceive(ERadioServForceMonoReception, |
|
511 TIpcArgs(&iDestinationPckg, aForcedMono)); |
|
512 } |
|
513 else |
|
514 { |
|
515 return KErrDisconnected; |
|
516 } |
|
517 } |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // RRadioSession::GetForceMonoReception |
|
521 // ----------------------------------------------------------------------------- |
|
522 EXPORT_C TInt RRadioSession::GetForceMonoReception( |
|
523 TBool& aForcedMono ) const |
|
524 { |
|
525 RADIO_RDEBUG(_L("[RADIO-SESS] GetForceMonoReception()")); |
|
526 if ( iConnected ) |
|
527 { |
|
528 TPckg<TBool> mono(aForcedMono); |
|
529 return SendReceive(ERadioServGetForceMonoReception, |
|
530 TIpcArgs(&iDestinationPckg, &mono)); |
|
531 } |
|
532 else |
|
533 { |
|
534 return KErrDisconnected; |
|
535 } |
|
536 } |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // RRadioSession::SetSquelch |
|
540 // ----------------------------------------------------------------------------- |
|
541 EXPORT_C TInt RRadioSession::SetSquelch( |
|
542 TBool aEnabled ) |
|
543 { |
|
544 RADIO_RDEBUG_INT(_L("[RADIO-SESS] SetSquelch() [%d]"), aEnabled); |
|
545 if ( iConnected ) |
|
546 { |
|
547 return SendReceive(ERadioServSetSquelch, |
|
548 TIpcArgs(&iDestinationPckg, aEnabled)); |
|
549 } |
|
550 else |
|
551 { |
|
552 return KErrDisconnected; |
|
553 } |
|
554 } |
|
555 |
|
556 // ----------------------------------------------------------------------------- |
|
557 // RRadioSession::GetSquelch |
|
558 // ----------------------------------------------------------------------------- |
|
559 EXPORT_C TInt RRadioSession::GetSquelch( |
|
560 TBool& aSquelch ) const |
|
561 { |
|
562 RADIO_RDEBUG(_L("[RADIO-SESS] GetSquelch()")); |
|
563 if ( iConnected ) |
|
564 { |
|
565 TPckg<TBool> squelch(aSquelch); |
|
566 return SendReceive(ERadioServGetSquelch, |
|
567 TIpcArgs(&iDestinationPckg, &squelch)); |
|
568 } |
|
569 else |
|
570 { |
|
571 return KErrDisconnected; |
|
572 } |
|
573 } |
|
574 |
|
575 //********** PlayerUtility control begins |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // RRadioSession::PlayerState |
|
579 // ----------------------------------------------------------------------------- |
|
580 EXPORT_C TInt RRadioSession::PlayerState( |
|
581 TRsPlayerState& aState ) const |
|
582 { |
|
583 RADIO_RDEBUG(_L("[RADIO-SESS] GetPlayerState()")); |
|
584 if ( iConnected ) |
|
585 { |
|
586 TPckg<TRsPlayerState> state(aState); |
|
587 return SendReceive(ERadioServGetPlayerState, |
|
588 TIpcArgs(&iDestinationPckg, &state)); |
|
589 } |
|
590 else |
|
591 { |
|
592 return KErrDisconnected; |
|
593 } |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // RRadioSession::Play |
|
598 // ----------------------------------------------------------------------------- |
|
599 EXPORT_C void RRadioSession::Play() |
|
600 { |
|
601 RADIO_RDEBUG(_L("[RADIO-SESS] Play()")); |
|
602 if ( iConnected ) |
|
603 { |
|
604 if ( iRequests[KReqPlay]->IsActive() ) |
|
605 { |
|
606 // Already active; ignore. |
|
607 return; |
|
608 } |
|
609 SendReceive(ERadioServPlay, |
|
610 TIpcArgs(&iDestinationPckg), |
|
611 iRequests[KReqPlay]->iStatus); |
|
612 iRequests[KReqPlay]->SetActive(); |
|
613 } |
|
614 } |
|
615 |
|
616 // ----------------------------------------------------------------------------- |
|
617 // RRadioSession::Stop |
|
618 // ----------------------------------------------------------------------------- |
|
619 EXPORT_C void RRadioSession::Stop( |
|
620 TBool aIfOnlyPrimaryClient ) |
|
621 { |
|
622 RADIO_RDEBUG_INT(_L("[RADIO-SESS] Stop() [%d]"), aIfOnlyPrimaryClient); |
|
623 if ( iConnected ) |
|
624 { |
|
625 TInt err = Send(ERadioServStop, |
|
626 TIpcArgs(&iDestinationPckg, aIfOnlyPrimaryClient)); |
|
627 if (err != KErrNone) |
|
628 { |
|
629 RADIO_RDEBUG_INT(_L("[RADIO-SESS] Stop() - err[%d]"), err); |
|
630 } |
|
631 } |
|
632 } |
|
633 |
|
634 // ----------------------------------------------------------------------------- |
|
635 // RRadioSession::GetMaxVolume |
|
636 // ----------------------------------------------------------------------------- |
|
637 EXPORT_C TInt RRadioSession::GetMaxVolume( |
|
638 TInt& aMaxVolume ) const |
|
639 { |
|
640 RADIO_RDEBUG(_L("[RADIO-SESS] GetMaxVolume()")); |
|
641 if ( iConnected ) |
|
642 { |
|
643 TPckg<TInt> maxVolume(aMaxVolume); |
|
644 return SendReceive(ERadioServGetMaxVolume, |
|
645 TIpcArgs(&iDestinationPckg, &maxVolume)); |
|
646 } |
|
647 else |
|
648 { |
|
649 return KErrDisconnected; |
|
650 } |
|
651 } |
|
652 |
|
653 // ----------------------------------------------------------------------------- |
|
654 // RRadioSession::SetVolume |
|
655 // ----------------------------------------------------------------------------- |
|
656 EXPORT_C TInt RRadioSession::SetVolume( |
|
657 TInt aVolume ) |
|
658 { |
|
659 RADIO_RDEBUG_INT(_L("[RADIO-SESS] SetVolume() [%d]"), aVolume); |
|
660 if ( iConnected ) |
|
661 { |
|
662 return SendReceive(ERadioServSetVolume, |
|
663 TIpcArgs(&iDestinationPckg, aVolume)); |
|
664 } |
|
665 else |
|
666 { |
|
667 return KErrDisconnected; |
|
668 } |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // RRadioSession::GetVolume |
|
673 // ----------------------------------------------------------------------------- |
|
674 EXPORT_C TInt RRadioSession::GetVolume( |
|
675 TInt& aVolume ) const |
|
676 { |
|
677 RADIO_RDEBUG(_L("[RADIO-SESS] GetVolume()")); |
|
678 if ( iConnected ) |
|
679 { |
|
680 TPckg<TInt> volume(aVolume); |
|
681 return SendReceive(ERadioServGetVolume, |
|
682 TIpcArgs(&iDestinationPckg, &volume)); |
|
683 } |
|
684 else |
|
685 { |
|
686 return KErrDisconnected; |
|
687 } |
|
688 } |
|
689 |
|
690 // ----------------------------------------------------------------------------- |
|
691 // RRadioSession::SetVolumeRamp |
|
692 // ----------------------------------------------------------------------------- |
|
693 EXPORT_C TInt RRadioSession::SetVolumeRamp( |
|
694 const TTimeIntervalMicroSeconds& aRampInterval ) |
|
695 { |
|
696 RADIO_RDEBUG(_L("[RADIO-SESS] SetVolumeRamp()")); |
|
697 if ( iConnected ) |
|
698 { |
|
699 TPckgBuf<TTimeIntervalMicroSeconds> interval(aRampInterval); |
|
700 return SendReceive(ERadioServSetVolumeRamp, |
|
701 TIpcArgs(&iDestinationPckg, &interval)); |
|
702 } |
|
703 else |
|
704 { |
|
705 return KErrDisconnected; |
|
706 } |
|
707 } |
|
708 |
|
709 // ----------------------------------------------------------------------------- |
|
710 // RRadioSession::Mute |
|
711 // ----------------------------------------------------------------------------- |
|
712 EXPORT_C TInt RRadioSession::Mute( |
|
713 TBool aMute ) |
|
714 { |
|
715 RADIO_RDEBUG_INT(_L("[RADIO-SESS] Mute() [%d]"), aMute); |
|
716 if ( iConnected ) |
|
717 { |
|
718 return SendReceive(ERadioServSetMute, |
|
719 TIpcArgs(&iDestinationPckg, aMute)); |
|
720 } |
|
721 else |
|
722 { |
|
723 return KErrDisconnected; |
|
724 } |
|
725 } |
|
726 |
|
727 // ----------------------------------------------------------------------------- |
|
728 // RRadioSession::GetMuteStatus |
|
729 // ----------------------------------------------------------------------------- |
|
730 EXPORT_C TInt RRadioSession::GetMuteStatus( |
|
731 TBool& aMute ) const |
|
732 { |
|
733 RADIO_RDEBUG(_L("[RADIO-SESS] Mute()")); |
|
734 if ( iConnected ) |
|
735 { |
|
736 TPckg<TBool> mute(aMute); |
|
737 return SendReceive(ERadioServGetMuteStatus, |
|
738 TIpcArgs(&iDestinationPckg, &mute)); |
|
739 } |
|
740 else |
|
741 { |
|
742 return KErrDisconnected; |
|
743 } |
|
744 } |
|
745 |
|
746 // ----------------------------------------------------------------------------- |
|
747 // RRadioSession::SetBalance |
|
748 // ----------------------------------------------------------------------------- |
|
749 EXPORT_C TInt RRadioSession::SetBalance( |
|
750 TInt aLeftPercentage, |
|
751 TInt aRightPercentage ) |
|
752 { |
|
753 RADIO_RDEBUG_INT2(_L("[RADIO-SESS] SetBalance() left=[%d] right=[%d]"), aLeftPercentage, aRightPercentage); |
|
754 if ( iConnected ) |
|
755 { |
|
756 return SendReceive(ERadioServSetBalance, |
|
757 TIpcArgs(&iDestinationPckg, aLeftPercentage, aRightPercentage)); |
|
758 } |
|
759 else |
|
760 { |
|
761 return KErrDisconnected; |
|
762 } |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // RRadioSession::GetBalance |
|
767 // ----------------------------------------------------------------------------- |
|
768 // |
|
769 EXPORT_C TInt RRadioSession::GetBalance( |
|
770 TInt& aLeftPercentage, |
|
771 TInt& aRightPercentage ) const |
|
772 { |
|
773 RADIO_RDEBUG(_L("[RADIO-SESS] GetBalance()")); |
|
774 if ( iConnected ) |
|
775 { |
|
776 TPckg<TInt> left(aLeftPercentage); |
|
777 TPckg<TInt> right(aRightPercentage); |
|
778 return SendReceive(ERadioServGetBalance, |
|
779 TIpcArgs(&iDestinationPckg, &left, &right)); |
|
780 } |
|
781 else |
|
782 { |
|
783 return KErrDisconnected; |
|
784 } |
|
785 } |
|
786 |
|
787 //********** RDSUtility control begins |
|
788 |
|
789 // ----------------------------------------------------------------------------- |
|
790 // RRadioSession::GetRdsCapabilities |
|
791 // ----------------------------------------------------------------------------- |
|
792 // |
|
793 EXPORT_C TInt RRadioSession::GetRdsCapabilities( |
|
794 TRsRdsCapabilities& aCaps ) const |
|
795 { |
|
796 RADIO_RDEBUG(_L("[RADIO-SESS] GetRdsCapabilities()")); |
|
797 if ( iConnected ) |
|
798 { |
|
799 TPckg<TRsRdsCapabilities> caps(aCaps); |
|
800 return SendReceive(ERadioServGetRdsCapabilities, |
|
801 TIpcArgs(&iDestinationPckg, &caps)); |
|
802 } |
|
803 else |
|
804 { |
|
805 return KErrDisconnected; |
|
806 } |
|
807 } |
|
808 |
|
809 // ----------------------------------------------------------------------------- |
|
810 // RRadioSession::GetRdsSignalStatus |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 EXPORT_C TInt RRadioSession::GetRdsSignalStatus( |
|
814 TBool& aRdsSignal ) const |
|
815 { |
|
816 RADIO_RDEBUG(_L("[RADIO-SESS] GetRdsSignalStatus()")); |
|
817 if ( iConnected ) |
|
818 { |
|
819 TPckg<TBool> signal(aRdsSignal); |
|
820 return SendReceive(ERadioServGetRdsSignalStatus, |
|
821 TIpcArgs(&iDestinationPckg, &signal)); |
|
822 } |
|
823 else |
|
824 { |
|
825 return KErrDisconnected; |
|
826 } |
|
827 } |
|
828 |
|
829 // ----------------------------------------------------------------------------- |
|
830 // RRadioSession::NotifyRdsDataChange |
|
831 // ----------------------------------------------------------------------------- |
|
832 // |
|
833 EXPORT_C TInt RRadioSession::NotifyRdsDataChange( |
|
834 TRsRdsData aRdsData ) |
|
835 { |
|
836 RADIO_RDEBUG_INT(_L("[RADIO-SESS] NotifyRdsDataChange() [%d]"), aRdsData.iRdsFunctions); |
|
837 if ( !iConnected ) |
|
838 { |
|
839 return KErrDisconnected; |
|
840 } |
|
841 |
|
842 if ( !iObserver ) |
|
843 { |
|
844 return KErrNotReady; |
|
845 } |
|
846 |
|
847 TRAPD(err, StartRdsEventHandlersL(aRdsData.iRdsFunctions)); |
|
848 if ( err != KErrNone ) |
|
849 { |
|
850 RADIO_RDEBUG_INT(_L("[RADIO-SESS] NotifyRdsDataChange() err=[%d]"), err); |
|
851 return err; |
|
852 } |
|
853 err = SendReceive(ERadioServNotifyRdsDataChange, |
|
854 TIpcArgs(&iDestinationPckg)); |
|
855 if ( err == KErrNone ) |
|
856 { |
|
857 iRdsNotify = ETrue; |
|
858 } |
|
859 return err; |
|
860 } |
|
861 |
|
862 // ----------------------------------------------------------------------------- |
|
863 // RRadioSession::CancelNotifyRdsDataChange |
|
864 // ----------------------------------------------------------------------------- |
|
865 // |
|
866 EXPORT_C void RRadioSession::CancelNotifyRdsDataChange() |
|
867 { |
|
868 RADIO_RDEBUG(_L("[RADIO-SESS] CancelNotifyRdsDataChange()")); |
|
869 if ( iConnected && iRdsNotify ) |
|
870 { |
|
871 iRdsEventHandlers.ResetAndDestroy(); |
|
872 SendReceive(ERadioServCancelNotifyRdsDataChange, |
|
873 TIpcArgs(&iDestinationPckg)); |
|
874 } |
|
875 } |
|
876 |
|
877 // ----------------------------------------------------------------------------- |
|
878 // RRadioSession::NotifyRadioTextPlusChange |
|
879 // ----------------------------------------------------------------------------- |
|
880 // |
|
881 EXPORT_C TInt RRadioSession::NotifyRadioTextPlusChange( |
|
882 RArray<TInt>& /*aRtPlusClasses*/ ) |
|
883 { |
|
884 RADIO_RDEBUG(_L("[RADIO-SESS] NotifyRadioTextPlusChange()")); |
|
885 return KErrNotSupported; |
|
886 } |
|
887 |
|
888 // ----------------------------------------------------------------------------- |
|
889 // RRadioSession::CancelNotifyRadioTextPlusChange |
|
890 // ----------------------------------------------------------------------------- |
|
891 // |
|
892 EXPORT_C void RRadioSession::CancelNotifyRadioTextPlusChange() |
|
893 { |
|
894 RADIO_RDEBUG(_L("[RADIO-SESS] CancelNotifyRadioTextPlusChange()")); |
|
895 // NotifyRadioTextPlusChange is not supported |
|
896 } |
|
897 |
|
898 // ----------------------------------------------------------------------------- |
|
899 // RRadioSession::SetAutomaticSwitching |
|
900 // ----------------------------------------------------------------------------- |
|
901 // |
|
902 EXPORT_C TInt RRadioSession::SetAutomaticSwitching( |
|
903 TBool aAuto ) |
|
904 { |
|
905 RADIO_RDEBUG_INT(_L("[RADIO-SESS] SetAutomaticSwitching() [%d]"), aAuto); |
|
906 if ( iConnected ) |
|
907 { |
|
908 return SendReceive(ERadioServSetAutomaticSwitching, |
|
909 TIpcArgs(&iDestinationPckg, aAuto)); |
|
910 } |
|
911 else |
|
912 { |
|
913 return KErrDisconnected; |
|
914 } |
|
915 } |
|
916 |
|
917 // ----------------------------------------------------------------------------- |
|
918 // RRadioSession::GetAutomaticSwitching |
|
919 // ----------------------------------------------------------------------------- |
|
920 // |
|
921 EXPORT_C TInt RRadioSession::GetAutomaticSwitching( |
|
922 TBool& aAuto ) |
|
923 { |
|
924 RADIO_RDEBUG(_L("[RADIO-SESS] GetAutomaticSwitching()")); |
|
925 if ( iConnected ) |
|
926 { |
|
927 TPckg<TBool> autoSwitching(aAuto); |
|
928 return SendReceive(ERadioServGetAutomaticSwitching, |
|
929 TIpcArgs(&iDestinationPckg, &autoSwitching)); |
|
930 } |
|
931 else |
|
932 { |
|
933 return KErrDisconnected; |
|
934 } |
|
935 } |
|
936 |
|
937 // ----------------------------------------------------------------------------- |
|
938 // RRadioSession::CancelAFSearch |
|
939 // ----------------------------------------------------------------------------- |
|
940 // |
|
941 EXPORT_C void RRadioSession::CancelAFSearch() |
|
942 { |
|
943 RADIO_RDEBUG(_L("[RADIO-SESS] CancelAFSearch()")); |
|
944 if ( iConnected ) |
|
945 { |
|
946 SendReceive(ERadioServCancelAFSearch, TIpcArgs(&iDestinationPckg)); |
|
947 } |
|
948 } |
|
949 |
|
950 // ----------------------------------------------------------------------------- |
|
951 // RRadioSession::SetAutomaticTrafficAnnouncement |
|
952 // ----------------------------------------------------------------------------- |
|
953 // |
|
954 EXPORT_C TInt RRadioSession::SetAutomaticTrafficAnnouncement( |
|
955 TBool /*aAuto*/ ) |
|
956 { |
|
957 RADIO_RDEBUG(_L("[RADIO-SESS] SetAutomaticTrafficAnnouncement()")); |
|
958 return KErrNotSupported; |
|
959 } |
|
960 |
|
961 // ----------------------------------------------------------------------------- |
|
962 // RRadioSession::GetAutomaticTrafficAnnouncement |
|
963 // ----------------------------------------------------------------------------- |
|
964 // |
|
965 EXPORT_C TInt RRadioSession::GetAutomaticTrafficAnnouncement( |
|
966 TBool& /*aAuto*/ ) |
|
967 { |
|
968 RADIO_RDEBUG(_L("[RADIO-SESS] GetAutomaticTrafficAnnouncement()")); |
|
969 return KErrNotSupported; |
|
970 } |
|
971 |
|
972 // ----------------------------------------------------------------------------- |
|
973 // RRadioSession::StationSeekByPTY |
|
974 // ----------------------------------------------------------------------------- |
|
975 // |
|
976 EXPORT_C void RRadioSession::StationSeekByPTY( |
|
977 TRsRdsProgrammeType aPty, |
|
978 TBool aSeekUp ) |
|
979 { |
|
980 RADIO_RDEBUG_INT(_L("[RADIO-SESS] StationSeekByPTY() pty=[%d]"), aPty); |
|
981 if ( iConnected ) |
|
982 { |
|
983 if ( iRequests[KReqStationSeekByPTY]->IsActive() ) |
|
984 { |
|
985 iRequests[KReqStationSeekByPTY]->Cancel(); |
|
986 } |
|
987 SendReceive(ERadioServStationSeekByPTY, |
|
988 TIpcArgs(&iDestinationPckg, aPty, aSeekUp, &(iRequests[KReqStationSeekByPTY]->iIntPckg)), |
|
989 iRequests[KReqStationSeekByPTY]->iStatus); |
|
990 iRequests[KReqStationSeekByPTY]->SetActive(); |
|
991 } |
|
992 else |
|
993 { |
|
994 iRequests[KReqInternal]->CompleteRequest(ERadioServStationSeekByPTY, KErrDisconnected); |
|
995 } |
|
996 } |
|
997 |
|
998 // ----------------------------------------------------------------------------- |
|
999 // RRadioSession::StationSeekByTA |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 // |
|
1002 EXPORT_C void RRadioSession::StationSeekByTA( |
|
1003 TBool aSeekUp ) |
|
1004 { |
|
1005 RADIO_RDEBUG(_L("[RADIO-SESS] StationSeekByTA()")); |
|
1006 if ( iConnected ) |
|
1007 { |
|
1008 if ( iRequests[KReqStationSeekByTA]->IsActive() ) |
|
1009 { |
|
1010 iRequests[KReqStationSeekByTA]->Cancel(); |
|
1011 } |
|
1012 SendReceive(ERadioServStationSeekByTA, |
|
1013 TIpcArgs(&iDestinationPckg, aSeekUp, &(iRequests[KReqStationSeekByTA]->iIntPckg)), |
|
1014 iRequests[KReqStationSeekByTA]->iStatus); |
|
1015 iRequests[KReqStationSeekByTA]->SetActive(); |
|
1016 } |
|
1017 else |
|
1018 { |
|
1019 iRequests[KReqInternal]->CompleteRequest(ERadioServStationSeekByTA, KErrDisconnected); |
|
1020 } |
|
1021 } |
|
1022 |
|
1023 // ----------------------------------------------------------------------------- |
|
1024 // RRadioSession::StationSeekByTP |
|
1025 // ----------------------------------------------------------------------------- |
|
1026 // |
|
1027 EXPORT_C void RRadioSession::StationSeekByTP( |
|
1028 TBool aSeekUp ) |
|
1029 { |
|
1030 RADIO_RDEBUG(_L("[RADIO-SESS] StationSeekByTP()")); |
|
1031 if ( iConnected ) |
|
1032 { |
|
1033 if ( iRequests[KReqStationSeekByTP]->IsActive() ) |
|
1034 { |
|
1035 iRequests[KReqStationSeekByTP]->Cancel(); |
|
1036 } |
|
1037 SendReceive(ERadioServStationSeekByTP, |
|
1038 TIpcArgs(&iDestinationPckg, aSeekUp, &(iRequests[KReqStationSeekByTP]->iIntPckg)), |
|
1039 iRequests[KReqStationSeekByTP]->iStatus); |
|
1040 iRequests[KReqStationSeekByTP]->SetActive(); |
|
1041 } |
|
1042 else |
|
1043 { |
|
1044 iRequests[KReqInternal]->CompleteRequest(ERadioServStationSeekByTP, KErrDisconnected); |
|
1045 } |
|
1046 } |
|
1047 |
|
1048 // ----------------------------------------------------------------------------- |
|
1049 // RRadioSession::CancelRdsStationSeek |
|
1050 // ----------------------------------------------------------------------------- |
|
1051 // |
|
1052 EXPORT_C void RRadioSession::CancelRdsStationSeek() |
|
1053 { |
|
1054 RADIO_RDEBUG(_L("[RADIO-SESS] CancelRdsStationSeek()")); |
|
1055 if ( iConnected ) |
|
1056 { |
|
1057 if ( iRequests[KReqStationSeekByPTY]->IsActive() ) |
|
1058 { |
|
1059 iRequests[KReqStationSeekByPTY]->Cancel(); |
|
1060 } |
|
1061 if ( iRequests[KReqStationSeekByTA]->IsActive() ) |
|
1062 { |
|
1063 iRequests[KReqStationSeekByTA]->Cancel(); |
|
1064 } |
|
1065 if ( iRequests[KReqStationSeekByTP]->IsActive() ) |
|
1066 { |
|
1067 iRequests[KReqStationSeekByTP]->Cancel(); |
|
1068 } |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 // ----------------------------------------------------------------------------- |
|
1073 // RRadioSession::GetFreqByPTY |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // |
|
1076 EXPORT_C void RRadioSession::GetFreqByPTY( |
|
1077 TRsRdsProgrammeType /*aPty*/ ) |
|
1078 { |
|
1079 RADIO_RDEBUG(_L("[RADIO-SESS] GetFreqByPTY()")); |
|
1080 iRequests[KReqInternal]->CompleteRequest(ERadioServGetFreqByPTY, KErrNotSupported); |
|
1081 } |
|
1082 |
|
1083 // ----------------------------------------------------------------------------- |
|
1084 // RRadioSession::CancelGetFreqByPTY |
|
1085 // ----------------------------------------------------------------------------- |
|
1086 // |
|
1087 EXPORT_C void RRadioSession::CancelGetFreqByPTY() |
|
1088 { |
|
1089 RADIO_RDEBUG(_L("[RADIO-SESS] CancelGetFreqByPTY()")); |
|
1090 // GetFreqByPTY is not supported |
|
1091 } |
|
1092 |
|
1093 // ----------------------------------------------------------------------------- |
|
1094 // RRadioSession::GetFreqByTA |
|
1095 // ----------------------------------------------------------------------------- |
|
1096 // |
|
1097 EXPORT_C void RRadioSession::GetFreqByTA() |
|
1098 { |
|
1099 RADIO_RDEBUG(_L("[RADIO-SESS] GetFreqByTA()")); |
|
1100 iRequests[KReqInternal]->CompleteRequest(ERadioServGetFreqByTA, KErrNotSupported); |
|
1101 } |
|
1102 |
|
1103 // ----------------------------------------------------------------------------- |
|
1104 // RRadioSession::CancelGetFreqByTA |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // |
|
1107 EXPORT_C void RRadioSession::CancelGetFreqByTA() |
|
1108 { |
|
1109 RADIO_RDEBUG(_L("[RADIO-SESS] CancelGetFreqByTA()")); |
|
1110 // GetFreqByTA is not supported |
|
1111 } |
|
1112 |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 // RRadioSession::GetPSByPTY |
|
1115 // ----------------------------------------------------------------------------- |
|
1116 // |
|
1117 EXPORT_C void RRadioSession::GetPSByPTY( |
|
1118 TRsRdsProgrammeType /*aPty*/ ) |
|
1119 { |
|
1120 RADIO_RDEBUG(_L("[RADIO-SESS] GetPSByPTY()")); |
|
1121 iRequests[KReqInternal]->CompleteRequest(ERadioServGetPSByPTY, KErrNotSupported); |
|
1122 } |
|
1123 |
|
1124 // ----------------------------------------------------------------------------- |
|
1125 // RRadioSession::CancelGetPSByPTY |
|
1126 // ----------------------------------------------------------------------------- |
|
1127 // |
|
1128 EXPORT_C void RRadioSession::CancelGetPSByPTY() |
|
1129 { |
|
1130 RADIO_RDEBUG(_L("[RADIO-SESS] CancelGetPSByPTY()")); |
|
1131 // GetPSByPTY is not supported |
|
1132 } |
|
1133 |
|
1134 // ----------------------------------------------------------------------------- |
|
1135 // RRadioSession::GetPSByTA |
|
1136 // ----------------------------------------------------------------------------- |
|
1137 // |
|
1138 EXPORT_C void RRadioSession::GetPSByTA() |
|
1139 { |
|
1140 RADIO_RDEBUG(_L("[RADIO-SESS] GetPSByTA()")); |
|
1141 iRequests[KReqInternal]->CompleteRequest(ERadioServGetPSByTA, KErrNotSupported); |
|
1142 } |
|
1143 |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // RRadioSession::CancelGetPSByTA |
|
1146 // ----------------------------------------------------------------------------- |
|
1147 // |
|
1148 EXPORT_C void RRadioSession::CancelGetPSByTA() |
|
1149 { |
|
1150 RADIO_RDEBUG(_L("[RADIO-SESS] CancelGetPSByTA()")); |
|
1151 // GetPSByTA is not supported |
|
1152 } |
|
1153 |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // RRadioSession::GetProgrammeIdentification |
|
1156 // ----------------------------------------------------------------------------- |
|
1157 // |
|
1158 EXPORT_C TInt RRadioSession::GetProgrammeIdentification( |
|
1159 TInt& aPi ) |
|
1160 { |
|
1161 RADIO_RDEBUG(_L("[RADIO-SESS] GetProgrammeIdentification()")); |
|
1162 if ( iConnected ) |
|
1163 { |
|
1164 TPckg<TInt> pi(aPi); |
|
1165 return SendReceive(ERadioServGetProgrammeIdentification, |
|
1166 TIpcArgs(&iDestinationPckg, &pi)); |
|
1167 } |
|
1168 else |
|
1169 { |
|
1170 return KErrDisconnected; |
|
1171 } |
|
1172 } |
|
1173 |
|
1174 // ----------------------------------------------------------------------------- |
|
1175 // RRadioSession::GetProgrammeType |
|
1176 // ----------------------------------------------------------------------------- |
|
1177 // |
|
1178 EXPORT_C TInt RRadioSession::GetProgrammeType( |
|
1179 TRsRdsProgrammeType& aPty ) |
|
1180 { |
|
1181 RADIO_RDEBUG(_L("[RADIO-SESS] GetProgrammeType()")); |
|
1182 if ( iConnected ) |
|
1183 { |
|
1184 TPckg<TRsRdsProgrammeType> pty(aPty); |
|
1185 return SendReceive(ERadioServGetProgrammeType, |
|
1186 TIpcArgs(&iDestinationPckg, &pty)); |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 return KErrDisconnected; |
|
1191 } |
|
1192 } |
|
1193 |
|
1194 // ----------------------------------------------------------------------------- |
|
1195 // RRadioSession::GetProgrammeService |
|
1196 // ----------------------------------------------------------------------------- |
|
1197 // |
|
1198 EXPORT_C TInt RRadioSession::GetProgrammeService( |
|
1199 TRsRdsPSName& aPs ) |
|
1200 { |
|
1201 RADIO_RDEBUG(_L("[RADIO-SESS] GetProgrammeService()")); |
|
1202 if ( iConnected ) |
|
1203 { |
|
1204 TPckg<TRsRdsPSName> ps(aPs); |
|
1205 return SendReceive(ERadioServGetProgrammeService, |
|
1206 TIpcArgs(&iDestinationPckg, &ps)); |
|
1207 } |
|
1208 else |
|
1209 { |
|
1210 return KErrDisconnected; |
|
1211 } |
|
1212 } |
|
1213 |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // RRadioSession::GetRadioText |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // |
|
1218 EXPORT_C TInt RRadioSession::GetRadioText( |
|
1219 TRsRdsRadioText& aRt ) |
|
1220 { |
|
1221 RADIO_RDEBUG(_L("[RADIO-SESS] GetRadioText()")); |
|
1222 if ( iConnected ) |
|
1223 { |
|
1224 TPckg<TRsRdsRadioText> rt(aRt); |
|
1225 return SendReceive(ERadioServGetRadioText, |
|
1226 TIpcArgs(&iDestinationPckg, &rt)); |
|
1227 } |
|
1228 else |
|
1229 { |
|
1230 return KErrDisconnected; |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 // ----------------------------------------------------------------------------- |
|
1235 // RRadioSession::GetRadioTextPlus |
|
1236 // ----------------------------------------------------------------------------- |
|
1237 // |
|
1238 EXPORT_C TInt RRadioSession::GetRadioTextPlus( |
|
1239 TRsRdsRTplusClass /*aRtPlusClass*/, |
|
1240 TRsRdsRadioText& /*aRtPlusData*/ ) |
|
1241 { |
|
1242 RADIO_RDEBUG(_L("[RADIO-SESS] GetRadioText()")); |
|
1243 return KErrNotSupported; |
|
1244 } |
|
1245 |
|
1246 // ----------------------------------------------------------------------------- |
|
1247 // RRadioSession::GetClockTime |
|
1248 // ----------------------------------------------------------------------------- |
|
1249 // |
|
1250 EXPORT_C TInt RRadioSession::GetClockTime( |
|
1251 TDateTime& aCt ) |
|
1252 { |
|
1253 RADIO_RDEBUG(_L("[RADIO-SESS] GetClockTime()")); |
|
1254 if ( iConnected ) |
|
1255 { |
|
1256 TPckg<TDateTime> ct(aCt); |
|
1257 return SendReceive(ERadioServGetClockTime, |
|
1258 TIpcArgs(&iDestinationPckg, &ct)); |
|
1259 } |
|
1260 else |
|
1261 { |
|
1262 return KErrDisconnected; |
|
1263 } |
|
1264 } |
|
1265 |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 // RRadioSession::GetTrafficAnnouncementStatus |
|
1268 // ----------------------------------------------------------------------------- |
|
1269 // |
|
1270 EXPORT_C TInt RRadioSession::GetTrafficAnnouncementStatus( |
|
1271 TBool& aTaStatus ) |
|
1272 { |
|
1273 RADIO_RDEBUG(_L("[RADIO-SESS] GetTrafficAnnouncementStatus()")); |
|
1274 if ( iConnected ) |
|
1275 { |
|
1276 TPckg<TBool> taStatus(aTaStatus); |
|
1277 return SendReceive(ERadioServGetTrafficAnnouncementStatus, |
|
1278 TIpcArgs(&iDestinationPckg, &taStatus)); |
|
1279 } |
|
1280 else |
|
1281 { |
|
1282 return KErrDisconnected; |
|
1283 } |
|
1284 } |
|
1285 |
|
1286 // ----------------------------------------------------------------------------- |
|
1287 // RRadioSession::GetTrafficProgrammeStatus |
|
1288 // ----------------------------------------------------------------------------- |
|
1289 // |
|
1290 EXPORT_C TInt RRadioSession::GetTrafficProgrammeStatus( |
|
1291 TBool& aTpStatus ) |
|
1292 { |
|
1293 RADIO_RDEBUG(_L("[RADIO-SESS] GetTrafficProgrammeStatus()")); |
|
1294 if ( iConnected ) |
|
1295 { |
|
1296 TPckg<TBool> tpStatus(aTpStatus); |
|
1297 return SendReceive(ERadioServGetTrafficProgrammeStatus, |
|
1298 TIpcArgs(&iDestinationPckg, &tpStatus)); |
|
1299 } |
|
1300 else |
|
1301 { |
|
1302 return KErrDisconnected; |
|
1303 } |
|
1304 } |
|
1305 |
|
1306 // ----------------------------------------------------------------------------- |
|
1307 // RRadioSession::CustomCommandSync |
|
1308 // ----------------------------------------------------------------------------- |
|
1309 EXPORT_C TInt RRadioSession::CustomCommandSync( |
|
1310 const TMMFMessageDestinationPckg& aDestination, |
|
1311 TInt aFunction, |
|
1312 const TDesC8& aDataTo1, |
|
1313 const TDesC8& aDataTo2 ) |
|
1314 { |
|
1315 RADIO_RDEBUG(_L("[RADIO-SESS] CustomCommandSync NoReturn()")); |
|
1316 if ( iConnected ) |
|
1317 { |
|
1318 return SendReceive(aFunction, TIpcArgs(&aDestination, &aDataTo1, &aDataTo2)); |
|
1319 } |
|
1320 else |
|
1321 { |
|
1322 return KErrDisconnected; |
|
1323 } |
|
1324 } |
|
1325 |
|
1326 // ----------------------------------------------------------------------------- |
|
1327 // RRadioSession::CustomCommandSync |
|
1328 // ----------------------------------------------------------------------------- |
|
1329 EXPORT_C TInt RRadioSession::CustomCommandSync( |
|
1330 const TMMFMessageDestinationPckg& aDestination, |
|
1331 TInt aFunction, |
|
1332 const TDesC8& aDataTo1, |
|
1333 const TDesC8& aDataTo2, |
|
1334 TDes8& aDataFrom ) |
|
1335 { |
|
1336 RADIO_RDEBUG(_L("[RADIO-SESS] CustomCommandSync Return()")); |
|
1337 if ( iConnected ) |
|
1338 { |
|
1339 return SendReceive(aFunction, TIpcArgs(&aDestination, &aDataTo1, &aDataTo2, &aDataFrom)); |
|
1340 } |
|
1341 else |
|
1342 { |
|
1343 return KErrDisconnected; |
|
1344 } |
|
1345 } |
|
1346 |
|
1347 // ----------------------------------------------------------------------------- |
|
1348 // RRadioSession::CustomCommandAsync |
|
1349 // ----------------------------------------------------------------------------- |
|
1350 EXPORT_C void RRadioSession::CustomCommandAsync( |
|
1351 const TMMFMessageDestinationPckg& aDestination, |
|
1352 TInt aFunction, |
|
1353 const TDesC8& aDataTo1, |
|
1354 const TDesC8& aDataTo2, |
|
1355 TRequestStatus& aStatus ) |
|
1356 { |
|
1357 RADIO_RDEBUG(_L("[RADIO-SESS] CustomCommandAsync NoReturn()")); |
|
1358 if ( iConnected ) |
|
1359 { |
|
1360 SendReceive(aFunction, TIpcArgs(&aDestination, &aDataTo1, &aDataTo2), aStatus); |
|
1361 } |
|
1362 else |
|
1363 { |
|
1364 TRequestStatus* stat = &aStatus; |
|
1365 User::RequestComplete(stat, KErrDisconnected); |
|
1366 } |
|
1367 } |
|
1368 |
|
1369 // ----------------------------------------------------------------------------- |
|
1370 // RRadioSession::CustomCommandAsync |
|
1371 // ----------------------------------------------------------------------------- |
|
1372 EXPORT_C void RRadioSession::CustomCommandAsync( |
|
1373 const TMMFMessageDestinationPckg& aDestination, |
|
1374 TInt aFunction, |
|
1375 const TDesC8& aDataTo1, |
|
1376 const TDesC8& aDataTo2, |
|
1377 TDes8& aDataFrom, |
|
1378 TRequestStatus& aStatus ) |
|
1379 { |
|
1380 RADIO_RDEBUG(_L("[RADIO-SESS] CustomCommandAsync Return()")); |
|
1381 if ( iConnected ) |
|
1382 { |
|
1383 SendReceive(aFunction, TIpcArgs(&aDestination, &aDataTo1, &aDataTo2, &aDataFrom), aStatus); |
|
1384 } |
|
1385 else |
|
1386 { |
|
1387 TRequestStatus* stat = &aStatus; |
|
1388 User::RequestComplete(stat, KErrDisconnected); |
|
1389 } |
|
1390 } |
|
1391 |
|
1392 // ----------------------------------------------------------------------------- |
|
1393 // RRadioSession::CancelRequest |
|
1394 // ----------------------------------------------------------------------------- |
|
1395 // |
|
1396 void RRadioSession::CancelRequest( |
|
1397 TInt aRequest ) |
|
1398 { |
|
1399 RADIO_RDEBUG_INT(_L("[RADIO-SESS] CancelRequest(): [%d]"), aRequest); |
|
1400 if ( iConnected ) |
|
1401 { |
|
1402 SendReceive(ERadioServCancel, TIpcArgs(&iDestinationPckg, aRequest)); |
|
1403 } |
|
1404 } |
|
1405 |
|
1406 // ----------------------------------------------------------------------------- |
|
1407 // RRadioSession::StartRequestHandlersL |
|
1408 // Create asynchronous request handlers. |
|
1409 // ** NOTE: The order in which each handler is appended to the iRequests array is critical. |
|
1410 // Access to each request is done with constants declared at the beginning of this file. |
|
1411 // ----------------------------------------------------------------------------- |
|
1412 // |
|
1413 void RRadioSession::StartRequestHandlersL( |
|
1414 MRadioObserver& aObserver ) |
|
1415 { |
|
1416 RADIO_RDEBUG(_L("[RADIO-SESS] StartRequestHandlersL()")); |
|
1417 |
|
1418 CRadioRequest* req = NULL; |
|
1419 |
|
1420 req = CRadioRequest::NewLC(*this, aObserver, ERadioServNone); |
|
1421 User::LeaveIfError( iRequests.Append(req) ); |
|
1422 CleanupStack::Pop( req ); |
|
1423 |
|
1424 req = CRadioRequest::NewLC(*this, aObserver, ERadioServRequestTunerControl); |
|
1425 User::LeaveIfError( iRequests.Append(req) ); |
|
1426 CleanupStack::Pop( req ); |
|
1427 |
|
1428 req = CRadioRequest::NewLC(*this, aObserver, ERadioServSetFrequencyRange); |
|
1429 User::LeaveIfError( iRequests.Append(req) ); |
|
1430 CleanupStack::Pop( req ); |
|
1431 |
|
1432 req = CRadioRequest::NewLC(*this, aObserver, ERadioServSetFrequency); |
|
1433 User::LeaveIfError( iRequests.Append(req) ); |
|
1434 CleanupStack::Pop( req ); |
|
1435 |
|
1436 req = CRadioRequest::NewLC(*this, aObserver, ERadioServStationSeek); |
|
1437 User::LeaveIfError( iRequests.Append(req) ); |
|
1438 CleanupStack::Pop( req ); |
|
1439 |
|
1440 req = CRadioRequest::NewLC(*this, aObserver, ERadioServPlay); |
|
1441 User::LeaveIfError( iRequests.Append(req) ); |
|
1442 CleanupStack::Pop( req ); |
|
1443 |
|
1444 req = CRadioRequest::NewLC(*this, aObserver, ERadioServStationSeekByPTY); |
|
1445 User::LeaveIfError( iRequests.Append(req) ); |
|
1446 CleanupStack::Pop( req ); |
|
1447 |
|
1448 req = CRadioRequest::NewLC(*this, aObserver, ERadioServStationSeekByTA); |
|
1449 User::LeaveIfError( iRequests.Append(req) ); |
|
1450 CleanupStack::Pop( req ); |
|
1451 |
|
1452 req = CRadioRequest::NewLC(*this, aObserver, ERadioServStationSeekByTP); |
|
1453 User::LeaveIfError( iRequests.Append(req) ); |
|
1454 CleanupStack::Pop( req ); |
|
1455 } |
|
1456 |
|
1457 // ----------------------------------------------------------------------------- |
|
1458 // RRadioSession::StartEventHandlersL |
|
1459 // ----------------------------------------------------------------------------- |
|
1460 // |
|
1461 void RRadioSession::StartEventHandlersL( |
|
1462 MRadioObserver& aEventObserver ) |
|
1463 { |
|
1464 RADIO_RDEBUG(_L("[RADIO-SESS] StartEventHandlersL()")); |
|
1465 |
|
1466 CRadioEventHandler* handler = NULL; |
|
1467 |
|
1468 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsPlayerState); |
|
1469 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1470 CleanupStack::Pop( handler ); |
|
1471 |
|
1472 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsAntennaStatus); |
|
1473 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1474 CleanupStack::Pop( handler ); |
|
1475 |
|
1476 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsOfflineMode ); |
|
1477 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1478 CleanupStack::Pop( handler ); |
|
1479 |
|
1480 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsTransmitterStatus ); |
|
1481 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1482 CleanupStack::Pop( handler ); |
|
1483 |
|
1484 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsFrequency); |
|
1485 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1486 CleanupStack::Pop( handler ); |
|
1487 |
|
1488 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsFrequencyRange); |
|
1489 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1490 CleanupStack::Pop( handler ); |
|
1491 |
|
1492 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsForceMonoReception); |
|
1493 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1494 CleanupStack::Pop( handler ); |
|
1495 |
|
1496 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsSquelch); |
|
1497 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1498 CleanupStack::Pop( handler ); |
|
1499 |
|
1500 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsVolume); |
|
1501 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1502 CleanupStack::Pop( handler ); |
|
1503 |
|
1504 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsMuteStatus); |
|
1505 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1506 CleanupStack::Pop( handler ); |
|
1507 |
|
1508 handler = CRadioEventHandler::NewLC(aEventObserver, *this, ERadioServPsBalance); |
|
1509 User::LeaveIfError( iEventHandlers.Append(handler) ); |
|
1510 CleanupStack::Pop( handler ); |
|
1511 } |
|
1512 |
|
1513 // ----------------------------------------------------------------------------- |
|
1514 // RRadioSession::StartRdsEventHandlersL |
|
1515 // ----------------------------------------------------------------------------- |
|
1516 // |
|
1517 void RRadioSession::StartRdsEventHandlersL( |
|
1518 TUint32 aRdsFunction ) |
|
1519 { |
|
1520 RADIO_RDEBUG(_L("[RADIO-SESS] StartRdsEventHandlersL()")); |
|
1521 |
|
1522 iRdsEventHandlers.ResetAndDestroy(); |
|
1523 CRadioEventHandler* handler = NULL; |
|
1524 |
|
1525 // If RDS notification started always return the latest RdsSignalStatus |
|
1526 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsRdsSignalStatus); |
|
1527 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1528 CleanupStack::Pop( handler ); |
|
1529 |
|
1530 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsAutoSwitchStatus); |
|
1531 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1532 CleanupStack::Pop( handler ); |
|
1533 |
|
1534 if (aRdsFunction & TRsRdsData::ERsRdsProgrammeIdentification) |
|
1535 { |
|
1536 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsProgrammeIdentification); |
|
1537 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1538 CleanupStack::Pop( handler ); |
|
1539 } |
|
1540 |
|
1541 if (aRdsFunction & TRsRdsData::ERsRdsProgrammeType) |
|
1542 { |
|
1543 handler = CRadioEventHandler::NewLC(*iObserver, *this,ERadioServPsProgrammeType ); |
|
1544 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1545 CleanupStack::Pop( handler ); |
|
1546 } |
|
1547 |
|
1548 if (aRdsFunction & TRsRdsData::ERsRdsProgrammeService) |
|
1549 { |
|
1550 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsProgrammeService); |
|
1551 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1552 CleanupStack::Pop( handler ); |
|
1553 } |
|
1554 |
|
1555 if(aRdsFunction & TRsRdsData::ERsRdsRadioText) |
|
1556 { |
|
1557 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsRadioText); |
|
1558 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1559 CleanupStack::Pop( handler ); |
|
1560 } |
|
1561 |
|
1562 if(aRdsFunction & TRsRdsData::ERsRdsRadioTextPlus) |
|
1563 { |
|
1564 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsRadioTextPlusObjects); |
|
1565 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1566 CleanupStack::Pop( handler ); |
|
1567 } |
|
1568 |
|
1569 if (aRdsFunction & TRsRdsData::ERsRdsClockTime) |
|
1570 { |
|
1571 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsClockTime); |
|
1572 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1573 CleanupStack::Pop( handler ); |
|
1574 } |
|
1575 |
|
1576 if (aRdsFunction & TRsRdsData::ERsRdsTrafficAnnouncement) |
|
1577 { |
|
1578 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsTrafficAnnouncementStatus); |
|
1579 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1580 CleanupStack::Pop( handler ); |
|
1581 } |
|
1582 |
|
1583 if (aRdsFunction & TRsRdsData::ERsRdsAlternateFrequency) |
|
1584 { |
|
1585 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsAfSearchBegin); |
|
1586 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1587 CleanupStack::Pop( handler ); |
|
1588 |
|
1589 handler = CRadioEventHandler::NewLC(*iObserver, *this, ERadioServPsAfSearchEnd); |
|
1590 User::LeaveIfError( iRdsEventHandlers.Append(handler) ); |
|
1591 CleanupStack::Pop( handler ); |
|
1592 } |
|
1593 } |
|
1594 |
|
1595 // End of File |