phoneapp/phoneuicontrol/src/cphonestateincoming.cpp
changeset 0 5f000ab63145
child 14 24062c24fe38
child 21 92ab7f8d0eab
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2005-2008 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: Implementation of CPhoneStateIncoming class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <cntdef.h>
       
    21 #include <e32base.h>
       
    22 #include <eikenv.h>
       
    23 #include <featmgr.h>
       
    24 #include <StringLoader.h>
       
    25 #include <dundomainpskeys.h>
       
    26 #include <telephonyvariant.hrh>
       
    27 #include <ScreensaverInternalPSKeys.h>
       
    28 #include <mpeengineinfo.h>
       
    29 #include <MediatorDomainUIDs.h>
       
    30 #include <videotelcontrolmediatorapi.h>
       
    31 
       
    32 #include "cphonepubsubproxy.h"
       
    33 #include "phoneui.pan"
       
    34 #include "cphonestateincoming.h"
       
    35 #include "tphonecmdparamboolean.h"
       
    36 #include "tphonecmdparamcallheaderdata.h"
       
    37 #include "tphonecmdparaminteger.h"
       
    38 #include "tphonecmdparamcallstatedata.h"
       
    39 #include "tphonecmdparamringtone.h"
       
    40 #include "tphonecmdparamsfidata.h"
       
    41 #include "tphonecmdparamstring.h"
       
    42 #include "tphonecmdparamglobalnote.h"
       
    43 #include "tphonecmdparamdynmenu.h"
       
    44 #include "mphonestatemachine.h"
       
    45 #include "phonestatedefinitions.h"
       
    46 #include "phoneui.hrh"
       
    47 #include "phonerssbase.h"
       
    48 #include "cphonemainresourceresolver.h"
       
    49 #include "phonelogger.h"
       
    50 #include "cphonecenrepproxy.h"
       
    51 #include "cphonepubsubproxy.h"
       
    52 #include "tphonecmdparamquery.h"
       
    53 #include "cphonemediatorfactory.h"
       
    54 #include "cphonemediatorsender.h"
       
    55 #include "cphonereleasecommand.h"
       
    56 #include "mphonecustomization.h"
       
    57 #include "mphonestorage.h"
       
    58 
       
    59 // ================= MEMBER FUNCTIONS =======================
       
    60 
       
    61 // C++ default constructor can NOT contain any code, that
       
    62 // might leave.
       
    63 //
       
    64 EXPORT_C CPhoneStateIncoming::CPhoneStateIncoming(
       
    65     MPhoneStateMachine* aStateMachine,
       
    66     MPhoneViewCommandHandle* aViewCommandHandle,
       
    67     MPhoneCustomization* aPhoneCustomization ) :
       
    68     CPhoneState( aStateMachine, aViewCommandHandle, aPhoneCustomization )
       
    69     {
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------
       
    73 // CPhoneStateIncoming::~CPhoneStateIncoming()
       
    74 // Destructor
       
    75 // (other items were commented in a header).
       
    76 // -----------------------------------------------------------
       
    77 //
       
    78 EXPORT_C CPhoneStateIncoming::~CPhoneStateIncoming()
       
    79     {
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------
       
    83 // CPhoneStateIncoming::ConstructL()
       
    84 // Constructor
       
    85 // (other items were commented in a header).
       
    86 // -----------------------------------------------------------
       
    87 //
       
    88 EXPORT_C void CPhoneStateIncoming::ConstructL()
       
    89     {
       
    90     CPhoneState::BaseConstructL();
       
    91     
       
    92     // Fetch incoming call's id from view
       
    93     TPhoneCmdParamCallStateData callStateData;
       
    94     callStateData.SetCallState( EPEStateRinging );
       
    95     iViewCommandHandle->HandleCommandL(
       
    96         EPhoneViewGetCallIdByState, &callStateData );
       
    97 
       
    98     // Do nothing if negative incoming call id
       
    99     if( callStateData.CallId() > KErrNotFound  )
       
   100         {
       
   101         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
       
   102         
       
   103         iRingingCallId = callStateData.CallId();
       
   104         }
       
   105     else
       
   106         {
       
   107         __PHONELOG( EOnlyFatal, EPhoneControl,
       
   108             "CPhoneStateIncoming::ConstructL - incoming call already in disconnecting state!");
       
   109         }
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------
       
   113 // CPhoneStateIncoming::NewL()
       
   114 // Constructor
       
   115 // (other items were commented in a header).
       
   116 // -----------------------------------------------------------
       
   117 //
       
   118 CPhoneStateIncoming* CPhoneStateIncoming::NewL(
       
   119     MPhoneStateMachine* aStateMachine,
       
   120     MPhoneViewCommandHandle* aViewCommandHandle,
       
   121     MPhoneCustomization* aPhoneCustomization )
       
   122     {
       
   123     CPhoneStateIncoming* self = new (ELeave) CPhoneStateIncoming(
       
   124         aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
   125 
       
   126     CleanupStack::PushL( self );
       
   127     self->ConstructL();
       
   128     CleanupStack::Pop( self );
       
   129 
       
   130     return self;
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------
       
   134 // CPhoneStateIncoming::HandleKeyEventL
       
   135 // -----------------------------------------------------------
       
   136 //
       
   137 EXPORT_C void CPhoneStateIncoming::HandleKeyEventL(
       
   138     const TKeyEvent& aKeyEvent,
       
   139     TEventCode aEventCode )
       
   140     {
       
   141     __LOGMETHODSTARTEND(EPhoneControl,
       
   142         "CPhoneStateIncoming::HandleKeyEventL ()" );
       
   143     // Handle numeric keys when key events are received in incoming state
       
   144     CPhoneState::HandleKeyEventL( aKeyEvent, aEventCode );
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------
       
   148 // CPhoneStateIncoming::HandleNumberEntryClearedL()
       
   149 // -----------------------------------------------------------
       
   150 //
       
   151 EXPORT_C void CPhoneStateIncoming::HandleNumberEntryClearedL()
       
   152     {
       
   153     __LOGMETHODSTARTEND(EPhoneControl,
       
   154         "CPhoneStateIncoming::HandleNumberEntryClearedL ()" );
       
   155     // Set incoming call CBA when number entry is cleared
       
   156     iCbaManager->UpdateIncomingCbaL( iRingingCallId );
       
   157     UpdateSilenceButtonDimming();
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------
       
   161 // CPhoneStateIncoming::HandleKeyMessageL
       
   162 // -----------------------------------------------------------
       
   163 //
       
   164 EXPORT_C void CPhoneStateIncoming::HandleKeyMessageL(
       
   165     TPhoneKeyEventMessages aMessage,
       
   166     TKeyCode aCode )
       
   167     {
       
   168     __LOGMETHODSTARTEND( EPhoneControl,
       
   169         "CPhoneStateIncoming::HandleKeyMessageL ()" );
       
   170     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
   171         Panic( EPhoneCtrlInvariant ) );
       
   172 
       
   173     switch ( aCode )
       
   174         {
       
   175         // end-key
       
   176         case EKeyNo:
       
   177             {
       
   178             // handle long press
       
   179             if ( aMessage == EPhoneKeyLongPress )
       
   180                 {
       
   181                 // Close all connections
       
   182                 iStateMachine->SendPhoneEngineMessage(
       
   183                     MPEPhoneModel::EPEMessageTerminateAllConnections );
       
   184                 iViewCommandHandle->ExecuteCommandL( EPhoneViewCloseFSW );
       
   185 
       
   186                 if ( CPhoneState::IsNumberEntryUsedL() )
       
   187                     {
       
   188                     // Remove number entry from screen
       
   189                     iViewCommandHandle->ExecuteCommandL(
       
   190                         EPhoneViewRemoveNumberEntry );
       
   191                     // Do state-specific operation when number entry is cleared
       
   192                     HandleNumberEntryClearedL();
       
   193                     }
       
   194                 }
       
   195             else
       
   196                 {
       
   197                 // handle end key
       
   198                 DisconnectWaitingCallL();
       
   199                 }
       
   200             }
       
   201             break;
       
   202 
       
   203         // send-key
       
   204         case EKeyYes:
       
   205             if( CPhoneState::IsNumberEntryVisibleL() )
       
   206                 {
       
   207                 HandleSendL();
       
   208                 }
       
   209             else
       
   210                 {
       
   211                 // Answer the call
       
   212                 AnswerCallL();
       
   213                 }
       
   214             break;
       
   215 
       
   216         // OK key
       
   217         case EKeyDevice3:
       
   218             if ( aMessage == EPhoneKeyLongPress )
       
   219                 {
       
   220                 // Answer the call if long press of selection key
       
   221                 AnswerCallL();
       
   222                 }
       
   223             else if ( CPhoneCenRepProxy::Instance()->IsTelephonyFeatureSupported(
       
   224                         KTelephonyLVFlagCoverHideSendEndKey ))
       
   225                 {
       
   226                 // Open number entry OK menubar
       
   227                 OpenMenuBarL();
       
   228                 }
       
   229             break;
       
   230 
       
   231         case EKeyDeviceF:
       
   232                 {
       
   233                 __PHONELOG( EBasic, EPhoneUIStates,
       
   234                     "CPhoneConferenceAndSingleAndWaiting::HandleKeyMessageL-deviceF" );
       
   235                 HandleHoldSwitchL();
       
   236                 }
       
   237             break;
       
   238             
       
   239         default:
       
   240             break;
       
   241         }
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------
       
   245 // CPhoneStateIncoming::HandleSendL
       
   246 // -----------------------------------------------------------
       
   247 //
       
   248 void CPhoneStateIncoming::HandleSendL()
       
   249     {
       
   250     // Get the number entry contents
       
   251     HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
   252     TPtr ptr( phoneNumber->Des() );
       
   253 
       
   254     iStateMachine->PhoneEngineInfo()->SetPhoneNumber( ptr );
       
   255     iStateMachine->SendPhoneEngineMessage(
       
   256             MPEPhoneModel::EPEMessagePhoneNumberEdited );
       
   257     
       
   258     if ( phoneNumber->Des().Length() < KPhoneValidPhoneNumberLength 
       
   259     		&& iStateMachine->PhoneEngineInfo()->PhoneNumberIsServiceCode() ) 
       
   260         {
       
   261         // Send a manual control sequence by providing number
       
   262         // information with dial command
       
   263         CPhoneState::CallFromNumberEntryL();
       
   264         }
       
   265     else
       
   266         {
       
   267         iStateMachine->SendPhoneEngineMessage(
       
   268                 MPEPhoneModel::EPEMessageCheckEmergencyNumber );
       
   269         }
       
   270     CleanupStack::PopAndDestroy( phoneNumber );
       
   271     }
       
   272 
       
   273 // -----------------------------------------------------------
       
   274 // CPhoneStateIncoming::HandleKeyPressDurationL
       
   275 // -----------------------------------------------------------
       
   276 //
       
   277 EXPORT_C void CPhoneStateIncoming::HandleKeyPressDurationL(
       
   278     TKeyCode /*aCode*/,
       
   279     TTimeIntervalMicroSeconds /*aKeyPressDuration*/ )
       
   280     {
       
   281     __LOGMETHODSTARTEND(EPhoneControl,
       
   282         "CPhoneStateIncoming::HandleKeyPressDurationL ()" );
       
   283  
       
   284     }
       
   285 
       
   286 // -----------------------------------------------------------
       
   287 // CPhoneStateIncoming::HandlePhoneEngineMessageL
       
   288 // -----------------------------------------------------------
       
   289 //
       
   290 EXPORT_C void CPhoneStateIncoming::HandlePhoneEngineMessageL(
       
   291     const TInt aMessage,
       
   292     TInt aCallId )
       
   293     {
       
   294     __LOGMETHODSTARTEND(EPhoneControl,
       
   295         "CPhoneStateIncoming::HandlePhoneEngineMessageL ()" );
       
   296     switch ( aMessage )
       
   297         {
       
   298         case MEngineMonitor::EPEMessageIdle:
       
   299             HandleIdleL( aCallId );
       
   300             break;
       
   301 
       
   302         case MEngineMonitor::EPEMessageConnected:
       
   303             HandleConnectedL( aCallId );
       
   304             break;
       
   305 
       
   306         case MEngineMonitor::EPEMessageInValidEmergencyNumber:
       
   307             // Answer the call
       
   308             AnswerCallL();
       
   309             break;
       
   310 
       
   311         case MEngineMonitor::EPEMessageValidEmergencyNumber:
       
   312             DialVoiceCallL();
       
   313             break;
       
   314 
       
   315         case MEngineMonitor::EPEMessageAnswering:
       
   316             iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   317             break;
       
   318 
       
   319         case MEngineMonitor::EPEMessageAudioOutputChanged:
       
   320             HandleAudioOutputChangedL();
       
   321             break;
       
   322 
       
   323         case MEngineMonitor::EPEMessageMuteRingingTone:
       
   324             // Silence the ringer. And stop vibrating, if it is active.
       
   325             iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   326             HandleAudioPlayStoppedL();
       
   327             iStateMachine->SendPhoneEngineMessage(
       
   328                 MPEPhoneModel::EPEMessageStopTonePlay );
       
   329             break;
       
   330          
       
   331         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
       
   332             HandleAudioAvailableOutputChangedL();
       
   333             // Need to avoid CBA update
       
   334             break;
       
   335         
       
   336         case MEngineMonitor::EPEMessageRemotePartyInfoChanged:
       
   337             // Update remote info data
       
   338             UpdateRemoteInfoDataAndLabelL( aCallId, UpdateCallHeaderInfoL( aCallId ) );
       
   339             break;
       
   340             
       
   341         default:
       
   342             CPhoneState::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   343             break;
       
   344         }
       
   345     }
       
   346 
       
   347 // -----------------------------------------------------------
       
   348 // CPhoneStateIncoming::UpdateRemoteInfoDataAndLabelL
       
   349 // -----------------------------------------------------------
       
   350 //
       
   351 void CPhoneStateIncoming::UpdateRemoteInfoDataAndLabelL( 
       
   352         TInt aCallId, 
       
   353         TPhoneCmdParamCallHeaderData aCallHeaderParam )
       
   354     {
       
   355     __LOGMETHODSTARTEND(EPhoneControl,
       
   356             "CPhoneStateIncoming::UpdateRemoteInfoDataAndLabelL ()" );
       
   357     // Update the remote info data in the call header
       
   358     iViewCommandHandle->ExecuteCommandL( 
       
   359         EPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel, 
       
   360         aCallId,
       
   361         &aCallHeaderParam );
       
   362     }
       
   363 
       
   364 // -----------------------------------------------------------
       
   365 // CPhoneStateIncoming::HandleConnectedL
       
   366 // -----------------------------------------------------------
       
   367 //
       
   368 void CPhoneStateIncoming::HandleConnectedL( TInt aCallId )
       
   369     {
       
   370     __LOGMETHODSTARTEND(EPhoneControl,
       
   371         "CPhoneStateIncoming::HandleConnectedL ()" );
       
   372 
       
   373     // Re-enable global notes
       
   374     TPhoneCmdParamBoolean globalNotifierParam;
       
   375     globalNotifierParam.SetBoolean( EFalse );
       
   376     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   377         &globalNotifierParam );
       
   378     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
       
   379         &globalNotifierParam );
       
   380     // Stop tone playing, if necessary
       
   381     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   382     
       
   383     if( IsVideoCall( aCallId ) && !IsAutoLockOn() )
       
   384         {
       
   385         // For keeping video call on top
       
   386         TPhoneCmdParamBoolean booleanParam;
       
   387         booleanParam.SetBoolean( EFalse );
       
   388         iViewCommandHandle->ExecuteCommandL(
       
   389             EPhoneViewSetNeedToSendToBackgroundStatus, &booleanParam );
       
   390         }
       
   391     
       
   392     BeginTransEffectLC( ENumberEntryOpen );
       
   393 
       
   394     if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) 
       
   395          && iStateMachine->PhoneStorage()->IsScreenLocked() )
       
   396         {
       
   397         EnableCallUIL();
       
   398         }
       
   399     
       
   400     // Reset blocked keys list
       
   401     iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
   402 
       
   403     BeginUiUpdateLC();
       
   404     
       
   405     // Update single call
       
   406     UpdateSingleActiveCallL( aCallId );
       
   407 
       
   408     SetTouchPaneButtons( EPhoneIncallButtons );
       
   409     SetToolbarDimming( EFalse );
       
   410             
       
   411     EndUiUpdate();
       
   412     EndTransEffect();
       
   413 
       
   414     // Go to single state
       
   415     iCbaManager->UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   416 
       
   417     iStateMachine->ChangeState( EPhoneStateSingle );
       
   418     }
       
   419 
       
   420 // -----------------------------------------------------------
       
   421 // CPhoneStateIncoming::HandleAudioPlayStoppedL
       
   422 // -----------------------------------------------------------
       
   423 //
       
   424 EXPORT_C void CPhoneStateIncoming::HandleAudioPlayStoppedL()
       
   425     {
       
   426     __LOGMETHODSTARTEND(EPhoneControl,
       
   427         "CPhoneStateIncoming::HandleAudioPlayStoppedL ()" );
       
   428     // Update the CBA
       
   429     
       
   430     // Set the ringtone silenced status
       
   431     iCbaManager->SetRingtoneSilencedStatus( ETrue );
       
   432     TInt resourceId = EPhoneCallHandlingIncomingRejectCBA;
       
   433     // Get the soft reject flag status
       
   434     TPhoneCmdParamBoolean softRejectParam;
       
   435     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSoftRejectFlag,
       
   436         &softRejectParam );
       
   437 
       
   438     if ( IsNumberEntryVisibleL() && !iOnScreenDialer )
       
   439         {
       
   440         resourceId = EPhoneNumberAcqCBA;
       
   441         }
       
   442     else if ( softRejectParam.Boolean() )
       
   443         {
       
   444         resourceId = EPhoneCallHandlingIncomingSoftRejectCBA;
       
   445         }
       
   446 	iCbaManager->SetCbaL( resourceId );
       
   447     }
       
   448 
       
   449 // -----------------------------------------------------------
       
   450 // CPhoneStateIncoming::HandleIdleL
       
   451 // -----------------------------------------------------------
       
   452 //
       
   453 void CPhoneStateIncoming::HandleIdleL( TInt aCallId )
       
   454     {
       
   455     __LOGMETHODSTARTEND(EPhoneControl,
       
   456         "CPhoneStateIncoming::HandleIdleL ()" );
       
   457 
       
   458     BeginTransEffectLC( ENumberEntryOpen );
       
   459     BeginUiUpdateLC();
       
   460 
       
   461     // Enable call UI
       
   462     if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) 
       
   463         && iStateMachine->PhoneStorage()->IsScreenLocked() )
       
   464         {
       
   465         EnableCallUIL();
       
   466         }
       
   467 
       
   468     // Reset blocked keys list
       
   469     iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
   470     
       
   471     // Remove call
       
   472     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId );
       
   473     // Close menu bar, if it is displayed
       
   474     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   475     // Stop tone playing, if necessary
       
   476     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   477     
       
   478     TPhoneCmdParamBoolean globalNotifierParam;
       
   479     globalNotifierParam.SetBoolean( EFalse );
       
   480     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
       
   481         &globalNotifierParam );
       
   482     
       
   483 
       
   484     SetDefaultFlagsL();
       
   485     
       
   486      if ( IsNumberEntryUsedL() )
       
   487         {
       
   488         if ( NeedToSendToBackgroundL() )
       
   489             {
       
   490             // Return phone to the background if send to background is needed.
       
   491             iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
       
   492 
       
   493             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetControlAndVisibility );
       
   494 
       
   495             // Set Number Entry CBA
       
   496             iCbaManager->SetCbaL( EPhoneNumberAcqCBA );
       
   497             }
       
   498         else
       
   499             {
       
   500             // Show the number entry if it exists.
       
   501             SetNumberEntryVisibilityL(ETrue);
       
   502             }
       
   503         }
       
   504     else if ( NeedToSendToBackgroundL() ||
       
   505         SoftRejectMessageEditorIsDisplayedL() )
       
   506         {
       
   507         // Continue displaying current app but set up the
       
   508         // idle screen in the background
       
   509         SetupIdleScreenInBackgroundL();
       
   510         }
       
   511     else
       
   512         {
       
   513         // Display idle screen
       
   514         DisplayIdleScreenL();
       
   515         }
       
   516  
       
   517     DeleteTouchPaneButtons();
       
   518     EndUiUpdate();
       
   519     EndTransEffect();
       
   520     // Go to idle state   
       
   521     iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
       
   522     iStateMachine->ChangeState( EPhoneStateIdle );
       
   523     }
       
   524 
       
   525 // -----------------------------------------------------------
       
   526 // CPhoneStateIncoming::HandleCommandL
       
   527 // -----------------------------------------------------------
       
   528 //
       
   529 EXPORT_C TBool CPhoneStateIncoming::HandleCommandL( TInt aCommand )
       
   530     {
       
   531     __LOGMETHODSTARTEND(EPhoneControl,
       
   532         "CPhoneStateIncoming::HandleCommandL ()" );
       
   533     TBool commandStatus = ETrue;
       
   534 
       
   535     switch( aCommand )
       
   536         {
       
   537         case EPhoneCmdOptions:
       
   538             // Stop tone playing, if necessary.
       
   539             // And stop vibrating, if it is active.
       
   540             iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   541             // Open the menu bar
       
   542             OpenMenuBarL();
       
   543             break;
       
   544 
       
   545         case EPhoneCallComingCmdAnswer:
       
   546             AnswerCallL();
       
   547             break;
       
   548 
       
   549         case EPhoneCallComingCmdAnswerHandPortableVideo:
       
   550         case EPhoneCallComingCmdAnswerHandPortable:
       
   551             iStateMachine->PhoneEngineInfo()->SetAudioOutputCommand(
       
   552                 EPEHandset, ETrue );
       
   553             iStateMachine->SendPhoneEngineMessage(
       
   554                 MPEPhoneModel::EPEMessageSetAudioOutput );
       
   555             AnswerCallL();
       
   556             break;
       
   557 
       
   558         case EPhoneCallComingCmdReject:
       
   559             DisconnectWaitingCallL();
       
   560             break;
       
   561 
       
   562         case EPhoneCallComingCmdSilent:
       
   563             // Silence the ringer. And stop vibrating, if it is active.
       
   564             iViewCommandHandle->ExecuteCommandL( EPhoneViewMuteRingTone );
       
   565             // Dim silence button
       
   566             SetTouchPaneButtonDisabled( EPhoneCallComingCmdSilent );
       
   567             HandleAudioPlayStoppedL();
       
   568             iStateMachine->SendPhoneEngineMessage(
       
   569                 MPEPhoneModel::EPEMessageStopTonePlay );
       
   570             break;
       
   571 
       
   572         case EPhoneCallComingCmdSoftReject:
       
   573             // Open Soft reject message editor
       
   574             OpenSoftRejectMessageEditorL();
       
   575             break;
       
   576 
       
   577         case EPhoneNumberAcqCmdSendCommand:
       
   578             HandleSendL();
       
   579             break;
       
   580 
       
   581         case EPhoneInCallCmdHelp:
       
   582             {
       
   583             TPtrC contextName;
       
   584             if( IsVideoCall( iRingingCallId ) )
       
   585                 {
       
   586                 contextName.Set( KINCAL_HLP_VIDEOCALL() );
       
   587                 }
       
   588             else
       
   589                 {
       
   590                 contextName.Set( KINCAL_HLP_CALL_HANDLING() );
       
   591                 }
       
   592             iViewCommandHandle->ExecuteCommandL(
       
   593                 EPhoneViewLaunchHelpApplication, 0, contextName );
       
   594             }
       
   595             break;
       
   596 
       
   597         default:
       
   598             commandStatus = CPhoneState::HandleCommandL( aCommand );
       
   599             break;
       
   600         }
       
   601 
       
   602     return commandStatus;
       
   603     }
       
   604 
       
   605 // -----------------------------------------------------------
       
   606 // CPhoneStateIncoming::AnswerCallL
       
   607 // -----------------------------------------------------------
       
   608 //
       
   609 void CPhoneStateIncoming::AnswerCallL()
       
   610     {
       
   611     __LOGMETHODSTARTEND(EPhoneControl,
       
   612         "CPhoneStateIncoming::AnswerCallL ()" );
       
   613     // Mute the ring tone
       
   614     iViewCommandHandle->ExecuteCommandL( EPhoneViewMuteRingToneOnAnswer );
       
   615     iViewCommandHandle->ExecuteCommandL( EPhoneViewCloseFSW );
       
   616     // Answer the call
       
   617     iStateMachine->SendPhoneEngineMessage(
       
   618         MPEPhoneModel::EPEMessageAnswer );
       
   619     }
       
   620 
       
   621 // -----------------------------------------------------------
       
   622 // CPhoneStateIncoming::DisconnectWaitingCallL
       
   623 // -----------------------------------------------------------
       
   624 //
       
   625 void CPhoneStateIncoming::DisconnectWaitingCallL()
       
   626     {
       
   627     __LOGMETHODSTARTEND(EPhoneControl,
       
   628         "CPhoneStateIncoming::DisconnectWaitingCallL ()" );
       
   629 
       
   630     // Stop tone playing, if necessary
       
   631     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   632     iViewCommandHandle->ExecuteCommandL( EPhoneViewCloseFSW );
       
   633 
       
   634     // The ringing call might have changed
       
   635     TPhoneCmdParamCallStateData callStateData;
       
   636     callStateData.SetCallState( EPEStateRinging );
       
   637     iViewCommandHandle->HandleCommandL(
       
   638         EPhoneViewGetCallIdByState, &callStateData );
       
   639     
       
   640     if ( callStateData.CallId() > KErrNotFound )
       
   641         {
       
   642         iRingingCallId = callStateData.CallId();
       
   643         }
       
   644     
       
   645     iStateMachine->SetCallId( iRingingCallId );
       
   646 
       
   647     if( IsVideoCall( iRingingCallId ) )
       
   648         {
       
   649         // Video call can be released only after we get response to VT Shutdown Command
       
   650         CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( 
       
   651                 KMediatorVideoTelephonyDomain,
       
   652                          KCatPhoneToVideotelCommands, 
       
   653                          EVtCmdReleaseDataport,
       
   654                TVersion( KPhoneToVideotelCmdVersionMajor,
       
   655                          KPhoneToVideotelCmdVersionMinor, 
       
   656                          KPhoneToVideotelCmdVersionBuild ),
       
   657                KNullDesC8,
       
   658                CPhoneReleaseCommand::NewL( *iStateMachine ) );
       
   659         }
       
   660     else
       
   661         {
       
   662         // Release the call
       
   663         iStateMachine->SendPhoneEngineMessage(
       
   664                 MPEPhoneModel::EPEMessageRelease );
       
   665         }
       
   666     
       
   667     ShowDisconnectingL( iRingingCallId );
       
   668     }
       
   669 
       
   670 // -----------------------------------------------------------
       
   671 // CPhoneStateIncoming::OpenSoftRejectMessageEditorL
       
   672 // -----------------------------------------------------------
       
   673 //
       
   674 void CPhoneStateIncoming::OpenSoftRejectMessageEditorL()
       
   675     {
       
   676     __LOGMETHODSTARTEND(EPhoneControl,
       
   677         "CPhoneStateIncoming::OpenSoftRejectMessageEditorL ()" );
       
   678     // Clear the soft reject flag
       
   679     TPhoneCmdParamBoolean softRejectParam;
       
   680     softRejectParam.SetBoolean( EFalse );
       
   681     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSoftRejectFlag,
       
   682         &softRejectParam );
       
   683 
       
   684     // Dim silence button
       
   685     SetTouchPaneButtonDisabled( EPhoneCallComingCmdSilent );
       
   686     
       
   687     // Silence the vibrating
       
   688     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   689     iStateMachine->SendPhoneEngineMessage(
       
   690         MPEPhoneModel::EPEMessageStopTonePlay );
       
   691     
       
   692     // Re-enable global notes. Otherwise message editor is not opened.
       
   693     TPhoneCmdParamBoolean globalNotifierParam;
       
   694     globalNotifierParam.SetBoolean( EFalse );
       
   695     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
       
   696         &globalNotifierParam );
       
   697 
       
   698     // Change the CBA to Options..Reject
       
   699     iCbaManager->SetCbaL( EPhoneCallHandlingIncomingRejectCBA );
       
   700 
       
   701     TPhoneCmdParamSfiData sfiDataParam;
       
   702 
       
   703     if ( iStateMachine->PhoneEngineInfo()->RemoteName( iRingingCallId ).Length() )
       
   704         {
       
   705         // store both the name and the number
       
   706         sfiDataParam.SetNumber( iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( iRingingCallId ) );
       
   707         sfiDataParam.SetName( iStateMachine->PhoneEngineInfo()->RemoteName( iRingingCallId ) );
       
   708         }
       
   709     else
       
   710         {
       
   711         // store the number
       
   712         sfiDataParam.SetNumber( iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( iRingingCallId ) );
       
   713         }
       
   714 
       
   715     iViewCommandHandle->ExecuteCommandL(
       
   716         EPhoneViewOpenSoftRejectEditor, &sfiDataParam );
       
   717     }
       
   718 
       
   719 // -----------------------------------------------------------
       
   720 // CPhoneStateIncoming::SoftRejectMessageEditorIsDisplayedL
       
   721 // -----------------------------------------------------------
       
   722 //
       
   723 TBool CPhoneStateIncoming::SoftRejectMessageEditorIsDisplayedL() const
       
   724     {
       
   725     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIncoming::SoftRejectMessageEditorIsDisplayedL () ");
       
   726     // Get the foreground application window group id
       
   727     TPhoneCmdParamInteger foregroundAppParam;
       
   728     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetForegroundApplication,
       
   729         &foregroundAppParam );
       
   730 
       
   731     // Get the soft reject message editor window group id
       
   732     TPhoneCmdParamInteger softRejectMessageEditorWgId;
       
   733     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSoftRejectWindowGroupId,
       
   734         &softRejectMessageEditorWgId );
       
   735 
       
   736     __PHONELOG1(
       
   737         EBasic,
       
   738         EPhoneControl,
       
   739         "CPhoneStateIncoming::SoftRejectMessageEditorIsDisplayedL() SoftRejectGroupId %d",
       
   740         softRejectMessageEditorWgId.Integer() );
       
   741     __PHONELOG1(
       
   742         EBasic,
       
   743         EPhoneControl,
       
   744         "CPhoneStateIncoming::SoftRejectMessageEditorIsDisplayedL() ForegroundAppGroupId %d",
       
   745         foregroundAppParam.Integer() );
       
   746     // Return ETrue if soft reject message editor is displayed
       
   747     return softRejectMessageEditorWgId.Integer() == foregroundAppParam.Integer();
       
   748     }
       
   749 
       
   750 // -----------------------------------------------------------
       
   751 // CPhoneStateIncoming::OpenMenuBarL
       
   752 // -----------------------------------------------------------
       
   753 //
       
   754 void CPhoneStateIncoming::OpenMenuBarL()
       
   755     {
       
   756     __LOGMETHODSTARTEND(EPhoneControl,
       
   757         "CPhoneStateIncoming::OpenMenuBarL ()" );
       
   758     TInt resourceId;
       
   759 
       
   760     // Determine the correct menu bar to display
       
   761     if ( CPhoneState::IsNumberEntryVisibleL() )
       
   762         {
       
   763         resourceId = GetNumberEntryVisibleMenuBar();
       
   764         }
       
   765     else
       
   766         {
       
   767         resourceId = GetNumberEntryNotVisibleMenuBar();
       
   768         }
       
   769 
       
   770     // Silence the ringer. And stop vibrating, if it is active.
       
   771     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   772     iStateMachine->SendPhoneEngineMessage(
       
   773         MPEPhoneModel::EPEMessageStopTonePlay );
       
   774 
       
   775     //Set correct cba
       
   776     HandleAudioPlayStoppedL();
       
   777     
       
   778     // Dim button
       
   779     SetTouchPaneButtonDisabled( EPhoneCallComingCmdSilent );
       
   780 
       
   781     // Open the menu bar
       
   782     TPhoneCmdParamInteger integerParam;
       
   783     integerParam.SetInteger(
       
   784         CPhoneMainResourceResolver::Instance()->
       
   785         ResolveResourceID( resourceId ) );
       
   786     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarOpen,
       
   787         &integerParam );
       
   788     }
       
   789 
       
   790 // -----------------------------------------------------------
       
   791 // CPhoneStateIncoming::GetNumberEntryVisibleMenuBar
       
   792 // -----------------------------------------------------------
       
   793 //
       
   794 TInt CPhoneStateIncoming::GetNumberEntryVisibleMenuBar()
       
   795     {
       
   796     if( CPhoneState::IsVideoCall ( iRingingCallId ) )
       
   797         {
       
   798         return EPhoneIncomingVideoCallMenubarWithNumberEntry;
       
   799         }
       
   800     else
       
   801         {
       
   802         return EPhoneIncomingCallMenubarWithNumberEntry;
       
   803         }
       
   804     }
       
   805 
       
   806 // -----------------------------------------------------------
       
   807 // CPhoneStateIncoming::GetNumberEntryNotVisibleMenuBar
       
   808 // -----------------------------------------------------------
       
   809 //
       
   810 TInt CPhoneStateIncoming::GetNumberEntryNotVisibleMenuBar()
       
   811     {
       
   812     if( CPhoneState::IsVideoCall ( iRingingCallId ) )
       
   813         {
       
   814         return EPhoneIncomingVideoCallMenubar;
       
   815         }
       
   816     else
       
   817         {
       
   818         return EPhoneIncomingCallMenubar;
       
   819         }
       
   820     }
       
   821 
       
   822 // -----------------------------------------------------------
       
   823 // CPhoneStateIncoming::DynInitMenuPaneL
       
   824 // -----------------------------------------------------------
       
   825 //
       
   826 EXPORT_C void CPhoneStateIncoming::DynInitMenuPaneL(
       
   827     TInt aResourceId,
       
   828     CEikMenuPane* aMenuPane )
       
   829     {
       
   830     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIncoming::DynInitMenuPaneL() ");
       
   831     __ASSERT_DEBUG( aMenuPane && aResourceId,
       
   832         Panic( EPhoneCtrlParameterNotInitialized ) );
       
   833 
       
   834     // Save the number of digits in the number entry before processing
       
   835     // the menu pane
       
   836     if ( IsNumberEntryUsedL() )
       
   837         {
       
   838         TPhoneCmdParamBoolean serviceCodeParam;
       
   839         serviceCodeParam.SetBoolean( ETrue );
       
   840         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetServiceCodeFlag,
       
   841             &serviceCodeParam );
       
   842         }
       
   843 
       
   844     if ( iCustomization )
       
   845         {
       
   846         iCustomization->CustomizeMenuPaneL(aResourceId, aMenuPane);
       
   847         }
       
   848     // Process the menu pane
       
   849     TPhoneCmdParamDynMenu dynMenuPane;
       
   850     dynMenuPane.SetResourceId( aResourceId );
       
   851     dynMenuPane.SetDynMenu( aMenuPane );
       
   852     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuPane, &dynMenuPane );
       
   853     }
       
   854 
       
   855 // -----------------------------------------------------------
       
   856 // CPhoneStateIncoming::ShowDisconnectingL
       
   857 // -----------------------------------------------------------
       
   858 //
       
   859 void CPhoneStateIncoming::ShowDisconnectingL( TInt aCallId )
       
   860     {
       
   861     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIncoming::ShowDisconnectingL( ) ");
       
   862     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   863     callHeaderParam.SetCallState( EPEStateDisconnecting );
       
   864 
       
   865     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
       
   866     TInt callLabelId = CPhoneMainResourceResolver::Instance()->
       
   867         ResolveResourceID( EPhoneInCallDisconnected );
       
   868 
       
   869     StringLoader::Load( labelText, callLabelId, CCoeEnv::Static() );
       
   870     callHeaderParam.SetLabelText( labelText );
       
   871 
       
   872     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
       
   873         &callHeaderParam );
       
   874     }
       
   875 
       
   876 // ---------------------------------------------------------
       
   877 // CPhoneStateIncoming::HandleKeyLockEnabledL
       
   878 // ---------------------------------------------------------
       
   879 //
       
   880 EXPORT_C void CPhoneStateIncoming::HandleKeyLockEnabled( TBool aKeylockEnabled )
       
   881     {
       
   882     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIncoming::HandleKeyLockEnabledL( ) ");
       
   883     if( !FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke )
       
   884 		&& CPhoneCenRepProxy::Instance()->
       
   885 			IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
   886 		{
       
   887     	if( aKeylockEnabled )
       
   888         	{
       
   889 	        // Keylock enabled
       
   890             if( iStateMachine->PhoneStorage()->IsBlockedKeysListEmpty() )
       
   891                 {
       
   892                 // Disable HW Keys if needed
       
   893                 DisableHWKeysL();
       
   894                 }
       
   895 	        }
       
   896 	    else
       
   897 	        {
       
   898 	        // Keylock disabled
       
   899             // Reset blocked keys list
       
   900             iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
   901 	        }
       
   902 		}
       
   903     }
       
   904 
       
   905 // End of File