fmradio/fmradioengine/inc/fmradioengine.h
branchRCL_3
changeset 20 93c594350b9a
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
       
     1 /*
       
     2 * Copyright (c) 2005 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:  The class implements the core functionality of the
       
    15 *                Radio Engine
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef FMRADIOENGINE_H
       
    21 #define FMRADIOENGINE_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <fmradiointernalpskeys.h>
       
    25 #include <RadioUtility.h>
       
    26 #include <RadioFmTunerUtility.h>
       
    27 #include <RadioPlayerUtility.h>
       
    28 #include <RadioPresetUtility.h>
       
    29 #include <RadioFmPresetUtility.h>
       
    30 
       
    31 #include "fmradiosystemeventdetectorobserver.h"
       
    32 #include "fmradionetworkchangeobserver.h"
       
    33 #include "fmradiordsobserver.h"
       
    34 #include "fmradioengine.hrh"
       
    35 #include "fmradioheadseteventobserver.h"
       
    36 
       
    37 #ifndef __ACCESSORY_FW
       
    38 #include <DosSvrServices.h>
       
    39 #endif
       
    40 
       
    41 // CONSTANTS
       
    42 const TUint8 KPresetNameLength = 32;
       
    43 const TInt KDefaultRadioFrequency = 87500000;
       
    44 _LIT(KFMRadioEngineResourceFile, "fmradioengine.rsc");
       
    45 const TInt KFMRadioFreqMultiplier = 1000;
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 class CAudioOutput;
       
    49 class CCentralRepositoryHandler;
       
    50 class CDesC16Array;
       
    51 class CFMRadioAccessoryConnection;
       
    52 class CFMRadioContextPublisher;
       
    53 class CFMRadioMobileNetworkInfoListener;
       
    54 class CFMRadioPubSub;
       
    55 class CFMRadioRdsReceiverBase;
       
    56 class CFMRadioSystemEventDetector;
       
    57 class CRadioStateHandler;
       
    58 class MRadioEngineStateChangeCallback;
       
    59 class TRadioSettings;
       
    60 
       
    61 #ifndef __ACCESSORY_FW
       
    62 class RDosServer;
       
    63 class CDosServerObserver;
       
    64 #endif
       
    65 
       
    66 // CLASS DECLARATION
       
    67 
       
    68 /**
       
    69  * This class implements the core functionality of the Radio Engine
       
    70  *
       
    71  * @since S60 3.2
       
    72  */
       
    73 class CRadioEngine : public CBase,
       
    74                      public MRadioPlayerObserver,
       
    75                      public MRadioFmTunerObserver,
       
    76                      public MRadioPresetObserver,
       
    77                      public MFMRadioSystemEventDetectorObserver,
       
    78                      public MFMRadioNetworkChangeObserver,
       
    79                      public MFMRadioRdsObserver,
       
    80                      public MFMRadioHeadsetEventObserver
       
    81 
       
    82     {
       
    83 public:
       
    84 
       
    85     typedef TBuf<KPresetNameLength> TStationName;
       
    86 
       
    87     enum TRadioMode
       
    88         {
       
    89         ERadioTunerMode,
       
    90         ERadioPresetMode
       
    91         };
       
    92 
       
    93     enum TFMRadioAudioMode
       
    94         {
       
    95         EFMRadioStereo = 0,
       
    96         EFMRadioMono
       
    97         };
       
    98 
       
    99     enum TFMRadioAudioOutput
       
   100         {
       
   101         EFMRadioOutputHeadset = 0,
       
   102         EFMRadioOutputIHF
       
   103         };
       
   104     
       
   105 public:
       
   106 
       
   107     /**
       
   108     * Two-phased class constructor.
       
   109     * @return pointer to CRadioEngine class instance
       
   110     */
       
   111     IMPORT_C static CRadioEngine* NewL( MRadioEngineStateChangeCallback& aCallback );
       
   112     /**
       
   113     * Destructor of CRadioEngine class.
       
   114     */
       
   115     IMPORT_C virtual ~CRadioEngine();
       
   116 
       
   117 public: // New functions
       
   118 
       
   119     /**
       
   120     * Set radio settings to their default values.
       
   121     * @since Series 60 3.0
       
   122     * @return none
       
   123     */
       
   124     IMPORT_C void InitializeRadio();
       
   125     /**
       
   126     * Retrieves the current radio mode .
       
   127     * @since Series 60 3.0
       
   128     * @return tune/preset
       
   129     */
       
   130     IMPORT_C TRadioMode GetRadioMode() const;
       
   131 
       
   132     /**
       
   133     * Gets the current audio mode.
       
   134     * @since Series 60 3.0
       
   135     * @return stereo/mono
       
   136     * @retval 0 = stereo
       
   137     * @retval 1 = mono
       
   138     */
       
   139     IMPORT_C TInt GetAudioMode() const;
       
   140 
       
   141     /**
       
   142     * Set the radio's audio mode.
       
   143     * @since Series 60 3.0
       
   144     * @param aAudioMode the new audio mode
       
   145     * @return none
       
   146     */
       
   147     IMPORT_C void SetAudioMode( const TFMRadioAudioMode aAudioMode );
       
   148 
       
   149     /**
       
   150     * get the currently selected channel index.
       
   151     * @since Series 60 3.0
       
   152     * @return none
       
   153     */
       
   154     IMPORT_C TInt GetPresetIndex() const;
       
   155 
       
   156     /**
       
   157     * Update the channel located at the index to use the frequency specified.
       
   158     * @since Series 60 3.0
       
   159     * @param aIndex index into the channel array.
       
   160     * @param aStationName name of the channel
       
   161     * @param aFrequency frequency value to be used.
       
   162     * @return none
       
   163     */
       
   164     IMPORT_C void SetPresetNameFrequencyL( TInt aIndex, const TStationName& aStationName, TInt aFrequency );
       
   165 
       
   166     /**
       
   167     * Retrieve the channel frequency at the index specified
       
   168     * @since Series 60 3.0
       
   169     * @param aIndex  index into the channel array.
       
   170     * @return the frequency
       
   171     */
       
   172     IMPORT_C TInt GetPresetFrequencyL(TInt aIndex) const;
       
   173 
       
   174     /**
       
   175     * Retrieve the channel name at the index specified
       
   176     * @since Series 60 3.0
       
   177     * @param aIndex  index into the channel array.
       
   178     * @return the channel name
       
   179     */
       
   180     IMPORT_C CRadioEngine::TStationName& GetPresetNameL( TInt aIndex );
       
   181     
       
   182     /**
       
   183     * Retrieve the channel name and the frequency at the index specified
       
   184     * @param aIndex station index
       
   185     * @param aName stored station name
       
   186     * @param aFrequency preset frequency
       
   187     */
       
   188     IMPORT_C void GetPresetNameAndFrequencyL( TInt aIndex, TDes& aName, TInt& aFrequency );
       
   189 
       
   190     /**
       
   191     * Starts the radio.
       
   192     * @since Series 60 3.0
       
   193     * @return none
       
   194     */
       
   195     IMPORT_C void RadioOn();
       
   196 
       
   197     /**
       
   198     * Stops the radio.
       
   199     * @since Series 60 3.0
       
   200     * @return none
       
   201     */
       
   202     IMPORT_C void RadioOff();
       
   203 
       
   204     /**
       
   205      * Returns the radio status
       
   206      * @since ??
       
   207      * @return ETrue = radio is on, EFalse = radio is off
       
   208      */
       
   209     IMPORT_C TBool IsRadioOn();
       
   210     
       
   211     /**
       
   212      * Checks if offine profile is current active profile
       
   213      * @since ??
       
   214      * @return True / False
       
   215      */
       
   216     IMPORT_C TBool IsOfflineProfileL();
       
   217     
       
   218     /**
       
   219     * Tune to the specified frequency
       
   220     * @since Series 60 3.0
       
   221     * @param aFrequency - frequency to lock onto.
       
   222     * @param aRadioMode - The radio mode to be used. Tuner mode by default
       
   223     * @return none
       
   224     */
       
   225     IMPORT_C void Tune( TInt aFrequency, TRadioMode aRadioMode = ERadioTunerMode );
       
   226     
       
   227     /*
       
   228      * Sets tuner mode on i.e. preset channel is not active.
       
   229      * Active preset Channel P&S data is also cleared.
       
   230      * Useful for example when preset channel is deleted.
       
   231      */
       
   232     IMPORT_C void SetTunerModeOn();
       
   233     
       
   234     /**
       
   235     * Scan up to the next available frequency.
       
   236     * @since Series 60 3.0
       
   237     * @return none
       
   238     */
       
   239     IMPORT_C void ScanUp();
       
   240 
       
   241     /**
       
   242     * Scan down to the last available frequency.
       
   243     * @since Series 60 3.0
       
   244     * @return none
       
   245     */
       
   246     IMPORT_C void ScanDown();
       
   247 
       
   248     /**
       
   249     * Cancel previously requested scan, and
       
   250     * return to the already tuned frequency.
       
   251     * @since Series 60 3.0
       
   252     * @return none
       
   253     */
       
   254     IMPORT_C void CancelScan();
       
   255 
       
   256     /**
       
   257     * Sets the audio mute state
       
   258     * @since Series 60 3.0
       
   259     * @param aMuteOn - flag to determine whether mute should be turned on or off
       
   260     * @return none
       
   261     */
       
   262     IMPORT_C void SetMuteOn(TBool aMuteOn);
       
   263 
       
   264     /**
       
   265     * Gets the audio mute state
       
   266     * @since Series 60 3.0
       
   267     * @return ETrue or EFalse to indicate whether mute is currently on.
       
   268     */
       
   269     IMPORT_C TBool IsMuteOn() const;
       
   270 
       
   271     /**
       
   272     * Sets the volume level of the FM radio
       
   273     * @since Series 60 3.0
       
   274     * @param aVolume - the volume to be used.
       
   275     * @return none
       
   276     */
       
   277     IMPORT_C void SetVolume(TInt aVolume);
       
   278 
       
   279     /**
       
   280     * Gets the volumelevel.
       
   281     * @since Series 60 3.0
       
   282     * @return the current volume
       
   283     */
       
   284     IMPORT_C TInt GetVolume() const;
       
   285 
       
   286     /**
       
   287     * Gets the max volumelevel.
       
   288     * @since Series 60 3.0
       
   289     * @return the max volume
       
   290     */
       
   291     IMPORT_C TInt GetMaxVolume() const;
       
   292 
       
   293     /**
       
   294     * Sets the audio Output
       
   295     * @since Series 60 3.0
       
   296     * @param aAudioOutput - where should the audio be routed?
       
   297     * @return none
       
   298     */
       
   299     IMPORT_C void SetAudioOutput( const TFMRadioAudioOutput aAudioOutput );
       
   300 
       
   301     /**
       
   302     * Sets the rds af search enabled
       
   303     * @param aEnabled ETrue if rds af search is enabled; EFalse otherwise.
       
   304     * @return none
       
   305     */
       
   306     IMPORT_C void SetRdsAfSearchEnable( TBool aEnabled );
       
   307      
       
   308      /**
       
   309      * Check whether flight mode is currently enabled
       
   310      * @since Series 60 3.0
       
   311      * @return ETrue or EFalse dependent on whether flightmode is enabled
       
   312      */
       
   313      IMPORT_C TBool IsRdsAfSearchEnabled() const;
       
   314      
       
   315      /**
       
   316       * @return reference to settings
       
   317       */
       
   318      IMPORT_C TRadioSettings& RadioSettings( );
       
   319      
       
   320     /**
       
   321     * Retrieve the current audio output
       
   322     * @since Series 60 3.0
       
   323     * @return EFMRadioOutputIHF or EFMRadioOutputHeadset
       
   324     */
       
   325     IMPORT_C TFMRadioAudioOutput GetAudioOutput() const;
       
   326 
       
   327     /**
       
   328     * Tunes to the chosen channel.
       
   329     * @since Series 60 3.0
       
   330     * @param aIndex - the index number of the channel you wish to tune to.
       
   331     * @return none
       
   332     */
       
   333     IMPORT_C void TunePresetL(TInt aIndex);
       
   334 
       
   335     /**
       
   336     * Retrieves the current frequency.
       
   337     * @since Series 60 3.0
       
   338     * @return the frequency
       
   339     */
       
   340     IMPORT_C TInt GetTunedFrequency() const;
       
   341 
       
   342     /**
       
   343     * Check whether flight mode is currently enabled
       
   344     * @since Series 60 3.0
       
   345     * @return ETrue or EFalse dependent on whether flightmode is enabled
       
   346     */
       
   347     IMPORT_C TBool IsFlightModeEnabled() const;
       
   348 
       
   349     /**
       
   350     * Get the frequency range (in Hertz) of the specified band.
       
   351     * This function should be used to enquire the frequency range
       
   352     * of the bands that GetCapabilities reports as supported.
       
   353     * @since Series 60 3.0
       
   354     * @param aBottomFrequency The variable to set to the lowest frequency allowed
       
   355     * @param aTopFrequency The variable to set to the highest frequency allowed
       
   356     * @return A standard system error code
       
   357     **/
       
   358     IMPORT_C TInt GetFrequencyBandRange( TInt& aBottomFrequency, TInt& aTopFrequency );
       
   359 
       
   360     /**
       
   361     * Check whether call is in progress
       
   362     * @since Series 60 3.1
       
   363     * @return ETrue or EFalse to indicate whether call is in progress
       
   364     */
       
   365     IMPORT_C TBool IsInCall() const;
       
   366     
       
   367     /**
       
   368     * Has the frequency been set by RDS AF search or not.
       
   369     *
       
   370     * @return ETrue if frequency was set by RDS AF, otherwise EFalse
       
   371     */
       
   372     IMPORT_C TBool FrequencySetByRdsAf() const;
       
   373 
       
   374     /**
       
   375     * Getter for RDS receiver
       
   376     *
       
   377     * @return Reference to CFMRadioRdsReceiver
       
   378     */
       
   379     IMPORT_C CFMRadioRdsReceiverBase& RdsReceiver();
       
   380     /**
       
   381     * Notifies UI that the headset button has been pressed
       
   382     */
       
   383     void HandleHeadsetButtonPress();
       
   384     /**
       
   385     * Switches the engine into flight mode, and notifies the UI of
       
   386     * the change in status.
       
   387     */
       
   388     void HandleFlightModeEnabled();
       
   389     /**
       
   390     * Switches the engine out of flight mode, and notifies the UI of
       
   391     * the change in status
       
   392     */
       
   393     void HandleFlightModeDisabled();
       
   394     /**
       
   395     * Calls the User Interface callback function, indicating the event code and
       
   396     * error code.
       
   397     */
       
   398     void HandleCallback(TInt aEventCode, TInt aErrorCode );
       
   399 
       
   400     /**
       
   401     * Gets the headset status
       
   402     * @return ETrue if headset connected
       
   403     */
       
   404     IMPORT_C TBool IsHeadsetConnected() const;
       
   405 
       
   406     /**
       
   407      * From MRadioPlayerObserver.
       
   408      * Called when Radio state changed.
       
   409      *
       
   410      * @since S60 3.2
       
   411      * @param aState Radio player state
       
   412      * @param aError A standard system error code, only used when aState is ERadioPlayerIdle
       
   413      */
       
   414     void MrpoStateChange( TPlayerState aState, TInt aError );
       
   415 
       
   416     /**
       
   417      * From MRadioPlayerObserver.
       
   418      * Called when volume changes. This may be caused by other applications.
       
   419      *
       
   420      * @since S60 3.2
       
   421      * @param aVolume Current volume.
       
   422      */
       
   423     void MrpoVolumeChange( TInt aVolume );
       
   424 
       
   425     /**
       
   426      * From MRadioPlayerObserver.
       
   427      * Called when mute setting changes. This may be caused by other applications.
       
   428      *
       
   429      * @since S60 3.2
       
   430      * @param aMute ETrue indicates audio is muted.
       
   431      */
       
   432     void MrpoMuteChange( TBool aMute );
       
   433 
       
   434     /**
       
   435      * From MRadioPlayerObserver.
       
   436      * Called when mute setting changes. This may be caused by other applications.
       
   437      *
       
   438      * Called when balance setting changes. This may be caused by other applications.
       
   439      *
       
   440      * @since S60 3.2
       
   441      * @param aLeftPercentage
       
   442      *        Left speaker volume percentage. This can be any value from zero to 100.
       
   443      *        Zero value means left speaker is muted.
       
   444      * @param aRightPercentage
       
   445      *        Right speaker volume percentage. This can be any value from zero to 100.
       
   446      *        Zero value means right speaker is muted.
       
   447      */
       
   448     void MrpoBalanceChange( TInt aLeftPercentage, TInt aRightPercentage );
       
   449 
       
   450 
       
   451     /**
       
   452      * From MRadioFmTunerObserver.
       
   453      * Called when Request for tuner control completes.
       
   454      *
       
   455      * @since S60 3.2
       
   456      * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
       
   457      */
       
   458     void MrftoRequestTunerControlComplete( TInt aError );
       
   459 
       
   460     /**
       
   461      * From MRadioFmTunerObserver.
       
   462      * Set frequency range complete event. This event is asynchronous and is received after
       
   463      * a call to CRadioFmTunerUtility::SetFrequencyRange.
       
   464      *
       
   465      * @since S60 3.2
       
   466      * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
       
   467      */
       
   468     void MrftoSetFrequencyRangeComplete( TInt aError );
       
   469 
       
   470     /**
       
   471      * From MRadioFmTunerObserver.
       
   472      * Set frequency complete event. This event is asynchronous and is received after a call to
       
   473      * CRadioFmTunerUtility::SetFrequency.
       
   474      *
       
   475      * @since S60 3.2
       
   476      * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
       
   477      */
       
   478     void MrftoSetFrequencyComplete( TInt aError );
       
   479 
       
   480     /**
       
   481      * From MRadioFmTunerObserver.
       
   482      * Station seek complete event. This event is asynchronous and is received after a call to
       
   483      * CRadioFmTunerUtility::StationSeek.
       
   484      *
       
   485      * @since S60 3.2
       
   486      * @param aError A standard system error code or FM tuner error (TFmRadioTunerError).
       
   487      * @param aFrequency The frequency(Hz) of the radio station that was found.
       
   488      */
       
   489     void MrftoStationSeekComplete( TInt aError, TInt aFrequency );
       
   490 
       
   491     /**
       
   492      * From MRadioFmTunerObserver.
       
   493      * Called when FM Transmitter status changes (if one is present in the device). Tuner receiver
       
   494      * is forced to be turned off due to hardware conflicts when FM transmitter is activated.
       
   495      *
       
   496      * @since S60 3.2
       
   497      * @param aActive ETrue if FM transmitter is active; EFalse otherwise.
       
   498      */
       
   499     void MrftoFmTransmitterStatusChange( TBool aActive );
       
   500 
       
   501     /**
       
   502      * From MRadioFmTunerObserver.
       
   503      * Called when antenna status changes.
       
   504      *
       
   505      * @since S60 3.2
       
   506      * @param aAttached ETrue if antenna is attached; EFalse otherwise.
       
   507      */
       
   508     void MrftoAntennaStatusChange( TBool aAttached );
       
   509 
       
   510     /**
       
   511      * From MRadioFmTunerObserver.
       
   512      * Called when offline mode status changes.
       
   513      * @since S60 3.2
       
   514      *
       
   515      * @param aOfflineMode ETrue if offline mode is enabled; EFalse otherwise.
       
   516      */
       
   517     void MrftoOfflineModeStatusChange( TBool aOfflineMode );
       
   518 
       
   519     /**
       
   520      * From MRadioFmTunerObserver.
       
   521      * Called when the frequency range changes. This may be caused by other applications.
       
   522      *
       
   523      * @since S60 3.2
       
   524      * @param aBand New frequency range.
       
   525      */
       
   526     void MrftoFrequencyRangeChange(TFmRadioFrequencyRange aBand );
       
   527 
       
   528     /**
       
   529      * From MRadioFmTunerObserver.
       
   530      * Called when the tuned frequency changes. This may be caused by other
       
   531      * applications or RDS if AF/TA is enabled.
       
   532      *
       
   533      * @since S60 3.2
       
   534      * @param aNewFrequency The new tuned frequency(Hz).
       
   535      */
       
   536     void MrftoFrequencyChange( TInt aNewFrequency );
       
   537 
       
   538     /**
       
   539      * From MRadioFmTunerObserver.
       
   540      * Called when the forced mono status change. This may be caused by other applications.
       
   541      *
       
   542      * @since S60 3.2
       
   543      * @param aForcedMono ETrue if forced mono mode is enabled; EFalse otherwise.
       
   544      */
       
   545     void MrftoForcedMonoChange( TBool aForcedMono );
       
   546 
       
   547     /**
       
   548      * From MRadioFmTunerObserver.
       
   549      * Called when the squelch (muting the frequencies without broadcast) status change.
       
   550      * This may be caused by other applications.
       
   551      *
       
   552      * @since S60 3.2
       
   553      * @param aSquelch ETrue if squelch is enabled; EFalse otherwise.
       
   554      */
       
   555     void MrftoSquelchChange( TBool aSquelch );
       
   556 
       
   557     /**
       
   558      * From MRadioPresetObserver.
       
   559      * Called when a preset changes.
       
   560      *
       
   561      * NOTE: EPresetDeleted with aIndex == 0, indicates that all presets have been deleted.
       
   562      *
       
   563      * @since S60 3.2
       
   564      * @param aChange Change event type
       
   565      * @param aIndex Index to the preset that has changed. Zero means all presets.
       
   566      */
       
   567     void MrpeoPresetChanged( TPresetChangeEvent aChange, TInt aIndex );
       
   568      /**
       
   569  	* From base class MFMRadioSystemEventDetectorObserver
       
   570 	* This callback notifies when networks comes up.
       
   571 	*/
       
   572 	void NetworkUpCallbackL();
       
   573 	/**
       
   574 	* From base class MFMRadioSystemEventDetectorObserver
       
   575 	* This callback notifies when network goes down.
       
   576 	*/
       
   577 	void NetworkDownCallbackL();
       
   578 	
       
   579 	/**
       
   580 	* From base class MFMRadioSystemEventDetectorObserver
       
   581 	* This callback notifies when audio resources become available.
       
   582 	*/
       
   583 	void AudioResourcesAvailableL();
       
   584 	
       
   585 	/**
       
   586     * From base class MFMRadioSystemEventDetectorObserver
       
   587 	* This callback notifies when audio auto resuming is forbidden.
       
   588 	*/
       
   589 	void AudioAutoResumeForbiddenL();
       
   590 	/**
       
   591 	* From base class MFMRadioSystemEventDetectorObserver
       
   592 	* This callback notifies when call becomes active.
       
   593 	*/
       
   594 	void CallActivatedCallbackL();
       
   595 
       
   596 	/**
       
   597 	* From base class MFMRadioSystemEventDetectorObserver
       
   598 	* This callback notifies when call becomes deactive.
       
   599 	*/
       
   600 	void CallDeactivatedCallbackL();	
       
   601 	/**
       
   602     * From base class MFMRadioNetworkChangeObserver
       
   603     * 
       
   604     * @see MFMRadioNetworkChangeObserver::NetworkIdChanged();
       
   605     */
       
   606     void NetworkIdChanged();
       
   607 
       
   608     // from base class MFMRAdioRdsObserver
       
   609     void RdsDataProgrammeService( const TDesC& aProgramService );
       
   610     void RdsDataPsNameIsStatic( TBool aStatic );
       
   611     void RdsDataRadioText( const TDesC& aRadioText );
       
   612     void RdsDataRadioTextPlus( const TInt aRTPlusClass, const TDesC& aRadioTextPlus );
       
   613     
       
   614     void RdsAfSearchBegin();
       
   615     void RdsAfSearchEnd( TUint32 aFrequency, TInt aError );
       
   616     void RdsAfSearchStateChange( TBool aEnabled );
       
   617     void RdsAvailable( TBool aAvailable );
       
   618     	
       
   619 	// from MFMRadioHeadsetEventObserver
       
   620 	void HeadsetAccessoryConnectedCallbackL();
       
   621 	void HeadsetAccessoryDisconnectedCallbackL();
       
   622 		
       
   623 	/**
       
   624     * Initialize fmradioengine resource file information
       
   625     */
       
   626 	void InitializeResourceLoadingL();	
       
   627 	/**
       
   628     * Convert FMRadio region info to frequency range used by fmradiotunerutility
       
   629     * @param aRegionId fmradio region
       
   630     * @return frequency range used by fmradiotunerutility
       
   631     */
       
   632 	TFmRadioFrequencyRange TunerFrequencyRangeForRegionId( const TInt aRegionId ) const;
       
   633 	/**
       
   634     * Determine current region
       
   635     * @return fmradio region
       
   636     */
       
   637 	IMPORT_C TFMRadioRegionSetting GetRegionL() const;
       
   638 	/**
       
   639     * fill the given list with fmradio regions
       
   640 	* @param aArray array to add regions
       
   641     */
       
   642 	IMPORT_C void FillListWithRegionDataL( CDesC16Array& aArray ) const;
       
   643 	/**
       
   644     * Returns region from the array of supported regions
       
   645     * @param aIndex index for region
       
   646     * @return fmradio region
       
   647     */
       
   648 	IMPORT_C TFMRadioRegionSetting RegionIdAtIndex( const TInt aIndex ) const;
       
   649 	/**
       
   650     * Returns current region Id
       
   651     * @return current region Id.
       
   652     */
       
   653 	IMPORT_C TInt RegionId() const;
       
   654 	/**
       
   655     * Change current region
       
   656     * @param aRegion region to set
       
   657     */
       
   658 	IMPORT_C void SetRegionIdL( TInt aRegion ) const;
       
   659 	/**
       
   660     * Request tuner control from fmradiotunerutility
       
   661     */
       
   662 	IMPORT_C void RequestTunerControl() const;
       
   663 	/**
       
   664     * Returns decimal count for current region MHz information
       
   665     * @return decimal count for current region
       
   666     */
       
   667 	IMPORT_C TInt DecimalCount() const;
       
   668 	/**
       
   669     * Return step size for tuning.
       
   670     * @return step size
       
   671     */
       
   672 	IMPORT_C TUint32 FrequencyStepSize() const;
       
   673 	/**
       
   674     * Returns a reference to P&S interface.
       
   675     * Method leaves if iPubSub is not allocated
       
   676     *
       
   677     * @return PS& interface.
       
   678     */	
       
   679 	IMPORT_C CFMRadioPubSub& PubSubL() const;
       
   680 	/**
       
   681 	* increases startup count by one and returns amount of app startups.
       
   682 	* 
       
   683 	* @return app startup count
       
   684 	*/
       
   685 	IMPORT_C TInt UpdatedStartupCount() const;
       
   686 	/**
       
   687     * Cancel seek and notify UI
       
   688     */
       
   689     IMPORT_C void CancelScanLocalStationsScan();
       
   690 	/**
       
   691      * Is routing between loudspeaker and headset possible
       
   692      *
       
   693      * @return ETrue, if routing is possible
       
   694      */
       
   695     IMPORT_C TBool IsAudioRoutingPossible() const;
       
   696 	
       
   697     /**
       
   698      * Has RT+ interaction tutorial dialog been shown to user.
       
   699      * 
       
   700      * @return ETrue after the first time user sees the dialog.
       
   701      */
       
   702     IMPORT_C TBool MusicStoreNoteDisplayed();
       
   703     
       
   704     /**
       
   705      * Sets music store tutorial note displayed value to true.
       
   706      * It needs to be false only before supported RT+ features
       
   707      * become available for the first time.
       
   708      */
       
   709     IMPORT_C void SetMusicStoreNoteDisplayed();
       
   710     
       
   711     /**
       
   712      * Get level of support for RT+ interactions.
       
   713      * Values are defined in fmradioengine.hrh:TFMRadioRTPlusLevel.
       
   714      * 
       
   715      * @return which interactions are supported as a TFMRadioRTPlusLevel value
       
   716      */
       
   717     IMPORT_C TFMRadioRTPlusLevel GetRTPlusSupportLevel();
       
   718         
       
   719     /**
       
   720      * Sets the currently active preset index
       
   721      * @param aIndex new active preset index
       
   722      */    
       
   723     IMPORT_C void SetCurrentPresetIndex( const TInt aIndex );
       
   724     
       
   725     /* Gets saved preset url.
       
   726      * @param aIndex channel index
       
   727      * @param aUrl string to be modified with saved url
       
   728      * @return error code. KErrNotFound if no url is saved or KErrOverflow
       
   729      * if the aUrl is not big enough. See TFmPresetName
       
   730      */
       
   731     IMPORT_C TInt PresetUrlL( TInt aIndex, TDes& aUrl );
       
   732     
       
   733     /*
       
   734      * Delete preset. With index -1 all preset are reseted
       
   735      * @param aIndex index to delete
       
   736      */
       
   737     IMPORT_C void DeletePresetL( TInt aIndex ); 
       
   738     
       
   739     /*
       
   740      * Saves given url to preset
       
   741      * @param aIndex channel index
       
   742      * @param aUrl url to save 
       
   743      */
       
   744     IMPORT_C void SaveUrlToPresetL( TInt aIndex, const TDesC& aUrl );
       
   745     
       
   746 private:
       
   747 
       
   748     /**
       
   749     * Default class constructor.
       
   750     */
       
   751     CRadioEngine( MRadioEngineStateChangeCallback& aCallback );
       
   752 
       
   753     /**
       
   754     * Second phase class constructor.
       
   755     */
       
   756     void ConstructL();
       
   757     
       
   758     /**
       
   759      * Updates the frequency into settings and P&S
       
   760      * 
       
   761      * @param aFrequency The frequency to be set
       
   762      */
       
   763     void StoreAndPublishFrequency( TInt aFrequency );
       
   764     
       
   765     // internal radio engine states
       
   766     enum TRadioEngineState
       
   767         {
       
   768         EStateRadioOff,
       
   769         EStateRadioOn,
       
   770         };
       
   771     
       
   772     // internal state of the tuner control
       
   773     enum TRadioTunerControlState
       
   774         {
       
   775         EStateRadioTunerControlUninitialized,
       
   776         EStateRadioTunerControlOn,
       
   777         EStateRadioTunerControlOff
       
   778         };
       
   779     
       
   780 private:
       
   781    
       
   782     // The Radio Utility
       
   783     CRadioUtility* iRadioUtility; // own
       
   784     // The Tuner Utility
       
   785     CRadioFmTunerUtility* iFmTunerUtility;
       
   786     // The Player Utility
       
   787     CRadioPlayerUtility* iPlayerUtility;
       
   788     // The Preset Utility
       
   789     CRadioFmPresetUtility* iPresetUtility; // own
       
   790     // Receives and notifies of the RDS data
       
   791     CFMRadioRdsReceiverBase* iRdsReceiver;  
       
   792     // Capabilities of the tuner
       
   793     TFmTunerCapabilities iTunerCaps;
       
   794     // Multiplier used to scale UI volume setting to volume level used by the player utility 
       
   795     TReal iUiVolumeFactor;
       
   796      // pointer to DosServerObserver
       
   797 #ifndef __ACCESSORY_FW
       
   798     CDosServerObserver *iDosServerObserver; //own
       
   799 #endif
       
   800     // Audio routing API
       
   801     CAudioOutput* iAudioOutput; //own
       
   802     // pointer to CCentralRepositoryHandler
       
   803     CCentralRepositoryHandler* iCentralRepositoryHandler; // own
       
   804     // Used to provide async behavior in some callbacks
       
   805     CRadioStateHandler *iStateHandler;
       
   806     // flag to indicate if a call is in progress
       
   807     TBool iInCall;
       
   808     // pointer to TRadioSettings
       
   809     TRadioSettings* iRadioSettings; // own
       
   810     // the current radio state
       
   811     TRadioEngineState iCurrentRadioState;
       
   812     // a reference of MRadioEngineStateChangeCallback object
       
   813     MRadioEngineStateChangeCallback& iCallback;
       
   814     // temperary frequency
       
   815     TInt iTempFrequency;
       
   816     // a flag indicating if tune prset is requestd
       
   817     TBool iTunePresetRequested;
       
   818     // Indicates a request to initialized the radio is pending
       
   819     TBool iInitializeRadioRequestExists;
       
   820     // Indicates if the tuner control has been granted.
       
   821     TRadioTunerControlState iTunerControl;
       
   822     // High and low frequency of the current band.
       
   823     TInt iBottomFrequency;
       
   824     TInt iTopFrequency;
       
   825     // ETrue if frequency was set by RDS AF
       
   826     TBool iFrequencySetByRdsAf;
       
   827     //Listens changes in network availability
       
   828     CFMRadioSystemEventDetector* iSystemEventDetector;
       
   829     // for fmradio engine resource file
       
   830     TInt iFMRadioEngineResourceOffset;
       
   831     //Listens changes in network ID and country code 
       
   832     CFMRadioMobileNetworkInfoListener* iNetworkInfoListener;
       
   833     //P&S interaction interface for FMRadio actions.
       
   834     CFMRadioPubSub* iPubSub;
       
   835     // accessory observer
       
   836     CFMRadioAccessoryConnection* iHeadsetObserver;
       
   837     // for storing station name for method GetPresetNameL
       
   838     TStationName iStationName;
       
   839     // Local cache for tuning state so that it doesn't get published before should
       
   840     TFMRadioPSTuningState iTuningState;
       
   841     };
       
   842 
       
   843 #endif  //FMRADIOENGINE_H
       
   844 
       
   845 // End of file