author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 20:26:56 +0300 | |
changeset 48 | e14766a36cdc |
parent 28 | 075425b8d9a4 |
child 37 | 451b2e1545b2 |
permissions | -rw-r--r-- |
24 | 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 "cradiordsreceiver.h" |
|
20 |
#include "mradioenginesettings.h" |
|
21 |
#include "mradiordsdataobserver.h" |
|
22 |
#include "cradioenginelogger.h" |
|
23 |
||
24 |
// ======== MEMBER FUNCTIONS ======== |
|
25 |
||
26 |
// --------------------------------------------------------------------------- |
|
27 |
// |
|
28 |
// --------------------------------------------------------------------------- |
|
29 |
// |
|
30 |
CRadioRdsReceiver::CRadioRdsReceiver( MRadioEngineSettings& aSettings ) |
|
31 |
: CRadioRdsReceiverBase( aSettings ) |
|
32 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
33 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 34 |
} |
35 |
||
36 |
// --------------------------------------------------------------------------- |
|
37 |
// |
|
38 |
// --------------------------------------------------------------------------- |
|
39 |
// |
|
40 |
void CRadioRdsReceiver::ConstructL() |
|
41 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
42 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 43 |
BaseConstructL(); |
44 |
} |
|
45 |
||
46 |
// --------------------------------------------------------------------------- |
|
47 |
// |
|
48 |
// --------------------------------------------------------------------------- |
|
49 |
// |
|
50 |
CRadioRdsReceiver* CRadioRdsReceiver::NewL( MRadioEngineSettings& aSettings ) |
|
51 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
52 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 53 |
CRadioRdsReceiver* self = new ( ELeave ) CRadioRdsReceiver( aSettings ); |
54 |
CleanupStack::PushL( self ); |
|
55 |
self->ConstructL(); |
|
56 |
CleanupStack::Pop( self ); |
|
57 |
return self; |
|
58 |
} |
|
59 |
||
60 |
// --------------------------------------------------------------------------- |
|
61 |
// |
|
62 |
// --------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
CRadioRdsReceiver::~CRadioRdsReceiver() |
|
65 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
66 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 67 |
if ( iRdsUtility ) |
68 |
{ |
|
69 |
iRdsUtility->Close(); |
|
70 |
} |
|
71 |
} |
|
72 |
||
73 |
// --------------------------------------------------------------------------- |
|
74 |
// |
|
75 |
// --------------------------------------------------------------------------- |
|
76 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
77 |
void CRadioRdsReceiver::InitL( CRadioUtility& aRadioUtility ) |
24 | 78 |
{ |
79 |
LOG_METHOD_AUTO; |
|
80 |
||
81 |
iRdsUtility = &aRadioUtility.RadioRdsUtilityL( *this ); |
|
82 |
||
83 |
LogReceiverCapabilities(); |
|
84 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
85 |
SetAutomaticSwitchingL( EFalse ); |
24 | 86 |
} |
87 |
||
88 |
// --------------------------------------------------------------------------- |
|
89 |
// |
|
90 |
// --------------------------------------------------------------------------- |
|
91 |
// |
|
92 |
void CRadioRdsReceiver::SetAutomaticSwitchingL( TBool aEnable ) |
|
93 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
94 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 95 |
if ( iRdsUtility ) |
96 |
{ |
|
97 |
User::LeaveIfError( iRdsUtility->SetAutomaticSwitching( aEnable ) ); |
|
98 |
} |
|
99 |
||
100 |
// Notifies the observers |
|
101 |
CRadioRdsReceiverBase::SetAutomaticSwitchingL( aEnable ); |
|
102 |
} |
|
103 |
||
104 |
// --------------------------------------------------------------------------- |
|
105 |
// |
|
106 |
// --------------------------------------------------------------------------- |
|
107 |
// |
|
108 |
void CRadioRdsReceiver::StartReceiver() |
|
109 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
110 |
LOG_METHOD_AUTO; |
24 | 111 |
// Request to be notified of almost all RDS data. |
112 |
// Unwanted RDS values: |
|
113 |
// ERdsClockTime |
|
114 |
// ERdsTrafficProgramme |
|
115 |
// ERdsTrafficAnnouncement |
|
116 |
// ERdsAlternateFrequency |
|
117 |
TRdsData rdsData; |
|
118 |
rdsData.iRdsFunctions = ERdsProgrammeIdentification | |
|
119 |
ERdsProgrammeType | |
|
120 |
ERdsProgrammeService | |
|
121 |
ERdsRadioText | |
|
122 |
ERdsRadioTextPlus; |
|
123 |
||
124 |
rdsData.iAdditionalFunctions1 = 0; |
|
125 |
rdsData.iAdditionalFunctions2 = 0; |
|
126 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
127 |
LOG_ASSERT( iRdsUtility, LOG( "Error: RDS utility not created!" ) ); |
24 | 128 |
if ( iRdsUtility && !iStarted ) |
129 |
{ |
|
130 |
TInt err = iRdsUtility->NotifyRdsDataChange( rdsData ); |
|
131 |
if ( !err ) |
|
132 |
{ |
|
133 |
// Avoid further calls |
|
134 |
iStarted = ETrue; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
135 |
LOG( "Requested RDS notifications from receiver." ); |
24 | 136 |
} |
137 |
else |
|
138 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
139 |
LOG_FORMAT( "Failed to request RDS data with err %d", err ); |
24 | 140 |
} |
141 |
} |
|
142 |
} |
|
143 |
||
144 |
// --------------------------------------------------------------------------- |
|
145 |
// |
|
146 |
// --------------------------------------------------------------------------- |
|
147 |
// |
|
148 |
void CRadioRdsReceiver::StopReceiver() |
|
149 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
150 |
LOG_METHOD_AUTO; |
24 | 151 |
|
152 |
if ( iRdsUtility ) |
|
153 |
{ |
|
154 |
iRdsUtility->CancelNotifyRdsDataChange(); |
|
155 |
} |
|
156 |
iStarted = EFalse; |
|
157 |
} |
|
158 |
||
159 |
// --------------------------------------------------------------------------- |
|
160 |
// Logs the RDS receiver capabilities if logging is enabled |
|
161 |
// --------------------------------------------------------------------------- |
|
162 |
// |
|
163 |
void CRadioRdsReceiver::LogReceiverCapabilities() |
|
164 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
165 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 166 |
#ifdef LOGGING_ENABLED |
167 |
// Log the RDS utility capabilities |
|
168 |
if ( iRdsUtility ) |
|
169 |
{ |
|
170 |
TRdsCapabilities caps; |
|
171 |
caps.iRdsFunctions = 0; |
|
172 |
caps.iAdditionalFunctions1 = 0; |
|
173 |
caps.iAdditionalFunctions2 = 0; |
|
174 |
TInt err = iRdsUtility->GetCapabilities( caps ); |
|
175 |
if ( !err ) |
|
176 |
{ |
|
177 |
TBuf<100> capsBuf; |
|
178 |
if ( caps.iRdsFunctions & ERdsProgrammeIdentification == ERdsProgrammeIdentification ) |
|
179 |
{ |
|
180 |
capsBuf.Append( _L("PI ") ); |
|
181 |
} |
|
182 |
if ( caps.iRdsFunctions & ERdsProgrammeType == ERdsProgrammeType ) |
|
183 |
{ |
|
184 |
capsBuf.Append( _L("Genre ") ); |
|
185 |
} |
|
186 |
if ( caps.iRdsFunctions & ERdsProgrammeService == ERdsProgrammeService ) |
|
187 |
{ |
|
188 |
capsBuf.Append( _L("PS ") ); |
|
189 |
} |
|
190 |
if ( caps.iRdsFunctions & ERdsRadioText == ERdsRadioText ) |
|
191 |
{ |
|
192 |
capsBuf.Append( _L("RT ") ); |
|
193 |
} |
|
194 |
if ( caps.iRdsFunctions & ERdsRadioTextPlus == ERdsRadioTextPlus ) |
|
195 |
{ |
|
196 |
capsBuf.Append( _L("RT+ ") ); |
|
197 |
} |
|
198 |
if ( caps.iRdsFunctions & ERdsAlternateFrequency == ERdsAlternateFrequency ) |
|
199 |
{ |
|
200 |
capsBuf.Append( _L("AF ") ); |
|
201 |
} |
|
202 |
if ( caps.iRdsFunctions & ERdsClockTime == ERdsClockTime ) |
|
203 |
{ |
|
204 |
capsBuf.Append( _L("Time ") ); |
|
205 |
} |
|
206 |
if ( caps.iRdsFunctions & ERdsTrafficProgramme == ERdsTrafficProgramme ) |
|
207 |
{ |
|
208 |
capsBuf.Append( _L("TrafficProgramme ") ); |
|
209 |
} |
|
210 |
if ( caps.iRdsFunctions & ERdsTrafficAnnouncement == ERdsTrafficAnnouncement ) |
|
211 |
{ |
|
212 |
capsBuf.Append( _L("TrafficAnnouncement ") ); |
|
213 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
214 |
LOG_FORMAT( "RDS receiver capabilities: %S", &capsBuf ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
215 |
LOG_FORMAT( "Functions: %d, AdditionalFunctions1: %d, iAdditionalFunctions2: %d", |
24 | 216 |
caps.iRdsFunctions, caps.iAdditionalFunctions1, caps.iAdditionalFunctions2 ); |
217 |
} |
|
218 |
else |
|
219 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
220 |
LOG_FORMAT( "Failed to get RDS utility capabilities: err %d", err ); |
24 | 221 |
} |
222 |
} |
|
223 |
#endif // LOGGING_ENABLED |
|
224 |
} |