tactilefeedback/tactilefeedbackresolver/src/tactilefeedbackresolver.cpp
changeset 27 dabdd02a1ba9
parent 22 4838b44af342
child 30 fb04b611ffe7
equal deleted inserted replaced
22:4838b44af342 27:dabdd02a1ba9
    21 #include <e32std.h>
    21 #include <e32std.h>
    22 #include <e32debug.h>
    22 #include <e32debug.h>
    23 
    23 
    24 #include <centralrepository.h>
    24 #include <centralrepository.h>
    25 #include <ecom/implementationinformation.h>
    25 #include <ecom/implementationinformation.h>
       
    26 #include <ProfileEngineInternalCRKeys.h>
    26 
    27 
    27 #include "tactilefeedbackprivatecrkeys.h"
    28 #include "tactilefeedbackprivatecrkeys.h"
    28 #include "tactilefeedbackinternalpskeys.h"
    29 #include "tactilefeedbackinternalpskeys.h"
    29 #include "tactilefeedbacktrace.h"
    30 #include "tactilefeedbacktrace.h"
    30 
    31 
   101 //
   102 //
   102 CTactileFeedbackResolver::~CTactileFeedbackResolver()
   103 CTactileFeedbackResolver::~CTactileFeedbackResolver()
   103     {
   104     {
   104     delete iCenRepNotifier;
   105     delete iCenRepNotifier;
   105     delete iRepository;
   106     delete iRepository;
       
   107     delete iProfileRepository;
   106     delete iPropertyWatcher;
   108     delete iPropertyWatcher;
   107     delete iHapticsPlayer;
   109     delete iHapticsPlayer;
   108     delete iAudioPlayer;
   110     delete iAudioPlayer;
   109     REComSession::FinalClose();
   111     REComSession::FinalClose();
   110     }
   112     }
   116         iLastFeedback == ETouchFeedbackSensitiveItem )
   118         iLastFeedback == ETouchFeedbackSensitiveItem )
   117         {
   119         {
   118         return ETrue;
   120         return ETrue;
   119         }
   121         }
   120     
   122     
   121     return ( ( aFeedback == ETouchFeedbackPopUp || 
   123     return ( aFeedback == ETouchFeedbackPopUp || 
   122             aFeedback == ETouchFeedbackPopupOpen || 
   124             aFeedback == ETouchFeedbackPopupOpen || 
   123             aFeedback == ETouchFeedbackPopupClose ||
   125             aFeedback == ETouchFeedbackPopupClose ||
   124             aFeedback == ETouchFeedbackBounceEffect ||
   126             aFeedback == ETouchFeedbackBounceEffect ) &&
   125             aFeedback == ETouchFeedbackOptionsMenuOpen ||
       
   126             aFeedback == ETouchFeedbackOptionsMenuClosed ||
       
   127             aFeedback == ETouchFeedbackSubMenuOpen ||
       
   128             aFeedback == ETouchFeedbackSubMenuClosed ) &&
       
   129             ( iLastFeedback == ETouchFeedbackBasicButton ||
   127             ( iLastFeedback == ETouchFeedbackBasicButton ||
   130             iLastFeedback == ETouchFeedbackSensitiveButton ||
   128             iLastFeedback == ETouchFeedbackSensitiveButton ||
   131             iLastFeedback == ETouchFeedbackSensitiveItem ||
   129             iLastFeedback == ETouchFeedbackSensitiveItem ||
   132             iLastFeedback == ETouchFeedbackBasicItem ||
   130             iLastFeedback == ETouchFeedbackBasicItem ||
   133             iLastFeedback == ETouchFeedbackCheckbox ) ) 
   131             iLastFeedback == ETouchFeedbackCheckbox );
   134             || (
       
   135              aFeedback == ETouchFeedbackPopUp && 
       
   136              ( iLastFeedback == ETouchFeedbackPopupOpen ||
       
   137               iLastFeedback == ETouchFeedbackOptionsMenuOpen ||
       
   138               iLastFeedback == ETouchFeedbackSubMenuOpen )
       
   139              );
       
   140     }
   132     }
   141 
   133 
   142 // ---------------------------------------------------------------------------
   134 // ---------------------------------------------------------------------------
   143 // We play feedback in case all three conditions are met:
   135 // We play feedback in case all three conditions are met:
   144 // 
   136 // 
   170         willPlay = ETrue;
   162         willPlay = ETrue;
   171         }
   163         }
   172     else if ( IsHigherThanPlaying( aFeedback ) )
   164     else if ( IsHigherThanPlaying( aFeedback ) )
   173         {
   165         {
   174         willPlay = ETrue;
   166         willPlay = ETrue;
       
   167         StopFeedback();
   175         }
   168         }
   176 
   169 
   177     if ( willPlay )
   170     if ( willPlay )
   178         {
   171         {
   179         // First store the timestamp of this feedback playing moment.
   172         // First store the timestamp of this feedback playing moment.
   193         if ( !iAudioEnabled )
   186         if ( !iAudioEnabled )
   194             {
   187             {
   195             aPlayAudio = EFalse;
   188             aPlayAudio = EFalse;
   196             }
   189             }
   197         
   190         
       
   191         // check silent mode, if device is in silent mode, 
       
   192         // audio feedback is not allowed.
       
   193         TInt err;
       
   194         TInt isAudioSupported;
       
   195         err = iProfileRepository->Get( KProEngSilenceMode, isAudioSupported );
       
   196         if ( KErrNone == err && 1 == isAudioSupported )
       
   197             {
       
   198             aPlayAudio = EFalse;
       
   199             }
       
   200 
   198         if ( ( aPlayVibra || aPlayAudio ) &&        // #1
   201         if ( ( aPlayVibra || aPlayAudio ) &&        // #1
   199                aFeedback != ETouchFeedbackNone )    // #2
   202                aFeedback != ETouchFeedbackNone )    // #2
   200             {
   203             {
   201             OstTrace0( TACTILE_PERFORMANCE, TACTILE_RESOLVER_PLAY_FEEDBACK_1, "e_TACTILE_RESOLVER_PLAY_FEEDBACK 1");
   204             OstTrace0( TACTILE_PERFORMANCE, TACTILE_RESOLVER_PLAY_FEEDBACK_1, "e_TACTILE_RESOLVER_PLAY_FEEDBACK 1");
   202             
   205             
   237 void CTactileFeedbackResolver::InitializeCrKeysL()    
   240 void CTactileFeedbackResolver::InitializeCrKeysL()    
   238     {
   241     {
   239     if ( !iRepository )
   242     if ( !iRepository )
   240         {
   243         {
   241         iRepository = CRepository::NewL( KCRUidTactileFeedback );    
   244         iRepository = CRepository::NewL( KCRUidTactileFeedback );    
   242         }    
   245         }
       
   246 
       
   247     if ( !iProfileRepository )
       
   248         {
       
   249         iProfileRepository = CRepository::NewL( KCRUidProfileEngine );
       
   250         }
   243     
   251     
   244     TInt minInterval(0);
   252     TInt minInterval(0);
   245     // Read and store minimun feedback interfal
   253     // Read and store minimun feedback interfal
   246     User::LeaveIfError( iRepository->Get( KTactileFeedbackMinimumInterval, 
   254     User::LeaveIfError( iRepository->Get( KTactileFeedbackMinimumInterval, 
   247                                           minInterval ) );
   255                                           minInterval ) );