phoneapp/phoneuiview/src/cphoneaudiocontroller.cpp
branchRCL_3
changeset 58 40a3f856b14d
parent 0 5f000ab63145
equal deleted inserted replaced
57:94dc1107e8b2 58:40a3f856b14d
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <aknnavi.h>
    20 #include <aknnavi.h>
    21 #include <aknnavide.h>
    21 #include <aknnavide.h>
    22 #include <StringLoader.h>
    22 
    23 #include <avkon.rsg>
    23 #include <avkon.rsg>
    24 #include <phoneui.rsg>
    24 
    25 #include <telephonyvariant.hrh>
    25 #include <telephonyvariant.hrh>
    26 #include <eikenv.h>
    26 #include <eikenv.h>
    27 #include <eikappui.h>
    27 #include <eikappui.h>
    28 #include <AknUtils.h>
    28 #include <AknUtils.h>
    29 #include "cphoneaudiocontroller.h"
    29 #include "cphoneaudiocontroller.h"
    37 #include "phoneconstants.h"
    37 #include "phoneconstants.h"
    38 #include "phonelogger.h"
    38 #include "phonelogger.h"
    39 #include "phoneui.hrh"
    39 #include "phoneui.hrh"
    40 
    40 
    41 // CONSTANTS
    41 // CONSTANTS
    42 // Defines how long time volume control is shown when volume is changed 
       
    43 // while device is muted. Duration in microseconds.
       
    44 const TInt KPhoneDelayVolumeControlToDefaultAfterReleased = 1000000;
       
    45 
    42 
    46 // ================= MEMBER FUNCTIONS =======================
    43 // ================= MEMBER FUNCTIONS =======================
    47 // C++ default constructor can NOT contain any code, that
    44 // C++ default constructor can NOT contain any code, that
    48 // might leave.
    45 // might leave.
    49 //
    46 //
    79         R_AVKON_NAVI_PANE_VOLUME_INDICATOR );
    76         R_AVKON_NAVI_PANE_VOLUME_INDICATOR );
    80         
    77         
    81     // To get touch input, pen check in HandleControlEventL()
    78     // To get touch input, pen check in HandleControlEventL()
    82     iEarVolumeControl->DecoratedControl()->SetObserver( this );
    79     iEarVolumeControl->DecoratedControl()->SetObserver( this );
    83     iIhfVolumeControl->DecoratedControl()->SetObserver( this );            
    80     iIhfVolumeControl->DecoratedControl()->SetObserver( this );            
    84   
       
    85     // Create "muted" navi decorator
       
    86     HBufC* mutedText = StringLoader::LoadLC( R_PHONE_INCALL_MUTED_PANE );
       
    87     iMutedControl = iStatusPane->NaviPane().CreateMessageLabelL( *mutedText );
       
    88     CleanupStack::PopAndDestroy( mutedText );
       
    89         
       
    90     iNaviPaneUpdateTimer = CPhoneTimer::NewL();
       
    91 
    81 
    92     iActivateRecoveryId = CPhoneRecoverySystem::Instance()->AddL( 
    82     iActivateRecoveryId = CPhoneRecoverySystem::Instance()->AddL( 
    93         TCallBack( DoRecoverActivateL, this ),
    83         TCallBack( DoRecoverActivateL, this ),
    94         CTeleRecoverySystem::EPhonePriorityStandard,
    84         CTeleRecoverySystem::EPhonePriorityStandard,
    95         CTeleRecoverySystem::EPhoneStateIdle );   
    85         CTeleRecoverySystem::EPhoneStateIdle );   
   119 CPhoneAudioController::~CPhoneAudioController()
   109 CPhoneAudioController::~CPhoneAudioController()
   120     {
   110     {
   121     CCoeEnv::Static()->RemoveForegroundObserver( *this );
   111     CCoeEnv::Static()->RemoveForegroundObserver( *this );
   122     CPhoneRecoverySystem::Remove( iActivateRecoveryId );
   112     CPhoneRecoverySystem::Remove( iActivateRecoveryId );
   123      
   113      
   124     delete iNaviPaneUpdateTimer;   
       
   125     delete iMutedControl;
       
   126     delete iIhfVolumeControl;
   114     delete iIhfVolumeControl;
   127     delete iEarVolumeControl;
   115     delete iEarVolumeControl;
   128     }
   116     }
   129 
   117 
   130 // ---------------------------------------------------------
   118 // ---------------------------------------------------------
   136     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioController::ActivateVolumeControlL()");
   124     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioController::ActivateVolumeControlL()");
   137     iVolumeControlCount++;
   125     iVolumeControlCount++;
   138     if ( iVolumeControlCount == 1 ) // First time activation
   126     if ( iVolumeControlCount == 1 ) // First time activation
   139         {
   127         {
   140         // Decide whether decorator should be Ear or ihf decorator
   128         // Decide whether decorator should be Ear or ihf decorator
   141         CAknNavigationDecorator& selectedDecorator = SelectDecoratorL(); 
   129         CAknNavigationDecorator& selectedVolumeDecorator =VolumeDecorator();  
   142         PushL( selectedDecorator ); 
   130         PushL( selectedVolumeDecorator ); 
   143         }
   131         }
   144     }
   132     }
   145 
   133 
   146 // ---------------------------------------------------------
   134 // ---------------------------------------------------------
   147 // CPhoneAudioController::DoRecoverUpdateL
   135 // CPhoneAudioController::DoRecoverUpdateL
   166     {
   154     {
   167     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioController::ActivateL()");
   155     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioController::ActivateL()");
   168     
   156     
   169     if( iVolumeControlCount )
   157     if( iVolumeControlCount )
   170         {
   158         {
   171         // Decide whether decorator should be Ear, Ihf or Muted decorator
   159         // Decide whether decorator should be Ear, Ihf decorator
   172         CAknNavigationDecorator& selectedDecorator = SelectDecoratorL(); 
   160         CAknNavigationDecorator& selectedVolumeDecorator = VolumeDecorator(); 
   173         PushL( selectedDecorator );     
   161         PushL( selectedVolumeDecorator );                    
   174         
   162         TInt volumeLevel = VolumeLevel();             
   175         if( &selectedDecorator != iMutedControl )
   163         SetVolumeLevel( VolumeControl(), volumeLevel );                       
   176             {            
       
   177             TInt volumeLevel = VolumeLevel(); 
       
   178             
       
   179             SetVolumeLevel( VolumeControl(), volumeLevel );                 
       
   180             }      
       
   181         }
   164         }
   182     }
   165     }
   183     
   166     
   184 // ---------------------------------------------------------
   167 // ---------------------------------------------------------
   185 // CPhoneAudioController::DeactivateVolumeControl
   168 // CPhoneAudioController::DeactivateVolumeControl
   222         iIhfVolume = volumeParam->Integer();
   205         iIhfVolume = volumeParam->Integer();
   223         }
   206         }
   224     else
   207     else
   225         {
   208         {
   226         iEarVolume = volumeParam->Integer();
   209         iEarVolume = volumeParam->Integer();
   227         }
       
   228     
       
   229     if( iMuted )
       
   230         {
       
   231         // Enable timed control transition in muted state    
       
   232         iTimedMuteTransferPending = ETrue; 
       
   233         }
       
   234     else
       
   235         {        
       
   236         iTimedMuteTransferPending = EFalse; 
       
   237         }
   210         }
   238      
   211      
   239     // Activate the approriate volume control
   212     // Activate the approriate volume control
   240     CPhoneRecoverySystem::Instance()->RecoverNow( 
   213     CPhoneRecoverySystem::Instance()->RecoverNow( 
   241         iActivateRecoveryId, 
   214         iActivateRecoveryId, 
   242         CTeleRecoverySystem::EPhonePriorityStandard );
   215         CTeleRecoverySystem::EPhonePriorityStandard );
   243 
   216     
   244     if( iTimedMuteTransferPending )    
       
   245         {
       
   246         iTimedMuteTransferPending = EFalse;     
       
   247         
       
   248         // Cancel any pending request
       
   249         iNaviPaneUpdateTimer->CancelTimer();
       
   250 
       
   251         // Activate change to Muted decorator after given delay        
       
   252         iNaviPaneUpdateTimer->After(                    
       
   253             KPhoneDelayVolumeControlToDefaultAfterReleased,
       
   254             TCallBack( DoUpdateNaviPaneToDefault, this ) );           
       
   255         }
       
   256     }
   217     }
   257     
   218     
   258 // ---------------------------------------------------------
   219 // ---------------------------------------------------------
   259 // CPhoneAudioController::HandleIhfChange
   220 // CPhoneAudioController::HandleIhfChange
   260 //
   221 //
   267     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioController::HandleIhfChange()");
   228     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioController::HandleIhfChange()");
   268     TPhoneCmdParamBoolean* booleanParam =
   229     TPhoneCmdParamBoolean* booleanParam =
   269         static_cast<TPhoneCmdParamBoolean*>( aCommandParam );
   230         static_cast<TPhoneCmdParamBoolean*>( aCommandParam );
   270     
   231     
   271     iIhfMode = booleanParam->Boolean();    
   232     iIhfMode = booleanParam->Boolean();    
   272     
       
   273     // Set state transition flag 
       
   274     iIhfTransferPending = ETrue; 
       
   275     }
       
   276     
       
   277 // ---------------------------------------------------------
       
   278 // CPhoneAudioController::HandleMuteChange
       
   279 //
       
   280 // Updates incall indicator according to current call state.
       
   281 // ---------------------------------------------------------
       
   282 //
       
   283 void CPhoneAudioController::HandleMuteChange(
       
   284     TPhoneCommandParam* aCommandParam )
       
   285     {
       
   286     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioController::HandleMuteChange()");
       
   287     TPhoneCmdParamBoolean* booleanParam =
       
   288         static_cast<TPhoneCmdParamBoolean*>( aCommandParam );
       
   289 
       
   290     iMuted = booleanParam->Boolean();
       
   291     
       
   292     // Decide whether decorator should be ear, ihf or muted decorator
       
   293     TRAP_IGNORE( PushL( SelectDecoratorL() ) );
       
   294     }
   233     }
   295     
   234     
   296 // -----------------------------------------------------------------------------
   235 // -----------------------------------------------------------------------------
   297 // CPhoneAudioController::PushL
   236 // CPhoneAudioController::PushL
   298 // -----------------------------------------------------------------------------
   237 // -----------------------------------------------------------------------------
   314 
   253 
   315     if ( err == KErrNone )
   254     if ( err == KErrNone )
   316         {
   255         {
   317         iOldControl = &aNew;
   256         iOldControl = &aNew;
   318         }
   257         }
   319     }
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CPhoneAudioController::DoUpdateNaviPaneToDefault
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 TInt CPhoneAudioController::DoUpdateNaviPaneToDefault( TAny* aAny )
       
   326     {
       
   327     __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneAudioController::DoUpdateNaviPaneToDefault()");
       
   328     CPhoneAudioController* self = static_cast< CPhoneAudioController* >( aAny );
       
   329     CPhoneRecoverySystem::Instance()->RecoverNow( 
       
   330         self->iActivateRecoveryId, 
       
   331         CTeleRecoverySystem::EPhonePriorityStandard );
       
   332     return KErrNone;
       
   333     }
   258     }
   334 
   259 
   335 // -----------------------------------------------------------------------------
   260 // -----------------------------------------------------------------------------
   336 // CPhoneAudioController::HandleControlEventL
   261 // CPhoneAudioController::HandleControlEventL
   337 // -----------------------------------------------------------------------------
   262 // -----------------------------------------------------------------------------
   440         
   365         
   441     return volumeLevel;
   366     return volumeLevel;
   442     }
   367     }
   443 
   368 
   444 // -----------------------------------------------------------------------------
   369 // -----------------------------------------------------------------------------
   445 // CPhoneAudioController::SelectDecoratorL
       
   446 // -----------------------------------------------------------------------------
       
   447 //    
       
   448 CAknNavigationDecorator& CPhoneAudioController::SelectDecoratorL()
       
   449     {
       
   450     __LOGMETHODSTARTEND( EPhoneUIView,"CPhoneAudioController::SelectDecoratorL()" );                                     
       
   451     CAknNavigationDecorator* newDecorator = NULL;    
       
   452     if ( !iMuted )
       
   453         {
       
   454         __PHONELOG( EBasic, EPhoneUIView,"CPhoneAudioController::SelectDecoratorL() - volume decorator " );     
       
   455         newDecorator = &VolumeDecorator();
       
   456         }
       
   457     else 
       
   458         {
       
   459         if ( iIhfTransferPending || !iTimedMuteTransferPending )
       
   460             {
       
   461             __PHONELOG( EBasic, EPhoneUIView,"CPhoneAudioController::SelectDecoratorL() - muted decorator " );         
       
   462             newDecorator = iMutedControl;    
       
   463             }            
       
   464         else 
       
   465             {
       
   466             __PHONELOG( EBasic, EPhoneUIView,"CPhoneAudioController::SelectDecoratorL() - volume decorator " );         
       
   467             newDecorator = &VolumeDecorator();
       
   468             
       
   469             // In muted state the volume decorator must be first 
       
   470             // pushed to container to enable volume popup showing 
       
   471             PushL( *newDecorator );             
       
   472             }
       
   473         }
       
   474 
       
   475     // Clear IHF transfer flag. 
       
   476     iIhfTransferPending = EFalse;
       
   477            
       
   478     return *newDecorator;         
       
   479     }
       
   480 
       
   481 // -----------------------------------------------------------------------------
       
   482 // CPhoneAudioController::SetVolumeLevel
   370 // CPhoneAudioController::SetVolumeLevel
   483 // -----------------------------------------------------------------------------
   371 // -----------------------------------------------------------------------------
   484 //    
   372 //    
   485 void CPhoneAudioController::SetVolumeLevel(
   373 void CPhoneAudioController::SetVolumeLevel(
   486     CAknVolumeControl& aVolumeControl, 
   374     CAknVolumeControl& aVolumeControl,