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