phoneapp/phoneuistates/src/cphoneemergency.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2005 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 CPhoneEmergency class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <eikmenub.h>
       
    21 #include <StringLoader.h>
       
    22 #include <ccpdefs.h>
       
    23 #include <featmgr.h>
       
    24 #include <cpephonemodelif.h>
       
    25 #include <mpeengineinfo.h>
       
    26 #include <AknUtils.h>
       
    27 
       
    28 #include "cphoneemergency.h"
       
    29 #include "tphonecmdparamstring.h"
       
    30 #include "tphonecmdparaminteger.h"
       
    31 #include "tphonecmdparamboolean.h"
       
    32 #include "tphonecmdparamemergencycallheaderdata.h"
       
    33 #include "tphonecmdparamcallheaderdata.h"
       
    34 #include "mphonestatemachine.h"
       
    35 #include "phonestatedefinitionsgsm.h"
       
    36 #include "phoneviewcommanddefinitions.h"
       
    37 #include "phoneui.hrh"
       
    38 #include "phonerssbase.h"
       
    39 #include "cphonemainresourceresolver.h"
       
    40 #include "phonelogger.h"
       
    41 #include "cphonepubsubproxy.h"
       
    42 #include "cphonekeys.h"
       
    43 #include "tphonecmdparamaudiooutput.h"
       
    44 #include "phoneresourceids.h"
       
    45 
       
    46 // ================= MEMBER FUNCTIONS =======================
       
    47 
       
    48 // C++ default constructor can NOT contain any code, that
       
    49 // might leave.
       
    50 //
       
    51 CPhoneEmergency::CPhoneEmergency(
       
    52     MPhoneStateMachine* aStateMachine,
       
    53     MPhoneViewCommandHandle* aViewCommandHandle,
       
    54     MPhoneCustomization* aPhoneCustomization ) :
       
    55     CPhoneGsmInCall( aStateMachine, aViewCommandHandle, aPhoneCustomization ),
       
    56     iCallSetup( ETrue )
       
    57     {
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------
       
    61 // CPhoneEmergency::~CPhoneEmergency()
       
    62 // Destructor
       
    63 // (other items were commented in a header).
       
    64 // -----------------------------------------------------------
       
    65 
       
    66 CPhoneEmergency::~CPhoneEmergency()
       
    67     {
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------
       
    71 // CPhoneEmergency::ConstructL()
       
    72 // Constructor
       
    73 // (other items were commented in a header).
       
    74 // -----------------------------------------------------------
       
    75 //
       
    76 void CPhoneEmergency::ConstructL()
       
    77     {
       
    78     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::ConstructL()");
       
    79     CPhoneGsmInCall::ConstructL();
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------
       
    83 // CPhoneEmergency::NewL()
       
    84 // Constructor
       
    85 // (other items were commented in a header).
       
    86 // -----------------------------------------------------------
       
    87 //
       
    88 CPhoneEmergency* CPhoneEmergency::NewL(
       
    89     MPhoneStateMachine* aStateMachine,
       
    90     MPhoneViewCommandHandle* aViewCommandHandle,
       
    91     MPhoneCustomization* aPhoneCustomization )
       
    92     {
       
    93     CPhoneEmergency* self = new (ELeave)
       
    94         CPhoneEmergency( aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
    95 
       
    96     CleanupStack::PushL( self );
       
    97     self->ConstructL();
       
    98     CleanupStack::Pop( self );
       
    99 
       
   100     return self;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------
       
   104 // CPhoneEmergency::HandleNumberEntryClearedL()
       
   105 // -----------------------------------------------------------
       
   106 //
       
   107 void CPhoneEmergency::HandleNumberEntryClearedL()
       
   108     {
       
   109     __LOGMETHODSTARTEND(EPhoneUIStates,
       
   110         "CPhoneEmergency::HandleNumberEntryClearedL()");
       
   111     UpdateInCallCbaL();
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------
       
   115 // CPhoneEmergency::HandlePhoneEngineMessageL
       
   116 // -----------------------------------------------------------
       
   117 //
       
   118 void CPhoneEmergency::HandlePhoneEngineMessageL(
       
   119     const TInt aMessage,
       
   120     TInt aCallId )
       
   121     {
       
   122     __LOGMETHODSTARTEND(EPhoneUIStates,
       
   123         "CPhoneEmergency::HandlePhoneEngineMessageL() ");
       
   124     switch ( aMessage )
       
   125         {
       
   126         case MEngineMonitor::EPEMessageIdle:
       
   127             iCallSetup = ETrue;
       
   128             HandleIdleL( aCallId );
       
   129             iConnected = EFalse;
       
   130             break;
       
   131 
       
   132         case MEngineMonitor::EPEMessageDialing:
       
   133             HandleDialingL( aCallId );
       
   134             break;
       
   135 
       
   136         case MEngineMonitor::EPEMessageConnected:
       
   137             if( iCallSetup )
       
   138                 {
       
   139                 HandleConnectingL( aCallId );
       
   140                 iCallSetup = EFalse;
       
   141                 }
       
   142             HandleConnectedL( aCallId );
       
   143             iConnected = ETrue;
       
   144             break;
       
   145 
       
   146         case MEngineMonitor::EPEMessageConnecting:
       
   147             HandleConnectingL( aCallId );
       
   148             iCallSetup = EFalse;
       
   149             break;
       
   150 
       
   151         case MEngineMonitor::EPEMessageDisconnecting:
       
   152             // Explicitly override this handling from CPhoneStateInCall
       
   153             // where DTMF sending is cancelled and that causes emergency
       
   154             // progress bar destroyed
       
   155             CPhoneState::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   156             break;
       
   157 
       
   158         case MEngineMonitor::EPEMessageAudioOutputChanged:
       
   159             if ( iCallSetup )
       
   160                 {
       
   161                 HandleAudioOutputChangedL();
       
   162                 }
       
   163             else
       
   164                 {
       
   165                 CPhoneGsmInCall::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   166                 }
       
   167             break;
       
   168 
       
   169         case MEngineMonitor::EPEMessageStoppedDTMF:      // fall through
       
   170         case MEngineMonitor::EPEMessageSentDTMF:         // fall through
       
   171         case MEngineMonitor::EPEMessageDTMFSendingAborted:
       
   172             CPhoneGsmInCall::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   173             if ( iStateMachine->PhoneEngineInfo()->CallState( KPEEmergencyCallId ) == EPEStateDialing )
       
   174                 {
       
   175                 TPhoneCmdParamBoolean isProgressNoteVisible;
       
   176                 iViewCommandHandle->ExecuteCommandL( EPhoneViewGetIsProgressNoteVisible,
       
   177                       &isProgressNoteVisible );
       
   178 
       
   179                 if ( !isProgressNoteVisible.Boolean() )
       
   180                     {
       
   181                     UpdateSetupCbaL();
       
   182                     }
       
   183                  }
       
   184             break;
       
   185 
       
   186         default:
       
   187             CPhoneGsmInCall::HandlePhoneEngineMessageL(
       
   188                 aMessage, aCallId );
       
   189             break;
       
   190         }
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------
       
   194 // CPhoneEmergency::HandleIdleL
       
   195 // -----------------------------------------------------------
       
   196 //
       
   197 void CPhoneEmergency::HandleIdleL( TInt aCallId )
       
   198     {
       
   199     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleIdleL() ");
       
   200 
       
   201     // Re-enable global notes, this enables secui (if needed) to come on top
       
   202     // if call creation was rejected by user
       
   203     TPhoneCmdParamBoolean globalNotifierParam;
       
   204     globalNotifierParam.SetBoolean( EFalse );
       
   205     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   206         &globalNotifierParam );
       
   207 
       
   208     if ( iOnScreenDialer && IsDTMFEditorVisibleL() )
       
   209         {
       
   210         CloseDTMFEditorL();
       
   211         }
       
   212 
       
   213     if ( aCallId == KEmergencyCallId )
       
   214         {
       
   215         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId );
       
   216         // Remove emergency connecting note if still there
       
   217         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
       
   218         // Close menu bar, if it is displayed
       
   219         iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   220 
       
   221         const TBool isSimStateNotPresentWithSecurityMode = IsSimStateNotPresentWithSecurityModeEnabled();
       
   222 
       
   223         // Sim IS not ok when making emergency call from Pin query, no note
       
   224         if ( (!IsSimOk() && !iStartupInterrupted) || isSimStateNotPresentWithSecurityMode )
       
   225             {
       
   226             StartShowSecurityNoteL();
       
   227             }
       
   228         else
       
   229             {
       
   230             if ( !TopAppIsDisplayedL() || iDeviceLockOn  )
       
   231                 {
       
   232                 // Continue displaying current app but set up the
       
   233                 // idle screen in the background
       
   234                 SetupIdleScreenInBackgroundL();
       
   235 
       
   236                 // Update toolbar
       
   237                 iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateToolbar );
       
   238                 }
       
   239 
       
   240             else if ( iOnScreenDialer && IsNumberEntryContentStored() )
       
   241                 {
       
   242                 if ( !IsNumberEntryUsedL() )
       
   243                     {
       
   244                     CreateNumberEntryL();
       
   245                     }
       
   246                 // Restore the number entry content from cache
       
   247                 RestoreNumberEntryContentL();
       
   248                 SetNumberEntryVisibilityL(ETrue);
       
   249                 }
       
   250 
       
   251             else if ( IsNumberEntryUsedL() )
       
   252                 {
       
   253                 // Show the number entry if it exists
       
   254                 SetNumberEntryVisibilityL(ETrue);
       
   255                 // Update toolbar
       
   256                 iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateToolbar );
       
   257                 }
       
   258 
       
   259             else
       
   260                 {
       
   261                  // Display idle screen
       
   262                 DisplayIdleScreenL();
       
   263                 }
       
   264 
       
   265             // Display call termination note, if necessary
       
   266             if ( iConnected )
       
   267                 {
       
   268                 DisplayCallTerminationNoteL();
       
   269                 }
       
   270             }
       
   271 
       
   272         // Go to emergency idle state or to startup state if emergency call
       
   273         // initiated from PIN query
       
   274         if ( iStartupInterrupted )
       
   275             {
       
   276             iStartupInterrupted = EFalse;
       
   277             iStateMachine->ChangeState( EPhoneStateStartup );
       
   278             }
       
   279         else
       
   280             {
       
   281             if ( !isSimStateNotPresentWithSecurityMode )
       
   282                 {
       
   283                 SetDefaultFlagsL();
       
   284                 }
       
   285             
       
   286             // As long as security note is not shown with feature flag 
       
   287             // KFeatureIdFfSimlessOfflineSupport undef it is ok to do SetupIdleScreenInBackgroundL.
       
   288             if ( ( !IsNumberEntryUsedL() ) && 
       
   289                  !( IsSimStateNotPresentWithSecurityModeEnabled() && 
       
   290                     !FeatureManager::FeatureSupported( KFeatureIdFfSimlessOfflineSupport ) ) )
       
   291                 {
       
   292                 UpdateCbaL( EPhoneEmptyCBA );
       
   293                 
       
   294                 TPhoneCmdParamBoolean securityMode;
       
   295                 iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &securityMode );
       
   296                 if ( !securityMode.Boolean() )
       
   297                     {
       
   298                     // Setup idle as next active app.
       
   299                     SetupIdleScreenInBackgroundL();
       
   300                     }
       
   301                 }
       
   302             
       
   303             iStateMachine->ChangeState( EPhoneStateIdle );
       
   304             }
       
   305         }
       
   306     else
       
   307         {
       
   308         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveAllCallHeaders );
       
   309         }
       
   310     }
       
   311 
       
   312 
       
   313 // -----------------------------------------------------------
       
   314 // CPhoneEmergency::HandleDialingL
       
   315 // -----------------------------------------------------------
       
   316 //
       
   317 void CPhoneEmergency::HandleDialingL( TInt aCallId )
       
   318     {
       
   319     // Discard all messages related to other calls than the emergency call
       
   320     // We trust that the ISA call server has taken care of them. However,
       
   321     // there could be a race condition between returning to Normal
       
   322     // mode (receiving a network registration status message from PE)
       
   323     // and receiving an EPEMessageDialling message. This can occur
       
   324     // because PE messages are processed asynchronously.
       
   325     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleDialingL() ");
       
   326 
       
   327     if ( aCallId == KPEEmergencyCallId )
       
   328         {
       
   329         if ( !IsSimOk() )
       
   330             {
       
   331             TPhoneCmdParamBoolean visibleMode;
       
   332             visibleMode.SetBoolean( ETrue );
       
   333             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetStatusPaneVisible, &visibleMode );
       
   334             }
       
   335 
       
   336         iDeviceLockOn = IsAutoLockOn();
       
   337 
       
   338         // Close menu bar, if it is displayed
       
   339         iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   340 
       
   341         // Disable global notes when the phone is dialling
       
   342         TPhoneCmdParamBoolean globalNotifierParam;
       
   343         globalNotifierParam.SetBoolean( ETrue );
       
   344         iViewCommandHandle->ExecuteCommandL(
       
   345             EPhoneViewSetGlobalNotifiersDisabled,
       
   346             &globalNotifierParam );
       
   347 
       
   348         // Capture keys when the phone is dialling
       
   349         CaptureKeysDuringCallNotificationL( ETrue );
       
   350 
       
   351         // Indicate that the Phone needs to be sent to the background if
       
   352         // an application other than the top application is in the foreground
       
   353         TPhoneCmdParamBoolean booleanParam;
       
   354         booleanParam.SetBoolean( !TopAppIsDisplayedL() );
       
   355         iViewCommandHandle->ExecuteCommandL(
       
   356             EPhoneViewSetNeedToSendToBackgroundStatus,
       
   357             &booleanParam );
       
   358 
       
   359         // Bring Phone app in the foreground
       
   360         TPhoneCmdParamInteger uidParam;
       
   361         uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   362         iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
   363             &uidParam );
       
   364 
       
   365         // Set Phone as the top application
       
   366         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
   367             &uidParam );
       
   368 
       
   369         // Hide the number entry if it is visible
       
   370         if ( IsNumberEntryUsedL() )
       
   371             {
       
   372             // Remove number entry
       
   373             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
   374             }
       
   375 
       
   376         // Remove exit emergency mode query, if it exists
       
   377         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
       
   378 
       
   379         // Enable the volume display
       
   380         iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNaviPaneAudioVolume );
       
   381         
       
   382         BeginUiUpdateLC();
       
   383         
       
   384         TPhoneCmdParamEmergencyCallHeaderData emergencyHeaderParam;
       
   385         // Set call header
       
   386         TBuf<KPhoneCallHeaderLabelMaxLength> headerText( KNullDesC );
       
   387         StringLoader::Load(
       
   388             headerText,
       
   389             CPhoneMainResourceResolver::Instance()->ResolveResourceID(
       
   390                 EPhoneEmergencyCallHeader ),
       
   391             CCoeEnv::Static() );
       
   392         emergencyHeaderParam.SetHeaderText( headerText );
       
   393 
       
   394         // Set call header ciphering status
       
   395         emergencyHeaderParam.SetCiphering(
       
   396             iStateMachine->PhoneEngineInfo()->IsSecureCall( aCallId ) );
       
   397         emergencyHeaderParam.SetCipheringIndicatorAllowed(
       
   398             iStateMachine->PhoneEngineInfo()->SecureSpecified() );
       
   399 
       
   400         // Notify the view
       
   401         iViewCommandHandle->ExecuteCommandL(
       
   402             EPhoneViewCreateEmergencyCallHeader,
       
   403             aCallId,
       
   404             &emergencyHeaderParam );
       
   405 
       
   406         TPhoneCmdParamCallHeaderData headerParam;
       
   407         headerParam.SetCallState( EPEStateDialing );
       
   408         
       
   409         StringLoader::Load(
       
   410             headerText,
       
   411             CPhoneMainResourceResolver::Instance()->ResolveResourceID(
       
   412                     EPhoneAttemptingEmergencyText ),
       
   413             CCoeEnv::Static() );
       
   414         headerParam.SetLabelText( headerText );
       
   415         
       
   416         iViewCommandHandle->ExecuteCommandL(
       
   417             EPhoneViewUpdateBubble,
       
   418             aCallId,
       
   419             &headerParam );
       
   420 
       
   421         SetTouchPaneButtons( EPhoneEmergencyCallButtons );
       
   422         SetBackButtonActive(EFalse);
       
   423         
       
   424         EndUiUpdate();        
       
   425 
       
   426         // ShowNoteL( EPhoneEmergencyConnectWaitNote );
       
   427         UpdateSetupCbaL();
       
   428         }
       
   429     }
       
   430 // -----------------------------------------------------------
       
   431 // CPhoneEmergency::HandleConnectingL
       
   432 // -----------------------------------------------------------
       
   433 //
       
   434 void CPhoneEmergency::HandleConnectingL( TInt aCallId )
       
   435     {
       
   436     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleConnectingL() ");
       
   437 
       
   438     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveGlobalNote );
       
   439 
       
   440     // Re-enable global notes
       
   441     TPhoneCmdParamBoolean globalNotifierParam;
       
   442     globalNotifierParam.SetBoolean( EFalse );
       
   443     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   444         &globalNotifierParam );
       
   445     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
       
   446           &globalNotifierParam );
       
   447 
       
   448     if(  TouchCallHandlingSupported() )
       
   449         {
       
   450         if ( !IsSimStateNotPresentWithSecurityModeEnabled() )
       
   451             {
       
   452             // Stop capturing keys
       
   453             CaptureKeysDuringCallNotificationL( EFalse );
       
   454             }
       
   455         }
       
   456     else if ( !iDeviceLockOn && SimState() == EPESimUsable )
       
   457         {
       
   458         // Stop capturing keys
       
   459         CaptureKeysDuringCallNotificationL( EFalse );
       
   460         }
       
   461 
       
   462     // Keep Phone in the foreground
       
   463     TPhoneCmdParamBoolean booleanParam;
       
   464     booleanParam.SetBoolean( EFalse );
       
   465     iViewCommandHandle->ExecuteCommandL(
       
   466         EPhoneViewSetNeedToSendToBackgroundStatus, &booleanParam );
       
   467 
       
   468     // Remove emergency connecting note
       
   469     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
       
   470 
       
   471     TPhoneCmdParamCallHeaderData headerParam;
       
   472     headerParam.SetCallState( EPEStateConnecting );
       
   473     // Notify the view
       
   474     iViewCommandHandle->ExecuteCommandL(
       
   475         EPhoneViewUpdateBubble,
       
   476         aCallId,
       
   477         &headerParam );
       
   478 
       
   479     SetToolbarButtonLoudspeakerEnabled();
       
   480 
       
   481     UpdateInCallCbaL();
       
   482     }
       
   483 
       
   484 // -----------------------------------------------------------
       
   485 // CPhoneEmergency::HandleConnectedL
       
   486 // -----------------------------------------------------------
       
   487 //
       
   488 void CPhoneEmergency::HandleConnectedL( TInt aCallId )
       
   489     {
       
   490     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleConnectedL() ");
       
   491 
       
   492     BeginUiUpdateLC();
       
   493 
       
   494     TPhoneCmdParamCallHeaderData emergencyHeaderParam;
       
   495     emergencyHeaderParam.SetCallState( EPEStateConnected );
       
   496     // Notify the view
       
   497     iViewCommandHandle->ExecuteCommandL(
       
   498         EPhoneViewUpdateBubble,
       
   499         aCallId,
       
   500         &emergencyHeaderParam );
       
   501 
       
   502     SetBackButtonActive(ETrue);
       
   503 
       
   504     EndUiUpdate();
       
   505     SetToolbarDimming( ETrue );
       
   506     UpdateInCallCbaL();
       
   507     }
       
   508 
       
   509 // -----------------------------------------------------------
       
   510 // CPhoneEmergency::OpenMenuBarL
       
   511 // -----------------------------------------------------------
       
   512 //
       
   513 void CPhoneEmergency::OpenMenuBarL()
       
   514     {
       
   515     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::OpenMenuBarL() ");
       
   516     TInt resourceId;
       
   517 
       
   518     if ( iOnScreenDialer && IsDTMFEditorVisibleL() )
       
   519         {
       
   520         resourceId = EPhoneDtmfDialerMenubar;
       
   521         }
       
   522     else if ( IsNumberEntryVisibleL() )
       
   523         {
       
   524         resourceId = EPhoneCallHandlingEmergencyMenubarWithNumberEntry;
       
   525         }
       
   526     else
       
   527         {
       
   528         resourceId = EPhoneCallHandlingEmergencyMenubar;
       
   529         }
       
   530 
       
   531     TPhoneCmdParamInteger integerParam;
       
   532     integerParam.SetInteger(
       
   533         CPhoneMainResourceResolver::Instance()->
       
   534         ResolveResourceID( resourceId ) );
       
   535     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarOpen,
       
   536         &integerParam );
       
   537     }
       
   538 
       
   539 
       
   540 // -----------------------------------------------------------
       
   541 // CPhoneEmergency::UpdateInCallCbaL
       
   542 // -----------------------------------------------------------
       
   543 //
       
   544 void CPhoneEmergency::UpdateInCallCbaL()
       
   545     {
       
   546     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::UpdateInCallCbaL() ");
       
   547     TInt resourceId = EPhoneCallHandlingEmergencyCBA;
       
   548     iCbaManager->SetCbaL( resourceId );
       
   549     }
       
   550 
       
   551 // --------------------------------------------------------------
       
   552 // CPhoneEmergency::HandleKeyMessageL
       
   553 // --------------------------------------------------------------
       
   554 //
       
   555 void CPhoneEmergency::HandleKeyMessageL(
       
   556     TPhoneKeyEventMessages aMessage,
       
   557     TKeyCode aCode )
       
   558     {
       
   559     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleKeyMessageL()");
       
   560 
       
   561     switch ( aCode )
       
   562         {
       
   563         // end-key
       
   564         case EKeyNo:
       
   565             // handle end key
       
   566             if ( iOnScreenDialer && IsDTMFEditorVisibleL() )
       
   567                 {
       
   568                 CloseDTMFEditorL();
       
   569                 }
       
   570             DisconnectEmergencyCallL();
       
   571             break;
       
   572 
       
   573         // send-key
       
   574         case EKeyYes:
       
   575              if( iOnScreenDialer && IsNumberEntryVisibleL() )
       
   576                 {
       
   577                 TPhoneCmdParamInteger numberEntryCountParam;
       
   578                     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
       
   579                             &numberEntryCountParam );
       
   580                     TInt neLength( numberEntryCountParam.Integer() );
       
   581                 if ( neLength )
       
   582                     {
       
   583                     // Show not allowed note
       
   584                     SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
       
   585                     }
       
   586                 else
       
   587                     {
       
   588                     // Logs to open
       
   589                     CallFromNumberEntryL();
       
   590                     }
       
   591                 }
       
   592             else
       
   593                 {
       
   594                 // Show not allowed note
       
   595                 SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
       
   596                 }
       
   597             break;
       
   598 
       
   599         default:
       
   600             {
       
   601             if ( TouchCallHandlingSupported() )
       
   602                 {
       
   603                 CPhoneGsmInCall::HandleKeyMessageL( aMessage, aCode ); 
       
   604                 }
       
   605             else if ( !iDeviceLockOn && SimState() == EPESimUsable )   
       
   606                 {
       
   607                 // do base operation
       
   608                 CPhoneGsmInCall::HandleKeyMessageL( aMessage, aCode );
       
   609                 }
       
   610             break;
       
   611             }
       
   612         }
       
   613     }
       
   614 
       
   615 // -----------------------------------------------------------
       
   616 // CPhoneEmergency::HandleCommandL
       
   617 // -----------------------------------------------------------
       
   618 //
       
   619 TBool CPhoneEmergency::HandleCommandL( TInt aCommand )
       
   620     {
       
   621     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleCommandL()");
       
   622     TBool commandStatus = ETrue;
       
   623 
       
   624     switch( aCommand )
       
   625         {
       
   626         case EPhoneInCallCmdDtmfManualQuery:
       
   627             if ( iStateMachine->PhoneEngineInfo()->CallState( KPEEmergencyCallId ) == EPEStateDialing )
       
   628                 {
       
   629                 // Remove emergency connecting note
       
   630                 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
       
   631                 }
       
   632             commandStatus = CPhoneGsmInCall::HandleCommandL( aCommand );
       
   633             break;
       
   634 
       
   635         case EPhoneDtmfDialerExit:      // fall through
       
   636         case EPhoneDtmfDialerCancel:
       
   637              {
       
   638              if ( iStateMachine->PhoneEngineInfo()->CallState( KPEEmergencyCallId ) == EPEStateDialing )
       
   639                  {
       
   640                  CloseDTMFEditorL();
       
   641 
       
   642                  TPhoneCmdParamBoolean isProgressNoteVisible;
       
   643                  iViewCommandHandle->ExecuteCommandL( EPhoneViewGetIsProgressNoteVisible,
       
   644                         &isProgressNoteVisible );
       
   645 
       
   646                  if ( !isProgressNoteVisible.Boolean() )
       
   647                      {
       
   648                      UpdateSetupCbaL();
       
   649                      }
       
   650                  }
       
   651              else
       
   652                  {
       
   653                  commandStatus = CPhoneGsmInCall::HandleCommandL( aCommand );
       
   654                  }
       
   655              }
       
   656              break;
       
   657 
       
   658         case EPhoneInCallCmdEndThisOutgoingCall:
       
   659         case EPhoneInCallCmdEndThisActiveCall:
       
   660             DisconnectEmergencyCallL();
       
   661             break;
       
   662 
       
   663         default:
       
   664             commandStatus = CPhoneGsmInCall::HandleCommandL( aCommand );
       
   665             break;
       
   666         }
       
   667 
       
   668     return commandStatus;
       
   669     }
       
   670 
       
   671 // -----------------------------------------------------------
       
   672 // CPhoneEmergency::DisconnectEmergencyCallL
       
   673 // -----------------------------------------------------------
       
   674 //
       
   675 void CPhoneEmergency::DisconnectEmergencyCallL()
       
   676     {
       
   677     __LOGMETHODSTARTEND(EPhoneUIStates,
       
   678         "CPhoneEmergency::DisconnectEmergencyCallL()");
       
   679     // Release the call
       
   680     iStateMachine->SetCallId(
       
   681         KEmergencyCallId );
       
   682     iStateMachine->SendPhoneEngineMessage(
       
   683         CPEPhoneModelIF::EPEMessageRelease );
       
   684     }
       
   685 
       
   686 // -----------------------------------------------------------
       
   687 // CPhoneEmergency::HandleErrorL
       
   688 // Emergency handling for HandleError message
       
   689 // (other items were commented in a header).
       
   690 // -----------------------------------------------------------
       
   691 //
       
   692 void CPhoneEmergency::HandleErrorL( const TPEErrorInfo& aErrorInfo )
       
   693     {
       
   694     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleError()");
       
   695 
       
   696     switch( aErrorInfo.iErrorCode )
       
   697         {
       
   698         case ECCPErrorCCNoRouteToDestination:
       
   699         case ECCPErrorUnacceptableChannel:
       
   700         case ECCPErrorCCDestinationOutOfOrder:
       
   701         case ECCPErrorNetworkOutOfOrder:
       
   702         case ECCPErrorAccessInformationDiscarded:
       
   703         case ECCPErrorCCResourceNotAvailable:
       
   704         case ECCPErrorQualityOfServiceNotAvailable:
       
   705         case ECCPErrorInvalidCallReferenceValue:
       
   706         case ECCPErrorBadRequest:
       
   707         case ECCPErrorConnectionError:
       
   708         case ECCPErrorCCIncompatibleMessageInProtocolState:
       
   709         case ECCPErrorCCNoChannelAvailable:
       
   710         case ECCPErrorNetworkBusy:
       
   711         case ECCPEmergencyFailed:
       
   712             SendGlobalErrorNoteL( EPhoneNoteNoNetworkCallEmergency );
       
   713             break;
       
   714 
       
   715        default:
       
   716         __PHONELOG1(
       
   717             EOnlyFatal,
       
   718             EPhoneUIStates,
       
   719             "PHONEUI_ERROR: CPhoneEmergency::HandleError - Error send to PhoneState (err=%d)",
       
   720             aErrorInfo.iErrorCode);
       
   721             CPhoneState::HandleErrorL( aErrorInfo );
       
   722             break;
       
   723         }
       
   724     }
       
   725 
       
   726 // -----------------------------------------------------------
       
   727 // CPhoneEmergency::HandleKeyEventL
       
   728 // -----------------------------------------------------------
       
   729 //
       
   730 void CPhoneEmergency::HandleKeyEventL(
       
   731     const TKeyEvent& aKeyEvent,
       
   732     TEventCode aEventCode )
       
   733     {
       
   734     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::HandleKeyEventL( ) ");
       
   735     
       
   736     if ( TouchCallHandlingSupported() )
       
   737         {
       
   738         CPhoneState::HandleKeyEventL( aKeyEvent, aEventCode );
       
   739         }
       
   740     else
       
   741         {
       
   742          if ( iDeviceLockOn && CPhoneKeys::IsNumericKey( aKeyEvent, aEventCode ) )
       
   743             {
       
   744             // Send the key event to the phone engine
       
   745             SendKeyEventL( aKeyEvent, aEventCode );
       
   746             }
       
   747         else
       
   748             {
       
   749             // Handle numeric keys when key events are received in idle state
       
   750             CPhoneState::HandleKeyEventL( aKeyEvent, aEventCode );
       
   751             }
       
   752         }
       
   753     }
       
   754 
       
   755 // -----------------------------------------------------------
       
   756 // CPhoneEmergency::SendKeyEventL
       
   757 // -----------------------------------------------------------
       
   758 //
       
   759 void CPhoneEmergency::SendKeyEventL(
       
   760     const TKeyEvent& aKeyEvent,
       
   761     TEventCode aEventCode )
       
   762     {
       
   763     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::SendKeyEventL( ) ");
       
   764     switch( aEventCode )
       
   765         {
       
   766         // EEventKey
       
   767         case EEventKey:
       
   768             {
       
   769             // Convert key code to western.
       
   770             TBuf<1> buffer; // one character
       
   771             buffer.Append( aKeyEvent.iCode );
       
   772             __PHONELOG1( EBasic, EPhoneControl,
       
   773                 "CPhoneEmergency::SendKeyEventL(%S)",
       
   774                 &buffer );
       
   775             AknTextUtils::ConvertDigitsTo( buffer, EDigitTypeWestern );
       
   776             __PHONELOG1( EBasic, EPhoneControl,
       
   777                 "CPhoneEmergency::SendKeyEventL(%S)",
       
   778                 &buffer );
       
   779             TLex code( buffer );
       
   780             // Save the key code
       
   781             iStateMachine->PhoneEngineInfo()->SetKeyCode( code.Peek() );
       
   782             // Plays a DTMF tone if active call
       
   783             iStateMachine->SendPhoneEngineMessage(
       
   784                 CPEPhoneModelIF::EPEMessagePlayDTMF );
       
   785             }
       
   786             break;
       
   787         // EEventKeyUp
       
   788         case EEventKeyUp:
       
   789             // Send a key up event for the last key code sent to
       
   790             // the phone engine
       
   791             iStateMachine->SendPhoneEngineMessage(
       
   792                 CPEPhoneModelIF::EPEMessageEndDTMF );
       
   793             break;
       
   794         default:
       
   795             break;
       
   796         }
       
   797     }
       
   798 
       
   799 // -----------------------------------------------------------------------------
       
   800 // CPhoneEmergency::HandleAudioOutputChangedL
       
   801 // for setup
       
   802 // -----------------------------------------------------------------------------
       
   803 //
       
   804 void CPhoneEmergency::HandleAudioOutputChangedL()
       
   805     {
       
   806     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneEmergency::HandleAudioOutputChangedL( ) ");
       
   807 
       
   808     // Audio Output
       
   809     TPhoneCmdParamAudioOutput outputParam;
       
   810 
       
   811     // Output
       
   812     const TPEAudioOutput audioOutput =
       
   813         iStateMachine->PhoneEngineInfo()->AudioOutput();
       
   814 
       
   815     UpdateSetupCbaL();
       
   816 
       
   817     // view update
       
   818     outputParam.SetAudioOutput( audioOutput );
       
   819     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateAudioPathUIChanges,
       
   820         &outputParam );
       
   821 
       
   822     }
       
   823 
       
   824 // -----------------------------------------------------------------------------
       
   825 // CPhoneEmergency::SetStartupInterrupted
       
   826 // -----------------------------------------------------------------------------
       
   827 //
       
   828 void CPhoneEmergency::SetStartupInterrupted( const TBool aStartupInterrupted )
       
   829     {
       
   830     iStartupInterrupted = aStartupInterrupted;
       
   831     }
       
   832 
       
   833 // -----------------------------------------------------------
       
   834 // CPhoneEmergency::UpdateSetupCbaL
       
   835 // -----------------------------------------------------------
       
   836 //
       
   837 void CPhoneEmergency::UpdateSetupCbaL()
       
   838     {
       
   839     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneEmergency::UpdateSetupCbaL() ");
       
   840    TInt resourceId = EPhoneCallHandlingEmergencyCBA;        
       
   841    iCbaManager->SetCbaL( resourceId );
       
   842     }
       
   843 
       
   844 // ---------------------------------------------------------
       
   845 // CPhoneEmergency::HandleCreateNumberEntryL
       
   846 //
       
   847 // ---------------------------------------------------------
       
   848 //
       
   849 void CPhoneEmergency::HandleCreateNumberEntryL( const TKeyEvent& aKeyEvent,
       
   850         TEventCode aEventCode )
       
   851     {
       
   852     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneEmergency::HandleCreateNumberEntryL() ");
       
   853     if ( !iCallSetup && !iStartupInterrupted )
       
   854         {
       
   855         CPhoneGsmInCall::HandleCreateNumberEntryL( aKeyEvent, aEventCode );
       
   856         }
       
   857 
       
   858     }
       
   859 
       
   860 // -----------------------------------------------------------------------------
       
   861 // CPhoneEmergency::HandleRemConCommandL
       
   862 // -----------------------------------------------------------------------------
       
   863 //
       
   864 EXPORT_C TBool CPhoneEmergency::HandleRemConCommandL(
       
   865     TRemConCoreApiOperationId aOperationId,
       
   866     TRemConCoreApiButtonAction aButtonAct )
       
   867     {
       
   868     TBool handled = EFalse;
       
   869 
       
   870     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneEmergency::MrccatoCommand() ");
       
   871     
       
   872     switch ( aOperationId )
       
   873         {
       
   874          case ERemConCoreApiMute:
       
   875              __PHONELOG( EBasic, EPhoneControl, "CPhoneEmergency::MrccatoCommand emerg. call no muting" );
       
   876              // Not Allowed
       
   877              break;
       
   878          default:
       
   879              handled = CPhoneState::HandleRemConCommandL( aOperationId, aButtonAct );
       
   880              break;
       
   881         }
       
   882     return handled;
       
   883     }
       
   884 
       
   885 // --------------------------------------------------------------
       
   886 // CPhoneEmergency::TouchCallHandlingSupported
       
   887 // --------------------------------------------------------------
       
   888 //
       
   889 TBool CPhoneEmergency::TouchCallHandlingSupported () const
       
   890     {
       
   891     if ( FeatureManager::FeatureSupported ( KFeatureIdTouchCallHandling ) )
       
   892         {
       
   893         return ETrue;
       
   894         }
       
   895     else 
       
   896         {
       
   897         return EFalse;
       
   898         }
       
   899     }
       
   900 
       
   901 // --------------------------------------------------------------
       
   902 // CPhoneEmergency::UseEmergencyNoIhfCBA
       
   903 // --------------------------------------------------------------
       
   904 //
       
   905 TBool CPhoneEmergency::UseEmergencyNoIhfCBA( const TPEAudioOutput& aAudioOutput ) const
       
   906     {
       
   907     if ( !( TouchCallHandlingSupported() ) 
       
   908         && ( ( aAudioOutput == EPEWiredAudioAccessory ) || ( IsSwivelClosed() ) ) )
       
   909         {
       
   910         return ETrue;
       
   911         }
       
   912     else 
       
   913         {
       
   914         return EFalse;
       
   915         }
       
   916     }
       
   917 
       
   918 // --------------------------------------------------------------
       
   919 // CPhoneEmergency::UseHandsetEmergencyCBA
       
   920 // --------------------------------------------------------------
       
   921 //
       
   922 TBool CPhoneEmergency::UseHandsetEmergencyCBA( const TPEAudioOutput& aAudioOutput ) const
       
   923 {
       
   924     if ( !( TouchCallHandlingSupported() ) 
       
   925         && ( ( aAudioOutput == EPELoudspeaker ) || ( aAudioOutput == EPEBTAudioAccessory ) ) )
       
   926         {
       
   927         return ETrue;
       
   928         }
       
   929     else 
       
   930         {
       
   931         return EFalse;
       
   932         }
       
   933 }
       
   934 
       
   935 // End of File