phoneapp/phoneuicontrol/src/cphonestate.cpp
branchRCL_3
changeset 24 41a7f70b3818
parent 23 40a3f856b14d
child 25 5266b1f337bd
equal deleted inserted replaced
23:40a3f856b14d 24:41a7f70b3818
     1 /*
     1 /*
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-2009 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>
       
    36 #include <wlaninternalpskeys.h>
    35 #include <wlaninternalpskeys.h>
    37 #include <btengdomainpskeys.h>
    36 #include <btengdomainpskeys.h>
    38 #include <btengdomaincrkeys.h>
    37 #include <btengdomaincrkeys.h>
    39 #include <settingsinternalcrkeys.h>
    38 #include <settingsinternalcrkeys.h>
    40 #include <starterclient.h>
    39 #include <starterclient.h>
    41 #include <RSSSettings.h>
    40 #include <rsssettings.h>
    42 #include <UikonInternalPSKeys.h>
    41 #include <UikonInternalPSKeys.h>
    43 #include <telephonydomainpstypes.h>
    42 #include <telephonydomainpstypes.h>
    44 #include <telinformationpskeys.h>
    43 #include <telinformationpskeys.h>
    45 #include <activeidle2domainpskeys.h>
       
    46 #include <coreapplicationuisdomainpskeys.h>
    44 #include <coreapplicationuisdomainpskeys.h>
    47 #include <mccecall.h>
    45 #include <mccecall.h>
    48 #include <ccpdefs.h>
    46 #include <ccpdefs.h>
    49 #include <LogsDomainCRKeys.h>
    47 #include <LogsDomainCRKeys.h>
    50 #include <spsettings.h>
    48 #include <spsettings.h>
    51 #include <ScreensaverInternalPSKeys.h>
       
    52 #include <startupdomainpskeys.h>
    49 #include <startupdomainpskeys.h>
    53 #include <MediatorDomainUIDs.h>
    50 #include <MediatorDomainUIDs.h>
    54 #include <videotelcontrolmediatorapi.h>
    51 #include <videotelcontrolmediatorapi.h>
    55 #include <textresolver.h>
    52 #include <textresolver.h>
    56 #include <phoneappvoipcommands.hrh>
    53 #include <phoneappvoipcommands.hrh>
    66 #include "tphonecmdparamkeyevent.h"
    63 #include "tphonecmdparamkeyevent.h"
    67 #include "tphonecmdparamdynmenu.h"
    64 #include "tphonecmdparamdynmenu.h"
    68 #include "tphonecmdparamcallheaderdata.h"
    65 #include "tphonecmdparamcallheaderdata.h"
    69 #include "tphonecmdparamincallindicatordata.h"
    66 #include "tphonecmdparamincallindicatordata.h"
    70 #include "tphonecmdparamnote.h"
    67 #include "tphonecmdparamnote.h"
    71 #include "tphonecmdparamKeycapture.h"
    68 #include "tphonecmdparamkeycapture.h"
    72 #include "tphonecmdparamglobalnote.h"
    69 #include "tphonecmdparamglobalnote.h"
    73 #include "tphonecmdparamquery.h"
    70 #include "tphonecmdparamquery.h"
    74 #include "tphonecmdparamstring.h"
    71 #include "tphonecmdparamstring.h"
    75 #include "tphonecmdparammessageeditor.h"
       
    76 #include "tphonecmdparamcallstatedata.h"
    72 #include "tphonecmdparamcallstatedata.h"
    77 #include "tphonecmdparambitmap.h"
    73 #include "tphonecmdparambitmap.h"
    78 #include "tphonecmdparamaudiooutput.h"
    74 #include "tphonecmdparamaudiooutput.h"
    79 #include "tphonecmdparamaudioavailability.h"
    75 #include "tphonecmdparamaudioavailability.h"
    80 #include "tphonecmdparamappinfo.h"
    76 #include "tphonecmdparamappinfo.h"
   103 #include "cphonemediatorsender.h"
    99 #include "cphonemediatorsender.h"
   104 #include "cphonereleasecommand.h"
   100 #include "cphonereleasecommand.h"
   105 #include "cphonecontinueemergencycallcommand.h"
   101 #include "cphonecontinueemergencycallcommand.h"
   106 #include "cphonecallheadermanager.h"
   102 #include "cphonecallheadermanager.h"
   107 #include "cphonenumberentrymanager.h"
   103 #include "cphonenumberentrymanager.h"
   108 #include "mphonesecuritymodeobserver.h"
   104 #include "tphonecmdparamsfidata.h" 
   109 #include "easydialingcommands.hrh"
   105 #include "mphonestorage.h"
   110 
   106 #include "phoneconstants.h"
       
   107 #include "cphoneclearblacklist.h"
   111 
   108 
   112 // ================= MEMBER FUNCTIONS =======================
   109 // ================= MEMBER FUNCTIONS =======================
   113 
   110 
   114 EXPORT_C CPhoneState::CPhoneState(
   111 EXPORT_C CPhoneState::CPhoneState(
   115     MPhoneStateMachine* aStateMachine,
   112     MPhoneStateMachine* aStateMachine,
   116     MPhoneViewCommandHandle* aViewCommandHandle,
   113     MPhoneViewCommandHandle* aViewCommandHandle,
   117     MPhoneCustomization* aCustomization) :
   114     MPhoneCustomization* aCustomization) :
   118     iStateMachine( aStateMachine ),
   115     iStateMachine( aStateMachine ),
   119     iViewCommandHandle( aViewCommandHandle ),
   116     iViewCommandHandle( aViewCommandHandle ),
   120     iCustomization( aCustomization )
   117     iCustomization( aCustomization ),
       
   118     iEnv( *CEikonEnv::Static() )
   121     {
   119     {
   122     // Need to get current SimState for inherited classis
   120     // Need to get current SimState for inherited classis
   123     iPreviousSimState = SimState();
   121     iPreviousSimState = SimState();
   124     __ASSERT_ALWAYS(
   122     __ASSERT_ALWAYS(
   125         aStateMachine && aViewCommandHandle,
   123         aStateMachine && aViewCommandHandle,
   189 
   187 
   190         case MEngineMonitor::EPEMessageAudioOutputChanged:
   188         case MEngineMonitor::EPEMessageAudioOutputChanged:
   191             HandleAudioOutputChangedL();
   189             HandleAudioOutputChangedL();
   192             // Go to current state implementation
   190             // Go to current state implementation
   193             iCbaManager->UpdateInCallCbaL();
   191             iCbaManager->UpdateInCallCbaL();
       
   192             SetTouchPaneButtons(0);
   194             break;
   193             break;
   195 
   194 
   196         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
   195         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
   197             HandleAudioAvailableOutputChangedL();
   196             HandleAudioAvailableOutputChangedL();
   198             if ( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPENotActive )
   197             if ( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPENotActive )
   199                 {
   198                 {
   200                 // Go to current state implementation
   199                 // Go to current state implementation
   201                 iCbaManager->UpdateInCallCbaL();
   200                 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             SendGlobalInfoNoteL( EPhoneWaitingText );
   214             // No need to send waiting notification for user.
       
   215             //SendGlobalInfoNoteL( EPhoneWaitingText, ETrue );
   215             break;
   216             break;
   216 
   217 
   217         case MEngineMonitor::EPEMessageProfileChanged:
   218         case MEngineMonitor::EPEMessageProfileChanged:
   218             {
   219             {
   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();
       
   229             }
   220             }
   230             break;
   221             break;
   231 
   222 
   232         case MEngineMonitor::EPEMessageRemoteTerminated:
   223         case MEngineMonitor::EPEMessageRemoteTerminated:
   233             // Close menu bar, if it is displayed, for call ending note
       
   234             iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   235             /* Flow through */
   224             /* Flow through */
   236         case MEngineMonitor::EPEMessageDisconnecting:
   225         case MEngineMonitor::EPEMessageDisconnecting:
   237             HandleDisconnectingL( aCallId );
   226             HandleDisconnectingL( aCallId );
   238             break;
   227             break;
   239 
   228 
   240         case MEngineMonitor::EPEMessageTransferDone:
   229         case MEngineMonitor::EPEMessageTransferDone:
   241             SendGlobalInfoNoteL( EPhoneInCallTransferred );
   230             SendGlobalInfoNoteL( EPhoneInCallTransferred, ETrue );
   242             break;
   231             break;
   243 
   232 
   244        case MEngineMonitor::EPEMessageInitiatedEmergencyCall:
   233        case MEngineMonitor::EPEMessageInitiatedEmergencyCall:
   245             HandleInitiatedEmergencyCallL( aCallId );
   234             HandleInitiatedEmergencyCallL( aCallId );
   246             break;
   235             break;
   247 
   236 
   248        case MEngineMonitor::EPEMessageInitiatedEmergencyWhileActiveVideo:
   237        case MEngineMonitor::EPEMessageInitiatedEmergencyWhileActiveVideo:
   249            HandleInitiatedEmergencyWhileActiveVideoL();
   238            HandleInitiatedEmergencyWhileActiveVideoL();
   250            break;
   239            break;
   251 
   240 
   252         case MEngineMonitor::EPEMessageShowIMEI:
   241        case MEngineMonitor::EPEMessageCallSecureStatusChanged:
   253             // Stop playing DTMF tone
   242            HandleCallSecureStatusChangeL( aCallId );
   254             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
   243 
   255             HandleShowImeiL();
   244            if ( iCustomization )
   256             break;
   245                {
   257 
   246                iCustomization->HandlePhoneEngineMessageL( aMessage,
   258         case MEngineMonitor::EPEMessageCallSecureStatusChanged:
   247                    aCallId );
   259             HandleCallSecureStatusChangeL( aCallId );
   248                }
   260             ForwardPEMessageToPhoneCustomizationL( aMessage, aCallId );
   249            break;
   261             break;
       
   262 
       
   263         case MEngineMonitor::EPEMessageActivateWarrantyMode:
       
   264             // Stop playing DTMF tone
       
   265             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   266             HandleShowLifeTimerL();
       
   267             break;
       
   268 
   250 
   269         case MEngineMonitor::EPEMessageIssuingUSSDRequest:
   251         case MEngineMonitor::EPEMessageIssuingUSSDRequest:
   270             {
   252             {
   271              // Enable global notes
   253              // Enable global notes
   272             TPhoneCmdParamBoolean globalNotifierParam;
   254             TPhoneCmdParamBoolean globalNotifierParam;
   361 
   343 
   362         case MEngineMonitor::EPEMessageShowIncCallGroupIndex:
   344         case MEngineMonitor::EPEMessageShowIncCallGroupIndex:
   363             HandleCugInUseNoteL();
   345             HandleCugInUseNoteL();
   364             break;
   346             break;
   365 
   347 
   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 
       
   379         default:
   348         default:
       
   349 
   380             TBool handled( EFalse );
   350             TBool handled( EFalse );
   381             handled = ForwardPEMessageToPhoneCustomizationL( aMessage, aCallId );
   351 
       
   352             if ( iCustomization )
       
   353                 {
       
   354                 handled = iCustomization->HandlePhoneEngineMessageL(
       
   355                                 aMessage, aCallId );
       
   356                 }
       
   357 
   382             if ( EFalse == handled )
   358             if ( EFalse == handled )
   383                 {
   359                 {
   384                 MPhoneMediatorMessage* mediatorMessage = CPhoneMediatorFactory::Instance()->MediatorMessage( aMessage, aCallId );
   360                 MPhoneMediatorMessage* mediatorMessage = CPhoneMediatorFactory::Instance()->MediatorMessage( aMessage, aCallId );
   385                 if( mediatorMessage )
   361                 if( mediatorMessage )
   386                     {
   362                     {
   409     TPhoneCmdParamBoolean booleanParam;
   385     TPhoneCmdParamBoolean booleanParam;
   410     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
   386     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
   411     booleanParam.SetBoolean( audioMute );
   387     booleanParam.SetBoolean( audioMute );
   412     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateMuteUIChanges,
   388     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateMuteUIChanges,
   413         &booleanParam );
   389         &booleanParam );
       
   390     
       
   391     SetTouchPaneButtons(0);
   414     }
   392     }
   415 
   393 
   416 // -----------------------------------------------------------
   394 // -----------------------------------------------------------
   417 // CPhoneState::HandleAudioOutputChangedL
   395 // CPhoneState::HandleAudioOutputChangedL
   418 // Default handling for EPEMessageAudioOutputChanged message
   396 // Default handling for EPEMessageAudioOutputChanged message
   452          !btAvailable )
   430          !btAvailable )
   453         {
   431         {
   454         CPhoneBtaaDisconnectHandler::InstanceL()->HandleConnectionLostL();
   432         CPhoneBtaaDisconnectHandler::InstanceL()->HandleConnectionLostL();
   455         }
   433         }
   456     else if ( audioOutput == EPEBTAudioAccessory && 
   434     else if ( audioOutput == EPEBTAudioAccessory && 
   457     		previousOutput > EPENotActive && 
   435             previousOutput != EPEBTAudioAccessory &&
   458     		previousOutput != EPEBTAudioAccessory &&
       
   459             btAvailable )
   436             btAvailable )
   460         {
   437         {
   461         CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
   438         CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
   462             iViewCommandHandle, iStateMachine, this );
   439             iViewCommandHandle, iStateMachine, this );
   463         bt->ShowBTActivatedL();
   440         bt->ShowBTActivatedL();
   469         CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
   446         CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
   470         }
   447         }
   471     else if ( RouteParameters.iShowNote && audioOutput == EPELoudspeaker )
   448     else if ( RouteParameters.iShowNote && audioOutput == EPELoudspeaker )
   472         {
   449         {
   473         CAknKeySoundSystem* keySounds =
   450         CAknKeySoundSystem* keySounds =
   474                static_cast<CAknAppUi*>( EikonEnv()->EikAppUi() )->KeySounds();
   451                static_cast<CAknAppUi*>( iEnv.EikAppUi() )->KeySounds();
   475         keySounds->PlaySound( EAvkonSIDIHFActive );
   452         keySounds->PlaySound( EAvkonSIDIHFActive );
   476         }
   453         }
   477     }
   454     }
   478 
   455 
   479 // -----------------------------------------------------------
   456 // -----------------------------------------------------------
   522                  iPreviousSimState == EPESimNotReady )
   499                  iPreviousSimState == EPESimNotReady )
   523                 {
   500                 {
   524                 __PHONELOG( EBasic, EPhoneControl, "SIM card was removed" );
   501                 __PHONELOG( EBasic, EPhoneControl, "SIM card was removed" );
   525 
   502 
   526                 TPhoneCmdParamGlobalNote globalNoteParam;
   503                 TPhoneCmdParamGlobalNote globalNoteParam;
   527                 globalNoteParam.SetType( EAknGlobalInformationNote );
   504                 globalNoteParam.SetType( EPhoneMessageBoxInformation );
   528                 globalNoteParam.SetTone( EAvkonSIDNoSound );
       
   529 
   505 
   530                 globalNoteParam.SetTextResourceId(
   506                 globalNoteParam.SetTextResourceId(
   531                     CPhoneMainResourceResolver::Instance()->
   507                     CPhoneMainResourceResolver::Instance()->
   532                     ResolveResourceID( EPhoneSimRemoved ) );
   508                     ResolveResourceID( EPhoneSimRemoved ) );
   533 
   509 
   616 // -----------------------------------------------------------------------------
   592 // -----------------------------------------------------------------------------
   617 //
   593 //
   618 TBool CPhoneState::IsTouchDTmfDialerOn() const
   594 TBool CPhoneState::IsTouchDTmfDialerOn() const
   619     {
   595     {
   620     TBool status( EFalse );
   596     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         }
       
   631     return status;
   597     return status;
   632     }
   598     }
   633 // -----------------------------------------------------------------------------
   599 // -----------------------------------------------------------------------------
   634 // CPhoneState::SendDtmfKeyEventL
   600 // CPhoneState::SendDtmfKeyEventL
   635 // send dtmf event when,
   601 // send dtmf event when,
   641 void CPhoneState::SendDtmfKeyEventL( const TKeyEvent& aKeyEvent,
   607 void CPhoneState::SendDtmfKeyEventL( const TKeyEvent& aKeyEvent,
   642                TEventCode aEventCode  )
   608                TEventCode aEventCode  )
   643     {
   609     {
   644 
   610 
   645     if ( !IsTouchDTmfDialerOn()
   611     if ( !IsTouchDTmfDialerOn()
   646         && !IsAnyQueryActiveL()
   612         && !IsAnyQueryActiveL() )
   647         && !IsMenuBarVisibleL() )
   613         {
   648         {
   614         // Send the key event to the phone engine.
   649         if( IsKeyEventFurtherProcessedL( aKeyEvent ))
   615         SendKeyEventL( aKeyEvent, aEventCode );
   650             {
   616         }
   651             // Send the key event to the phone engine.
       
   652             SendKeyEventL( aKeyEvent, aEventCode );
       
   653             }
       
   654         }
       
   655 
       
   656     }
   617     }
   657 
   618 
   658 // -----------------------------------------------------------------------------
   619 // -----------------------------------------------------------------------------
   659 // CPhoneState::IsKeyEventFurtherProcessed
   620 // CPhoneState::IsKeyEventFurtherProcessed
   660 // -----------------------------------------------------------------------------
   621 // -----------------------------------------------------------------------------
   661 //
   622 //
   662 TBool CPhoneState::IsKeyEventFurtherProcessedL( const TKeyEvent& aKeyEvent ) const
   623 TBool CPhoneState::IsKeyEventFurtherProcessedL( const TKeyEvent& /*aKeyEvent*/ ) const
   663     {
   624     {
   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 
       
   682     return ETrue;
   625     return ETrue;
   683     }
   626     }
   684 
   627 
   685 // -----------------------------------------------------------
   628 // -----------------------------------------------------------
   686 // CPhoneState::HandleErrorL
   629 // CPhoneState::HandleErrorL
   698 
   641 
   699     __PHONELOG1( EBasic, EPhoneControl,
   642     __PHONELOG1( EBasic, EPhoneControl,
   700         "PhoneUIControl: CPhoneState::HandleErrorL - aErrorInfo.iCallId =%d ",
   643         "PhoneUIControl: CPhoneState::HandleErrorL - aErrorInfo.iCallId =%d ",
   701         aErrorInfo.iCallId );
   644         aErrorInfo.iCallId );
   702 
   645 
   703 
       
   704     // Sets touch buttons to correct status if error has occured.
       
   705     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
   706         {
       
   707         iViewCommandHandle->ExecuteCommand( EPhoneResetTouchButtons );
       
   708         }
       
   709 
   646 
   710     // Do the common error handling (display proper notes etc)
   647     // Do the common error handling (display proper notes etc)
   711     CPhoneMainErrorMessagesHandler::Instance()->ShowErrorSpecificNoteL( aErrorInfo );
   648     CPhoneMainErrorMessagesHandler::Instance()->ShowErrorSpecificNoteL( aErrorInfo );
   712 
   649 
   713     switch( aErrorInfo.iErrorCode )
   650     switch( aErrorInfo.iErrorCode )
   737                     }
   674                     }
   738                 }
   675                 }
   739             }
   676             }
   740             break;
   677             break;
   741 
   678 
   742         case ECCPErrorCCServiceNotAvailable:
   679             case ECCPErrorCCServiceNotAvailable:
   743             {
       
   744             if( IsVideoCall( aErrorInfo.iCallId ) )
       
   745                 {
   680                 {
   746                 CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( EFalse );
   681                 if( IsVideoCall( aErrorInfo.iCallId ) )
       
   682                     {
       
   683                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( EFalse );
       
   684                     }
   747                 }
   685                 }
   748             }
   686                 break;
   749             break;
   687 
   750 
   688             case ECCPErrorBadRequest:
   751         case ECCPErrorBadRequest:
       
   752             {
       
   753             TPECallType callType =
       
   754                 iStateMachine->PhoneEngineInfo()->CallTypeCommand();
       
   755 
       
   756             if( callType == EPECallTypeVideo )
       
   757                 {
   689                 {
   758                     // Dialling MO video call cannot reach 3G network.
   690                 TPECallType callType =
   759                     __PHONELOG1( EBasic, EPhoneControl,
   691                     iStateMachine->PhoneEngineInfo()->CallTypeCommand();
   760                         "PhoneUIControl: CPhoneState::HandleErrorL - ShowReconnectQueryL vid 2, callid%d ",
   692 
   761                         aErrorInfo.iCallId );
   693                 if( callType == EPECallTypeVideo )
   762                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
   694                     {
       
   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                     }
   763                 }
   701                 }
   764             }
   702                 break;
   765             break;
   703 
   766 
   704         case ECCPErrorVideoCallNotSupportedByNetwork:
   767         case ECCPErrorVideoCallNotSupportedByNetwork: // Flow trough
       
   768         case ECCPErrorVideoCallSetupFailed:
   705         case ECCPErrorVideoCallSetupFailed:
   769         case ECCPErrorNotReached:
   706         case ECCPErrorNotReached:
   770         case ECCPErrorCCBearerCapabilityNotCurrentlyAvailable:
   707            // If call id found and seems to be Video Call
   771         case ECCPErrorCCBearerCapabilityNotAuthorised:
       
   772         case ECCPErrorServiceSettingError:
       
   773         case ECCPErrorNoAnswerForVideo:
       
   774             {
       
   775             // If call id found and seems to be Video Call
       
   776             if ( IsVideoCall( aErrorInfo.iCallId ) )
   708             if ( IsVideoCall( aErrorInfo.iCallId ) )
   777                 {
   709                 {
   778                 // Get active call count
   710                 // Get active call count
   779                 TPhoneCmdParamInteger activeCallCount;
   711                 TPhoneCmdParamInteger activeCallCount;
   780                 iViewCommandHandle->ExecuteCommandL(
   712                 iViewCommandHandle->ExecuteCommandL(
   792                     aErrorInfo.iCallId );
   724                     aErrorInfo.iCallId );
   793                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL(
   725                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL(
   794                               ECCPErrorNotReached == aErrorInfo.iErrorCode );
   726                               ECCPErrorNotReached == aErrorInfo.iErrorCode );
   795                     }
   727                     }
   796                 }
   728                 }
   797             }
       
   798             break;
   729             break;
   799 
   730 
   800         case ECCPErrorNoService:
   731         case ECCPErrorNoService:
   801             // No network -> hide volume popup
   732             // No network -> hide volume popup
   802             iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
   733             iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
   804 
   735 
   805         case ECCPErrorSatControl:
   736         case ECCPErrorSatControl:
   806             {
   737             {
   807             // check, that there really was a call established before completing SAT request
   738             // check, that there really was a call established before completing SAT request
   808             if( aErrorInfo.iCallId != KPECallIdNotUsed )
   739             if( aErrorInfo.iCallId != KPECallIdNotUsed )
   809                 {                
   740                 {
   810                 // Complete sat request
       
   811                 if ( iStateMachine->PhoneEngineInfo()->CallOrigin( aErrorInfo.iCallId ) == EPECallOriginSAT )
       
   812                     {
       
   813                     CompleteSatRequestL( aErrorInfo.iCallId );
       
   814                     }
       
   815                 }
   741                 }
   816 
   742 
   817             // remove number entry
   743             // remove number entry
   818             if ( !IsOnScreenDialerSupported() && IsNumberEntryUsedL() )
   744             if ( !IsOnScreenDialerSupported() && IsNumberEntryUsedL() )
   819                 {
   745                 {
   828             break;
   754             break;
   829 
   755 
   830         default:
   756         default:
   831             break;
   757             break;
   832         }
   758         }
       
   759 
   833     // clear call blacklist if call failure occurs
   760     // clear call blacklist if call failure occurs
   834     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   761     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   835     }
   762     }
   836 
   763 
   837 // -----------------------------------------------------------
   764 // -----------------------------------------------------------
   851     // Update only if the display is on or if HAL::Get returns an error, 
   778     // Update only if the display is on or if HAL::Get returns an error, 
   852     // in which case display value cannot be trusted.
   779     // in which case display value cannot be trusted.
   853     if ( ret || isDisplayOn )
   780     if ( ret || isDisplayOn )
   854         {
   781         {
   855         // Get the call duration
   782         // Get the call duration
   856         TTime time( 0 );
   783         TTimeIntervalSeconds seconds =
   857         TTimeIntervalSeconds timeInterval =
       
   858             iStateMachine->PhoneEngineInfo()->CallDuration( aCallId );
   784             iStateMachine->PhoneEngineInfo()->CallDuration( aCallId );
   859         time += timeInterval;
   785 
   860         
   786         TPhoneCmdParamInteger time;
   861         // Read format string from AVKON resource
   787         time.SetInteger(seconds.Int());
   862         TBuf<KPhoneMaxCharsInNote> timeDurationFormatString( KNullDesC );
   788         iViewCommandHandle->ExecuteCommandL(EPhoneViewUpdateCallHeaderCallDuration, aCallId, &time);
   863         LoadResource( timeDurationFormatString, EPhoneCallDurationFormatString );
   789         }
   864         
   790     }	
   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     }
       
   879 
   791 
   880 // -----------------------------------------------------------------------------
   792 // -----------------------------------------------------------------------------
   881 // CPhoneState::HandleRemoteBusyL
   793 // CPhoneState::HandleRemoteBusyL
   882 // -----------------------------------------------------------------------------
   794 // -----------------------------------------------------------------------------
   883 //
   795 //
   884 void CPhoneState::HandleRemoteBusyL( TInt aCallId )
   796 void CPhoneState::HandleRemoteBusyL( TInt aCallId )
   885     {
   797     {
   886     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleRemoteBusyL( ) ");
   798     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleRemoteBusyL( ) ");
   887     ShowNumberBusyNoteL();
   799 
   888 
   800     TPEErrorInfo info;
       
   801     info.iCallId = aCallId;
       
   802     info.iErrorCode = ECCPErrorBusy;
       
   803     info.iErrorType = EPECcp;
       
   804     CPhoneMainErrorMessagesHandler::Instance()->ShowErrorSpecificNoteL( info );
       
   805     
   889     const TPECallType callType =
   806     const TPECallType callType =
   890         iStateMachine->PhoneEngineInfo()->CallTypeCommand();
   807         iStateMachine->PhoneEngineInfo()->CallTypeCommand();
   891 
   808 
   892     if( callType == EPECallTypeVideo )
   809     if( callType == EPECallTypeVideo )
   893         {
   810         {
   895          __PHONELOG1( EBasic, EPhoneControl,
   812          __PHONELOG1( EBasic, EPhoneControl,
   896             "PhoneUIControl: CPhoneState::HandleRemoteBusyL - ShowReconnectQueryL vid 5, callid%d ",
   813             "PhoneUIControl: CPhoneState::HandleRemoteBusyL - ShowReconnectQueryL vid 5, callid%d ",
   897                 aCallId );
   814                 aCallId );
   898         CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
   815         CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
   899         }
   816         }
   900     else
       
   901         {        
       
   902         // Complete sat request
       
   903         if ( iStateMachine->PhoneEngineInfo()->CallOrigin( aCallId ) == EPECallOriginSAT )
       
   904             {
       
   905             CompleteSatRequestL( aCallId );
       
   906             }
       
   907         }
       
   908     }
   817     }
   909 
   818 
   910 // -----------------------------------------------------------
   819 // -----------------------------------------------------------
   911 // CPhoneState::HandleDisconnectingL
   820 // CPhoneState::HandleDisconnectingL
   912 // -----------------------------------------------------------
   821 // -----------------------------------------------------------
   913 //
   822 //
   914 EXPORT_C void CPhoneState::HandleDisconnectingL( TInt aCallId )
   823 EXPORT_C void CPhoneState::HandleDisconnectingL( TInt aCallId )
   915     {
   824     {
   916     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleDisconnectingL( ) ");
   825     __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         }
       
   926 
   826 
   927     TPhoneCmdParamCallHeaderData callHeaderParam;
   827     TPhoneCmdParamCallHeaderData callHeaderParam;
   928     callHeaderParam.SetCallState( EPEStateDisconnecting );
   828     callHeaderParam.SetCallState( EPEStateDisconnecting );
   929 
   829 
   930     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
   830     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
   933     callHeaderParam.SetLabelText( labelText );
   833     callHeaderParam.SetLabelText( labelText );
   934 
   834 
   935     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
   835     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
   936 
   836 
   937     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
   837     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
   938         &callHeaderParam );
   838         &callHeaderParam );    
   939 
   839 
   940     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   840     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   941     }
   841     }
   942 
   842 
   943 // -----------------------------------------------------------
   843 // -----------------------------------------------------------
  1038             }
   938             }
  1039         }
   939         }
  1040     }
   940     }
  1041 
   941 
  1042 // -----------------------------------------------------------
   942 // -----------------------------------------------------------
  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 // -----------------------------------------------------------
       
  1068 // CPhoneState::HandleNumericKeyEventL
   943 // CPhoneState::HandleNumericKeyEventL
  1069 // -----------------------------------------------------------
   944 // -----------------------------------------------------------
  1070 //
   945 //
  1071 EXPORT_C void CPhoneState::HandleNumericKeyEventL(
   946 EXPORT_C void CPhoneState::HandleNumericKeyEventL(
  1072     const TKeyEvent& aKeyEvent,
   947     const TKeyEvent& /*aKeyEvent*/,
  1073     TEventCode aEventCode )
   948     TEventCode /*aEventCode*/ )
  1074     {
   949     {
  1075     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleNumericKeyEventL( ) ");
   950     __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         }
       
  1089 
   951 
  1090     }
   952     }
  1091 
   953 
  1092 // -----------------------------------------------------------------------------
   954 // -----------------------------------------------------------------------------
  1093 // CPhoneState::IsAnyQueryActiveL
   955 // CPhoneState::IsAnyQueryActiveL
  1147     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsNoteDismissableL: %d ", dismiss );
  1009     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsNoteDismissableL: %d ", dismiss );
  1148     return dismiss;
  1010     return dismiss;
  1149     }
  1011     }
  1150 
  1012 
  1151 // -----------------------------------------------------------
  1013 // -----------------------------------------------------------
  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 // -----------------------------------------------------------
       
  1184 // CPhoneState::SendKeyEventL
  1014 // CPhoneState::SendKeyEventL
  1185 // -----------------------------------------------------------
  1015 // -----------------------------------------------------------
  1186 //
  1016 //
  1187 void CPhoneState::SendKeyEventL(
  1017 void CPhoneState::SendKeyEventL(
  1188     const TKeyEvent& aKeyEvent,
  1018     const TKeyEvent& aKeyEvent,
  1228         // Get the number entry contents, if it exists
  1058         // Get the number entry contents, if it exists
  1229         if ( IsNumberEntryUsedL() )
  1059         if ( IsNumberEntryUsedL() )
  1230             {
  1060             {
  1231             HBufC* phoneNumber = PhoneNumberFromEntryLC();
  1061             HBufC* phoneNumber = PhoneNumberFromEntryLC();
  1232             // Save the phone number
  1062             // Save the phone number
  1233             __PHONELOG1( EBasic, EPhoneControl, "SetPhoneNumber: %S ", &phoneNumber->Des() );
  1063             __PHONELOG1( EBasic, EPhoneControl, "SetPhoneNumber: %S ", phoneNumber );
  1234             iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
  1064             iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
  1235 
  1065 
  1236             // Convert key code to western.
  1066             // Convert key code to western.
  1237             TBuf<1> buffer; // one character
  1067             TBuf<1> buffer; // one character
  1238             buffer.Append( aKeyEvent.iCode );
  1068             buffer.Append( aKeyEvent.iCode );
  1257         }
  1087         }
  1258     }
  1088     }
  1259 
  1089 
  1260 // <------------------------------ SYSTEM EVENTS ----------------------------->
  1090 // <------------------------------ SYSTEM EVENTS ----------------------------->
  1261 
  1091 
  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     }
       
  1322 
  1092 
  1323 // -----------------------------------------------------------
  1093 // -----------------------------------------------------------
  1324 // CPhoneState::HandleSystemEventL
  1094 // CPhoneState::HandleSystemEventL
  1325 // -----------------------------------------------------------
  1095 // -----------------------------------------------------------
  1326 //
  1096 //
  1348 // CPhoneState::HandlePhoneForegroundEventL
  1118 // CPhoneState::HandlePhoneForegroundEventL
  1349 // -----------------------------------------------------------
  1119 // -----------------------------------------------------------
  1350 //
  1120 //
  1351 EXPORT_C void CPhoneState::HandlePhoneForegroundEventL()
  1121 EXPORT_C void CPhoneState::HandlePhoneForegroundEventL()
  1352     {
  1122     {
  1353     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneForegroundEventL( ) ");
  1123     }
  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      }
       
  1398 
  1124 
  1399 // -----------------------------------------------------------
  1125 // -----------------------------------------------------------
  1400 // CPhoneState::HandlePhoneFocusLostEventL
  1126 // CPhoneState::HandlePhoneFocusLostEventL
  1401 // -----------------------------------------------------------
  1127 // -----------------------------------------------------------
  1402 //
  1128 //
  1404     {
  1130     {
  1405     // Notify that this method is called always when Idle is brought to foreground
  1131     // Notify that this method is called always when Idle is brought to foreground
  1406     // See implementation in CPhoneAppUI::HandleWsEventL
  1132     // See implementation in CPhoneAppUI::HandleWsEventL
  1407 
  1133 
  1408     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneFocusLostEventL( ) ");
  1134     __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 );
       
  1420     }
  1135     }
  1421 // ---------------------------------------------------------
  1136 // ---------------------------------------------------------
  1422 // CPhoneState::HandleIdleForegroundEventL
  1137 // CPhoneState::HandleIdleForegroundEventL
  1423 // ---------------------------------------------------------
  1138 // ---------------------------------------------------------
  1424 //
  1139 //
  1470             "CPhoneState::HandlePropertyChangedL - aCategory= %d", aCategory  );
  1185             "CPhoneState::HandlePropertyChangedL - aCategory= %d", aCategory  );
  1471     __PHONELOG1( EBasic, EPhoneControl,
  1186     __PHONELOG1( EBasic, EPhoneControl,
  1472             "CPhoneState::HandlePropertyChangedL - aKey= %d", aKey  );
  1187             "CPhoneState::HandlePropertyChangedL - aKey= %d", aKey  );
  1473     __PHONELOG1( EBasic, EPhoneControl,
  1188     __PHONELOG1( EBasic, EPhoneControl,
  1474             "CPhoneState::HandlePropertyChangedL - aValue= %d", aValue  );
  1189             "CPhoneState::HandlePropertyChangedL - aValue= %d", aValue  );
  1475     if ( aCategory == KPSUidCtsyCallInformation )
  1190     if ( aCategory == KPSUidTelInformation
  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
       
  1487               && SimState() == EPESimUsable )
  1191               && SimState() == EPESimUsable )
  1488         {
  1192         {
  1489         // Telephony display event
  1193         // Telephony display event
  1490         if ( aKey == KTelDisplayInfo )
  1194         if ( aKey == KTelDisplayInfo )
  1491             {
  1195             {
  1495             }
  1199             }
  1496         }
  1200         }
  1497     else if ( aCategory == KPSUidStartup && aKey == KStartupSimSecurityStatus )
  1201     else if ( aCategory == KPSUidStartup && aKey == KStartupSimSecurityStatus )
  1498         {
  1202         {
  1499         // Show security note, SIM is not valid.
  1203         // Show security note, SIM is not valid.
  1500         if ( aValue == ESimRejected 
  1204         if ( aValue == ESimRejected ||  aValue == ESimUnaccepted )
  1501                 || aValue == ESimUnaccepted 
       
  1502                 || aValue == ESimInvalid )
       
  1503             {
  1205             {
  1504             __PHONELOG( EBasic, EPhoneControl, "CPhoneStateStartup::HandlePropertyChangedL - SimSecurity status received" );
  1206             __PHONELOG( EBasic, EPhoneControl, "CPhoneStateStartup::HandlePropertyChangedL - SimSecurity status received" );
  1505             StartShowSecurityNoteL();
  1207             StartShowSecurityNoteL();
  1506             }
  1208             }
  1507         }
  1209         }
  1521     {
  1223     {
  1522     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCenRepChangeL( ) ");
  1224     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCenRepChangeL( ) ");
  1523     }
  1225     }
  1524 
  1226 
  1525 // -----------------------------------------------------------
  1227 // -----------------------------------------------------------
  1526 // CPhoneState::NeedToReturnToForegroundAppL
  1228 // CPhoneState::NeedToSendToBackgroundL
  1527 // -----------------------------------------------------------
  1229 // -----------------------------------------------------------
  1528 //
  1230 //
  1529 EXPORT_C TBool CPhoneState::NeedToReturnToForegroundAppL() const
  1231 EXPORT_C TBool CPhoneState::NeedToSendToBackgroundL() const
  1530     {
  1232     {
  1531     return iViewCommandHandle->HandleCommandL(
  1233     return iViewCommandHandle->HandleCommandL(
  1532         EPhoneViewGetNeedToReturnToForegroundAppStatus ) ==
  1234         EPhoneViewGetNeedToSendToBackgroundStatus ) ==
  1533         EPhoneViewResponseSuccess;
  1235         EPhoneViewResponseSuccess;
  1534     }
  1236     }
  1535 
  1237 
  1536 // -----------------------------------------------------------
  1238 // -----------------------------------------------------------
  1537 // CPhoneState::TopAppIsDisplayedL
  1239 // CPhoneState::TopAppIsDisplayedL
  1543     return iViewCommandHandle->HandleCommandL(
  1245     return iViewCommandHandle->HandleCommandL(
  1544         EPhoneViewGetTopApplicationIsDisplayedStatus ) ==
  1246         EPhoneViewGetTopApplicationIsDisplayedStatus ) ==
  1545         EPhoneViewResponseSuccess;
  1247         EPhoneViewResponseSuccess;
  1546     }
  1248     }
  1547 
  1249 
  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 
       
  1560 // <---------------------------- MENU AND CBA EVENTS ------------------------->
  1250 // <---------------------------- MENU AND CBA EVENTS ------------------------->
  1561 
  1251 
  1562 EXPORT_C TBool CPhoneState::HandleCommandL( TInt aCommand )
  1252 EXPORT_C TBool CPhoneState::HandleCommandL( TInt aCommand )
  1563     {
  1253     {
  1564     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCommandL( ) ");
  1254     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCommandL( ) ");
  1565     TBool commandStatus = ETrue;
  1255     TBool commandStatus = ETrue;
  1566     switch( aCommand )
  1256     switch( aCommand )
  1567         {
  1257         {
  1568         case EPhoneEmergencyCmdExit:
  1258         case EPhoneEmergencyCmdExit:
       
  1259             {
       
  1260             }
  1569             // this should be bypasses?
  1261             // this should be bypasses?
  1570         case EPhoneDialerCallHandling:
  1262         case EPhoneDialerCallHandling:
  1571         case EPhoneCmdBack:
  1263         case EPhoneCmdBack:
  1572             CloseClearNumberEntryAndLoadEffectL( ECallUiAppear );
  1264             // Remove number entry from screen
       
  1265             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1266             // Do state-specific behaviour if number entry is cleared
       
  1267             HandleNumberEntryClearedL();
  1573             break;
  1268             break;
  1574 
  1269 
  1575         case EPhoneDialerCmdTouchInput:
  1270         case EPhoneDialerCmdTouchInput:
  1576             OpenVkbL();
       
  1577             break;
  1271             break;
  1578 
  1272 
  1579         case EPhoneNumberAcqCmdSendMessage:
  1273         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                 }
       
  1590             break;
  1274             break;
  1591 
  1275 
  1592         case EPhoneNumberAcqCmdSave:
  1276         case EPhoneNumberAcqCmdSave:
  1593             // Open Create contact
       
  1594             iViewCommandHandle->ExecuteCommandL(
       
  1595                 EPhoneViewAddContact );
       
  1596             break;
  1277             break;
  1597 
  1278 
  1598         case EPhoneNumberAcqCmdAddToName:
  1279         case EPhoneNumberAcqCmdAddToName:
  1599             // Open the message editor
       
  1600             iViewCommandHandle->ExecuteCommandL(
       
  1601                 EPhoneViewUpdateContact );
       
  1602             break;
  1280             break;
  1603 
  1281 
  1604         case EPhoneNumberAcqCmdAddToContacts:
  1282         case EPhoneNumberAcqCmdAddToContacts:
  1605             {
  1283             {
  1606             if ( IsOnScreenDialerSupported() )
  1284             if ( IsOnScreenDialerSupported() )
  1669                  aCommand == EPhoneInCallCmdBtHandsfree );
  1347                  aCommand == EPhoneInCallCmdBtHandsfree );
  1670             break;
  1348             break;
  1671 
  1349 
  1672         case EPhoneInCallCmdActivatEPhonebook:
  1350         case EPhoneInCallCmdActivatEPhonebook:
  1673             {
  1351             {
  1674             // Launch Phonebook application
  1352             }
  1675             TPhoneCmdParamAppInfo appInfoParam;
  1353             break;
  1676             appInfoParam.SetAppUid( KPhoneUidAppPhonebook );
  1354 
  1677             iViewCommandHandle->ExecuteCommandL(
  1355         case EPhoneNumberAcqSecurityDialer:
  1678                 EPhoneViewActivateApp, &appInfoParam );
  1356             {
  1679             }
  1357 
  1680             break;
  1358             }
  1681 
  1359             break;
  1682         case EPhoneViewYesSingleItemFetch:
  1360 
  1683             {
  1361         case EPhoneDialerCmdContacts:
  1684             if ( IsOnScreenDialerSupported() )
  1362             {
  1685                 {
  1363             }
  1686                 TBuf<KPhoneNumberEntryBufferSize> fetchContent;
  1364             break;
  1687                 fetchContent = iViewCommandHandle->FetchContent();
  1365 
  1688                 if ( fetchContent.Length() )
       
  1689                     {
       
  1690                     iViewCommandHandle->ExecuteCommandL(
       
  1691                                             EPhoneViewSetNumberEntryContent,
       
  1692                                             0,
       
  1693                                             fetchContent );
       
  1694 
       
  1695                     CallFromNumberEntryL();
       
  1696                     }
       
  1697                 }
       
  1698             }
       
  1699             break;
       
  1700         case EPhoneNumberAcqCmdToggleNeAlphaMode:
  1366         case EPhoneNumberAcqCmdToggleNeAlphaMode:
  1701         case EPhoneNumberAcqCmdToggleNeNumericMode:
  1367         case EPhoneNumberAcqCmdToggleNeNumericMode:
  1702             {
  1368             {
  1703             // Toggle mode
  1369 
  1704             NumberEntryManagerL()->NumberEntryToggleAlphaNumericModeL();
       
  1705             }
  1370             }
  1706             break;
  1371             break;
  1707 
  1372 
  1708         case EPhoneCmdYesVideoFailedNoMemorySwitchToVoice:
  1373         case EPhoneCmdYesVideoFailedNoMemorySwitchToVoice:
  1709             DialVoiceCallL();
  1374             DialVoiceCallL();
  1713             if ( IsNumberEntryUsedL() )
  1378             if ( IsNumberEntryUsedL() )
  1714                 {
  1379                 {
  1715                 // Show the number entry if it exists
  1380                 // Show the number entry if it exists
  1716                 SetNumberEntryVisibilityL(ETrue);
  1381                 SetNumberEntryVisibilityL(ETrue);
  1717                 }
  1382                 }
  1718             else if ( NeedToReturnToForegroundAppL() )
  1383             else if ( NeedToSendToBackgroundL() )
  1719                 {
  1384                 {
  1720                 // Continue displaying current app but set up the
  1385                 // Continue displaying current app but set up the
  1721                 // idle screen in the background
  1386                 // idle screen in the background
  1722                 SetupIdleScreenInBackgroundL();
  1387                 SetupIdleScreenInBackgroundL();
  1723                 }
  1388                 }
  1734             // value to control (second parameter set false).
  1399             // value to control (second parameter set false).
  1735             ChangeAudioVolumeL( GetVolumeLevel(), EFalse );
  1400             ChangeAudioVolumeL( GetVolumeLevel(), EFalse );
  1736             }
  1401             }
  1737             break;
  1402             break;
  1738 
  1403 
  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 
       
  1749         case EPhoneCmdVideoCallOutOfMemory:
  1404         case EPhoneCmdVideoCallOutOfMemory:
  1750             ShowVideoCallOutOfMemoryNoteL();
  1405             ShowVideoCallOutOfMemoryNoteL();
  1751             DisconnectCallL();
  1406             DisconnectCallL();
  1752             break;
  1407             break;
  1753 
  1408             
  1754         case EPhoneCmdUpdateCba:
  1409         case EPhoneCallComingCmdSoftReject:
  1755         case EPhoneDialerValidNumber:
  1410             // Open Soft reject message editor
  1756         case EPhoneDialerInvalidNumber:
  1411             OpenSoftRejectMessageEditorL();
  1757         case EPhoneCmdBlockingDialogLaunched:
  1412             break;
  1758         case EPhoneCmdBlockingDialogClosed:
  1413             
  1759             {
  1414         case EPhoneInCallCmdContacts:
  1760             // these command ids are sent by easydialing to communicate to phone app
  1415             iViewCommandHandle->ExecuteCommand( EPhoneViewOpenContacts );
  1761             HandleEasyDialingCommandsL( aCommand );
  1416             break;
  1762             }
  1417             
  1763             break;
       
  1764                 
       
  1765         default:
  1418         default:
  1766             if ( IsOnScreenDialerSupported() )
  1419 
       
  1420             /*if ( IsOnScreenDialerSupported() )
  1767                 {
  1421                 {
  1768                 // Offer command to view.
  1422                 // Offer command to view.
  1769                 // Easydialing commands are handled in view, too.
       
  1770                 TPhoneViewResponseId resId =
  1423                 TPhoneViewResponseId resId =
  1771                             iViewCommandHandle->HandleCommandL( aCommand );
  1424                             iViewCommandHandle->HandleCommandL( aCommand );
  1772 
  1425 
  1773                 if( resId == EPhoneViewResponseFailed )
  1426                 if( resId == EPhoneViewResponseFailed )
  1774                     {
  1427                     {
  1775                      commandStatus = EFalse;
  1428                     commandStatus = EFalse;
  1776                     }
  1429                     }
  1777                 }
  1430                 }
  1778             else
  1431             else*/
       
  1432 
  1779                 {
  1433                 {
  1780                 commandStatus = EFalse;
  1434                 commandStatus = EFalse;
  1781                 }
  1435                 }
  1782             break;
  1436             break;
  1783         }
  1437         }
  1794 // CPhoneState::ProcessCommandL
  1448 // CPhoneState::ProcessCommandL
  1795 // -----------------------------------------------------------------------------
  1449 // -----------------------------------------------------------------------------
  1796 //
  1450 //
  1797 EXPORT_C TBool CPhoneState::ProcessCommandL( TInt /*aCommand*/ )
  1451 EXPORT_C TBool CPhoneState::ProcessCommandL( TInt /*aCommand*/ )
  1798     {
  1452     {
  1799     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::ProcessCommandL() ");
  1453     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::ProcessCommandL() ");
  1800     // no implementation.
  1454     // no implementation.
  1801     return EFalse;
  1455     return EFalse;
  1802     }
  1456     }
  1803 
  1457 
  1804 // <-------------------------- REMOTE CONTROL EVENTS ------------------------->
  1458 // <-------------------------- REMOTE CONTROL EVENTS ------------------------->
  1860 
  1514 
  1861     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
  1515     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
  1862      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::DecreaseAudioVolumeL - audio output =%d", output );
  1516      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::DecreaseAudioVolumeL - audio output =%d", output );
  1863     if( output == EPETTY )
  1517     if( output == EPETTY )
  1864         {
  1518         {
  1865         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl );
  1519         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl, ETrue );
  1866         }
  1520         }
  1867     else
  1521     else
  1868         {
  1522         {
  1869         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
  1523         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
  1870         audioVolume--;
  1524         audioVolume--;
  1884 
  1538 
  1885     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
  1539     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
  1886      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IncreaseAudioVolumeL - audio output =%d", output );
  1540      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IncreaseAudioVolumeL - audio output =%d", output );
  1887     if( output == EPETTY )
  1541     if( output == EPETTY )
  1888         {
  1542         {
  1889         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl );
  1543         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl, ETrue );
  1890         }
  1544         }
  1891     else
  1545     else
  1892         {
  1546         {
  1893         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
  1547         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
  1894         audioVolume++;
  1548         audioVolume++;
  1914         // Syncronizes audio volume level between engine and ui
  1568         // Syncronizes audio volume level between engine and ui
  1915         // causes EPEMessageAudioVolumeChanged message to phoneUI
  1569         // causes EPEMessageAudioVolumeChanged message to phoneUI
  1916         iStateMachine->SendPhoneEngineMessage(
  1570         iStateMachine->SendPhoneEngineMessage(
  1917             MPEPhoneModel::EPEMessageSetAudioVolume );
  1571             MPEPhoneModel::EPEMessageSetAudioVolume );
  1918         }
  1572         }
  1919     else
  1573         
  1920         {
  1574     if ( aUpdateControl )        
  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 )
       
  1940         {
  1575         {
  1941         // Update the volume display.
  1576         // Update the volume display.
  1942         // Upper max (11) and under min (-1)
  1577         // Upper max (11) and under min (-1)
  1943         // values are also updated to volume popup.
  1578         // values are also updated to volume popup.
  1944         TPhoneCmdParamInteger volumeParam;
  1579         TPhoneCmdParamInteger volumeParam;
  1971 EXPORT_C void CPhoneState::DialVoiceCallL()
  1606 EXPORT_C void CPhoneState::DialVoiceCallL()
  1972     {
  1607     {
  1973     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialVoiceCallL() ");
  1608     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialVoiceCallL() ");
  1974     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
  1609     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
  1975         Panic( EPhoneCtrlInvariant ) );
  1610         Panic( EPhoneCtrlInvariant ) );
       
  1611 
  1976     // Disable global notes
  1612     // Disable global notes
  1977     TPhoneCmdParamBoolean globalNotifierParam;
  1613     TPhoneCmdParamBoolean globalNotifierParam;
  1978     globalNotifierParam.SetBoolean( ETrue );
  1614     globalNotifierParam.SetBoolean( ETrue );
  1979     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1615     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1980             &globalNotifierParam );
  1616             &globalNotifierParam );
  1981     iStateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeCSVoice );
  1617    iStateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeCSVoice );
  1982     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
  1618     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
  1983     }
  1619     }
  1984 
  1620 
  1985 // -----------------------------------------------------------
  1621 // -----------------------------------------------------------
  1986 // CPhoneState::DisconnectCallL
  1622 // CPhoneState::DisconnectCallL
  1987 // -----------------------------------------------------------
  1623 // -----------------------------------------------------------
  1988 //
  1624 //
  1989 EXPORT_C void CPhoneState::DisconnectCallL()
  1625 EXPORT_C TBool CPhoneState::DisconnectCallL()
  1990     {
  1626     {
  1991     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
  1627     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
  1992     // Fetch active call's id from view
  1628     TPhoneCmdParamInteger callIdParam;
  1993     TPhoneCmdParamCallStateData callStateData;
  1629     iViewCommandHandle->ExecuteCommandL( 
  1994     callStateData.SetCallState( EPEStateConnected );
  1630             EPhoneViewGetExpandedBubbleCallId, &callIdParam );
  1995     iViewCommandHandle->HandleCommandL(
  1631 
  1996         EPhoneViewGetCallIdByState, &callStateData );
  1632     TBool ret = EFalse;
  1997 
  1633     if( callIdParam.Integer() > KErrNotFound )
  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 )
       
  2031         {
  1634         {
  2032         // Release the call
  1635         // Release the call
  2033         iStateMachine->SetCallId( callStateData.CallId() );
  1636         iStateMachine->SetCallId( callIdParam.Integer() );
  2034         if( IsVideoCall( callStateData.CallId() ) )
  1637 
       
  1638         if( IsVideoCall( callIdParam.Integer() ) )
  2035             {
  1639             {
  2036             // Video call can be released only after we get response to VT Shutdown Command
  1640             // Video call can be released only after we get response to VT Shutdown Command
  2037             CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
  1641             CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
  2038 			                                                           			 KCatPhoneToVideotelCommands,
  1642                                                                                  KCatPhoneToVideotelCommands,
  2039 			                                                           			 EVtCmdReleaseDataport,
  1643                                                                                  EVtCmdReleaseDataport,
  2040                                                                        TVersion( KPhoneToVideotelCmdVersionMajor,
  1644                                                                        TVersion( KPhoneToVideotelCmdVersionMajor,
  2041                               	                                                 KPhoneToVideotelCmdVersionMinor,
  1645                                                                                  KPhoneToVideotelCmdVersionMinor,
  2042                               	                                                 KPhoneToVideotelCmdVersionBuild ),
  1646                                                                                  KPhoneToVideotelCmdVersionBuild ),
  2043                                                                        KNullDesC8,
  1647                                                                        KNullDesC8,
  2044                                                                        CPhoneReleaseCommand::NewL( *iStateMachine ) );
  1648                                                                        CPhoneReleaseCommand::NewL( *iStateMachine ) );
  2045             }
  1649             }
  2046         else
  1650         else
  2047             {
  1651             {
  2048             // Release the call
  1652             // Release the call
  2049             iStateMachine->SendPhoneEngineMessage(
  1653             iStateMachine->SendPhoneEngineMessage(
  2050                 MPEPhoneModel::EPEMessageRelease );
  1654                 MPEPhoneModel::EPEMessageRelease );
  2051             }
  1655             }
       
  1656         ret = ETrue;
  2052         }
  1657         }
  2053     else
  1658     else
  2054         {
  1659         {
  2055         __PHONELOG( EOnlyFatal, EPhoneControl,
  1660         __PHONELOG( EOnlyFatal, EPhoneControl,
  2056             "CPhoneState::DisconnectCallL has negative call id!" );
  1661             "CPhoneState::DisconnectCallL has negative call id!" );
  2057         }   
  1662         }
  2058    }
  1663 
       
  1664     return ret;
       
  1665     }
  2059 
  1666 
  2060 // -----------------------------------------------------------
  1667 // -----------------------------------------------------------
  2061 // CPhoneState::DisplayIdleScreenL
  1668 // CPhoneState::DisplayIdleScreenL
  2062 // -----------------------------------------------------------
  1669 // -----------------------------------------------------------
  2063 //
  1670 //
  2086     {
  1693     {
  2087     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetupIdleScreenInBackgroundL( ) ");
  1694     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetupIdleScreenInBackgroundL( ) ");
  2088     // Don't remove reconnect query if it's shown
  1695     // Don't remove reconnect query if it's shown
  2089     if( !CPhoneReconnectQuery::InstanceL()->IsDisplayingQuery() )
  1696     if( !CPhoneReconnectQuery::InstanceL()->IsDisplayingQuery() )
  2090         {
  1697         {
       
  1698         // Remove dialogs if necessary
  2091         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  1699         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  2092         }
  1700         }
  2093     // Return phone to the background
  1701     // Return phone to the background
  2094     iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
  1702     iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
  2095     // Set Idle app as the top app to PS key this way we know if need to 
  1703 
  2096     // bring idle to fore in next phone acitvation event.
  1704     // Set Idle app as the top app
  2097     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIdleTopApplication );
  1705     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIdleTopApplication );
       
  1706 
       
  1707     // Set Empty CBA
  2098     iCbaManager->SetCbaL( EPhoneEmptyCBA );
  1708     iCbaManager->SetCbaL( EPhoneEmptyCBA );
  2099     }
  1709     }
  2100 
  1710 
  2101 // ---------------------------------------------------------
  1711 // ---------------------------------------------------------
  2102 // CPhoneState::CallFromNumberEntryL
  1712 // CPhoneState::CallFromNumberEntryL
  2108     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
  1718     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
  2109         Panic( EPhoneCtrlInvariant ) );
  1719         Panic( EPhoneCtrlInvariant ) );
  2110 
  1720 
  2111     if ( IsOnScreenDialerSupported() )
  1721     if ( IsOnScreenDialerSupported() )
  2112         {
  1722         {
  2113         if ( IsDTMFEditorVisibleL() ||
  1723         if ( IsCustomizedDialerVisibleL() )
  2114              IsCustomizedDialerVisibleL() )
       
  2115             {
  1724             {
  2116             return;
  1725             return;
  2117             }
  1726             }
  2118 
  1727 
  2119         else if( IsNumberEntryUsedL() )
  1728         else if( IsNumberEntryUsedL() )
  2120             {
  1729             {
  2121             // Query on top of dialer
  1730             // Query on top of dialer
  2122             if ( IsAnyQueryActiveL() )
  1731             if ( IsAnyQueryActiveL() )
  2123                 {
  1732                 {
  2124                 return;
       
  2125                 }
       
  2126             else if ( IsMenuBarVisibleL() )
       
  2127                 {
       
  2128                 iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
  2129                 return;
  1733                 return;
  2130                 }
  1734                 }
  2131             // Open recent calls list when the number entry is empty
  1735             // Open recent calls list when the number entry is empty
  2132             TPhoneCmdParamInteger numberEntryCountParam;
  1736             TPhoneCmdParamInteger numberEntryCountParam;
  2133             iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
  1737             iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
  2141                 EPhoneDialerCmdLog );
  1745                 EPhoneDialerCmdLog );
  2142                 return;
  1746                 return;
  2143                 }
  1747                 }
  2144             }
  1748             }
  2145         }
  1749         }
  2146     
  1750 
  2147     // If easydialing has focus, call should be initiated to focused contact.
  1751     // Get the number entry contents
  2148     if ( IsDialingExtensionInFocusL() )
  1752     HBufC* phoneNumber = PhoneNumberFromEntryLC();
  2149         {
  1753 
  2150         iViewCommandHandle->HandleCommandL( EEasyDialingVoiceCall );
  1754     // Call the number
  2151         }
  1755     iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
  2152     else
  1756 
  2153         {  
  1757     if ( phoneNumber->Des().Length() < KPhoneValidPhoneNumberLength )
  2154         // Get the number entry contents
  1758         {
  2155         HBufC* phoneNumber = PhoneNumberFromEntryLC();
  1759         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
  2156         
  1760 
  2157         // Call the number
  1761         HandleNumberEntryClearedL();
  2158         iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
  1762         }
  2159     
  1763 
  2160         if ( phoneNumber->Des().Length() < KPhoneValidPhoneNumberLength )
  1764     CleanupStack::PopAndDestroy( phoneNumber );
  2161             {
  1765 
  2162             CloseClearNumberEntryAndLoadEffectL( ECallUiAppear );
  1766     if ( !iCustomization ||
  2163             }
  1767          !iCustomization->HandleCallFromNumberEntryL() )
  2164     
  1768         {
  2165         CleanupStack::PopAndDestroy( phoneNumber );        
  1769         // Customization didn't handle call. Dial voice call
  2166     
  1770         // as normally
  2167         if ( !iCustomization || 
  1771         DialVoiceCallL();
  2168              !iCustomization->HandleCallFromNumberEntryL() )
  1772         }
  2169             {
  1773 
  2170             // Customization didn't handle call. Dial voice call
       
  2171             // as normally
       
  2172             DialVoiceCallL();
       
  2173             }
       
  2174         }
       
  2175     
       
  2176     }
  1774     }
  2177 
  1775 
  2178 // -----------------------------------------------------------
  1776 // -----------------------------------------------------------
  2179 // CPhoneState::DisplayHeaderForCallComingInL
  1777 // CPhoneState::DisplayHeaderForCallComingInL
  2180 // -----------------------------------------------------------
  1778 // -----------------------------------------------------------
  2216 // -----------------------------------------------------------
  1814 // -----------------------------------------------------------
  2217 //
  1815 //
  2218 EXPORT_C void CPhoneState::UpdateSingleActiveCallL( TInt aCallId )
  1816 EXPORT_C void CPhoneState::UpdateSingleActiveCallL( TInt aCallId )
  2219     {
  1817     {
  2220     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateSingleActiveCallL( ) ");
  1818     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateSingleActiveCallL( ) ");
       
  1819 
  2221     // Stop capturing keys
  1820     // Stop capturing keys
  2222     CaptureKeysDuringCallNotificationL( EFalse );
  1821     CaptureKeysDuringCallNotificationL( EFalse );
       
  1822 
  2223     BeginUiUpdateLC();
  1823     BeginUiUpdateLC();
  2224 
       
  2225     SetTouchPaneButtonEnabled( EPhoneInCallCmdHold );
       
  2226 
  1824 
  2227     // Update call state
  1825     // Update call state
  2228     TPhoneCmdParamCallHeaderData callHeaderParam;
  1826     TPhoneCmdParamCallHeaderData callHeaderParam;
  2229     callHeaderParam.SetCallState( EPEStateConnected );
  1827     callHeaderParam.SetCallState( EPEStateConnected );
  2230     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
  1828     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
  2232 
  1830 
  2233     // Update remote info data
  1831     // Update remote info data
  2234     UpdateRemoteInfoDataL( aCallId );
  1832     UpdateRemoteInfoDataL( aCallId );
  2235 
  1833 
  2236     // Create call duration label if enabled
  1834     // 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.
  2237     TBool callDuration( EFalse );
  1837     TBool callDuration( EFalse );
  2238     CPhoneCenRepProxy::Instance()->GetInt(
  1838     CPhoneCenRepProxy::Instance()->GetInt(
  2239             KCRUidLogs, KLogsShowCallDuration, callDuration );
  1839             KCRUidLogs, KLogsShowCallDuration, callDuration );
  2240 
  1840 
  2241     if ( callDuration )
  1841     if ( callDuration )
  2246     EndUiUpdate();
  1846     EndUiUpdate();
  2247 
  1847 
  2248      // Go to current state implementation
  1848      // Go to current state implementation
  2249     iCbaManager->UpdateInCallCbaL();
  1849     iCbaManager->UpdateInCallCbaL();
  2250 
  1850 
  2251     //Update state of switch to video or voice call touch button.
  1851     // Go to background if necessary
  2252     TPECallType type = iStateMachine->PhoneEngineInfo()->CallType( aCallId );
  1852     if ( NeedToSendToBackgroundL() ||  IsAutoLockOn() )
  2253 
  1853         {
  2254     if( type == EPECallTypeVideo )
  1854         }
  2255         {
  1855     // If there is no need to send back ground and number entry is used then
  2256         TPhoneCmdParamBoolean booleanParam;
  1856     // we must show number entry.
  2257         booleanParam.SetBoolean( ETrue );
  1857     else if ( !NeedToSendToBackgroundL() && IsNumberEntryUsedL() )
  2258         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetVideoCallFlag, &booleanParam );
  1858         {
  2259         }
  1859         SetNumberEntryVisibilityL(ETrue);
  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            }
       
  2276         }
  1860         }
  2277     }
  1861     }
  2278 
  1862 
  2279 // -----------------------------------------------------------
  1863 // -----------------------------------------------------------
  2280 // CPhoneState::CaptureKeysDuringCallNotificationL
  1864 // CPhoneState::CaptureKeysDuringCallNotificationL
  2281 // -----------------------------------------------------------
  1865 // -----------------------------------------------------------
  2282 //
  1866 //
  2283 EXPORT_C void CPhoneState::CaptureKeysDuringCallNotificationL(
  1867 EXPORT_C void CPhoneState::CaptureKeysDuringCallNotificationL(
  2284     TBool aCaptured )
  1868     TBool /*aCaptured*/ )
  2285     {
  1869     {
  2286     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CaptureKeysDuringCallNotificationL( ) ");
  1870     __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 
       
  2296     // Determine which view command to execute based on the capture status
  1871     // Determine which view command to execute based on the capture status
  2297     const TInt viewCommandId = aCaptured ?
  1872     /*const TInt viewCommandId = aCaptured ?
  2298         EPhoneViewStartCapturingKey :
  1873         EPhoneViewStartCapturingKey :
  2299         EPhoneViewStopCapturingKey;
  1874         EPhoneViewStopCapturingKey;
  2300 
  1875 
  2301     // Capture the App key
  1876     // Capture the App key
  2302     TPhoneCmdParamKeyCapture appKeyCaptureParam;
  1877     TPhoneCmdParamKeyCapture appKeyCaptureParam;
  2312         cameraKeyCaptureParam.SetKey( EStdKeyDevice7 );
  1887         cameraKeyCaptureParam.SetKey( EStdKeyDevice7 );
  2313         cameraKeyCaptureParam.SetKeyCode( EKeyDevice7 );
  1888         cameraKeyCaptureParam.SetKeyCode( EKeyDevice7 );
  2314         cameraKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
  1889         cameraKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
  2315         iViewCommandHandle->ExecuteCommandL( viewCommandId,
  1890         iViewCommandHandle->ExecuteCommandL( viewCommandId,
  2316             &cameraKeyCaptureParam );
  1891             &cameraKeyCaptureParam );
  2317         }
  1892         }*/
  2318     }
  1893     }
  2319 
  1894 
  2320 // -----------------------------------------------------------
  1895 // -----------------------------------------------------------
  2321 // CPhoneState::IsWaitingCallL
  1896 // CPhoneState::IsWaitingCallL
  2322 // -----------------------------------------------------------
  1897 // -----------------------------------------------------------
  2347     TPhoneCmdParamCallHeaderData callHeaderParam = UpdateCallHeaderInfoL( aCallId );
  1922     TPhoneCmdParamCallHeaderData callHeaderParam = UpdateCallHeaderInfoL( aCallId );
  2348 
  1923 
  2349     if( iCustomization )
  1924     if( iCustomization )
  2350         {
  1925         {
  2351         TBuf<KCntMaxTextFieldLength> inCallNumberText( KNullDesC );
  1926         TBuf<KCntMaxTextFieldLength> inCallNumberText( KNullDesC );
  2352         // incall number text could be 'Call 1', 'Call 2', ...
  1927 
  2353         CallheaderManagerL()->GetInCallNumberTextL( aCallId, inCallNumberText );
       
  2354         // to check if we have VoIP call in question and fix
  1928         // to check if we have VoIP call in question and fix
  2355         // parameters if needed
  1929         // parameters if needed
  2356         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
  1930         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
  2357             inCallNumberText );
  1931             inCallNumberText );
  2358         }
  1932         }
  2368 // -----------------------------------------------------------
  1942 // -----------------------------------------------------------
  2369 // CPhoneState::SetCallHeaderType
  1943 // CPhoneState::SetCallHeaderType
  2370 // -----------------------------------------------------------
  1944 // -----------------------------------------------------------
  2371 //
  1945 //
  2372 EXPORT_C void CPhoneState::SetCallHeaderType(
  1946 EXPORT_C void CPhoneState::SetCallHeaderType(
  2373     const CBubbleManager::TPhoneCallTypeFlags aCallHeaderType )
  1947     TInt aCallHeaderType )
  2374     {
  1948     {
  2375     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetCallHeaderType() ");
  1949     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetCallHeaderType() ");
  2376     TRAP_IGNORE( CallheaderManagerL()->SetCallHeaderType( aCallHeaderType ) );
  1950     TRAP_IGNORE( CallheaderManagerL()->SetCallHeaderType( aCallHeaderType ) );
  2377     }
  1951     }
  2378 
  1952 
  2409     if ( incomingCall > KErrNotFound )
  1983     if ( incomingCall > KErrNotFound )
  2410         {
  1984         {
  2411        if( activeCallCount.Integer() == ENoActiveCalls )
  1985        if( activeCallCount.Integer() == ENoActiveCalls )
  2412             {
  1986             {
  2413             iCbaManager->UpdateIncomingCbaL( incomingCall );
  1987             iCbaManager->UpdateIncomingCbaL( incomingCall );
  2414             UpdateSilenceButtonDimming();
       
  2415             }
  1988             }
  2416         else
  1989         else
  2417             {
  1990             {
  2418             iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
  1991             iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
  2419             }
  1992             }
  2444         return EFalse;
  2017         return EFalse;
  2445         }
  2018         }
  2446     }
  2019     }
  2447 
  2020 
  2448 // <-------------------------- CONTEXT MENU ------------------------->
  2021 // <-------------------------- 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     }
       
  2498 
  2022 
  2499 // -----------------------------------------------------------
  2023 // -----------------------------------------------------------
  2500 // CPhoneState::ShowNoteL
  2024 // CPhoneState::ShowNoteL
  2501 // -----------------------------------------------------------
  2025 // -----------------------------------------------------------
  2502 //
  2026 //
  2598         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString );
  2122         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString );
  2599 
  2123 
  2600         noteText.Append( timeString );
  2124         noteText.Append( timeString );
  2601 
  2125 
  2602         TPhoneCmdParamGlobalNote globalNoteParam;
  2126         TPhoneCmdParamGlobalNote globalNoteParam;
  2603         globalNoteParam.SetType( EAknGlobalInformationNote );
  2127         globalNoteParam.SetType( EPhoneMessageBoxInformation );
  2604         globalNoteParam.SetText( noteText );
  2128         globalNoteParam.SetText( noteText );
  2605         globalNoteParam.SetTone( CAknNoteDialog::ENoTone );
  2129 
  2606         iViewCommandHandle->ExecuteCommandL(
  2130         iViewCommandHandle->ExecuteCommandL(
  2607             EPhoneViewShowGlobalNote, &globalNoteParam );
  2131             EPhoneViewShowGlobalNote, &globalNoteParam );
  2608         }
  2132         }
  2609     }
  2133     }
  2610 
  2134 
  2611 // ---------------------------------------------------------
  2135 // ---------------------------------------------------------
  2612 // CPhoneState::SendGlobalInfoNoteL
  2136 // CPhoneState::SendGlobalInfoNoteL
  2613 // ---------------------------------------------------------
  2137 // ---------------------------------------------------------
  2614 //
  2138 //
  2615 EXPORT_C void CPhoneState::SendGlobalInfoNoteL( TInt aResourceId )
  2139 EXPORT_C void CPhoneState::SendGlobalInfoNoteL( 
       
  2140         TInt aResourceId, TBool aNotificationDialog )
  2616     {
  2141     {
  2617     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalInfoNoteL( ) ");
  2142     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalInfoNoteL( ) ");
  2618     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2143     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2619     if ( CPhonePubSubProxy::Instance()->Value(
  2144     if ( CPhonePubSubProxy::Instance()->Value(
  2620             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  2145             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  2624         globalNotifierParam.SetBoolean( EFalse );
  2149         globalNotifierParam.SetBoolean( EFalse );
  2625         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2150         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2626             &globalNotifierParam );
  2151             &globalNotifierParam );
  2627 
  2152 
  2628         TPhoneCmdParamGlobalNote globalNoteParam;
  2153         TPhoneCmdParamGlobalNote globalNoteParam;
  2629 
  2154         PhoneNotificationType type = aNotificationDialog ? 
  2630         globalNoteParam.SetType( EAknGlobalInformationNote );
  2155             EPhoneNotificationDialog : EPhoneMessageBoxInformation;
       
  2156         globalNoteParam.SetType( type );
  2631         globalNoteParam.SetTextResourceId(
  2157         globalNoteParam.SetTextResourceId(
  2632             CPhoneMainResourceResolver::Instance()->
  2158             CPhoneMainResourceResolver::Instance()->
  2633             ResolveResourceID( aResourceId ) );
  2159             ResolveResourceID( aResourceId ) );
  2634         globalNoteParam.SetTone( EAvkonSIDInformationTone );
  2160 
  2635 
  2161         globalNoteParam.SetNotificationDialog( aNotificationDialog );
       
  2162         
  2636         iViewCommandHandle->ExecuteCommandL(
  2163         iViewCommandHandle->ExecuteCommandL(
  2637             EPhoneViewShowGlobalNote, &globalNoteParam );
  2164             EPhoneViewShowGlobalNote, &globalNoteParam );
  2638         }
  2165         }
  2639     }
  2166     }
  2640 
  2167 
  2641 // ---------------------------------------------------------
  2168 // ---------------------------------------------------------
  2642 //  CPhoneUIController::SendGlobalWarningNoteL
  2169 //  CPhoneUIController::SendGlobalWarningNoteL
  2643 // ---------------------------------------------------------
  2170 // ---------------------------------------------------------
  2644 //
  2171 //
  2645 EXPORT_C void CPhoneState::SendGlobalWarningNoteL( TInt aResourceId )
  2172 EXPORT_C void CPhoneState::SendGlobalWarningNoteL( 
       
  2173         TInt aResourceId, TBool aNotificationDialog )
  2646     {
  2174     {
  2647     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalWarningNoteL( ) ");
  2175     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalWarningNoteL( ) ");
  2648     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2176     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2649     if ( CPhonePubSubProxy::Instance()->Value(
  2177     if ( CPhonePubSubProxy::Instance()->Value(
  2650             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 ||
  2178             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 ||
  2655         globalNotifierParam.SetBoolean( EFalse );
  2183         globalNotifierParam.SetBoolean( EFalse );
  2656         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2184         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2657             &globalNotifierParam );
  2185             &globalNotifierParam );
  2658 
  2186 
  2659         TPhoneCmdParamGlobalNote globalNoteParam;
  2187         TPhoneCmdParamGlobalNote globalNoteParam;
  2660         globalNoteParam.SetType( EAknGlobalWarningNote );
  2188         PhoneNotificationType type = aNotificationDialog ? 
       
  2189                     EPhoneNotificationDialog : EPhoneMessageBoxWarning;
       
  2190         globalNoteParam.SetType( type );
  2661         globalNoteParam.SetTextResourceId(
  2191         globalNoteParam.SetTextResourceId(
  2662             CPhoneMainResourceResolver::Instance()->
  2192             CPhoneMainResourceResolver::Instance()->
  2663             ResolveResourceID( aResourceId ) );
  2193             ResolveResourceID( aResourceId ) );
  2664         globalNoteParam.SetTone( EAvkonSIDWarningTone );
  2194   
  2665 
  2195         globalNoteParam.SetNotificationDialog( aNotificationDialog );
       
  2196         
  2666         iViewCommandHandle->ExecuteCommandL(
  2197         iViewCommandHandle->ExecuteCommandL(
  2667             EPhoneViewShowGlobalNote, &globalNoteParam );
  2198             EPhoneViewShowGlobalNote, &globalNoteParam );
  2668         }
  2199         }
  2669     }
  2200     }
  2670 
  2201 
  2671 // ---------------------------------------------------------
  2202 // ---------------------------------------------------------
  2672 //  CPhoneUIController::SendGlobalErrorNoteL
  2203 //  CPhoneUIController::SendGlobalErrorNoteL
  2673 // ---------------------------------------------------------
  2204 // ---------------------------------------------------------
  2674 //
  2205 //
  2675 EXPORT_C void CPhoneState::SendGlobalErrorNoteL( TInt aResourceId )
  2206 EXPORT_C void CPhoneState::SendGlobalErrorNoteL( 
       
  2207         TInt aResourceId, TBool aNotificationDialog )
  2676     {
  2208     {
  2677     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalErrorNoteL( ) ");
  2209     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalErrorNoteL( ) ");
  2678     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2210     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  2679     if ( CPhonePubSubProxy::Instance()->Value(
  2211     if ( CPhonePubSubProxy::Instance()->Value(
  2680             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  2212             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  2684         globalNotifierParam.SetBoolean( EFalse );
  2216         globalNotifierParam.SetBoolean( EFalse );
  2685         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2217         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2686             &globalNotifierParam );
  2218             &globalNotifierParam );
  2687 
  2219 
  2688         TPhoneCmdParamGlobalNote globalNoteParam;
  2220         TPhoneCmdParamGlobalNote globalNoteParam;
  2689         globalNoteParam.SetType( EAknGlobalErrorNote );
  2221         PhoneNotificationType type = aNotificationDialog ? 
       
  2222                     EPhoneNotificationDialog : EPhoneMessageBoxInformation;
       
  2223         globalNoteParam.SetType( type );
       
  2224         
  2690         globalNoteParam.SetTextResourceId(
  2225         globalNoteParam.SetTextResourceId(
  2691             CPhoneMainResourceResolver::Instance()->
  2226             CPhoneMainResourceResolver::Instance()->
  2692             ResolveResourceID( aResourceId ) );
  2227             ResolveResourceID( aResourceId ) );
  2693         globalNoteParam.SetTone( CAknNoteDialog::EErrorTone );
  2228         globalNoteParam.SetNotificationDialog( aNotificationDialog );
  2694 
  2229 
  2695         iViewCommandHandle->ExecuteCommandL(
  2230         iViewCommandHandle->ExecuteCommandL(
  2696             EPhoneViewShowGlobalNote, &globalNoteParam );
  2231             EPhoneViewShowGlobalNote, &globalNoteParam );
  2697         }
  2232         }
  2698     }
  2233     }
  2706     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetHandsfreeModeL( ) ");
  2241     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetHandsfreeModeL( ) ");
  2707     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
  2242     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
  2708         iViewCommandHandle, iStateMachine, this );
  2243         iViewCommandHandle, iStateMachine, this );
  2709     if ( !bt->SetHandsfreeModeL( aHandsfreeMode ))
  2244     if ( !bt->SetHandsfreeModeL( aHandsfreeMode ))
  2710         {
  2245         {
  2711         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
  2246         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed, ETrue );
  2712         }
  2247         }
  2713     CleanupStack::PopAndDestroy( bt );
  2248     CleanupStack::PopAndDestroy( bt );
  2714     }
  2249     }
  2715 
  2250 
  2716 // ---------------------------------------------------------
  2251 // ---------------------------------------------------------
  2722     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetBTHandsfreeModeL( ) ");
  2257     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetBTHandsfreeModeL( ) ");
  2723     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
  2258     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
  2724         iViewCommandHandle, iStateMachine, this );
  2259         iViewCommandHandle, iStateMachine, this );
  2725     if ( !bt->SetBTHandsfreeModeL( aHandsfreeMode ))
  2260     if ( !bt->SetBTHandsfreeModeL( aHandsfreeMode ))
  2726         {
  2261         {
  2727         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
  2262         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed, ETrue );
  2728         }
  2263         }
  2729     CleanupStack::PopAndDestroy( bt );
  2264     CleanupStack::PopAndDestroy( bt );
  2730     }
  2265     }
  2731 
  2266 
  2732 // <-------------------------- INTERNAL FUNCTIONS ------------------------>
  2267 // <-------------------------- INTERNAL FUNCTIONS ------------------------>
  2733 
  2268 
  2734 // -----------------------------------------------------------
  2269 // -----------------------------------------------------------
  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 // -----------------------------------------------------------
       
  2801 // CPhoneState::UpdateProfileDisplayL
  2270 // CPhoneState::UpdateProfileDisplayL
  2802 // -----------------------------------------------------------
  2271 // -----------------------------------------------------------
  2803 //
  2272 //
  2804 void CPhoneState::UpdateProfileDisplayL()
  2273 void CPhoneState::UpdateProfileDisplayL()
  2805     {
  2274     {
  2806     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateProfileDisplayL( ) ");
  2275     }
  2807     // Get the profile information
  2276 
  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     }
       
  3027 
  2277 
  3028 // -----------------------------------------------------------
  2278 // -----------------------------------------------------------
  3029 // CPhoneState::HandleInitiatedEmergencyCallL
  2279 // CPhoneState::HandleInitiatedEmergencyCallL
  3030 // Default handling for EPEMessageInitiatedEmergencyCallL message
  2280 // Default handling for EPEMessageInitiatedEmergencyCallL message
  3031 // (other items were commented in a header).
  2281 // (other items were commented in a header).
  3043     // Reset Hold flag to view
  2293     // Reset Hold flag to view
  3044     TPhoneCmdParamBoolean holdFlag;
  2294     TPhoneCmdParamBoolean holdFlag;
  3045     holdFlag.SetBoolean( EFalse );
  2295     holdFlag.SetBoolean( EFalse );
  3046     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
  2296     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
  3047 
  2297 
  3048     // Undim Answer button for sure.
       
  3049     SetTouchPaneButtonEnabled( EPhoneCallComingCmdAnswer );
       
  3050 
       
  3051     // Go to emergency call state
  2298     // Go to emergency call state
  3052     // No need update cba
  2299     // No need update cba
  3053     iStateMachine->ChangeState( EPhoneStateEmergency );
  2300     iStateMachine->ChangeState( EPhoneStateEmergency );
  3054     }
  2301     }
  3055 
  2302 
  3061     {
  2308     {
  3062     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleInitiatedEmergencyWhileActiveVideoL( ) ");
  2309     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleInitiatedEmergencyWhileActiveVideoL( ) ");
  3063 
  2310 
  3064     // We have existing video call so need to release dataport before continuing
  2311     // We have existing video call so need to release dataport before continuing
  3065     // emergency call. Otherwise we will face problems with dataport use later.
  2312     // emergency call. Otherwise we will face problems with dataport use later.
  3066     CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( 
  2313     CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
  3067             KMediatorVideoTelephonyDomain,
  2314                                                                      KCatPhoneToVideotelCommands,
  3068             KCatPhoneToVideotelCommands,
  2315                                                                      EVtCmdReleaseDataport,
  3069             EVtCmdReleaseDataport,
  2316                                                                TVersion( KPhoneToVideotelCmdVersionMajor,
  3070             TVersion( KPhoneToVideotelCmdVersionMajor,
  2317                                                                          KPhoneToVideotelCmdVersionMinor,
  3071                     KPhoneToVideotelCmdVersionMinor,
  2318                                                                          KPhoneToVideotelCmdVersionBuild ),
  3072                     KPhoneToVideotelCmdVersionBuild ),
  2319                                                                KNullDesC8,
  3073             KNullDesC8,
  2320                                                                CPhoneContinueEmergencyCallCommand::NewL( *iStateMachine ) );
  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 );
       
  3117     }
  2321     }
  3118 
  2322 
  3119 // -----------------------------------------------------------
  2323 // -----------------------------------------------------------
  3120 // CPhoneState::HandleCallSecureStatusChangeL
  2324 // CPhoneState::HandleCallSecureStatusChangeL
  3121 // -----------------------------------------------------------
  2325 // -----------------------------------------------------------
  3140 
  2344 
  3141     iViewCommandHandle->ExecuteCommandL(
  2345     iViewCommandHandle->ExecuteCommandL(
  3142         EPhoneViewCipheringInfoChange,
  2346         EPhoneViewCipheringInfoChange,
  3143         aCallId,
  2347         aCallId,
  3144         &callHeaderParam );
  2348         &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 );
       
  3200     }
  2349     }
  3201 
  2350 
  3202 // ---------------------------------------------------------
  2351 // ---------------------------------------------------------
  3203 // CPhoneState::IsVideoCall
  2352 // CPhoneState::IsVideoCall
  3204 // ---------------------------------------------------------
  2353 // ---------------------------------------------------------
  3344         // Sim state is valid, check also Sim security status
  2493         // Sim state is valid, check also Sim security status
  3345         switch ( SimSecurityStatus() )
  2494         switch ( SimSecurityStatus() )
  3346             {
  2495             {
  3347             case ESimRejected:
  2496             case ESimRejected:
  3348             case ESimUnaccepted:
  2497             case ESimUnaccepted:
  3349             case ESimInvalid:
       
  3350                 retVal = EFalse;
  2498                 retVal = EFalse;
  3351                 break;
  2499                 break;
  3352 
  2500 
  3353             default:
  2501             default:
  3354                 break;
  2502                 break;
  3363 // CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled
  2511 // CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled
  3364 // -----------------------------------------------------------
  2512 // -----------------------------------------------------------
  3365 //
  2513 //
  3366 EXPORT_C TBool CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled()
  2514 EXPORT_C TBool CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled()
  3367     {
  2515     {
  3368     if ( SimState() == EPESimNotPresent && iStateMachine->SecurityMode()->IsSecurityMode() )
  2516     TPhoneCmdParamBoolean isSecurityMode;
       
  2517     TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode ) );
       
  2518     if ( SimState() == EPESimNotPresent && isSecurityMode.Boolean() )
  3369         {
  2519         {
  3370         return ETrue;
  2520         return ETrue;
  3371         }
  2521         }
  3372     else
  2522     else
  3373         {
  2523         {
  3374         return EFalse;
  2524         return EFalse;
  3375         }
  2525         }
       
  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 ) );
  3376     }
  2536     }
  3377 
  2537 
  3378 // ---------------------------------------------------------
  2538 // ---------------------------------------------------------
  3379 // CPhoneState::StartAlsLineChangeTimerL
  2539 // CPhoneState::StartAlsLineChangeTimerL
  3380 // ---------------------------------------------------------
  2540 // ---------------------------------------------------------
  3408 //
  2568 //
  3409 EXPORT_C void CPhoneState::StartShowSecurityNoteL()
  2569 EXPORT_C void CPhoneState::StartShowSecurityNoteL()
  3410     {
  2570     {
  3411     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::StartShowSecurityNoteL ");
  2571     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::StartShowSecurityNoteL ");
  3412 
  2572 
       
  2573     // Set security mode on.
       
  2574     TPhoneCmdParamBoolean securityMode;
       
  2575     securityMode.SetBoolean( ETrue );
       
  2576     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSecurityMode, &securityMode );
       
  2577 
  3413     // Remove number entry from screen
  2578     // Remove number entry from screen
  3414     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
  2579     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
  3415 
       
  3416     TPhoneCmdParamBoolean visibleMode;
       
  3417     visibleMode.SetBoolean( EFalse );
       
  3418     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetStatusPaneVisible, &visibleMode );
       
  3419     
  2580     
  3420     iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
  2581     iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
  3421 
  2582 
  3422     TPhoneCmdParamInteger uidParam;
  2583     TPhoneCmdParamInteger uidParam;
  3423     // Bring Phone app in the foreground
  2584     // Bring Phone app in the foreground
  3429     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
  2590     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
  3430         &uidParam );
  2591         &uidParam );
  3431 
  2592 
  3432     TInt resourceId ( KErrNone );
  2593     TInt resourceId ( KErrNone );
  3433 
  2594 
  3434 
  2595     if ( SimSecurityStatus() == ESimRejected )
  3435     switch( SimSecurityStatus() )
  2596         {
  3436         {
  2597         resourceId = CPhoneMainResourceResolver::Instance()->
  3437 			  case ESimRejected:
  2598             ResolveResourceID( EPhoneSimRejected );
  3438 			      {
  2599         }
  3439 			      resourceId = CPhoneMainResourceResolver::Instance()->
  2600     else if ( SimState() == EPESimNotPresent )
  3440               ResolveResourceID( EPhoneSimRejected );
  2601         {
  3441             break;
  2602         // insert sim card -note
  3442 			      }
  2603         resourceId = CPhoneMainResourceResolver::Instance()->
  3443 			  case ESimUnaccepted:
  2604             ResolveResourceID( EPhoneSimRemoved );
  3444 			      {
  2605         }
  3445 			      // insert sim card -note
  2606     else if ( SimSecurityStatus() == ESimUnaccepted )
  3446             resourceId = CPhoneMainResourceResolver::Instance()->
  2607         {
  3447               ResolveResourceID( EPhoneSimUnaccepted );	
  2608         resourceId = CPhoneMainResourceResolver::Instance()->
  3448 			      break;
  2609             ResolveResourceID( EPhoneSimUnaccepted );
  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 	          }
       
  3466         }
  2610         }
  3467 
  2611 
  3468     if ( resourceId != KErrNone )
  2612     if ( resourceId != KErrNone )
  3469         {
  2613         {
  3470         // Add it to the resource string
  2614         // Add it to the resource string
  3676         {
  2820         {
  3677         // Get customized text resource for busy note
  2821         // Get customized text resource for busy note
  3678         resource = iCustomization->CustomizeBusyNoteText();
  2822         resource = iCustomization->CustomizeBusyNoteText();
  3679         }
  2823         }
  3680 
  2824 
  3681     // Show number busy note
  2825     // Show number busy notification
  3682     TPhoneCmdParamGlobalNote globalNoteParam;
  2826     TPhoneCmdParamGlobalNote globalNoteParam;
  3683     globalNoteParam.SetType( EAknGlobalInformationNote );
  2827     globalNoteParam.SetType( EPhoneNotificationDialog );
  3684     globalNoteParam.SetTextResourceId(
  2828     globalNoteParam.SetTextResourceId(
  3685         CPhoneMainResourceResolver::Instance()->
  2829         CPhoneMainResourceResolver::Instance()->
  3686         ResolveResourceID( resource ) );
  2830         ResolveResourceID( resource ) );
  3687     globalNoteParam.SetTone( EAvkonSIDInformationTone );
  2831     
       
  2832     globalNoteParam.SetNotificationDialog( ETrue );
  3688     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowGlobalNote,
  2833     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowGlobalNote,
  3689         &globalNoteParam );
  2834         &globalNoteParam );
  3690     }
  2835     }
  3691 
  2836 
  3692 // ---------------------------------------------------------
  2837 // ---------------------------------------------------------
  3699     const TBool phoneIsLocked =
  2844     const TBool phoneIsLocked =
  3700                 CPhonePubSubProxy::Instance()->Value(
  2845                 CPhonePubSubProxy::Instance()->Value(
  3701                 KPSUidCoreApplicationUIs,
  2846                 KPSUidCoreApplicationUIs,
  3702                 KCoreAppUIsAutolockStatus ) > EAutolockOff;
  2847                 KCoreAppUIsAutolockStatus ) > EAutolockOff;
  3703 
  2848 
       
  2849     __PHONELOG1( EBasic,
       
  2850             EPhoneControl,
       
  2851             "CPhoneState::IsAutoLockOn() Status: %d",
       
  2852             phoneIsLocked );
       
  2853     
  3704     return phoneIsLocked;
  2854     return phoneIsLocked;
  3705     }
  2855     }
  3706 
  2856 
  3707 // ---------------------------------------------------------
  2857 // ---------------------------------------------------------
  3708 // CPhoneState::IsKeyLockOn
  2858 // CPhoneState::IsKeyLockOn
  3739 
  2889 
  3740 // ---------------------------------------------------------
  2890 // ---------------------------------------------------------
  3741 // CPhoneState::SetTouchPaneButtons
  2891 // CPhoneState::SetTouchPaneButtons
  3742 // ---------------------------------------------------------
  2892 // ---------------------------------------------------------
  3743 //
  2893 //
  3744 EXPORT_C void CPhoneState::SetTouchPaneButtons( TInt aResourceId )
  2894 EXPORT_C void CPhoneState::SetTouchPaneButtons( TInt /*aResourceId*/ )
  3745     {
  2895     {
  3746     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  2896     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3747         {
  2897         {
  3748         // Display Video Share button instead of Hold Button if
  2898         TPhoneCmdParamBoolean muteParam;
  3749         // the feature is enabled and video sharing is currently available.
  2899         muteParam.SetBoolean( iStateMachine->PhoneEngineInfo()->AudioMute() );
  3750         if ( aResourceId == EPhoneIncallButtons &&
  2900         iViewCommandHandle->ExecuteCommand(EPhoneViewSetMuteFlag,&muteParam);
  3751              FeatureManager::FeatureSupported( KFeatureIdFfEntryPointForVideoShare ) &&
  2901         
  3752              CPhonePubSubProxy::Instance()->Value
  2902         const TPEAudioOutput audioOutput =
  3753                 ( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator )
  2903             iStateMachine->PhoneEngineInfo()->AudioOutput();
  3754                 == ECoreAppUIsVideoSharingIndicatorOn )
  2904 
  3755             {
  2905         TBool btAvailable = iStateMachine->PhoneEngineInfo()->AudioOutputAvailable(
  3756             aResourceId = EPhoneIncallVideoShareButtons;
  2906             EPEBTAudioAccessory );
  3757             }
  2907         
  3758         TPhoneCmdParamInteger integerParam;
  2908         TPhoneCmdParamBoolean btParam;
  3759         integerParam.SetInteger( CPhoneMainResourceResolver::Instance()->
  2909         btParam.SetBoolean( audioOutput == EPEBTAudioAccessory );        
  3760                                  ResolveResourceID( aResourceId ) );
  2910         iViewCommandHandle->ExecuteCommand(EPhoneViewSetBlueToothFlag,&btParam);
       
  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 
  3761         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  2922         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  3762                      EPhoneViewSetTouchPaneButtons,
  2923                      EPhoneViewSetTouchPaneButtons,
  3763                      &integerParam ) );
  2924                      &booleanParam ) );
  3764 
       
  3765         SetTouchPaneVisible( ETrue );
       
  3766         }
  2925         }
  3767     }
  2926     }
  3768 
  2927 
  3769 // ---------------------------------------------------------
  2928 // ---------------------------------------------------------
  3770 // CPhoneState::DeleteTouchPaneButtons
  2929 // CPhoneState::DeleteTouchPaneButtons
  3772 //
  2931 //
  3773 EXPORT_C void CPhoneState::DeleteTouchPaneButtons()
  2932 EXPORT_C void CPhoneState::DeleteTouchPaneButtons()
  3774     {
  2933     {
  3775     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  2934     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3776         {
  2935         {
  3777         TPhoneCmdParamInteger integerParam;
  2936         TPhoneCmdParamBoolean boolParam;
  3778         integerParam.SetInteger( 0 );
       
  3779         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  2937         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  3780                         EPhoneViewSetTouchPaneButtons,
  2938                         EPhoneViewSetTouchPaneButtons,
  3781                         &integerParam ) );
  2939                         &boolParam ) );
  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 );
       
  3831         }
  2940         }
  3832     }
  2941     }
  3833 
  2942 
  3834 // ---------------------------------------------------------
  2943 // ---------------------------------------------------------
  3835 // CPhoneState::HandleLongHashL
  2944 // CPhoneState::HandleLongHashL
  3837 //
  2946 //
  3838 EXPORT_C void CPhoneState::HandleLongHashL()
  2947 EXPORT_C void CPhoneState::HandleLongHashL()
  3839     {
  2948     {
  3840     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::HandleLongHashL() ");
  2949     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::HandleLongHashL() ");
  3841 
  2950 
  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 );
       
  3864     }
  2951     }
  3865 
  2952 
  3866 // -----------------------------------------------------------
  2953 // -----------------------------------------------------------
  3867 // CPhoneState::BeginUiUpdateLC
  2954 // CPhoneState::BeginUiUpdateLC
  3868 // -----------------------------------------------------------
  2955 // -----------------------------------------------------------
  3869 //
  2956 //
  3870 EXPORT_C void CPhoneState::BeginUiUpdateLC()
  2957 EXPORT_C void CPhoneState::BeginUiUpdateLC()
  3871     {
  2958     {
       
  2959 
  3872     iViewCommandHandle->ExecuteCommand( EPhoneViewBeginUpdate );
  2960     iViewCommandHandle->ExecuteCommand( EPhoneViewBeginUpdate );
       
  2961 
  3873     TCleanupItem operation( UiUpdateCleanup, this );
  2962     TCleanupItem operation( UiUpdateCleanup, this );
  3874     CleanupStack::PushL( operation );
  2963     CleanupStack::PushL( operation );
  3875     }
  2964     }
  3876 
  2965 
  3877 // -----------------------------------------------------------
  2966 // -----------------------------------------------------------
  3878 // CPhoneState::EndUiUpdate
  2967 // CPhoneState::EndUiUpdate
  3879 // -----------------------------------------------------------
  2968 // -----------------------------------------------------------
  3880 //
  2969 //
  3881 EXPORT_C void CPhoneState::EndUiUpdate()
  2970 EXPORT_C void CPhoneState::EndUiUpdate()
  3882     {
  2971     {
  3883      CleanupStack::PopAndDestroy(); // Call UiUpdateCleanup
  2972     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
       
  3930     }
  2973     }
  3931 
  2974 
  3932 // -----------------------------------------------------------
  2975 // -----------------------------------------------------------
  3933 // CPhoneState::CheckIfShowTerminationNote
  2976 // CPhoneState::CheckIfShowTerminationNote
  3934 // This method is intended to be overridden in states
  2977 // This method is intended to be overridden in states
  3972 //
  3015 //
  3973 void CPhoneState::UiUpdateCleanup(TAny* aThis )
  3016 void CPhoneState::UiUpdateCleanup(TAny* aThis )
  3974     {
  3017     {
  3975     static_cast<CPhoneState*>( aThis )->iViewCommandHandle->ExecuteCommand(
  3018     static_cast<CPhoneState*>( aThis )->iViewCommandHandle->ExecuteCommand(
  3976         EPhoneViewEndUpdate );
  3019         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         }
       
  4029     }
  3020     }
  4030 
  3021 
  4031 // -----------------------------------------------------------
  3022 // -----------------------------------------------------------
  4032 // CPhoneState::SetDefaultFlagsL()
  3023 // CPhoneState::SetDefaultFlagsL()
  4033 // -----------------------------------------------------------
  3024 // -----------------------------------------------------------
  4052         &globalNotifierParam );
  3043         &globalNotifierParam );
  4053     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
  3044     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
  4054         &globalNotifierParam );
  3045         &globalNotifierParam );
  4055 
  3046 
  4056     // uncapture App and Camera keys if not security mode
  3047     // uncapture App and Camera keys if not security mode
  4057     if ( !iStateMachine->SecurityMode()->IsSecurityMode() )
  3048     TPhoneCmdParamBoolean isSecurityMode;
       
  3049     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );
       
  3050     if ( !isSecurityMode.Boolean() )
  4058         {
  3051         {
  4059         CaptureKeysDuringCallNotificationL( EFalse );
  3052         CaptureKeysDuringCallNotificationL( EFalse );
  4060         }
  3053         }
  4061     
  3054 
  4062     CPhonePubSubProxy::Instance()->ChangePropertyValue(
  3055     // Restore keylock if phone has been locked before call.
  4063                     KPSUidScreenSaver,
  3056     if ( iStateMachine->PhoneStorage()->NeedToEnableKeylock() )
  4064                     KScreenSaverAllowScreenSaver,
  3057         {
  4065                     EPhoneScreensaverAllowed );
  3058         iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLock );
       
  3059         iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( EFalse );
       
  3060         }
  4066     }
  3061     }
  4067 
  3062 
  4068 // -----------------------------------------------------------
  3063 // -----------------------------------------------------------
  4069 // CPhoneState::GetVolumeLevel
  3064 // CPhoneState::GetVolumeLevel
  4070 // -----------------------------------------------------------
  3065 // -----------------------------------------------------------
  4122     Sim security statuses:
  3117     Sim security statuses:
  4123 
  3118 
  4124     ESimSecurityStatusUninitialized = KStartupEnumerationFirstValue,
  3119     ESimSecurityStatusUninitialized = KStartupEnumerationFirstValue,
  4125     ESimRejected,   // The PUK code has been entered incorrectly, so the card is rejected.
  3120     ESimRejected,   // The PUK code has been entered incorrectly, so the card is rejected.
  4126     ESimUnaccepted  // The SIM lock is on, so the card is unaccepted.
  3121     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.
       
  4129     */
  3122     */
  4130     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SimSecurityStatus()" );
  3123     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SimSecurityStatus()" );
  4131     return CPhonePubSubProxy::Instance()->Value(
  3124     return CPhonePubSubProxy::Instance()->Value(
  4132                     KPSUidStartup, KStartupSimSecurityStatus );
  3125                     KPSUidStartup, KStartupSimSecurityStatus );
  4133     }
  3126     }
  4169             callText = iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId );
  3162             callText = iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId );
  4170             }
  3163             }
  4171 
  3164 
  4172         TPhoneCmdParamGlobalNote globalNoteParam;
  3165         TPhoneCmdParamGlobalNote globalNoteParam;
  4173         globalNoteParam.SetText( callText );
  3166         globalNoteParam.SetText( callText );
  4174         globalNoteParam.SetType( EAknGlobalInformationNote );
  3167         globalNoteParam.SetType( EPhoneNotificationDialog );
  4175         globalNoteParam.SetTone( EAvkonSIDInformationTone );
  3168 
  4176         globalNoteParam.SetTextResourceId(
  3169         globalNoteParam.SetTextResourceId(
  4177             CPhoneMainResourceResolver::Instance()->
  3170             CPhoneMainResourceResolver::Instance()->
  4178             ResolveResourceID( EPhoneCallWaitingWithLabel ) );
  3171             ResolveResourceID( EPhoneCallWaitingWithLabel ) );
  4179 
  3172         globalNoteParam.SetNotificationDialog( ETrue );
       
  3173         
  4180         iViewCommandHandle->ExecuteCommandL(
  3174         iViewCommandHandle->ExecuteCommandL(
  4181                 EPhoneViewShowGlobalNote, &globalNoteParam );
  3175                 EPhoneViewShowGlobalNote, &globalNoteParam );
  4182         }
  3176         }
  4183     else
  3177     else
  4184         {
  3178         {
  4185         SendGlobalInfoNoteL( EPhoneCallWaitingWithoutLabel );
  3179         SendGlobalInfoNoteL( EPhoneCallWaitingWithoutLabel, ETrue );
  4186         }
  3180         }
  4187     }
  3181     }
  4188 
  3182 
  4189 // ----------------------------------------------------------------------------
  3183 // ----------------------------------------------------------------------------
  4190 // CPhoneState::SetRingingTonePlaybackL()
  3184 // CPhoneState::SetRingingTonePlaybackL()
  4309             CPhoneMainResourceResolver::Instance()->
  3303             CPhoneMainResourceResolver::Instance()->
  4310             ResolveResourceID(
  3304             ResolveResourceID(
  4311             EPhoneInfoCugInUse ), cugIndex );
  3305             EPhoneInfoCugInUse ), cugIndex );
  4312 
  3306 
  4313         TPhoneCmdParamGlobalNote globalNoteParam;
  3307         TPhoneCmdParamGlobalNote globalNoteParam;
  4314 	    globalNoteParam.SetText( *buf );
  3308         globalNoteParam.SetText( *buf );
  4315 	    globalNoteParam.SetType( EAknGlobalInformationNote );
  3309         globalNoteParam.SetType( EPhoneMessageBoxInformation );
  4316 	    globalNoteParam.SetTone( EAvkonSIDInformationTone );
  3310    
  4317 
  3311         iViewCommandHandle->ExecuteCommandL(
  4318 	    iViewCommandHandle->ExecuteCommandL(
  3312                 EPhoneViewShowGlobalNote, &globalNoteParam );
  4319 	            EPhoneViewShowGlobalNote, &globalNoteParam );
  3313 
  4320 
  3314         CleanupStack::PopAndDestroy( buf );
  4321 	    CleanupStack::PopAndDestroy( buf );
       
  4322         }
  3315         }
  4323     }
  3316     }
  4324 
  3317 
  4325 // -----------------------------------------------------------
  3318 // -----------------------------------------------------------
  4326 // CPhoneState::CallheaderManagerL
  3319 // CPhoneState::CallheaderManagerL
  4337                 iCustomization );
  3330                 iCustomization );
  4338         }
  3331         }
  4339     return iCallHeaderManager;
  3332     return iCallHeaderManager;
  4340     }
  3333     }
  4341 
  3334 
  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 
       
  4433 // -----------------------------------------------------------
  3335 // -----------------------------------------------------------
  4434 // CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer
  3336 // CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer
  4435 // -----------------------------------------------------------
  3337 // -----------------------------------------------------------
  4436 //
  3338 //
  4437 EXPORT_C void CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer()
  3339 EXPORT_C void CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer()
  4438     {
  3340     {
  4439     if ( IsOnScreenDialerSupported() )
  3341 
  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          }
       
  4464     }
  3342     }
  4465 
  3343 
  4466 // -----------------------------------------------------------
  3344 // -----------------------------------------------------------
  4467 // CPhoneState::IsOnScreenDialerSupported
  3345 // CPhoneState::IsOnScreenDialerSupported
  4468 // -----------------------------------------------------------
  3346 // -----------------------------------------------------------
  4480     {
  3358     {
  4481     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::LoadResource() ");
  3359     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::LoadResource() ");
  4482     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::LoadResource - aResource: %d", aResource );
  3360     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::LoadResource - aResource: %d", aResource );
  4483     StringLoader::Load(  aData,
  3361     StringLoader::Load(  aData,
  4484                          CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
  3362                          CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
  4485                          EikonEnv() );
  3363                          &iEnv  );
  4486     }
  3364     }
  4487 
  3365 
  4488 // -----------------------------------------------------------
  3366 // -----------------------------------------------------------
  4489 // CPhoneState::IsAnyConnectedCalls
  3367 // CPhoneState::IsAnyConnectedCalls
  4490 // -----------------------------------------------------------
  3368 // -----------------------------------------------------------
  4550     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNumberEntryVisibleL( ) ");
  3428     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNumberEntryVisibleL( ) ");
  4551     return NumberEntryManagerL()->IsNumberEntryVisibleL();
  3429     return NumberEntryManagerL()->IsNumberEntryVisibleL();
  4552     }
  3430     }
  4553 
  3431 
  4554 // -----------------------------------------------------------
  3432 // -----------------------------------------------------------
  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 // -----------------------------------------------------------
       
  4566 // CPhoneState::HandleNumberEntryClearedL
  3433 // CPhoneState::HandleNumberEntryClearedL
  4567 // -----------------------------------------------------------
  3434 // -----------------------------------------------------------
  4568 //
  3435 //
  4569 EXPORT_C void CPhoneState::HandleNumberEntryClearedL()
  3436 EXPORT_C void CPhoneState::HandleNumberEntryClearedL()
  4570     {
  3437     {
  4586         booleanParam.SetBoolean( EFalse );
  3453         booleanParam.SetBoolean( EFalse );
  4587         }
  3454         }
  4588     NumberEntryManagerL()->SetNumberEntryVisibilityL( booleanParam );
  3455     NumberEntryManagerL()->SetNumberEntryVisibilityL( booleanParam );
  4589     }
  3456     }
  4590 
  3457 
  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 
       
  4602 // -----------------------------------------------------------
  3458 // -----------------------------------------------------------
  4603 // CPhoneState::IsNumberEntryContentStored
  3459 // CPhoneState::IsNumberEntryContentStored
  4604 // -----------------------------------------------------------
  3460 // -----------------------------------------------------------
  4605 //
  3461 //
  4606 EXPORT_C TBool CPhoneState::IsNumberEntryContentStored()
  3462 EXPORT_C TBool CPhoneState::IsNumberEntryContentStored()
  4618     {
  3474     {
  4619     NumberEntryManagerL()->StoreNumberEntryContentL();
  3475     NumberEntryManagerL()->StoreNumberEntryContentL();
  4620     }
  3476     }
  4621 
  3477 
  4622 // -----------------------------------------------------------
  3478 // -----------------------------------------------------------
  4623 // CPhoneState::RestoreNumberEntryContentL
       
  4624 // -----------------------------------------------------------
       
  4625 //
       
  4626 EXPORT_C void CPhoneState::RestoreNumberEntryContentL()
       
  4627     {
       
  4628     NumberEntryManagerL()->RestoreNumberEntryContentL();
       
  4629     }
       
  4630 
       
  4631 // -----------------------------------------------------------
       
  4632 // CPhoneState::ClearNumberEntryContentCache
  3479 // CPhoneState::ClearNumberEntryContentCache
  4633 // -----------------------------------------------------------
  3480 // -----------------------------------------------------------
  4634 //
  3481 //
  4635 EXPORT_C void CPhoneState::ClearNumberEntryContentCache()
  3482 EXPORT_C void CPhoneState::ClearNumberEntryContentCache()
  4636     {
  3483     {
  4637     TRAP_IGNORE( NumberEntryManagerL()->ClearNumberEntryContentCache() );
  3484     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() );
       
  4648     }
  3485     }
  4649 
  3486 
  4650 // -----------------------------------------------------------------------------
  3487 // -----------------------------------------------------------------------------
  4651 // CPhoneState::IsAlphanumericSupportedAndCharInput
  3488 // CPhoneState::IsAlphanumericSupportedAndCharInput
  4652 // -----------------------------------------------------------------------------
  3489 // -----------------------------------------------------------------------------
  4677 //
  3514 //
  4678 void CPhoneState::NumberEntryClearL()
  3515 void CPhoneState::NumberEntryClearL()
  4679     {
  3516     {
  4680     NumberEntryManagerL()->NumberEntryClearL();
  3517     NumberEntryManagerL()->NumberEntryClearL();
  4681     }
  3518     }
  4682 	
  3519 
  4683 // -----------------------------------------------------------
  3520 // -----------------------------------------------------------
  4684 // CPhoneState::UpdateSilenceButtonDimming
  3521 // CPhoneState::GetBlockedKeyList
  4685 // -----------------------------------------------------------
  3522 // -----------------------------------------------------------
  4686 //
  3523 //
  4687 EXPORT_C void CPhoneState::UpdateSilenceButtonDimming()
  3524 EXPORT_C const RArray<TInt>& CPhoneState::GetBlockedKeyList() const
  4688     {
  3525     {
  4689     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3526     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::GetBlockedKeyList( ) ");
  4690         {
  3527     return iStateMachine->PhoneStorage()->GetBlockedKeyList();
  4691         const TProfileRingingType ringingType =
  3528     }
  4692             iStateMachine->PhoneEngineInfo()->RingingType();
  3529 
       
  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 );
  4693         
  3580         
  4694         TBool callIsAlerting =
  3581         // Set Call UI state to storage
  4695                 !(( ringingType == EProfileRingingTypeSilent ) ||
  3582         iStateMachine->PhoneStorage()->SetScreenLocked( ETrue );
  4696                   ( ringingType == EProfileRingingTypeBeepOnce ));
  3583         }
  4697 
  3584     }
  4698         if ( !callIsAlerting )
  3585 
  4699             {
  3586 // -----------------------------------------------------------
  4700             SetTouchPaneButtonDisabled( EPhoneCallComingCmdSilent );
  3587 // CPhoneState::EnableCallUIL
  4701             }
  3588 // -----------------------------------------------------------
  4702         }
  3589 //
  4703     }
  3590 EXPORT_C void CPhoneState::EnableCallUIL()
  4704 	
  3591     {
  4705 // ---------------------------------------------------------
  3592     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::EnableCallUIL( ) ");
  4706 // CPhoneState::SetToolbarDimming
  3593 
  4707 // ---------------------------------------------------------
  3594     if( iStateMachine->PhoneStorage()->IsScreenLocked() )
  4708 //
  3595         {
  4709 EXPORT_C void CPhoneState::SetToolbarDimming( TBool aDimmed )
  3596         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::EnableCallUIL CallUI Enabled " );
  4710     {
  3597 
  4711 	if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3598         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
  4712         {
  3599         iViewCommandHandle->ExecuteCommandL( EPhoneViewDisableKeyLockWithoutNote );
  4713 		// Check that we are not undimming toolbar in security mode
  3600 
  4714 		if ( !( !aDimmed && iStateMachine->SecurityMode()->IsSecurityMode() ) )
  3601         // Stop capturing the key guard key
  4715 			{
  3602         TPhoneCmdParamKeyCapture appKeyCaptureParam;
  4716 			TPhoneCmdParamBoolean booleanParam;
  3603         appKeyCaptureParam.SetKey( EStdKeyDevice7 );
  4717 			booleanParam.SetBoolean( aDimmed );
  3604         appKeyCaptureParam.SetKeyCode( EKeyDeviceF );
  4718 			TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  3605         appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
  4719 				EPhoneViewSetToolbarDimming, &booleanParam ));
  3606         iViewCommandHandle->ExecuteCommandL( EPhoneViewStopCapturingKey, &appKeyCaptureParam );
  4720 			}
  3607         
       
  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             }
  4721         }
  3718         }
  4722     }
  3719     }
  4723 
  3720 
  4724 // ---------------------------------------------------------
  3721 // ---------------------------------------------------------
  4725 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
  3722 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
  4729     {
  3726     {
  4730     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3727     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  4731         {
  3728         {
  4732         TPhoneCmdParamInteger integerParam;
  3729         TPhoneCmdParamInteger integerParam;
  4733         integerParam.SetInteger( EPhoneInCallCmdActivateIhf );
  3730         integerParam.SetInteger( EPhoneInCallCmdActivateIhf );
       
  3731         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
       
  3732             EPhoneViewEnableToolbarButton, &integerParam ));
       
  3733         }
       
  3734     }
       
  3735 
       
  3736 // ---------------------------------------------------------
       
  3737 // CPhoneState::SetBackButtonActive
       
  3738 // ---------------------------------------------------------
       
  3739 //
       
  3740 EXPORT_C void CPhoneState::SetBackButtonActive( TBool aActive )
       
  3741     {
       
  3742     if(IsAutoLockOn() && aActive) {
       
  3743         // keep back button dimmed device lock case
       
  3744         return;
       
  3745     }
       
  3746     
       
  3747     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3748         {
       
  3749         TPhoneCmdParamBoolean booleanParam;
       
  3750         booleanParam.SetBoolean( aActive );
  4734         iViewCommandHandle->ExecuteCommand(
  3751         iViewCommandHandle->ExecuteCommand(
  4735             EPhoneViewEnableToolbarButton, &integerParam );
  3752             EPhoneViewBackButtonActive, &booleanParam );
  4736         }
  3753         }
  4737     }
  3754     }
  4738 
  3755 
  4739 // ---------------------------------------------------------
  3756 // -----------------------------------------------------------
  4740 // CPhoneState::SetToolbarButtonHandsetEnabled
  3757 // CPhoneState::OpenSoftRejectMessageEditorL
  4741 // ---------------------------------------------------------
  3758 // -----------------------------------------------------------
  4742 //
  3759 //
  4743 EXPORT_C void CPhoneState::SetToolbarButtonHandsetEnabled()
  3760 EXPORT_C void CPhoneState::OpenSoftRejectMessageEditorL()
  4744     {
  3761     {
  4745     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3762     __LOGMETHODSTARTEND(EPhoneControl,
  4746         {
  3763         "CPhoneState::OpenSoftRejectMessageEditorL ()" );
  4747         TPhoneCmdParamInteger integerParam;
  3764 
  4748         integerParam.SetInteger( EPhoneInCallCmdHandset );
  3765     // Fetch incoming call's id from view
  4749         iViewCommandHandle->ExecuteCommand(
  3766     TPhoneCmdParamCallStateData callStateData;
  4750             EPhoneViewEnableToolbarButton, &integerParam );
  3767     callStateData.SetCallState( EPEStateRinging );
  4751         }
  3768     iViewCommandHandle->HandleCommandL(
  4752     }
  3769         EPhoneViewGetCallIdByState, &callStateData );
  4753 
  3770 
  4754 // ---------------------------------------------------------
  3771     TInt ringingCallId( KErrNotFound );
  4755 // CPhoneState::SetToolbarButtonBTHFEnabled
  3772     // Do nothing if negative incoming call id
  4756 // ---------------------------------------------------------
  3773     if( callStateData.CallId() > KErrNotFound  )
  4757 //
  3774         {
  4758 EXPORT_C void CPhoneState::SetToolbarButtonBTHFEnabled()
  3775         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
  4759     {
  3776         
  4760     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
  3777         ringingCallId = callStateData.CallId();
  4761         {
  3778         }
  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;
       
  4830     
  3779     
  4831     if ( iCustomization )
  3780     
  4832        {
  3781     TPhoneCmdParamSfiData sfiDataParam;
  4833        handled = iCustomization->HandlePhoneEngineMessageL( aMessage, aCallId );
  3782 
  4834        }
  3783     if (KErrNotFound != ringingCallId) 
  4835     return handled;
  3784         {
  4836     }
  3785         if ( iStateMachine->PhoneEngineInfo()->RemoteName( ringingCallId ).Length() )
  4837 
  3786             {
  4838 // -----------------------------------------------------------
  3787             // store both the name and the number
  4839 // CPhoneState::SetLittleBubbleVisibilityL
  3788             sfiDataParam.SetNumber( iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( ringingCallId ) );
  4840 // -----------------------------------------------------------
  3789             sfiDataParam.SetName( iStateMachine->PhoneEngineInfo()->RemoteName( ringingCallId ) );
  4841 //
  3790             }
  4842 void CPhoneState::SetLittleBubbleVisibilityL(
  3791         else
  4843         TPhoneCommandParam* aCommandParam)
  3792             {
  4844     {
  3793             // store the number
  4845     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetLittleBubbleVisibilityL() " );
  3794             sfiDataParam.SetNumber( iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( ringingCallId ) );
  4846     // If user has opened dtmfeditor(dtmfdialer) then do not make any changes 
  3795             }
  4847     // to SetLittleBubbleVisible value. SetLittleBubbleVisible value is true by default.
  3796         }
  4848     if( !IsDTMFEditorVisibleL() )
  3797 
  4849         {
  3798     iViewCommandHandle->ExecuteCommandL(
  4850         TPhoneCmdParamIncallIndicatorData* incallIndicatorParam =
  3799         EPhoneViewOpenSoftRejectEditor, &sfiDataParam );
  4851                    static_cast<TPhoneCmdParamIncallIndicatorData*>( aCommandParam );
       
  4852         TInt activeCallId = GetActiveCallIdL();
       
  4853         switch( incallIndicatorParam->CallState() )
       
  4854            {
       
  4855            case EPSCTsyCallStateRinging:
       
  4856            case EPSCTsyCallStateDialling:
       
  4857                {
       
  4858                // If we have single ringing or dialling call then it is ok
       
  4859                // to set visibility to false.
       
  4860                if ( activeCallId < KErrNone )
       
  4861                    {
       
  4862                    incallIndicatorParam->SetLittleBubbleVisible( EFalse );
       
  4863                    }
       
  4864                }
       
  4865                break;
       
  4866            default:
       
  4867                incallIndicatorParam->SetLittleBubbleVisible( ETrue );
       
  4868                break;
       
  4869            }
       
  4870         } 
       
  4871     }
       
  4872 
       
  4873 // -----------------------------------------------------------
       
  4874 // CPhoneState::DisplayCallSetupL
       
  4875 // -----------------------------------------------------------
       
  4876 //
       
  4877 EXPORT_C void CPhoneState::DisplayCallSetupL( TInt aCallId )
       
  4878     {
       
  4879     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::DisplayCallSetupL() ");
       
  4880     BeginTransEffectLC( ECallUiAppear );
       
  4881     BeginUiUpdateLC();
       
  4882     SetNumberEntryVisibilityL( EFalse );
       
  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();
       
  4935     }
  3800     }
  4936 
  3801 
  4937 //  End of File
  3802 //  End of File
  4938 
  3803