audiostubs/fmradiotunercontrolstub/Src/FMRadioTunerControlStub.cpp
changeset 0 0ce1b5ce9557
child 3 f935d51494d1
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     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:	
       
    15 *			Contains implementation of the CAdaptation class.
       
    16 *			Which holds RadioServer Console Test.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include 	<e32svr.h>
       
    24 #include    "FMRadioTunerControlStub.h"
       
    25 
       
    26 // CONSTANTS
       
    27 const TInt KReqTunerOn				= 1;
       
    28 const TInt KReqTunerOff				= 2;
       
    29 const TInt KReqSetFrequencyRange	= 3;
       
    30 const TInt KReqSetFrequency			= 4;
       
    31 const TInt KReqStationSeek			= 5;
       
    32 const TInt KReqAudioMode			= 6;
       
    33 const TInt KReqSetAudioMode			= 7;
       
    34 const TInt KReqMaxSignalStrength	= 8;
       
    35 const TInt KReqSignalStrength		= 9;
       
    36 const TInt KReqSquelch				= 10;
       
    37 const TInt KReqSetSquelch			= 11;
       
    38 //---------------------------------------
       
    39 const TInt KReqStationSeekByPTY		= 12;
       
    40 const TInt KReqStationSeekByTA		= 13;
       
    41 const TInt KReqStationSeekByTP		= 14;
       
    42 const TInt KReqGetFreqByPTY			= 15;
       
    43 const TInt KReqGetFreqByTA			= 16;
       
    44 const TInt KReqGetPSByPTY			= 17;
       
    45 const TInt KReqGetPSByTA			= 18;
       
    46 
       
    47 const TInt KEuroAmericaMin	=  87500000;
       
    48 const TInt KEuroAmericaMax	= 108000000;
       
    49 const TInt KJapanMin		=  76000000;
       
    50 const TInt KJapanMax		=  90000000;
       
    51 
       
    52 /*
       
    53 KCBI 	 90.9	PTY = KRdsPtyReligion
       
    54 KLTY 	 94.9	PTY = KRdsPtyReligion
       
    55 KVIL	103.7	PTY = KRdsPtyLightClassical
       
    56 KHKS	106.1	PTY = KRdsPtyRockMusic
       
    57 */
       
    58 
       
    59 const TInt KFrequency1	=	 90900000;	// TA, TP
       
    60 const TInt KFrequency2	=	 94900000;	// Alternate Frequency of KFrequency1
       
    61 const TInt KFrequency3	=	103700000;
       
    62 const TInt KFrequency4	=	106100000;	// TP
       
    63 
       
    64 // DATA TYPES
       
    65 struct TRadioMessageRequestData
       
    66 	{
       
    67 	TSglQueLink iLink;
       
    68 	TInt iRequest;
       
    69 	TInt iError;
       
    70 	};
       
    71 
       
    72 // ============================= LOCAL FUNCTIONS ===============================
       
    73 
       
    74 /**
       
    75 *  Class CTuner
       
    76 *  @lib FMRadioTunerControlStub.lib
       
    77 *  @since Series 60 3.0
       
    78 */
       
    79 class CTuner : public CTimer
       
    80     {
       
    81 	public:
       
    82 		static CTuner* NewL( MFMRadioTunerControlObserver& aObserver )
       
    83 			{
       
    84 			CTuner* self = new( ELeave ) CTuner(aObserver);
       
    85 			CleanupStack::PushL( self );
       
    86 		    self->ConstructL();
       
    87 		    CleanupStack::Pop();
       
    88 		    return self;
       
    89 			};
       
    90 
       
    91 		virtual ~CTuner()
       
    92 			{
       
    93 			iFreqList.Close();
       
    94 			iPsList.Close();
       
    95 			iRTplusTags.Close();
       
    96 			if ( IsActive() )
       
    97 				{
       
    98 				Cancel();
       
    99 				}
       
   100 			TRadioMessageRequestData* data;
       
   101 			while ( !iRequestQue.IsEmpty() )
       
   102 				{
       
   103 				data = iRequestQue.First();
       
   104 				iRequestQue.Remove(*data);
       
   105 				delete data;
       
   106 				}
       
   107 			};
       
   108 
       
   109 		void CompleteRequest( TInt aRequest, TInt aError )
       
   110 			{
       
   111 			TRadioMessageRequestData *data = new (ELeave) TRadioMessageRequestData;
       
   112 			data->iRequest = aRequest;
       
   113 			data->iError = aError;
       
   114 			// Add it to the queue
       
   115 			iRequestQue.AddLast(*data);
       
   116 			if ( !IsActive() )
       
   117 				{
       
   118 				After(500000);	// 0.5 sec by default
       
   119 				}
       
   120 			};
       
   121 
       
   122 		void Reset()
       
   123 			{
       
   124 			iTunerOn = EFalse;
       
   125 			iRange = EFMRadioFrequencyEuroAmerica;
       
   126 			iFrequency = KEuroAmericaMin;
       
   127 			iSigStrength = 0;
       
   128 			iMode = EFMRadioAudioStereo;
       
   129 			iSquelch = ETrue;
       
   130 			ResetRds();
       
   131 			};
       
   132 
       
   133 		void ResetRds()
       
   134 			{
       
   135 			iNotifyOn = EFalse;
       
   136 			iRdsSignal = EFalse;
       
   137 			iRdsData = 0;
       
   138 			iAutoSwitch = EFalse;
       
   139 			iFreqList.Reset();
       
   140 			iPsList.Reset();
       
   141 			iPi = 0;
       
   142 			iPty = KRdsPtyNone;
       
   143 			iPs = _L8("");
       
   144 			iRt = _L8("");
       
   145 			iRTplusTags.Reset();
       
   146 			// Hardcoded to 2007/11/10 7:35
       
   147 			iCt.Set(2007,ENovember,10,7,35,0,0);
       
   148 			};
       
   149 
       
   150 		void SendRdsData()
       
   151 			{
       
   152 			// Make sure we are still in RDS channel
       
   153 			if ( !iRdsSignal || !iNotifyOn )
       
   154 				{
       
   155 				return;
       
   156 				}
       
   157 
       
   158 			if( iRdsData & ERdsProgrammeIdentification )
       
   159 				{
       
   160 				iRdsObserver->RdsDataPI(iPi);
       
   161 				}
       
   162 			if( iRdsData & ERdsProgrammeType )
       
   163 				{
       
   164 				iRdsObserver->RdsDataPTY(iPty);
       
   165 				}
       
   166 			if( iRdsData & ERdsProgrammeService )
       
   167 				{
       
   168 				iRdsObserver->RdsDataPS(iPs);
       
   169 				}
       
   170 			if( iRdsData & ERdsRadioText )
       
   171 				{
       
   172 				iRdsObserver->RdsDataRT(iRt, iRTplusTags);
       
   173 				}
       
   174 			if( iRdsData & ERdsClockTime )
       
   175 				{
       
   176 				iRdsObserver->RdsDataCT(iCt);
       
   177 				}
       
   178 			};
       
   179 
       
   180 		void SendRdsAf(TBool aBegin)
       
   181 			{
       
   182 			if (aBegin)
       
   183 				{
       
   184 				iRdsObserver->RdsSearchBeginAF();
       
   185 				}
       
   186 			else
       
   187 				{
       
   188 				iFrequency = KFrequency2;
       
   189 				iSigStrength = 2;
       
   190 				iPs = _L8("KLTY");
       
   191 				iRdsObserver->RdsSearchEndAF(iError, iFrequency);
       
   192 				}
       
   193 			};
       
   194 
       
   195 
       
   196     private:
       
   197 		void DoCancel()
       
   198 			{};
       
   199 
       
   200 		void RunL()
       
   201 			{
       
   202 			TRadioMessageRequestData* data;
       
   203 			data = iRequestQue.First();
       
   204 			iRequestQue.Remove(*data);
       
   205 			iRequest = data->iRequest;
       
   206 			iError = data->iError;
       
   207 			delete data;
       
   208 
       
   209 			switch (iRequest)
       
   210 				{
       
   211 				case KReqTunerOn:
       
   212 					iObserver->TunerOnComplete(iError);
       
   213 					break;
       
   214 				case KReqTunerOff:
       
   215 					iObserver->TunerOffComplete(iError);
       
   216 					break;
       
   217 				case KReqSetFrequencyRange:
       
   218 					iObserver->SetFrequencyRangeComplete(iError);
       
   219 					break;
       
   220 				case KReqSetFrequency:
       
   221 					iObserver->SetFrequencyComplete(iError);
       
   222 					break;
       
   223 				case KReqStationSeek:
       
   224 					iObserver->StationSeekComplete(iError, iFrequency);
       
   225 					break;
       
   226 				case KReqAudioMode:
       
   227 					iObserver->AudioModeComplete(iError, iMode);
       
   228 					break;
       
   229 				case KReqSetAudioMode:
       
   230 					iObserver->SetAudioModeComplete(iError);
       
   231 					break;
       
   232 				case KReqMaxSignalStrength:
       
   233 					iObserver->MaxSignalStrengthComplete(iError, 15);
       
   234 					break;
       
   235 				case KReqSignalStrength:
       
   236 					iObserver->SignalStrengthComplete(iError, iSigStrength);
       
   237 					break;
       
   238 				case KReqSquelch:
       
   239 					iObserver->SquelchComplete(iError, iSquelch);
       
   240 					break;
       
   241 				case KReqSetSquelch:
       
   242 					iObserver->SetSquelchComplete(iError);
       
   243 					break;
       
   244 // -----------------------------------------------------------------------------
       
   245 //		RDS
       
   246 				case KReqStationSeekByPTY:
       
   247 					iRdsObserver->StationSeekByPTYComplete(iError, iFrequency);
       
   248 					break;
       
   249 				case KReqStationSeekByTA:
       
   250 					iRdsObserver->StationSeekByTAComplete(iError, iFrequency);
       
   251 					break;
       
   252 				case KReqStationSeekByTP:
       
   253 					iRdsObserver->StationSeekByTPComplete(iError, iFrequency);
       
   254 					break;
       
   255 				case KReqGetFreqByPTY:
       
   256 					iRdsObserver->GetFreqByPTYComplete(iError, iFreqList);
       
   257 					break;
       
   258 				case KReqGetFreqByTA:
       
   259 					iRdsObserver->GetFreqByTAComplete(iError, iFreqList);
       
   260 					break;
       
   261 				case KReqGetPSByPTY:
       
   262 					iRdsObserver->GetPSByPTYComplete(iError, iPsList);
       
   263 					break;
       
   264 				case KReqGetPSByTA:
       
   265 					iRdsObserver->GetPSByTAComplete(iError, iPsList);
       
   266 					break;
       
   267 //		RDS
       
   268 // -----------------------------------------------------------------------------
       
   269 				default:
       
   270 					break;
       
   271 				}
       
   272 
       
   273 			// Process the next item in the queue if any
       
   274 			if ( !iRequestQue.IsEmpty() )
       
   275 				{
       
   276 				// there is at least one element in the linked list
       
   277 				After(100000);	// 0.1 sec by default
       
   278 				}
       
   279 			};
       
   280 
       
   281     private:
       
   282         CTuner( MFMRadioTunerControlObserver& aObserver )
       
   283         	:	CTimer(EPriorityStandard),
       
   284         		iObserver(&aObserver),
       
   285         		iRdsObserver(NULL),
       
   286         		iRequestQue(_FOFF( TRadioMessageRequestData, iLink ))
       
   287         	{};
       
   288 
       
   289         void ConstructL()
       
   290         	{
       
   291         	CTimer::ConstructL();
       
   292 			CActiveScheduler::Add(this);
       
   293 			Reset();
       
   294 			};
       
   295 
       
   296     private:    // Data
       
   297     	// Tuner observer
       
   298     	MFMRadioTunerControlObserver* iObserver;
       
   299 		// Rds observer
       
   300 		MRdsControlObserver* iRdsObserver;
       
   301 		// Request queue
       
   302 		TSglQue<TRadioMessageRequestData> iRequestQue;
       
   303     	// Outstanding request
       
   304     	TInt iRequest;
       
   305     	TInt iError;
       
   306 
       
   307 		// Tuner data
       
   308     	TBool iTunerOn;
       
   309     	TFMRadioFrequencyRange iRange;
       
   310 		TInt iFrequency;
       
   311 		TInt iSigStrength;
       
   312 		TFMRadioAudioMode iMode;
       
   313 		TBool iSquelch;
       
   314 
       
   315 		// RDS data
       
   316     	TBool iNotifyOn;
       
   317 		TBool iRdsSignal;
       
   318 		TUint32 iRdsData;
       
   319 		TBool iAutoSwitch;
       
   320 		RArray<TInt> iFreqList;
       
   321 		RArray<TRdsPSName> iPsList;
       
   322 		TInt iPi;
       
   323 		TRdsProgrammeType iPty;
       
   324 		TRdsPSName iPs;
       
   325 		TRdsRadioText iRt;
       
   326 		RArray<TRdsRTplusTag> iRTplusTags;
       
   327 		TDateTime iCt;
       
   328 
       
   329 	private:    // Friend classes
       
   330 		friend class CAdaptation;
       
   331 		friend class CRdsGenerator;
       
   332 	};
       
   333 
       
   334 /**
       
   335 *  Class CRdsGenerator
       
   336 *  @lib FMRadioTunerControlStub.lib
       
   337 *  @since Series 60 3.2
       
   338 */
       
   339 class CRdsGenerator : public CTimer
       
   340     {
       
   341 	public:
       
   342 		static CRdsGenerator* NewL(CTuner& aTuner)
       
   343 			{
       
   344 			CRdsGenerator* self = new( ELeave ) CRdsGenerator(aTuner);
       
   345 			CleanupStack::PushL( self );
       
   346 		    self->ConstructL();
       
   347 		    CleanupStack::Pop();
       
   348 		    return self;
       
   349 			};
       
   350 
       
   351 		virtual ~CRdsGenerator()
       
   352 			{
       
   353 			if ( IsActive() )
       
   354 				{
       
   355 				Cancel();
       
   356 				}
       
   357 			};
       
   358 
       
   359 		void Start()
       
   360 			{
       
   361 			if ( IsActive() )
       
   362 				{
       
   363 				Cancel();
       
   364 				}
       
   365 			After(1000000);	// 1 sec
       
   366 			};
       
   367 
       
   368     private:
       
   369 		void DoCancel()
       
   370 			{};
       
   371 
       
   372 		void RunL()
       
   373 			{
       
   374 			iTuner->SendRdsData();
       
   375 			};
       
   376 
       
   377     private:
       
   378         CRdsGenerator( CTuner& aTuner )
       
   379         	:	CTimer(EPriorityStandard),
       
   380         		iTuner(&aTuner)
       
   381         	{};
       
   382 
       
   383         void ConstructL()
       
   384         	{
       
   385         	CTimer::ConstructL();
       
   386 			CActiveScheduler::Add(this);
       
   387 			};
       
   388 
       
   389     private:    // Data
       
   390     	// Tuner
       
   391     	CTuner* iTuner;
       
   392 	};
       
   393 
       
   394 /**
       
   395 *  Class CAfSwitcher
       
   396 *  @lib FMRadioTunerControlStub.lib
       
   397 *  @since Series 60 3.2
       
   398 */
       
   399 class CAfSwitcher : public CTimer
       
   400     {
       
   401 	public:
       
   402 		static CAfSwitcher* NewL(CTuner& aTuner)
       
   403 			{
       
   404 			CAfSwitcher* self = new( ELeave ) CAfSwitcher(aTuner);
       
   405 			CleanupStack::PushL( self );
       
   406 		    self->ConstructL();
       
   407 		    CleanupStack::Pop();
       
   408 		    return self;
       
   409 			};
       
   410 
       
   411 		virtual ~CAfSwitcher()
       
   412 			{
       
   413 			if ( IsActive() )
       
   414 				{
       
   415 				Cancel();
       
   416 				}
       
   417 			};
       
   418 
       
   419 		void Start()
       
   420 			{
       
   421 			if ( IsActive() )
       
   422 				{
       
   423 				Cancel();
       
   424 				}
       
   425 			iBegin = ETrue;
       
   426 			After(3000000);	// 3 sec
       
   427 			};
       
   428 
       
   429     private:
       
   430 		void DoCancel()
       
   431 			{};
       
   432 
       
   433 		void RunL()
       
   434 			{
       
   435 			iTuner->SendRdsAf(iBegin);
       
   436 			if (iBegin)
       
   437 				{
       
   438 				iBegin = EFalse;
       
   439 				After(2000000);	// 2 sec
       
   440 				}
       
   441 			};
       
   442 
       
   443     private:
       
   444         CAfSwitcher( CTuner& aTuner )
       
   445         	:	CTimer(EPriorityStandard),
       
   446         		iTuner(&aTuner),
       
   447         		iBegin(EFalse)
       
   448         	{};
       
   449 
       
   450         void ConstructL()
       
   451         	{
       
   452         	CTimer::ConstructL();
       
   453 			CActiveScheduler::Add(this);
       
   454 			};
       
   455 
       
   456     private:    // Data
       
   457     	// Tuner
       
   458     	CTuner* iTuner;
       
   459     	TBool iBegin;
       
   460 	};
       
   461 
       
   462 EXPORT_C CFMRadioTunerControl* CFMRadioTunerControl::NewL(
       
   463 	MFMRadioTunerControlObserver& aObserver )
       
   464 	{
       
   465 	return CAdaptation::NewL(aObserver);
       
   466 	}
       
   467 
       
   468 // ============================ MEMBER FUNCTIONS ===============================
       
   469 
       
   470 // -----------------------------------------------------------------------------
       
   471 // CAdaptation::CAdaptation
       
   472 // C++ default constructor can NOT contain any code, that
       
   473 // might leave.
       
   474 // -----------------------------------------------------------------------------
       
   475 //
       
   476 CAdaptation::CAdaptation()
       
   477 	:	iTuner(NULL),
       
   478 		iRds(NULL),
       
   479 		iRdsAf(NULL)
       
   480     {
       
   481     }
       
   482 
       
   483 // -----------------------------------------------------------------------------
       
   484 // CAdaptation::ConstructL
       
   485 // Symbian 2nd phase constructor can leave.
       
   486 // -----------------------------------------------------------------------------
       
   487 //
       
   488 void CAdaptation::ConstructL(
       
   489 	MFMRadioTunerControlObserver& aObserver )
       
   490     {
       
   491 	iTuner = CTuner::NewL(aObserver);
       
   492 	iRds = CRdsGenerator::NewL(*iTuner);
       
   493 	iRdsAf = CAfSwitcher::NewL(*iTuner);
       
   494     }
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 // CAdaptation::NewL
       
   498 // Two-phased constructor.
       
   499 // -----------------------------------------------------------------------------
       
   500 //
       
   501 CAdaptation* CAdaptation::NewL(
       
   502 	MFMRadioTunerControlObserver& aObserver )
       
   503     {
       
   504     CAdaptation* self = new( ELeave ) CAdaptation();
       
   505     CleanupStack::PushL( self );
       
   506     self->ConstructL(aObserver);
       
   507     CleanupStack::Pop();
       
   508     return self;
       
   509     }
       
   510 
       
   511 // Destructor
       
   512 CAdaptation::~CAdaptation()
       
   513     {
       
   514 	delete iRdsAf;
       
   515 	delete iRds;
       
   516 	delete iTuner;
       
   517     }
       
   518 
       
   519 // -----------------------------------------------------------------------------
       
   520 //
       
   521 void CAdaptation::TunerOn(
       
   522 	TFMRadioFrequencyRange aRange,
       
   523 	TInt aFrequency )
       
   524 	{
       
   525 	if ( ValidFrequency(aRange, aFrequency) )
       
   526 		{
       
   527 		iTuner->iTunerOn = ETrue;
       
   528 		iTuner->iRange = aRange;
       
   529 		SetFrequencySettings(aFrequency);
       
   530 		iTuner->CompleteRequest(KReqTunerOn, KErrNone);
       
   531 		}
       
   532 	else
       
   533 		{
       
   534 		iTuner->CompleteRequest(KReqTunerOn, KFMRadioErrFrequencyOutOfBandRange);
       
   535 		}
       
   536 	}
       
   537 
       
   538 // -----------------------------------------------------------------------------
       
   539 //
       
   540 void CAdaptation::CancelTunerOn()
       
   541 	{
       
   542 	}
       
   543 
       
   544 // -----------------------------------------------------------------------------
       
   545 //
       
   546 void CAdaptation::TunerOff()
       
   547 	{
       
   548 	iTuner->Reset();
       
   549 	iTuner->CompleteRequest(KReqTunerOff, KErrNone);
       
   550 	}
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 //
       
   554 void CAdaptation::CancelTunerOff()
       
   555 	{
       
   556 	}
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 //
       
   560 void CAdaptation::SetFrequencyRange(
       
   561 	TFMRadioFrequencyRange aRange )
       
   562 	{
       
   563 	iTuner->iRange = aRange;
       
   564 	iTuner->CompleteRequest(KReqSetFrequencyRange, KErrNone);
       
   565 	}
       
   566 
       
   567 // -----------------------------------------------------------------------------
       
   568 //
       
   569 void CAdaptation::CancelSetFrequencyRange()
       
   570 	{
       
   571 	}
       
   572 
       
   573 // -----------------------------------------------------------------------------
       
   574 //
       
   575 void CAdaptation::SetFrequency(
       
   576 	TInt aFrequency )
       
   577 	{
       
   578 	if ( !iTuner->iTunerOn )
       
   579 		{
       
   580 		iTuner->CompleteRequest(KReqSetFrequency, KFMRadioErrNotPermittedInCurrentState);
       
   581 		return;
       
   582 		}
       
   583 
       
   584 	if ( ValidFrequency(iTuner->iRange, aFrequency) )
       
   585 		{
       
   586 		SetFrequencySettings(aFrequency);
       
   587 		iTuner->CompleteRequest(KReqSetFrequency, KErrNone);
       
   588 		}
       
   589 	else
       
   590 		{
       
   591 		iTuner->CompleteRequest(KReqTunerOn, KFMRadioErrFrequencyNotValid);
       
   592 		}
       
   593 	}
       
   594 
       
   595 // -----------------------------------------------------------------------------
       
   596 //
       
   597 void CAdaptation::CancelSetFrequency()
       
   598 	{
       
   599 	}
       
   600 
       
   601 // -----------------------------------------------------------------------------
       
   602 //
       
   603 void CAdaptation::StationSeek(
       
   604 	TFMRadioSeekDirection aDirection )
       
   605 	{
       
   606 	if ( !iTuner->iTunerOn )
       
   607 		{
       
   608 		iTuner->CompleteRequest(KReqStationSeek, KFMRadioErrNotPermittedInCurrentState);
       
   609 		return;
       
   610 		}
       
   611 
       
   612 	if ( aDirection == EFMRadioSeekUp )
       
   613 		{
       
   614 		if ( iTuner->iFrequency < KFrequency1 )
       
   615 			{
       
   616 			SetFrequencySettings(KFrequency1);
       
   617 			}
       
   618 		else if ( (iTuner->iFrequency >= KFrequency1) && (iTuner->iFrequency < KFrequency2) )
       
   619 			{
       
   620 			SetFrequencySettings(KFrequency2);
       
   621 			}
       
   622 		else if ( (iTuner->iFrequency >= KFrequency2) && (iTuner->iFrequency < KFrequency3) )
       
   623 			{
       
   624 			SetFrequencySettings(KFrequency3);
       
   625 			}
       
   626 		else if ( (iTuner->iFrequency >= KFrequency3) && (iTuner->iFrequency < KFrequency4) )
       
   627 			{
       
   628 			SetFrequencySettings(KFrequency4);
       
   629 			}
       
   630 		else	// iTuner->iFrequency >= KFrequency4
       
   631 			{
       
   632 			SetFrequencySettings(KFrequency1);
       
   633 			}
       
   634 		}
       
   635 	else
       
   636 		{
       
   637 		if ( iTuner->iFrequency > KFrequency4 )
       
   638 			{
       
   639 			SetFrequencySettings(KFrequency4);
       
   640 			}
       
   641 		else if ( (iTuner->iFrequency <= KFrequency4) && (iTuner->iFrequency > KFrequency3) )
       
   642 			{
       
   643 			SetFrequencySettings(KFrequency3);
       
   644 			}
       
   645 		else if ( (iTuner->iFrequency <= KFrequency3) && (iTuner->iFrequency > KFrequency2) )
       
   646 			{
       
   647 			SetFrequencySettings(KFrequency2);
       
   648 			}
       
   649 		else if ( (iTuner->iFrequency <= KFrequency2) && (iTuner->iFrequency > KFrequency1) )
       
   650 			{
       
   651 			SetFrequencySettings(KFrequency1);
       
   652 			}
       
   653 		else	// iTuner->iFrequency < KFrequency1
       
   654 			{
       
   655 			SetFrequencySettings(KFrequency4);
       
   656 			}
       
   657 		}
       
   658 
       
   659 	iTuner->CompleteRequest(KReqStationSeek, KErrNone);
       
   660 	}
       
   661 
       
   662 // -----------------------------------------------------------------------------
       
   663 //
       
   664 void CAdaptation::CancelStationSeek()
       
   665 	{
       
   666 	}
       
   667 
       
   668 // -----------------------------------------------------------------------------
       
   669 //
       
   670 void CAdaptation::AudioMode()
       
   671 	{
       
   672 	iTuner->CompleteRequest(KReqAudioMode, KErrNone);
       
   673 	}
       
   674 
       
   675 // -----------------------------------------------------------------------------
       
   676 //
       
   677 void CAdaptation::CancelAudioMode()
       
   678 	{
       
   679 	}
       
   680 
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 void CAdaptation::SetAudioMode(
       
   684 	TFMRadioAudioMode aMode )
       
   685 	{
       
   686 	iTuner->iMode = aMode;
       
   687 	iTuner->CompleteRequest(KReqSetAudioMode, KErrNone);
       
   688 	}
       
   689 
       
   690 // -----------------------------------------------------------------------------
       
   691 //
       
   692 void CAdaptation::CancelSetAudioMode()
       
   693 	{
       
   694 	}
       
   695 
       
   696 // -----------------------------------------------------------------------------
       
   697 //
       
   698 void CAdaptation::MaxSignalStrength()
       
   699 	{
       
   700 	iTuner->CompleteRequest(KReqMaxSignalStrength, KErrNone);
       
   701 	}
       
   702 
       
   703 // -----------------------------------------------------------------------------
       
   704 //
       
   705 void CAdaptation::CancelMaxSignalStrength()
       
   706 	{
       
   707 	}
       
   708 
       
   709 // -----------------------------------------------------------------------------
       
   710 //
       
   711 void CAdaptation::SignalStrength()
       
   712 	{
       
   713 	iTuner->CompleteRequest(KReqSignalStrength, KErrNone);
       
   714 	}
       
   715 
       
   716 // -----------------------------------------------------------------------------
       
   717 //
       
   718 void CAdaptation::CancelSignalStrength()
       
   719 	{
       
   720 	}
       
   721 
       
   722 // -----------------------------------------------------------------------------
       
   723 //
       
   724 void CAdaptation::Squelch()
       
   725 	{
       
   726 	iTuner->CompleteRequest(KReqSquelch, KErrNone);
       
   727 	}
       
   728 
       
   729 // -----------------------------------------------------------------------------
       
   730 //
       
   731 void CAdaptation::CancelSquelch()
       
   732 	{
       
   733 	}
       
   734 
       
   735 // -----------------------------------------------------------------------------
       
   736 //
       
   737 void CAdaptation::SetSquelch(
       
   738 	TBool aEnabled )
       
   739 	{
       
   740 	iTuner->iSquelch = aEnabled;
       
   741 	iTuner->CompleteRequest(KReqSetSquelch, KErrNone);
       
   742 	}
       
   743 
       
   744 // -----------------------------------------------------------------------------
       
   745 //
       
   746 void CAdaptation::CancelSetSquelch()
       
   747 	{
       
   748 	}
       
   749 
       
   750 // -----------------------------------------------------------------------------
       
   751 //
       
   752 void CAdaptation::BufferToBeFilled(
       
   753 	TDes8& /*aBuffer*/ )
       
   754 	{
       
   755 	// Not used.
       
   756 	}
       
   757 
       
   758 // -----------------------------------------------------------------------------
       
   759 //
       
   760 TFMRadioCapabilities CAdaptation::Capabilities()
       
   761 	{
       
   762 	TFMRadioCapabilities cap;
       
   763 	cap.iSampleRate = EFMRadioSampleRate48000Hz;
       
   764 	cap.iChannels = EFMRadioAudioMono | EFMRadioAudioStereo;
       
   765 	//const TUint32 KMMFFourCCCodePCM16 = 0x36315020;		//(' ', 'P', '1', '6')
       
   766 	cap.iEncoding = 0x36315020;
       
   767 
       
   768 	cap.iTunerBands = EFMRadioFrequencyEuroAmerica | EFMRadioFrequencyJapan;
       
   769 	//cap.iTunerFunctions = ETunerAvailableInOfflineMode | ETunerRdsSupport;
       
   770 	cap.iTunerFunctions = 0x01 | 0x02;
       
   771 	return cap;
       
   772 	}
       
   773 
       
   774 /*********************************************************************
       
   775 *  RD_FM_RADIO_ENHANCEMENTS
       
   776 **********************************************************************/
       
   777 #ifdef RD_FM_RADIO_ENHANCEMENTS
       
   778 
       
   779 // -----------------------------------------------------------------------------
       
   780 //
       
   781 MRdsControl* CAdaptation::RdsControl(
       
   782 	MRdsControlObserver& aObserver )
       
   783 	{
       
   784 	iTuner->iRdsObserver = &aObserver;
       
   785 	return this;
       
   786 	}
       
   787 
       
   788 // -----------------------------------------------------------------------------
       
   789 //
       
   790 TInt CAdaptation::GetFrequencyRange(
       
   791 	TFMRadioFrequencyRange& aRange,
       
   792 	TInt& aMinFreq,
       
   793 	TInt& aMaxFreq ) const
       
   794 	{
       
   795 	aRange = iTuner->iRange;
       
   796 	if ( aRange == EFMRadioFrequencyEuroAmerica )
       
   797 		{
       
   798 		aMinFreq = KEuroAmericaMin;
       
   799 		aMaxFreq = KEuroAmericaMax;
       
   800 		}
       
   801 	else	// aRange = EFMRadioFrequencyJapan;
       
   802 		{
       
   803 		aMinFreq = KJapanMin;
       
   804 		aMaxFreq = KJapanMax;
       
   805 		}
       
   806 	return KErrNone;
       
   807 	}
       
   808 
       
   809 // -----------------------------------------------------------------------------
       
   810 //
       
   811 TInt CAdaptation::GetCapabilities(
       
   812 	TRdsCapabilities& aCaps ) const
       
   813 	{
       
   814 	aCaps.iRdsFunctions = ERdsProgrammeIdentification | ERdsProgrammeType | ERdsProgrammeService
       
   815 			| ERdsRadioText | ERdsClockTime | ERdsAlternateFrequency;
       
   816 	return KErrNone;
       
   817 	}
       
   818 
       
   819 // -----------------------------------------------------------------------------
       
   820 //
       
   821 TInt CAdaptation::GetRdsSignalStatus(
       
   822 	TBool& aRdsSignal ) const
       
   823 	{
       
   824     aRdsSignal = iTuner->iRdsSignal;
       
   825     return KErrNone;
       
   826     }
       
   827 
       
   828 // -----------------------------------------------------------------------------
       
   829 //
       
   830 TInt CAdaptation::NotifyRdsDataChange(
       
   831 	TRdsData aRdsData )
       
   832 	{
       
   833 	iTuner->iRdsData = aRdsData.iRdsFunctions;
       
   834 	// We'll only generate events for ERdsProgrammeIdentification, ERdsProgrammeType,
       
   835 	// ERdsProgrammeService for now.
       
   836 	if ( (aRdsData.iRdsFunctions & ERdsProgrammeIdentification) ||
       
   837 		 (aRdsData.iRdsFunctions & ERdsProgrammeType) ||
       
   838 		 (aRdsData.iRdsFunctions & ERdsProgrammeService) )
       
   839 		{
       
   840 		iTuner->iNotifyOn = ETrue;
       
   841 		}
       
   842 
       
   843 	if ( (iTuner->iRdsSignal) && (iTuner->iNotifyOn) )
       
   844 		{
       
   845 		iRds->Start();
       
   846 		}
       
   847      return KErrNone;
       
   848      }
       
   849 
       
   850 // -----------------------------------------------------------------------------
       
   851 //
       
   852 void CAdaptation::CancelNotifyRdsDataChange()
       
   853 	{
       
   854 	iTuner->iRdsData = 0;
       
   855 	iTuner->iNotifyOn = EFalse;
       
   856 	iRds->Cancel();
       
   857 	}
       
   858 
       
   859 // -----------------------------------------------------------------------------
       
   860 //
       
   861 TInt CAdaptation::SetAutomaticSwitching(
       
   862 	TBool aAuto )
       
   863 	{
       
   864 	iTuner->iAutoSwitch = aAuto;
       
   865 	if ( aAuto && (iTuner->iFrequency == KFrequency1) )
       
   866 		{
       
   867 		iRdsAf->Start();
       
   868 		}
       
   869 	return KErrNone;
       
   870 	}
       
   871 
       
   872 // -----------------------------------------------------------------------------
       
   873 //
       
   874 TInt CAdaptation::GetAutomaticSwitching(
       
   875 	TBool& aAuto )
       
   876 	{
       
   877 	aAuto = iTuner->iAutoSwitch;
       
   878 	return KErrNone;
       
   879 	}
       
   880 
       
   881 // -----------------------------------------------------------------------------
       
   882 //
       
   883 void CAdaptation::CancelAFSearch()
       
   884 	{
       
   885 	}
       
   886 
       
   887 // -----------------------------------------------------------------------------
       
   888 //
       
   889 TInt CAdaptation::SetAutomaticTrafficAnnouncement(
       
   890 	TBool /*aAuto*/ )
       
   891 	{
       
   892 	return KErrNotSupported;
       
   893 	};
       
   894 
       
   895 // -----------------------------------------------------------------------------
       
   896 //
       
   897 TInt CAdaptation::GetAutomaticTrafficAnnouncement(
       
   898 	TBool& aAuto )
       
   899 	{
       
   900 	aAuto = EFalse;
       
   901 	return KErrNone;
       
   902 	}
       
   903 
       
   904 // -----------------------------------------------------------------------------
       
   905 //
       
   906 void CAdaptation::StationSeekByPTY(
       
   907 	TRdsProgrammeType aPty,
       
   908 	TBool aSeekUp )
       
   909 	{
       
   910 	if ( !iTuner->iTunerOn )
       
   911 		{
       
   912 		iTuner->CompleteRequest(KReqStationSeekByPTY, KRdsErrNotPermittedInCurrentState);
       
   913 		return;
       
   914 		}
       
   915 
       
   916 	TInt err = KErrNone;
       
   917 	switch ( aPty )
       
   918 		{
       
   919 		case KRdsPtyReligion:
       
   920 			if ( aSeekUp )
       
   921 				{
       
   922 				if ( iTuner->iFrequency < KFrequency1 )
       
   923 					{
       
   924 					SetFrequencySettings(KFrequency1);
       
   925 					}
       
   926 				else if ( (iTuner->iFrequency >= KFrequency1) && (iTuner->iFrequency < KFrequency2) )
       
   927 					{
       
   928 					SetFrequencySettings(KFrequency2);
       
   929 					}
       
   930 				else	// iTuner->iFrequency >= KFrequency2
       
   931 					{
       
   932 					SetFrequencySettings(KFrequency1);
       
   933 					}
       
   934 				}
       
   935 			else
       
   936 				{
       
   937 				if ( iTuner->iFrequency > KFrequency2 )
       
   938 					{
       
   939 					SetFrequencySettings(KFrequency2);
       
   940 					}
       
   941 				else if ( (iTuner->iFrequency <= KFrequency2) && (iTuner->iFrequency > KFrequency1) )
       
   942 					{
       
   943 					SetFrequencySettings(KFrequency1);
       
   944 					}
       
   945 				else	// iTuner->iFrequency < KFrequency1
       
   946 					{
       
   947 					SetFrequencySettings(KFrequency2);
       
   948 					}
       
   949 				}
       
   950 			break;
       
   951 		case KRdsPtyLightClassical:
       
   952 			SetFrequencySettings(KFrequency3);
       
   953 			break;
       
   954 		case KRdsPtyRockMusic:
       
   955 			SetFrequencySettings(KFrequency4);
       
   956 			break;
       
   957 		default:
       
   958 			err = KErrNotFound;
       
   959 			break;
       
   960 		}
       
   961 	iTuner->CompleteRequest(KReqStationSeekByPTY, err);
       
   962 	}
       
   963 
       
   964 // -----------------------------------------------------------------------------
       
   965 //
       
   966 void CAdaptation::StationSeekByTA(
       
   967 	TBool aSeekUp )
       
   968 	{
       
   969 	if ( !iTuner->iTunerOn )
       
   970 		{
       
   971 		iTuner->CompleteRequest(KReqStationSeekByTA, KRdsErrNotPermittedInCurrentState);
       
   972 		return;
       
   973 		}
       
   974 
       
   975 	// Just for testing purpose, if aSeekUp return KFrequency1, else return KErrNotFound.
       
   976 	if ( aSeekUp )
       
   977 		{
       
   978 		SetFrequencySettings(KFrequency1);
       
   979 		iTuner->CompleteRequest(KReqStationSeekByTA, KErrNone);
       
   980 		}
       
   981 	else
       
   982 		{
       
   983 		iTuner->CompleteRequest(KReqStationSeekByTA, KErrNotFound);
       
   984 		}
       
   985 	}
       
   986 
       
   987 // -----------------------------------------------------------------------------
       
   988 //
       
   989 void CAdaptation::StationSeekByTP(
       
   990 	TBool aSeekUp )
       
   991 	{
       
   992 	if ( !iTuner->iTunerOn )
       
   993 		{
       
   994 		iTuner->CompleteRequest(KReqStationSeekByTP, KRdsErrNotPermittedInCurrentState);
       
   995 		return;
       
   996 		}
       
   997 
       
   998 	if ( aSeekUp )
       
   999 		{
       
  1000 		if ( iTuner->iFrequency < KFrequency1 )
       
  1001 			{
       
  1002 			SetFrequencySettings(KFrequency1);
       
  1003 			}
       
  1004 		else if ( (iTuner->iFrequency >= KFrequency1) && (iTuner->iFrequency < KFrequency4) )
       
  1005 			{
       
  1006 			SetFrequencySettings(KFrequency4);
       
  1007 			}
       
  1008 		else	// iTuner->iFrequency >= KFrequency4
       
  1009 			{
       
  1010 			SetFrequencySettings(KFrequency1);
       
  1011 			}
       
  1012 		}
       
  1013 	else
       
  1014 		{
       
  1015 		if ( iTuner->iFrequency > KFrequency4 )
       
  1016 			{
       
  1017 			SetFrequencySettings(KFrequency4);
       
  1018 			}
       
  1019 		else if ( (iTuner->iFrequency <= KFrequency4) && (iTuner->iFrequency > KFrequency1) )
       
  1020 			{
       
  1021 			SetFrequencySettings(KFrequency1);
       
  1022 			}
       
  1023 		else	// iTuner->iFrequency < KFrequency1
       
  1024 			{
       
  1025 			SetFrequencySettings(KFrequency4);
       
  1026 			}
       
  1027 		}
       
  1028 
       
  1029 	iTuner->CompleteRequest(KReqStationSeekByTP, KErrNone);
       
  1030 	}
       
  1031 
       
  1032 // -----------------------------------------------------------------------------
       
  1033 //
       
  1034 void CAdaptation::CancelRdsStationSeek()
       
  1035      {
       
  1036      }
       
  1037 
       
  1038 // -----------------------------------------------------------------------------
       
  1039 //
       
  1040 void CAdaptation::GetFreqByPTY(
       
  1041 	TRdsProgrammeType aPty )
       
  1042 	{
       
  1043 	if ( !iTuner->iTunerOn )
       
  1044 		{
       
  1045 		iTuner->CompleteRequest(KReqGetFreqByPTY, KRdsErrNotPermittedInCurrentState);
       
  1046 		return;
       
  1047 		}
       
  1048 
       
  1049 	TInt err = KErrNone;
       
  1050 	iTuner->iFreqList.Reset();
       
  1051 	switch ( aPty )
       
  1052 		{
       
  1053 		case KRdsPtyReligion:
       
  1054 			iTuner->iFreqList.Append(KFrequency1);
       
  1055 			iTuner->iFreqList.Append(KFrequency2);
       
  1056 			break;
       
  1057 		case KRdsPtyLightClassical:
       
  1058 			iTuner->iFreqList.Append(KFrequency3);
       
  1059 			break;
       
  1060 		case KRdsPtyRockMusic:
       
  1061 			iTuner->iFreqList.Append(KFrequency4);
       
  1062 			break;
       
  1063 		default:
       
  1064 			err = KErrNotFound;
       
  1065 			break;
       
  1066 		}
       
  1067 	iTuner->CompleteRequest(KReqGetFreqByPTY, err);
       
  1068 	}
       
  1069 
       
  1070 // -----------------------------------------------------------------------------
       
  1071 //
       
  1072 void CAdaptation::CancelGetFreqByPTY()
       
  1073     {
       
  1074     }
       
  1075 
       
  1076 // -----------------------------------------------------------------------------
       
  1077 //
       
  1078 void CAdaptation::GetFreqByTA()
       
  1079 	{
       
  1080 	if ( !iTuner->iTunerOn )
       
  1081 		{
       
  1082 		iTuner->CompleteRequest(KReqGetFreqByTA, KRdsErrNotPermittedInCurrentState);
       
  1083 		return;
       
  1084 		}
       
  1085 
       
  1086 	iTuner->iFreqList.Reset();
       
  1087 	iTuner->iFreqList.Append(KFrequency1);
       
  1088 	iTuner->CompleteRequest(KReqGetFreqByTA, KErrNone);
       
  1089 	}
       
  1090 
       
  1091 // -----------------------------------------------------------------------------
       
  1092 //
       
  1093 void CAdaptation::CancelGetFreqByTA()
       
  1094 	{
       
  1095 	}
       
  1096 
       
  1097 // -----------------------------------------------------------------------------
       
  1098 //
       
  1099 void CAdaptation::GetPSByPTY
       
  1100 	( TRdsProgrammeType aPty )
       
  1101 	{
       
  1102 	if ( !iTuner->iTunerOn )
       
  1103 		{
       
  1104 		iTuner->CompleteRequest(KReqGetPSByPTY, KRdsErrNotPermittedInCurrentState);
       
  1105 		return;
       
  1106 		}
       
  1107 
       
  1108 	TInt err = KErrNone;
       
  1109 	iTuner->iPsList.Reset();
       
  1110 	switch ( aPty )
       
  1111 		{
       
  1112 		case KRdsPtyReligion:
       
  1113 			iTuner->iPsList.Append(_L8("KCBI"));
       
  1114 			iTuner->iPsList.Append(_L8("KLTY"));
       
  1115 			break;
       
  1116 		case KRdsPtyLightClassical:
       
  1117 			iTuner->iPsList.Append(_L8("KVIL"));
       
  1118 			break;
       
  1119 		case KRdsPtyRockMusic:
       
  1120 			iTuner->iPsList.Append(_L8("KHKS"));
       
  1121 			break;
       
  1122 		default:
       
  1123 			err = KErrNotFound;
       
  1124 			break;
       
  1125 		}
       
  1126 	iTuner->CompleteRequest(KReqGetPSByPTY, err);
       
  1127 	}
       
  1128 
       
  1129 // -----------------------------------------------------------------------------
       
  1130 //
       
  1131 void CAdaptation::CancelGetPSByPTY()
       
  1132 	{
       
  1133 	}
       
  1134 
       
  1135 // -----------------------------------------------------------------------------
       
  1136 //
       
  1137 void CAdaptation::GetPSByTA()
       
  1138 	{
       
  1139 	if ( !iTuner->iTunerOn )
       
  1140 		{
       
  1141 		iTuner->CompleteRequest(KReqGetPSByTA, KRdsErrNotPermittedInCurrentState);
       
  1142 		return;
       
  1143 		}
       
  1144 
       
  1145 	iTuner->iPsList.Reset();
       
  1146 	iTuner->iPsList.Append(_L8("KCBI"));
       
  1147 	iTuner->CompleteRequest(KReqGetPSByTA, KErrNone);
       
  1148 	}
       
  1149 
       
  1150 // -----------------------------------------------------------------------------
       
  1151 //
       
  1152 void CAdaptation::CancelGetPSByTA()
       
  1153 	{
       
  1154 	}
       
  1155 
       
  1156 // -----------------------------------------------------------------------------
       
  1157 //
       
  1158 TInt CAdaptation::GetProgrammeIdentification(
       
  1159 	TInt& aPi )
       
  1160 	{
       
  1161 	if ( !iTuner->iTunerOn )
       
  1162 		{
       
  1163 		return KRdsErrNotPermittedInCurrentState;
       
  1164 		}
       
  1165 
       
  1166 	if ( iTuner->iRdsSignal )
       
  1167 		{
       
  1168 		aPi = iTuner->iPi;
       
  1169 		return KErrNone;
       
  1170 		}
       
  1171 	else
       
  1172 		{
       
  1173 		return KErrNotFound;
       
  1174 		}
       
  1175 	}
       
  1176 
       
  1177 // -----------------------------------------------------------------------------
       
  1178 //
       
  1179 TInt CAdaptation::GetProgrammeType(
       
  1180 	TRdsProgrammeType& aPty )
       
  1181 	{
       
  1182 	if ( !iTuner->iTunerOn )
       
  1183 		{
       
  1184 		return KRdsErrNotPermittedInCurrentState;
       
  1185 		}
       
  1186 
       
  1187 	if ( iTuner->iRdsSignal )
       
  1188 		{
       
  1189 		aPty = iTuner->iPty;
       
  1190 		return KErrNone;
       
  1191 		}
       
  1192 	else
       
  1193 		{
       
  1194 		return KErrNotFound;
       
  1195 		}
       
  1196 	}
       
  1197 
       
  1198 // -----------------------------------------------------------------------------
       
  1199 //
       
  1200 TInt CAdaptation::GetProgrammeService(
       
  1201 	TRdsPSName& aPs )
       
  1202 	{
       
  1203 	if ( !iTuner->iTunerOn )
       
  1204 		{
       
  1205 		return KRdsErrNotPermittedInCurrentState;
       
  1206 		}
       
  1207 
       
  1208 	if ( iTuner->iRdsSignal )
       
  1209 		{
       
  1210 		aPs = iTuner->iPs;
       
  1211 		return KErrNone;
       
  1212 		}
       
  1213 	else
       
  1214 		{
       
  1215 		return KErrNotFound;
       
  1216 		}
       
  1217 	}
       
  1218 
       
  1219 // -----------------------------------------------------------------------------
       
  1220 //
       
  1221 TInt CAdaptation::GetRadioText(
       
  1222 	TRdsRadioText& aRt,
       
  1223 	RArray<TRdsRTplusTag>& /*aRTplusTags*/ )
       
  1224 	{
       
  1225 	if ( !iTuner->iTunerOn )
       
  1226 		{
       
  1227 		return KRdsErrNotPermittedInCurrentState;
       
  1228 		}
       
  1229 
       
  1230 	if ( iTuner->iRdsSignal )
       
  1231 		{
       
  1232 		aRt = iTuner->iRt;
       
  1233 		return KErrNone;
       
  1234 		}
       
  1235 	else
       
  1236 		{
       
  1237 		return KErrNotFound;
       
  1238 		}
       
  1239 	}
       
  1240 
       
  1241 // -----------------------------------------------------------------------------
       
  1242 //
       
  1243 TInt CAdaptation::GetClockTime(
       
  1244 	TDateTime& aCt )
       
  1245 	{
       
  1246 	if ( !iTuner->iTunerOn )
       
  1247 		{
       
  1248 		return KRdsErrNotPermittedInCurrentState;
       
  1249 		}
       
  1250 
       
  1251 	if ( iTuner->iRdsSignal )
       
  1252 		{
       
  1253 		// Hardcoded to 2007/11/10 7:35
       
  1254 		aCt.Set(2007,ENovember,10,7,35,0,0);
       
  1255 		return KErrNone;
       
  1256 		}
       
  1257 	else
       
  1258 		{
       
  1259 		return KErrNotFound;
       
  1260 		}
       
  1261 	}
       
  1262 
       
  1263 // -----------------------------------------------------------------------------
       
  1264 //
       
  1265 TInt CAdaptation::GetTrafficAnnouncementStatus(
       
  1266 	TBool& aTaStatus )
       
  1267 	{
       
  1268 	if ( !iTuner->iTunerOn )
       
  1269 		{
       
  1270 		return KRdsErrNotPermittedInCurrentState;
       
  1271 		}
       
  1272 
       
  1273 	if ( iTuner->iFrequency == KFrequency1 )
       
  1274 		{
       
  1275 		aTaStatus = ETrue;
       
  1276 		return KErrNone;
       
  1277 		}
       
  1278 	else if ( iTuner->iFrequency == KFrequency4 )
       
  1279 		{
       
  1280 		aTaStatus = EFalse;
       
  1281 		return KErrNone;
       
  1282 		}
       
  1283 	else
       
  1284 		{
       
  1285 		return KErrNotFound;
       
  1286 
       
  1287 		}
       
  1288 	}
       
  1289 
       
  1290 // -----------------------------------------------------------------------------
       
  1291 //
       
  1292 TInt CAdaptation::GetTrafficProgrammeStatus(
       
  1293 	TBool& aTpStatus )
       
  1294 	{
       
  1295 	if ( !iTuner->iTunerOn )
       
  1296 		{
       
  1297 		return KRdsErrNotPermittedInCurrentState;
       
  1298 		}
       
  1299 
       
  1300 	if ( (iTuner->iFrequency == KFrequency1) || (iTuner->iFrequency == KFrequency4) )
       
  1301 		{
       
  1302 		aTpStatus = ETrue;
       
  1303 		return KErrNone;
       
  1304 		}
       
  1305 	else if ( (iTuner->iFrequency == KFrequency2) || (iTuner->iFrequency == KFrequency3) )
       
  1306 		{
       
  1307 		aTpStatus = EFalse;
       
  1308 		return KErrNone;
       
  1309 		}
       
  1310 	else
       
  1311 		{
       
  1312 		return KErrNotFound;
       
  1313 		}
       
  1314      }
       
  1315 
       
  1316 #endif //#ifdef RD_FM_RADIO_ENHANCEMENTS
       
  1317 
       
  1318 // -----------------------------------------------------------------------------
       
  1319 //
       
  1320 TBool CAdaptation::ValidFrequency(
       
  1321 	TFMRadioFrequencyRange aRange,
       
  1322 	TInt aFrequency )
       
  1323 	{
       
  1324 	if ( aRange == EFMRadioFrequencyEuroAmerica )
       
  1325 		{
       
  1326 		if ( (aFrequency < KEuroAmericaMin) || (aFrequency > KEuroAmericaMax) )
       
  1327 			{
       
  1328 			return EFalse;
       
  1329 			}
       
  1330 		}
       
  1331 	else	// aRange = EFMRadioFrequencyJapan;
       
  1332 		{
       
  1333 		if ( (aFrequency < KJapanMin) || (aFrequency > KJapanMax) )
       
  1334 			{
       
  1335 			return EFalse;
       
  1336 			}
       
  1337 		}
       
  1338 	return ETrue;
       
  1339 	}
       
  1340 
       
  1341 // -----------------------------------------------------------------------------
       
  1342 //
       
  1343 void CAdaptation::SetFrequencySettings(
       
  1344 	TInt aFrequency )
       
  1345 	{
       
  1346 	iTuner->iFrequency = aFrequency;
       
  1347 	switch ( aFrequency )
       
  1348 		{
       
  1349 		case KFrequency1:
       
  1350 			iTuner->iSigStrength = 1;
       
  1351 			iTuner->iRdsSignal = ETrue;
       
  1352 			iTuner->iPi = 1000;
       
  1353 			iTuner->iPty = KRdsPtyReligion;
       
  1354 			iTuner->iPs = _L8("KCBI");
       
  1355 			iTuner->iRt = _L8("Hail to the King");
       
  1356 			if ( iTuner->iAutoSwitch )
       
  1357 				{
       
  1358 				iRdsAf->Start();
       
  1359 				}
       
  1360 			break;
       
  1361 		case KFrequency2:
       
  1362 			iTuner->iSigStrength = 2;
       
  1363 			iTuner->iRdsSignal = ETrue;
       
  1364 			iTuner->iPi = 1000;
       
  1365 			iTuner->iPty = KRdsPtyReligion;
       
  1366 			iTuner->iPs = _L8("KLTY");
       
  1367 			iTuner->iRt = _L8("He Knows My Name");
       
  1368 			break;
       
  1369 		case KFrequency3:
       
  1370 			iTuner->iSigStrength = 3;
       
  1371 			iTuner->iRdsSignal = ETrue;
       
  1372 			iTuner->iPi = 2000;
       
  1373 			iTuner->iPty = KRdsPtyLightClassical;
       
  1374 			iTuner->iPs = _L8("KVIL");
       
  1375 			iTuner->iRt = _L8("Power of Love");
       
  1376 			break;
       
  1377 		case KFrequency4:
       
  1378 			iTuner->iSigStrength = 4;
       
  1379 			iTuner->iRdsSignal = ETrue;
       
  1380 			iTuner->iPi = 3000;
       
  1381 			iTuner->iPty = KRdsPtyRockMusic;
       
  1382 			iTuner->iPs = _L8("KHKS");
       
  1383 			iTuner->iRt = _L8("The Reason");
       
  1384 			break;
       
  1385 		default:
       
  1386 			iTuner->iSigStrength = 5;
       
  1387 			iTuner->iRdsSignal = EFalse;
       
  1388 			break;
       
  1389 		}
       
  1390 	if ( (iTuner->iRdsSignal) && (iTuner->iNotifyOn) )
       
  1391 		{
       
  1392 		iRds->Start();
       
  1393 		}
       
  1394 	}
       
  1395 
       
  1396 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
  1397 
       
  1398 
       
  1399 //  End of File
       
  1400