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