|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "HWRMtrace.h" |
|
20 #include "HWRMFmTxInternalCRKeys.h" |
|
21 #include "HWRMFmTxInternalPSKeys.h" |
|
22 #include "HWRMFmTxAudioPolicyDomainPSKeys.h" |
|
23 #include "HWRMFmTxCommonData.h" |
|
24 #include "HWRMFmTxStateUtility.h" |
|
25 #include "HWRMClientServer.h" |
|
26 #include "HWRMConfiguration.h" |
|
27 #include "HWRMFmTxClientServer.h" |
|
28 #include "HWRMFmTxRdsTextConverter.h" |
|
29 #include "HWRMFmTxCommands.h" |
|
30 |
|
31 // CONSTANTS |
|
32 const TUint KRdsSpaceChar = 0x20; |
|
33 // For converting seconds to microseconds |
|
34 const TInt KSecondsToMicros(1000000); |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CHWRMFmTxCommonData::CHWRMFmTxCommonData |
|
40 // C++ constructor |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CHWRMFmTxCommonData::CHWRMFmTxCommonData() |
|
44 : iFrequencyRangeUpdated(EFalse) |
|
45 { |
|
46 COMPONENT_TRACE1( ( _L( "HWRM Server - CHWRMFmTxCommonData::CHWRMFmTxCommonData()" ) ) ); |
|
47 |
|
48 // Initialize RdsData |
|
49 iRdsData.iPty = KRdsPtyNone; |
|
50 iRdsData.iPtyn.Zero(); |
|
51 iRdsData.iMs = ETrue; |
|
52 iRdsData.iLanguageId = KRdsLanguageUnknown; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CHWRMFmTxCommonData::ConstructL |
|
57 // Symbian 2nd phase constructor can leave. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CHWRMFmTxCommonData::ConstructL() |
|
61 { |
|
62 COMPONENT_TRACE1( ( _L( "HWRM Server - CHWRMFmTxCommonData::ConstructL()" ) ) ); |
|
63 |
|
64 // Instantiate RDS text converter. Must be done before InitCenrepL() |
|
65 iRdsTextConverter = CHWRMFmTxRdsTextConverter::NewL(); |
|
66 |
|
67 InitCenrepL(); |
|
68 |
|
69 // Setup status P&S values |
|
70 TInt err = RProperty::Define( KHWRMFmTxStatus, RProperty::EInt, KNoCapability, KHWRMSidOnlyPolicy); |
|
71 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
72 { |
|
73 User::Leave( err ); |
|
74 } |
|
75 |
|
76 User::LeaveIfError(iFmTxStatusProperty.Attach(KPSUidHWRMFmTx, KHWRMFmTxStatus)); |
|
77 User::LeaveIfError(iFmTxStatusProperty.Set(EFmTxStateOff)); |
|
78 |
|
79 // Setup Audio Policy P&S values |
|
80 TSecurityPolicy audioPolicy(iFmTxAudioRoutingSid); |
|
81 err = RProperty::Define( KHWRMFmTxAvailableFlag, |
|
82 RProperty::EInt, |
|
83 audioPolicy, |
|
84 KHWRMSidOnlyPolicy); |
|
85 |
|
86 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
87 { |
|
88 User::Leave( err ); |
|
89 } |
|
90 |
|
91 User::LeaveIfError(iFmTxIsAvailableProperty.Attach(KPSUidHWRMFmTx, KHWRMFmTxAvailableFlag)); |
|
92 User::LeaveIfError(iFmTxIsAvailableProperty.Set(EFalse/*not available*/)); |
|
93 |
|
94 // Audio Policy will publish these P&S values |
|
95 TInt defineErr; |
|
96 |
|
97 #ifdef INSECURE_AUDIO_POLICY_KEYS |
|
98 // Allow test applications to publish audio routed flag |
|
99 defineErr = RProperty::Define( KHWRMFmTxAudioRoutedFlag, RProperty::EInt, KAlwaysPassPolicy, KAlwaysPassPolicy ); |
|
100 #else |
|
101 defineErr = RProperty::Define( KHWRMFmTxAudioRoutedFlag, |
|
102 RProperty::EInt, |
|
103 KHWRMSidOnlyPolicy, |
|
104 audioPolicy ); |
|
105 #endif // INSECURE_AUDIO_POLICY_KEYS |
|
106 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxCommonData::ConstructL() KHWRMFmTxAudioRoutedFlag defineErr %d" ), defineErr ); |
|
107 if( KErrNone != defineErr && |
|
108 KErrAlreadyExists != defineErr ) |
|
109 { |
|
110 User::Leave(defineErr); |
|
111 } |
|
112 User::LeaveIfError(iFmTxAudioRoutingProperty.Attach(KPSUidHWRMFmTx, KHWRMFmTxAudioRoutedFlag)); |
|
113 |
|
114 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxCommonData::ConstructL - return " ) ); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CHWRMFmTxCommonData::NewL |
|
119 // Two-phased constructor. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 CHWRMFmTxCommonData* CHWRMFmTxCommonData::NewL() |
|
123 { |
|
124 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxCommonData::NewL()" ) ); |
|
125 |
|
126 CHWRMFmTxCommonData* self = new( ELeave ) CHWRMFmTxCommonData(); |
|
127 |
|
128 CleanupStack::PushL( self ); |
|
129 self->ConstructL(); |
|
130 CleanupStack::Pop( self ); |
|
131 |
|
132 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxCommonData::NewL - return 0x%x" ), self ); |
|
133 |
|
134 return self; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------- |
|
138 // Destructor |
|
139 // --------------------------------------------------------- |
|
140 // |
|
141 CHWRMFmTxCommonData::~CHWRMFmTxCommonData() |
|
142 { |
|
143 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxCommonData::~CHWRMFmTxCommonData()" ) ); |
|
144 |
|
145 delete iRdsTextConverter; |
|
146 |
|
147 // clean up central repository related data |
|
148 CleanCenrep(); |
|
149 |
|
150 // close properties |
|
151 iFmTxStatusProperty.Close(); |
|
152 iFmTxIsAvailableProperty.Close(); |
|
153 |
|
154 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxCommonData::~CHWRMFmTxCommonData - return" ) ); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CHWRMFmTxCommonData::ProcessIndicationL |
|
159 // Handles status change indications from HWRM plugin |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CHWRMFmTxCommonData::ProcessIndicationL( const TUint32 aId, TDesC8& aData ) |
|
163 { |
|
164 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxCommonData::ProcessIndicationL, aId = %d" ), aId ); |
|
165 |
|
166 switch ( aId ) |
|
167 { |
|
168 case HWRMFmTxCommand::ETxStatusIndId: |
|
169 { |
|
170 // Check data size |
|
171 if ( aData.Size() != sizeof(HWRMFmTxCommand::TFmTxStatusData) ) |
|
172 { |
|
173 COMPONENT_TRACE3( _L( "HWRM Server - CHWRMFmTxCommonData::ProcessIndicationL data size error 0x%x, 0x%x" ), aData.Size(), sizeof(HWRMFmTxCommand::TFmTxStatusData) ); |
|
174 return; // Ignore indication when data size is invalid |
|
175 } |
|
176 |
|
177 // Unpack the new status |
|
178 HWRMFmTxCommand::TStatusIndicationPackage statusPckg; |
|
179 statusPckg.Copy(aData); |
|
180 HWRMFmTxCommand::TFmTxStatusData status = statusPckg(); |
|
181 |
|
182 TFmTxStateTransition stateTrans = EFmTxStateTransOff; |
|
183 if ( status.state == HWRMFmTxCommand::EFmTxHwStateOn ) |
|
184 { |
|
185 stateTrans = EFmTxStateTransOn; |
|
186 |
|
187 // Store the new frequency, when FM Tx is enabled |
|
188 UpdateFrequency(status.frequency); |
|
189 } |
|
190 else if ( status.state == HWRMFmTxCommand::EFmTxHwStateScanning ) |
|
191 { |
|
192 stateTrans = EFmTxStateTransScanning; |
|
193 } |
|
194 |
|
195 // Store the new status |
|
196 UpdateStatus(stateTrans); |
|
197 } |
|
198 break; |
|
199 |
|
200 default: |
|
201 // do nothing |
|
202 break; |
|
203 } |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CHWRMFmTxCommonData::UpdateStatus |
|
208 // Updates the common state data, after response/indication from the FM Tx plug-in |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 void CHWRMFmTxCommonData::UpdateStatus(TFmTxStateTransition aEvent) |
|
212 { |
|
213 COMPONENT_TRACE4(_L("HWRM Server - CHWRMFmTxCommonData::UpdateStatus(0x%x, 0x%x, 0x%x)"), aEvent, iFmTxPowerSaveFlag, iFmTxAudioRoutedFlag ); |
|
214 |
|
215 TFmTxState newState(EFmTxStateUnknown); |
|
216 |
|
217 // Establish the newState |
|
218 switch ( aEvent ) |
|
219 { |
|
220 case EFmTxStateTransError: |
|
221 { |
|
222 newState = EFmTxStateUnknown; |
|
223 } |
|
224 break; |
|
225 |
|
226 case EFmTxStateTransOff: |
|
227 { |
|
228 if ( IsPowerSaveOn() ) |
|
229 { |
|
230 // The "power save" flag triggered a disable request |
|
231 newState = (iFmTxPowerSaveFlag == EHWRMFmTxPowerSaveInactivity) ? EFmTxStatePowerSaveInactivity : EFmTxStatePowerSaveAccessory; |
|
232 } |
|
233 else |
|
234 { |
|
235 // FM Tx has been disabled automatically |
|
236 newState = EFmTxStateOff; |
|
237 } |
|
238 } |
|
239 break; |
|
240 |
|
241 case EFmTxStateTransRequestedOff: |
|
242 { |
|
243 // User has disabled FM Tx |
|
244 newState = EFmTxStateOff; |
|
245 } |
|
246 break; |
|
247 |
|
248 case EFmTxStateTransOn: |
|
249 { |
|
250 if ( iFmTxAudioRoutedFlag != EFalse ) |
|
251 { |
|
252 newState = EFmTxStateActive; |
|
253 } |
|
254 else |
|
255 { |
|
256 newState = EFmTxStateInactive; |
|
257 } |
|
258 } |
|
259 break; |
|
260 |
|
261 case EFmTxStateTransScanning: |
|
262 { |
|
263 newState = EFmTxStateScanning; |
|
264 } |
|
265 break; |
|
266 |
|
267 default: |
|
268 { |
|
269 newState = EFmTxStateUnknown; |
|
270 } |
|
271 break; |
|
272 } |
|
273 |
|
274 // Update if the state has changed |
|
275 if ( newState != iFmTxState) |
|
276 { |
|
277 // Notify Audio Policy first |
|
278 THWRMFmTxAvailableFlag nowAvailable = FmTxAvailableState(newState); |
|
279 THWRMFmTxAvailableFlag wasAvailable = FmTxAvailableState(iFmTxState); |
|
280 |
|
281 if ( nowAvailable != wasAvailable ) |
|
282 { |
|
283 COMPONENT_TRACE2(_L("HWRM Server - CHWRMFmTxCommonData::UpdateStatus - Audio Policy notification: %d"), nowAvailable ); |
|
284 TInt err = iFmTxIsAvailableProperty.Set(nowAvailable); |
|
285 if ( err != KErrNone ) |
|
286 { |
|
287 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateStatus - Audio Policy notification failed: %d"), err ); |
|
288 } |
|
289 |
|
290 // Update power save status if Fm Tx is available |
|
291 if( nowAvailable == EHWRMFmTxAvailableOn ) |
|
292 { |
|
293 UpdatePowerSaveState( CHWRMFmTxCommonData::EHWRMFmTxPowerSaveOff ); |
|
294 } |
|
295 } |
|
296 |
|
297 // Update state |
|
298 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateStatus - Setting state to: 0x%x"), newState ); |
|
299 iFmTxState = newState; |
|
300 |
|
301 // Publish new state |
|
302 TInt err = iFmTxStatusProperty.Set(iFmTxState); |
|
303 if ( err != KErrNone ) |
|
304 { |
|
305 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateStatus - Property set failed: %d"), err ); |
|
306 } |
|
307 } |
|
308 |
|
309 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxCommonData::UpdateStatus - return")); |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // CHWRMFmTxCommonData::FmTxAvailableState |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 THWRMFmTxAvailableFlag CHWRMFmTxCommonData::FmTxAvailableState( TFmTxState aState ) const |
|
317 { |
|
318 if( aState == EFmTxStatePowerSaveInactivity ) |
|
319 { |
|
320 return EHWRMFmTxAvailableStandby; |
|
321 } |
|
322 else if( aState == EFmTxStateUnknown || aState == EFmTxStateOff || |
|
323 aState == EFmTxStatePowerSaveAccessory ) |
|
324 { |
|
325 return EHWRMFmTxAvailableOff; |
|
326 } |
|
327 else |
|
328 { |
|
329 return EHWRMFmTxAvailableOn; |
|
330 } |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // CHWRMFmTxCommonData::UpdateAudioStatus |
|
335 // Updates the common state data, after Audio Policy flag has been set/cleared |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void CHWRMFmTxCommonData::UpdateAudioStatus( TInt aAudioRoutedFlag ) |
|
339 { |
|
340 if ( aAudioRoutedFlag ) |
|
341 { |
|
342 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::UpdateAudioStatus - Audio Activated") ) ); |
|
343 |
|
344 // State transition from EFmTxStateInactive -> EFmTxStateActive |
|
345 if ( iFmTxState == EFmTxStateInactive ) |
|
346 { |
|
347 iFmTxState = EFmTxStateActive; |
|
348 |
|
349 TInt err = iFmTxStatusProperty.Set(iFmTxState); |
|
350 if ( err != KErrNone ) |
|
351 { |
|
352 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateAudioStatus - Property set failed: %d"), err ); |
|
353 } |
|
354 } |
|
355 |
|
356 // Cache audio routed flag |
|
357 iFmTxAudioRoutedFlag = ETrue; |
|
358 } |
|
359 else |
|
360 { |
|
361 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxCommonData::UpdateAudioStatus - Audio Deactivated") ); |
|
362 |
|
363 // State transition from EFmTxStateActive -> EFmTxStateInactive |
|
364 if ( iFmTxState == EFmTxStateActive ) |
|
365 { |
|
366 iFmTxState = EFmTxStateInactive; |
|
367 |
|
368 TInt err = iFmTxStatusProperty.Set(iFmTxState); |
|
369 if ( err != KErrNone ) |
|
370 { |
|
371 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateAudioStatus - Property set failed: %d"), err ); |
|
372 } |
|
373 } |
|
374 |
|
375 // Cache audio routed flag |
|
376 iFmTxAudioRoutedFlag = EFalse; |
|
377 } |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CHWRMFmTxCommonData::UpdateFrequency |
|
382 // Updates the common frequency data, after response from the FM Tx plug-in |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 void CHWRMFmTxCommonData::UpdateFrequency(TInt aFrequency) |
|
386 { |
|
387 COMPONENT_TRACE3( _L("HWRM Server - CHWRMFmTxCommonData::UpdateFrequency(%d, %d)"), aFrequency, iFmTxFrequency ); |
|
388 |
|
389 if ( aFrequency != iFmTxFrequency ) |
|
390 { |
|
391 iFmTxFrequency = aFrequency; |
|
392 iRepository->Set(KFmTxCenResKeyFrequency, aFrequency); // ignore errors |
|
393 } |
|
394 } |
|
395 |
|
396 // ----------------------------------------------------------------------------- |
|
397 // CHWRMFmTxCommonData::UpdateRdsPty |
|
398 // Update the common PTY data, after response from the FM Tx plug-in |
|
399 // ----------------------------------------------------------------------------- |
|
400 // |
|
401 void CHWRMFmTxCommonData::UpdateRdsPty(const TRdsProgrammeType aPty) |
|
402 { |
|
403 COMPONENT_TRACE3( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPty %d, %d"), iRdsData.iPty, aPty ); |
|
404 |
|
405 if ( aPty != iRdsData.iPty) |
|
406 { |
|
407 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPty - Setting PTY") ); |
|
408 |
|
409 // Publish new RDS settings |
|
410 TInt err = RProperty::Define(KHWRMFmTxRdsPty, RProperty::EInt, KNoCapability, KHWRMSidOnlyPolicy); |
|
411 if ( err == KErrNone || err == KErrAlreadyExists ) |
|
412 { |
|
413 err = RProperty::Set(KPSUidHWRMFmTx, KHWRMFmTxRdsPty, aPty); |
|
414 if ( err != KErrNone ) |
|
415 { |
|
416 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPty - Property set failed: %d"), err ); |
|
417 } |
|
418 } |
|
419 else |
|
420 { |
|
421 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPty - Property define failed: %d"), err ); |
|
422 } |
|
423 |
|
424 // Update cached data |
|
425 iRdsData.iPty = aPty; |
|
426 } |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CHWRMFmTxCommonData::UpdateRdsPtyn |
|
431 // Update the common PTYN data, after response from the FM Tx plug-in |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 void CHWRMFmTxCommonData::UpdateRdsPtyn(const TRdsProgrammeTypeName& aPtyn) |
|
435 { |
|
436 COMPONENT_TRACE3( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPtyn %S, %S"), &iRdsData.iPtyn, &aPtyn ); |
|
437 |
|
438 if ( aPtyn.Compare(iRdsData.iPtyn) ) |
|
439 { |
|
440 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPtyn - Setting PTYN") ); |
|
441 |
|
442 // Publish new RDS settings |
|
443 TInt err = RProperty::Define(KHWRMFmTxRdsPtyn, RProperty::EText, KNoCapability, KHWRMSidOnlyPolicy); |
|
444 if ( err == KErrNone || err == KErrAlreadyExists ) |
|
445 { |
|
446 err = RProperty::Set(KPSUidHWRMFmTx, KHWRMFmTxRdsPtyn, aPtyn); |
|
447 if ( err != KErrNone ) |
|
448 { |
|
449 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPtyn - Property set failed: %d"), err ); |
|
450 } |
|
451 } |
|
452 else |
|
453 { |
|
454 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPtyn - Property define failed: %d"), err ); |
|
455 } |
|
456 |
|
457 // Store converted 8bit version for convenience |
|
458 TRAP(err, iRdsTextConverter->ConvertFromUnicodeL(aPtyn, iRdsConvertedPtyn) ); |
|
459 if (err != KErrNone) |
|
460 { |
|
461 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsPtyn - error converting PTYN") ); |
|
462 // ignore error |
|
463 } |
|
464 |
|
465 // Update cached data |
|
466 iRdsData.iPtyn.Copy(aPtyn); |
|
467 } |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CHWRMFmTxCommonData::UpdateRdsMs |
|
472 // Update the common MS data, after response from the FM Tx plug-in |
|
473 // ----------------------------------------------------------------------------- |
|
474 // |
|
475 void CHWRMFmTxCommonData::UpdateRdsMs(const TBool aMusic) |
|
476 { |
|
477 COMPONENT_TRACE3( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsMs %d, %d"), iRdsData.iMs, aMusic ); |
|
478 |
|
479 if ( aMusic != iRdsData.iMs) |
|
480 { |
|
481 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsMs - Setting MS") ); |
|
482 |
|
483 // Publish new RDS settings |
|
484 TInt err = RProperty::Define(KHWRMFmTxRdsMs, RProperty::EInt, KNoCapability, KHWRMSidOnlyPolicy); |
|
485 if ( err == KErrNone || err == KErrAlreadyExists ) |
|
486 { |
|
487 TInt value = (aMusic == EFalse) ? 0 : 1; |
|
488 err = RProperty::Set(KPSUidHWRMFmTx, KHWRMFmTxRdsMs, value); |
|
489 if ( err != KErrNone ) |
|
490 { |
|
491 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsMs - Property set failed: %d"), err ); |
|
492 } |
|
493 } |
|
494 else |
|
495 { |
|
496 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsMs - Property define failed: %d"), err ); |
|
497 } |
|
498 |
|
499 // Update cached data |
|
500 iRdsData.iMs = aMusic; |
|
501 } |
|
502 } |
|
503 |
|
504 // ----------------------------------------------------------------------------- |
|
505 // CHWRMFmTxCommonData::UpdateRdsLanguageId |
|
506 // Update the common language ID data, after response from the FM Tx plug-in |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 void CHWRMFmTxCommonData::UpdateRdsLanguageId(const TRdsLanguageIdType aLanguageId) |
|
510 { |
|
511 COMPONENT_TRACE3( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsLanguageId %d, %d"), iRdsData.iLanguageId, aLanguageId ); |
|
512 |
|
513 if ( aLanguageId != iRdsData.iLanguageId) |
|
514 { |
|
515 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsLanguageId - Setting language ID") ); |
|
516 |
|
517 // Publish new RDS settings |
|
518 TInt err = RProperty::Define(KHWRMFmTxRdsLangId, RProperty::EInt, KNoCapability, KHWRMSidOnlyPolicy); |
|
519 if ( err == KErrNone || err == KErrAlreadyExists ) |
|
520 { |
|
521 TInt err = RProperty::Set(KPSUidHWRMFmTx, KHWRMFmTxRdsLangId, aLanguageId); |
|
522 if ( err != KErrNone ) |
|
523 { |
|
524 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsLanguageId - Property set failed: %d"), err ); |
|
525 } |
|
526 } |
|
527 else |
|
528 { |
|
529 COMPONENT_TRACE2( _L("HWRM Server - CHWRMFmTxCommonData::UpdateRdsLanguageId - Property define failed: %d"), err ); |
|
530 } |
|
531 |
|
532 iRdsData.iLanguageId = aLanguageId; |
|
533 } |
|
534 } |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // CHWRMFmTxCommonData::SetFrequencyRange |
|
538 // Set the Central Repository data, frequency range and step size |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 void CHWRMFmTxCommonData::SetFrequencyRange(TInt aMinFrequency, TInt aMaxFrequency, TInt aStepSize) |
|
542 { |
|
543 COMPONENT_TRACE4( _L("HWRM Server - CHWRMFmTxCommonData::SetFrequencyRange(%d, %d, %d)"), aMinFrequency, aMaxFrequency, aStepSize ); |
|
544 |
|
545 if ( iRepository->Set(KFmTxCenResKeyMinFrequency, aMinFrequency) == KErrNone && |
|
546 iRepository->Set(KFmTxCenResKeyMaxFrequency, aMaxFrequency) == KErrNone && |
|
547 iRepository->Set(KFmTxCenResKeyStepSize, aStepSize) == KErrNone ) |
|
548 { |
|
549 iFrequencyRangeUpdated = ETrue; |
|
550 } |
|
551 else |
|
552 { |
|
553 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::SetFrequencyRange CenRep error") ) ); |
|
554 // Not much we can do about this. Ignore error. |
|
555 } |
|
556 |
|
557 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::SetFrequencyRange - return")) ); |
|
558 } |
|
559 |
|
560 // ----------------------------------------------------------------------------- |
|
561 // CHWRMFmTxCommonData::CleanCenrep |
|
562 // Cleans the central repository related functionality. |
|
563 // ----------------------------------------------------------------------------- |
|
564 // |
|
565 void CHWRMFmTxCommonData::CleanCenrep() |
|
566 { |
|
567 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::CleanCenrep()") ) ); |
|
568 |
|
569 delete iRepository; |
|
570 iRepository = NULL; |
|
571 |
|
572 COMPONENT_TRACE1( ( _L( "HWRM Server - CHWRMFmTxCommonData::CleanCenrep - return" ) ) ); |
|
573 } |
|
574 |
|
575 // ----------------------------------------------------------------------------- |
|
576 // CHWRMFmTxCommonData::InitCenrepL |
|
577 // Starts the central repository related functionality. |
|
578 // ----------------------------------------------------------------------------- |
|
579 // |
|
580 void CHWRMFmTxCommonData::InitCenrepL() |
|
581 { |
|
582 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::InitCenrepL()") ) ); |
|
583 |
|
584 iRepository = CRepository::NewL(KCRUidFmTxCenRes); |
|
585 |
|
586 // Get the RDS replacement char. Do this first, so iRdsTextConverter can be used |
|
587 TInt replacementChar; |
|
588 User::LeaveIfError(iRepository->Get(KFmTxCenResKeyRdsReplacementChar, replacementChar)); |
|
589 iRdsTextConverter->SetUnsupportedCharReplacement( (TText8)replacementChar ); |
|
590 |
|
591 // Get previously used FM Tx frequency |
|
592 User::LeaveIfError(iRepository->Get(KFmTxCenResKeyFrequency, iFmTxFrequency)); |
|
593 |
|
594 // Get FM frequency range |
|
595 TInt minFreq, maxFreq, stepSize; |
|
596 User::LeaveIfError(iRepository->Get(KFmTxCenResKeyMinFrequency, minFreq)); |
|
597 User::LeaveIfError(iRepository->Get(KFmTxCenResKeyMaxFrequency, maxFreq)); |
|
598 User::LeaveIfError(iRepository->Get(KFmTxCenResKeyStepSize, stepSize)); |
|
599 |
|
600 // Flag whether frequency range has been updated |
|
601 if ( minFreq!=0 && maxFreq!=0 && stepSize!=0 ) |
|
602 { |
|
603 iFrequencyRangeUpdated = ETrue; |
|
604 } |
|
605 |
|
606 // Read PS string from CenRep |
|
607 TRdsProgrammeService ps; |
|
608 User::LeaveIfError(iRepository->Get(KFmTxCenResKeyRdsPs, ps)); |
|
609 iRdsTextConverter->ConvertFromUnicodeL(ps, iRdsConvertedPs); // store in 8bit RDS format |
|
610 iRdsConvertedPs.AppendFill( KRdsSpaceChar, iRdsConvertedPs.MaxLength() - iRdsConvertedPs.Length() ); // pad with spaces |
|
611 |
|
612 // Get audio policy related configuration |
|
613 TInt value(0); |
|
614 User::LeaveIfError(iRepository->Get(KFmTxCenResKeyAudioPolicySid, value)); |
|
615 iFmTxAudioRoutingSid = TSecureId(value); |
|
616 User::LeaveIfError(iRepository->Get(KFmTxCenResKeyPowerSaveTimerLength, value)); |
|
617 iFmTxPowerSaveTimeout = value*KSecondsToMicros; |
|
618 |
|
619 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::InitCenrepL - return") ) ); |
|
620 } |
|
621 |
|
622 // ----------------------------------------------------------------------------- |
|
623 // CHWRMFmTxCommonData::UpdatePowerSaveState |
|
624 // ----------------------------------------------------------------------------- |
|
625 // |
|
626 void CHWRMFmTxCommonData::UpdatePowerSaveState( TFmTxPowerSaveFlag aState ) |
|
627 { |
|
628 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::UpdatePowerSaveState()")) ); |
|
629 |
|
630 iFmTxPowerSaveFlag = aState; |
|
631 } |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // CHWRMFmTxCommonData::IsPowerSaveOn |
|
635 // ----------------------------------------------------------------------------- |
|
636 // |
|
637 TBool CHWRMFmTxCommonData::IsPowerSaveOn() |
|
638 { |
|
639 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::IsPowerSaveOn()")) ); |
|
640 |
|
641 return (iFmTxPowerSaveFlag != EHWRMFmTxPowerSaveOff); |
|
642 } |
|
643 |
|
644 // ----------------------------------------------------------------------------- |
|
645 // CHWRMFmTxCommonData::IsAccessoryPowerSaveOn |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 TBool CHWRMFmTxCommonData::IsAccessoryPowerSaveOn() |
|
649 { |
|
650 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::IsAccessoryPowerSaveOn()")) ); |
|
651 |
|
652 return (iFmTxPowerSaveFlag == EHWRMFmTxPowerSaveAccessory); |
|
653 } |
|
654 |
|
655 // ----------------------------------------------------------------------------- |
|
656 // CHWRMFmTxCommonData::IsAudioRouted |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 TBool CHWRMFmTxCommonData::IsAudioRouted() |
|
660 { |
|
661 COMPONENT_TRACE1( (_L("HWRM Server - CHWRMFmTxCommonData::IsAudioRouted()")) ); |
|
662 TBool audioRouted; |
|
663 |
|
664 if( iFmTxAudioRoutingProperty.Get( audioRouted ) == KErrNone) |
|
665 { |
|
666 iFmTxAudioRoutedFlag = audioRouted; |
|
667 } |
|
668 |
|
669 return iFmTxAudioRoutedFlag; |
|
670 } |
|
671 |
|
672 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
673 |
|
674 // End of File |