1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // User includes |
|
19 #include "radiordslistener.h" |
|
20 #include "radiostationhandlerif.h" |
|
21 #include "radioenginewrapper_p.h" |
|
22 #include "radioenginewrapperobserver.h" |
|
23 #include "radiologger.h" |
|
24 |
|
25 /*! |
|
26 * Converts a symbian descriptor to Qt string |
|
27 */ |
|
28 static QString convertString( const TDesC& aDesc ) |
|
29 { |
|
30 return QString::fromUtf16( aDesc.Ptr(), aDesc.Length() ); |
|
31 } |
|
32 |
|
33 /*! |
|
34 * |
|
35 */ |
|
36 RadioRdsListener::RadioRdsListener( RadioStationHandlerIf& stationHandler, RadioEngineWrapperPrivate& wrapper ) : |
|
37 mStationHandler( stationHandler ), |
|
38 mWrapper( wrapper ) |
|
39 { |
|
40 } |
|
41 |
|
42 /*! |
|
43 * \reimp |
|
44 */ |
|
45 void RadioRdsListener::RdsAvailable( TUint32 /*aFrequency*/, TBool aAvailable ) |
|
46 { |
|
47 RUN_NOTIFY_LOOP( mWrapper.observers(), rdsAvailabilityChanged( aAvailable ) ); |
|
48 } |
|
49 |
|
50 /*! |
|
51 * \reimp |
|
52 */ |
|
53 void RadioRdsListener::RdsAfSearchBegin() |
|
54 { |
|
55 } |
|
56 |
|
57 /*! |
|
58 * \reimp |
|
59 */ |
|
60 void RadioRdsListener::RdsAfSearchEnd( TUint32 /*aFrequency*/, TInt /*aError*/ ) |
|
61 { |
|
62 } |
|
63 |
|
64 /*! |
|
65 * \reimp |
|
66 */ |
|
67 void RadioRdsListener::RdsAfSearchStateChange( TBool /*aEnabled*/ ) |
|
68 { |
|
69 } |
|
70 |
|
71 /*! |
|
72 * \reimp |
|
73 */ |
|
74 void RadioRdsListener::RdsDataProgrammeService( TUint32 aFrequency, const TDesC& aProgramService ) |
|
75 { |
|
76 if ( aProgramService.Length() > 0 ) { |
|
77 LOG_TIMESTAMP( "RdsName changed" ); |
|
78 const uint frequency = static_cast<uint>( aFrequency ); |
|
79 mStationHandler.setCurrentPsName( frequency, convertString( aProgramService ) ); |
|
80 |
|
81 #ifdef SHOW_CALLSIGN_IN_ANY_REGION |
|
82 RdsDataPiCode( frequency, 0x3BB7 ); //KQOL-FM - Las Vegas, NV |
|
83 #endif |
|
84 } |
|
85 } |
|
86 |
|
87 /*! |
|
88 * \reimp |
|
89 */ |
|
90 void RadioRdsListener::RdsDataRadioText( TUint32 aFrequency, const TDesC& aRadioText ) |
|
91 { |
|
92 if ( aRadioText.Length() > 0 ) { |
|
93 const uint frequency = static_cast<uint>( aFrequency ); |
|
94 mStationHandler.setCurrentRadioText( frequency, convertString( aRadioText ) ); |
|
95 } |
|
96 } |
|
97 |
|
98 /*! |
|
99 * \reimp |
|
100 */ |
|
101 void RadioRdsListener::RdsDataRadioTextPlus( TUint32 aFrequency, |
|
102 const TInt aRadioTextPlusClass, |
|
103 const TDesC& aRadioText ) |
|
104 { |
|
105 TInt rtClass = aRadioTextPlusClass; |
|
106 if ( aRadioTextPlusClass == RtPlus::Band ) { |
|
107 rtClass = RtPlus::Artist; |
|
108 } |
|
109 |
|
110 const uint frequency = static_cast<uint>( aFrequency ); |
|
111 mStationHandler.setCurrentRadioTextPlus( frequency, rtClass, convertString( aRadioText ) ); |
|
112 } |
|
113 |
|
114 /*! |
|
115 * \reimp |
|
116 */ |
|
117 void RadioRdsListener::RdsDataGenre( TUint32 aFrequency, const TInt aGenre ) |
|
118 { |
|
119 LOG_FORMAT( "RadioRdsListener::RdsDataGenre: Genre: %d", aGenre ); |
|
120 const uint frequency = static_cast<uint>( aFrequency ); |
|
121 mStationHandler.setCurrentGenre( frequency, aGenre ); |
|
122 } |
|
123 |
|
124 /*! |
|
125 * \reimp |
|
126 */ |
|
127 void RadioRdsListener::RdsDataPiCode( TUint32 aFrequency, const TInt aPiCode ) |
|
128 { |
|
129 LOG_FORMAT( "RadioRdsListener::RdsDataPiCode, PI: %d", aPiCode ); |
|
130 const uint frequency = static_cast<uint>( aFrequency ); |
|
131 mStationHandler.setCurrentPiCode( frequency, aPiCode ); |
|
132 } |
|