phoneapp/phoneuicontrol/src/cphonestate.cpp
branchRCL_3
changeset 25 5266b1f337bd
parent 24 41a7f70b3818
child 26 8baf28733c3d
equal deleted inserted replaced
24:41a7f70b3818 25:5266b1f337bd
     1 /*
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    30 #include <Profile.hrh>
    30 #include <Profile.hrh>
    31 #include <PUAcodes.hrh>
    31 #include <PUAcodes.hrh>
    32 #include <AknUtils.h>
    32 #include <AknUtils.h>
    33 #include <telephonyvariant.hrh>
    33 #include <telephonyvariant.hrh>
    34 #include <aknsoundsystem.h>
    34 #include <aknsoundsystem.h>
       
    35 #include <cphcntprofileengine.h>
    35 #include <wlaninternalpskeys.h>
    36 #include <wlaninternalpskeys.h>
    36 #include <btengdomainpskeys.h>
    37 #include <btengdomainpskeys.h>
    37 #include <btengdomaincrkeys.h>
    38 #include <btengdomaincrkeys.h>
    38 #include <settingsinternalcrkeys.h>
    39 #include <settingsinternalcrkeys.h>
    39 #include <starterclient.h>
    40 #include <starterclient.h>
    40 #include <rsssettings.h>
    41 #include <RSSSettings.h>
    41 #include <UikonInternalPSKeys.h>
    42 #include <UikonInternalPSKeys.h>
    42 #include <telephonydomainpstypes.h>
    43 #include <telephonydomainpstypes.h>
    43 #include <telinformationpskeys.h>
    44 #include <telinformationpskeys.h>
       
    45 #include <activeidle2domainpskeys.h>
    44 #include <coreapplicationuisdomainpskeys.h>
    46 #include <coreapplicationuisdomainpskeys.h>
    45 #include <mccecall.h>
    47 #include <mccecall.h>
    46 #include <ccpdefs.h>
    48 #include <ccpdefs.h>
    47 #include <LogsDomainCRKeys.h>
    49 #include <LogsDomainCRKeys.h>
    48 #include <spsettings.h>
    50 #include <spsettings.h>
       
    51 #include <ScreensaverInternalPSKeys.h>
    49 #include <startupdomainpskeys.h>
    52 #include <startupdomainpskeys.h>
    50 #include <MediatorDomainUIDs.h>
    53 #include <MediatorDomainUIDs.h>
    51 #include <videotelcontrolmediatorapi.h>
    54 #include <videotelcontrolmediatorapi.h>
    52 #include <textresolver.h>
    55 #include <textresolver.h>
    53 #include <phoneappvoipcommands.hrh>
    56 #include <phoneappvoipcommands.hrh>
    63 #include "tphonecmdparamkeyevent.h"
    66 #include "tphonecmdparamkeyevent.h"
    64 #include "tphonecmdparamdynmenu.h"
    67 #include "tphonecmdparamdynmenu.h"
    65 #include "tphonecmdparamcallheaderdata.h"
    68 #include "tphonecmdparamcallheaderdata.h"
    66 #include "tphonecmdparamincallindicatordata.h"
    69 #include "tphonecmdparamincallindicatordata.h"
    67 #include "tphonecmdparamnote.h"
    70 #include "tphonecmdparamnote.h"
    68 #include "tphonecmdparamkeycapture.h"
    71 #include "tphonecmdparamKeycapture.h"
    69 #include "tphonecmdparamglobalnote.h"
    72 #include "tphonecmdparamglobalnote.h"
    70 #include "tphonecmdparamquery.h"
    73 #include "tphonecmdparamquery.h"
    71 #include "tphonecmdparamstring.h"
    74 #include "tphonecmdparamstring.h"
       
    75 #include "tphonecmdparammessageeditor.h"
    72 #include "tphonecmdparamcallstatedata.h"
    76 #include "tphonecmdparamcallstatedata.h"
    73 #include "tphonecmdparambitmap.h"
    77 #include "tphonecmdparambitmap.h"
    74 #include "tphonecmdparamaudiooutput.h"
    78 #include "tphonecmdparamaudiooutput.h"
    75 #include "tphonecmdparamaudioavailability.h"
    79 #include "tphonecmdparamaudioavailability.h"
    76 #include "tphonecmdparamappinfo.h"
    80 #include "tphonecmdparamappinfo.h"
    99 #include "cphonemediatorsender.h"
   103 #include "cphonemediatorsender.h"
   100 #include "cphonereleasecommand.h"
   104 #include "cphonereleasecommand.h"
   101 #include "cphonecontinueemergencycallcommand.h"
   105 #include "cphonecontinueemergencycallcommand.h"
   102 #include "cphonecallheadermanager.h"
   106 #include "cphonecallheadermanager.h"
   103 #include "cphonenumberentrymanager.h"
   107 #include "cphonenumberentrymanager.h"
   104 #include "tphonecmdparamsfidata.h" 
   108 #include "mphonesecuritymodeobserver.h"
   105 #include "mphonestorage.h"
   109 #include "easydialingcommands.hrh"
   106 #include "phoneconstants.h"
   110 
   107 #include "cphoneclearblacklist.h"
       
   108 
   111 
   109 // ================= MEMBER FUNCTIONS =======================
   112 // ================= MEMBER FUNCTIONS =======================
   110 
   113 
   111 EXPORT_C CPhoneState::CPhoneState(
   114 EXPORT_C CPhoneState::CPhoneState(
   112     MPhoneStateMachine* aStateMachine,
   115     MPhoneStateMachine* aStateMachine,
   113     MPhoneViewCommandHandle* aViewCommandHandle,
   116     MPhoneViewCommandHandle* aViewCommandHandle,
   114     MPhoneCustomization* aCustomization) :
   117     MPhoneCustomization* aCustomization) :
   115     iStateMachine( aStateMachine ),
   118     iStateMachine( aStateMachine ),
   116     iViewCommandHandle( aViewCommandHandle ),
   119     iViewCommandHandle( aViewCommandHandle ),
   117     iCustomization( aCustomization ),
   120     iCustomization( aCustomization )
   118     iEnv( *CEikonEnv::Static() )
       
   119     {
   121     {
   120     // Need to get current SimState for inherited classis
   122     // Need to get current SimState for inherited classis
   121     iPreviousSimState = SimState();
   123     iPreviousSimState = SimState();
   122     __ASSERT_ALWAYS(
   124     __ASSERT_ALWAYS(
   123         aStateMachine && aViewCommandHandle,
   125         aStateMachine && aViewCommandHandle,
   187 
   189 
   188         case MEngineMonitor::EPEMessageAudioOutputChanged:
   190         case MEngineMonitor::EPEMessageAudioOutputChanged:
   189             HandleAudioOutputChangedL();
   191             HandleAudioOutputChangedL();
   190             // Go to current state implementation
   192             // Go to current state implementation
   191             iCbaManager->UpdateInCallCbaL();
   193             iCbaManager->UpdateInCallCbaL();
   192             SetTouchPaneButtons(0);
       
   193             break;
   194             break;
   194 
   195 
   195         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
   196         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
   196             HandleAudioAvailableOutputChangedL();
   197             HandleAudioAvailableOutputChangedL();
   197             if ( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPENotActive )
   198             if ( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPENotActive )
   198                 {
   199                 {
   199                 // Go to current state implementation
   200                 // Go to current state implementation
   200                 iCbaManager->UpdateInCallCbaL();
   201                 iCbaManager->UpdateInCallCbaL();
   201                 SetTouchPaneButtons(0);
       
   202                 }
   202                 }
   203             break;
   203             break;
   204 
   204 
   205         case MEngineMonitor::EPEMessageChangedCallDuration:
   205         case MEngineMonitor::EPEMessageChangedCallDuration:
   206             HandleChangedCallDurationL( aCallId );
   206             HandleChangedCallDurationL( aCallId );
   209         case MEngineMonitor::EPEMessageRemoteBusy:
   209         case MEngineMonitor::EPEMessageRemoteBusy:
   210             HandleRemoteBusyL( aCallId );
   210             HandleRemoteBusyL( aCallId );
   211             break;
   211             break;
   212 
   212 
   213         case MEngineMonitor::EPEMessageCallWaiting:
   213         case MEngineMonitor::EPEMessageCallWaiting:
   214             // No need to send waiting notification for user.
   214             SendGlobalInfoNoteL( EPhoneWaitingText );
   215             //SendGlobalInfoNoteL( EPhoneWaitingText, ETrue );
       
   216             break;
   215             break;
   217 
   216 
   218         case MEngineMonitor::EPEMessageProfileChanged:
   217         case MEngineMonitor::EPEMessageProfileChanged:
   219             {
   218             {
       
   219             TPhoneCmdParamBoolean keypadVolumeParam;
       
   220             if ( iStateMachine->PhoneEngineInfo()->KeypadVolume() == 0 )
       
   221                 {
       
   222                 iViewCommandHandle->ExecuteCommandL( EPhoneViewKeypadAudioDisabled );
       
   223                 }
       
   224             else
       
   225                 {
       
   226                 iViewCommandHandle->ExecuteCommandL( EPhoneViewKeypadAudioEnabled );
       
   227                 }
       
   228             UpdateProfileDisplayL();
   220             }
   229             }
   221             break;
   230             break;
   222 
   231 
   223         case MEngineMonitor::EPEMessageRemoteTerminated:
   232         case MEngineMonitor::EPEMessageRemoteTerminated:
       
   233             // Close menu bar, if it is displayed, for call ending note
       
   234             iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
   224             /* Flow through */
   235             /* Flow through */
   225         case MEngineMonitor::EPEMessageDisconnecting:
   236         case MEngineMonitor::EPEMessageDisconnecting:
   226             HandleDisconnectingL( aCallId );
   237             HandleDisconnectingL( aCallId );
   227             break;
   238             break;
   228 
   239 
   229         case MEngineMonitor::EPEMessageTransferDone:
   240         case MEngineMonitor::EPEMessageTransferDone:
   230             SendGlobalInfoNoteL( EPhoneInCallTransferred, ETrue );
   241             SendGlobalInfoNoteL( EPhoneInCallTransferred );
   231             break;
   242             break;
   232 
   243 
   233        case MEngineMonitor::EPEMessageInitiatedEmergencyCall:
   244        case MEngineMonitor::EPEMessageInitiatedEmergencyCall:
   234             HandleInitiatedEmergencyCallL( aCallId );
   245             HandleInitiatedEmergencyCallL( aCallId );
   235             break;
   246             break;
   236 
   247 
   237        case MEngineMonitor::EPEMessageInitiatedEmergencyWhileActiveVideo:
   248        case MEngineMonitor::EPEMessageInitiatedEmergencyWhileActiveVideo:
   238            HandleInitiatedEmergencyWhileActiveVideoL();
   249            HandleInitiatedEmergencyWhileActiveVideoL();
   239            break;
   250            break;
   240 
   251 
   241        case MEngineMonitor::EPEMessageCallSecureStatusChanged:
   252         case MEngineMonitor::EPEMessageShowIMEI:
   242            HandleCallSecureStatusChangeL( aCallId );
   253             // Stop playing DTMF tone
   243 
   254             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
   244            if ( iCustomization )
   255             HandleShowImeiL();
   245                {
   256             break;
   246                iCustomization->HandlePhoneEngineMessageL( aMessage,
   257 
   247                    aCallId );
   258         case MEngineMonitor::EPEMessageCallSecureStatusChanged:
   248                }
   259             HandleCallSecureStatusChangeL( aCallId );
   249            break;
   260             ForwardPEMessageToPhoneCustomizationL( aMessage, aCallId );
       
   261             break;
       
   262 
       
   263         case MEngineMonitor::EPEMessageActivateWarrantyMode:
       
   264             // Stop playing DTMF tone
       
   265             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   266             HandleShowLifeTimerL();
       
   267             break;
   250 
   268 
   251         case MEngineMonitor::EPEMessageIssuingUSSDRequest:
   269         case MEngineMonitor::EPEMessageIssuingUSSDRequest:
   252             {
   270             {
   253              // Enable global notes
   271              // Enable global notes
   254             TPhoneCmdParamBoolean globalNotifierParam;
   272             TPhoneCmdParamBoolean globalNotifierParam;
   343 
   361 
   344         case MEngineMonitor::EPEMessageShowIncCallGroupIndex:
   362         case MEngineMonitor::EPEMessageShowIncCallGroupIndex:
   345             HandleCugInUseNoteL();
   363             HandleCugInUseNoteL();
   346             break;
   364             break;
   347 
   365 
       
   366         // *#2873#
       
   367         case MEngineMonitor::EPEMessageBTDebugMode:
       
   368             accessoryBtHandler = CPhoneAccessoryBTHandler::NewLC(
       
   369                 iViewCommandHandle, iStateMachine, this );
       
   370             accessoryBtHandler->SetBTDebugModeL();
       
   371             CleanupStack::PopAndDestroy( accessoryBtHandler );
       
   372             break;
       
   373         
       
   374         case MEngineMonitor::EPEMessageInitiatedMoCall:
       
   375             // Message should be only handled by CPhoneStateIdle, 
       
   376             // if state is something else than idle then do nothing.
       
   377             break;
       
   378 
   348         default:
   379         default:
   349 
       
   350             TBool handled( EFalse );
   380             TBool handled( EFalse );
   351 
   381             handled = ForwardPEMessageToPhoneCustomizationL( aMessage, aCallId );
   352             if ( iCustomization )
       
   353                 {
       
   354                 handled = iCustomization->HandlePhoneEngineMessageL(
       
   355                                 aMessage, aCallId );
       
   356                 }
       
   357 
       
   358             if ( EFalse == handled )
   382             if ( EFalse == handled )
   359                 {
   383                 {
   360                 MPhoneMediatorMessage* mediatorMessage = CPhoneMediatorFactory::Instance()->MediatorMessage( aMessage, aCallId );
   384                 MPhoneMediatorMessage* mediatorMessage = CPhoneMediatorFactory::Instance()->MediatorMessage( aMessage, aCallId );
   361                 if( mediatorMessage )
   385                 if( mediatorMessage )
   362                     {
   386                     {
   385     TPhoneCmdParamBoolean booleanParam;
   409     TPhoneCmdParamBoolean booleanParam;
   386     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
   410     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
   387     booleanParam.SetBoolean( audioMute );
   411     booleanParam.SetBoolean( audioMute );
   388     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateMuteUIChanges,
   412     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateMuteUIChanges,
   389         &booleanParam );
   413         &booleanParam );
   390     
       
   391     SetTouchPaneButtons(0);
       
   392     }
   414     }
   393 
   415 
   394 // -----------------------------------------------------------
   416 // -----------------------------------------------------------
   395 // CPhoneState::HandleAudioOutputChangedL
   417 // CPhoneState::HandleAudioOutputChangedL
   396 // Default handling for EPEMessageAudioOutputChanged message
   418 // Default handling for EPEMessageAudioOutputChanged message
   430          !btAvailable )
   452          !btAvailable )
   431         {
   453         {
   432         CPhoneBtaaDisconnectHandler::InstanceL()->HandleConnectionLostL();
   454         CPhoneBtaaDisconnectHandler::InstanceL()->HandleConnectionLostL();
   433         }
   455         }
   434     else if ( audioOutput == EPEBTAudioAccessory && 
   456     else if ( audioOutput == EPEBTAudioAccessory && 
   435             previousOutput != EPEBTAudioAccessory &&
   457     		previousOutput > EPENotActive && 
       
   458     		previousOutput != EPEBTAudioAccessory &&
   436             btAvailable )
   459             btAvailable )
   437         {
   460         {
   438         CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
   461         CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
   439             iViewCommandHandle, iStateMachine, this );
   462             iViewCommandHandle, iStateMachine, this );
   440         bt->ShowBTActivatedL();
   463         bt->ShowBTActivatedL();
   446         CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
   469         CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
   447         }
   470         }
   448     else if ( RouteParameters.iShowNote && audioOutput == EPELoudspeaker )
   471     else if ( RouteParameters.iShowNote && audioOutput == EPELoudspeaker )
   449         {
   472         {
   450         CAknKeySoundSystem* keySounds =
   473         CAknKeySoundSystem* keySounds =
   451                static_cast<CAknAppUi*>( iEnv.EikAppUi() )->KeySounds();
   474                static_cast<CAknAppUi*>( EikonEnv()->EikAppUi() )->KeySounds();
   452         keySounds->PlaySound( EAvkonSIDIHFActive );
   475         keySounds->PlaySound( EAvkonSIDIHFActive );
   453         }
   476         }
   454     }
   477     }
   455 
   478 
   456 // -----------------------------------------------------------
   479 // -----------------------------------------------------------
   499                  iPreviousSimState == EPESimNotReady )
   522                  iPreviousSimState == EPESimNotReady )
   500                 {
   523                 {
   501                 __PHONELOG( EBasic, EPhoneControl, "SIM card was removed" );
   524                 __PHONELOG( EBasic, EPhoneControl, "SIM card was removed" );
   502 
   525 
   503                 TPhoneCmdParamGlobalNote globalNoteParam;
   526                 TPhoneCmdParamGlobalNote globalNoteParam;
   504                 globalNoteParam.SetType( EPhoneMessageBoxInformation );
   527                 globalNoteParam.SetType( EAknGlobalInformationNote );
       
   528                 globalNoteParam.SetTone( EAvkonSIDNoSound );
   505 
   529 
   506                 globalNoteParam.SetTextResourceId(
   530                 globalNoteParam.SetTextResourceId(
   507                     CPhoneMainResourceResolver::Instance()->
   531                     CPhoneMainResourceResolver::Instance()->
   508                     ResolveResourceID( EPhoneSimRemoved ) );
   532                     ResolveResourceID( EPhoneSimRemoved ) );
   509 
   533 
   592 // -----------------------------------------------------------------------------
   616 // -----------------------------------------------------------------------------
   593 //
   617 //
   594 TBool CPhoneState::IsTouchDTmfDialerOn() const
   618 TBool CPhoneState::IsTouchDTmfDialerOn() const
   595     {
   619     {
   596     TBool status( EFalse );
   620     TBool status( EFalse );
       
   621     if ( IsOnScreenDialerSupported() )
       
   622         {
       
   623         TBool isDialerVisible( EFalse );
       
   624         TRAP_IGNORE( isDialerVisible = IsDTMFEditorVisibleL() );
       
   625 
       
   626         if ( isDialerVisible )
       
   627             {
       
   628             status = ETrue;
       
   629             }
       
   630         }
   597     return status;
   631     return status;
   598     }
   632     }
   599 // -----------------------------------------------------------------------------
   633 // -----------------------------------------------------------------------------
   600 // CPhoneState::SendDtmfKeyEventL
   634 // CPhoneState::SendDtmfKeyEventL
   601 // send dtmf event when,
   635 // send dtmf event when,
   607 void CPhoneState::SendDtmfKeyEventL( const TKeyEvent& aKeyEvent,
   641 void CPhoneState::SendDtmfKeyEventL( const TKeyEvent& aKeyEvent,
   608                TEventCode aEventCode  )
   642                TEventCode aEventCode  )
   609     {
   643     {
   610 
   644 
   611     if ( !IsTouchDTmfDialerOn()
   645     if ( !IsTouchDTmfDialerOn()
   612         && !IsAnyQueryActiveL() )
   646         && !IsAnyQueryActiveL()
   613         {
   647         && !IsMenuBarVisibleL() )
   614         // Send the key event to the phone engine.
   648         {
   615         SendKeyEventL( aKeyEvent, aEventCode );
   649         if( IsKeyEventFurtherProcessedL( aKeyEvent ))
   616         }
   650             {
       
   651             // Send the key event to the phone engine.
       
   652             SendKeyEventL( aKeyEvent, aEventCode );
       
   653             }
       
   654         }
       
   655 
   617     }
   656     }
   618 
   657 
   619 // -----------------------------------------------------------------------------
   658 // -----------------------------------------------------------------------------
   620 // CPhoneState::IsKeyEventFurtherProcessed
   659 // CPhoneState::IsKeyEventFurtherProcessed
   621 // -----------------------------------------------------------------------------
   660 // -----------------------------------------------------------------------------
   622 //
   661 //
   623 TBool CPhoneState::IsKeyEventFurtherProcessedL( const TKeyEvent& /*aKeyEvent*/ ) const
   662 TBool CPhoneState::IsKeyEventFurtherProcessedL( const TKeyEvent& aKeyEvent ) const
   624     {
   663     {
       
   664     // While being in some special keyboard mode (Full Screen&mini QWERTY,
       
   665     // handwriting mode) FEP sends only EEventKey -event and thus manual
       
   666     // DTMFs can not be played with the user specified tone lengths. Also,
       
   667     // in general, DTMFs are tried to play only in numeric mode.
       
   668     TBool numericMode = iViewCommandHandle->HandleCommandL(
       
   669       EPhoneViewIsNumberEntryNumericMode ) == EPhoneViewResponseSuccess;
       
   670 
       
   671     // Key presses simulated by dialer are played even if in alphanumeric mode.
       
   672     const TBool simulatedByDialer = 
       
   673         ( ( aKeyEvent.iModifiers & ( EModifierNumLock | EModifierKeypad ) ) 
       
   674                 == ( EModifierNumLock | EModifierKeypad ) );
       
   675 
       
   676 
       
   677     if ( ( ( aKeyEvent.iModifiers & EModifierSpecial ) != 0 || !numericMode ) && !simulatedByDialer )
       
   678         {
       
   679         return EFalse;
       
   680         }
       
   681 
   625     return ETrue;
   682     return ETrue;
   626     }
   683     }
   627 
   684 
   628 // -----------------------------------------------------------
   685 // -----------------------------------------------------------
   629 // CPhoneState::HandleErrorL
   686 // CPhoneState::HandleErrorL
   641 
   698 
   642     __PHONELOG1( EBasic, EPhoneControl,
   699     __PHONELOG1( EBasic, EPhoneControl,
   643         "PhoneUIControl: CPhoneState::HandleErrorL - aErrorInfo.iCallId =%d ",
   700         "PhoneUIControl: CPhoneState::HandleErrorL - aErrorInfo.iCallId =%d ",
   644         aErrorInfo.iCallId );
   701         aErrorInfo.iCallId );
   645 
   702 
       
   703 
       
   704     // Sets touch buttons to correct status if error has occured.
       
   705     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
   706         {
       
   707         iViewCommandHandle->ExecuteCommand( EPhoneResetTouchButtons );
       
   708         }
   646 
   709 
   647     // Do the common error handling (display proper notes etc)
   710     // Do the common error handling (display proper notes etc)
   648     CPhoneMainErrorMessagesHandler::Instance()->ShowErrorSpecificNoteL( aErrorInfo );
   711     CPhoneMainErrorMessagesHandler::Instance()->ShowErrorSpecificNoteL( aErrorInfo );
   649 
   712 
   650     switch( aErrorInfo.iErrorCode )
   713     switch( aErrorInfo.iErrorCode )
   674                     }
   737                     }
   675                 }
   738                 }
   676             }
   739             }
   677             break;
   740             break;
   678 
   741 
   679             case ECCPErrorCCServiceNotAvailable:
   742         case ECCPErrorCCServiceNotAvailable:
       
   743             {
       
   744             if( IsVideoCall( aErrorInfo.iCallId ) )
   680                 {
   745                 {
   681                 if( IsVideoCall( aErrorInfo.iCallId ) )
   746                 CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( EFalse );
   682                     {
       
   683                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( EFalse );
       
   684                     }
       
   685                 }
   747                 }
   686                 break;
   748             }
   687 
   749             break;
   688             case ECCPErrorBadRequest:
   750 
       
   751         case ECCPErrorBadRequest:
       
   752             {
       
   753             TPECallType callType =
       
   754                 iStateMachine->PhoneEngineInfo()->CallTypeCommand();
       
   755 
       
   756             if( callType == EPECallTypeVideo )
   689                 {
   757                 {
   690                 TPECallType callType =
   758                     // Dialling MO video call cannot reach 3G network.
   691                     iStateMachine->PhoneEngineInfo()->CallTypeCommand();
   759                     __PHONELOG1( EBasic, EPhoneControl,
   692 
   760                         "PhoneUIControl: CPhoneState::HandleErrorL - ShowReconnectQueryL vid 2, callid%d ",
   693                 if( callType == EPECallTypeVideo )
   761                         aErrorInfo.iCallId );
   694                     {
   762                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
   695                         // Dialling MO video call cannot reach 3G network.
       
   696                         __PHONELOG1( EBasic, EPhoneControl,
       
   697                             "PhoneUIControl: CPhoneState::HandleErrorL - ShowReconnectQueryL vid 2, callid%d ",
       
   698                             aErrorInfo.iCallId );
       
   699                         CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
       
   700                     }
       
   701                 }
   763                 }
   702                 break;
   764             }
   703 
   765             break;
   704         case ECCPErrorVideoCallNotSupportedByNetwork:
   766 
       
   767         case ECCPErrorVideoCallNotSupportedByNetwork: // Flow trough
   705         case ECCPErrorVideoCallSetupFailed:
   768         case ECCPErrorVideoCallSetupFailed:
   706         case ECCPErrorNotReached:
   769         case ECCPErrorNotReached:
   707            // If call id found and seems to be Video Call
   770         case ECCPErrorCCBearerCapabilityNotCurrentlyAvailable:
       
   771         case ECCPErrorCCBearerCapabilityNotAuthorised:
       
   772         case ECCPErrorServiceSettingError:
       
   773         case ECCPErrorNoAnswerForVideo:
       
   774             {
       
   775             // If call id found and seems to be Video Call
   708             if ( IsVideoCall( aErrorInfo.iCallId ) )
   776             if ( IsVideoCall( aErrorInfo.iCallId ) )
   709                 {
   777                 {
   710                 // Get active call count
   778                 // Get active call count
   711                 TPhoneCmdParamInteger activeCallCount;
   779                 TPhoneCmdParamInteger activeCallCount;
   712                 iViewCommandHandle->ExecuteCommandL(
   780                 iViewCommandHandle->ExecuteCommandL(
   724                     aErrorInfo.iCallId );
   792                     aErrorInfo.iCallId );
   725                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL(
   793                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL(
   726                               ECCPErrorNotReached == aErrorInfo.iErrorCode );
   794                               ECCPErrorNotReached == aErrorInfo.iErrorCode );
   727                     }
   795                     }
   728                 }
   796                 }
       
   797             }
   729             break;
   798             break;
   730 
   799 
   731         case ECCPErrorNoService:
   800         case ECCPErrorNoService:
   732             // No network -> hide volume popup
   801             // No network -> hide volume popup
   733             iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
   802             iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
   735 
   804 
   736         case ECCPErrorSatControl:
   805         case ECCPErrorSatControl:
   737             {
   806             {
   738             // check, that there really was a call established before completing SAT request
   807             // check, that there really was a call established before completing SAT request
   739             if( aErrorInfo.iCallId != KPECallIdNotUsed )
   808             if( aErrorInfo.iCallId != KPECallIdNotUsed )
   740                 {
   809                 {                
       
   810                 // Complete sat request
       
   811                 if ( iStateMachine->PhoneEngineInfo()->CallOrigin( aErrorInfo.iCallId ) == EPECallOriginSAT )
       
   812                     {
       
   813                     CompleteSatRequestL( aErrorInfo.iCallId );
       
   814                     }
   741                 }
   815                 }
   742 
   816 
   743             // remove number entry
   817             // remove number entry
   744             if ( !IsOnScreenDialerSupported() && IsNumberEntryUsedL() )
   818             if ( !IsOnScreenDialerSupported() && IsNumberEntryUsedL() )
   745                 {
   819                 {
   754             break;
   828             break;
   755 
   829 
   756         default:
   830         default:
   757             break;
   831             break;
   758         }
   832         }
   759 
       
   760     // clear call blacklist if call failure occurs
   833     // clear call blacklist if call failure occurs
   761     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   834     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   762     }
   835     }
   763 
   836 
   764 // -----------------------------------------------------------
   837 // -----------------------------------------------------------
   778     // Update only if the display is on or if HAL::Get returns an error, 
   851     // Update only if the display is on or if HAL::Get returns an error, 
   779     // in which case display value cannot be trusted.
   852     // in which case display value cannot be trusted.
   780     if ( ret || isDisplayOn )
   853     if ( ret || isDisplayOn )
   781         {
   854         {
   782         // Get the call duration
   855         // Get the call duration
   783         TTimeIntervalSeconds seconds =
   856         TTime time( 0 );
       
   857         TTimeIntervalSeconds timeInterval =
   784             iStateMachine->PhoneEngineInfo()->CallDuration( aCallId );
   858             iStateMachine->PhoneEngineInfo()->CallDuration( aCallId );
   785 
   859         time += timeInterval;
   786         TPhoneCmdParamInteger time;
   860         
   787         time.SetInteger(seconds.Int());
   861         // Read format string from AVKON resource
   788         iViewCommandHandle->ExecuteCommandL(EPhoneViewUpdateCallHeaderCallDuration, aCallId, &time);
   862         TBuf<KPhoneMaxCharsInNote> timeDurationFormatString( KNullDesC );
   789         }
   863         LoadResource( timeDurationFormatString, EPhoneCallDurationFormatString );
   790     }	
   864         
       
   865         // Format the time
       
   866         TBuf<KPhoneMaxTimeDisplayTextLength> timeString( KNullDesC );
       
   867         time.FormatL( timeString, timeDurationFormatString );
       
   868         
       
   869         // Localize time format
       
   870         AknTextUtils::LanguageSpecificNumberConversion( timeString );
       
   871         
       
   872         // update the call header call duration
       
   873         iViewCommandHandle->ExecuteCommandL(
       
   874             EPhoneViewUpdateCallHeaderCallDuration,
       
   875             aCallId,
       
   876             timeString );
       
   877         }
       
   878     }
   791 
   879 
   792 // -----------------------------------------------------------------------------
   880 // -----------------------------------------------------------------------------
   793 // CPhoneState::HandleRemoteBusyL
   881 // CPhoneState::HandleRemoteBusyL
   794 // -----------------------------------------------------------------------------
   882 // -----------------------------------------------------------------------------
   795 //
   883 //
   796 void CPhoneState::HandleRemoteBusyL( TInt aCallId )
   884 void CPhoneState::HandleRemoteBusyL( TInt aCallId )
   797     {
   885     {
   798     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleRemoteBusyL( ) ");
   886     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleRemoteBusyL( ) ");
   799 
   887     ShowNumberBusyNoteL();
   800     TPEErrorInfo info;
   888 
   801     info.iCallId = aCallId;
       
   802     info.iErrorCode = ECCPErrorBusy;
       
   803     info.iErrorType = EPECcp;
       
   804     CPhoneMainErrorMessagesHandler::Instance()->ShowErrorSpecificNoteL( info );
       
   805     
       
   806     const TPECallType callType =
   889     const TPECallType callType =
   807         iStateMachine->PhoneEngineInfo()->CallTypeCommand();
   890         iStateMachine->PhoneEngineInfo()->CallTypeCommand();
   808 
   891 
   809     if( callType == EPECallTypeVideo )
   892     if( callType == EPECallTypeVideo )
   810         {
   893         {
   812          __PHONELOG1( EBasic, EPhoneControl,
   895          __PHONELOG1( EBasic, EPhoneControl,
   813             "PhoneUIControl: CPhoneState::HandleRemoteBusyL - ShowReconnectQueryL vid 5, callid%d ",
   896             "PhoneUIControl: CPhoneState::HandleRemoteBusyL - ShowReconnectQueryL vid 5, callid%d ",
   814                 aCallId );
   897                 aCallId );
   815         CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
   898         CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
   816         }
   899         }
       
   900     else
       
   901         {        
       
   902         // Complete sat request
       
   903         if ( iStateMachine->PhoneEngineInfo()->CallOrigin( aCallId ) == EPECallOriginSAT )
       
   904             {
       
   905             CompleteSatRequestL( aCallId );
       
   906             }
       
   907         }
   817     }
   908     }
   818 
   909 
   819 // -----------------------------------------------------------
   910 // -----------------------------------------------------------
   820 // CPhoneState::HandleDisconnectingL
   911 // CPhoneState::HandleDisconnectingL
   821 // -----------------------------------------------------------
   912 // -----------------------------------------------------------
   822 //
   913 //
   823 EXPORT_C void CPhoneState::HandleDisconnectingL( TInt aCallId )
   914 EXPORT_C void CPhoneState::HandleDisconnectingL( TInt aCallId )
   824     {
   915     {
   825     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleDisconnectingL( ) ");
   916     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleDisconnectingL( ) ");
       
   917     // If there is no call in connected state then EPhoneDtmfTextQuery and EPhoneDtmfListQueryDialog
       
   918     // must be dismmissed from UI, therefore we must set EPhoneViewSetNoConnectedCalls to ETrue this
       
   919     // way we can ensure that CPhoneQueryController doesnt relaunch EPhoneDtmfListQueryDialog.
       
   920     if ( !IsAnyConnectedCalls() )
       
   921         {
       
   922         TPhoneCmdParamBoolean booleanParam;
       
   923         booleanParam.SetBoolean(ETrue);
       
   924         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetNoConnectedCalls, &booleanParam );
       
   925         }
   826 
   926 
   827     TPhoneCmdParamCallHeaderData callHeaderParam;
   927     TPhoneCmdParamCallHeaderData callHeaderParam;
   828     callHeaderParam.SetCallState( EPEStateDisconnecting );
   928     callHeaderParam.SetCallState( EPEStateDisconnecting );
   829 
   929 
   830     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
   930     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
   833     callHeaderParam.SetLabelText( labelText );
   933     callHeaderParam.SetLabelText( labelText );
   834 
   934 
   835     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
   935     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
   836 
   936 
   837     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
   937     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
   838         &callHeaderParam );    
   938         &callHeaderParam );
   839 
   939 
   840     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   940     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   841     }
   941     }
   842 
   942 
   843 // -----------------------------------------------------------
   943 // -----------------------------------------------------------
   938             }
  1038             }
   939         }
  1039         }
   940     }
  1040     }
   941 
  1041 
   942 // -----------------------------------------------------------
  1042 // -----------------------------------------------------------
       
  1043 // CPhoneState::IsNoteVisibleL
       
  1044 // -----------------------------------------------------------
       
  1045 //
       
  1046 EXPORT_C TBool CPhoneState::IsNoteVisibleL()
       
  1047     {
       
  1048     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNoteVisibleL( ) ");
       
  1049     TPhoneCmdParamBoolean booleanParam;
       
  1050     iViewCommandHandle->ExecuteCommandL(
       
  1051         EPhoneViewGetIsNoteVisible, &booleanParam );
       
  1052     return booleanParam.Boolean();
       
  1053     }
       
  1054 
       
  1055 // -----------------------------------------------------------
       
  1056 // CPhoneState::IsMenuBarVisibleL
       
  1057 // -----------------------------------------------------------
       
  1058 //
       
  1059 EXPORT_C TBool CPhoneState::IsMenuBarVisibleL() const
       
  1060     {
       
  1061     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsMenuBarVisibleL( ) ");
       
  1062     return iViewCommandHandle->HandleCommandL(
       
  1063         EPhoneViewIsMenuBarVisible ) ==
       
  1064         EPhoneViewResponseSuccess;
       
  1065     }
       
  1066 
       
  1067 // -----------------------------------------------------------
   943 // CPhoneState::HandleNumericKeyEventL
  1068 // CPhoneState::HandleNumericKeyEventL
   944 // -----------------------------------------------------------
  1069 // -----------------------------------------------------------
   945 //
  1070 //
   946 EXPORT_C void CPhoneState::HandleNumericKeyEventL(
  1071 EXPORT_C void CPhoneState::HandleNumericKeyEventL(
   947     const TKeyEvent& /*aKeyEvent*/,
  1072     const TKeyEvent& aKeyEvent,
   948     TEventCode /*aEventCode*/ )
  1073     TEventCode aEventCode )
   949     {
  1074     {
   950     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleNumericKeyEventL( ) ");
  1075     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleNumericKeyEventL( ) ");
       
  1076 
       
  1077     TBool numberEntryUsed = IsNumberEntryUsedL();
       
  1078 
       
  1079     if ( numberEntryUsed && ( aKeyEvent.iRepeats == 0 ||
       
  1080               aKeyEvent.iScanCode == EStdKeyBackspace ||
       
  1081               aKeyEvent.iScanCode == EStdKeyLeftArrow ||
       
  1082               aKeyEvent.iScanCode == EStdKeyUpArrow   ||
       
  1083               aKeyEvent.iScanCode == EStdKeyDownArrow ||
       
  1084               aKeyEvent.iScanCode == EStdKeyRightArrow ))
       
  1085         {
       
  1086         // Number entry exists but may be hidden
       
  1087         KeyEventForExistingNumberEntryL( aKeyEvent, aEventCode );
       
  1088         }
   951 
  1089 
   952     }
  1090     }
   953 
  1091 
   954 // -----------------------------------------------------------------------------
  1092 // -----------------------------------------------------------------------------
   955 // CPhoneState::IsAnyQueryActiveL
  1093 // CPhoneState::IsAnyQueryActiveL
  1009     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsNoteDismissableL: %d ", dismiss );
  1147     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsNoteDismissableL: %d ", dismiss );
  1010     return dismiss;
  1148     return dismiss;
  1011     }
  1149     }
  1012 
  1150 
  1013 // -----------------------------------------------------------
  1151 // -----------------------------------------------------------
       
  1152 // CPhoneState::IsDialingExtensionInFocusL
       
  1153 // -----------------------------------------------------------
       
  1154 //
       
  1155 EXPORT_C TBool CPhoneState::IsDialingExtensionInFocusL() const
       
  1156     {
       
  1157     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsDialingExtensionInFocusL( ) ");
       
  1158     return iViewCommandHandle->HandleCommandL(
       
  1159         EPhoneViewGetEasyDialingInFocusStatus ) ==
       
  1160         EPhoneViewResponseSuccess;
       
  1161     }
       
  1162 
       
  1163 // -----------------------------------------------------------
       
  1164 // CPhoneState::EikonEnv
       
  1165 // -----------------------------------------------------------
       
  1166 //
       
  1167 EXPORT_C CEikonEnv* CPhoneState::EikonEnv() const
       
  1168     {
       
  1169     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::EikonEnv( ) ");
       
  1170     return iEnv;
       
  1171     }
       
  1172 
       
  1173 // -----------------------------------------------------------
       
  1174 // CPhoneState::SetEikonEnv
       
  1175 // -----------------------------------------------------------
       
  1176 //
       
  1177 EXPORT_C void CPhoneState::SetEikonEnv( CEikonEnv* aEnv )
       
  1178     {
       
  1179     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetEikonEnv( ) ");
       
  1180     iEnv = aEnv;
       
  1181     }
       
  1182 
       
  1183 // -----------------------------------------------------------
  1014 // CPhoneState::SendKeyEventL
  1184 // CPhoneState::SendKeyEventL
  1015 // -----------------------------------------------------------
  1185 // -----------------------------------------------------------
  1016 //
  1186 //
  1017 void CPhoneState::SendKeyEventL(
  1187 void CPhoneState::SendKeyEventL(
  1018     const TKeyEvent& aKeyEvent,
  1188     const TKeyEvent& aKeyEvent,
  1058         // Get the number entry contents, if it exists
  1228         // Get the number entry contents, if it exists
  1059         if ( IsNumberEntryUsedL() )
  1229         if ( IsNumberEntryUsedL() )
  1060             {
  1230             {
  1061             HBufC* phoneNumber = PhoneNumberFromEntryLC();
  1231             HBufC* phoneNumber = PhoneNumberFromEntryLC();
  1062             // Save the phone number
  1232             // Save the phone number
  1063             __PHONELOG1( EBasic, EPhoneControl, "SetPhoneNumber: %S ", phoneNumber );
  1233             __PHONELOG1( EBasic, EPhoneControl, "SetPhoneNumber: %S ", &phoneNumber->Des() );
  1064             iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
  1234             iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
  1065 
  1235 
  1066             // Convert key code to western.
  1236             // Convert key code to western.
  1067             TBuf<1> buffer; // one character
  1237             TBuf<1> buffer; // one character
  1068             buffer.Append( aKeyEvent.iCode );
  1238             buffer.Append( aKeyEvent.iCode );
  1087         }
  1257         }
  1088     }
  1258     }
  1089 
  1259 
  1090 // <------------------------------ SYSTEM EVENTS ----------------------------->
  1260 // <------------------------------ SYSTEM EVENTS ----------------------------->
  1091 
  1261 
       
  1262 // -----------------------------------------------------------
       
  1263 // CPhoneState::DynInitMenuPaneL
       
  1264 // -----------------------------------------------------------
       
  1265 //
       
  1266 EXPORT_C void CPhoneState::DynInitMenuPaneL(
       
  1267     TInt aResourceId,
       
  1268     CEikMenuPane* aMenuPane )
       
  1269     {
       
  1270     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DynInitMenuPaneL( ) ");
       
  1271     __ASSERT_DEBUG( aMenuPane && aResourceId,
       
  1272         Panic( EPhoneCtrlParameterNotInitialized ) );
       
  1273 
       
  1274     // Save the number of digits in the number entry before processing
       
  1275     // the menu pane
       
  1276     if ( IsNumberEntryUsedL() )
       
  1277         {
       
  1278         TPhoneCmdParamBoolean serviceCodeParam;
       
  1279             serviceCodeParam.SetBoolean(
       
  1280             iStateMachine->PhoneEngineInfo()->PhoneNumberIsServiceCode() );
       
  1281         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetServiceCodeFlag,
       
  1282             &serviceCodeParam );
       
  1283         }
       
  1284 
       
  1285     // Process the menu pane
       
  1286     TPhoneCmdParamDynMenu dynMenuPane;
       
  1287     dynMenuPane.SetResourceId( aResourceId );
       
  1288     dynMenuPane.SetDynMenu( aMenuPane );
       
  1289     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuPane, &dynMenuPane );
       
  1290 
       
  1291     if ( iCustomization )
       
  1292         {
       
  1293         // Menu pane is customized after default items are decided
       
  1294         iCustomization->CustomizeMenuPaneL(aResourceId, aMenuPane);
       
  1295         }
       
  1296     }
       
  1297 
       
  1298 // -----------------------------------------------------------
       
  1299 // CPhoneState::DynInitMenuBarL
       
  1300 // -----------------------------------------------------------
       
  1301 //
       
  1302 EXPORT_C void CPhoneState::DynInitMenuBarL(
       
  1303     TInt aResourceId,
       
  1304     CEikMenuBar* aMenuBar )
       
  1305     {
       
  1306     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DynInitMenuBarL( ) ");
       
  1307     __ASSERT_DEBUG( aMenuBar && aResourceId,
       
  1308         Panic( EPhoneCtrlParameterNotInitialized ) );
       
  1309 
       
  1310     TPhoneCmdParamDynMenu dynMenuBar;
       
  1311     dynMenuBar.SetResourceId( aResourceId );
       
  1312     dynMenuBar.SetDynMenu( aMenuBar );
       
  1313     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBar, &dynMenuBar );
       
  1314 
       
  1315     if ( iCustomization )
       
  1316         {
       
  1317         // Menu bar is customized after default items are decided
       
  1318         iCustomization->CustomizeMenuBarL(aResourceId, aMenuBar);
       
  1319         }
       
  1320 
       
  1321     }
  1092 
  1322 
  1093 // -----------------------------------------------------------
  1323 // -----------------------------------------------------------
  1094 // CPhoneState::HandleSystemEventL
  1324 // CPhoneState::HandleSystemEventL
  1095 // -----------------------------------------------------------
  1325 // -----------------------------------------------------------
  1096 //
  1326 //
  1118 // CPhoneState::HandlePhoneForegroundEventL
  1348 // CPhoneState::HandlePhoneForegroundEventL
  1119 // -----------------------------------------------------------
  1349 // -----------------------------------------------------------
  1120 //
  1350 //
  1121 EXPORT_C void CPhoneState::HandlePhoneForegroundEventL()
  1351 EXPORT_C void CPhoneState::HandlePhoneForegroundEventL()
  1122     {
  1352     {
  1123     }
  1353     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneForegroundEventL( ) ");
       
  1354 
       
  1355     // Force Idle to the foreground if a foreground event is received,
       
  1356     // but Idle is the top application
       
  1357 
       
  1358     const TBool idleIsTopApp = iViewCommandHandle->HandleCommandL(
       
  1359         EPhoneViewIsIdleTopApp ) ==
       
  1360         EPhoneViewResponseSuccess ;
       
  1361 
       
  1362     if ( !IsOnScreenDialerSupported() && idleIsTopApp )
       
  1363         {
       
  1364         TBool activatePhone = CPhonePubSubProxy::Instance()->Value(
       
  1365             KPSUidAiInformation, KActiveIdleState ) == EPSAiNumberEntry;
       
  1366         if ( activatePhone )
       
  1367             {
       
  1368             // Set Phone as the top application
       
  1369             TPhoneCmdParamInteger uidParam;
       
  1370             uidParam.SetInteger( KUidPhoneApplication.iUid );
       
  1371             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
  1372                 &uidParam );
       
  1373             NumberEntryManagerL()->CreateNumberEntryL();
       
  1374             SetNumberEntryVisibilityL(ETrue);
       
  1375             }
       
  1376 
       
  1377         else
       
  1378             {
       
  1379             if ( !iStateMachine->SecurityMode()->IsSecurityMode() )
       
  1380                 {
       
  1381                 __PHONELOG( EBasic, EPhoneControl,
       
  1382                   "CPhoneState::HandlePhoneForegroundEventL - Force Idle to the foreground" );
       
  1383                 // Bring Idle app to the foreground
       
  1384                 iViewCommandHandle->ExecuteCommandL( EPhoneViewBringIdleToForeground );
       
  1385                 }
       
  1386             }
       
  1387         }
       
  1388 
       
  1389     if( NumberEntryManagerL()->IsNumberEntryUsedL() )
       
  1390         {
       
  1391         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIncallBubbleTrue );
       
  1392         }
       
  1393     else
       
  1394         {
       
  1395         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIncallBubbleFalse );
       
  1396         }
       
  1397      }
  1124 
  1398 
  1125 // -----------------------------------------------------------
  1399 // -----------------------------------------------------------
  1126 // CPhoneState::HandlePhoneFocusLostEventL
  1400 // CPhoneState::HandlePhoneFocusLostEventL
  1127 // -----------------------------------------------------------
  1401 // -----------------------------------------------------------
  1128 //
  1402 //
  1130     {
  1404     {
  1131     // Notify that this method is called always when Idle is brought to foreground
  1405     // Notify that this method is called always when Idle is brought to foreground
  1132     // See implementation in CPhoneAppUI::HandleWsEventL
  1406     // See implementation in CPhoneAppUI::HandleWsEventL
  1133 
  1407 
  1134     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneFocusLostEventL( ) ");
  1408     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneFocusLostEventL( ) ");
       
  1409     // Phone app focus lost -> close Dtmf dialer when visible
       
  1410     if ( IsOnScreenDialerSupported() && IsDTMFEditorVisibleL() )
       
  1411         {
       
  1412         CloseDTMFEditorL();
       
  1413         }
       
  1414     else if ( IsOnScreenDialerSupported() && IsCustomizedDialerVisibleL() )
       
  1415         {
       
  1416         CloseCustomizedDialerL();
       
  1417         }
       
  1418 
       
  1419     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIncallBubbleTrue );
  1135     }
  1420     }
  1136 // ---------------------------------------------------------
  1421 // ---------------------------------------------------------
  1137 // CPhoneState::HandleIdleForegroundEventL
  1422 // CPhoneState::HandleIdleForegroundEventL
  1138 // ---------------------------------------------------------
  1423 // ---------------------------------------------------------
  1139 //
  1424 //
  1185             "CPhoneState::HandlePropertyChangedL - aCategory= %d", aCategory  );
  1470             "CPhoneState::HandlePropertyChangedL - aCategory= %d", aCategory  );
  1186     __PHONELOG1( EBasic, EPhoneControl,
  1471     __PHONELOG1( EBasic, EPhoneControl,
  1187             "CPhoneState::HandlePropertyChangedL - aKey= %d", aKey  );
  1472             "CPhoneState::HandlePropertyChangedL - aKey= %d", aKey  );
  1188     __PHONELOG1( EBasic, EPhoneControl,
  1473     __PHONELOG1( EBasic, EPhoneControl,
  1189             "CPhoneState::HandlePropertyChangedL - aValue= %d", aValue  );
  1474             "CPhoneState::HandlePropertyChangedL - aValue= %d", aValue  );
  1190     if ( aCategory == KPSUidTelInformation
  1475     if ( aCategory == KPSUidCtsyCallInformation )
       
  1476         {
       
  1477         // Call state event
       
  1478         if ( aKey == KCTsyCallState )
       
  1479             {
       
  1480             // Update the incall indicator
       
  1481             UpdateIncallIndicatorL( aValue );
       
  1482             }
       
  1483         }
       
  1484 
       
  1485     // Telephony information category
       
  1486     else if ( aCategory == KPSUidTelInformation
  1191               && SimState() == EPESimUsable )
  1487               && SimState() == EPESimUsable )
  1192         {
  1488         {
  1193         // Telephony display event
  1489         // Telephony display event
  1194         if ( aKey == KTelDisplayInfo )
  1490         if ( aKey == KTelDisplayInfo )
  1195             {
  1491             {
  1199             }
  1495             }
  1200         }
  1496         }
  1201     else if ( aCategory == KPSUidStartup && aKey == KStartupSimSecurityStatus )
  1497     else if ( aCategory == KPSUidStartup && aKey == KStartupSimSecurityStatus )
  1202         {
  1498         {
  1203         // Show security note, SIM is not valid.
  1499         // Show security note, SIM is not valid.
  1204         if ( aValue == ESimRejected ||  aValue == ESimUnaccepted )
  1500         if ( aValue == ESimRejected 
       
  1501                 || aValue == ESimUnaccepted 
       
  1502                 || aValue == ESimInvalid )
  1205             {
  1503             {
  1206             __PHONELOG( EBasic, EPhoneControl, "CPhoneStateStartup::HandlePropertyChangedL - SimSecurity status received" );
  1504             __PHONELOG( EBasic, EPhoneControl, "CPhoneStateStartup::HandlePropertyChangedL - SimSecurity status received" );
  1207             StartShowSecurityNoteL();
  1505             StartShowSecurityNoteL();
  1208             }
  1506             }
  1209         }
  1507         }
  1223     {
  1521     {
  1224     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCenRepChangeL( ) ");
  1522     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCenRepChangeL( ) ");
  1225     }
  1523     }
  1226 
  1524 
  1227 // -----------------------------------------------------------
  1525 // -----------------------------------------------------------
  1228 // CPhoneState::NeedToSendToBackgroundL
  1526 // CPhoneState::NeedToReturnToForegroundAppL
  1229 // -----------------------------------------------------------
  1527 // -----------------------------------------------------------
  1230 //
  1528 //
  1231 EXPORT_C TBool CPhoneState::NeedToSendToBackgroundL() const
  1529 EXPORT_C TBool CPhoneState::NeedToReturnToForegroundAppL() const
  1232     {
  1530     {
  1233     return iViewCommandHandle->HandleCommandL(
  1531     return iViewCommandHandle->HandleCommandL(
  1234         EPhoneViewGetNeedToSendToBackgroundStatus ) ==
  1532         EPhoneViewGetNeedToReturnToForegroundAppStatus ) ==
  1235         EPhoneViewResponseSuccess;
  1533         EPhoneViewResponseSuccess;
  1236     }
  1534     }
  1237 
  1535 
  1238 // -----------------------------------------------------------
  1536 // -----------------------------------------------------------
  1239 // CPhoneState::TopAppIsDisplayedL
  1537 // CPhoneState::TopAppIsDisplayedL
  1245     return iViewCommandHandle->HandleCommandL(
  1543     return iViewCommandHandle->HandleCommandL(
  1246         EPhoneViewGetTopApplicationIsDisplayedStatus ) ==
  1544         EPhoneViewGetTopApplicationIsDisplayedStatus ) ==
  1247         EPhoneViewResponseSuccess;
  1545         EPhoneViewResponseSuccess;
  1248     }
  1546     }
  1249 
  1547 
       
  1548 // -----------------------------------------------------------
       
  1549 // CPhoneState::TitlePaneIsVisibleL
       
  1550 // -----------------------------------------------------------
       
  1551 //
       
  1552 TBool CPhoneState::TitlePaneIsVisibleL() const
       
  1553     {
       
  1554     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::TitlePaneIsVisibleL( ) ");
       
  1555     return iViewCommandHandle->HandleCommandL(
       
  1556         EPhoneViewGetTitlePaneIsVisibleStatus ) ==
       
  1557         EPhoneViewResponseSuccess;
       
  1558     }
       
  1559 
  1250 // <---------------------------- MENU AND CBA EVENTS ------------------------->
  1560 // <---------------------------- MENU AND CBA EVENTS ------------------------->
  1251 
  1561 
  1252 EXPORT_C TBool CPhoneState::HandleCommandL( TInt aCommand )
  1562 EXPORT_C TBool CPhoneState::HandleCommandL( TInt aCommand )
  1253     {
  1563     {
  1254     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCommandL( ) ");
  1564     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCommandL( ) ");
  1255     TBool commandStatus = ETrue;
  1565     TBool commandStatus = ETrue;
  1256     switch( aCommand )
  1566     switch( aCommand )
  1257         {
  1567         {
  1258         case EPhoneEmergencyCmdExit:
  1568         case EPhoneEmergencyCmdExit:
  1259             {
       
  1260             }
       
  1261             // this should be bypasses?
  1569             // this should be bypasses?
  1262         case EPhoneDialerCallHandling:
  1570         case EPhoneDialerCallHandling:
  1263         case EPhoneCmdBack:
  1571         case EPhoneCmdBack:
  1264             // Remove number entry from screen
  1572             CloseClearNumberEntryAndLoadEffectL( ECallUiAppear );
  1265             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1266             // Do state-specific behaviour if number entry is cleared
       
  1267             HandleNumberEntryClearedL();
       
  1268             break;
  1573             break;
  1269 
  1574 
  1270         case EPhoneDialerCmdTouchInput:
  1575         case EPhoneDialerCmdTouchInput:
       
  1576             OpenVkbL();
  1271             break;
  1577             break;
  1272 
  1578 
  1273         case EPhoneNumberAcqCmdSendMessage:
  1579         case EPhoneNumberAcqCmdSendMessage:
       
  1580             // Open the mms editor
       
  1581             iViewCommandHandle->ExecuteCommandL(
       
  1582                 EPhoneViewSendMessage );
       
  1583             if ( !IsOnScreenDialerSupported() )
       
  1584                 {
       
  1585                 // Remove number entry from screen
       
  1586                 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1587                 // Do state-specific behaviour if number entry is cleared
       
  1588                 HandleNumberEntryClearedL();
       
  1589                 }
  1274             break;
  1590             break;
  1275 
  1591 
  1276         case EPhoneNumberAcqCmdSave:
  1592         case EPhoneNumberAcqCmdSave:
       
  1593             // Open Create contact
       
  1594             iViewCommandHandle->ExecuteCommandL(
       
  1595                 EPhoneViewAddContact );
  1277             break;
  1596             break;
  1278 
  1597 
  1279         case EPhoneNumberAcqCmdAddToName:
  1598         case EPhoneNumberAcqCmdAddToName:
       
  1599             // Open the message editor
       
  1600             iViewCommandHandle->ExecuteCommandL(
       
  1601                 EPhoneViewUpdateContact );
  1280             break;
  1602             break;
  1281 
  1603 
  1282         case EPhoneNumberAcqCmdAddToContacts:
  1604         case EPhoneNumberAcqCmdAddToContacts:
  1283             {
  1605             {
  1284             if ( IsOnScreenDialerSupported() )
  1606             if ( IsOnScreenDialerSupported() )
  1347                  aCommand == EPhoneInCallCmdBtHandsfree );
  1669                  aCommand == EPhoneInCallCmdBtHandsfree );
  1348             break;
  1670             break;
  1349 
  1671 
  1350         case EPhoneInCallCmdActivatEPhonebook:
  1672         case EPhoneInCallCmdActivatEPhonebook:
  1351             {
  1673             {
  1352             }
  1674             // Launch Phonebook application
  1353             break;
  1675             TPhoneCmdParamAppInfo appInfoParam;
  1354 
  1676             appInfoParam.SetAppUid( KPhoneUidAppPhonebook );
  1355         case EPhoneNumberAcqSecurityDialer:
  1677             iViewCommandHandle->ExecuteCommandL(
  1356             {
  1678                 EPhoneViewActivateApp, &appInfoParam );
  1357 
  1679             }
  1358             }
  1680             break;
  1359             break;
  1681 
  1360 
  1682         case EPhoneViewYesSingleItemFetch:
  1361         case EPhoneDialerCmdContacts:
  1683             {
  1362             {
  1684             if ( IsOnScreenDialerSupported() )
  1363             }
  1685                 {
  1364             break;
  1686                 TBuf<KPhoneNumberEntryBufferSize> fetchContent;
  1365 
  1687                 fetchContent = iViewCommandHandle->FetchContent();
       
  1688                 if ( fetchContent.Length() )
       
  1689                     {
       
  1690                     iViewCommandHandle->ExecuteCommandL(
       
  1691                                             EPhoneViewSetNumberEntryContent,
       
  1692                                             0,
       
  1693                                             fetchContent );
       
  1694 
       
  1695                     CallFromNumberEntryL();
       
  1696                     }
       
  1697                 }
       
  1698             }
       
  1699             break;
  1366         case EPhoneNumberAcqCmdToggleNeAlphaMode:
  1700         case EPhoneNumberAcqCmdToggleNeAlphaMode:
  1367         case EPhoneNumberAcqCmdToggleNeNumericMode:
  1701         case EPhoneNumberAcqCmdToggleNeNumericMode:
  1368             {
  1702             {
  1369 
  1703             // Toggle mode
       
  1704             NumberEntryManagerL()->NumberEntryToggleAlphaNumericModeL();
  1370             }
  1705             }
  1371             break;
  1706             break;
  1372 
  1707 
  1373         case EPhoneCmdYesVideoFailedNoMemorySwitchToVoice:
  1708         case EPhoneCmdYesVideoFailedNoMemorySwitchToVoice:
  1374             DialVoiceCallL();
  1709             DialVoiceCallL();
  1378             if ( IsNumberEntryUsedL() )
  1713             if ( IsNumberEntryUsedL() )
  1379                 {
  1714                 {
  1380                 // Show the number entry if it exists
  1715                 // Show the number entry if it exists
  1381                 SetNumberEntryVisibilityL(ETrue);
  1716                 SetNumberEntryVisibilityL(ETrue);
  1382                 }
  1717                 }
  1383             else if ( NeedToSendToBackgroundL() )
  1718             else if ( NeedToReturnToForegroundAppL() )
  1384                 {
  1719                 {
  1385                 // Continue displaying current app but set up the
  1720                 // Continue displaying current app but set up the
  1386                 // idle screen in the background
  1721                 // idle screen in the background
  1387                 SetupIdleScreenInBackgroundL();
  1722                 SetupIdleScreenInBackgroundL();
  1388                 }
  1723                 }
  1399             // value to control (second parameter set false).
  1734             // value to control (second parameter set false).
  1400             ChangeAudioVolumeL( GetVolumeLevel(), EFalse );
  1735             ChangeAudioVolumeL( GetVolumeLevel(), EFalse );
  1401             }
  1736             }
  1402             break;
  1737             break;
  1403 
  1738 
       
  1739         case EPhoneDialerCmdHelp:
       
  1740             if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
  1741                 {
       
  1742                 TPtrC contextName;
       
  1743                 contextName.Set( KDATA_DIALER_HLP_MAIN() );
       
  1744                 iViewCommandHandle->ExecuteCommandL(
       
  1745                     EPhoneViewLaunchHelpApplication, 0, contextName );
       
  1746                 }
       
  1747             break;
       
  1748 
  1404         case EPhoneCmdVideoCallOutOfMemory:
  1749         case EPhoneCmdVideoCallOutOfMemory:
  1405             ShowVideoCallOutOfMemoryNoteL();
  1750             ShowVideoCallOutOfMemoryNoteL();
  1406             DisconnectCallL();
  1751             DisconnectCallL();
  1407             break;
  1752             break;
  1408             
  1753 
  1409         case EPhoneCallComingCmdSoftReject:
  1754         case EPhoneCmdUpdateCba:
  1410             // Open Soft reject message editor
  1755         case EPhoneDialerValidNumber:
  1411             OpenSoftRejectMessageEditorL();
  1756         case EPhoneDialerInvalidNumber:
  1412             break;
  1757         case EPhoneCmdBlockingDialogLaunched:
  1413             
  1758         case EPhoneCmdBlockingDialogClosed:
  1414         case EPhoneInCallCmdContacts:
  1759             {
  1415             iViewCommandHandle->ExecuteCommand( EPhoneViewOpenContacts );
  1760             // these command ids are sent by easydialing to communicate to phone app
  1416             break;
  1761             HandleEasyDialingCommandsL( aCommand );
  1417             
  1762             }
       
  1763             break;
       
  1764                 
  1418         default:
  1765         default:
  1419 
  1766             if ( IsOnScreenDialerSupported() )
  1420             /*if ( IsOnScreenDialerSupported() )
       
  1421                 {
  1767                 {
  1422                 // Offer command to view.
  1768                 // Offer command to view.
       
  1769                 // Easydialing commands are handled in view, too.
  1423                 TPhoneViewResponseId resId =
  1770                 TPhoneViewResponseId resId =
  1424                             iViewCommandHandle->HandleCommandL( aCommand );
  1771                             iViewCommandHandle->HandleCommandL( aCommand );
  1425 
  1772 
  1426                 if( resId == EPhoneViewResponseFailed )
  1773                 if( resId == EPhoneViewResponseFailed )
  1427                     {
  1774                     {
  1428                     commandStatus = EFalse;
  1775                      commandStatus = EFalse;
  1429                     }
  1776                     }
  1430                 }
  1777                 }
  1431             else*/
  1778             else
  1432 
       
  1433                 {
  1779                 {
  1434                 commandStatus = EFalse;
  1780                 commandStatus = EFalse;
  1435                 }
  1781                 }
  1436             break;
  1782             break;
  1437         }
  1783         }
  1448 // CPhoneState::ProcessCommandL
  1794 // CPhoneState::ProcessCommandL
  1449 // -----------------------------------------------------------------------------
  1795 // -----------------------------------------------------------------------------
  1450 //
  1796 //
  1451 EXPORT_C TBool CPhoneState::ProcessCommandL( TInt /*aCommand*/ )
  1797 EXPORT_C TBool CPhoneState::ProcessCommandL( TInt /*aCommand*/ )
  1452     {
  1798     {
  1453     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::ProcessCommandL() ");
  1799     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::ProcessCommandL() ");
  1454     // no implementation.
  1800     // no implementation.
  1455     return EFalse;
  1801     return EFalse;
  1456     }
  1802     }
  1457 
  1803 
  1458 // <-------------------------- REMOTE CONTROL EVENTS ------------------------->
  1804 // <-------------------------- REMOTE CONTROL EVENTS ------------------------->
  1514 
  1860 
  1515     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
  1861     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
  1516      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::DecreaseAudioVolumeL - audio output =%d", output );
  1862      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::DecreaseAudioVolumeL - audio output =%d", output );
  1517     if( output == EPETTY )
  1863     if( output == EPETTY )
  1518         {
  1864         {
  1519         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl, ETrue );
  1865         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl );
  1520         }
  1866         }
  1521     else
  1867     else
  1522         {
  1868         {
  1523         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
  1869         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
  1524         audioVolume--;
  1870         audioVolume--;
  1538 
  1884 
  1539     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
  1885     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
  1540      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IncreaseAudioVolumeL - audio output =%d", output );
  1886      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IncreaseAudioVolumeL - audio output =%d", output );
  1541     if( output == EPETTY )
  1887     if( output == EPETTY )
  1542         {
  1888         {
  1543         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl, ETrue );
  1889         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl );
  1544         }
  1890         }
  1545     else
  1891     else
  1546         {
  1892         {
  1547         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
  1893         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
  1548         audioVolume++;
  1894         audioVolume++;
  1568         // Syncronizes audio volume level between engine and ui
  1914         // Syncronizes audio volume level between engine and ui
  1569         // causes EPEMessageAudioVolumeChanged message to phoneUI
  1915         // causes EPEMessageAudioVolumeChanged message to phoneUI
  1570         iStateMachine->SendPhoneEngineMessage(
  1916         iStateMachine->SendPhoneEngineMessage(
  1571             MPEPhoneModel::EPEMessageSetAudioVolume );
  1917             MPEPhoneModel::EPEMessageSetAudioVolume );
  1572         }
  1918         }
  1573         
  1919     else
  1574     if ( aUpdateControl )        
  1920         {
       
  1921         CAknKeySoundSystem* keySounds =
       
  1922             static_cast<CAknAppUi*>( EikonEnv()->EikAppUi() )
       
  1923                 ->KeySounds();
       
  1924 
       
  1925         if ( aLevel < KPhoneVolumeMinValue )
       
  1926             {
       
  1927             // Set the volume value to volume control
       
  1928             valueToControl = KPhoneVolumeMinValue;
       
  1929             keySounds->PlaySound( EAvkonSIDVolumeMinTone );
       
  1930             }
       
  1931         else // aLevel > KPhoneVolumeMaxValue
       
  1932             {
       
  1933             // Set the volume value to volume control
       
  1934             valueToControl = KPhoneVolumeMaxValue;
       
  1935             keySounds->PlaySound( EAvkonSIDVolumeMaxTone );
       
  1936             }
       
  1937         }
       
  1938 
       
  1939     if ( aUpdateControl )
  1575         {
  1940         {
  1576         // Update the volume display.
  1941         // Update the volume display.
  1577         // Upper max (11) and under min (-1)
  1942         // Upper max (11) and under min (-1)
  1578         // values are also updated to volume popup.
  1943         // values are also updated to volume popup.
  1579         TPhoneCmdParamInteger volumeParam;
  1944         TPhoneCmdParamInteger volumeParam;
  1606 EXPORT_C void CPhoneState::DialVoiceCallL()
  1971 EXPORT_C void CPhoneState::DialVoiceCallL()
  1607     {
  1972     {
  1608     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialVoiceCallL() ");
  1973     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialVoiceCallL() ");
  1609     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
  1974     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
  1610         Panic( EPhoneCtrlInvariant ) );
  1975         Panic( EPhoneCtrlInvariant ) );
  1611 
       
  1612     // Disable global notes
  1976     // Disable global notes
  1613     TPhoneCmdParamBoolean globalNotifierParam;
  1977     TPhoneCmdParamBoolean globalNotifierParam;
  1614     globalNotifierParam.SetBoolean( ETrue );
  1978     globalNotifierParam.SetBoolean( ETrue );
  1615     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1979     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1616             &globalNotifierParam );
  1980             &globalNotifierParam );
  1617    iStateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeCSVoice );
  1981     iStateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeCSVoice );
  1618     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
  1982     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
  1619     }
  1983     }
  1620 
  1984 
  1621 // -----------------------------------------------------------
  1985 // -----------------------------------------------------------
  1622 // CPhoneState::DisconnectCallL
  1986 // CPhoneState::DisconnectCallL
  1623 // -----------------------------------------------------------
  1987 // -----------------------------------------------------------
  1624 //
  1988 //
  1625 EXPORT_C TBool CPhoneState::DisconnectCallL()
  1989 EXPORT_C void CPhoneState::DisconnectCallL()
  1626     {
  1990     {
  1627     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
  1991     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
  1628     TPhoneCmdParamInteger callIdParam;
  1992     // Fetch active call's id from view
  1629     iViewCommandHandle->ExecuteCommandL( 
  1993     TPhoneCmdParamCallStateData callStateData;
  1630             EPhoneViewGetExpandedBubbleCallId, &callIdParam );
  1994     callStateData.SetCallState( EPEStateConnected );
  1631 
  1995     iViewCommandHandle->HandleCommandL(
  1632     TBool ret = EFalse;
  1996         EPhoneViewGetCallIdByState, &callStateData );
  1633     if( callIdParam.Integer() > KErrNotFound )
  1997 
       
  1998     if( callStateData.CallId() == KErrNotFound )
       
  1999         {
       
  2000         // No connected call, find the hold call
       
  2001         callStateData.SetCallState( EPEStateHeld );
       
  2002         iViewCommandHandle->HandleCommandL(
       
  2003             EPhoneViewGetCallIdByState, &callStateData );
       
  2004 
       
  2005         if( callStateData.CallId() == KErrNotFound )
       
  2006             {
       
  2007             // No hold call, find the dialing call
       
  2008             callStateData.SetCallState( EPEStateDialing );
       
  2009             iViewCommandHandle->HandleCommandL(
       
  2010                 EPhoneViewGetCallIdByState, &callStateData );
       
  2011             }
       
  2012 
       
  2013         if( callStateData.CallId() == KErrNotFound )
       
  2014             {
       
  2015             // No dialing call, find the outgoing call
       
  2016             callStateData.SetCallState( EPEStateConnecting );
       
  2017             iViewCommandHandle->HandleCommandL(
       
  2018                 EPhoneViewGetCallIdByState, &callStateData );
       
  2019             }
       
  2020 
       
  2021         if( callStateData.CallId() == KErrNotFound )
       
  2022             {
       
  2023             // No active call, find the disconnectinging call
       
  2024             callStateData.SetCallState( EPEStateDisconnecting );
       
  2025             iViewCommandHandle->HandleCommandL(
       
  2026                 EPhoneViewGetCallIdByState, &callStateData );
       
  2027             }
       
  2028         }
       
  2029 
       
  2030     if( callStateData.CallId() > KErrNotFound )
  1634         {
  2031         {
  1635         // Release the call
  2032         // Release the call
  1636         iStateMachine->SetCallId( callIdParam.Integer() );
  2033         iStateMachine->SetCallId( callStateData.CallId() );
  1637 
  2034         if( IsVideoCall( callStateData.CallId() ) )
  1638         if( IsVideoCall( callIdParam.Integer() ) )
       
  1639             {
  2035             {
  1640             // Video call can be released only after we get response to VT Shutdown Command
  2036             // Video call can be released only after we get response to VT Shutdown Command
  1641             CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
  2037             CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
  1642                                                                                  KCatPhoneToVideotelCommands,
  2038 			                                                           			 KCatPhoneToVideotelCommands,
  1643                                                                                  EVtCmdReleaseDataport,
  2039 			                                                           			 EVtCmdReleaseDataport,
  1644                                                                        TVersion( KPhoneToVideotelCmdVersionMajor,
  2040                                                                        TVersion( KPhoneToVideotelCmdVersionMajor,
  1645                                                                                  KPhoneToVideotelCmdVersionMinor,
  2041                               	                                                 KPhoneToVideotelCmdVersionMinor,
  1646                                                                                  KPhoneToVideotelCmdVersionBuild ),
  2042                               	                                                 KPhoneToVideotelCmdVersionBuild ),
  1647                                                                        KNullDesC8,
  2043                                                                        KNullDesC8,
  1648                                                                        CPhoneReleaseCommand::NewL( *iStateMachine ) );
  2044                                                                        CPhoneReleaseCommand::NewL( *iStateMachine ) );
  1649             }
  2045             }
  1650         else
  2046         else
  1651             {
  2047             {
  1652             // Release the call
  2048             // Release the call
  1653             iStateMachine->SendPhoneEngineMessage(
  2049             iStateMachine->SendPhoneEngineMessage(
  1654                 MPEPhoneModel::EPEMessageRelease );
  2050                 MPEPhoneModel::EPEMessageRelease );
  1655             }
  2051             }
  1656         ret = ETrue;
       
  1657         }
  2052         }
  1658     else
  2053     else
  1659         {
  2054         {
  1660         __PHONELOG( EOnlyFatal, EPhoneControl,
  2055         __PHONELOG( EOnlyFatal, EPhoneControl,
  1661             "CPhoneState::DisconnectCallL has negative call id!" );
  2056             "CPhoneState::DisconnectCallL has negative call id!" );
  1662         }
  2057         }   
  1663 
  2058    }
  1664     return ret;
       
  1665     }
       
  1666 
  2059 
  1667 // -----------------------------------------------------------
  2060 // -----------------------------------------------------------
  1668 // CPhoneState::DisplayIdleScreenL
  2061 // CPhoneState::DisplayIdleScreenL
  1669 // -----------------------------------------------------------
  2062 // -----------------------------------------------------------
  1670 //
  2063 //
  1693     {
  2086     {
  1694     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetupIdleScreenInBackgroundL( ) ");
  2087     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetupIdleScreenInBackgroundL( ) ");
  1695     // Don't remove reconnect query if it's shown
  2088     // Don't remove reconnect query if it's shown
  1696     if( !CPhoneReconnectQuery::InstanceL()->IsDisplayingQuery() )
  2089     if( !CPhoneReconnectQuery::InstanceL()->IsDisplayingQuery() )
  1697         {
  2090         {
  1698         // Remove dialogs if necessary
       
  1699         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  2091         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  1700         }
  2092         }
  1701     // Return phone to the background
  2093     // Return phone to the background
  1702     iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
  2094     iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
  1703 
  2095     // Set Idle app as the top app to PS key this way we know if need to 
  1704     // Set Idle app as the top app
  2096     // bring idle to fore in next phone acitvation event.
  1705     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIdleTopApplication );
  2097     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIdleTopApplication );
  1706 
       
  1707     // Set Empty CBA
       
  1708     iCbaManager->SetCbaL( EPhoneEmptyCBA );
  2098     iCbaManager->SetCbaL( EPhoneEmptyCBA );
  1709     }
  2099     }
  1710 
  2100 
  1711 // ---------------------------------------------------------
  2101 // ---------------------------------------------------------
  1712 // CPhoneState::CallFromNumberEntryL
  2102 // CPhoneState::CallFromNumberEntryL
  1718     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
  2108     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
  1719         Panic( EPhoneCtrlInvariant ) );
  2109         Panic( EPhoneCtrlInvariant ) );
  1720 
  2110 
  1721     if ( IsOnScreenDialerSupported() )
  2111     if ( IsOnScreenDialerSupported() )
  1722         {
  2112         {
  1723         if ( IsCustomizedDialerVisibleL() )
  2113         if ( IsDTMFEditorVisibleL() ||
       
  2114              IsCustomizedDialerVisibleL() )
  1724             {
  2115             {
  1725             return;
  2116             return;
  1726             }
  2117             }
  1727 
  2118 
  1728         else if( IsNumberEntryUsedL() )
  2119         else if( IsNumberEntryUsedL() )
  1729             {
  2120             {
  1730             // Query on top of dialer
  2121             // Query on top of dialer
  1731             if ( IsAnyQueryActiveL() )
  2122             if ( IsAnyQueryActiveL() )
  1732                 {
  2123                 {
       
  2124                 return;
       
  2125                 }
       
  2126             else if ( IsMenuBarVisibleL() )
       
  2127                 {
       
  2128                 iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
  1733                 return;
  2129                 return;
  1734                 }
  2130                 }
  1735             // Open recent calls list when the number entry is empty
  2131             // Open recent calls list when the number entry is empty
  1736             TPhoneCmdParamInteger numberEntryCountParam;
  2132             TPhoneCmdParamInteger numberEntryCountParam;
  1737             iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
  2133             iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
  1745                 EPhoneDialerCmdLog );
  2141                 EPhoneDialerCmdLog );
  1746                 return;
  2142                 return;
  1747                 }
  2143                 }
  1748             }
  2144             }
  1749         }
  2145         }
  1750 
  2146     
  1751     // Get the number entry contents
  2147     // If easydialing has focus, call should be initiated to focused contact.
  1752     HBufC* phoneNumber = PhoneNumberFromEntryLC();
  2148     if ( IsDialingExtensionInFocusL() )
  1753 
  2149         {
  1754     // Call the number
  2150         iViewCommandHandle->HandleCommandL( EEasyDialingVoiceCall );
  1755     iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
  2151         }
  1756 
  2152     else
  1757     if ( phoneNumber->Des().Length() < KPhoneValidPhoneNumberLength )
  2153         {  
  1758         {
  2154         // Get the number entry contents
  1759         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
  2155         HBufC* phoneNumber = PhoneNumberFromEntryLC();
  1760 
  2156         
  1761         HandleNumberEntryClearedL();
  2157         // Call the number
  1762         }
  2158         iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
  1763 
  2159     
  1764     CleanupStack::PopAndDestroy( phoneNumber );
  2160         if ( phoneNumber->Des().Length() < KPhoneValidPhoneNumberLength )
  1765 
  2161             {
  1766     if ( !iCustomization ||
  2162             CloseClearNumberEntryAndLoadEffectL( ECallUiAppear );
  1767          !iCustomization->HandleCallFromNumberEntryL() )
  2163             }
  1768         {
  2164     
  1769         // Customization didn't handle call. Dial voice call
  2165         CleanupStack::PopAndDestroy( phoneNumber );        
  1770         // as normally
  2166     
  1771         DialVoiceCallL();
  2167         if ( !iCustomization || 
  1772         }
  2168              !iCustomization->HandleCallFromNumberEntryL() )
  1773 
  2169             {
       
  2170             // Customization didn't handle call. Dial voice call
       
  2171             // as normally
       
  2172             DialVoiceCallL();
       
  2173             }
       
  2174         }
       
  2175     
  1774     }
  2176     }
  1775 
  2177 
  1776 // -----------------------------------------------------------
  2178 // -----------------------------------------------------------
  1777 // CPhoneState::DisplayHeaderForCallComingInL
  2179 // CPhoneState::DisplayHeaderForCallComingInL
  1778 // -----------------------------------------------------------
  2180 // -----------------------------------------------------------
  1814 // -----------------------------------------------------------
  2216 // -----------------------------------------------------------
  1815 //
  2217 //
  1816 EXPORT_C void CPhoneState::UpdateSingleActiveCallL( TInt aCallId )
  2218 EXPORT_C void CPhoneState::UpdateSingleActiveCallL( TInt aCallId )
  1817     {
  2219     {
  1818     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateSingleActiveCallL( ) ");
  2220     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateSingleActiveCallL( ) ");
  1819 
       
  1820     // Stop capturing keys
  2221     // Stop capturing keys
  1821     CaptureKeysDuringCallNotificationL( EFalse );
  2222     CaptureKeysDuringCallNotificationL( EFalse );
  1822 
       
  1823     BeginUiUpdateLC();
  2223     BeginUiUpdateLC();
       
  2224 
       
  2225     SetTouchPaneButtonEnabled( EPhoneInCallCmdHold );
  1824 
  2226 
  1825     // Update call state
  2227     // Update call state
  1826     TPhoneCmdParamCallHeaderData callHeaderParam;
  2228     TPhoneCmdParamCallHeaderData callHeaderParam;
  1827     callHeaderParam.SetCallState( EPEStateConnected );
  2229     callHeaderParam.SetCallState( EPEStateConnected );
  1828     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
  2230     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
  1830 
  2232 
  1831     // Update remote info data
  2233     // Update remote info data
  1832     UpdateRemoteInfoDataL( aCallId );
  2234     UpdateRemoteInfoDataL( aCallId );
  1833 
  2235 
  1834     // Create call duration label if enabled
  2236     // Create call duration label if enabled
  1835     // This key will be moved to some other area, but since key
       
  1836     // is supported we can still use it.
       
  1837     TBool callDuration( EFalse );
  2237     TBool callDuration( EFalse );
  1838     CPhoneCenRepProxy::Instance()->GetInt(
  2238     CPhoneCenRepProxy::Instance()->GetInt(
  1839             KCRUidLogs, KLogsShowCallDuration, callDuration );
  2239             KCRUidLogs, KLogsShowCallDuration, callDuration );
  1840 
  2240 
  1841     if ( callDuration )
  2241     if ( callDuration )
  1846     EndUiUpdate();
  2246     EndUiUpdate();
  1847 
  2247 
  1848      // Go to current state implementation
  2248      // Go to current state implementation
  1849     iCbaManager->UpdateInCallCbaL();
  2249     iCbaManager->UpdateInCallCbaL();
  1850 
  2250 
  1851     // Go to background if necessary
  2251     //Update state of switch to video or voice call touch button.
  1852     if ( NeedToSendToBackgroundL() ||  IsAutoLockOn() )
  2252     TPECallType type = iStateMachine->PhoneEngineInfo()->CallType( aCallId );
  1853         {
  2253 
  1854         }
  2254     if( type == EPECallTypeVideo )
  1855     // If there is no need to send back ground and number entry is used then
  2255         {
  1856     // we must show number entry.
  2256         TPhoneCmdParamBoolean booleanParam;
  1857     else if ( !NeedToSendToBackgroundL() && IsNumberEntryUsedL() )
  2257         booleanParam.SetBoolean( ETrue );
  1858         {
  2258         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetVideoCallFlag, &booleanParam );
  1859         SetNumberEntryVisibilityL(ETrue);
  2259         }
       
  2260     else
       
  2261         {
       
  2262         TPhoneCmdParamBoolean booleanParam;
       
  2263         booleanParam.SetBoolean( EFalse );
       
  2264         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetVideoCallFlag, &booleanParam );
       
  2265         }
       
  2266 
       
  2267     // Check if application and number entry was open before incoming call. If so give control to number entry 
       
  2268 	// to prevent flickering
       
  2269     if ( NeedToReturnToForegroundAppL() ||  IsAutoLockOn() )
       
  2270         {
       
  2271         // If number entry is used set control and visibility.
       
  2272         if ( IsNumberEntryUsedL() )
       
  2273            {
       
  2274            iViewCommandHandle->ExecuteCommandL( EPhoneViewSetControlAndVisibility );
       
  2275            }
  1860         }
  2276         }
  1861     }
  2277     }
  1862 
  2278 
  1863 // -----------------------------------------------------------
  2279 // -----------------------------------------------------------
  1864 // CPhoneState::CaptureKeysDuringCallNotificationL
  2280 // CPhoneState::CaptureKeysDuringCallNotificationL
  1865 // -----------------------------------------------------------
  2281 // -----------------------------------------------------------
  1866 //
  2282 //
  1867 EXPORT_C void CPhoneState::CaptureKeysDuringCallNotificationL(
  2283 EXPORT_C void CPhoneState::CaptureKeysDuringCallNotificationL(
  1868     TBool /*aCaptured*/ )
  2284     TBool aCaptured )
  1869     {
  2285     {
  1870     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CaptureKeysDuringCallNotificationL( ) ");
  2286     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CaptureKeysDuringCallNotificationL( ) ");
       
  2287 
       
  2288     if ( AknLayoutUtils::PenEnabled() )
       
  2289         {
       
  2290         //Capture pointer events
       
  2291         TPhoneCmdParamBoolean booleanParam;
       
  2292         booleanParam.SetBoolean( aCaptured );
       
  2293         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetPointerCapture, &booleanParam );
       
  2294         }
       
  2295 
  1871     // Determine which view command to execute based on the capture status
  2296     // Determine which view command to execute based on the capture status
  1872     /*const TInt viewCommandId = aCaptured ?
  2297     const TInt viewCommandId = aCaptured ?
  1873         EPhoneViewStartCapturingKey :
  2298         EPhoneViewStartCapturingKey :
  1874         EPhoneViewStopCapturingKey;
  2299         EPhoneViewStopCapturingKey;
  1875 
  2300 
  1876     // Capture the App key
  2301     // Capture the App key
  1877     TPhoneCmdParamKeyCapture appKeyCaptureParam;
  2302     TPhoneCmdParamKeyCapture appKeyCaptureParam;
  1887         cameraKeyCaptureParam.SetKey( EStdKeyDevice7 );
  2312         cameraKeyCaptureParam.SetKey( EStdKeyDevice7 );
  1888         cameraKeyCaptureParam.SetKeyCode( EKeyDevice7 );
  2313         cameraKeyCaptureParam.SetKeyCode( EKeyDevice7 );
  1889         cameraKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
  2314         cameraKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
  1890         iViewCommandHandle->ExecuteCommandL( viewCommandId,
  2315         iViewCommandHandle->ExecuteCommandL( viewCommandId,
  1891             &cameraKeyCaptureParam );
  2316             &cameraKeyCaptureParam );
  1892         }*/
  2317         }
  1893     }
  2318     }
  1894 
  2319 
  1895 // -----------------------------------------------------------
  2320 // -----------------------------------------------------------
  1896 // CPhoneState::IsWaitingCallL
  2321 // CPhoneState::IsWaitingCallL
  1897 // -----------------------------------------------------------
  2322 // -----------------------------------------------------------
  1922     TPhoneCmdParamCallHeaderData callHeaderParam = UpdateCallHeaderInfoL( aCallId );
  2347     TPhoneCmdParamCallHeaderData callHeaderParam = UpdateCallHeaderInfoL( aCallId );
  1923 
  2348 
  1924     if( iCustomization )
  2349     if( iCustomization )
  1925         {
  2350         {
  1926         TBuf<KCntMaxTextFieldLength> inCallNumberText( KNullDesC );
  2351         TBuf<KCntMaxTextFieldLength> inCallNumberText( KNullDesC );
  1927 
  2352         // incall number text could be 'Call 1', 'Call 2', ...
       
  2353         CallheaderManagerL()->GetInCallNumberTextL( aCallId, inCallNumberText );
  1928         // to check if we have VoIP call in question and fix
  2354         // to check if we have VoIP call in question and fix
  1929         // parameters if needed
  2355         // parameters if needed
  1930         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
  2356         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
  1931             inCallNumberText );
  2357             inCallNumberText );
  1932         }
  2358         }
  1942 // -----------------------------------------------------------
  2368 // -----------------------------------------------------------
  1943 // CPhoneState::SetCallHeaderType
  2369 // CPhoneState::SetCallHeaderType
  1944 // -----------------------------------------------------------
  2370 // -----------------------------------------------------------
  1945 //
  2371 //
  1946 EXPORT_C void CPhoneState::SetCallHeaderType(
  2372 EXPORT_C void CPhoneState::SetCallHeaderType(
  1947     TInt aCallHeaderType )
  2373     const CBubbleManager::TPhoneCallTypeFlags aCallHeaderType )
  1948     {
  2374     {
  1949     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetCallHeaderType() ");
  2375     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetCallHeaderType() ");
  1950     TRAP_IGNORE( CallheaderManagerL()->SetCallHeaderType( aCallHeaderType ) );
  2376     TRAP_IGNORE( CallheaderManagerL()->SetCallHeaderType( aCallHeaderType ) );
  1951     }
  2377     }
  1952 
  2378 
  1983     if ( incomingCall > KErrNotFound )
  2409     if ( incomingCall > KErrNotFound )
  1984         {
  2410         {
  1985        if( activeCallCount.Integer() == ENoActiveCalls )
  2411        if( activeCallCount.Integer() == ENoActiveCalls )
  1986             {
  2412             {
  1987             iCbaManager->UpdateIncomingCbaL( incomingCall );
  2413             iCbaManager->UpdateIncomingCbaL( incomingCall );
       
  2414             UpdateSilenceButtonDimming();
  1988             }
  2415             }
  1989         else
  2416         else
  1990             {
  2417             {
  1991             iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
  2418             iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
  1992             }
  2419             }
  2017         return EFalse;
  2444         return EFalse;
  2018         }
  2445         }
  2019     }
  2446     }
  2020 
  2447 
  2021 // <-------------------------- CONTEXT MENU ------------------------->
  2448 // <-------------------------- CONTEXT MENU ------------------------->
       
  2449 
       
  2450 // -----------------------------------------------------------------------------
       
  2451 // CPhoneState::SetContextMenu
       
  2452 // -----------------------------------------------------------------------------
       
  2453 //
       
  2454 EXPORT_C void CPhoneState::SetContextMenuL( TInt aResourceId )
       
  2455     {
       
  2456     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetContextMenuL() ");
       
  2457 
       
  2458     TPhoneCmdParamInteger integerParam;
       
  2459     TInt resId( CPhoneMainResourceResolver::Instance()->
       
  2460                             ResolveResourceID( aResourceId ) );
       
  2461     integerParam.SetInteger( resId );
       
  2462     __PHONELOG1( EBasic, EPhoneControl,
       
  2463                   "CPhoneState::SetContextMenuL : resId =%d",resId );
       
  2464 
       
  2465     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateContextMenu,
       
  2466                                       &integerParam );
       
  2467     }
       
  2468 // -----------------------------------------------------------------------------
       
  2469 // CPhoneState::UpdateInCallContextMenuL
       
  2470 // -----------------------------------------------------------------------------
       
  2471 //
       
  2472 EXPORT_C void CPhoneState::UpdateInCallContextMenuL()
       
  2473     {
       
  2474     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateInCallContextMenuL() ");
       
  2475 
       
  2476     SetContextMenuL( EPhoneNumberAcqMenubar );
       
  2477 
       
  2478     }
       
  2479 
       
  2480 // -----------------------------------------------------------------------------
       
  2481 // CPhoneState::UpdateIncomingContextMenuL
       
  2482 // -----------------------------------------------------------------------------
       
  2483 //
       
  2484 EXPORT_C void CPhoneState::UpdateIncomingContextMenuL( TInt aCallId )
       
  2485     {
       
  2486     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateIncomingContextMenuL() ");
       
  2487 
       
  2488     if( CPhoneState::IsVideoCall ( aCallId ) )
       
  2489         {
       
  2490         SetContextMenuL( EPhoneIncomingVideoCallMenubar );
       
  2491         }
       
  2492     else
       
  2493         {
       
  2494         SetContextMenuL( EPhoneIncomingCallMenubar );
       
  2495         }
       
  2496 
       
  2497     }
  2022 
  2498 
  2023 // -----------------------------------------------------------
  2499 // -----------------------------------------------------------
  2024 // CPhoneState::ShowNoteL
  2500 // CPhoneState::ShowNoteL
  2025 // -----------------------------------------------------------
  2501 // -----------------------------------------------------------
  2026 //
  2502 //
  2122         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString );
  2598         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString );
  2123 
  2599 
  2124         noteText.Append( timeString );
  2600         noteText.Append( timeString );
  2125 
  2601 
  2126         TPhoneCmdParamGlobalNote globalNoteParam;
  2602         TPhoneCmdParamGlobalNote globalNoteParam;
  2127         globalNoteParam.SetType( EPhoneMessageBoxInformation );
  2603         globalNoteParam.SetType( EAknGlobalInformationNote );
  2128         globalNoteParam.SetText( noteText );
  2604         globalNoteParam.SetText( noteText );
  2129 
  2605         globalNoteParam.SetTone( CAknNoteDialog::ENoTone );
  2130         iViewCommandHandle->ExecuteCommandL(
  2606         iViewCommandHandle->ExecuteCommandL(
  2131             EPhoneViewShowGlobalNote, &globalNoteParam );
  2607             EPhoneViewShowGlobalNote, &globalNoteParam );
  2132         }
  2608         }
  2133     }
  2609     }
  2134 
  2610 
  2135 // ---------------------------------------------------------
  2611 // ---------------------------------------------------------
  2136 // CPhoneState::SendGlobalInfoNoteL
  2612 // CPhoneState::SendGlobalInfoNoteL
  2137 // ---------------------------------------------------------
  2613 // ---------------------------------------------------------
  2138 //
  2614 //
  2139 EXPORT_C void CPhoneState::SendGlobalInfoNoteL( 
  2615 EXPORT_C void CPhoneState::SendGlobalInfoNoteL( TInt aResourceId )
  2140         TInt aResourceId, TBool aNotificationDialog )
       
  2141     {
  2616     {
  2142     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalInfoNoteL( ) ");
  2617     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalInfoNoteL( ) ");
  2143     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2618     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2144     if ( CPhonePubSubProxy::Instance()->Value(
  2619     if ( CPhonePubSubProxy::Instance()->Value(
  2145             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  2620             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  2149         globalNotifierParam.SetBoolean( EFalse );
  2624         globalNotifierParam.SetBoolean( EFalse );
  2150         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2625         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2151             &globalNotifierParam );
  2626             &globalNotifierParam );
  2152 
  2627 
  2153         TPhoneCmdParamGlobalNote globalNoteParam;
  2628         TPhoneCmdParamGlobalNote globalNoteParam;
  2154         PhoneNotificationType type = aNotificationDialog ? 
  2629 
  2155             EPhoneNotificationDialog : EPhoneMessageBoxInformation;
  2630         globalNoteParam.SetType( EAknGlobalInformationNote );
  2156         globalNoteParam.SetType( type );
       
  2157         globalNoteParam.SetTextResourceId(
  2631         globalNoteParam.SetTextResourceId(
  2158             CPhoneMainResourceResolver::Instance()->
  2632             CPhoneMainResourceResolver::Instance()->
  2159             ResolveResourceID( aResourceId ) );
  2633             ResolveResourceID( aResourceId ) );
  2160 
  2634         globalNoteParam.SetTone( EAvkonSIDInformationTone );
  2161         globalNoteParam.SetNotificationDialog( aNotificationDialog );
  2635 
  2162         
       
  2163         iViewCommandHandle->ExecuteCommandL(
  2636         iViewCommandHandle->ExecuteCommandL(
  2164             EPhoneViewShowGlobalNote, &globalNoteParam );
  2637             EPhoneViewShowGlobalNote, &globalNoteParam );
  2165         }
  2638         }
  2166     }
  2639     }
  2167 
  2640 
  2168 // ---------------------------------------------------------
  2641 // ---------------------------------------------------------
  2169 //  CPhoneUIController::SendGlobalWarningNoteL
  2642 //  CPhoneUIController::SendGlobalWarningNoteL
  2170 // ---------------------------------------------------------
  2643 // ---------------------------------------------------------
  2171 //
  2644 //
  2172 EXPORT_C void CPhoneState::SendGlobalWarningNoteL( 
  2645 EXPORT_C void CPhoneState::SendGlobalWarningNoteL( TInt aResourceId )
  2173         TInt aResourceId, TBool aNotificationDialog )
       
  2174     {
  2646     {
  2175     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalWarningNoteL( ) ");
  2647     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalWarningNoteL( ) ");
  2176     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2648     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2177     if ( CPhonePubSubProxy::Instance()->Value(
  2649     if ( CPhonePubSubProxy::Instance()->Value(
  2178             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 ||
  2650             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 ||
  2183         globalNotifierParam.SetBoolean( EFalse );
  2655         globalNotifierParam.SetBoolean( EFalse );
  2184         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2656         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2185             &globalNotifierParam );
  2657             &globalNotifierParam );
  2186 
  2658 
  2187         TPhoneCmdParamGlobalNote globalNoteParam;
  2659         TPhoneCmdParamGlobalNote globalNoteParam;
  2188         PhoneNotificationType type = aNotificationDialog ? 
  2660         globalNoteParam.SetType( EAknGlobalWarningNote );
  2189                     EPhoneNotificationDialog : EPhoneMessageBoxWarning;
       
  2190         globalNoteParam.SetType( type );
       
  2191         globalNoteParam.SetTextResourceId(
  2661         globalNoteParam.SetTextResourceId(
  2192             CPhoneMainResourceResolver::Instance()->
  2662             CPhoneMainResourceResolver::Instance()->
  2193             ResolveResourceID( aResourceId ) );
  2663             ResolveResourceID( aResourceId ) );
  2194   
  2664         globalNoteParam.SetTone( EAvkonSIDWarningTone );
  2195         globalNoteParam.SetNotificationDialog( aNotificationDialog );
  2665 
  2196         
       
  2197         iViewCommandHandle->ExecuteCommandL(
  2666         iViewCommandHandle->ExecuteCommandL(
  2198             EPhoneViewShowGlobalNote, &globalNoteParam );
  2667             EPhoneViewShowGlobalNote, &globalNoteParam );
  2199         }
  2668         }
  2200     }
  2669     }
  2201 
  2670 
  2202 // ---------------------------------------------------------
  2671 // ---------------------------------------------------------
  2203 //  CPhoneUIController::SendGlobalErrorNoteL
  2672 //  CPhoneUIController::SendGlobalErrorNoteL
  2204 // ---------------------------------------------------------
  2673 // ---------------------------------------------------------
  2205 //
  2674 //
  2206 EXPORT_C void CPhoneState::SendGlobalErrorNoteL( 
  2675 EXPORT_C void CPhoneState::SendGlobalErrorNoteL( TInt aResourceId )
  2207         TInt aResourceId, TBool aNotificationDialog )
       
  2208     {
  2676     {
  2209     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalErrorNoteL( ) ");
  2677     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalErrorNoteL( ) ");
  2210     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2678     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2211     if ( CPhonePubSubProxy::Instance()->Value(
  2679     if ( CPhonePubSubProxy::Instance()->Value(
  2212             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  2680             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  2216         globalNotifierParam.SetBoolean( EFalse );
  2684         globalNotifierParam.SetBoolean( EFalse );
  2217         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2685         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2218             &globalNotifierParam );
  2686             &globalNotifierParam );
  2219 
  2687 
  2220         TPhoneCmdParamGlobalNote globalNoteParam;
  2688         TPhoneCmdParamGlobalNote globalNoteParam;
  2221         PhoneNotificationType type = aNotificationDialog ? 
  2689         globalNoteParam.SetType( EAknGlobalErrorNote );
  2222                     EPhoneNotificationDialog : EPhoneMessageBoxInformation;
       
  2223         globalNoteParam.SetType( type );
       
  2224         
       
  2225         globalNoteParam.SetTextResourceId(
  2690         globalNoteParam.SetTextResourceId(
  2226             CPhoneMainResourceResolver::Instance()->
  2691             CPhoneMainResourceResolver::Instance()->
  2227             ResolveResourceID( aResourceId ) );
  2692             ResolveResourceID( aResourceId ) );
  2228         globalNoteParam.SetNotificationDialog( aNotificationDialog );
  2693         globalNoteParam.SetTone( CAknNoteDialog::EErrorTone );
  2229 
  2694 
  2230         iViewCommandHandle->ExecuteCommandL(
  2695         iViewCommandHandle->ExecuteCommandL(
  2231             EPhoneViewShowGlobalNote, &globalNoteParam );
  2696             EPhoneViewShowGlobalNote, &globalNoteParam );
  2232         }
  2697         }
  2233     }
  2698     }
  2241     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetHandsfreeModeL( ) ");
  2706     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetHandsfreeModeL( ) ");
  2242     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
  2707     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
  2243         iViewCommandHandle, iStateMachine, this );
  2708         iViewCommandHandle, iStateMachine, this );
  2244     if ( !bt->SetHandsfreeModeL( aHandsfreeMode ))
  2709     if ( !bt->SetHandsfreeModeL( aHandsfreeMode ))
  2245         {
  2710         {
  2246         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed, ETrue );
  2711         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
  2247         }
  2712         }
  2248     CleanupStack::PopAndDestroy( bt );
  2713     CleanupStack::PopAndDestroy( bt );
  2249     }
  2714     }
  2250 
  2715 
  2251 // ---------------------------------------------------------
  2716 // ---------------------------------------------------------
  2257     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetBTHandsfreeModeL( ) ");
  2722     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetBTHandsfreeModeL( ) ");
  2258     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
  2723     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
  2259         iViewCommandHandle, iStateMachine, this );
  2724         iViewCommandHandle, iStateMachine, this );
  2260     if ( !bt->SetBTHandsfreeModeL( aHandsfreeMode ))
  2725     if ( !bt->SetBTHandsfreeModeL( aHandsfreeMode ))
  2261         {
  2726         {
  2262         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed, ETrue );
  2727         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
  2263         }
  2728         }
  2264     CleanupStack::PopAndDestroy( bt );
  2729     CleanupStack::PopAndDestroy( bt );
  2265     }
  2730     }
  2266 
  2731 
  2267 // <-------------------------- INTERNAL FUNCTIONS ------------------------>
  2732 // <-------------------------- INTERNAL FUNCTIONS ------------------------>
  2268 
  2733 
  2269 // -----------------------------------------------------------
  2734 // -----------------------------------------------------------
       
  2735 // CPhoneState::UpdateIncallIndicatorL
       
  2736 // -----------------------------------------------------------
       
  2737 //
       
  2738 void CPhoneState::UpdateIncallIndicatorL( TInt aCallState )
       
  2739     {
       
  2740     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateIncallIndicatorL( ) ");
       
  2741     TPhoneCmdParamIncallIndicatorData incallIndicatorParam;
       
  2742     // Set the state.
       
  2743     incallIndicatorParam.SetCallState( aCallState );
       
  2744 
       
  2745     if((aCallState == EPSCTsyCallStateUninitialized) || 
       
  2746        (aCallState == EPSCTsyCallStateNone))
       
  2747         {
       
  2748         incallIndicatorParam.SetLittleBubbleVisible( EFalse );
       
  2749         }
       
  2750     else
       
  2751         {
       
  2752         SetLittleBubbleVisibilityL(&incallIndicatorParam);
       
  2753         }
       
  2754     
       
  2755     // Set mode
       
  2756     incallIndicatorParam.SetMode(
       
  2757        CPhonePubSubProxy::Instance()->Value(
       
  2758             KPSUidCtsyCallInformation,
       
  2759             KCTsyCallType ) );
       
  2760             
       
  2761     TInt activeCallId = GetActiveCallIdL();
       
  2762     if ( activeCallId > KErrNone )
       
  2763         {
       
  2764         if ( iStateMachine->PhoneEngineInfo()->CallALSLine( activeCallId )
       
  2765              == CCCECallParameters::ECCELineTypeAux )
       
  2766             {
       
  2767             incallIndicatorParam.SetLine2( ETrue );
       
  2768             }
       
  2769         }
       
  2770 
       
  2771     // Set the mute status
       
  2772     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
       
  2773     incallIndicatorParam.SetMute( audioMute );
       
  2774 
       
  2775     // Set the voice privacy status
       
  2776     if ( activeCallId > KErrNotFound && activeCallId != KConferenceCallId  )
       
  2777         {
       
  2778         incallIndicatorParam.SetCiphering(
       
  2779             iStateMachine->PhoneEngineInfo()->IsSecureCall( activeCallId ) );
       
  2780         }
       
  2781     else
       
  2782         {
       
  2783         incallIndicatorParam.SetCiphering( ETrue );
       
  2784         }
       
  2785 
       
  2786     incallIndicatorParam.SetCipheringIndicatorAllowed(
       
  2787         iStateMachine->PhoneEngineInfo()->SecureSpecified() );
       
  2788 
       
  2789     // Set the emergency status
       
  2790     if( EPEStateIdle != iStateMachine->PhoneEngineInfo()->CallState( KPEEmergencyCallId ) )
       
  2791         {
       
  2792         incallIndicatorParam.SetEmergency( ETrue );
       
  2793         }
       
  2794     
       
  2795     // Update the in-call indicator
       
  2796     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateIncallIndicator,
       
  2797         &incallIndicatorParam );
       
  2798     }
       
  2799 
       
  2800 // -----------------------------------------------------------
  2270 // CPhoneState::UpdateProfileDisplayL
  2801 // CPhoneState::UpdateProfileDisplayL
  2271 // -----------------------------------------------------------
  2802 // -----------------------------------------------------------
  2272 //
  2803 //
  2273 void CPhoneState::UpdateProfileDisplayL()
  2804 void CPhoneState::UpdateProfileDisplayL()
  2274     {
  2805     {
  2275     }
  2806     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateProfileDisplayL( ) ");
  2276 
  2807     // Get the profile information
       
  2808     const TInt profileId =
       
  2809         iStateMachine->PhoneEngineInfo()->ProfileId();
       
  2810     TPEProfileName profileName =
       
  2811         iStateMachine->PhoneEngineInfo()->ProfileName();
       
  2812 
       
  2813     HBufC* profileString = HBufC::NewLC( profileName.Length() +
       
  2814         KPhoneMaxDateDisplayTextLength );
       
  2815 
       
  2816     TPtr profileNameBuf = profileString->Des();
       
  2817     profileNameBuf.Zero();
       
  2818     profileNameBuf.Append( profileName );
       
  2819 
       
  2820     if ( ( profileId == EProfileGeneralId ) ||
       
  2821         ( profileId == EProfileOffLineId ) )
       
  2822         {
       
  2823         // Show date instead of profile name on navi pane
       
  2824         HBufC* buffer = HBufC::NewLC( KPhoneMaxDateDisplayTextLength );
       
  2825         TPtr dateString( buffer->Des() );
       
  2826 
       
  2827         TTime time;
       
  2828         time.HomeTime();
       
  2829 
       
  2830         // Get date string
       
  2831         CCoeEnv* coeEnv = CCoeEnv::Static();
       
  2832 
       
  2833         HBufC* dateFormatString =
       
  2834             StringLoader::LoadLC( R_QTN_DATE_USUAL_WITH_ZERO, coeEnv );
       
  2835         time.FormatL( dateString, *dateFormatString );
       
  2836         CleanupStack::PopAndDestroy( dateFormatString );
       
  2837 
       
  2838         // To arabic
       
  2839         AknTextUtils::DisplayTextLanguageSpecificNumberConversion(
       
  2840             dateString );
       
  2841 
       
  2842         //Get week day abbreviation
       
  2843         TDayNameAbb wkDayAbb = TDayNameAbb();
       
  2844         wkDayAbb.Set(time.DayNoInWeek());
       
  2845 
       
  2846         //Get time format string
       
  2847         HBufC* timeFormat = StringLoader::LoadLC(
       
  2848             CPhoneMainResourceResolver::Instance()->
       
  2849                 ResolveResourceID( EPhoneIdleTimeFormat ),
       
  2850             coeEnv );
       
  2851 
       
  2852         //Set date and weekdays to time format
       
  2853         profileNameBuf.Zero();
       
  2854 
       
  2855         StringLoader::Format(
       
  2856             profileNameBuf,
       
  2857             *timeFormat,
       
  2858             1, // date
       
  2859             dateString );
       
  2860 
       
  2861         dateString.Copy( profileNameBuf );
       
  2862 
       
  2863         StringLoader::Format(
       
  2864             profileNameBuf,
       
  2865             dateString,
       
  2866             0, // weekday
       
  2867             wkDayAbb );
       
  2868 
       
  2869         CleanupStack::PopAndDestroy( timeFormat );
       
  2870         CleanupStack::PopAndDestroy( buffer );
       
  2871         }
       
  2872 
       
  2873     // Set silence indicator based on the ringing profile
       
  2874     const TProfileRingingType ringingType =
       
  2875         iStateMachine->PhoneEngineInfo()->RingingType();
       
  2876     if ( ringingType == EProfileRingingTypeSilent )
       
  2877         {
       
  2878         TBuf< 1 > silent;
       
  2879         silent.Append( KPuaCodeSilentSymbol );
       
  2880         profileNameBuf.Insert( 0, silent );
       
  2881         }
       
  2882 
       
  2883     // Update the profile display on the navi pane
       
  2884     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetNaviPaneContent, 0,
       
  2885         profileNameBuf );
       
  2886 
       
  2887     if ( profileId == EProfileOffLineId )
       
  2888         {
       
  2889         iViewCommandHandle->ExecuteCommandL(
       
  2890             EPhoneViewSetTitlePaneContent,
       
  2891             0,
       
  2892             profileName );
       
  2893         }
       
  2894     else
       
  2895         {
       
  2896         UpdateOperatorDisplayL();
       
  2897         }
       
  2898 
       
  2899     CleanupStack::PopAndDestroy( profileString );
       
  2900     }
       
  2901 
       
  2902 // -----------------------------------------------------------
       
  2903 // CPhoneState::UpdateOperatorDisplayL
       
  2904 // -----------------------------------------------------------
       
  2905 //
       
  2906 void CPhoneState::UpdateOperatorDisplayL()
       
  2907     {
       
  2908     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateOperatorDisplayL( ) ");
       
  2909     __PHONELOG( EBasic, EPhoneControl, "CPhoneState::UpdateOperatorDisplayL" );
       
  2910     // Get current title pane content.
       
  2911     TTelTitleDisplay titleContent;
       
  2912     titleContent.iDisplayTag.Zero();
       
  2913     titleContent.iLogoHandle = 0;
       
  2914     TPckg<TTelTitleDisplay> titlePckg( titleContent );
       
  2915 
       
  2916     RProperty::Get(
       
  2917         KPSUidTelInformation,
       
  2918         KTelDisplayInfo,
       
  2919         titlePckg );
       
  2920 
       
  2921     if ( TitlePaneIsVisibleL() )
       
  2922         {
       
  2923         // There is a title pane icon.
       
  2924         if ( titleContent.iLogoHandle != 0 )
       
  2925             {
       
  2926             // Set new logo.
       
  2927             __PHONELOG( EBasic, EPhoneControl,
       
  2928                 "CPhoneState::UpdateOperatorDisplayL - logo found" );
       
  2929 
       
  2930             if( iLogoHandle != titleContent.iLogoHandle )
       
  2931                 {
       
  2932                  __PHONELOG( EBasic, EPhoneControl,
       
  2933                   "CPhoneState::UpdateOperatorDisplayL - set new logo" );
       
  2934 
       
  2935                  TPhoneCmdParamBitmap bitmapParam;
       
  2936 
       
  2937                  // Duplicate bitmap from handle.
       
  2938                  CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
  2939                  CleanupStack::PushL( bitmap );
       
  2940                  User::LeaveIfError(
       
  2941                          bitmap->Duplicate( titleContent.iLogoHandle ) );
       
  2942                  bitmapParam.SetBitmap( bitmap );
       
  2943 
       
  2944                  // Duplicate and set bitmap mask if needed
       
  2945                  CFbsBitmap* maskBitmap = NULL;
       
  2946                  if( titleContent.iLogoMaskHandle != 0 )
       
  2947                      {
       
  2948                      maskBitmap = new( ELeave )CFbsBitmap;
       
  2949                      CleanupStack::PushL( maskBitmap );
       
  2950                      User::LeaveIfError( maskBitmap->Duplicate(
       
  2951                              titleContent.iLogoMaskHandle ) );
       
  2952                      bitmapParam.SetMaskBitmap( maskBitmap );
       
  2953                      }
       
  2954 
       
  2955                  iViewCommandHandle->ExecuteCommandL(
       
  2956                          EPhoneViewSetTitlePanePicture,
       
  2957                          &bitmapParam );
       
  2958 
       
  2959                  // The title pane takes ownership of the bitmaps so no need
       
  2960                  // to destroy it here.
       
  2961                  if( maskBitmap )
       
  2962                      {
       
  2963                      // Pop maskBitmap only, if it has been created
       
  2964                      CleanupStack::Pop( maskBitmap );
       
  2965                      }
       
  2966                  CleanupStack::Pop( bitmap );
       
  2967                 }
       
  2968             }
       
  2969         else
       
  2970             {
       
  2971             __PHONELOG1( EBasic, EPhoneControl,
       
  2972             "CPhoneState::UpdateOperatorDisplayL - set text=%S", &titleContent.iDisplayTag );
       
  2973             iLogoHandle = titleContent.iLogoHandle;
       
  2974 
       
  2975             iViewCommandHandle->ExecuteCommandL(
       
  2976                 EPhoneViewSetTitlePaneContent,
       
  2977                 0,
       
  2978                 titleContent.iDisplayTag );
       
  2979             }
       
  2980         }
       
  2981 
       
  2982     // Check background image.
       
  2983     TPhoneCmdParamBitmap savedBitmapParam;
       
  2984     iViewCommandHandle->ExecuteCommandL(
       
  2985         EPhoneViewGetBackgroundImageBitmap,
       
  2986         &savedBitmapParam );
       
  2987 
       
  2988     if ( titleContent.iBackgroundImageHandle !=
       
  2989         savedBitmapParam.Bitmap()->Handle() )
       
  2990         {
       
  2991         __PHONELOG2( EBasic, EPhoneControl,
       
  2992         "CPhoneState::UpdateOperatorDisplayL - update background image since different titleContent(%d), saved(%d)",
       
  2993             titleContent.iBackgroundImageHandle, savedBitmapParam.Bitmap()->Handle() );
       
  2994         // Background image has changed. Duplicate bitmap from handle if
       
  2995         // available; otherwise reset the background image
       
  2996         CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
  2997         CleanupStack::PushL( bitmap );
       
  2998         TInt err = KErrNone;
       
  2999         if ( titleContent.iBackgroundImageHandle != 0 )
       
  3000             {
       
  3001             err = bitmap->Duplicate( titleContent.iBackgroundImageHandle );
       
  3002             }
       
  3003         else
       
  3004             {
       
  3005             bitmap->Reset();
       
  3006             }
       
  3007 
       
  3008         if ( err == KErrNone )
       
  3009             {
       
  3010             iBitmapRedrawCounter = titleContent.iBackgroundImageRedrawCounter;
       
  3011             TPhoneCmdParamBitmap bitmapParam;
       
  3012             bitmapParam.SetBitmap( bitmap );
       
  3013             iViewCommandHandle->ExecuteCommandL(
       
  3014                 EPhoneViewSetBackgroundImageBitmap,
       
  3015                 &bitmapParam );
       
  3016             }
       
  3017 
       
  3018         CleanupStack::PopAndDestroy( bitmap );
       
  3019         }
       
  3020     else if ( titleContent.iBackgroundImageRedrawCounter !=
       
  3021                   iBitmapRedrawCounter  )
       
  3022         {
       
  3023         iBitmapRedrawCounter = titleContent.iBackgroundImageRedrawCounter;
       
  3024         iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateView );
       
  3025         }
       
  3026     }
  2277 
  3027 
  2278 // -----------------------------------------------------------
  3028 // -----------------------------------------------------------
  2279 // CPhoneState::HandleInitiatedEmergencyCallL
  3029 // CPhoneState::HandleInitiatedEmergencyCallL
  2280 // Default handling for EPEMessageInitiatedEmergencyCallL message
  3030 // Default handling for EPEMessageInitiatedEmergencyCallL message
  2281 // (other items were commented in a header).
  3031 // (other items were commented in a header).
  2293     // Reset Hold flag to view
  3043     // Reset Hold flag to view
  2294     TPhoneCmdParamBoolean holdFlag;
  3044     TPhoneCmdParamBoolean holdFlag;
  2295     holdFlag.SetBoolean( EFalse );
  3045     holdFlag.SetBoolean( EFalse );
  2296     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
  3046     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
  2297 
  3047 
       
  3048     // Undim Answer button for sure.
       
  3049     SetTouchPaneButtonEnabled( EPhoneCallComingCmdAnswer );
       
  3050 
  2298     // Go to emergency call state
  3051     // Go to emergency call state
  2299     // No need update cba
  3052     // No need update cba
  2300     iStateMachine->ChangeState( EPhoneStateEmergency );
  3053     iStateMachine->ChangeState( EPhoneStateEmergency );
  2301     }
  3054     }
  2302 
  3055 
  2308     {
  3061     {
  2309     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleInitiatedEmergencyWhileActiveVideoL( ) ");
  3062     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleInitiatedEmergencyWhileActiveVideoL( ) ");
  2310 
  3063 
  2311     // We have existing video call so need to release dataport before continuing
  3064     // We have existing video call so need to release dataport before continuing
  2312     // emergency call. Otherwise we will face problems with dataport use later.
  3065     // emergency call. Otherwise we will face problems with dataport use later.
  2313     CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
  3066     CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( 
  2314                                                                      KCatPhoneToVideotelCommands,
  3067             KMediatorVideoTelephonyDomain,
  2315                                                                      EVtCmdReleaseDataport,
  3068             KCatPhoneToVideotelCommands,
  2316                                                                TVersion( KPhoneToVideotelCmdVersionMajor,
  3069             EVtCmdReleaseDataport,
  2317                                                                          KPhoneToVideotelCmdVersionMinor,
  3070             TVersion( KPhoneToVideotelCmdVersionMajor,
  2318                                                                          KPhoneToVideotelCmdVersionBuild ),
  3071                     KPhoneToVideotelCmdVersionMinor,
  2319                                                                KNullDesC8,
  3072                     KPhoneToVideotelCmdVersionBuild ),
  2320                                                                CPhoneContinueEmergencyCallCommand::NewL( *iStateMachine ) );
  3073             KNullDesC8,
       
  3074             CPhoneContinueEmergencyCallCommand::NewL( *iStateMachine ) );
       
  3075     }
       
  3076 
       
  3077 // -----------------------------------------------------------
       
  3078 // CPhoneState::HandleShowImeiL
       
  3079 // -----------------------------------------------------------
       
  3080 //
       
  3081 void CPhoneState::HandleShowImeiL()
       
  3082     {
       
  3083     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleShowImeiL( ) ");
       
  3084 
       
  3085     if ( IsOnScreenDialerSupported() )
       
  3086         {
       
  3087         NumberEntryClearL();
       
  3088         }
       
  3089     else
       
  3090         {
       
  3091         // Remove number entry from screen
       
  3092         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  3093         }
       
  3094 
       
  3095     // Fetch IMEI
       
  3096     TBuf<RMobilePhone::KPhoneSerialNumberSize> serialNumber;
       
  3097     TPEPhoneIdentityParameters phoneIdentityParameters = iStateMachine->
       
  3098         PhoneEngineInfo()->PhoneIdentityParameters();
       
  3099     serialNumber = phoneIdentityParameters.iSerialNumber;
       
  3100 
       
  3101     // Add it to the resource string
       
  3102     HBufC* buf = StringLoader::LoadLC(
       
  3103         CPhoneMainResourceResolver::Instance()->
       
  3104         ResolveResourceID(
       
  3105         EPhonePhoneImeiString ), serialNumber );
       
  3106 
       
  3107     TPhoneCmdParamNote noteParam;
       
  3108     noteParam.SetType( EPhoneNoteCustom );
       
  3109     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
  3110         ResolveResourceID( EPhoneInformationWaitNote ) );
       
  3111     noteParam.SetText( *buf );
       
  3112 
       
  3113     // Display note
       
  3114     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
  3115 
       
  3116     CleanupStack::PopAndDestroy( buf );
  2321     }
  3117     }
  2322 
  3118 
  2323 // -----------------------------------------------------------
  3119 // -----------------------------------------------------------
  2324 // CPhoneState::HandleCallSecureStatusChangeL
  3120 // CPhoneState::HandleCallSecureStatusChangeL
  2325 // -----------------------------------------------------------
  3121 // -----------------------------------------------------------
  2344 
  3140 
  2345     iViewCommandHandle->ExecuteCommandL(
  3141     iViewCommandHandle->ExecuteCommandL(
  2346         EPhoneViewCipheringInfoChange,
  3142         EPhoneViewCipheringInfoChange,
  2347         aCallId,
  3143         aCallId,
  2348         &callHeaderParam );
  3144         &callHeaderParam );
       
  3145     }
       
  3146 
       
  3147 // -----------------------------------------------------------
       
  3148 // CPhoneState::HandleShowLifeTimerL
       
  3149 // -----------------------------------------------------------
       
  3150 //
       
  3151 void CPhoneState::HandleShowLifeTimerL()
       
  3152    {
       
  3153     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleShowLifeTimerL( ) ");
       
  3154     if ( IsOnScreenDialerSupported() )
       
  3155         {
       
  3156         NumberEntryClearL();
       
  3157         }
       
  3158     else
       
  3159         {
       
  3160         // Remove number entry from screen
       
  3161         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  3162         }
       
  3163 
       
  3164     // Fetch LifeTime
       
  3165     TPELifeTimeData lifeTimeData = iStateMachine->
       
  3166         PhoneEngineInfo()->LifeTimerData();
       
  3167 
       
  3168     TLocale locale;
       
  3169     TBuf<KTimerTextLength> lifetimerText;
       
  3170     lifetimerText.NumFixedWidth(
       
  3171         lifeTimeData.iHours,
       
  3172         EDecimal,
       
  3173         KPhoneLifeTimerHoursLength );
       
  3174 
       
  3175     lifetimerText.Append(locale.TimeSeparator( KTimerMinuteSeparator ) );   // minute seperator
       
  3176 
       
  3177     TBuf<KPhoneLifeTimerMinutesLength> mins;
       
  3178     mins.NumFixedWidth(
       
  3179         lifeTimeData.iMinutes,
       
  3180         EDecimal,
       
  3181         KPhoneLifeTimerMinutesLength );
       
  3182 
       
  3183     lifetimerText.Append(mins);
       
  3184 
       
  3185     // Add it to the resource string
       
  3186     HBufC* buf = StringLoader::LoadLC(
       
  3187         CPhoneMainResourceResolver::Instance()->
       
  3188         ResolveResourceID(
       
  3189         EPhoneLifeTimeFormat ), lifetimerText );
       
  3190     TPhoneCmdParamNote noteParam;
       
  3191     noteParam.SetType( EPhoneNoteCustom );
       
  3192     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
  3193         ResolveResourceID( EPhoneInformationWaitNote ) );
       
  3194     noteParam.SetText( *buf );
       
  3195 
       
  3196     // Display note
       
  3197     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
  3198 
       
  3199     CleanupStack::PopAndDestroy( buf );
  2349     }
  3200     }
  2350 
  3201 
  2351 // ---------------------------------------------------------
  3202 // ---------------------------------------------------------
  2352 // CPhoneState::IsVideoCall
  3203 // CPhoneState::IsVideoCall
  2353 // ---------------------------------------------------------
  3204 // ---------------------------------------------------------
  2493         // Sim state is valid, check also Sim security status
  3344         // Sim state is valid, check also Sim security status
  2494         switch ( SimSecurityStatus() )
  3345         switch ( SimSecurityStatus() )
  2495             {
  3346             {
  2496             case ESimRejected:
  3347             case ESimRejected:
  2497             case ESimUnaccepted:
  3348             case ESimUnaccepted:
       
  3349             case ESimInvalid:
  2498                 retVal = EFalse;
  3350                 retVal = EFalse;
  2499                 break;
  3351                 break;
  2500 
  3352 
  2501             default:
  3353             default:
  2502                 break;
  3354                 break;
  2511 // CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled
  3363 // CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled
  2512 // -----------------------------------------------------------
  3364 // -----------------------------------------------------------
  2513 //
  3365 //
  2514 EXPORT_C TBool CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled()
  3366 EXPORT_C TBool CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled()
  2515     {
  3367     {
  2516     TPhoneCmdParamBoolean isSecurityMode;
  3368     if ( SimState() == EPESimNotPresent && iStateMachine->SecurityMode()->IsSecurityMode() )
  2517     TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode ) );
       
  2518     if ( SimState() == EPESimNotPresent && isSecurityMode.Boolean() )
       
  2519         {
  3369         {
  2520         return ETrue;
  3370         return ETrue;
  2521         }
  3371         }
  2522     else
  3372     else
  2523         {
  3373         {
  2524         return EFalse;
  3374         return EFalse;
  2525         }
  3375         }
  2526     }
       
  2527 
       
  2528 // ---------------------------------------------------------
       
  2529 // CPhoneState::SetDivertIndication
       
  2530 // ---------------------------------------------------------
       
  2531 //
       
  2532 EXPORT_C void CPhoneState::SetDivertIndication( const TBool aDivertIndication )
       
  2533     {
       
  2534     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetDivertIndication()");
       
  2535     TRAP_IGNORE( CallheaderManagerL()->SetDivertIndication( aDivertIndication ) );
       
  2536     }
  3376     }
  2537 
  3377 
  2538 // ---------------------------------------------------------
  3378 // ---------------------------------------------------------
  2539 // CPhoneState::StartAlsLineChangeTimerL
  3379 // CPhoneState::StartAlsLineChangeTimerL
  2540 // ---------------------------------------------------------
  3380 // ---------------------------------------------------------
  2568 //
  3408 //
  2569 EXPORT_C void CPhoneState::StartShowSecurityNoteL()
  3409 EXPORT_C void CPhoneState::StartShowSecurityNoteL()
  2570     {
  3410     {
  2571     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::StartShowSecurityNoteL ");
  3411     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::StartShowSecurityNoteL ");
  2572 
  3412 
  2573     // Set security mode on.
       
  2574     TPhoneCmdParamBoolean securityMode;
       
  2575     securityMode.SetBoolean( ETrue );
       
  2576     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSecurityMode, &securityMode );
       
  2577 
       
  2578     // Remove number entry from screen
  3413     // Remove number entry from screen
  2579     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
  3414     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  3415 
       
  3416     TPhoneCmdParamBoolean visibleMode;
       
  3417     visibleMode.SetBoolean( EFalse );
       
  3418     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetStatusPaneVisible, &visibleMode );
  2580     
  3419     
  2581     iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
  3420     iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
  2582 
  3421 
  2583     TPhoneCmdParamInteger uidParam;
  3422     TPhoneCmdParamInteger uidParam;
  2584     // Bring Phone app in the foreground
  3423     // Bring Phone app in the foreground
  2590     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
  3429     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
  2591         &uidParam );
  3430         &uidParam );
  2592 
  3431 
  2593     TInt resourceId ( KErrNone );
  3432     TInt resourceId ( KErrNone );
  2594 
  3433 
  2595     if ( SimSecurityStatus() == ESimRejected )
  3434 
  2596         {
  3435     switch( SimSecurityStatus() )
  2597         resourceId = CPhoneMainResourceResolver::Instance()->
  3436         {
  2598             ResolveResourceID( EPhoneSimRejected );
  3437 			  case ESimRejected:
  2599         }
  3438 			      {
  2600     else if ( SimState() == EPESimNotPresent )
  3439 			      resourceId = CPhoneMainResourceResolver::Instance()->
  2601         {
  3440               ResolveResourceID( EPhoneSimRejected );
  2602         // insert sim card -note
  3441             break;
  2603         resourceId = CPhoneMainResourceResolver::Instance()->
  3442 			      }
  2604             ResolveResourceID( EPhoneSimRemoved );
  3443 			  case ESimUnaccepted:
  2605         }
  3444 			      {
  2606     else if ( SimSecurityStatus() == ESimUnaccepted )
  3445 			      // insert sim card -note
  2607         {
  3446             resourceId = CPhoneMainResourceResolver::Instance()->
  2608         resourceId = CPhoneMainResourceResolver::Instance()->
  3447               ResolveResourceID( EPhoneSimUnaccepted );	
  2609             ResolveResourceID( EPhoneSimUnaccepted );
  3448 			      break;
       
  3449 			      }
       
  3450 			  case ESimInvalid:
       
  3451 			      {
       
  3452 			      resourceId = CPhoneMainResourceResolver::Instance()->
       
  3453               ResolveResourceID( EPhoneSIMInvalidUICC );
       
  3454 			      break;
       
  3455 			      }
       
  3456         default:
       
  3457 	          {
       
  3458 	          if ( SimState() == EPESimNotPresent )
       
  3459                 {
       
  3460                 // insert sim card -note
       
  3461                 resourceId = CPhoneMainResourceResolver::Instance()->
       
  3462                     ResolveResourceID( EPhoneSimRemoved );
       
  3463                 }
       
  3464 	          break;	
       
  3465 	          }
  2610         }
  3466         }
  2611 
  3467 
  2612     if ( resourceId != KErrNone )
  3468     if ( resourceId != KErrNone )
  2613         {
  3469         {
  2614         // Add it to the resource string
  3470         // Add it to the resource string
  2820         {
  3676         {
  2821         // Get customized text resource for busy note
  3677         // Get customized text resource for busy note
  2822         resource = iCustomization->CustomizeBusyNoteText();
  3678         resource = iCustomization->CustomizeBusyNoteText();
  2823         }
  3679         }
  2824 
  3680 
  2825     // Show number busy notification
  3681     // Show number busy note
  2826     TPhoneCmdParamGlobalNote globalNoteParam;
  3682     TPhoneCmdParamGlobalNote globalNoteParam;
  2827     globalNoteParam.SetType( EPhoneNotificationDialog );
  3683     globalNoteParam.SetType( EAknGlobalInformationNote );
  2828     globalNoteParam.SetTextResourceId(
  3684     globalNoteParam.SetTextResourceId(
  2829         CPhoneMainResourceResolver::Instance()->
  3685         CPhoneMainResourceResolver::Instance()->
  2830         ResolveResourceID( resource ) );
  3686         ResolveResourceID( resource ) );
  2831     
  3687     globalNoteParam.SetTone( EAvkonSIDInformationTone );
  2832     globalNoteParam.SetNotificationDialog( ETrue );
       
  2833     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowGlobalNote,
  3688     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowGlobalNote,
  2834         &globalNoteParam );
  3689         &globalNoteParam );
  2835     }
  3690     }
  2836 
  3691 
  2837 // ---------------------------------------------------------
  3692 // ---------------------------------------------------------
  2844     const TBool phoneIsLocked =
  3699     const TBool phoneIsLocked =
  2845                 CPhonePubSubProxy::Instance()->Value(
  3700                 CPhonePubSubProxy::Instance()->Value(
  2846                 KPSUidCoreApplicationUIs,
  3701                 KPSUidCoreApplicationUIs,
  2847                 KCoreAppUIsAutolockStatus ) > EAutolockOff;
  3702                 KCoreAppUIsAutolockStatus ) > EAutolockOff;
  2848 
  3703 
  2849     __PHONELOG1( EBasic,
       
  2850             EPhoneControl,
       
  2851             "CPhoneState::IsAutoLockOn() Status: %d",
       
  2852             phoneIsLocked );
       
  2853     
       
  2854     return phoneIsLocked;
  3704     return phoneIsLocked;
  2855     }
  3705     }
  2856 
  3706 
  2857 // ---------------------------------------------------------
  3707 // ---------------------------------------------------------
  2858 // CPhoneState::IsKeyLockOn
  3708 // CPhoneState::IsKeyLockOn
  2889 
  3739 
  2890 // ---------------------------------------------------------
  3740 // ---------------------------------------------------------
  2891 // CPhoneState::SetTouchPaneButtons
  3741 // CPhoneState::SetTouchPaneButtons
  2892 // ---------------------------------------------------------
  3742 // ---------------------------------------------------------
  2893 //
  3743 //
  2894 EXPORT_C void CPhoneState::SetTouchPaneButtons( TInt /*aResourceId*/ )
  3744 EXPORT_C void CPhoneState::SetTouchPaneButtons( TInt aResourceId )
  2895     {
  3745     {
  2896     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3746     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  2897         {
  3747         {
  2898         TPhoneCmdParamBoolean muteParam;
  3748         // Display Video Share button instead of Hold Button if
  2899         muteParam.SetBoolean( iStateMachine->PhoneEngineInfo()->AudioMute() );
  3749         // the feature is enabled and video sharing is currently available.
  2900         iViewCommandHandle->ExecuteCommand(EPhoneViewSetMuteFlag,&muteParam);
  3750         if ( aResourceId == EPhoneIncallButtons &&
  2901         
  3751              FeatureManager::FeatureSupported( KFeatureIdFfEntryPointForVideoShare ) &&
  2902         const TPEAudioOutput audioOutput =
  3752              CPhonePubSubProxy::Instance()->Value
  2903             iStateMachine->PhoneEngineInfo()->AudioOutput();
  3753                 ( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator )
  2904 
  3754                 == ECoreAppUIsVideoSharingIndicatorOn )
  2905         TBool btAvailable = iStateMachine->PhoneEngineInfo()->AudioOutputAvailable(
  3755             {
  2906             EPEBTAudioAccessory );
  3756             aResourceId = EPhoneIncallVideoShareButtons;
  2907         
  3757             }
  2908         TPhoneCmdParamBoolean btParam;
  3758         TPhoneCmdParamInteger integerParam;
  2909         btParam.SetBoolean( audioOutput == EPEBTAudioAccessory );        
  3759         integerParam.SetInteger( CPhoneMainResourceResolver::Instance()->
  2910         iViewCommandHandle->ExecuteCommand(EPhoneViewSetBlueToothFlag,&btParam);
  3760                                  ResolveResourceID( aResourceId ) );
  2911 
       
  2912         TPhoneCmdParamBoolean btAvailableParam;
       
  2913         btAvailableParam.SetBoolean( btAvailable );        
       
  2914         iViewCommandHandle->ExecuteCommand(
       
  2915                 EPhoneViewSetBluetoothAvailableFlag,&btAvailableParam);
       
  2916                
       
  2917         TBool emergency( EPEStateIdle != 
       
  2918             iStateMachine->PhoneEngineInfo()->CallState( KPEEmergencyCallId ) );
       
  2919         TPhoneCmdParamBoolean booleanParam;
       
  2920         booleanParam.SetBoolean( emergency );
       
  2921 
       
  2922         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  3761         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  2923                      EPhoneViewSetTouchPaneButtons,
  3762                      EPhoneViewSetTouchPaneButtons,
  2924                      &booleanParam ) );
  3763                      &integerParam ) );
       
  3764 
       
  3765         SetTouchPaneVisible( ETrue );
  2925         }
  3766         }
  2926     }
  3767     }
  2927 
  3768 
  2928 // ---------------------------------------------------------
  3769 // ---------------------------------------------------------
  2929 // CPhoneState::DeleteTouchPaneButtons
  3770 // CPhoneState::DeleteTouchPaneButtons
  2931 //
  3772 //
  2932 EXPORT_C void CPhoneState::DeleteTouchPaneButtons()
  3773 EXPORT_C void CPhoneState::DeleteTouchPaneButtons()
  2933     {
  3774     {
  2934     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3775     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  2935         {
  3776         {
  2936         TPhoneCmdParamBoolean boolParam;
  3777         TPhoneCmdParamInteger integerParam;
       
  3778         integerParam.SetInteger( 0 );
  2937         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  3779         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  2938                         EPhoneViewSetTouchPaneButtons,
  3780                         EPhoneViewSetTouchPaneButtons,
  2939                         &boolParam ) );
  3781                         &integerParam ) );
       
  3782 
       
  3783         SetTouchPaneVisible( EFalse );
       
  3784         }
       
  3785     }
       
  3786 
       
  3787 // ---------------------------------------------------------
       
  3788 // CPhoneState::SetTouchPaneVisible
       
  3789 // ---------------------------------------------------------
       
  3790 //
       
  3791 EXPORT_C void CPhoneState::SetTouchPaneVisible( TBool aVisible )
       
  3792     {
       
  3793     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3794         {
       
  3795         TPhoneCmdParamBoolean booleanParam;
       
  3796         booleanParam.SetBoolean( aVisible );
       
  3797         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
       
  3798                         EPhoneViewSetTouchPaneVisible,
       
  3799                         &booleanParam ) );
       
  3800         }
       
  3801     }
       
  3802 
       
  3803 // ----------------------------------------------------------------------------
       
  3804 // CPhoneState::SetTouchButtonEnabled
       
  3805 // ----------------------------------------------------------------------------
       
  3806 //
       
  3807 EXPORT_C void CPhoneState::SetTouchPaneButtonEnabled( TInt aCommandId )
       
  3808     {
       
  3809     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3810         {
       
  3811         TPhoneCmdParamInteger commandParam;
       
  3812         commandParam.SetInteger( aCommandId );
       
  3813         iViewCommandHandle->ExecuteCommand( EPhoneViewEnableTouchButton,
       
  3814                                             &commandParam );
       
  3815         }
       
  3816     }
       
  3817 
       
  3818 // ----------------------------------------------------------------------------
       
  3819 // CPhoneState::SetTouchButtonDisabled
       
  3820 // ----------------------------------------------------------------------------
       
  3821 //
       
  3822 EXPORT_C void CPhoneState::SetTouchPaneButtonDisabled( TInt aCommandId )
       
  3823     {
       
  3824     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3825         {
       
  3826         TPhoneCmdParamInteger commandParam;
       
  3827         commandParam.SetInteger( aCommandId );
       
  3828 
       
  3829         iViewCommandHandle->ExecuteCommand( EPhoneViewDisableTouchButton,
       
  3830                                             &commandParam );
  2940         }
  3831         }
  2941     }
  3832     }
  2942 
  3833 
  2943 // ---------------------------------------------------------
  3834 // ---------------------------------------------------------
  2944 // CPhoneState::HandleLongHashL
  3835 // CPhoneState::HandleLongHashL
  2946 //
  3837 //
  2947 EXPORT_C void CPhoneState::HandleLongHashL()
  3838 EXPORT_C void CPhoneState::HandleLongHashL()
  2948     {
  3839     {
  2949     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::HandleLongHashL() ");
  3840     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::HandleLongHashL() ");
  2950 
  3841 
       
  3842     TPhoneCmdParamInteger numberEntryCountParam;
       
  3843     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
       
  3844             &numberEntryCountParam );
       
  3845     TInt neLength( numberEntryCountParam.Integer() );
       
  3846 
       
  3847     if( neLength == 1 )
       
  3848         {
       
  3849          if ( !iStateMachine->SecurityMode()->IsSecurityMode() )
       
  3850             {
       
  3851             OnlyHashInNumberEntryL();
       
  3852             }
       
  3853         }
       
  3854     }
       
  3855 
       
  3856 // -----------------------------------------------------------
       
  3857 // CPhoneState::OpenVKBL
       
  3858 // -----------------------------------------------------------
       
  3859 //
       
  3860 void CPhoneState::OpenVkbL()
       
  3861     {
       
  3862     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::OpenVKB() ");
       
  3863     iViewCommandHandle->ExecuteCommandL( EPhoneViewOpenVirtualKeyBoard );
  2951     }
  3864     }
  2952 
  3865 
  2953 // -----------------------------------------------------------
  3866 // -----------------------------------------------------------
  2954 // CPhoneState::BeginUiUpdateLC
  3867 // CPhoneState::BeginUiUpdateLC
  2955 // -----------------------------------------------------------
  3868 // -----------------------------------------------------------
  2956 //
  3869 //
  2957 EXPORT_C void CPhoneState::BeginUiUpdateLC()
  3870 EXPORT_C void CPhoneState::BeginUiUpdateLC()
  2958     {
  3871     {
  2959 
       
  2960     iViewCommandHandle->ExecuteCommand( EPhoneViewBeginUpdate );
  3872     iViewCommandHandle->ExecuteCommand( EPhoneViewBeginUpdate );
  2961 
       
  2962     TCleanupItem operation( UiUpdateCleanup, this );
  3873     TCleanupItem operation( UiUpdateCleanup, this );
  2963     CleanupStack::PushL( operation );
  3874     CleanupStack::PushL( operation );
  2964     }
  3875     }
  2965 
  3876 
  2966 // -----------------------------------------------------------
  3877 // -----------------------------------------------------------
  2967 // CPhoneState::EndUiUpdate
  3878 // CPhoneState::EndUiUpdate
  2968 // -----------------------------------------------------------
  3879 // -----------------------------------------------------------
  2969 //
  3880 //
  2970 EXPORT_C void CPhoneState::EndUiUpdate()
  3881 EXPORT_C void CPhoneState::EndUiUpdate()
  2971     {
  3882     {
  2972     CleanupStack::PopAndDestroy(); // Call UiUpdateCleanup
  3883      CleanupStack::PopAndDestroy(); // Call UiUpdateCleanup
       
  3884     }
       
  3885 	
       
  3886 // -----------------------------------------------------------
       
  3887 // CPhoneState::BeginTransEffectLC
       
  3888 // -----------------------------------------------------------
       
  3889 //
       
  3890 EXPORT_C void CPhoneState::BeginTransEffectLC( TStateTransEffectType aType )
       
  3891     {
       
  3892     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::BeginTransEffectLC( ) ");
       
  3893     TPhoneCmdParamTransEffect effectParam;
       
  3894     switch ( aType )
       
  3895         {
       
  3896         case ENumberEntryOpen:
       
  3897             effectParam.SetType( EPhoneTransEffectDialerOpen );
       
  3898             break;
       
  3899         case ENumberEntryClose:
       
  3900             effectParam.SetType( EPhoneTransEffectDialerClose );
       
  3901             break;
       
  3902         case ENumberEntryCreate:
       
  3903             effectParam.SetType( EPhoneTransEffectDialerCreate );
       
  3904             break;
       
  3905         case ECallUiAppear:
       
  3906             effectParam.SetType( EPhoneTransEffectCallUiAppear );
       
  3907             break;
       
  3908         case ECallUiDisappear:
       
  3909             effectParam.SetType( EPhoneTransEffectCallUiDisappear );
       
  3910             break;
       
  3911         default:
       
  3912             effectParam.SetType( EPhoneTransEffectNone );
       
  3913         }
       
  3914     effectParam.SetAppUid( KUidPhoneApplication );
       
  3915     iViewCommandHandle->ExecuteCommand( 
       
  3916             EPhoneViewBeginTransEffect, 
       
  3917             &effectParam );
       
  3918     // Always put the cleanup item into stack as expected by the caller.
       
  3919     TCleanupItem operation( EffectCleanup, this );
       
  3920     CleanupStack::PushL( operation );
       
  3921     }
       
  3922 
       
  3923 // -----------------------------------------------------------
       
  3924 // CPhoneState::EndTransEffect
       
  3925 // -----------------------------------------------------------
       
  3926 //
       
  3927 EXPORT_C void CPhoneState::EndTransEffect()
       
  3928     {
       
  3929     CleanupStack::PopAndDestroy(); // Call EffectCleanup
  2973     }
  3930     }
  2974 
  3931 
  2975 // -----------------------------------------------------------
  3932 // -----------------------------------------------------------
  2976 // CPhoneState::CheckIfShowTerminationNote
  3933 // CPhoneState::CheckIfShowTerminationNote
  2977 // This method is intended to be overridden in states
  3934 // This method is intended to be overridden in states
  3015 //
  3972 //
  3016 void CPhoneState::UiUpdateCleanup(TAny* aThis )
  3973 void CPhoneState::UiUpdateCleanup(TAny* aThis )
  3017     {
  3974     {
  3018     static_cast<CPhoneState*>( aThis )->iViewCommandHandle->ExecuteCommand(
  3975     static_cast<CPhoneState*>( aThis )->iViewCommandHandle->ExecuteCommand(
  3019         EPhoneViewEndUpdate );
  3976         EPhoneViewEndUpdate );
       
  3977     }
       
  3978 
       
  3979 // -----------------------------------------------------------------------------
       
  3980 // CPhoneState::EffectCleanup
       
  3981 // -----------------------------------------------------------------------------
       
  3982 //
       
  3983 void CPhoneState::EffectCleanup(TAny* aThis )
       
  3984     {
       
  3985     TPhoneCmdParamTransEffect effectParam;
       
  3986     effectParam.SetType( EPhoneTransEffectStop );
       
  3987     // won't do anything if effect wasn't started
       
  3988     static_cast<CPhoneState*>( aThis )->iViewCommandHandle->ExecuteCommand(
       
  3989         EPhoneViewEndTransEffect, &effectParam );
       
  3990     }
       
  3991 
       
  3992 // -----------------------------------------------------------------------------
       
  3993 // CPhoneState::IsDTMFEditorVisibleL
       
  3994 // -----------------------------------------------------------------------------
       
  3995 //
       
  3996 EXPORT_C TBool CPhoneState::IsDTMFEditorVisibleL() const
       
  3997     {
       
  3998     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsDTMFEditorVisibleL( ) ");
       
  3999     return iViewCommandHandle->HandleCommandL(
       
  4000         EPhoneViewIsDTMFEditorVisible ) ==
       
  4001         EPhoneViewResponseSuccess;
       
  4002     }
       
  4003 
       
  4004 // -----------------------------------------------------------------------------
       
  4005 // CPhoneState::CloseDTMFEditorL
       
  4006 // -----------------------------------------------------------------------------
       
  4007 //
       
  4008 EXPORT_C void CPhoneState::CloseDTMFEditorL()
       
  4009     {
       
  4010     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CloseDTMFEditorL()");
       
  4011     if ( iOnScreenDialer ) // Touch
       
  4012         {
       
  4013         TPhoneCmdParamBoolean booleanParam;
       
  4014         booleanParam.SetBoolean( EFalse );
       
  4015         iViewCommandHandle->ExecuteCommandL( 
       
  4016                 EPhoneViewSetDtmfDialerViewVisible,
       
  4017                 &booleanParam );
       
  4018         CloseClearNumberEntryAndLoadEffectL( ECallUiAppear );
       
  4019         }
       
  4020     else // Non-Touch
       
  4021         {
       
  4022         // If dtmf query is visible then remove number entry
       
  4023         // because it should not be shown if user has pressed end key.
       
  4024         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  4025         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
       
  4026         // Do state-specific behaviour if number entry is cleared
       
  4027         HandleNumberEntryClearedL();
       
  4028         }
  3020     }
  4029     }
  3021 
  4030 
  3022 // -----------------------------------------------------------
  4031 // -----------------------------------------------------------
  3023 // CPhoneState::SetDefaultFlagsL()
  4032 // CPhoneState::SetDefaultFlagsL()
  3024 // -----------------------------------------------------------
  4033 // -----------------------------------------------------------
  3043         &globalNotifierParam );
  4052         &globalNotifierParam );
  3044     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
  4053     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
  3045         &globalNotifierParam );
  4054         &globalNotifierParam );
  3046 
  4055 
  3047     // uncapture App and Camera keys if not security mode
  4056     // uncapture App and Camera keys if not security mode
  3048     TPhoneCmdParamBoolean isSecurityMode;
  4057     if ( !iStateMachine->SecurityMode()->IsSecurityMode() )
  3049     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );
       
  3050     if ( !isSecurityMode.Boolean() )
       
  3051         {
  4058         {
  3052         CaptureKeysDuringCallNotificationL( EFalse );
  4059         CaptureKeysDuringCallNotificationL( EFalse );
  3053         }
  4060         }
  3054 
  4061     
  3055     // Restore keylock if phone has been locked before call.
  4062     CPhonePubSubProxy::Instance()->ChangePropertyValue(
  3056     if ( iStateMachine->PhoneStorage()->NeedToEnableKeylock() )
  4063                     KPSUidScreenSaver,
  3057         {
  4064                     KScreenSaverAllowScreenSaver,
  3058         iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLock );
  4065                     EPhoneScreensaverAllowed );
  3059         iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( EFalse );
       
  3060         }
       
  3061     }
  4066     }
  3062 
  4067 
  3063 // -----------------------------------------------------------
  4068 // -----------------------------------------------------------
  3064 // CPhoneState::GetVolumeLevel
  4069 // CPhoneState::GetVolumeLevel
  3065 // -----------------------------------------------------------
  4070 // -----------------------------------------------------------
  3117     Sim security statuses:
  4122     Sim security statuses:
  3118 
  4123 
  3119     ESimSecurityStatusUninitialized = KStartupEnumerationFirstValue,
  4124     ESimSecurityStatusUninitialized = KStartupEnumerationFirstValue,
  3120     ESimRejected,   // The PUK code has been entered incorrectly, so the card is rejected.
  4125     ESimRejected,   // The PUK code has been entered incorrectly, so the card is rejected.
  3121     ESimUnaccepted  // The SIM lock is on, so the card is unaccepted.
  4126     ESimUnaccepted  // The SIM lock is on, so the card is unaccepted.
       
  4127     ESimInvalid     // The Sim inserted is not same as the one provided by the
       
  4128                     // operator, so card is invalid.
  3122     */
  4129     */
  3123     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SimSecurityStatus()" );
  4130     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SimSecurityStatus()" );
  3124     return CPhonePubSubProxy::Instance()->Value(
  4131     return CPhonePubSubProxy::Instance()->Value(
  3125                     KPSUidStartup, KStartupSimSecurityStatus );
  4132                     KPSUidStartup, KStartupSimSecurityStatus );
  3126     }
  4133     }
  3162             callText = iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId );
  4169             callText = iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId );
  3163             }
  4170             }
  3164 
  4171 
  3165         TPhoneCmdParamGlobalNote globalNoteParam;
  4172         TPhoneCmdParamGlobalNote globalNoteParam;
  3166         globalNoteParam.SetText( callText );
  4173         globalNoteParam.SetText( callText );
  3167         globalNoteParam.SetType( EPhoneNotificationDialog );
  4174         globalNoteParam.SetType( EAknGlobalInformationNote );
  3168 
  4175         globalNoteParam.SetTone( EAvkonSIDInformationTone );
  3169         globalNoteParam.SetTextResourceId(
  4176         globalNoteParam.SetTextResourceId(
  3170             CPhoneMainResourceResolver::Instance()->
  4177             CPhoneMainResourceResolver::Instance()->
  3171             ResolveResourceID( EPhoneCallWaitingWithLabel ) );
  4178             ResolveResourceID( EPhoneCallWaitingWithLabel ) );
  3172         globalNoteParam.SetNotificationDialog( ETrue );
  4179 
  3173         
       
  3174         iViewCommandHandle->ExecuteCommandL(
  4180         iViewCommandHandle->ExecuteCommandL(
  3175                 EPhoneViewShowGlobalNote, &globalNoteParam );
  4181                 EPhoneViewShowGlobalNote, &globalNoteParam );
  3176         }
  4182         }
  3177     else
  4183     else
  3178         {
  4184         {
  3179         SendGlobalInfoNoteL( EPhoneCallWaitingWithoutLabel, ETrue );
  4185         SendGlobalInfoNoteL( EPhoneCallWaitingWithoutLabel );
  3180         }
  4186         }
  3181     }
  4187     }
  3182 
  4188 
  3183 // ----------------------------------------------------------------------------
  4189 // ----------------------------------------------------------------------------
  3184 // CPhoneState::SetRingingTonePlaybackL()
  4190 // CPhoneState::SetRingingTonePlaybackL()
  3303             CPhoneMainResourceResolver::Instance()->
  4309             CPhoneMainResourceResolver::Instance()->
  3304             ResolveResourceID(
  4310             ResolveResourceID(
  3305             EPhoneInfoCugInUse ), cugIndex );
  4311             EPhoneInfoCugInUse ), cugIndex );
  3306 
  4312 
  3307         TPhoneCmdParamGlobalNote globalNoteParam;
  4313         TPhoneCmdParamGlobalNote globalNoteParam;
  3308         globalNoteParam.SetText( *buf );
  4314 	    globalNoteParam.SetText( *buf );
  3309         globalNoteParam.SetType( EPhoneMessageBoxInformation );
  4315 	    globalNoteParam.SetType( EAknGlobalInformationNote );
  3310    
  4316 	    globalNoteParam.SetTone( EAvkonSIDInformationTone );
  3311         iViewCommandHandle->ExecuteCommandL(
  4317 
  3312                 EPhoneViewShowGlobalNote, &globalNoteParam );
  4318 	    iViewCommandHandle->ExecuteCommandL(
  3313 
  4319 	            EPhoneViewShowGlobalNote, &globalNoteParam );
  3314         CleanupStack::PopAndDestroy( buf );
  4320 
       
  4321 	    CleanupStack::PopAndDestroy( buf );
  3315         }
  4322         }
  3316     }
  4323     }
  3317 
  4324 
  3318 // -----------------------------------------------------------
  4325 // -----------------------------------------------------------
  3319 // CPhoneState::CallheaderManagerL
  4326 // CPhoneState::CallheaderManagerL
  3330                 iCustomization );
  4337                 iCustomization );
  3331         }
  4338         }
  3332     return iCallHeaderManager;
  4339     return iCallHeaderManager;
  3333     }
  4340     }
  3334 
  4341 
       
  4342 // -----------------------------------------------------------------------------
       
  4343 // CPhoneState::CloseCustomizedDialerL
       
  4344 // -----------------------------------------------------------------------------
       
  4345 //
       
  4346 EXPORT_C void CPhoneState::CloseCustomizedDialerL()
       
  4347     {
       
  4348     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CloseCustomizedDialerL( ) ");
       
  4349     // Set dialer back to default mode.
       
  4350     iViewCommandHandle->HandleCommandL( EPhoneViewHideCustomizedDialer );
       
  4351     CloseClearNumberEntryAndLoadEffectL( ENumberEntryClose );
       
  4352     }
       
  4353 
       
  4354 // -----------------------------------------------------------------------------
       
  4355 // CPhoneState::CustomizedDialerMenuResourceId
       
  4356 // -----------------------------------------------------------------------------
       
  4357 //
       
  4358 EXPORT_C TInt CPhoneState::CustomizedDialerMenuResourceIdL()
       
  4359     {
       
  4360     __LOGMETHODSTARTEND(EPhoneControl,
       
  4361         "CPhoneState::CustomizedDialerMenuResourceId( ) ");
       
  4362     // Get and return customized dialer menu resource id
       
  4363     TPhoneCmdParamInteger integerParam;
       
  4364     iViewCommandHandle->HandleCommandL(
       
  4365         EPhoneViewGetCustomizedDialerMenuResourceId,
       
  4366         &integerParam );
       
  4367     return integerParam.Integer();
       
  4368     }
       
  4369 
       
  4370 // -----------------------------------------------------------------------------
       
  4371 // CPhoneState::CustomizedDialerCbaResourceId
       
  4372 // -----------------------------------------------------------------------------
       
  4373 //
       
  4374 EXPORT_C TInt CPhoneState::CustomizedDialerCbaResourceIdL()
       
  4375     {
       
  4376     __LOGMETHODSTARTEND(EPhoneControl,
       
  4377            "CPhoneState::CustomizedDialerCbaResourceId( ) ");
       
  4378     // Get and return customized dialer CBA resource id
       
  4379     TPhoneCmdParamInteger integerParam;
       
  4380     iViewCommandHandle->HandleCommandL(
       
  4381             EPhoneViewGetCustomizedDialerCbaResourceId,
       
  4382         &integerParam );
       
  4383     return integerParam.Integer();
       
  4384     }
       
  4385 
       
  4386 // -----------------------------------------------------------
       
  4387 // CPhoneState::ShowDtmfDialerL
       
  4388 // -----------------------------------------------------------
       
  4389 //
       
  4390 void CPhoneState::ShowDtmfDialerL()
       
  4391     {
       
  4392     __LOGMETHODSTARTEND(EPhoneControl,
       
  4393         "CPhoneState::ShowDtmfDialerL()" );
       
  4394 
       
  4395     // Set dialer to DTMF mode.
       
  4396     TPhoneCmdParamBoolean booleanParam;
       
  4397     booleanParam.SetBoolean( ETrue );
       
  4398     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetDtmfDialerViewVisible,
       
  4399                                          &booleanParam );
       
  4400     BeginTransEffectLC( ECallUiDisappear );
       
  4401     if ( IsNumberEntryUsedL() )
       
  4402         {
       
  4403         // Store the number entry content to cache
       
  4404         if ( !IsNumberEntryContentStored() )
       
  4405             {
       
  4406             StoreNumberEntryContentL();
       
  4407             }
       
  4408         // Clear and display DTMF dialer
       
  4409         NumberEntryClearL();
       
  4410         SetNumberEntryVisibilityL(ETrue);
       
  4411         }
       
  4412     else
       
  4413         {
       
  4414         // Create and display DTMF dialer
       
  4415         NumberEntryManagerL()->CreateNumberEntryL();
       
  4416         }
       
  4417     EndTransEffect();
       
  4418 
       
  4419     // Update CBA
       
  4420     iCbaManager->UpdateInCallCbaL();
       
  4421     
       
  4422     if( EPSCTsyCallStateDialling == 
       
  4423         CPhonePubSubProxy::Instance()->Value(KPSUidCtsyCallInformation, KCTsyCallState ) )
       
  4424         {
       
  4425         // Call indicator update to ensure that small call 
       
  4426         // bubble is shown in dtmf dialer during dialing
       
  4427         // call this needs to be done because when call is 
       
  4428         // initialized small call bubble visibility is set to false.
       
  4429         UpdateIncallIndicatorL(EPSCTsyCallStateDialling);
       
  4430         }
       
  4431     }
       
  4432 
  3335 // -----------------------------------------------------------
  4433 // -----------------------------------------------------------
  3336 // CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer
  4434 // CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer
  3337 // -----------------------------------------------------------
  4435 // -----------------------------------------------------------
  3338 //
  4436 //
  3339 EXPORT_C void CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer()
  4437 EXPORT_C void CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer()
  3340     {
  4438     {
  3341 
  4439     if ( IsOnScreenDialerSupported() )
       
  4440         {
       
  4441         TBool isDialerVisible( EFalse );
       
  4442         TRAP_IGNORE( isDialerVisible = IsDTMFEditorVisibleL() );
       
  4443 
       
  4444          if ( isDialerVisible )
       
  4445              {
       
  4446              TRAP_IGNORE( CloseDTMFEditorL() );
       
  4447              }
       
  4448 
       
  4449          // if the DTMF dialer is used before the idle message, we have to
       
  4450          // restore the original content of the number entry
       
  4451          if ( IsNumberEntryContentStored() )
       
  4452              {
       
  4453              TBool isNumberEntryUsed( EFalse );
       
  4454              TRAP_IGNORE( isNumberEntryUsed = IsNumberEntryUsedL() );
       
  4455 
       
  4456              if ( !isNumberEntryUsed )
       
  4457                  {
       
  4458                  TRAP_IGNORE( NumberEntryManagerL()->CreateNumberEntryL() );
       
  4459                  }
       
  4460              // Restore the number entry content from cache
       
  4461              TRAP_IGNORE( RestoreNumberEntryContentL() );
       
  4462              }
       
  4463          }
  3342     }
  4464     }
  3343 
  4465 
  3344 // -----------------------------------------------------------
  4466 // -----------------------------------------------------------
  3345 // CPhoneState::IsOnScreenDialerSupported
  4467 // CPhoneState::IsOnScreenDialerSupported
  3346 // -----------------------------------------------------------
  4468 // -----------------------------------------------------------
  3358     {
  4480     {
  3359     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::LoadResource() ");
  4481     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::LoadResource() ");
  3360     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::LoadResource - aResource: %d", aResource );
  4482     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::LoadResource - aResource: %d", aResource );
  3361     StringLoader::Load(  aData,
  4483     StringLoader::Load(  aData,
  3362                          CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
  4484                          CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
  3363                          &iEnv  );
  4485                          EikonEnv() );
  3364     }
  4486     }
  3365 
  4487 
  3366 // -----------------------------------------------------------
  4488 // -----------------------------------------------------------
  3367 // CPhoneState::IsAnyConnectedCalls
  4489 // CPhoneState::IsAnyConnectedCalls
  3368 // -----------------------------------------------------------
  4490 // -----------------------------------------------------------
  3428     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNumberEntryVisibleL( ) ");
  4550     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNumberEntryVisibleL( ) ");
  3429     return NumberEntryManagerL()->IsNumberEntryVisibleL();
  4551     return NumberEntryManagerL()->IsNumberEntryVisibleL();
  3430     }
  4552     }
  3431 
  4553 
  3432 // -----------------------------------------------------------
  4554 // -----------------------------------------------------------
       
  4555 // CPhoneState::KeyEventForExistingNumberEntryL
       
  4556 // -----------------------------------------------------------
       
  4557 //
       
  4558 void CPhoneState::KeyEventForExistingNumberEntryL( const TKeyEvent& aKeyEvent,
       
  4559     TEventCode aEventCode )
       
  4560     {
       
  4561     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::KeyEventForExistingNumberEntryL( ) ");
       
  4562     NumberEntryManagerL()->KeyEventForExistingNumberEntryL( aKeyEvent, aEventCode );
       
  4563     }
       
  4564 
       
  4565 // -----------------------------------------------------------
  3433 // CPhoneState::HandleNumberEntryClearedL
  4566 // CPhoneState::HandleNumberEntryClearedL
  3434 // -----------------------------------------------------------
  4567 // -----------------------------------------------------------
  3435 //
  4568 //
  3436 EXPORT_C void CPhoneState::HandleNumberEntryClearedL()
  4569 EXPORT_C void CPhoneState::HandleNumberEntryClearedL()
  3437     {
  4570     {
  3453         booleanParam.SetBoolean( EFalse );
  4586         booleanParam.SetBoolean( EFalse );
  3454         }
  4587         }
  3455     NumberEntryManagerL()->SetNumberEntryVisibilityL( booleanParam );
  4588     NumberEntryManagerL()->SetNumberEntryVisibilityL( booleanParam );
  3456     }
  4589     }
  3457 
  4590 
       
  4591 // ---------------------------------------------------------
       
  4592 // CPhoneState::HandleCreateNumberEntryL
       
  4593 // ---------------------------------------------------------
       
  4594 //
       
  4595 EXPORT_C void CPhoneState::HandleCreateNumberEntryL(
       
  4596         const TKeyEvent& /*aKeyEvent*/,
       
  4597         TEventCode /*aEventCode*/ )
       
  4598     {
       
  4599     NumberEntryManagerL()->HandleCreateNumberEntryL();
       
  4600     }
       
  4601 
  3458 // -----------------------------------------------------------
  4602 // -----------------------------------------------------------
  3459 // CPhoneState::IsNumberEntryContentStored
  4603 // CPhoneState::IsNumberEntryContentStored
  3460 // -----------------------------------------------------------
  4604 // -----------------------------------------------------------
  3461 //
  4605 //
  3462 EXPORT_C TBool CPhoneState::IsNumberEntryContentStored()
  4606 EXPORT_C TBool CPhoneState::IsNumberEntryContentStored()
  3474     {
  4618     {
  3475     NumberEntryManagerL()->StoreNumberEntryContentL();
  4619     NumberEntryManagerL()->StoreNumberEntryContentL();
  3476     }
  4620     }
  3477 
  4621 
  3478 // -----------------------------------------------------------
  4622 // -----------------------------------------------------------
       
  4623 // CPhoneState::RestoreNumberEntryContentL
       
  4624 // -----------------------------------------------------------
       
  4625 //
       
  4626 EXPORT_C void CPhoneState::RestoreNumberEntryContentL()
       
  4627     {
       
  4628     NumberEntryManagerL()->RestoreNumberEntryContentL();
       
  4629     }
       
  4630 
       
  4631 // -----------------------------------------------------------
  3479 // CPhoneState::ClearNumberEntryContentCache
  4632 // CPhoneState::ClearNumberEntryContentCache
  3480 // -----------------------------------------------------------
  4633 // -----------------------------------------------------------
  3481 //
  4634 //
  3482 EXPORT_C void CPhoneState::ClearNumberEntryContentCache()
  4635 EXPORT_C void CPhoneState::ClearNumberEntryContentCache()
  3483     {
  4636     {
  3484     TRAP_IGNORE( NumberEntryManagerL()->ClearNumberEntryContentCache() );
  4637     TRAP_IGNORE( NumberEntryManagerL()->ClearNumberEntryContentCache() );
       
  4638     }
       
  4639 
       
  4640 // -----------------------------------------------------------
       
  4641 // CPhoneState::HandleNumberEntryEdited
       
  4642 // -----------------------------------------------------------
       
  4643 //
       
  4644 EXPORT_C void CPhoneState::HandleNumberEntryEdited()
       
  4645     {
       
  4646     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::HandleNumberEntryEdited() ");
       
  4647     TRAP_IGNORE( NumberEntryManagerL()->HandleNumberEntryEdited() );
  3485     }
  4648     }
  3486 
  4649 
  3487 // -----------------------------------------------------------------------------
  4650 // -----------------------------------------------------------------------------
  3488 // CPhoneState::IsAlphanumericSupportedAndCharInput
  4651 // CPhoneState::IsAlphanumericSupportedAndCharInput
  3489 // -----------------------------------------------------------------------------
  4652 // -----------------------------------------------------------------------------
  3514 //
  4677 //
  3515 void CPhoneState::NumberEntryClearL()
  4678 void CPhoneState::NumberEntryClearL()
  3516     {
  4679     {
  3517     NumberEntryManagerL()->NumberEntryClearL();
  4680     NumberEntryManagerL()->NumberEntryClearL();
  3518     }
  4681     }
  3519 
  4682 	
  3520 // -----------------------------------------------------------
  4683 // -----------------------------------------------------------
  3521 // CPhoneState::GetBlockedKeyList
  4684 // CPhoneState::UpdateSilenceButtonDimming
  3522 // -----------------------------------------------------------
  4685 // -----------------------------------------------------------
  3523 //
  4686 //
  3524 EXPORT_C const RArray<TInt>& CPhoneState::GetBlockedKeyList() const
  4687 EXPORT_C void CPhoneState::UpdateSilenceButtonDimming()
  3525     {
  4688     {
  3526     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::GetBlockedKeyList( ) ");
  4689     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3527     return iStateMachine->PhoneStorage()->GetBlockedKeyList();
  4690         {
  3528     }
  4691         const TProfileRingingType ringingType =
  3529 
  4692             iStateMachine->PhoneEngineInfo()->RingingType();
  3530 // -----------------------------------------------------------
       
  3531 // CPhoneState::DisableHWKeysL
       
  3532 // -----------------------------------------------------------
       
  3533 //
       
  3534 EXPORT_C void CPhoneState::DisableHWKeysL()
       
  3535     {
       
  3536     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisableHWKeysL( ) ");
       
  3537 
       
  3538     if( iStateMachine->PhoneStorage()->IsBlockedKeysListEmpty() )
       
  3539         {
       
  3540         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::DisableHWKeysL HW Keys Disabled " );
       
  3541 
       
  3542         iStateMachine->PhoneStorage()->AppendBlockedKeysListL( EStdKeyNo );
       
  3543         iStateMachine->PhoneStorage()->AppendBlockedKeysListL( EStdKeyYes );
       
  3544         }
       
  3545     }
       
  3546 
       
  3547 // -----------------------------------------------------------
       
  3548 // CPhoneState::DisableCallUIL
       
  3549 // -----------------------------------------------------------
       
  3550 //
       
  3551 EXPORT_C void CPhoneState::DisableCallUIL()
       
  3552     {
       
  3553     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisableCallUIL( ) ");
       
  3554 
       
  3555     // Set Call UI state to storage
       
  3556     if( !iStateMachine->PhoneStorage()->IsScreenLocked() )
       
  3557         {
       
  3558         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::DisableCallUIL CallUI Disabled " );
       
  3559 
       
  3560         // Show keys locked note
       
  3561         TPhoneCmdParamNote noteParam;
       
  3562         noteParam.SetType( EPhoneNoteUIDisabled );
       
  3563         noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
  3564             ResolveResourceID( EPhoneInformationNote ) );
       
  3565     
       
  3566         HBufC* noteText = StringLoader::LoadLC( 
       
  3567             CPhoneMainResourceResolver::Instance()->
       
  3568                 ResolveResourceID( EPhoneIncomingCallKeysLocked ) );
       
  3569         noteParam.SetText( *noteText );
       
  3570     
       
  3571         iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
  3572         CleanupStack::PopAndDestroy( noteText );
       
  3573     
       
  3574         // Start capturing the key guard key
       
  3575         TPhoneCmdParamKeyCapture appKeyCaptureParam;
       
  3576         appKeyCaptureParam.SetKey( EStdKeyDevice7 );
       
  3577         appKeyCaptureParam.SetKeyCode( EKeyDeviceF );
       
  3578         appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
  3579         iViewCommandHandle->ExecuteCommandL( EPhoneViewStartCapturingKey, &appKeyCaptureParam );
       
  3580         
  4693         
  3581         // Set Call UI state to storage
  4694         TBool callIsAlerting =
  3582         iStateMachine->PhoneStorage()->SetScreenLocked( ETrue );
  4695                 !(( ringingType == EProfileRingingTypeSilent ) ||
  3583         }
  4696                   ( ringingType == EProfileRingingTypeBeepOnce ));
  3584     }
  4697 
  3585 
  4698         if ( !callIsAlerting )
  3586 // -----------------------------------------------------------
  4699             {
  3587 // CPhoneState::EnableCallUIL
  4700             SetTouchPaneButtonDisabled( EPhoneCallComingCmdSilent );
  3588 // -----------------------------------------------------------
  4701             }
  3589 //
  4702         }
  3590 EXPORT_C void CPhoneState::EnableCallUIL()
  4703     }
  3591     {
  4704 	
  3592     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::EnableCallUIL( ) ");
  4705 // ---------------------------------------------------------
  3593 
  4706 // CPhoneState::SetToolbarDimming
  3594     if( iStateMachine->PhoneStorage()->IsScreenLocked() )
  4707 // ---------------------------------------------------------
  3595         {
  4708 //
  3596         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::EnableCallUIL CallUI Enabled " );
  4709 EXPORT_C void CPhoneState::SetToolbarDimming( TBool aDimmed )
  3597 
  4710     {
  3598         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
  4711 	if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3599         iViewCommandHandle->ExecuteCommandL( EPhoneViewDisableKeyLockWithoutNote );
  4712         {
  3600 
  4713 		// Check that we are not undimming toolbar in security mode
  3601         // Stop capturing the key guard key
  4714 		if ( !( !aDimmed && iStateMachine->SecurityMode()->IsSecurityMode() ) )
  3602         TPhoneCmdParamKeyCapture appKeyCaptureParam;
  4715 			{
  3603         appKeyCaptureParam.SetKey( EStdKeyDevice7 );
  4716 			TPhoneCmdParamBoolean booleanParam;
  3604         appKeyCaptureParam.SetKeyCode( EKeyDeviceF );
  4717 			booleanParam.SetBoolean( aDimmed );
  3605         appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
  4718 			TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  3606         iViewCommandHandle->ExecuteCommandL( EPhoneViewStopCapturingKey, &appKeyCaptureParam );
  4719 				EPhoneViewSetToolbarDimming, &booleanParam ));
  3607         
  4720 			}
  3608         iStateMachine->PhoneStorage()->SetScreenLocked( EFalse );
       
  3609         }
       
  3610     }
       
  3611 
       
  3612 // -----------------------------------------------------------
       
  3613 // CPhoneState::CheckDisableHWKeysAndCallUIL
       
  3614 // -----------------------------------------------------------
       
  3615 //
       
  3616 EXPORT_C void CPhoneState::CheckDisableHWKeysAndCallUIL()
       
  3617     {
       
  3618     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneState::CheckDisableHWKeysAndCallUIL( ) ");
       
  3619 
       
  3620     if( IsKeyLockOn() || IsAutoLockOn() )
       
  3621         {
       
  3622         // Disable HW keys if needed
       
  3623         if( CPhoneCenRepProxy::Instance()->
       
  3624                 IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  3625             {
       
  3626             DisableHWKeysL();
       
  3627             }
       
  3628 
       
  3629         // Disable Call UI if needed
       
  3630         if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke )
       
  3631                 && !CPhoneCenRepProxy::Instance()->
       
  3632                 IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) )
       
  3633             {
       
  3634             DisableCallUIL();
       
  3635             iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( ETrue );
       
  3636             }
       
  3637         }
       
  3638     }
       
  3639 
       
  3640 // -----------------------------------------------------------
       
  3641 // CPhoneState::HandleHoldSwitchL
       
  3642 // -----------------------------------------------------------
       
  3643 //
       
  3644 EXPORT_C void CPhoneState::HandleHoldSwitchL()
       
  3645     {
       
  3646     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneState::HandleHoldSwitchL( ) ");
       
  3647 
       
  3648     if( CPhoneCenRepProxy::Instance()->
       
  3649             IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  3650         {
       
  3651         if( iStateMachine->PhoneStorage()->IsBlockedKeysListEmpty() )
       
  3652             {
       
  3653             // Disable HW Keys if needed
       
  3654             DisableHWKeysL();
       
  3655             }
       
  3656         else
       
  3657             {
       
  3658             // Reset blocked keys list
       
  3659             iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
  3660             }
       
  3661         }
       
  3662     
       
  3663     if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) 
       
  3664             && !CPhoneCenRepProxy::Instance()->
       
  3665             IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) )
       
  3666         {
       
  3667         if( iStateMachine->PhoneStorage()->IsScreenLocked() )
       
  3668             {
       
  3669             // Enable Call
       
  3670             EnableCallUIL();
       
  3671             }
       
  3672         else
       
  3673             {
       
  3674             // Set keylock enabled
       
  3675             iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLockWithoutNote );
       
  3676             // Disable Call
       
  3677             DisableCallUIL();
       
  3678             }
       
  3679         }
       
  3680         
       
  3681         // Stop ringingtone
       
  3682         iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
  3683     }
       
  3684 
       
  3685 // -----------------------------------------------------------
       
  3686 // CPhoneState::RetainPreviousKeylockStateL
       
  3687 // -----------------------------------------------------------
       
  3688 //
       
  3689 EXPORT_C void CPhoneState::RetainPreviousKeylockStateL()
       
  3690     {
       
  3691     // Lock keypad, if keylock was enabled before incoming call.
       
  3692     // Also reset PhoneStorage keylock status.
       
  3693     if ( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) &&
       
  3694         iStateMachine->PhoneStorage()->NeedToEnableKeylock() )
       
  3695         {
       
  3696         iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( EFalse );
       
  3697         iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLockWithoutNote ); 
       
  3698         }
       
  3699     }
       
  3700 
       
  3701 // ---------------------------------------------------------
       
  3702 // CPhoneState::HandleKeyLockEnabledL
       
  3703 // ---------------------------------------------------------
       
  3704 //
       
  3705 EXPORT_C void CPhoneState::HandleKeyLockEnabled( TBool aKeylockEnabled )
       
  3706     {
       
  3707     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleKeyLockEnabledL( ) ");
       
  3708     if( !FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke )
       
  3709         && CPhoneCenRepProxy::Instance()->
       
  3710             IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  3711         {
       
  3712         if( !aKeylockEnabled )
       
  3713             {
       
  3714             // Keylock disabled
       
  3715             // Reset blocked keys list
       
  3716             iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
  3717             }
       
  3718         }
  4721         }
  3719     }
  4722     }
  3720 
  4723 
  3721 // ---------------------------------------------------------
  4724 // ---------------------------------------------------------
  3722 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
  4725 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
  3726     {
  4729     {
  3727     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  4730     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3728         {
  4731         {
  3729         TPhoneCmdParamInteger integerParam;
  4732         TPhoneCmdParamInteger integerParam;
  3730         integerParam.SetInteger( EPhoneInCallCmdActivateIhf );
  4733         integerParam.SetInteger( EPhoneInCallCmdActivateIhf );
  3731         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  4734         iViewCommandHandle->ExecuteCommand(
  3732             EPhoneViewEnableToolbarButton, &integerParam ));
  4735             EPhoneViewEnableToolbarButton, &integerParam );
  3733         }
  4736         }
  3734     }
  4737     }
  3735 
  4738 
  3736 // ---------------------------------------------------------
  4739 // ---------------------------------------------------------
  3737 // CPhoneState::SetBackButtonActive
  4740 // CPhoneState::SetToolbarButtonHandsetEnabled
  3738 // ---------------------------------------------------------
  4741 // ---------------------------------------------------------
  3739 //
  4742 //
  3740 EXPORT_C void CPhoneState::SetBackButtonActive( TBool aActive )
  4743 EXPORT_C void CPhoneState::SetToolbarButtonHandsetEnabled()
  3741     {
  4744     {
  3742     if(IsAutoLockOn() && aActive) {
  4745     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3743         // keep back button dimmed device lock case
  4746         {
  3744         return;
  4747         TPhoneCmdParamInteger integerParam;
  3745     }
  4748         integerParam.SetInteger( EPhoneInCallCmdHandset );
       
  4749         iViewCommandHandle->ExecuteCommand(
       
  4750             EPhoneViewEnableToolbarButton, &integerParam );
       
  4751         }
       
  4752     }
       
  4753 
       
  4754 // ---------------------------------------------------------
       
  4755 // CPhoneState::SetToolbarButtonBTHFEnabled
       
  4756 // ---------------------------------------------------------
       
  4757 //
       
  4758 EXPORT_C void CPhoneState::SetToolbarButtonBTHFEnabled()
       
  4759     {
       
  4760     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  4761         {
       
  4762         TPhoneCmdParamInteger integerParam;
       
  4763         integerParam.SetInteger( EPhoneInCallCmdBtHandsfree );
       
  4764         iViewCommandHandle->ExecuteCommand(
       
  4765             EPhoneViewEnableToolbarButton, &integerParam );
       
  4766         }
       
  4767     }
       
  4768 
       
  4769 // ---------------------------------------------------------
       
  4770 // CPhoneState::HandleEasyDialingCommandsL
       
  4771 // ---------------------------------------------------------
       
  4772 //
       
  4773 void CPhoneState::HandleEasyDialingCommandsL( TInt aCommandId )
       
  4774     {
       
  4775     switch ( aCommandId )
       
  4776         {
       
  4777         case EPhoneCmdUpdateCba:
       
  4778             iCbaManager->UpdateInCallCbaL();
       
  4779             break;
       
  4780                 
       
  4781         case EPhoneDialerValidNumber:
       
  4782             {
       
  4783             TPhoneCmdParamBoolean command;
       
  4784             command.SetBoolean( EFalse );
       
  4785             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetInvalidCsPhoneNumberFlag, &command );           
       
  4786             }
       
  4787             break;
       
  4788                 
       
  4789         case EPhoneDialerInvalidNumber:
       
  4790             {
       
  4791             TPhoneCmdParamBoolean command;
       
  4792             command.SetBoolean( ETrue );
       
  4793             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetInvalidCsPhoneNumberFlag, &command );
       
  4794             }
       
  4795             break;
       
  4796             
       
  4797         case EPhoneCmdBlockingDialogLaunched:
       
  4798             {
       
  4799             TPhoneCmdParamBoolean param;
       
  4800             param.SetBoolean( ETrue );
       
  4801             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetBlockingDialogStatus, &param );
       
  4802             }
       
  4803             break;
       
  4804             
       
  4805         case EPhoneCmdBlockingDialogClosed:
       
  4806             {
       
  4807             TPhoneCmdParamBoolean param;
       
  4808             param.SetBoolean( EFalse );
       
  4809             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetBlockingDialogStatus, &param );
       
  4810             }
       
  4811             break;
       
  4812             
       
  4813         default:
       
  4814             break;
       
  4815         }
       
  4816     }
       
  4817 
       
  4818 // -----------------------------------------------------------
       
  4819 // CPhoneState::ForwardPEMessageToPhoneCustomizationL
       
  4820 // Forward Phone Engine messages to Phone customization
       
  4821 // (other items were commented in a header).
       
  4822 // -----------------------------------------------------------
       
  4823 //
       
  4824 EXPORT_C TBool CPhoneState::ForwardPEMessageToPhoneCustomizationL(
       
  4825     const TInt aMessage,
       
  4826     TInt aCallId )
       
  4827     {
       
  4828     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::ForwardPEMessageToPhoneCustomizationL() " );
       
  4829     TBool handled = EFalse;
  3746     
  4830     
  3747     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  4831     if ( iCustomization )
  3748         {
  4832        {
  3749         TPhoneCmdParamBoolean booleanParam;
  4833        handled = iCustomization->HandlePhoneEngineMessageL( aMessage, aCallId );
  3750         booleanParam.SetBoolean( aActive );
  4834        }
  3751         iViewCommandHandle->ExecuteCommand(
  4835     return handled;
  3752             EPhoneViewBackButtonActive, &booleanParam );
  4836     }
  3753         }
  4837 
  3754     }
  4838 // -----------------------------------------------------------
  3755 
  4839 // CPhoneState::SetLittleBubbleVisibilityL
  3756 // -----------------------------------------------------------
  4840 // -----------------------------------------------------------
  3757 // CPhoneState::OpenSoftRejectMessageEditorL
  4841 //
  3758 // -----------------------------------------------------------
  4842 void CPhoneState::SetLittleBubbleVisibilityL(
  3759 //
  4843         TPhoneCommandParam* aCommandParam)
  3760 EXPORT_C void CPhoneState::OpenSoftRejectMessageEditorL()
  4844     {
  3761     {
  4845     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetLittleBubbleVisibilityL() " );
  3762     __LOGMETHODSTARTEND(EPhoneControl,
  4846     // If user has opened dtmfeditor(dtmfdialer) then do not make any changes 
  3763         "CPhoneState::OpenSoftRejectMessageEditorL ()" );
  4847     // to SetLittleBubbleVisible value. SetLittleBubbleVisible value is true by default.
  3764 
  4848     if( !IsDTMFEditorVisibleL() )
  3765     // Fetch incoming call's id from view
  4849         {
  3766     TPhoneCmdParamCallStateData callStateData;
  4850         TPhoneCmdParamIncallIndicatorData* incallIndicatorParam =
  3767     callStateData.SetCallState( EPEStateRinging );
  4851                    static_cast<TPhoneCmdParamIncallIndicatorData*>( aCommandParam );
  3768     iViewCommandHandle->HandleCommandL(
  4852         TInt activeCallId = GetActiveCallIdL();
  3769         EPhoneViewGetCallIdByState, &callStateData );
  4853         switch( incallIndicatorParam->CallState() )
  3770 
  4854            {
  3771     TInt ringingCallId( KErrNotFound );
  4855            case EPSCTsyCallStateRinging:
  3772     // Do nothing if negative incoming call id
  4856            case EPSCTsyCallStateDialling:
  3773     if( callStateData.CallId() > KErrNotFound  )
  4857                {
  3774         {
  4858                // If we have single ringing or dialling call then it is ok
  3775         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
  4859                // to set visibility to false.
  3776         
  4860                if ( activeCallId < KErrNone )
  3777         ringingCallId = callStateData.CallId();
  4861                    {
  3778         }
  4862                    incallIndicatorParam->SetLittleBubbleVisible( EFalse );
  3779     
  4863                    }
  3780     
  4864                }
  3781     TPhoneCmdParamSfiData sfiDataParam;
  4865                break;
  3782 
  4866            default:
  3783     if (KErrNotFound != ringingCallId) 
  4867                incallIndicatorParam->SetLittleBubbleVisible( ETrue );
  3784         {
  4868                break;
  3785         if ( iStateMachine->PhoneEngineInfo()->RemoteName( ringingCallId ).Length() )
  4869            }
  3786             {
  4870         } 
  3787             // store both the name and the number
  4871     }
  3788             sfiDataParam.SetNumber( iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( ringingCallId ) );
  4872 
  3789             sfiDataParam.SetName( iStateMachine->PhoneEngineInfo()->RemoteName( ringingCallId ) );
  4873 // -----------------------------------------------------------
  3790             }
  4874 // CPhoneState::DisplayCallSetupL
  3791         else
  4875 // -----------------------------------------------------------
  3792             {
  4876 //
  3793             // store the number
  4877 EXPORT_C void CPhoneState::DisplayCallSetupL( TInt aCallId )
  3794             sfiDataParam.SetNumber( iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( ringingCallId ) );
  4878     {
  3795             }
  4879     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::DisplayCallSetupL() ");
  3796         }
  4880     BeginTransEffectLC( ECallUiAppear );
  3797 
  4881     BeginUiUpdateLC();
  3798     iViewCommandHandle->ExecuteCommandL(
  4882     SetNumberEntryVisibilityL( EFalse );
  3799         EPhoneViewOpenSoftRejectEditor, &sfiDataParam );
  4883     CaptureKeysDuringCallNotificationL( ETrue );
       
  4884     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
  4885     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  4886     TPhoneCmdParamInteger uidParam;
       
  4887     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
  4888     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
  4889         &uidParam );
       
  4890     // Do state-specific operations.
       
  4891     DoStateSpecificCallSetUpDefinitionsL();
       
  4892     DisplayHeaderForOutgoingCallL(aCallId);
       
  4893     EndUiUpdate();
       
  4894     EndTransEffect();
       
  4895     iCbaManager->UpdateCbaL(EPhoneCallHandlingCallSetupCBA);
       
  4896     }
       
  4897 
       
  4898 // -----------------------------------------------------------
       
  4899 // Sends command to viewcontroller to store the flag
       
  4900 // -----------------------------------------------------------
       
  4901 //
       
  4902 EXPORT_C void CPhoneState::SetNeedToReturnToForegroundAppStatusL( 
       
  4903     TBool aNeedToReturn )
       
  4904     {
       
  4905     TPhoneCmdParamBoolean booleanParam;
       
  4906     booleanParam.SetBoolean( aNeedToReturn );
       
  4907     iViewCommandHandle->ExecuteCommandL( 
       
  4908         EPhoneViewSetNeedToReturnToForegroundAppStatus,
       
  4909         &booleanParam );
       
  4910     }
       
  4911 
       
  4912 // -----------------------------------------------------------
       
  4913 // CPhoneState::DoStateSpecificCallSetUpDefinitionsL
       
  4914 // -----------------------------------------------------------
       
  4915 //
       
  4916 EXPORT_C void CPhoneState::DoStateSpecificCallSetUpDefinitionsL()
       
  4917     {
       
  4918     // do nothing
       
  4919     }
       
  4920 
       
  4921 // -----------------------------------------------------------
       
  4922 // CPhoneState::CloseClearNumberEntryAndLoadEffect
       
  4923 // -----------------------------------------------------------
       
  4924 //
       
  4925 EXPORT_C void CPhoneState::CloseClearNumberEntryAndLoadEffectL( 
       
  4926         TStateTransEffectType aType )
       
  4927     {
       
  4928     __LOGMETHODSTARTEND( EPhoneControl, 
       
  4929             "CPhoneState::CloseClearNumberEntryAndLoadEffectL() ");
       
  4930     BeginTransEffectLC( aType );
       
  4931     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  4932     EndTransEffect();
       
  4933     // Do state-specific operation when number entry is cleared
       
  4934     HandleNumberEntryClearedL();
  3800     }
  4935     }
  3801 
  4936 
  3802 //  End of File
  4937 //  End of File
  3803 
  4938