phoneapp/phoneuicontrol/src/cphonestateidle.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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 CPhoneStateIdle class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <eikenv.h>
       
    21 #include <e32property.h>
       
    22 #include <connect/sbdefs.h>
       
    23 #include <w32std.h>
       
    24 #include <StringLoader.h>
       
    25 #include <aknnotedialog.h> // For CAknNoteDialog::EErrorTone
       
    26 #include <apgcli.h>
       
    27 #include <telephonyvariant.hrh>
       
    28 #include <featmgr.h>
       
    29 #include <settingsinternalcrkeys.h>
       
    30 #include <mpeengineinfo.h>
       
    31 #include <activeidle2domainpskeys.h>
       
    32 #include <mpeclientinformation.h>
       
    33 #include <bldvariant.hrh>
       
    34 
       
    35 #include "cphonepubsubproxy.h"
       
    36 #include "cphonecenrepproxy.h"
       
    37 #include "cphonestateidle.h"
       
    38 #include "tphonecmdparaminteger.h"
       
    39 #include "tphonecmdparamboolean.h"
       
    40 #include "tphonecmdparamglobalnote.h"
       
    41 #include "tphonecmdparamstring.h"
       
    42 #include "tphonecmdparamspeeddial.h"
       
    43 #include "tphonecmdparamboolean.h"
       
    44 #include "mphonestatemachine.h"
       
    45 #include "phonestatedefinitions.h"
       
    46 #include "tphonecmdparamappinfo.h"
       
    47 #include "cphonekeys.h"
       
    48 
       
    49 #include "tphonecmdparamcallstatedata.h"
       
    50 #include "phoneviewcommanddefinitions.h"
       
    51 #include "phoneui.hrh"
       
    52 #include "phonerssbase.h"
       
    53 #include "cphonemainresourceresolver.h"
       
    54 #include "cphonecenrepproxy.h"
       
    55 #include "cphonepubsubproxy.h"
       
    56 #include "phonelogger.h"
       
    57 #include "phoneui.pan"
       
    58 #include "mphonecustomization.h"
       
    59 
       
    60 //CONSTANTS
       
    61 const TInt  KMaxParamLength = 1024;
       
    62 
       
    63 // ================= MEMBER FUNCTIONS =======================
       
    64 
       
    65 // C++ default constructor can NOT contain any code, that
       
    66 // might leave.
       
    67 //
       
    68 EXPORT_C CPhoneStateIdle::CPhoneStateIdle( 
       
    69     MPhoneStateMachine* aStateMachine, 
       
    70     MPhoneViewCommandHandle* aViewCommandHandle,
       
    71     MPhoneCustomization* aCustomization ) : 
       
    72     CPhoneState( aStateMachine, aViewCommandHandle, aCustomization )
       
    73     {
       
    74     }
       
    75 
       
    76 // Destructor
       
    77 EXPORT_C CPhoneStateIdle::~CPhoneStateIdle()
       
    78     {
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------
       
    82 // CPhoneStateIdle::ConstructL()
       
    83 // -----------------------------------------------------------
       
    84 //
       
    85 EXPORT_C void CPhoneStateIdle::ConstructL()
       
    86     {
       
    87     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::ConstructL() ");
       
    88     CPhoneState::BaseConstructL();
       
    89     
       
    90     // Set send key activation on.
       
    91     TPhoneCmdParamBoolean boolean;
       
    92     boolean.SetBoolean( ETrue );
       
    93     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSendKeyDialerActivationFlag, 
       
    94                 &boolean );
       
    95     
       
    96     iViewCommandHandle->ExecuteCommandL( EPhoneViewCreatePhoneBookServices );
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------
       
   100 // CPhoneStateIdle::NewL()
       
   101 // -----------------------------------------------------------
       
   102 //
       
   103 CPhoneStateIdle* CPhoneStateIdle::NewL( 
       
   104     MPhoneStateMachine* aStateMachine, 
       
   105     MPhoneViewCommandHandle* aViewCommandHandle,
       
   106     MPhoneCustomization* aPhoneCustomization )
       
   107     {
       
   108     CPhoneStateIdle* self = new (ELeave) CPhoneStateIdle( 
       
   109         aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
   110     
       
   111     CleanupStack::PushL( self );
       
   112     self->ConstructL();
       
   113     CleanupStack::Pop( self );
       
   114     
       
   115     return self;
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------
       
   119 // CPhoneStateIdle::HandleKeyEventL
       
   120 // -----------------------------------------------------------
       
   121 //
       
   122 EXPORT_C void CPhoneStateIdle::HandleKeyEventL( 
       
   123     const TKeyEvent& aKeyEvent, 
       
   124     TEventCode aEventCode )
       
   125     {
       
   126     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleKeyEventL( ) ");
       
   127     // Security mode check
       
   128     TPhoneCmdParamBoolean isSecurityMode;      
       
   129     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );  
       
   130     // Number entry is blocked, if active Query
       
   131     if ( !IsAnyQueryActiveL() )
       
   132         {
       
   133         // Handle numeric keys when key events are received in idle state
       
   134         HandleNumericKeyEventL( aKeyEvent, aEventCode );  
       
   135         }
       
   136     else if ( isSecurityMode.Boolean() && CPhoneKeys::IsNumericKey( 
       
   137         aKeyEvent, aEventCode ) )
       
   138         {
       
   139         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
       
   140         // Handle numeric keys when key events are received in single state
       
   141         HandleNumericKeyEventL( aKeyEvent, aEventCode );  
       
   142         }
       
   143     else if ( aEventCode == EEventKeyUp )
       
   144         {
       
   145         // Provide up event to engine. 
       
   146         // Otherwise DTMF tone keeps playing.    
       
   147            iStateMachine->SendPhoneEngineMessage( 
       
   148                 MPEPhoneModel::EPEMessageEndDTMF );
       
   149          __PHONELOG( EBasic, EPhoneControl,
       
   150                 "PhoneUIControl: CPhoneStateIdle::HandleKeyEventL" );
       
   151         }
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------
       
   155 // CPhoneStateIdle::HandleNumberEntryClearedL()
       
   156 // -----------------------------------------------------------
       
   157 //
       
   158 EXPORT_C void CPhoneStateIdle::HandleNumberEntryClearedL()
       
   159     {
       
   160     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleNumberEntryClearedL( ) ");
       
   161     
       
   162     if ( IsSimOk() && !IsSimStateNotPresentWithSecurityModeEnabled() )
       
   163         {
       
   164         //  if still idle ( f.e not incoming call arrived when rfs )
       
   165         if ( iStateMachine->State() == this )
       
   166             {
       
   167             DisplayIdleScreenL();
       
   168             }
       
   169         }
       
   170    else
       
   171         {
       
   172         StartShowSecurityNoteL(); 
       
   173         }
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------
       
   177 // CPhoneStateIdle::HandleKeyMessageL
       
   178 // -----------------------------------------------------------
       
   179 //
       
   180 EXPORT_C void CPhoneStateIdle::HandleKeyMessageL( 
       
   181     TPhoneKeyEventMessages aMessage,
       
   182     TKeyCode aCode )
       
   183     {
       
   184     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleKeyMessageL( ) ");
       
   185 
       
   186     if( aMessage == EPhoneKeyLongPress && CheckAppLaunchingL( aCode ) )
       
   187         {
       
   188         return;
       
   189         }
       
   190 
       
   191     switch ( aCode )
       
   192         {
       
   193         case EKeyEnd:
       
   194             // This key even occur only in idle state, behaviour for this should
       
   195             // be same as long end-key press. (Bug in window server)
       
   196             HandleEndKeyPressL( EPhoneKeyLongPress );
       
   197             break;
       
   198             
       
   199         // end-key
       
   200         case EKeyNo:
       
   201             HandleEndKeyPressL( aMessage );            
       
   202             break;
       
   203 
       
   204         // send-key
       
   205         case EKeyYes:
       
   206             
       
   207             if ( iOnScreenDialer )
       
   208                 {
       
   209                 if ( IsNumberEntryUsedL() )
       
   210                     {
       
   211                     // Security mode check
       
   212                     TPhoneCmdParamBoolean isSecurityMode;      
       
   213                     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );
       
   214 
       
   215                     TPhoneCmdParamInteger numberEntryCountParam;
       
   216                     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
       
   217                     &numberEntryCountParam );
       
   218                     TInt neLength( numberEntryCountParam.Integer() );
       
   219                     
       
   220                     // Query on top of dialer
       
   221                     if ( IsAnyQueryActiveL() )
       
   222                         {
       
   223                         return;
       
   224                         }
       
   225                     else if ( IsMenuBarVisibleL() )
       
   226                         {
       
   227                         iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   228                         return;
       
   229                         }
       
   230                     
       
   231                     else if ( neLength == 0 && !isSecurityMode.Boolean())
       
   232                         {
       
   233                         // start logs
       
   234                         iViewCommandHandle->HandleCommandL( 
       
   235                         EPhoneDialerCmdLog );
       
   236                         return;
       
   237                         }
       
   238                     HandleSendCommandL();
       
   239                     }
       
   240                 // If dialer is not open but phone is in foreground and phone receives
       
   241                 // send-key event we have to check if security mode is true and if it
       
   242                 // is then open emergency dialer.
       
   243                 else if ( !IsNumberEntryUsedL() )
       
   244                     {
       
   245                     // Security mode check
       
   246                     TPhoneCmdParamBoolean isSecurityMode;      
       
   247                     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );
       
   248 
       
   249                     if ( isSecurityMode.Boolean())
       
   250                         {
       
   251                         // launch dialer.
       
   252                         HandleCommandL(EPhoneNumberAcqSecurityDialer);
       
   253                         }
       
   254                     }           
       
   255                 }
       
   256             else // iOnScreenDialer false, non-touch.
       
   257                 {
       
   258                 HandleSendCommandL();
       
   259                 }
       
   260             break;
       
   261             
       
   262         case EKeyApplication0:
       
   263             {
       
   264             // If dialer is not open but phone is in foreground and phone receives
       
   265             // applicaion-key event we have to open emergency dialer. No need own
       
   266             // securitymode check because Applicationkey only captured in securitymode.
       
   267             if ( !IsNumberEntryUsedL() )
       
   268                 {
       
   269                 HandleCommandL(EPhoneNumberAcqSecurityDialer);
       
   270                 }           
       
   271             }
       
   272             break;
       
   273             
       
   274         // "O" key
       
   275         case KPhoneDtmf0Character:
       
   276             if ( aMessage == EPhoneKeyLongPress && IsSimOk() )
       
   277                 {
       
   278                 LaunchApplicationL();
       
   279                 }
       
   280             break;
       
   281             
       
   282         // number key
       
   283         case KPhoneDtmf1Character:
       
   284         case KPhoneDtmf2Character:
       
   285         case KPhoneDtmf3Character:
       
   286         case KPhoneDtmf4Character:
       
   287         case KPhoneDtmf5Character:
       
   288         case KPhoneDtmf6Character:
       
   289         case KPhoneDtmf7Character:
       
   290         case KPhoneDtmf8Character:
       
   291         case KPhoneDtmf9Character:
       
   292             if ( aMessage == EPhoneKeyLongPress && IsSimOk() )
       
   293                 {
       
   294                 HandleNumberLongKeyPressL();
       
   295                 }
       
   296             break;
       
   297 
       
   298 #ifdef RD_INTELLIGENT_TEXT_INPUT   
       
   299         case EKeyEnter:
       
   300             if ( IsNumberEntryVisibleL() )
       
   301                 {
       
   302                 HandleCommandL( EPhoneCmdOptions );
       
   303                 }
       
   304             break;
       
   305 #endif
       
   306             
       
   307         default:
       
   308             break;
       
   309         }
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------
       
   313 // CPhoneStateIdle::HandlePhoneEngineMessageL
       
   314 // -----------------------------------------------------------
       
   315 //
       
   316 EXPORT_C void CPhoneStateIdle::HandlePhoneEngineMessageL( 
       
   317     const TInt aMessage, 
       
   318     TInt aCallId )
       
   319     {
       
   320     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandlePhoneEngineMessageL( ) ");
       
   321     switch ( aMessage )
       
   322         {
       
   323         case MEngineMonitor::EPEMessageIncoming:
       
   324             HandleIncomingL( aCallId );
       
   325             break;
       
   326             
       
   327         case MEngineMonitor::EPEMessageDialing:
       
   328             HandleDialingL( aCallId );
       
   329             break;
       
   330             
       
   331         case MEngineMonitor::EPEMessageConnected:
       
   332             HandleConnectedL( aCallId );
       
   333             break;
       
   334             
       
   335         case MEngineMonitor::EPEMessageIssuedUSSDRequest:
       
   336             // Note that after the sending of SS 
       
   337             // strings the view stays in Dialer.
       
   338             if ( !iOnScreenDialer )  
       
   339                 {
       
   340                 if ( IsNumberEntryUsedL() )
       
   341                     {
       
   342                     // Show the number entry if it exists
       
   343                     SetNumberEntryVisibilityL(ETrue);    
       
   344                     }    
       
   345                 else if ( NeedToSendToBackgroundL() )
       
   346                     {
       
   347                     // Continue displaying current app but set up the 
       
   348                     // idle screen in the background
       
   349                     SetupIdleScreenInBackgroundL();
       
   350                     }
       
   351                 else
       
   352                     {
       
   353                      // Display idle screen
       
   354                     DisplayIdleScreenL();
       
   355                     }
       
   356                 }
       
   357             break;
       
   358             
       
   359         case MEngineMonitor::EPEMessageIdle:
       
   360             HandleIdleL( aCallId );
       
   361             break;
       
   362             
       
   363         case MEngineMonitor::EPEMessageInValidEmergencyNumber:                
       
   364             SendGlobalWarningNoteL( EPhoneEmergencyCallsOnly );                           
       
   365             break;
       
   366             
       
   367         case MEngineMonitor::EPEMessageValidEmergencyNumber:
       
   368             DialVoiceCallL();
       
   369             break; 
       
   370                         
       
   371         default:
       
   372             CPhoneState::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   373             break;
       
   374         }
       
   375     }
       
   376 
       
   377 // -----------------------------------------------------------
       
   378 // CPhoneStateIdle::HandleIncomingL( TInt aCallId )
       
   379 // Default handling for incoming message
       
   380 // (other items were commented in a header).
       
   381 // -----------------------------------------------------------
       
   382 //
       
   383 void CPhoneStateIdle::HandleIncomingL( TInt aCallId )
       
   384     {
       
   385     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleIncomingL( ) ");
       
   386 
       
   387     HandleAudioAvailableOutputChangedL();
       
   388     
       
   389     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNaviPaneAudioVolume );
       
   390 
       
   391     SetRingingTonePlaybackL( aCallId );
       
   392 
       
   393     BeginTransEffectLC( ENumberEntryClose );
       
   394     BeginUiUpdateLC();
       
   395     
       
   396     // Hide the number entry if it exists
       
   397     if ( IsNumberEntryUsedL() )
       
   398         {
       
   399         SetNumberEntryVisibilityL(EFalse);    
       
   400         }
       
   401      
       
   402     // Display incoming call
       
   403     DisplayIncomingCallL( aCallId );
       
   404     
       
   405     // Show incoming call buttons
       
   406     SetTouchPaneButtons( EPhoneIncomingCallButtons );
       
   407     
       
   408     // Disable HW keys and Call UI if needed
       
   409     CheckDisableHWKeysAndCallUIL();
       
   410     
       
   411     SetBackButtonActive(EFalse);
       
   412     
       
   413     EndUiUpdate();
       
   414     
       
   415     EndTransEffect();
       
   416     
       
   417     // Go to incoming state
       
   418     iCbaManager->UpdateIncomingCbaL( aCallId );
       
   419     UpdateSilenceButtonDimming();
       
   420     UpdateIncomingContextMenuL( aCallId );
       
   421     //Dim toolbar items
       
   422     SetToolbarDimming( ETrue );
       
   423     //request that dimmed toolbar is visible.
       
   424     iViewCommandHandle->HandleCommandL( EPhoneViewShowToolbar );
       
   425     iStateMachine->ChangeState( EPhoneStateIncoming );
       
   426          
       
   427     // Reset divert indication
       
   428     SetDivertIndication( EFalse );
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------
       
   432 // CPhoneStateIdle::HandleDiallingL
       
   433 // Default handling for dialling message
       
   434 // (other items were commented in a header).
       
   435 // -----------------------------------------------------------
       
   436 //
       
   437 EXPORT_C void CPhoneStateIdle::HandleDialingL( TInt aCallId )
       
   438     {
       
   439     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleDialingL( ) ");
       
   440 
       
   441     BeginTransEffectLC( ENumberEntryClose );
       
   442     BeginUiUpdateLC();
       
   443     
       
   444     SetNumberEntryVisibilityL(EFalse);
       
   445 
       
   446     // Display call setup 
       
   447     DisplayCallSetupL( aCallId );  
       
   448     
       
   449     // Show call setup buttons
       
   450     SetTouchPaneButtons( EPhoneCallSetupButtons );          
       
   451     
       
   452     EndUiUpdate();
       
   453     
       
   454     // Remove any phone dialogs if they are displayed
       
   455     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
   456             
       
   457     // Go to call setup state
       
   458     iCbaManager->UpdateCbaL( EPhoneCallHandlingCallSetupCBA );
       
   459 
       
   460     SetToolbarDimming( ETrue );
       
   461     
       
   462     EndTransEffect();
       
   463     
       
   464     iStateMachine->ChangeState( EPhoneStateCallSetup );
       
   465     }
       
   466 
       
   467 // -----------------------------------------------------------
       
   468 // CPhoneStateIdle::HandleConnectedL
       
   469 // Message Handling function for message EPEMessageConnected
       
   470 // This could happen during transaction from Emergency mode
       
   471 // to Normal mode where a network status change is received
       
   472 // from PE after PE initiates an MO call. Since PE messages
       
   473 // are asynchronous, this sequence can occur in any order.
       
   474 // (other items were commented in a header).
       
   475 // -----------------------------------------------------------
       
   476 //
       
   477 void CPhoneStateIdle::HandleConnectedL( TInt aCallId )
       
   478     {
       
   479     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleConnectedL( ) ");
       
   480     // Keep Phone app in the foreground if it is external
       
   481     if ( !TopAppIsDisplayedL() )
       
   482         {
       
   483         TPhoneCmdParamInteger uidParam;
       
   484         uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   485         iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground, 
       
   486             &uidParam );
       
   487         }
       
   488  
       
   489     BeginTransEffectLC( ENumberEntryClose );
       
   490     BeginUiUpdateLC();
       
   491             
       
   492     // Remove the number entry
       
   493     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
   494  
       
   495     // Display call setup header
       
   496     DisplayCallSetupL( aCallId );
       
   497 
       
   498     // Update single active call
       
   499     UpdateSingleActiveCallL( aCallId );
       
   500     
       
   501     // Update touch buttons
       
   502     SetTouchPaneButtons( EPhoneIncallButtons );
       
   503     SetToolbarDimming( EFalse );
       
   504     
       
   505     EndUiUpdate();
       
   506     EndTransEffect();
       
   507   
       
   508     // Go to single state
       
   509     iCbaManager->UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   510     iStateMachine->ChangeState( EPhoneStateSingle );
       
   511     }
       
   512 
       
   513 // -----------------------------------------------------------
       
   514 // CPhoneStateIdle::HandleCommandL
       
   515 // -----------------------------------------------------------
       
   516 //
       
   517 EXPORT_C TBool CPhoneStateIdle::HandleCommandL( TInt aCommand )
       
   518     {
       
   519     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleCommandL( ) ");
       
   520     TBool commandStatus = ETrue;
       
   521 
       
   522     switch( aCommand )
       
   523         {
       
   524         case EPhoneCmdOptions:
       
   525             {
       
   526             // Open number entry menubar
       
   527             TPhoneCmdParamInteger integerParam;  
       
   528                       
       
   529             integerParam.SetInteger( 
       
   530              CPhoneMainResourceResolver::Instance()->
       
   531                 ResolveResourceID( EPhoneNumberAcqMenubar ) );               
       
   532 
       
   533             iViewCommandHandle->ExecuteCommandL( 
       
   534                 EPhoneViewMenuBarOpen, &integerParam );
       
   535             break;
       
   536             }
       
   537         
       
   538         case EPhoneNumberAcqCmdCall:
       
   539             HandleVoiceCallCommandL( EFalse );
       
   540             break;
       
   541         case EPhoneNumberAcqCmdSendCommand:
       
   542             HandleSendCommandL();
       
   543             break;
       
   544             
       
   545         case EPhoneNumberAcqCmdVideoCall:
       
   546             DialVideoCallL();
       
   547             break;
       
   548             
       
   549         case EPhoneCmdBack:
       
   550             HandleBackCommandL();
       
   551             break;            
       
   552             
       
   553         default:
       
   554             commandStatus = CPhoneState::HandleCommandL( aCommand );
       
   555             break;
       
   556         }
       
   557 
       
   558     return commandStatus;
       
   559 
       
   560     }
       
   561 
       
   562 // -----------------------------------------------------------------------------
       
   563 // CPhoneStateIdle::ProcessCommandL
       
   564 // -----------------------------------------------------------------------------
       
   565 //
       
   566 EXPORT_C TBool CPhoneStateIdle::ProcessCommandL( TInt aCommand )
       
   567     {
       
   568     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::ProcessCommandL( ) ");
       
   569     TBool commandStatus = EFalse;
       
   570     switch( aCommand )
       
   571        {
       
   572        case EAknSoftkeyContextOptions:
       
   573            {
       
   574            // Open number entry OK menubar
       
   575            TPhoneCmdParamInteger integerParam;
       
   576            integerParam.SetInteger( 
       
   577                CPhoneMainResourceResolver::Instance()->
       
   578                ResolveResourceID( EPhoneNumberAcqOkMenubar ) );
       
   579            iViewCommandHandle->ExecuteCommandL( 
       
   580                EPhoneViewMenuBarOpen, &integerParam );
       
   581            commandStatus = ETrue;
       
   582            }
       
   583            break;       
       
   584            
       
   585        default:
       
   586            commandStatus = CPhoneState::ProcessCommandL( aCommand );
       
   587            break;
       
   588        }
       
   589     return commandStatus;
       
   590     }
       
   591 
       
   592 // -----------------------------------------------------------------------------
       
   593 // CPhoneStateIdle::HandleRemConCommandL
       
   594 // -----------------------------------------------------------------------------
       
   595 //
       
   596 EXPORT_C TBool CPhoneStateIdle::HandleRemConCommandL(
       
   597     TRemConCoreApiOperationId /*aOperationId */, 
       
   598     TRemConCoreApiButtonAction /*aButtonAct*/ )
       
   599     {
       
   600     return EFalse;
       
   601     }
       
   602 
       
   603 // -----------------------------------------------------------
       
   604 // CPhoneStateIdle::DialL
       
   605 // -----------------------------------------------------------
       
   606 //
       
   607 EXPORT_C void CPhoneStateIdle::DialL( 
       
   608         const TDesC& aNumber, 
       
   609         TPhoneNumberType aNumberType,
       
   610         TDialInitiationMethod /*aDialMethod*/ )
       
   611     {
       
   612     iStateMachine->PhoneEngineInfo()->SetPhoneNumber( aNumber );
       
   613     
       
   614     if ( aNumberType == EPhoneNumberTypeVideo &&
       
   615         FeatureManager::FeatureSupported( KFeatureIdCsVideoTelephony ) )
       
   616         {
       
   617         DialMultimediaCallL();
       
   618         }
       
   619     else if ( EPhoneNumberTypeVoip == aNumberType &&
       
   620               iCustomization )
       
   621         {
       
   622         iCustomization->HandleDialL( aNumber );
       
   623         }
       
   624     else
       
   625         {
       
   626         DialVoiceCallL();                
       
   627         }
       
   628     }
       
   629     
       
   630 // -----------------------------------------------------------
       
   631 // CPhoneStateIdle::HandleBackCommandL
       
   632 // -----------------------------------------------------------
       
   633 //
       
   634 void CPhoneStateIdle::HandleBackCommandL()
       
   635     {
       
   636     TBool previousApp(EFalse);
       
   637     // If previous app activation is true then open
       
   638     // previous application.
       
   639     if ( iOnScreenDialer && 
       
   640         IsSimOk() )
       
   641         {
       
   642         TPhoneCmdParamBoolean booleanParam;
       
   643         iViewCommandHandle->ExecuteCommandL( 
       
   644             EPhoneViewGetActivatePreviousApp, &booleanParam );
       
   645         
       
   646         if ( booleanParam.Boolean() )
       
   647             {
       
   648             // Open previous app.
       
   649             iViewCommandHandle->ExecuteCommandL( 
       
   650                 EPhoneViewActivatePreviousApp );
       
   651 
       
   652             // Remove number entry from screen
       
   653             iViewCommandHandle->ExecuteCommandL( 
       
   654                 EPhoneViewRemoveNumberEntry ); 
       
   655 
       
   656             iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateFSW ); 
       
   657             previousApp = ETrue;   
       
   658             }
       
   659         }
       
   660         
       
   661     if ( !previousApp )
       
   662         {
       
   663         // Remove number entry from screen
       
   664         iViewCommandHandle->ExecuteCommandL( 
       
   665             EPhoneViewRemoveNumberEntry );
       
   666         // Do state-specific operation when number entry is cleared
       
   667         HandleNumberEntryClearedL();
       
   668         }    
       
   669     }
       
   670 
       
   671 // -----------------------------------------------------------
       
   672 // CPhoneStateIdle::DialVideoCallL
       
   673 // -----------------------------------------------------------
       
   674 //
       
   675 void CPhoneStateIdle::DialVideoCallL()
       
   676     {
       
   677     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::DialVideoCallL( ) ");
       
   678     if ( IsNumberEntryUsedL() )
       
   679         {
       
   680         // get the number entry contents
       
   681         HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
   682 #ifdef _DEBUG
       
   683         if ( (*phoneNumber).Compare( KExit ) == 0 )
       
   684             {
       
   685             CleanupStack::PopAndDestroy( phoneNumber );
       
   686             SendExitCommandL();
       
   687             }
       
   688         else
       
   689 #endif // _DEBUG
       
   690             {
       
   691             if ( IsSpeedDialNumber( (*phoneNumber) ) )
       
   692                 {
       
   693                 // Handle speed dial
       
   694                 SpeedDialL( (*phoneNumber)[0], EDialMethodMenuSelection );
       
   695                 }
       
   696             else
       
   697                 {
       
   698                 // call the number
       
   699                 iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
       
   700                 DialMultimediaCallL();
       
   701                 }
       
   702 
       
   703             CleanupStack::PopAndDestroy( phoneNumber );
       
   704             }
       
   705         }       
       
   706     }
       
   707 
       
   708 // -----------------------------------------------------------
       
   709 // CPhoneStateIdle::DisplayIncomingCallL
       
   710 // -----------------------------------------------------------
       
   711 //
       
   712 EXPORT_C void CPhoneStateIdle::DisplayIncomingCallL( TInt aCallId )
       
   713     {
       
   714     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::DisplayIncomingCallL( ) ");
       
   715     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo() && aCallId >= 0,
       
   716         Panic( EPhoneCtrlInvariant ) );
       
   717     // Close menu bar, if it is displayed
       
   718     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   719 
       
   720     // Remove any phone dialogs if they are displayed
       
   721     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
   722 
       
   723     // Capture keys when there is an incoming call
       
   724     CaptureKeysDuringCallNotificationL( ETrue );
       
   725 
       
   726     // Indicate that the Phone needs to be sent to the background if
       
   727     // an application other than the top application is in the foreground
       
   728     TPhoneCmdParamBoolean booleanParam;
       
   729     booleanParam.SetBoolean( !TopAppIsDisplayedL() );
       
   730     iViewCommandHandle->ExecuteCommandL( 
       
   731         EPhoneViewSetNeedToSendToBackgroundStatus,
       
   732         &booleanParam );
       
   733 
       
   734     // Bring Phone app in the foreground
       
   735     TPhoneCmdParamInteger uidParam;
       
   736     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   737     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
   738         &uidParam );
       
   739 
       
   740     // Set Phone as the top application
       
   741     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
   742         &uidParam );
       
   743         
       
   744     // Disable global notes when there is an incoming call
       
   745     TPhoneCmdParamBoolean globalNotifierParam;
       
   746     globalNotifierParam.SetBoolean( ETrue );
       
   747     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   748         &globalNotifierParam );
       
   749     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
       
   750         &globalNotifierParam );
       
   751     
       
   752     DisplayHeaderForCallComingInL( aCallId, EFalse ); //not waiting
       
   753     }
       
   754 
       
   755 // -----------------------------------------------------------
       
   756 // CPhoneStateIdle::DisplayCallSetupL
       
   757 // -----------------------------------------------------------
       
   758 //
       
   759 EXPORT_C void CPhoneStateIdle::DisplayCallSetupL( TInt aCallId )
       
   760     {
       
   761     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::DisplayCallSetupL( ) ");
       
   762     __ASSERT_DEBUG( aCallId > KErrNotFound, Panic( EPhoneCtrlParameterNotInitialized ) );
       
   763     
       
   764     // Close menu bar, if it is displayed
       
   765     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   766 
       
   767     // Capture keys when the phone is dialling
       
   768     CaptureKeysDuringCallNotificationL( ETrue );
       
   769 
       
   770     // Indicate that the Phone needs to be sent to the background if
       
   771     // an application other than the top application is in the foreground
       
   772     TPhoneCmdParamBoolean booleanParam;
       
   773     booleanParam.SetBoolean( !TopAppIsDisplayedL() );
       
   774     
       
   775     iViewCommandHandle->ExecuteCommandL( 
       
   776         EPhoneViewSetNeedToSendToBackgroundStatus,
       
   777         &booleanParam );
       
   778     
       
   779     // Bring Phone app in the foreground
       
   780     TPhoneCmdParamInteger uidParam;
       
   781     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   782     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
   783         &uidParam );
       
   784 
       
   785     // Set Phone as the top application
       
   786     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
   787         &uidParam ); 
       
   788     
       
   789     // Display call setup header
       
   790     DisplayHeaderForOutgoingCallL( aCallId );
       
   791     }
       
   792 
       
   793 // -----------------------------------------------------------
       
   794 // CPhoneStateIdle::HandleIdleForegroundEventL
       
   795 // -----------------------------------------------------------
       
   796 //
       
   797 EXPORT_C void CPhoneStateIdle::HandleIdleForegroundEventL()
       
   798     {
       
   799     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandleIdleForegroundEventL( ) ");
       
   800     
       
   801     if ( IsNumberEntryUsedL() )
       
   802         {
       
   803         // If numberentry is used then we need to call EPhoneViewSetDialerControlVisible 
       
   804         // to ensure that numberentry/dialler is drawn to UI.
       
   805         TPhoneViewResponseId respond = 
       
   806             iViewCommandHandle->HandleCommandL( EPhoneViewSetDialerControlVisible );
       
   807         
       
   808         if ( respond && IsNumberEntryVisibleL() )
       
   809             {
       
   810             // Set Number Entry CBA
       
   811             iCbaManager->SetCbaL( EPhoneNumberAcqCBA );
       
   812             }
       
   813         }
       
   814     else if ( !IsAnyQueryActiveL() )
       
   815         {
       
   816         // Set idle as top application
       
   817         iViewCommandHandle->ExecuteCommandL( EPhoneViewBringIdleToForeground );            
       
   818         }
       
   819     }
       
   820 
       
   821 // -----------------------------------------------------------
       
   822 // CPhoneStateIdle::HandlePhoneForegroundEventL
       
   823 // -----------------------------------------------------------
       
   824 
       
   825 EXPORT_C void CPhoneStateIdle::HandlePhoneForegroundEventL()
       
   826     {
       
   827     }
       
   828 
       
   829 // -----------------------------------------------------------
       
   830 // CPhoneStateIdle::HandlePhoneFocusLostEventL
       
   831 // -----------------------------------------------------------
       
   832 //
       
   833 EXPORT_C void CPhoneStateIdle::HandlePhoneFocusLostEventL()
       
   834     {
       
   835     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::HandlePhoneFocusLostEventL( ) ");
       
   836     if ( !IsNumberEntryUsedL() )
       
   837          {
       
   838          // If NE/dialer is open add icon to FSW list.
       
   839          iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateFSW );
       
   840          }
       
   841     }
       
   842 
       
   843 // -----------------------------------------------------------
       
   844 // CPhoneStateIdle::HandleIdleL
       
   845 // -----------------------------------------------------------
       
   846 //
       
   847 void CPhoneStateIdle::HandleIdleL( TInt /*aCallId*/ )
       
   848     {
       
   849     __LOGMETHODSTARTEND(EPhoneControl,  
       
   850         "CPhoneStateIdle::HandleIdleL()" );
       
   851         
       
   852     // Remove all call headers
       
   853     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveAllCallHeaders );
       
   854     
       
   855     // Close number entry
       
   856     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );    
       
   857 
       
   858     // Remove all notes and dialogs
       
   859     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );    
       
   860     }
       
   861  
       
   862 // -----------------------------------------------------------
       
   863 // CPhoneStateIdle::SpeedDialL
       
   864 // -----------------------------------------------------------
       
   865 //   
       
   866 EXPORT_C void CPhoneStateIdle::SpeedDialL( const TUint& aDigit, 
       
   867         TDialInitiationMethod aDialMethod )
       
   868     {
       
   869     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::SpeedDialL( ) ");
       
   870     
       
   871     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   872     
       
   873     TPhoneCmdParamSpeedDial speedDialParam;
       
   874     HBufC* phoneNumber = NumberForSpeedDialLocationL( aDigit, speedDialParam );
       
   875 
       
   876     // Store serviceId received from vmbx handler
       
   877     iStateMachine->PhoneEngineInfo()->SetServiceIdCommand( speedDialParam.ServiceId() );
       
   878     CleanupStack::PushL( phoneNumber );
       
   879     
       
   880     if ( NULL != phoneNumber && KNullDesC() != *phoneNumber )
       
   881         {
       
   882 
       
   883 
       
   884         DialL( *phoneNumber, speedDialParam.NumberType(), aDialMethod );
       
   885         
       
   886         if ( IsNumberEntryUsedL()  ) 
       
   887             {
       
   888             BeginTransEffectLC( ENumberEntryClose ); 
       
   889             
       
   890             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
   891             
       
   892             // Set Idle background, if still idle
       
   893             if ( iStateMachine->State() == this )
       
   894                 {
       
   895                 SetupIdleScreenInBackgroundL();
       
   896                 }
       
   897             
       
   898             EndTransEffect();
       
   899             }
       
   900         }
       
   901     else
       
   902         {
       
   903         // User cancelled dialog or didn't give a valid number
       
   904         SpeedDialCanceledL( aDigit );
       
   905         }
       
   906     
       
   907     CleanupStack::PopAndDestroy( phoneNumber );
       
   908     }
       
   909 
       
   910 // -----------------------------------------------------------
       
   911 // CPhoneStateIdle:SpeedDialCanceledL
       
   912 // -----------------------------------------------------------
       
   913 //
       
   914 EXPORT_C void CPhoneStateIdle::SpeedDialCanceledL( const TUint& aDigit )
       
   915 
       
   916     {
       
   917     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::SpeedDialCanceledL( ) ");
       
   918     if ( IsNumberEntryUsedL() )
       
   919         {
       
   920         if ( aDigit == KPhoneDtmf1Character || 
       
   921                   ( aDigit == KPhoneDtmf2Character && 
       
   922                     iViewCommandHandle->HandleCommandL( 
       
   923                      EPhoneViewIsStraightCallToVideoMailBox ) == EPhoneViewResponseSuccess ) ) 
       
   924             {
       
   925             // Remove number entry and set idle background on non-touch products
       
   926             if ( !FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
   927                 {
       
   928                 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
   929                 
       
   930                 // Set Idle background, if still idle ( f.e not incoming call arrived )
       
   931                 if ( iStateMachine->State() == this )
       
   932                     {
       
   933                     // idle screen in the background
       
   934                     SetupIdleScreenInBackgroundL();
       
   935                     }
       
   936                 }
       
   937             }
       
   938         }        
       
   939     }
       
   940 
       
   941 // -----------------------------------------------------------
       
   942 // CPhoneStateIdle::HandleNumberLongKeyPressL()
       
   943 // -----------------------------------------------------------
       
   944 //
       
   945 EXPORT_C void CPhoneStateIdle::HandleNumberLongKeyPressL()
       
   946     {
       
   947     __LOGMETHODSTARTEND(EPhoneControl, 
       
   948         "CPhoneStateIdle::HandleNumberLongKeyPressL( ) ");
       
   949     
       
   950     HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
   951     
       
   952     if ( phoneNumber && IsSpeedDialNumber ( *phoneNumber ) )
       
   953         {
       
   954         SpeedDialL( (*phoneNumber)[0], EDialMethodOneKeyDialing );
       
   955         }
       
   956     
       
   957     CleanupStack::PopAndDestroy( phoneNumber );
       
   958     }
       
   959 
       
   960 // -----------------------------------------------------------
       
   961 // CPhoneStateIdle::IsSpeedDialNumber()
       
   962 // -----------------------------------------------------------
       
   963 //
       
   964 EXPORT_C TBool CPhoneStateIdle::IsSpeedDialNumber( 
       
   965         const TDesC& aNumber ) const
       
   966     {
       
   967     return ( aNumber.Length() == KPhoneDtmfSpeedDialPrefixLength 
       
   968             && aNumber[0] >= KPhoneDtmf1Character 
       
   969             && aNumber[0] <= KPhoneDtmf9Character );
       
   970     }
       
   971 
       
   972 // -----------------------------------------------------------
       
   973 // CPhoneStateIdle::HandleSendCommandL()
       
   974 // -----------------------------------------------------------
       
   975 //
       
   976 EXPORT_C void CPhoneStateIdle::HandleSendCommandL()
       
   977     {
       
   978     __LOGMETHODSTARTEND(
       
   979         EPhoneControl, "CPhoneStateIdle::HandleSendCommandL()" );
       
   980     
       
   981     HandleVoiceCallCommandL( ETrue );
       
   982     }
       
   983 
       
   984 // -----------------------------------------------------------
       
   985 // CPhoneStateIdle::LaunchApplicationL()
       
   986 // -----------------------------------------------------------
       
   987 //
       
   988 void CPhoneStateIdle::LaunchApplicationL()
       
   989     {
       
   990     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::LaunchApplicationL( ) ");
       
   991     // Check if only one number exists in the number
       
   992     // entry
       
   993     TPhoneCmdParamInteger numberEntryCountParam;
       
   994     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
       
   995         &numberEntryCountParam );
       
   996 
       
   997     if ( numberEntryCountParam.Integer() == 1 )
       
   998         {
       
   999         // Remove the number entry window
       
  1000         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1001         
       
  1002         iStateMachine->SendPhoneEngineMessage( 
       
  1003                 MPEPhoneModel::EPEMessageEndDTMF );
       
  1004 
       
  1005         // Launch application.
       
  1006         iViewCommandHandle->ExecuteCommandL(
       
  1007             EPhoneViewLaunchApplication );
       
  1008 
       
  1009         // Continue displaying current app but set up the 
       
  1010         // idle screen in the background
       
  1011         SetupIdleScreenInBackgroundL();
       
  1012         }
       
  1013     }
       
  1014 
       
  1015 // -----------------------------------------------------------
       
  1016 // CPhoneStateIdle:SendExitCommandL
       
  1017 // -----------------------------------------------------------
       
  1018 //
       
  1019 void CPhoneStateIdle::SendExitCommandL()
       
  1020     {
       
  1021     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::SendExitCommand( ) ");
       
  1022     // Remove number entry from screen
       
  1023     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1024 
       
  1025     // Simulate exit command
       
  1026     CEikonEnv& eikEnv = *CEikonEnv::Static();
       
  1027     CCoeEnv& coeEnv = eikEnv;
       
  1028     RWsSession& wsSession=coeEnv.WsSession();
       
  1029     TKeyEvent keyEvent;
       
  1030     keyEvent.iCode = EEikCmdExit;
       
  1031     keyEvent.iScanCode = EEikCmdExit;
       
  1032     keyEvent.iModifiers = 0;
       
  1033     keyEvent.iRepeats = 0;
       
  1034     wsSession.SimulateKeyEvent( keyEvent );
       
  1035     wsSession.Flush();  
       
  1036 
       
  1037     iViewCommandHandle->ExecuteCommandL( EPhoneAppShutDown );
       
  1038     }
       
  1039 
       
  1040 // -----------------------------------------------------------
       
  1041 // CPhoneStateIdle::HandleEndKeyPressL
       
  1042 // -----------------------------------------------------------
       
  1043 //
       
  1044 void CPhoneStateIdle::HandleEndKeyPressL( TPhoneKeyEventMessages aMessage )
       
  1045     {
       
  1046     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneStateIdle::HandleEndKeyPressL( ) ");
       
  1047 
       
  1048     // End key not handled also in phone startup when pressed during country/time/date query
       
  1049     RWsSession sess = CCoeEnv::Static()->WsSession();
       
  1050     TApaTaskList appList( sess );
       
  1051     TApaTask startup = appList.FindApp( KUidStartupApplication );
       
  1052     
       
  1053     if ( !IsAutoLockOn() && !IsKeyLockOn() && !startup.Exists() )
       
  1054         {
       
  1055         //Cancels e.g. USB notifier and Audio notifier.
       
  1056         iViewCommandHandle->ExecuteCommandL( EPhoneViewCancelAllNotications );
       
  1057         iViewCommandHandle->ExecuteCommandL( EPhoneViewExitApplications );
       
  1058         // If KFeatureIdFfSimlessOfflineSupport is undef and security note is shown then do not
       
  1059         // remove security note from screen.
       
  1060         if ( !( IsSimStateNotPresentWithSecurityModeEnabled() && 
       
  1061                 !FeatureManager::FeatureSupported( KFeatureIdFfSimlessOfflineSupport ) ) )
       
  1062             {
       
  1063             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  1064             }
       
  1065         
       
  1066         if ( IsSimOk() )
       
  1067             {
       
  1068             if ( aMessage == EPhoneKeyLongPress )
       
  1069                 {
       
  1070                 // Close all connections
       
  1071                 iStateMachine->SendPhoneEngineMessage(
       
  1072                         MPEPhoneModel::EPEMessageTerminateAllConnections );   
       
  1073 
       
  1074                 if ( IsNumberEntryUsedL() )
       
  1075                     {
       
  1076                     // Remove number entry from screen
       
  1077                     iViewCommandHandle->ExecuteCommandL( 
       
  1078                         EPhoneViewRemoveNumberEntry );
       
  1079                     // Do state-specific operation when number entry is cleared
       
  1080                     HandleNumberEntryClearedL();
       
  1081                     
       
  1082                     // If long end key event occures then all calls are terminated and
       
  1083                     // dialer is closed, therefore tel.icon must be removed from FSW.
       
  1084                     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateFSW );
       
  1085                     }
       
  1086                 if ( !TopAppIsDisplayedL() )
       
  1087                     {
       
  1088                     // Display idle screen
       
  1089                     DisplayIdleScreenL();
       
  1090                     }
       
  1091                 }
       
  1092             else if ( IsNumberEntryUsedL() && TopAppIsDisplayedL() )
       
  1093                 {
       
  1094                 // Remove number entry from screen
       
  1095                 iViewCommandHandle->ExecuteCommandL( 
       
  1096                     EPhoneViewRemoveNumberEntry );
       
  1097                 // Do state-specific operation when number entry is cleared
       
  1098                 HandleNumberEntryClearedL();
       
  1099                 }
       
  1100             else if ( !TopAppIsDisplayedL() )
       
  1101                 {
       
  1102                 // Phone might not be the topmost app since it has
       
  1103                 // some dialog/query open therefore we need to check this
       
  1104                 // and remove dialog/phone.
       
  1105                 if ( IsAnyQueryActiveL()  )
       
  1106                     {
       
  1107                     if ( !IsSimStateNotPresentWithSecurityModeEnabled() )
       
  1108                         {
       
  1109                         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  1110                         }
       
  1111                     
       
  1112                     // Remove number entry from screen
       
  1113                     iViewCommandHandle->ExecuteCommandL( 
       
  1114                         EPhoneViewRemoveNumberEntry );
       
  1115                     } 
       
  1116                 // Bring Idle app to the foreground
       
  1117                 iViewCommandHandle->ExecuteCommandL( EPhoneViewBringIdleToForeground );
       
  1118                 }
       
  1119             }
       
  1120         else if ( IsNumberEntryUsedL() )
       
  1121             {
       
  1122             // Remove number entry from screen
       
  1123             iViewCommandHandle->ExecuteCommandL( 
       
  1124                 EPhoneViewRemoveNumberEntry );
       
  1125             StartShowSecurityNoteL();    
       
  1126             }
       
  1127         }
       
  1128     }
       
  1129 
       
  1130 // ---------------------------------------------------------
       
  1131 // CPhoneStateIdle::OnlyHashInNumberEntryL
       
  1132 // ---------------------------------------------------------
       
  1133 //
       
  1134 EXPORT_C void CPhoneStateIdle::OnlyHashInNumberEntryL()
       
  1135     {
       
  1136     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneStateIdle::OnlyHashInNumberEntryL( ) ");
       
  1137     
       
  1138     if ( CPhoneCenRepProxy::Instance()->IsTelephonyFeatureSupported( 
       
  1139         KTelephonyLVFlagMannerMode ) )
       
  1140         {
       
  1141         ChangeMannerModeL();
       
  1142         }            
       
  1143     else
       
  1144         {
       
  1145         StartAlsLineChangeTimerL();
       
  1146         }
       
  1147 
       
  1148     // Check if any application launch functionality
       
  1149     // is configured for pressing hash for a long time
       
  1150     // the return value of CheckAppLaunchingL ignored.
       
  1151     CheckAppLaunchingL( TKeyCode( KPhoneDtmfHashCharacter ) );
       
  1152     }
       
  1153 
       
  1154 // ---------------------------------------------------------
       
  1155 // CPhoneStateIdle::ChangeMannerModeL
       
  1156 // ---------------------------------------------------------
       
  1157 //
       
  1158 void CPhoneStateIdle::ChangeMannerModeL()
       
  1159     {
       
  1160     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneStateIdle::ChangeMannerModeL( ) ");
       
  1161 
       
  1162     // Get the profile information
       
  1163     const TInt profileId = 
       
  1164         iStateMachine->PhoneEngineInfo()->ProfileId();
       
  1165     TInt newProfile;
       
  1166     
       
  1167     if ( profileId == EProfileSilentId )
       
  1168         {
       
  1169         newProfile = EProfileGeneralId;
       
  1170         }
       
  1171     else
       
  1172         {
       
  1173         newProfile = EProfileSilentId;    
       
  1174         }
       
  1175         
       
  1176     if ( !iEngine )
       
  1177         {
       
  1178         iEngine = CreateProfileEngineL();
       
  1179         }
       
  1180 
       
  1181     iEngine->SetActiveProfileL( newProfile );
       
  1182     
       
  1183     // Stop playing DTMF tone
       
  1184     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF ); 
       
  1185     
       
  1186     if ( !iOnScreenDialer )
       
  1187         {
       
  1188         // Remove the number entry
       
  1189         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );        
       
  1190         }
       
  1191     else
       
  1192         {
       
  1193         NumberEntryClearL();
       
  1194         }
       
  1195     
       
  1196     iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
       
  1197  
       
  1198      // Bring Idle app to the top app
       
  1199     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIdleTopApplication );            
       
  1200     }
       
  1201 
       
  1202 // -----------------------------------------------------------
       
  1203 // CPhoneStateIdle::DialMultimediaCallL
       
  1204 // -----------------------------------------------------------
       
  1205 //
       
  1206 EXPORT_C void CPhoneStateIdle::DialMultimediaCallL()
       
  1207     {
       
  1208     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneStateIdle::DialMultimediaCall() ");
       
  1209     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  1210         Panic( EPhoneCtrlInvariant ) );
       
  1211     
       
  1212     if ( RestoreOngoing() )
       
  1213         {
       
  1214         CPhoneState::SendGlobalInfoNoteL( EPhoneInformationVideoCallNotAllowedDuringRestoreNote );
       
  1215         }
       
  1216     else
       
  1217         {
       
  1218         CPhoneState::DialMultimediaCallL();
       
  1219         }
       
  1220     }
       
  1221 
       
  1222 // -----------------------------------------------------------
       
  1223 // CPhoneStateIdle::DialVoiceCallL
       
  1224 // -----------------------------------------------------------
       
  1225 //
       
  1226 EXPORT_C void CPhoneStateIdle::DialVoiceCallL()
       
  1227     {
       
  1228     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::DialVoiceCallL() ");
       
  1229     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  1230         Panic( EPhoneCtrlInvariant ) );
       
  1231         
       
  1232     // Disable global notes
       
  1233     TPhoneCmdParamBoolean globalNotifierParam;
       
  1234     globalNotifierParam.SetBoolean( ETrue );
       
  1235     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
  1236         &globalNotifierParam );
       
  1237     
       
  1238     CPhoneState::DialVoiceCallL();
       
  1239  
       
  1240     }
       
  1241 
       
  1242 // -----------------------------------------------------------------------------
       
  1243 // CPhoneStateIdle::RestoreOngoing
       
  1244 // -----------------------------------------------------------------------------
       
  1245 //
       
  1246 TBool CPhoneStateIdle::RestoreOngoing()
       
  1247     {
       
  1248     TInt restoreValue;
       
  1249     
       
  1250     RProperty::Get( KUidSystemCategory, 
       
  1251                     conn::KUidBackupRestoreKey,
       
  1252                     restoreValue );
       
  1253         
       
  1254     return ( restoreValue & ( conn::EBURRestoreFull | conn::EBURRestorePartial ));
       
  1255     }
       
  1256 
       
  1257 // -----------------------------------------------------------------------------
       
  1258 // CPhoneStateIdle::CheckAppLaunchingL
       
  1259 // -----------------------------------------------------------------------------
       
  1260 //
       
  1261 TBool CPhoneStateIdle::CheckAppLaunchingL( const TKeyCode aCode )
       
  1262     {
       
  1263     TBool valuesFetched( EFalse );
       
  1264     
       
  1265     if( !IsSimOk() )
       
  1266         {
       
  1267         return valuesFetched;
       
  1268         }
       
  1269     
       
  1270     TPhoneCmdParamAppInfo appInfo;
       
  1271     HBufC8* appParam = HBufC8::NewL( KMaxParamLength );
       
  1272     CleanupStack::PushL( appParam );
       
  1273 
       
  1274     TPhoneCmdParamInteger numberEntryCount;
       
  1275     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
       
  1276         &numberEntryCount );
       
  1277     
       
  1278     TBool isValidAppLaunchingKeyEvent = EFalse;
       
  1279     if ( iCustomization && iCustomization->AllowAlphaNumericMode() &&
       
  1280          TKeyCode( KPhoneDtmfHashCharacter ) == aCode )
       
  1281         {
       
  1282         // If alphanumeric mode is supported FEP changes text input mode with
       
  1283         // long hash and removes hash from number entry.
       
  1284         isValidAppLaunchingKeyEvent = ( numberEntryCount.Integer() == 0 );
       
  1285         }
       
  1286     else
       
  1287         {
       
  1288         isValidAppLaunchingKeyEvent = ( numberEntryCount.Integer() == 1 );
       
  1289         }
       
  1290     
       
  1291     if ( isValidAppLaunchingKeyEvent )
       
  1292         {
       
  1293         TRAPD( err, 
       
  1294             CPhoneCenRepProxy::Instance()->FetchValuesFromCenRepL( 
       
  1295             appInfo, aCode, appParam, valuesFetched ) );
       
  1296         
       
  1297         if ( KErrNone == err && valuesFetched )
       
  1298             {
       
  1299             // Remove the number entry window
       
  1300             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1301 
       
  1302             // Stop playing DTMF tone
       
  1303             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
  1304 
       
  1305             TPhoneCommandParam* phoneCommandParam = 
       
  1306                 static_cast<TPhoneCommandParam*>( &appInfo );
       
  1307             iViewCommandHandle->ExecuteCommandL( 
       
  1308                         EPhoneViewActivateAppViewConventional,
       
  1309                         phoneCommandParam ); 
       
  1310             
       
  1311             // Continue displaying current app but set up the 
       
  1312             // idle screen in the background
       
  1313             SetupIdleScreenInBackgroundL();
       
  1314             }
       
  1315         }
       
  1316     CleanupStack::PopAndDestroy( appParam );
       
  1317     return valuesFetched;
       
  1318     }
       
  1319 
       
  1320 // -----------------------------------------------------------
       
  1321 // CPhoneStateIdle::NumberForSpeedDialLocationL
       
  1322 // -----------------------------------------------------------
       
  1323 // 
       
  1324 HBufC* CPhoneStateIdle::NumberForSpeedDialLocationL( 
       
  1325         const TUint& aDigit,
       
  1326         TPhoneCmdParamSpeedDial& aSpeedDialParam ) const
       
  1327     {
       
  1328     // Set the speed dial location from the digit in buffer. Character
       
  1329     // '1' means location 1, and so on.
       
  1330     const TInt location = aDigit - KPhoneDtmf1Character + 1;
       
  1331     aSpeedDialParam.SetLocation( location );
       
  1332     
       
  1333     // Get the number and type from the speed dial location.
       
  1334     HBufC* phoneNumber = HBufC::NewLC( KPhoneNumberEntryBufferSize );
       
  1335     
       
  1336     TPtr ptr( phoneNumber->Des() );
       
  1337     aSpeedDialParam.SetPhoneNumber( &ptr );
       
  1338     iViewCommandHandle->HandleCommandL( 
       
  1339         EPhoneViewGetNumberFromSpeedDialLocation, &aSpeedDialParam );
       
  1340 
       
  1341     CleanupStack::Pop( phoneNumber );
       
  1342     return phoneNumber;
       
  1343     }
       
  1344 
       
  1345 // -----------------------------------------------------------
       
  1346 // CPhoneStateIdle::HandleVoiceCallCommandL()
       
  1347 // -----------------------------------------------------------
       
  1348 //
       
  1349 void CPhoneStateIdle::HandleVoiceCallCommandL( TBool aSendKey )
       
  1350     {
       
  1351     __LOGMETHODSTARTEND(
       
  1352         EPhoneControl, "CPhoneStateIdle::HandleVoiceCallCommandL()" );
       
  1353     
       
  1354     if ( IsNumberEntryUsedL() )
       
  1355         {
       
  1356         // Handle send key short press, get the number entry contents.
       
  1357         HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
  1358         
       
  1359         if ( !IsSimOk() )
       
  1360             {
       
  1361             iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber ) ;
       
  1362             iStateMachine->SendPhoneEngineMessage( 
       
  1363             MPEPhoneModel::EPEMessageCheckEmergencyNumber );
       
  1364             CleanupStack::PopAndDestroy( phoneNumber );
       
  1365             return;
       
  1366             }
       
  1367             
       
  1368 #ifdef _DEBUG
       
  1369         if ( (*phoneNumber).Compare( KExit ) == 0 )
       
  1370             {
       
  1371             CleanupStack::PopAndDestroy( phoneNumber );
       
  1372             SendExitCommandL();
       
  1373             }
       
  1374         else
       
  1375 #endif // _DEBUG
       
  1376             {
       
  1377             if ( IsSpeedDialNumber( *phoneNumber ) )
       
  1378                 {
       
  1379                 // Handle speed dial
       
  1380                 SpeedDialL( (*phoneNumber)[0], aSendKey ? EDialMethodSendCommand : EDialMethodMenuSelection );
       
  1381                 }
       
  1382             else
       
  1383                 {
       
  1384                 // call the number
       
  1385                 iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
       
  1386                 DialVoiceCallL();
       
  1387                 }
       
  1388             
       
  1389             CleanupStack::PopAndDestroy( phoneNumber );
       
  1390             }
       
  1391         }    
       
  1392     }
       
  1393 
       
  1394 // End of File