resourcemgmt/hwresourcesmgr/server/inc/HWRMFmTxCommonData.h
changeset 0 4e1aa6a622a0
child 78 3f0699f2e14c
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2006-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 
       
    19 
       
    20 #ifndef HWRMFMTXCOMMONDATA_H
       
    21 #define HWRMFMTXCOMMONDATA_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <centralrepository.h>
       
    26 #include "HWRMFmTxData.h"
       
    27 #include "HWRMFmTxAudioPolicyDomainPSKeys.h"
       
    28 #include "HWRMPSChangeObserver.h"
       
    29 #include "HWRMFmTxCommands.h"
       
    30 #include "HWRMPluginHandler.h"
       
    31 #include "HWRMFmTxPowersaveTimer.h"
       
    32 
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CHWRMFmTxRdsTextConverter;
       
    36 class CHWRMFmTxStateUtility;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 * Container for FM Tx data that is common for all sessions.
       
    42 * Also handles FM Tx related cenrep and P&S data.
       
    43 * HWRM server upkeeps the instance.
       
    44 */
       
    45 class CHWRMFmTxCommonData : public CBase, 
       
    46                             public MHWRMIndicationHandler
       
    47     {
       
    48     public:
       
    49     
       
    50         /**
       
    51         * Possible power save reasons
       
    52         * 0: power-save off
       
    53         * Non-zero: power-save on
       
    54         */
       
    55         enum TFmTxPowerSaveFlag
       
    56             {
       
    57             EHWRMFmTxPowerSaveOff        = 0,
       
    58             EHWRMFmTxPowerSaveInactivity = 1, // due to inactivity timeout
       
    59             EHWRMFmTxPowerSaveAccessory  = 2  // due to mutually exclusive accessory connected
       
    60             };
       
    61 
       
    62         enum TFmTxStateTransition
       
    63             {
       
    64             EFmTxStateTransError        = 0, // Unknown error event 
       
    65             EFmTxStateTransOff          = 1, // HW disabled event       
       
    66             EFmTxStateTransRequestedOff = 2, // User requested disable event                
       
    67             EFmTxStateTransOn           = 3, // HW enabled event 
       
    68             EFmTxStateTransScanning     = 4  // RSSI scanning in progress
       
    69             };
       
    70     
       
    71         // Constructors and Destructor
       
    72     
       
    73         /**
       
    74         * Two-phased constructor.
       
    75         *
       
    76         * @param aPluginHandler Pointer to plugin handler for FM Tx
       
    77         * @param aReservationHandler Pointer to reservation handler for FM Tx
       
    78         */
       
    79         static CHWRMFmTxCommonData* NewL();
       
    80         
       
    81         /**
       
    82         * Destructor.
       
    83         */
       
    84         virtual ~CHWRMFmTxCommonData();
       
    85         
       
    86     public: // From MHWRMIndicationHandler
       
    87                 
       
    88         /**
       
    89         * Process indications from from plugin handler
       
    90         *
       
    91         * @param aId  The indication ID
       
    92         * @param aData  Data associated with the indication. 
       
    93         *
       
    94         */
       
    95         virtual void ProcessIndicationL( const TUint32 aId, TDesC8& aData );
       
    96         
       
    97     public: // New functions
       
    98 
       
    99         /**
       
   100         * Getter for Tx status
       
   101         *
       
   102         * @return TFmTxState The current status.
       
   103         */
       
   104         inline TFmTxState Status() const;       
       
   105         
       
   106         /**
       
   107         * Tests whether FM Tx is available as an audio output, in a given state
       
   108         *
       
   109         * @param aState The FM Tx state to test
       
   110         * @return THWRMFmTxAvailableFlag FM Tx available status
       
   111         */
       
   112         THWRMFmTxAvailableFlag FmTxAvailableState( TFmTxState aState ) const;
       
   113 
       
   114         /**
       
   115         * Tests whether FM Tx hardware is currently powered up
       
   116         *
       
   117         * @return TBool ETrue if FM Tx has been powered up
       
   118         */
       
   119         inline TBool IsFmTxHardwareOn() const;
       
   120 
       
   121         /**
       
   122         * Returns whether the FM Tx is considered to be powered up in the given state.
       
   123         *
       
   124         * @param aState The FM Tx state to be evaluated.
       
   125         * @return TBool ETrue if the FM Tx is active in the given state
       
   126         */      
       
   127         inline TBool IsFmTxHardwareOn( TFmTxState aState ) const;
       
   128 
       
   129         /**
       
   130         * Reads and updates the power save flag set by Audio Policy (for any reason)
       
   131         * Method is needed for getting up-to-date state information, because
       
   132         * observer is not run yet in all cases, where status is already changed.
       
   133         *
       
   134         * @param aState The FM Tx power save state               
       
   135         */
       
   136         void UpdatePowerSaveState( TFmTxPowerSaveFlag aState );
       
   137         
       
   138         /**
       
   139         * Tests whether the power save flag has been set by Audio Policy (for any reason)
       
   140         *
       
   141         * @return TBool ETrue if FM Tx power save flag is set
       
   142         */
       
   143         TBool IsPowerSaveOn();     
       
   144         
       
   145         /**
       
   146         * Tests whether an access the power save flag has been set by Audio Policy, due 
       
   147         * to a mutually exclusive accessory connection.
       
   148         *
       
   149         * @return TBool ETrue if FM Tx power save flag has been set to EHWRMFmTxPowerSaveAccessory
       
   150         */
       
   151         TBool IsAccessoryPowerSaveOn();        
       
   152 
       
   153         /**
       
   154         * Tests whether FM Tx is currently an active audio output
       
   155         * This is determined by Audio Policy
       
   156         *
       
   157         * @return TBool ETrue if FM Tx audio routed flag is set
       
   158         */
       
   159         TBool IsAudioRouted();             
       
   160 
       
   161         /**
       
   162         * Publish FM Tx status
       
   163         *
       
   164         * @param aEvent Event which requires status update
       
   165         */
       
   166         void UpdateStatus(TFmTxStateTransition aEvent);
       
   167 
       
   168         /**
       
   169         * Query whether frequency range has been updated.
       
   170         * Initially CenRep does not contain valid frequency range settings.
       
   171         * @return TBool ETrue if frequency range has been updated.
       
   172         */
       
   173         inline TBool FrequencyRangeUpdated() const;
       
   174   
       
   175         /**
       
   176         * Setter for Tx frequency range.
       
   177         * This should be called once (only), before calls to GetFrequencyRange are valid.
       
   178         */
       
   179         void SetFrequencyRange(TInt aMinFrequency, TInt aMaxFrequency, TInt aStepSize);
       
   180 
       
   181         /**
       
   182         * Getter for Tx frequency.
       
   183         *
       
   184         * @return TInt The current frequency.
       
   185         */
       
   186         inline TInt Frequency() const;
       
   187 
       
   188         /**
       
   189         * Publish FM Tx status.  Note that frequency values
       
   190         * are persistent i.e. stored in CenRep (not P&S)
       
   191         *
       
   192         * @param aFrequency The new frequency to be published.
       
   193         */
       
   194         void UpdateFrequency(TInt aFrequency);
       
   195 
       
   196         /**
       
   197         * Get pointer to Unicode->RDS text converter.
       
   198         *
       
   199         * @return CHWRMFmTxRdsTextConverter* Pointer to text converter
       
   200         */
       
   201         inline CHWRMFmTxRdsTextConverter* GetRdsTextConverter();
       
   202 
       
   203         /**
       
   204         * Getter for current RDS data
       
   205         *
       
   206         * @return TFmTxRdsData The current RDS data
       
   207         */
       
   208         inline TFmTxRdsData RdsData() const;
       
   209 
       
   210         /**
       
   211         * Getter for RDS PS string
       
   212         *
       
   213         * @param On return, the PS string (8bit RDS format)
       
   214         */
       
   215         inline const TDesC8& ConvertedRdsPs() const;
       
   216 
       
   217         /**
       
   218         * Getter for RDS PS string
       
   219         *
       
   220         * @param On return, the PTYN string (8bit RDS format)
       
   221         */
       
   222         inline const TDesC8& ConvertedRdsPtyn() const;
       
   223 
       
   224         /**
       
   225         * Queries whether RDS data has been set, since last boot
       
   226         *
       
   227         * @return TBool EFalse if RDS has not been set
       
   228         */
       
   229         inline TBool IsRdsInitialised() const;
       
   230 
       
   231         /**
       
   232         * Getter for power save timout
       
   233         *
       
   234         * @return Timeout in seconds
       
   235         */
       
   236         inline TUint32 PowerSaveTimeout() const;
       
   237 
       
   238         /**
       
   239         * Setter for RDS PTY data
       
   240         *
       
   241         * @param TRdsProgrammeType The new PTY
       
   242         */
       
   243         void UpdateRdsPty(const TRdsProgrammeType aData);
       
   244         
       
   245         /**
       
   246         * Setter for RDS PTYN data
       
   247         *
       
   248         * @param  The new PTYN
       
   249         */
       
   250         void UpdateRdsPtyn(const TRdsProgrammeTypeName& aData);
       
   251 
       
   252         /**
       
   253         * Setter for RDS MS data
       
   254         *
       
   255         * @param  The new Music/Speech flag
       
   256         */                  
       
   257         void UpdateRdsMs(const TBool aMusic);
       
   258         
       
   259         /**
       
   260         * Setter for RDS language ID data
       
   261         *
       
   262         * @param  The new language ID
       
   263         */          
       
   264         void UpdateRdsLanguageId(const TRdsLanguageIdType aLanguageId);   
       
   265             
       
   266     private:
       
   267     
       
   268         /**
       
   269         * C++ default constructor.
       
   270         */
       
   271         CHWRMFmTxCommonData();
       
   272 
       
   273         /**
       
   274         * By default Symbian 2nd phase constructor is private.
       
   275         */
       
   276         void ConstructL();       
       
   277 
       
   278         /**
       
   279         * Starts notifications and reads values from cenrep.  Used at startup.
       
   280         */
       
   281         void InitCenrepL();
       
   282 
       
   283         /**
       
   284         * Cleans up central repository related parameters.
       
   285         */
       
   286         void CleanCenrep();
       
   287         
       
   288         /**
       
   289         * Updates the common state data, after Audio Policy flag has been set/cleared.
       
   290         * Used by CHWRMFmTxStateUtility
       
   291         */
       
   292         void UpdateAudioStatus( TInt aAudioRoutedFlag );
       
   293 
       
   294     private:
       
   295 
       
   296         CRepository*           iRepository;              // Cenrep client
       
   297         RProperty              iFmTxStatusProperty;      // P&S property for publishing FM Tx status
       
   298         RProperty              iFmTxIsAvailableProperty; // P&S property for notifications to Audio Policy
       
   299         RProperty              iFmTxPowerSaveProperty;   // P&S property for checking Audio Policy published power save state
       
   300         RProperty              iFmTxAudioRoutingProperty;// P&S property for checking Audio Policy published audio routing state
       
   301         TFmTxState             iFmTxState;               // Cached FM Tx state
       
   302         TInt                   iFmTxFrequency;           // Cached FM Tx frequency
       
   303 		TBool                  iFrequencyRangeUpdated;   // Flags whether frequency range is valid in CenRep
       
   304         
       
   305         // Audio Policy publishes these state variables                                                         
       
   306         TFmTxPowerSaveFlag     iFmTxPowerSaveFlag;   // Cached power save flag
       
   307         TBool                  iFmTxAudioRoutedFlag; // Cached audio routed flag
       
   308 
       
   309         TSecureId              iFmTxAudioRoutingSid;  // Configurable SID protection for KHWRMFmTxAudioRoutedFlag
       
   310         TUint32                iFmTxPowerSaveTimeout; // Timeout configuration as micro seconds for power save mode.
       
   311 
       
   312         // RDS
       
   313         TBool                      iRdsInitialised;   // Flag to check whether RDS (particularly PS) has been set
       
   314         CHWRMFmTxRdsTextConverter* iRdsTextConverter; // Converts unicode <-> 8bit RDS text. Owned.
       
   315         TFmTxRdsData               iRdsData;          // RDS settings
       
   316         HWRMFmTxCommand::TRdsPs    iRdsConvertedPs;   // Text converted into 8bit RDS format
       
   317         HWRMFmTxCommand::TRdsPtyn  iRdsConvertedPtyn; // Text converted into 8bit RDS format
       
   318         
       
   319     public: // Friend classes
       
   320     
       
   321         friend class CHWRMFmTxStateUtility;
       
   322     };
       
   323 
       
   324 #include "HWRMFmTxCommonData.inl"
       
   325 
       
   326 #endif  // HWRMFMTXCOMMONDATA_H
       
   327             
       
   328 // End of File