tactilefeedback/tactilefeedbackresolver/plugins/tactiletoneplugin/inc/tactiletoneplayer.h
changeset 0 d54f32e146dd
equal deleted inserted replaced
-1:000000000000 0:d54f32e146dd
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Class for producing audio tone feedback.
       
    15 * Part of:      Tactile Feedback.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef C_TACTILETONEPLAYER_H
       
    20 #define C_TACTILETONEPLAYER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <mdaaudiotoneplayer.h> 
       
    24 #include <cenrepnotifyhandler.h>
       
    25 #include <touchlogicalfeedback.h>
       
    26 #include <MProfileChangeObserver.h>
       
    27 
       
    28 #include "tactileplayer.h"
       
    29 
       
    30 class CRepository;
       
    31 class MProfileEngine;
       
    32 class CProfileChangeNotifyHandler;
       
    33 /**
       
    34  *  Class for procuding audio tone feedback based on logical
       
    35  *  feedback type.
       
    36  *
       
    37  *  @since S60 5.2
       
    38  */
       
    39 NONSHARABLE_CLASS( CTactileTonePlayer ): public CTactilePlayer, 
       
    40                                          public MMdaAudioToneObserver,
       
    41                                          public MCenRepNotifyHandlerCallback,
       
    42                                          public MProfileChangeObserver
       
    43     {
       
    44     /**
       
    45      * Sound params for tone feedback. 
       
    46      */
       
    47     struct TTactileSoundParams
       
    48         {
       
    49         TInt iFrequency;
       
    50         TTimeIntervalMicroSeconds iDuration;
       
    51         TInt iVolume; // 0 = No physical feedback.
       
    52         };
       
    53         
       
    54     /**
       
    55      * State of tone playing.
       
    56      */
       
    57     enum TTactileToneState
       
    58         {
       
    59         ETactileTonePreparing,
       
    60         ETactileToneReady,
       
    61         ETactileTonePlaying,
       
    62         ETactileTonePlayPending,
       
    63         ETactileToneError
       
    64         };
       
    65 
       
    66 public:
       
    67 
       
    68     static CTactileTonePlayer* NewL( CRepository& aRepository );
       
    69 
       
    70 
       
    71     virtual ~CTactileTonePlayer();
       
    72 
       
    73  // from base class CTactilePlayer
       
    74     /**
       
    75      * @see CTactilePlayer.
       
    76      */
       
    77     TInt PlayFeedback( TTouchLogicalFeedback aFeedback );
       
    78     
       
    79     /**
       
    80      * @see CTactilePlayer.
       
    81      */
       
    82     TInt PlayPreviewFeedback( TInt aLevel, TTouchLogicalFeedback aFeedback );
       
    83     
       
    84 private: // From MMdaAudioToneObserver
       
    85 
       
    86     /**
       
    87      * From MMdaAudioToneObserver
       
    88      * Called when audio tone player utility has been configured.
       
    89      *
       
    90      * @param aError - KErrNone if operation was succesful. Otherwise one of
       
    91      *                 the standard Symbian OS error codes.
       
    92      */
       
    93     void MatoPrepareComplete( TInt aError );
       
    94     
       
    95     /**
       
    96      * From MMdaAudioToneObserver
       
    97      * Called when audio tone playing operation has completed.
       
    98      *
       
    99      * @param aError - KErrNone if operation was succesful. Otherwise one of
       
   100      *                 the standard Symbian OS error codes.
       
   101      */
       
   102     void MatoPlayComplete( TInt aError );
       
   103 
       
   104 private: // From MCenRepNotifyHandlerCallback.
       
   105 
       
   106     /**
       
   107      * @see MCenRepNotifyHandlerCallback.
       
   108      */
       
   109     void HandleNotifyInt( TUint32 aId, TInt aNewValue );
       
   110 
       
   111 private: // From MProfileChangeObserver
       
   112     /**
       
   113      * @see MProfileChangeObserver.
       
   114      */
       
   115     void HandleActiveProfileEventL( TProfileEvent aProfileEvent, 
       
   116                                     TInt aProfileId );
       
   117 
       
   118 private:
       
   119     /**
       
   120      * Constructror.
       
   121      */
       
   122     CTactileTonePlayer( CRepository& aRepository );
       
   123 
       
   124     /**
       
   125      * 2nd phase constructror.
       
   126      */
       
   127     void ConstructL();
       
   128     
       
   129     /**
       
   130      * Read settings values.
       
   131      */    
       
   132     void ReadSettings();
       
   133     
       
   134     /**
       
   135      * Scales given volume percentage to 0 - CMdaAudioToneUtility::MaxVolume.
       
   136      *
       
   137      * @param aPercentages - Volume level in percentages
       
   138      * @return Volume level that can be set to audio tone player.
       
   139      */
       
   140     TInt ScaleVolume( TInt aPercentages );
       
   141 
       
   142     /**
       
   143      * Profiles engine -related initializations.
       
   144      * (User changeable settings are stored in profiles)
       
   145      */
       
   146     void InitializeProfilesEngineL();
       
   147 
       
   148 private: // data
       
   149 
       
   150     /**
       
   151      * Current state of the player.
       
   152      */
       
   153     TTactileToneState iState;
       
   154 
       
   155     /**
       
   156      * Audio tone player utility used for producing sound feedback.
       
   157      * Own. 
       
   158      */
       
   159     CMdaAudioToneUtility* iMdaAudioToneUtility;
       
   160     
       
   161     /**
       
   162      * Physical feedback definitions
       
   163      */
       
   164     RArray<TTactileSoundParams> iSoundParams;
       
   165     
       
   166     /**
       
   167      * Currently loaded sound parameters (index is to iSoundParams array)
       
   168      */
       
   169     TInt iCurrentEffectIndex;
       
   170 
       
   171     /**
       
   172      * Reference to CenRep session
       
   173      * Not own
       
   174      */
       
   175     CRepository& iRepository;
       
   176     
       
   177     /**
       
   178      * Utility for listening to changes in configurable parameters.
       
   179      * Own.  
       
   180      */
       
   181     CCenRepNotifyHandler* iCenRepNotifier;    
       
   182     
       
   183     /**
       
   184      * Current audio volume level.
       
   185      */
       
   186     TInt iAudioLevel;
       
   187 
       
   188     /**
       
   189      * Original audio volume level is saved here in preview playing.
       
   190      */    
       
   191     TInt iOriginalLevel;
       
   192     
       
   193     /**
       
   194      * This flag indicates if preview is played. This is needed because original 
       
   195      * settings have to be returned after preview.
       
   196      */    
       
   197     TBool iPlayPreview;
       
   198     
       
   199     /**
       
   200      * Access to user changeable settings (stored into profiles)
       
   201      * Own.
       
   202      */
       
   203      MProfileEngine* iProfileEng;
       
   204 
       
   205     /**
       
   206      * For listening to changes in profiles.
       
   207      * Own.  
       
   208      */
       
   209     CProfileChangeNotifyHandler* iProfileHandler;
       
   210     };
       
   211 
       
   212 
       
   213 #endif // C_TACTILETONEPLAYER_H