radioengine/engine/src/cradiordsreceiverbase.cpp
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // User includes
       
    19 #include "cradiordsreceiverbase.h"
       
    20 #include "cradioenginelogger.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CRadioRdsReceiverBase::CRadioRdsReceiverBase( MRadioEngineSettings& aSettings )
       
    29     : iSettings( aSettings )
       
    30     {
       
    31     LEVEL3( LOG_METHOD_AUTO );
       
    32     }
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 void CRadioRdsReceiverBase::BaseConstructL()
       
    39     {
       
    40     LEVEL3( LOG_METHOD_AUTO );
       
    41     iPsName = HBufC::NewL( TRdsPSName().MaxLength() );
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CRadioRdsReceiverBase::~CRadioRdsReceiverBase()
       
    49     {
       
    50     LEVEL3( LOG_METHOD_AUTO );
       
    51     iObservers.Close();
       
    52     delete iPsName;
       
    53     iRadioText.Close();
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 void CRadioRdsReceiverBase::AddObserverL( MRadioRdsDataObserver* aObserver )
       
    61     {
       
    62     LEVEL3( LOG_METHOD_AUTO );
       
    63     TInt index = iObservers.FindInAddressOrder( aObserver );
       
    64     if ( index == KErrNotFound )
       
    65         {
       
    66         iObservers.InsertInAddressOrderL( aObserver );
       
    67         }
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CRadioRdsReceiverBase::RemoveObserver( MRadioRdsDataObserver* aObserver )
       
    75     {
       
    76     LEVEL3( LOG_METHOD_AUTO );
       
    77     TInt index = iObservers.FindInAddressOrder( aObserver );
       
    78 
       
    79     if ( index >= 0 )
       
    80         {
       
    81         iObservers.Remove( index );
       
    82         }
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 TBool CRadioRdsReceiverBase::AutomaticSwitchingEnabled() const
       
    90     {
       
    91     LEVEL3( LOG_METHOD_AUTO );
       
    92     return iAfEnabled;
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 const TDesC& CRadioRdsReceiverBase::ProgrammeService() const
       
   100     {
       
   101     LEVEL3( LOG_METHOD_AUTO );
       
   102     return *iPsName;
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 const TDesC& CRadioRdsReceiverBase::RadioText() const
       
   110     {
       
   111     LEVEL3( LOG_METHOD_AUTO );
       
   112     return iRadioText;
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 TBool CRadioRdsReceiverBase::SignalAvailable() const
       
   120     {
       
   121     LEVEL3( LOG_METHOD_AUTO );
       
   122     return iSignalAvailable;
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 void CRadioRdsReceiverBase::SetAutomaticSwitchingL( TBool aEnable )
       
   130     {
       
   131     LEVEL3( LOG_METHOD_AUTO );
       
   132     iAfEnabled = aEnable;
       
   133     for ( TInt i = 0; i < iObservers.Count(); ++i )
       
   134         {
       
   135         iObservers[i]->RdsAfSearchStateChange( iAfEnabled );
       
   136         }
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CRadioRdsReceiverBase::ClearRdsInformation()
       
   144     {
       
   145     LEVEL3( LOG_METHOD_AUTO );
       
   146     iPsName->Des().Zero();
       
   147     iRadioText.Close();
       
   148     MrroRdsEventSignalChange( EFalse );
       
   149     }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void CRadioRdsReceiverBase::MrroStationSeekByPTYComplete( TInt DEBUGVAR3( aError ),
       
   156                                                           TInt DEBUGVAR3( aFrequency ) )
       
   157     {
       
   158     LEVEL3( LOG_METHOD_AUTO );
       
   159     LEVEL3( LOG_FORMAT( "aError: %d, aFrequency: %d ", aError, aFrequency ) );
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void CRadioRdsReceiverBase::MrroStationSeekByTAComplete( TInt DEBUGVAR3( aError ),
       
   167                                                          TInt DEBUGVAR3( aFrequency ) )
       
   168     {
       
   169     LEVEL3( LOG_METHOD_AUTO );
       
   170     LEVEL3( LOG_FORMAT( "aError: %d, aFrequency: %d ", aError, aFrequency ) );
       
   171     }
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 void CRadioRdsReceiverBase::MrroStationSeekByTPComplete( TInt DEBUGVAR3( aError ),
       
   178                                                          TInt DEBUGVAR3( aFrequency ) )
       
   179     {
       
   180     LEVEL3( LOG_METHOD_AUTO );
       
   181     LEVEL3( LOG_FORMAT( "aError: %d, aFrequency: %d ", aError, aFrequency ) );
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 //
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 void CRadioRdsReceiverBase::MrroGetFreqByPTYComplete( TInt DEBUGVAR3( aError ),
       
   189                                                       RArray<TInt>& /*aFreqList*/ )
       
   190     {
       
   191     LEVEL3( LOG_METHOD_AUTO );
       
   192     LEVEL3( LOG_FORMAT( "aError: %d", aError ) );
       
   193     }
       
   194 
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 void CRadioRdsReceiverBase::MrroGetFreqByTAComplete( TInt DEBUGVAR3( aError ),
       
   200                                                      RArray<TInt>& /*aFreqList*/ )
       
   201     {
       
   202     LEVEL3( LOG_METHOD_AUTO );
       
   203     LEVEL3( LOG_FORMAT( "aError: %d", aError ) );
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 void CRadioRdsReceiverBase::MrroGetPSByPTYComplete( TInt DEBUGVAR3( aError ),
       
   211                                                     RArray<TRdsPSName>& /*aPsList*/ )
       
   212     {
       
   213     LEVEL3( LOG_METHOD_AUTO );
       
   214     LEVEL3( LOG_FORMAT( "aError: %d", aError ) );
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 void CRadioRdsReceiverBase::MrroGetPSByTAComplete( TInt DEBUGVAR3( aError ),
       
   222                                                    RArray<TRdsPSName>& /*aPsList*/ )
       
   223     {
       
   224     LEVEL3( LOG_METHOD_AUTO );
       
   225     LEVEL3( LOG_FORMAT( "aError: %d", aError ) );
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 //
       
   230 // ---------------------------------------------------------------------------
       
   231 //
       
   232 void CRadioRdsReceiverBase::MrroRdsDataPI( TInt aPi )
       
   233     {
       
   234     LEVEL2( LOG_METHOD_AUTO );
       
   235     LEVEL2( LOG_FORMAT( "aPi: %d", aPi ) );
       
   236     const TInt observerCount = iObservers.Count();
       
   237     const TUint32 frequency = iSettings.TunedFrequency();
       
   238     for ( TInt i = 0; i < observerCount; ++i )
       
   239         {
       
   240         iObservers[i]->RdsDataPiCode( frequency, aPi );
       
   241         }
       
   242     }
       
   243 
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 void CRadioRdsReceiverBase::MrroRdsDataPTY( TRdsProgrammeType aPty )
       
   249     {
       
   250     LEVEL2( LOG_METHOD_AUTO );
       
   251     LEVEL2( LOG_FORMAT( "aPty: %d", aPty ) );
       
   252     const TInt observerCount = iObservers.Count();
       
   253     const TUint32 frequency = iSettings.TunedFrequency();
       
   254     for ( TInt i = 0; i < observerCount; ++i )
       
   255         {
       
   256         iObservers[i]->RdsDataGenre( frequency, aPty );
       
   257         }
       
   258     }
       
   259 
       
   260 // ---------------------------------------------------------------------------
       
   261 // Notifies of the New Programme Service data
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 void CRadioRdsReceiverBase::MrroRdsDataPS( TRdsPSName& aPs )
       
   265     {
       
   266     LEVEL2( LOG_METHOD_AUTO );
       
   267     LEVEL2( LOG_FORMAT( "aPs: %S", &aPs ) );
       
   268     const TUint32 frequency = iSettings.TunedFrequency();
       
   269     iPsName->Des().Copy( aPs );
       
   270     const TInt observerCount = iObservers.Count();
       
   271     for ( TInt i = 0; i < observerCount; ++i )
       
   272         {
       
   273         iObservers[i]->RdsDataProgrammeService( frequency, *iPsName );
       
   274         }
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 void CRadioRdsReceiverBase::MrroRdsDataRT( TRdsRadioText& aRt )
       
   282     {
       
   283     LEVEL2( LOG_METHOD_AUTO );
       
   284     LEVEL2( LOG_FORMAT( "aRt: %S", &aRt ) );
       
   285     iRadioText.Close();
       
   286     iRadioText.Create( aRt );
       
   287 
       
   288     const TUint32 frequency = iSettings.TunedFrequency();
       
   289     const TInt observerCount = iObservers.Count();
       
   290     for ( TInt i = 0; i < observerCount; ++i )
       
   291         {
       
   292         iObservers[i]->RdsDataRadioText( frequency, iRadioText );
       
   293         }
       
   294     }
       
   295 
       
   296 // ---------------------------------------------------------------------------
       
   297 //
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 void CRadioRdsReceiverBase::MrroRdsDataCT( TDateTime& /*aCt*/ )
       
   301     {
       
   302     LEVEL2( LOG_METHOD_AUTO );
       
   303     }
       
   304 
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 // ---------------------------------------------------------------------------
       
   308 //
       
   309 void CRadioRdsReceiverBase::MrroRdsDataTA( TBool DEBUGVAR2( aTaOn ) )
       
   310     {
       
   311     LEVEL2( LOG_METHOD_AUTO );
       
   312     LEVEL2( LOG_FORMAT( "aTaOn: %d", aTaOn ) );
       
   313     }
       
   314 
       
   315 // ---------------------------------------------------------------------------
       
   316 //
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 void CRadioRdsReceiverBase::MrroRdsDataRTplus( TRdsRTplusClass aRtPlusClass,
       
   320                                                TRdsRadioText& aRtPlusData )
       
   321     {
       
   322     LOG_METHOD_AUTO;
       
   323     LOG_FORMAT( "Class: %d, data: %S", aRtPlusClass, &aRtPlusData );
       
   324     const TUint32 frequency = iSettings.TunedFrequency();
       
   325     const TInt observerCount = iObservers.Count();
       
   326     for ( TInt i = 0; i < observerCount; ++i )
       
   327         {
       
   328         iObservers[i]->RdsDataRadioTextPlus( frequency, aRtPlusClass, aRtPlusData );
       
   329         }
       
   330     }
       
   331 
       
   332 // ---------------------------------------------------------------------------
       
   333 // Notifies of the start of Alternate Frequency search
       
   334 // ---------------------------------------------------------------------------
       
   335 //
       
   336 void CRadioRdsReceiverBase::MrroRdsSearchBeginAF()
       
   337     {
       
   338     LEVEL3( LOG_METHOD_AUTO );
       
   339     const TInt observerCount = iObservers.Count();
       
   340     for ( TInt i = 0; i < observerCount; ++i )
       
   341         {
       
   342         iObservers[i]->RdsAfSearchBegin();
       
   343         }
       
   344     }
       
   345 
       
   346 // ---------------------------------------------------------------------------
       
   347 // Notifies of the end of Alternate Frequency search
       
   348 // ---------------------------------------------------------------------------
       
   349 //
       
   350 void CRadioRdsReceiverBase::MrroRdsSearchEndAF( TInt aError, TInt aFrequency )
       
   351     {
       
   352     LEVEL3( LOG_METHOD_AUTO );
       
   353     LEVEL3( LOG_FORMAT( "aError: %d, aFrequency: %d", aError, aFrequency ) );
       
   354     const TInt observerCount = iObservers.Count();
       
   355     for ( TInt i = 0; i < observerCount; ++i )
       
   356         {
       
   357         // Radio utility uses Hz, UI uses kHz. It's ok to divide with 1000, possible lost fractions are useless.
       
   358         iObservers[i]->RdsAfSearchEnd( aFrequency, aError );
       
   359         }
       
   360     }
       
   361 
       
   362 // ---------------------------------------------------------------------------
       
   363 //
       
   364 // ---------------------------------------------------------------------------
       
   365 //
       
   366 void CRadioRdsReceiverBase::MrroRdsStationChangeTA( TInt DEBUGVAR3( aFrequency ) )
       
   367     {
       
   368     LEVEL3( LOG_METHOD_AUTO );
       
   369     LEVEL3( LOG_FORMAT( "aFrequency: %d", aFrequency ) );
       
   370     }
       
   371 
       
   372 // ---------------------------------------------------------------------------
       
   373 //
       
   374 // ---------------------------------------------------------------------------
       
   375 //
       
   376 void CRadioRdsReceiverBase::MrroRdsEventAutomaticSwitchingChange( TBool DEBUGVAR3( aAuto ) )
       
   377     {
       
   378     LEVEL3( LOG_METHOD_AUTO );
       
   379     LEVEL3( LOG_FORMAT( "aAuto: %d", aAuto ) );
       
   380     }
       
   381 
       
   382 // ---------------------------------------------------------------------------
       
   383 //
       
   384 // ---------------------------------------------------------------------------
       
   385 //
       
   386 void CRadioRdsReceiverBase::MrroRdsEventAutomaticTrafficAnnouncement( TBool DEBUGVAR3( aAuto ) )
       
   387     {
       
   388     LEVEL3( LOG_METHOD_AUTO );
       
   389     LEVEL3( LOG_FORMAT( "aAuto: %d", aAuto ) );
       
   390     }
       
   391 
       
   392 // ---------------------------------------------------------------------------
       
   393 //
       
   394 // ---------------------------------------------------------------------------
       
   395 //
       
   396 void CRadioRdsReceiverBase::MrroRdsEventSignalChange( TBool aSignal )
       
   397     {
       
   398     LEVEL3( LOG_METHOD_AUTO );
       
   399     LEVEL3( LOG_FORMAT( "aSignal: %d", aSignal ) );
       
   400     iSignalAvailable = aSignal;
       
   401     const TUint32 frequency = iSettings.TunedFrequency();
       
   402     const TInt observerCount = iObservers.Count();
       
   403     for ( TInt i = 0; i < observerCount; ++i )
       
   404         {
       
   405         iObservers[i]->RdsAvailable( frequency, iSignalAvailable );
       
   406         }
       
   407     }