phoneapp/phoneuicontrol/src/cphonestate.cpp
changeset 77 2be0b271d017
parent 72 c76a0b1755b9
equal deleted inserted replaced
72:c76a0b1755b9 77:2be0b271d017
    27 #include <cpephonemodelif.h>
    27 #include <cpephonemodelif.h>
    28 #include <featmgr.h>
    28 #include <featmgr.h>
    29 #include <rconnmon.h>
    29 #include <rconnmon.h>
    30 #include <Profile.hrh>
    30 #include <Profile.hrh>
    31 #include <PUAcodes.hrh>
    31 #include <PUAcodes.hrh>
    32 #include <AknUtils.h>
       
    33 #include <telephonyvariant.hrh>
    32 #include <telephonyvariant.hrh>
    34 #include <aknsoundsystem.h>
    33 #include <aknsoundsystem.h>
    35 #include <wlaninternalpskeys.h>
    34 #include <wlaninternalpskeys.h>
    36 #include <btengdomainpskeys.h>
    35 #include <btengdomainpskeys.h>
    37 #include <btengdomaincrkeys.h>
    36 #include <btengdomaincrkeys.h>
    38 #include <settingsinternalcrkeys.h>
    37 #include <settingsinternalcrkeys.h>
    39 #include <starterclient.h>
    38 #include <starterclient.h>
    40 #include <rsssettings.h>
    39 #include <rsssettings.h>
    41 #include <UikonInternalPSKeys.h>
       
    42 #include <telephonydomainpstypes.h>
    40 #include <telephonydomainpstypes.h>
    43 #include <telinformationpskeys.h>
    41 #include <telinformationpskeys.h>
    44 #include <coreapplicationuisdomainpskeys.h>
    42 #include <coreapplicationuisdomainpskeys.h>
    45 #include <mccecall.h>
    43 #include <mccecall.h>
    46 #include <ccpdefs.h>
    44 #include <ccpdefs.h>
    96 #include "cphonemediatorfactory.h"
    94 #include "cphonemediatorfactory.h"
    97 #include "mphonemediatormessage.h"
    95 #include "mphonemediatormessage.h"
    98 #include "cphonemediatorsender.h"
    96 #include "cphonemediatorsender.h"
    99 #include "cphonereleasecommand.h"
    97 #include "cphonereleasecommand.h"
   100 #include "cphonecontinueemergencycallcommand.h"
    98 #include "cphonecontinueemergencycallcommand.h"
   101 #include "cphonecallheadermanager.h"
       
   102 #include "cphonenumberentrymanager.h"
       
   103 #include "tphonecmdparamsfidata.h" 
    99 #include "tphonecmdparamsfidata.h" 
   104 #include "mphonestorage.h"
   100 #include "mphonestorage.h"
   105 #include "phoneconstants.h"
   101 #include "phoneconstants.h"
   106 #include "cphoneclearblacklist.h"
   102 #include "cphoneclearblacklist.h"
   107 
   103 
   111     MPhoneStateMachine* aStateMachine,
   107     MPhoneStateMachine* aStateMachine,
   112     MPhoneViewCommandHandle* aViewCommandHandle,
   108     MPhoneViewCommandHandle* aViewCommandHandle,
   113     MPhoneCustomization* aCustomization) :
   109     MPhoneCustomization* aCustomization) :
   114     iStateMachine( aStateMachine ),
   110     iStateMachine( aStateMachine ),
   115     iViewCommandHandle( aViewCommandHandle ),
   111     iViewCommandHandle( aViewCommandHandle ),
   116     iCustomization( aCustomization ),
   112     iCustomization( aCustomization )
   117     iEnv( *CEikonEnv::Static() )
       
   118     {
   113     {
   119     // Need to get current SimState for inherited classis
   114     // Need to get current SimState for inherited classis
   120     iPreviousSimState = SimState();
   115     iPreviousSimState = SimState();
   121     __ASSERT_ALWAYS(
   116     __ASSERT_ALWAYS(
   122         aStateMachine && aViewCommandHandle,
   117         aStateMachine && aViewCommandHandle,
   124     }
   119     }
   125 
   120 
   126 EXPORT_C void CPhoneState::BaseConstructL()
   121 EXPORT_C void CPhoneState::BaseConstructL()
   127     {
   122     {
   128     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::BaseConstructL() ");
   123     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::BaseConstructL() ");
   129     if ( !iCbaManager )
   124     if ( !iUiCommandManager )
   130         {
   125         {
   131         iCbaManager = CPhoneCbaManager::NewL(
   126         iUiCommandManager = CPhoneUiCommandManager::NewL(
   132                         this,
   127                         this,
   133                         *iViewCommandHandle,
   128                         *iViewCommandHandle,
   134                         *iStateMachine );
   129                         *iStateMachine );
   135         }
   130         }
       
   131     
       
   132     if ( !iNumberEntryManager )
       
   133         {
       
   134         iNumberEntryManager = CPhoneNumberEntryManager::NewL(
       
   135                 this,
       
   136                 *iViewCommandHandle,
       
   137                 *iStateMachine,
       
   138                 iCustomization,
       
   139                 *iUiCommandManager );
       
   140         }
       
   141     
   136     }
   142     }
   137 
   143 
   138 EXPORT_C CPhoneState::~CPhoneState()
   144 EXPORT_C CPhoneState::~CPhoneState()
   139     {
   145     {
   140     delete iNumberEntryManager;
   146     delete iNumberEntryManager;
   141     delete iCallHeaderManager;
   147     delete iUiCommandManager;
   142     delete iCbaManager;
   148     }
       
   149 
       
   150 // -----------------------------------------------------------
       
   151 // CPhoneState::EikonEnv
       
   152 // -----------------------------------------------------------
       
   153 //
       
   154 EXPORT_C CEikonEnv* CPhoneState::EikonEnv() const
       
   155     {
       
   156     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::EikonEnv( ) ");
       
   157     return iEnv;
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------
       
   161 // CPhoneState::SetEikonEnv
       
   162 // -----------------------------------------------------------
       
   163 //
       
   164 EXPORT_C void CPhoneState::SetEikonEnv( CEikonEnv* aEnv )
       
   165     {
       
   166     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetEikonEnv( ) ");
       
   167     iEnv = aEnv;
   143     }
   168     }
   144 
   169 
   145 // <-------------------------- PHONE ENGINE EVENTS --------------------------->
   170 // <-------------------------- PHONE ENGINE EVENTS --------------------------->
   146 // -----------------------------------------------------------
   171 // -----------------------------------------------------------
   147 // CPhoneState::HandlePhoneEngineMessageL
   172 // CPhoneState::HandlePhoneEngineMessageL
   169             HandleAudioMuteChangedL();
   194             HandleAudioMuteChangedL();
   170             break;
   195             break;
   171 
   196 
   172         case MEngineMonitor::EPEMessageAudioOutputChanged:
   197         case MEngineMonitor::EPEMessageAudioOutputChanged:
   173             HandleAudioOutputChangedL();
   198             HandleAudioOutputChangedL();
   174             // Go to current state implementation
   199             UpdateUiCommands();
   175             iCbaManager->UpdateInCallCbaL();
       
   176             SetTouchPaneButtons(0);
       
   177             break;
   200             break;
   178 
   201 
   179         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
   202         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
   180             HandleAudioAvailableOutputChangedL();
   203             HandleAudioAvailableOutputChangedL();
   181             if ( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPENotActive )
   204             if ( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPENotActive )
   182                 {
   205                 {
   183                 // Go to current state implementation
   206                 UpdateUiCommands();
   184                 iCbaManager->UpdateInCallCbaL();
       
   185                 SetTouchPaneButtons(0);
       
   186                 }
   207                 }
   187             break;
   208             break;
   188 
   209 
   189         case MEngineMonitor::EPEMessageChangedCallDuration:
   210         case MEngineMonitor::EPEMessageChangedCallDuration:
   190             HandleChangedCallDurationL( aCallId );
   211             HandleChangedCallDurationL( aCallId );
   230             TPhoneCmdParamBoolean globalNotifierParam;
   251             TPhoneCmdParamBoolean globalNotifierParam;
   231             globalNotifierParam.SetBoolean( EFalse );
   252             globalNotifierParam.SetBoolean( EFalse );
   232             iViewCommandHandle->ExecuteCommandL(
   253             iViewCommandHandle->ExecuteCommandL(
   233                 EPhoneViewSetGlobalNotifiersDisabled,
   254                 EPhoneViewSetGlobalNotifiersDisabled,
   234                 &globalNotifierParam );
   255                 &globalNotifierParam );
   235             NumberEntryClearL();
   256             iNumberEntryManager->NumberEntryClearL();
   236             }
   257             }
   237             break;
   258             break;
   238 
   259 
   239         case MEngineMonitor::EPEMessageIssuedUSSDRequest:
   260         case MEngineMonitor::EPEMessageIssuedUSSDRequest:
   240             // Go to current state implementation
   261             UpdateUiCommands();
   241             iCbaManager->UpdateInCallCbaL();
       
   242             break;
   262             break;
   243 
   263 
   244         // *#9990#
   264         // *#9990#
   245         case MEngineMonitor::EPEMessageShowBTLoopback:
   265         case MEngineMonitor::EPEMessageShowBTLoopback:
   246             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
   266             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
   330     TPhoneCmdParamBoolean booleanParam;
   350     TPhoneCmdParamBoolean booleanParam;
   331     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
   351     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
   332     booleanParam.SetBoolean( audioMute );
   352     booleanParam.SetBoolean( audioMute );
   333     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateMuteUIChanges,
   353     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateMuteUIChanges,
   334         &booleanParam );
   354         &booleanParam );
   335     SetTouchPaneButtons(0);
   355     UpdateUiCommands();
   336     }
   356     }
   337 
   357 
   338 // -----------------------------------------------------------
   358 // -----------------------------------------------------------
   339 // CPhoneState::HandleAudioOutputChangedL
   359 // CPhoneState::HandleAudioOutputChangedL
   340 // Default handling for EPEMessageAudioOutputChanged message
   360 // Default handling for EPEMessageAudioOutputChanged message
   382         {
   402         {
   383         CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
   403         CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
   384         }
   404         }
   385     else if ( RouteParameters.iShowNote && audioOutput == EPELoudspeaker )
   405     else if ( RouteParameters.iShowNote && audioOutput == EPELoudspeaker )
   386         {
   406         {
   387         CAknKeySoundSystem* keySounds =
   407         // Avkon removal
   388                static_cast<CAknAppUi*>( iEnv.EikAppUi() )->KeySounds();
       
   389         keySounds->PlaySound( EAvkonSIDIHFActive );
       
   390         }
   408         }
   391     }
   409     }
   392 
   410 
   393 // -----------------------------------------------------------
   411 // -----------------------------------------------------------
   394 // CPhoneState::HandleSimStateChangedL
   412 // CPhoneState::HandleSimStateChangedL
   453         }
   471         }
   454     iPreviousSimState = simState;
   472     iPreviousSimState = simState;
   455     }
   473     }
   456 
   474 
   457 // -----------------------------------------------------------------------------
   475 // -----------------------------------------------------------------------------
   458 // CPhoneState::IsValidAlphaNumericKey
       
   459 // Checks is the key event a number, a special character
       
   460 // or if VoIP is enabled some other character
       
   461 // -----------------------------------------------------------------------------
       
   462 //
       
   463 TBool CPhoneState::IsValidAlphaNumericKey( const TKeyEvent& aKeyEvent,
       
   464         TEventCode aEventCode )
       
   465     {
       
   466     TBool ret(EFalse);
       
   467     const TBool numericKeyEntered( CPhoneKeys::IsNumericKey(
       
   468           aKeyEvent, aEventCode ) );
       
   469     // a numeric key (1,2,3,4,6,7,8,9,0,+,*,p,w )
       
   470     // or
       
   471     // a letter from fullscreen qwerty, miniqwerty or handwriting
       
   472     // when voip is enabled
       
   473     if ( numericKeyEntered
       
   474         || IsAlphanumericSupportedAndCharInput( aKeyEvent ) )
       
   475         {
       
   476         ret= ETrue;
       
   477         }
       
   478     return ret;
       
   479     }
       
   480 
       
   481 // -----------------------------------------------------------------------------
       
   482 // CPhoneState::SendDtmfKeyEventL
   476 // CPhoneState::SendDtmfKeyEventL
   483 // send dtmf event when,
   477 // send dtmf event when,
   484 // -touch dtmf dialer is NOT visible
   478 // -touch dtmf dialer is NOT visible
   485 // -query is not active
   479 // -query is not active
   486 // -menubar is not open
   480 // -menubar is not open
   487 // -----------------------------------------------------------------------------
   481 // -----------------------------------------------------------------------------
   488 //
   482 //
   489 void CPhoneState::SendDtmfKeyEventL( const TKeyEvent& aKeyEvent,
   483 void CPhoneState::SendDtmfKeyEventL( const TKeyEvent& aKeyEvent,
   490                TEventCode aEventCode  )
   484                TEventCode aEventCode  )
   491     {
   485     {
   492     if ( !IsAnyQueryActiveL() )
   486     // Send the key event to the phone engine.
   493         {
   487     SendKeyEventL( aKeyEvent, aEventCode );
   494         // Send the key event to the phone engine.
       
   495         SendKeyEventL( aKeyEvent, aEventCode );
       
   496         }
       
   497     }
   488     }
   498 
   489 
   499 // -----------------------------------------------------------
   490 // -----------------------------------------------------------
   500 // CPhoneState::HandleErrorL
   491 // CPhoneState::HandleErrorL
   501 // Default handling for HandleError message
   492 // Default handling for HandleError message
   520             // No network -> hide volume popup
   511             // No network -> hide volume popup
   521             iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
   512             iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
   522             break;
   513             break;
   523 
   514 
   524         case ECCPErrorSatControl:
   515         case ECCPErrorSatControl:
   525             NumberEntryClearL();
   516             iNumberEntryManager->NumberEntryClearL();
   526             break;
   517             break;
   527 
   518 
   528         default:
   519         default:
   529             break;
   520             break;
   530         }
   521         }
   575 // -----------------------------------------------------------
   566 // -----------------------------------------------------------
   576 //
   567 //
   577 EXPORT_C void CPhoneState::HandleDisconnectingL( TInt aCallId )
   568 EXPORT_C void CPhoneState::HandleDisconnectingL( TInt aCallId )
   578     {
   569     {
   579     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleDisconnectingL( ) ");
   570     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleDisconnectingL( ) ");
   580     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   581     callHeaderParam.SetCallState( EPEStateDisconnecting );
       
   582     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
       
   583     LoadResource( labelText, EPhoneInCallDisconnected );
       
   584     callHeaderParam.SetLabelText( labelText );
       
   585 
   571 
   586     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
   572     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
   587     iViewCommandHandle->ExecuteCommandL( 
   573     iViewCommandHandle->ExecuteCommandL( 
   588             EPhoneViewUpdateBubble, 
   574             EPhoneViewUpdateBubble, 
   589             aCallId,
   575             aCallId);
   590             &callHeaderParam );
       
   591 
   576 
   592     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   577     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
   593     }
       
   594 
       
   595 // -----------------------------------------------------------
       
   596 // CPhoneState::IsCustomizedDialerVisibleL()
       
   597 // -----------------------------------------------------------
       
   598 //
       
   599 EXPORT_C TBool CPhoneState::IsCustomizedDialerVisibleL() const
       
   600     {
       
   601     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsCustomizedDialerVisibleL( ) ");
       
   602     return iViewCommandHandle->HandleCommandL(
       
   603         EPhoneIsCustomizedDialerVisible ) == EPhoneViewResponseSuccess;
       
   604     }
   578     }
   605 
   579 
   606 // <------------------------------- KEY EVENTS ------------------------------->
   580 // <------------------------------- KEY EVENTS ------------------------------->
   607 // -----------------------------------------------------------
   581 // -----------------------------------------------------------
   608 // CPhoneState::HandleKeyMessageL( aMessage, aKeyCode )
   582 // CPhoneState::HandleKeyMessageL( aMessage, aKeyCode )
   656             "OnlySideVolumeKeySupported: %d",
   630             "OnlySideVolumeKeySupported: %d",
   657             onlySideVolumeKeySupported );
   631             onlySideVolumeKeySupported );
   658     return onlySideVolumeKeySupported;
   632     return onlySideVolumeKeySupported;
   659     }
   633     }
   660 
   634 
   661 // -----------------------------------------------------------------------------
       
   662 // CPhoneState::IsAnyQueryActiveL
       
   663 // -----------------------------------------------------------------------------
       
   664 //
       
   665 EXPORT_C TBool CPhoneState::IsAnyQueryActiveL()
       
   666     {
       
   667     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsAnyQueryActiveL( ) ");
       
   668     TBool isActive( EFalse );
       
   669     // If IsNoteDismissableL returns true then shown note is dismissable by key event
       
   670     // and then there is no actual query and IsAnyQueryActiveL returns false.
       
   671     if ( !IsNoteDismissableL() )
       
   672         {
       
   673         // Check is query displayed
       
   674         TPhoneCmdParamBoolean isQueryDisplayed;
       
   675         iViewCommandHandle->ExecuteCommandL( EPhoneViewIsQuery, &isQueryDisplayed );
       
   676         // Check is Blocking Dialog active ( e.g. RFS query )
       
   677         TPhoneCmdParamBoolean blockingDialogStatus;
       
   678         iViewCommandHandle->ExecuteCommandL( EPhoneViewGetBlockingDialogStatus,
       
   679             &blockingDialogStatus );
       
   680         // Check is note displayed
       
   681         TPhoneCmdParamBoolean isNoteActive;
       
   682         iViewCommandHandle->ExecuteCommandL(
       
   683             EPhoneViewIsNoteActive, &isNoteActive );
       
   684 
       
   685         if ( isQueryDisplayed.Boolean() || blockingDialogStatus.Boolean() || isNoteActive.Boolean() )
       
   686             {
       
   687             isActive = ETrue;
       
   688             }
       
   689         }
       
   690     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsAnyQueryActiveL: %d ", isActive );
       
   691     return isActive;
       
   692     }
       
   693 
       
   694 // -----------------------------------------------------------------------------
       
   695 // CPhoneState::IsNoteDismissable
       
   696 // -----------------------------------------------------------------------------
       
   697 //
       
   698 TBool CPhoneState::IsNoteDismissableL()
       
   699     {
       
   700     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNoteDismissableL( ) ");
       
   701     TBool dismiss = EFalse;
       
   702     if ( !FeatureManager::FeatureSupported( KFeatureIdFfSimlessOfflineSupport ) ||
       
   703          (FeatureManager::FeatureSupported( KFeatureIdFfSimlessOfflineSupport ) &&
       
   704                   SimSecurityStatus() == ESimRejected )  )
       
   705         {
       
   706         // Check if note is dismissed by key event.
       
   707         TPhoneCmdParamBoolean isNoteDismissed;
       
   708         iViewCommandHandle->ExecuteCommandL(
       
   709                 EPhoneViewIsActiveNoteDissmissableByKeyEvent, &isNoteDismissed );
       
   710         if ( isNoteDismissed.Boolean() )
       
   711             {
       
   712             dismiss = ETrue;
       
   713             }
       
   714         }
       
   715     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsNoteDismissableL: %d ", dismiss );
       
   716     return dismiss;
       
   717     }
       
   718 
       
   719 // -----------------------------------------------------------
   635 // -----------------------------------------------------------
   720 // CPhoneState::SendKeyEventL
   636 // CPhoneState::SendKeyEventL
   721 // -----------------------------------------------------------
   637 // -----------------------------------------------------------
   722 //
   638 //
   723 void CPhoneState::SendKeyEventL(
   639 void CPhoneState::SendKeyEventL(
   758 
   674 
   759     if ( dtmfToneKeyEntered ||
   675     if ( dtmfToneKeyEntered ||
   760         aKeyEvent.iCode == EKeyBackspace )
   676         aKeyEvent.iCode == EKeyBackspace )
   761         {
   677         {
   762         // Get the number entry contents and store, if it exists
   678         // Get the number entry contents and store, if it exists
   763         if ( IsNumberEntryUsedL() )
   679         if ( iNumberEntryManager->IsNumberEntryUsedL() )
   764             {
   680             {
   765             HBufC* phoneNumber = PhoneNumberFromEntryLC();
   681             HBufC* phoneNumber = iNumberEntryManager->PhoneNumberFromEntryLC();
   766             __PHONELOG1( EBasic, EPhoneControl, "SetPhoneNumber: %S ", phoneNumber );
   682             __PHONELOG1( EBasic, EPhoneControl, "SetPhoneNumber: %S ", phoneNumber );
   767             iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
   683             iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
   768 
   684 
   769             // Convert key code to western.
   685             // Convert key code to western.
   770             TBuf<1> buffer; // one character
   686             TBuf<1> buffer; // one character
   771             buffer.Append( aKeyEvent.iCode );
   687             buffer.Append( aKeyEvent.iCode );
   772             __PHONELOG1( EBasic, EPhoneControl,
   688             __PHONELOG1( EBasic, EPhoneControl,
   773                 "CPhoneState::SendKeyPressL(%S)",
   689                 "CPhoneState::SendKeyPressL(%S)",
   774                 &buffer );
   690                 &buffer );
   775             AknTextUtils::ConvertDigitsTo( buffer, EDigitTypeWestern );
   691             
   776             __PHONELOG1( EBasic, EPhoneControl,
       
   777                 "CPhoneState::SendKeyPressL(%S)",
       
   778                 &buffer );
       
   779 
       
   780             // Save the key code
   692             // Save the key code
   781             TLex code( buffer );
   693             TLex code( buffer );
   782             iStateMachine->PhoneEngineInfo()->SetKeyCode( code.Peek() );
   694             iStateMachine->PhoneEngineInfo()->SetKeyCode( code.Peek() );
   783 
   695 
   784             // Plays a DTMF tone if active call
   696             // Plays a DTMF tone if active call
   788             }
   700             }
   789         }
   701         }
   790     }
   702     }
   791 
   703 
   792 // <------------------------------ SYSTEM EVENTS ----------------------------->
   704 // <------------------------------ SYSTEM EVENTS ----------------------------->
   793 // -----------------------------------------------------------
       
   794 // CPhoneState::HandleSystemEventL
       
   795 // -----------------------------------------------------------
       
   796 //
       
   797 EXPORT_C void CPhoneState::HandleSystemEventL( const TWsEvent& /*aEvent*/ )
       
   798     {
       
   799     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleSystemEventL( ) ");
       
   800     }
       
   801 
       
   802 // -----------------------------------------------------------
       
   803 // CPhoneState::HandleForegroundEventL
       
   804 // -----------------------------------------------------------
       
   805 //
       
   806 EXPORT_C void CPhoneState::HandleForegroundEventL( TBool aForeground )
       
   807     {
       
   808     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleForegroundEventL( ) ");
       
   809     if ( !aForeground && IsNumberEntryUsedL() )
       
   810         {
       
   811         // Going out from foreground and number entry is open.
       
   812         // Make sure that dtmf playing is stopped ( EEventKeyUp may be missed ).
       
   813         iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   814         }
       
   815     }
       
   816 
       
   817 // -----------------------------------------------------------
       
   818 // CPhoneState::HandlePhoneForegroundEventL
       
   819 // -----------------------------------------------------------
       
   820 //
       
   821 EXPORT_C void CPhoneState::HandlePhoneForegroundEventL()
       
   822     {
       
   823     }
       
   824 
       
   825 // -----------------------------------------------------------
       
   826 // CPhoneState::HandlePhoneFocusLostEventL
       
   827 // -----------------------------------------------------------
       
   828 //
       
   829 EXPORT_C void CPhoneState::HandlePhoneFocusLostEventL()
       
   830     {
       
   831     // Notify that this method is called always when Idle is brought to foreground
       
   832     // See implementation in CPhoneAppUI::HandleWsEventL
       
   833     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneFocusLostEventL( ) ");
       
   834     }
       
   835 // ---------------------------------------------------------
       
   836 // CPhoneState::HandleIdleForegroundEventL
       
   837 // ---------------------------------------------------------
       
   838 //
       
   839 EXPORT_C void CPhoneState::HandleIdleForegroundEventL()
       
   840     {
       
   841     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleIdleForegroundEventL( ) ");
       
   842     // Empty implementation
       
   843     }
       
   844 
   705 
   845 // -----------------------------------------------------------
   706 // -----------------------------------------------------------
   846 // CPhoneState::HandlePhoneStartupL
   707 // CPhoneState::HandlePhoneStartupL
   847 // -----------------------------------------------------------
   708 // -----------------------------------------------------------
   848 //
   709 //
   860     const TUid& aCategory,
   721     const TUid& aCategory,
   861     const TUint aKey,
   722     const TUint aKey,
   862     const TInt aValue )
   723     const TInt aValue )
   863     {
   724     {
   864     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePropertyChangedL( ) ");
   725     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePropertyChangedL( ) ");
   865     __PHONELOG1( EBasic, EPhoneControl,
   726     if ( ( aCategory == KPSUidStartup  ) && 
   866             "CPhoneState::HandlePropertyChangedL - aCategory= %d", aCategory  );
   727          ( aKey == KStartupSimSecurityStatus ) && 
   867     __PHONELOG1( EBasic, EPhoneControl,
   728          ( aValue == ESimRejected || aValue == ESimUnaccepted ) )
   868             "CPhoneState::HandlePropertyChangedL - aKey= %d", aKey  );
   729         {
   869     __PHONELOG1( EBasic, EPhoneControl,
   730        
   870             "CPhoneState::HandlePropertyChangedL - aValue= %d", aValue  );
   731         __PHONELOG3( EBasic, EPhoneControl,
   871     if ( aCategory == KPSUidTelInformation && SimState() == EPESimUsable )
   732                 "CPhoneState::HandlePropertyChangedL -aCategory= %d, aKey= %d, aValue= %d",
   872         {
   733                 aCategory, aKey, aValue );
   873         if ( aKey == KTelDisplayInfo )
       
   874             {
       
   875             __PHONELOG( EBasic, EPhoneControl, 
       
   876                     "CPhoneState::HandlePropertyChangedL - telephony display info received" );
       
   877             }
       
   878         }
       
   879     else if ( aCategory == KPSUidStartup && aKey == KStartupSimSecurityStatus )
       
   880         {
       
   881         // Show security note, SIM is not valid.
   734         // Show security note, SIM is not valid.
   882         if ( aValue == ESimRejected ||  aValue == ESimUnaccepted )
   735         StartShowSecurityNoteL();
   883             {
   736         }
   884             __PHONELOG( EBasic, EPhoneControl, "CPhoneStateStartup::HandlePropertyChangedL - SimSecurity status received" );
       
   885             StartShowSecurityNoteL();
       
   886             }
       
   887         }
       
   888     else if ( aCategory == KPSUidHWRM && aKey == KHWRMGripStatus )
       
   889         {
       
   890         UpdateCbaSwivelStateChangedL();
       
   891         }
       
   892     }
       
   893 
       
   894 // -----------------------------------------------------------
       
   895 // CPhoneState::HandleCenRepChangeL
       
   896 // -----------------------------------------------------------
       
   897 //
       
   898 EXPORT_C void CPhoneState::HandleCenRepChangeL(
       
   899     const TUid& /*aUid*/,
       
   900     const TUint /*aId*/ )
       
   901     {
       
   902     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCenRepChangeL( ) ");
       
   903     }
       
   904 
       
   905 // -----------------------------------------------------------
       
   906 // CPhoneState::NeedToSendToBackgroundL
       
   907 // -----------------------------------------------------------
       
   908 //
       
   909 EXPORT_C TBool CPhoneState::NeedToSendToBackgroundL() const
       
   910     {
       
   911     return iViewCommandHandle->HandleCommandL(
       
   912         EPhoneViewGetNeedToSendToBackgroundStatus ) ==
       
   913         EPhoneViewResponseSuccess;
       
   914     }
       
   915 
       
   916 // -----------------------------------------------------------
       
   917 // CPhoneState::TopAppIsDisplayedL
       
   918 // -----------------------------------------------------------
       
   919 //
       
   920 EXPORT_C TBool CPhoneState::TopAppIsDisplayedL() const
       
   921     {
       
   922     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::TopAppIsDisplayedL( ) ");
       
   923     return iViewCommandHandle->HandleCommandL(
       
   924         EPhoneViewGetTopApplicationIsDisplayedStatus ) ==
       
   925         EPhoneViewResponseSuccess;
       
   926     }
   737     }
   927 
   738 
   928 // <---------------------------- MENU AND CBA EVENTS ------------------------->
   739 // <---------------------------- MENU AND CBA EVENTS ------------------------->
   929 EXPORT_C TBool CPhoneState::HandleCommandL( TInt aCommand )
   740 EXPORT_C TBool CPhoneState::HandleCommandL( TInt aCommand )
   930     {
   741     {
   939             // Do state-specific behaviour if number entry is cleared
   750             // Do state-specific behaviour if number entry is cleared
   940             HandleNumberEntryClearedL();
   751             HandleNumberEntryClearedL();
   941             break;
   752             break;
   942 
   753 
   943         case EPhoneDialerCmdTouchInput:
   754         case EPhoneDialerCmdTouchInput:
   944         case EPhoneNumberAcqCmdSendMessage:
       
   945         case EPhoneNumberAcqCmdSave:
   755         case EPhoneNumberAcqCmdSave:
   946         case EPhoneNumberAcqCmdAddToName:
   756         case EPhoneNumberAcqCmdAddToName:
   947             break;
   757             break;
   948 
   758 
   949         case EPhoneNumberAcqCmdAddToContacts:
   759         case EPhoneNumberAcqCmdAddToContacts:
   964 
   774 
   965         case EPhoneInCallCmdEndThisOutgoingCall:
   775         case EPhoneInCallCmdEndThisOutgoingCall:
   966             DisconnectCallL();
   776             DisconnectCallL();
   967             break;
   777             break;
   968 
   778 
   969         case EPhoneCmdYesAlsLineChange:
       
   970             if( IsAlsLineChangePossible() )
       
   971                 {
       
   972                 ChangeAlsLineL();
       
   973                 }
       
   974             else
       
   975                 {
       
   976                 SendGlobalErrorNoteL( EPhoneLineBlockingNote );
       
   977                 HandleNumberEntryClearedL();
       
   978                 }
       
   979             break;
       
   980 
       
   981         case EPhoneCmdYesBtDisconnectQuery:
   779         case EPhoneCmdYesBtDisconnectQuery:
   982         case EPhoneCmdNoBtDisconnectQuery:
   780         case EPhoneCmdNoBtDisconnectQuery:
   983             CPhoneBtaaDisconnectHandler::InstanceL()->HandleQueryDismissL( aCommand );
   781             CPhoneBtaaDisconnectHandler::InstanceL()->HandleQueryDismissL( aCommand );
   984             // Make sure that query is removed
   782             // Make sure that query is removed
   985             // if there has been also another ( by Cover UI ).
   783             // if there has been also another ( by Cover UI ).
   995         case EPhoneInCallCmdBtHandsfree:
   793         case EPhoneInCallCmdBtHandsfree:
   996             CPhoneState::SetBTHandsfreeModeL(
   794             CPhoneState::SetBTHandsfreeModeL(
   997                  aCommand == EPhoneInCallCmdBtHandsfree );
   795                  aCommand == EPhoneInCallCmdBtHandsfree );
   998             break;
   796             break;
   999 
   797 
  1000         case EPhoneCmdNoAlsLineChange:
       
  1001         case EPhoneInCallCmdActivatEPhonebook:
   798         case EPhoneInCallCmdActivatEPhonebook:
  1002         case EPhoneNumberAcqSecurityDialer:
   799         case EPhoneNumberAcqSecurityDialer:
  1003         case EPhoneDialerCmdContacts:
   800         case EPhoneDialerCmdContacts:
  1004         case EPhoneNumberAcqCmdToggleNeAlphaMode:
   801         case EPhoneNumberAcqCmdToggleNeAlphaMode:
  1005         case EPhoneNumberAcqCmdToggleNeNumericMode:
   802         case EPhoneNumberAcqCmdToggleNeNumericMode:
  1006             break;
   803             break;
  1007 
   804         
  1008         case EPhoneCmdYesVideoFailedNoMemorySwitchToVoice:
       
  1009             DialVoiceCallL();
       
  1010             break;
       
  1011 
       
  1012         case EPhoneCmdNoVideoFailedNoMemorySwitchToVoice:
       
  1013             if ( IsNumberEntryUsedL() )
       
  1014                 {
       
  1015                 SetNumberEntryVisibilityL(ETrue);
       
  1016                 }
       
  1017             else if ( NeedToSendToBackgroundL() )
       
  1018                 {
       
  1019                 // Continue displaying current app but set up the
       
  1020                 // idle screen in the background
       
  1021                 SetupIdleScreenInBackgroundL();
       
  1022                 }
       
  1023             else
       
  1024                 {
       
  1025                 DisplayIdleScreenL();
       
  1026                 }
       
  1027             break;
       
  1028 
       
  1029         case EPhoneInCallCmdSetVolumeLevel:
   805         case EPhoneInCallCmdSetVolumeLevel:
  1030             {
   806             {
  1031             // This command comes from ui control, no need to update
   807             // This command comes from ui control, no need to update
  1032             // value to control (second parameter set false).
   808             // value to control (second parameter set false).
  1033             ChangeAudioVolumeL( GetVolumeLevel(), EFalse );
   809             ChangeAudioVolumeL( GetVolumeLevel(), EFalse );
  1229 //
  1005 //
  1230 EXPORT_C TBool CPhoneState::DisconnectCallL()
  1006 EXPORT_C TBool CPhoneState::DisconnectCallL()
  1231     {
  1007     {
  1232     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
  1008     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
  1233     TPhoneCmdParamInteger callIdParam;
  1009     TPhoneCmdParamInteger callIdParam;
  1234     iViewCommandHandle->ExecuteCommandL( 
  1010     iViewCommandHandle->ExecuteCommand( 
  1235             EPhoneViewGetExpandedBubbleCallId, &callIdParam );
  1011             EPhoneViewGetExpandedBubbleCallId, &callIdParam );
  1236     TBool ret = EFalse;
  1012     TBool ret = EFalse;
  1237     if( callIdParam.Integer() > KErrNotFound )
  1013     if( callIdParam.Integer() > KErrNotFound )
  1238         {
  1014         {
  1239         iStateMachine->SetCallId( callIdParam.Integer() );
  1015         iStateMachine->SetCallId( callIdParam.Integer() );
  1264         }
  1040         }
  1265     return ret;
  1041     return ret;
  1266     }
  1042     }
  1267 
  1043 
  1268 // -----------------------------------------------------------
  1044 // -----------------------------------------------------------
  1269 // CPhoneState::DisplayIdleScreenL
  1045 // CPhoneState::RemoveDialogsAndSendPhoneToBackgroundL()
  1270 // -----------------------------------------------------------
  1046 // -----------------------------------------------------------
  1271 //
  1047 //
  1272 EXPORT_C void CPhoneState::DisplayIdleScreenL()
  1048 EXPORT_C void CPhoneState::RemoveDialogsAndSendPhoneToBackgroundL()
  1273     {
  1049     {
  1274     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisplayIdleScreenL( ) ");
  1050     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::RemoveDialogsAndSendPhoneToBackgroundL( ) ");
  1275 
       
  1276      iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  1277 
       
  1278     // Set Empty CBA
       
  1279     iCbaManager->SetCbaL( EPhoneEmptyCBA );
       
  1280     // Bring Idle app to the foreground
       
  1281     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringIdleToForeground );
       
  1282     }
       
  1283 
       
  1284 // -----------------------------------------------------------
       
  1285 // CPhoneState::SetupIdleScreenInBackgroundL()
       
  1286 // -----------------------------------------------------------
       
  1287 //
       
  1288 EXPORT_C void CPhoneState::SetupIdleScreenInBackgroundL()
       
  1289     {
       
  1290     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetupIdleScreenInBackgroundL( ) ");
       
  1291     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  1051     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  1292     iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
  1052     iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
  1293     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIdleTopApplication );
  1053     UpdateUiCommands();
  1294     iCbaManager->SetCbaL( EPhoneEmptyCBA );
       
  1295     }
       
  1296 
       
  1297 // ---------------------------------------------------------
       
  1298 // CPhoneState::CallFromNumberEntryL
       
  1299 // ---------------------------------------------------------
       
  1300 //
       
  1301 EXPORT_C void CPhoneState::CallFromNumberEntryL()
       
  1302     {
       
  1303     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CallFromNumberEntryL( ) ");
       
  1304     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
       
  1305     if ( IsCustomizedDialerVisibleL() )
       
  1306         {
       
  1307         return;
       
  1308         }
       
  1309     else if( IsNumberEntryUsedL() )
       
  1310         {
       
  1311         // IS query on top of dialer
       
  1312         if ( IsAnyQueryActiveL() )
       
  1313             {
       
  1314             return;
       
  1315             }
       
  1316         // Open recent calls list when the number entry is empty
       
  1317         TPhoneCmdParamInteger numberEntryCountParam;
       
  1318         iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
       
  1319         &numberEntryCountParam );
       
  1320         TInt neLength( numberEntryCountParam.Integer() );
       
  1321         TBool startLogs = neLength == 0 ? ETrue : EFalse;
       
  1322 
       
  1323         if ( startLogs )
       
  1324             {
       
  1325             iViewCommandHandle->HandleCommandL(
       
  1326             EPhoneDialerCmdLog );
       
  1327             return;
       
  1328             }
       
  1329         }
       
  1330 
       
  1331     HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
  1332     iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
       
  1333     if ( phoneNumber->Des().Length() < KPhoneValidPhoneNumberLength )
       
  1334         {
       
  1335         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1336         HandleNumberEntryClearedL();
       
  1337         }
       
  1338     CleanupStack::PopAndDestroy( phoneNumber );
       
  1339 
       
  1340     if ( !iCustomization ||
       
  1341          !iCustomization->HandleCallFromNumberEntryL() )
       
  1342         {
       
  1343         // Customization didn't handle call. Dial voice call
       
  1344         // as normally
       
  1345         DialVoiceCallL();
       
  1346         }
       
  1347 
       
  1348     }
       
  1349 
       
  1350 // -----------------------------------------------------------
       
  1351 // CPhoneState::DisplayHeaderForCallComingInL
       
  1352 // -----------------------------------------------------------
       
  1353 //
       
  1354 EXPORT_C void CPhoneState::DisplayHeaderForCallComingInL(
       
  1355     TInt aCallId,
       
  1356     TBool aWaitingCall )
       
  1357     {
       
  1358     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisplayHeaderForCallComingInL( ) ");
       
  1359     CallheaderManagerL()->DisplayHeaderForCallComingInL( aCallId, aWaitingCall );
       
  1360     }
       
  1361 
       
  1362 // -----------------------------------------------------------
       
  1363 // CPhoneState::SetCallHeaderTextsForCallComingInL
       
  1364 // -----------------------------------------------------------
       
  1365 //
       
  1366 EXPORT_C void CPhoneState::SetCallHeaderTextsForCallComingInL(
       
  1367         TInt aCallId,
       
  1368         TBool aWaitingCall,
       
  1369         TPhoneCmdParamCallHeaderData* aCallHeaderData )
       
  1370     {
       
  1371     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetCallHeaderTextsForCallComingInL( ) ");
       
  1372     CallheaderManagerL()->SetCallHeaderTextsForCallComingIn( aCallId, aWaitingCall, aCallHeaderData );
       
  1373     }
       
  1374 
       
  1375 // -----------------------------------------------------------
       
  1376 // CPhoneState::DisplayHeaderForOutgoingCallL
       
  1377 // -----------------------------------------------------------
       
  1378 //
       
  1379 EXPORT_C void CPhoneState::DisplayHeaderForOutgoingCallL(
       
  1380     TInt aCallId )
       
  1381     {
       
  1382     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisplayHeaderForOutgoingCallL( ) ");
       
  1383     CallheaderManagerL()->DisplayHeaderForOutgoingCallL(aCallId);
       
  1384     }
  1054     }
  1385 
  1055 
  1386 // -----------------------------------------------------------
  1056 // -----------------------------------------------------------
  1387 // CPhoneState::UpdateSingleActiveCallL
  1057 // CPhoneState::UpdateSingleActiveCallL
  1388 // -----------------------------------------------------------
  1058 // -----------------------------------------------------------
  1389 //
  1059 //
  1390 EXPORT_C void CPhoneState::UpdateSingleActiveCallL( TInt aCallId )
  1060 EXPORT_C void CPhoneState::UpdateSingleActiveCallL( TInt aCallId )
  1391     {
  1061     {
  1392     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateSingleActiveCallL( ) ");
  1062     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateSingleActiveCallL( ) ");
  1393     BeginUiUpdateLC();
  1063     BeginUiUpdateLC();
  1394     TPhoneCmdParamCallHeaderData callHeaderParam;
  1064 
  1395     callHeaderParam.SetCallState( EPEStateConnected );
  1065     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId);
  1396     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
       
  1397         &callHeaderParam );
       
  1398     
  1066     
  1399     UpdateRemoteInfoDataL( aCallId );
  1067     UpdateRemoteInfoDataL( aCallId );
  1400 
  1068 
  1401     // Create call duration label if enabled
  1069     // Create call duration label if enabled
  1402     // This key will be moved to some other area, but since key
  1070     // This key will be moved to some other area, but since key
  1407 
  1075 
  1408     if ( callDuration )
  1076     if ( callDuration )
  1409         {
  1077         {
  1410         HandleChangedCallDurationL( aCallId );
  1078         HandleChangedCallDurationL( aCallId );
  1411         }
  1079         }
       
  1080     UpdateUiCommands();
  1412     EndUiUpdate();
  1081     EndUiUpdate();
  1413 
  1082     
  1414     iCbaManager->UpdateInCallCbaL();
       
  1415     // If there is no need to send back ground and number entry is used then
  1083     // If there is no need to send back ground and number entry is used then
  1416     // we must show number entry.
  1084     // we must show number entry.
  1417     if ( !NeedToSendToBackgroundL() && IsNumberEntryUsedL() && !IsAutoLockOn() )
  1085     if ( iNumberEntryManager->IsNumberEntryUsedL() && !IsAutoLockOn() )
  1418         {
  1086         {
  1419         SetNumberEntryVisibilityL(ETrue);
  1087         iNumberEntryManager->SetNumberEntryVisibilityL(ETrue);
  1420         }
  1088         }
  1421     }
  1089     }
  1422 
  1090 
  1423 // -----------------------------------------------------------
  1091 // -----------------------------------------------------------
  1424 // CPhoneState::IsWaitingCallL
  1092 // CPhoneState::IsWaitingCallL
  1425 // -----------------------------------------------------------
  1093 // -----------------------------------------------------------
  1426 //
  1094 //
  1427 TBool CPhoneState::IsWaitingCallL( const TInt aCallId  )
  1095 TBool CPhoneState::IsWaitingCallL( const TInt aCallId  )
  1428     {
  1096     {
  1429     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsWaitingCallL( ) ");
  1097     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsWaitingCallL( ) ");
  1430     return CallheaderManagerL()->IsWaitingCallL( aCallId );
  1098     TBool waiting( EFalse );
  1431     }
  1099     if ( aCallId >= 0 && 
  1432 
  1100          iStateMachine->PhoneEngineInfo()->CallState( aCallId ) == EPEStateRinging )
  1433 // -----------------------------------------------------------
  1101         {
  1434 // CPhoneState::UpdateCallHeaderInfoL
  1102         TPhoneCmdParamInteger activeCallCount;
  1435 // -----------------------------------------------------------
  1103         iViewCommandHandle->ExecuteCommandL(
  1436 //
  1104             EPhoneViewGetCountOfActiveCalls, &activeCallCount );
  1437 TPhoneCmdParamCallHeaderData CPhoneState::UpdateCallHeaderInfoL( TInt aCallId )
  1105         
  1438     {
  1106         if( activeCallCount.Integer() > 0 )
  1439     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateCallHeaderInfoL( ) ");
  1107             {
  1440     return CallheaderManagerL()->UpdateCallHeaderInfoL( aCallId );
  1108             waiting = ETrue;
       
  1109             }
       
  1110         }
       
  1111     
       
  1112     return waiting;
  1441     }
  1113     }
  1442 
  1114 
  1443 // -----------------------------------------------------------
  1115 // -----------------------------------------------------------
  1444 // CPhoneState::UpdateRemoteInfoDataL
  1116 // CPhoneState::UpdateRemoteInfoDataL
  1445 // -----------------------------------------------------------
  1117 // -----------------------------------------------------------
  1446 //
  1118 //
  1447 EXPORT_C void CPhoneState::UpdateRemoteInfoDataL( TInt aCallId )
  1119 EXPORT_C void CPhoneState::UpdateRemoteInfoDataL( TInt aCallId )
  1448     {
  1120     {
  1449     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::UpdateRemoteInfoDataL() ");
  1121     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::UpdateRemoteInfoDataL() ");
  1450     TPhoneCmdParamCallHeaderData callHeaderParam = UpdateCallHeaderInfoL( aCallId );
  1122     /*TPhoneCmdParamCallHeaderData callHeaderParam = UpdateCallHeaderInfoL( aCallId );
  1451     if( iCustomization )
  1123     if( iCustomization )
  1452         {
  1124         {
  1453         TBuf<KCntMaxTextFieldLength> inCallNumberText( KNullDesC );
  1125         TBuf<KCntMaxTextFieldLength> inCallNumberText( KNullDesC );
  1454         // to check if we have VoIP call in question and fix
  1126         // to check if we have VoIP call in question and fix
  1455         // parameters if needed
  1127         // parameters if needed
  1456         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
  1128         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
  1457             inCallNumberText );
  1129             inCallNumberText );
  1458         }
  1130         }*/
       
  1131     //TODO
  1459     // Update the remote info data in the call header
  1132     // Update the remote info data in the call header
  1460     iViewCommandHandle->ExecuteCommandL(
  1133     iViewCommandHandle->ExecuteCommandL(
  1461         EPhoneViewUpdateCallHeaderRemoteInfoData,
  1134         EPhoneViewUpdateCallHeaderRemoteInfoData,
  1462         aCallId,
  1135         aCallId );
  1463         &callHeaderParam );
  1136     
  1464     }
       
  1465 
       
  1466 // -----------------------------------------------------------
       
  1467 // CPhoneState::SetCallHeaderType
       
  1468 // -----------------------------------------------------------
       
  1469 //
       
  1470 EXPORT_C void CPhoneState::SetCallHeaderType(
       
  1471     TInt aCallHeaderType )
       
  1472     {
       
  1473     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetCallHeaderType() ");
       
  1474     TRAP_IGNORE( CallheaderManagerL()->SetCallHeaderType( aCallHeaderType ) );
       
  1475     }
       
  1476 
       
  1477 // -----------------------------------------------------------
       
  1478 // CPhoneState::GetRemoteInfoDataL
       
  1479 // -----------------------------------------------------------
       
  1480 //
       
  1481 EXPORT_C void CPhoneState::GetRemoteInfoDataL(
       
  1482     TInt aCallId,
       
  1483     TDes& aData )
       
  1484     {
       
  1485     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::GetRemoteInfoDataL() ");
       
  1486     CallheaderManagerL()->GetRemoteInfoDataL( aCallId, aData );
       
  1487     }
       
  1488 
       
  1489 // -----------------------------------------------------------
       
  1490 // CPhoneState::UpdateCbaSwivelStateChangedL
       
  1491 // -----------------------------------------------------------
       
  1492 //
       
  1493 void CPhoneState::UpdateCbaSwivelStateChangedL()
       
  1494     {
       
  1495     __LOGMETHODSTARTEND(EPhoneControl,"CPhoneState::UpdateCbaSwivelStateChangedL()" );
       
  1496     TPhoneCmdParamCallStateData callStateData;
       
  1497     callStateData.SetCallState( EPEStateRinging );
       
  1498     iViewCommandHandle->HandleCommandL(
       
  1499         EPhoneViewGetCallIdByState, &callStateData );
       
  1500     TInt incomingCall = callStateData.CallId();
       
  1501 
       
  1502     TPhoneCmdParamInteger activeCallCount;
       
  1503     iViewCommandHandle->ExecuteCommandL(
       
  1504             EPhoneViewGetCountOfActiveCalls, &activeCallCount );
       
  1505 
       
  1506     if ( incomingCall > KErrNotFound )
       
  1507         {
       
  1508        if( activeCallCount.Integer() == ENoActiveCalls )
       
  1509             {
       
  1510             iCbaManager->UpdateIncomingCbaL( incomingCall );
       
  1511             }
       
  1512         else
       
  1513             {
       
  1514             iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
       
  1515             }
       
  1516         }
       
  1517     else if ( activeCallCount.Integer() != ENoActiveCalls )
       
  1518         {
       
  1519         iCbaManager->UpdateInCallCbaL();
       
  1520         }
       
  1521     }
       
  1522 
       
  1523 // -----------------------------------------------------------------------------
       
  1524 // CPhoneState::IsSwivelClosed
       
  1525 // This function checks from PubSubProxy that is
       
  1526 // Swivel closed or not in product.
       
  1527 //
       
  1528 // -----------------------------------------------------------------------------
       
  1529 //
       
  1530 EXPORT_C TBool CPhoneState::IsSwivelClosed() const
       
  1531     {
       
  1532     if( CPhoneCenRepProxy::Instance()->
       
  1533             IsTelephonyFeatureSupported( KTelephonyLVFlagSwivelInDevice ))
       
  1534         {
       
  1535         return CPhonePubSubProxy::Instance()->
       
  1536             Value( KPSUidHWRM, KHWRMGripStatus ) == EPSHWRMGripClosed;
       
  1537         }
       
  1538     else
       
  1539         {
       
  1540         return EFalse;
       
  1541         }
       
  1542     }
  1137     }
  1543 
  1138 
  1544 // <-------------------------- CONTEXT MENU ------------------------->
  1139 // <-------------------------- CONTEXT MENU ------------------------->
  1545 
  1140 
  1546 // -----------------------------------------------------------
  1141 // -----------------------------------------------------------
  1636 
  1231 
  1637         // Format the time
  1232         // Format the time
  1638         TBuf<KPhoneMaxTimeDisplayTextLength> timeString( KNullDesC );
  1233         TBuf<KPhoneMaxTimeDisplayTextLength> timeString( KNullDesC );
  1639         time.FormatL( timeString, durationFormat );
  1234         time.FormatL( timeString, durationFormat );
  1640 
  1235 
  1641         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString );
       
  1642 
       
  1643         noteText.Append( timeString );
  1236         noteText.Append( timeString );
  1644 
  1237 
  1645         TPhoneCmdParamGlobalNote globalNoteParam;
  1238         TPhoneCmdParamGlobalNote globalNoteParam;
  1646         globalNoteParam.SetType( EPhoneMessageBoxInformation );
  1239         globalNoteParam.SetType( EPhoneMessageBoxInformation );
  1647         globalNoteParam.SetText( noteText );
  1240         globalNoteParam.SetText( noteText );
  1658 EXPORT_C void CPhoneState::SendGlobalInfoNoteL( 
  1251 EXPORT_C void CPhoneState::SendGlobalInfoNoteL( 
  1659         TInt aResourceId, TBool aNotificationDialog )
  1252         TInt aResourceId, TBool aNotificationDialog )
  1660     {
  1253     {
  1661     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalInfoNoteL( ) ");
  1254     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalInfoNoteL( ) ");
  1662     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  1255     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  1663     if ( CPhonePubSubProxy::Instance()->Value(
  1256     
  1664             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  1257     // Avkon removal
  1665         {
  1258     TPhoneCmdParamBoolean globalNotifierParam;
  1666         TPhoneCmdParamBoolean globalNotifierParam;
  1259     globalNotifierParam.SetBoolean( EFalse );
  1667         globalNotifierParam.SetBoolean( EFalse );
  1260     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1668         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1261         &globalNotifierParam );
  1669             &globalNotifierParam );
  1262 
  1670 
  1263     TPhoneCmdParamGlobalNote globalNoteParam;
  1671         TPhoneCmdParamGlobalNote globalNoteParam;
  1264     PhoneNotificationType type = aNotificationDialog ? 
  1672         PhoneNotificationType type = aNotificationDialog ? 
  1265         EPhoneNotificationDialog : EPhoneMessageBoxInformation;
  1673             EPhoneNotificationDialog : EPhoneMessageBoxInformation;
  1266     globalNoteParam.SetType( type );
  1674         globalNoteParam.SetType( type );
  1267     globalNoteParam.SetTextResourceId(
  1675         globalNoteParam.SetTextResourceId(
  1268         CPhoneMainResourceResolver::Instance()->
  1676             CPhoneMainResourceResolver::Instance()->
  1269         ResolveResourceID( aResourceId ) );
  1677             ResolveResourceID( aResourceId ) );
  1270     globalNoteParam.SetNotificationDialog( aNotificationDialog );
  1678         globalNoteParam.SetNotificationDialog( aNotificationDialog );
  1271     
       
  1272     iViewCommandHandle->ExecuteCommandL(
       
  1273         EPhoneViewShowGlobalNote, &globalNoteParam );
  1679         
  1274         
  1680         iViewCommandHandle->ExecuteCommandL(
       
  1681             EPhoneViewShowGlobalNote, &globalNoteParam );
       
  1682         }
       
  1683     }
  1275     }
  1684 
  1276 
  1685 // ---------------------------------------------------------
  1277 // ---------------------------------------------------------
  1686 //  CPhoneUIController::SendGlobalWarningNoteL
  1278 //  CPhoneUIController::SendGlobalWarningNoteL
  1687 // ---------------------------------------------------------
  1279 // ---------------------------------------------------------
  1689 EXPORT_C void CPhoneState::SendGlobalWarningNoteL( 
  1281 EXPORT_C void CPhoneState::SendGlobalWarningNoteL( 
  1690         TInt aResourceId, TBool aNotificationDialog )
  1282         TInt aResourceId, TBool aNotificationDialog )
  1691     {
  1283     {
  1692     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalWarningNoteL( ) ");
  1284     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalWarningNoteL( ) ");
  1693     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  1285     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  1694     if ( CPhonePubSubProxy::Instance()->Value(
  1286     if ( SimState() == EPESimReadable )
  1695             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 ||
       
  1696             SimState() == EPESimReadable )
       
  1697         {
  1287         {
  1698         TPhoneCmdParamBoolean globalNotifierParam;
  1288         TPhoneCmdParamBoolean globalNotifierParam;
  1699         globalNotifierParam.SetBoolean( EFalse );
  1289         globalNotifierParam.SetBoolean( EFalse );
  1700         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1290         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1701             &globalNotifierParam );
  1291             &globalNotifierParam );
  1721 EXPORT_C void CPhoneState::SendGlobalErrorNoteL( 
  1311 EXPORT_C void CPhoneState::SendGlobalErrorNoteL( 
  1722         TInt aResourceId, TBool aNotificationDialog )
  1312         TInt aResourceId, TBool aNotificationDialog )
  1723     {
  1313     {
  1724     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalErrorNoteL( ) ");
  1314     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalErrorNoteL( ) ");
  1725     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  1315     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
  1726     if ( CPhonePubSubProxy::Instance()->Value(
  1316 
  1727             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
  1317     TPhoneCmdParamBoolean globalNotifierParam;
  1728         {
  1318     globalNotifierParam.SetBoolean( EFalse );
  1729         TPhoneCmdParamBoolean globalNotifierParam;
  1319     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1730         globalNotifierParam.SetBoolean( EFalse );
  1320         &globalNotifierParam );
  1731         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1321 
  1732             &globalNotifierParam );
  1322     TPhoneCmdParamGlobalNote globalNoteParam;
  1733 
  1323     PhoneNotificationType type = aNotificationDialog ? 
  1734         TPhoneCmdParamGlobalNote globalNoteParam;
  1324                 EPhoneNotificationDialog : EPhoneMessageBoxInformation;
  1735         PhoneNotificationType type = aNotificationDialog ? 
  1325     globalNoteParam.SetType( type );
  1736                     EPhoneNotificationDialog : EPhoneMessageBoxInformation;
  1326     
  1737         globalNoteParam.SetType( type );
  1327     globalNoteParam.SetTextResourceId(
  1738         
  1328         CPhoneMainResourceResolver::Instance()->
  1739         globalNoteParam.SetTextResourceId(
  1329         ResolveResourceID( aResourceId ) );
  1740             CPhoneMainResourceResolver::Instance()->
  1330     globalNoteParam.SetNotificationDialog( aNotificationDialog );
  1741             ResolveResourceID( aResourceId ) );
  1331 
  1742         globalNoteParam.SetNotificationDialog( aNotificationDialog );
  1332     iViewCommandHandle->ExecuteCommandL(
  1743 
  1333         EPhoneViewShowGlobalNote, &globalNoteParam );
  1744         iViewCommandHandle->ExecuteCommandL(
  1334 
  1745             EPhoneViewShowGlobalNote, &globalNoteParam );
       
  1746         }
       
  1747     }
  1335     }
  1748 
  1336 
  1749 // ---------------------------------------------------------
  1337 // ---------------------------------------------------------
  1750 // CPhoneState::SetHandsfreeModeL
  1338 // CPhoneState::SetHandsfreeModeL
  1751 // ---------------------------------------------------------
  1339 // ---------------------------------------------------------
  1788 void CPhoneState::HandleInitiatedEmergencyCallL( TInt /*aCallId*/ )
  1376 void CPhoneState::HandleInitiatedEmergencyCallL( TInt /*aCallId*/ )
  1789     {
  1377     {
  1790     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleInitiatedEmergencyCallL( ) ");
  1378     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleInitiatedEmergencyCallL( ) ");
  1791     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  1379     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  1792     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
  1380     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
  1793 
       
  1794     // Reset Hold flag to view
       
  1795     TPhoneCmdParamBoolean holdFlag;
       
  1796     holdFlag.SetBoolean( EFalse );
       
  1797     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
  1798     
  1381     
  1799     iStateMachine->ChangeState( EPhoneStateEmergency );
  1382     iStateMachine->ChangeState( EPhoneStateEmergency );
  1800     }
  1383     }
  1801 
  1384 
  1802 // -----------------------------------------------------------
  1385 // -----------------------------------------------------------
  1824 // -----------------------------------------------------------
  1407 // -----------------------------------------------------------
  1825 //
  1408 //
  1826 void CPhoneState::HandleCallSecureStatusChangeL( TInt aCallId )
  1409 void CPhoneState::HandleCallSecureStatusChangeL( TInt aCallId )
  1827     {
  1410     {
  1828     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCallSecureStatusChangeL( ) ");
  1411     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCallSecureStatusChangeL( ) ");
  1829     TBool ciphering( ETrue );
       
  1830     TBool secureSpecified( ETrue );
       
  1831     if ( aCallId > KErrNotFound )
       
  1832         {
       
  1833         ciphering = iStateMachine->PhoneEngineInfo()->IsSecureCall( aCallId );
       
  1834         secureSpecified = iStateMachine->PhoneEngineInfo()->SecureSpecified();
       
  1835         }
       
  1836     TPhoneCmdParamCallHeaderData callHeaderParam;
       
  1837     callHeaderParam.SetCiphering( ciphering );
       
  1838     callHeaderParam.SetCipheringIndicatorAllowed( secureSpecified );
       
  1839     iViewCommandHandle->ExecuteCommandL(
  1412     iViewCommandHandle->ExecuteCommandL(
  1840         EPhoneViewCipheringInfoChange,
  1413         EPhoneViewCipheringInfoChange,
  1841         aCallId,
  1414         aCallId);
  1842         &callHeaderParam );
       
  1843     }
  1415     }
  1844 
  1416 
  1845 // ---------------------------------------------------------
  1417 // ---------------------------------------------------------
  1846 // CPhoneState::IsVideoCall
  1418 // CPhoneState::IsVideoCall
  1847 // ---------------------------------------------------------
  1419 // ---------------------------------------------------------
  1848 //
  1420 //
  1849 EXPORT_C TBool CPhoneState::IsVideoCall( const TInt aCallId )
  1421 EXPORT_C TBool CPhoneState::IsVideoCall( const TInt aCallId )
  1850     {
  1422     {
  1851     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsVideoCall( ) ");
  1423     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsVideoCall( ) ");
  1852     TBool isVideoCall( EFalse );
  1424     if ( aCallId < 0 )
  1853     TRAP_IGNORE( isVideoCall = CallheaderManagerL()->IsVideoCall( aCallId ) );
  1425         {
  1854     __PHONELOG1( EBasic, EPhoneControl, 
  1426         return EFalse;
  1855         "CPhoneState::IsVideoCall isVideoCall(%d)",
  1427         }
  1856         isVideoCall );
  1428 
  1857     return isVideoCall;
  1429     return EPECallTypeVideo == iStateMachine->PhoneEngineInfo()->CallType( aCallId );
  1858     }
       
  1859 
       
  1860 // ---------------------------------------------------------
       
  1861 // CPhoneState::ChangeAlsLineL
       
  1862 // ---------------------------------------------------------
       
  1863 //
       
  1864 void CPhoneState::ChangeAlsLineL()
       
  1865     {
       
  1866     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::ChangeAlsLineL( ) ");
       
  1867     CCCECallParameters::TCCELineType currentLine;
       
  1868     TSSSettingsAlsValue newLine( ESSSettingsAlsPrimary );
       
  1869     currentLine = iStateMachine->PhoneEngineInfo()->ALSLine();
       
  1870     if ( currentLine == CCCECallParameters::ECCELineTypePrimary )
       
  1871         {
       
  1872         newLine = ESSSettingsAlsAlternate;
       
  1873         }
       
  1874     else if ( currentLine == CCCECallParameters::ECCELineTypeAux )
       
  1875         {
       
  1876         newLine = ESSSettingsAlsPrimary;
       
  1877         }
       
  1878 
       
  1879     RSSSettings ssSettings;
       
  1880     TInt retValue = ssSettings.Open();
       
  1881     __PHONELOG1( EBasic, EPhoneControl,
       
  1882             "CPhoneState::ChangeAlsLineL : Open %d", retValue );
       
  1883     if ( retValue == KErrNone )
       
  1884         {
       
  1885         retValue = ssSettings.Set( ESSSettingsAls, newLine );
       
  1886         __PHONELOG1( EBasic, EPhoneControl,
       
  1887             "CPhoneState::ChangeAlsLineL : Set %d", retValue );
       
  1888         ssSettings.Close();
       
  1889         }
       
  1890     }
  1430     }
  1891 
  1431 
  1892 // ---------------------------------------------------------
  1432 // ---------------------------------------------------------
  1893 // CPhoneState::GetActiveCallIdL()
  1433 // CPhoneState::GetActiveCallIdL()
  1894 // ---------------------------------------------------------
  1434 // ---------------------------------------------------------
  2000         retValue = ETrue;
  1540         retValue = ETrue;
  2001         }
  1541         }
  2002     return retValue;
  1542     return retValue;
  2003     }
  1543     }
  2004 
  1544 
  2005 // ---------------------------------------------------------
       
  2006 // CPhoneState::SetDivertIndication
       
  2007 // ---------------------------------------------------------
       
  2008 //
       
  2009 EXPORT_C void CPhoneState::SetDivertIndication( const TBool aDivertIndication )
       
  2010     {
       
  2011     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetDivertIndication()");
       
  2012     TRAP_IGNORE( CallheaderManagerL()->SetDivertIndication( aDivertIndication ) );
       
  2013     }
       
  2014 
       
  2015 // -----------------------------------------------------------------------------
  1545 // -----------------------------------------------------------------------------
  2016 // CPhoneState::StartShowSecurityNoteL
  1546 // CPhoneState::StartShowSecurityNoteL
  2017 // -----------------------------------------------------------------------------
  1547 // -----------------------------------------------------------------------------
  2018 //
  1548 //
  2019 EXPORT_C void CPhoneState::StartShowSecurityNoteL()
  1549 EXPORT_C void CPhoneState::StartShowSecurityNoteL()
  2021     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::StartShowSecurityNoteL ");
  1551     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::StartShowSecurityNoteL ");
  2022     TPhoneCmdParamBoolean securityMode;
  1552     TPhoneCmdParamBoolean securityMode;
  2023     securityMode.SetBoolean( ETrue );
  1553     securityMode.SetBoolean( ETrue );
  2024     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSecurityMode, &securityMode );
  1554     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSecurityMode, &securityMode );
  2025     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
  1555     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
  2026     iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
  1556     UpdateUiCommands();
  2027     
  1557     
  2028     TPhoneCmdParamInteger uidParam;
  1558     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringPhoneAppToForeground );
  2029     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
  2030     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
  2031         &uidParam );
       
  2032     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
  2033         &uidParam );
       
  2034 
       
  2035     TInt resourceId ( KErrNone );
  1559     TInt resourceId ( KErrNone );
  2036     if ( SimSecurityStatus() == ESimRejected )
  1560     if ( SimSecurityStatus() == ESimRejected )
  2037         {
  1561         {
  2038         resourceId = CPhoneMainResourceResolver::Instance()->
  1562         resourceId = CPhoneMainResourceResolver::Instance()->
  2039             ResolveResourceID( EPhoneSimRejected );
  1563             ResolveResourceID( EPhoneSimRejected );
  2078 // ---------------------------------------------------------
  1602 // ---------------------------------------------------------
  2079 //
  1603 //
  2080 void CPhoneState::ShowWlanMacAddressL()
  1604 void CPhoneState::ShowWlanMacAddressL()
  2081     {
  1605     {
  2082     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::ShowWlanMacAddressL()");
  1606     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::ShowWlanMacAddressL()");
  2083     NumberEntryClearL();
  1607     iNumberEntryManager->NumberEntryClearL();
  2084     // Fetch WLAN MAC address
  1608     // Fetch WLAN MAC address
  2085     TBuf8<KPhoneWlanMacAddressLength> address;
  1609     TBuf8<KPhoneWlanMacAddressLength> address;
  2086     RProperty::Get(
  1610     RProperty::Get(
  2087         KPSUidWlan,
  1611         KPSUidWlan,
  2088         KPSWlanMacAddress,
  1612         KPSWlanMacAddress,
  2146     iViewCommandHandle->ExecuteCommandL( 
  1670     iViewCommandHandle->ExecuteCommandL( 
  2147             EPhoneViewActivateAudioAvailabilityUIChanges,
  1671             EPhoneViewActivateAudioAvailabilityUIChanges,
  2148             &outputParam );
  1672             &outputParam );
  2149     }
  1673     }
  2150 
  1674 
  2151 
       
  2152 // ---------------------------------------------------------
       
  2153 // CPhoneState::IsAlsLineChangePossible
       
  2154 // ---------------------------------------------------------
       
  2155 //
       
  2156 TBool CPhoneState::IsAlsLineChangePossible()
       
  2157     {
       
  2158     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsAlsLineChangePossible( ) ");
       
  2159     TBool isAlsLineChangePossible( ETrue );
       
  2160     TSSSettingsAlsBlockingValue AlsBlockingValue( ESSSettingsAlsBlockingNotSupported );
       
  2161     TInt value( 0 );
       
  2162     RSSSettings ssSettings;
       
  2163     TInt retValue = ssSettings.Open();
       
  2164     if ( retValue == KErrNone )
       
  2165         {
       
  2166         ssSettings.Get( ESSSettingsAlsBlocking, value );
       
  2167         ssSettings.Close();
       
  2168         AlsBlockingValue = static_cast< TSSSettingsAlsBlockingValue > ( value );
       
  2169         if( AlsBlockingValue == ESSSettingsAlsAlternate )
       
  2170             {
       
  2171             isAlsLineChangePossible = EFalse;
       
  2172             }
       
  2173         }
       
  2174     return isAlsLineChangePossible;
       
  2175     }
       
  2176 
       
  2177 // ---------------------------------------------------------
  1675 // ---------------------------------------------------------
  2178 // CPhoneState::ShowNumberBusyNoteL
  1676 // CPhoneState::ShowNumberBusyNoteL
  2179 // ---------------------------------------------------------
  1677 // ---------------------------------------------------------
  2180 //
  1678 //
  2181 EXPORT_C void CPhoneState::ShowNumberBusyNoteL()
  1679 EXPORT_C void CPhoneState::ShowNumberBusyNoteL()
  2221             phoneIsLocked );
  1719             phoneIsLocked );
  2222     return phoneIsLocked;
  1720     return phoneIsLocked;
  2223     }
  1721     }
  2224 
  1722 
  2225 // ---------------------------------------------------------
  1723 // ---------------------------------------------------------
  2226 // CPhoneState::IsKeyLockOn
       
  2227 // ---------------------------------------------------------
       
  2228 //
       
  2229 EXPORT_C TBool CPhoneState::IsKeyLockOn() const
       
  2230     {
       
  2231     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsKeyLockOn( ) ");
       
  2232     TPhoneCmdParamBoolean keyLockStatus;
       
  2233     keyLockStatus.SetBoolean( EFalse );
       
  2234     iViewCommandHandle->ExecuteCommand(
       
  2235             EPhoneViewGetKeyLockStatus,
       
  2236             &keyLockStatus );
       
  2237     __PHONELOG1( EBasic,
       
  2238             EPhoneControl,
       
  2239             "CPhoneState::IsKeyLockOn() Lock Status: %d",
       
  2240             keyLockStatus.Boolean() );
       
  2241     return keyLockStatus.Boolean();
       
  2242     }
       
  2243 
       
  2244 // ---------------------------------------------------------
       
  2245 // CPhoneState::CompleteSatRequestL
       
  2246 // ---------------------------------------------------------
       
  2247 //
       
  2248 EXPORT_C void CPhoneState::CompleteSatRequestL( const TInt aCallId )
       
  2249     {
       
  2250     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CompleteSatRequestL( ) ");
       
  2251     iStateMachine->SetCallId( aCallId );
       
  2252     iStateMachine->SendPhoneEngineMessage(
       
  2253         MPEPhoneModel::EPEMessageSatCallRequestCompleted );
       
  2254     }
       
  2255 
       
  2256 // ---------------------------------------------------------
       
  2257 // CPhoneState::SetTouchPaneButtons
       
  2258 // ---------------------------------------------------------
       
  2259 //
       
  2260 EXPORT_C void CPhoneState::SetTouchPaneButtons( TInt /*aResourceId*/ )
       
  2261     {
       
  2262     TPhoneCmdParamBoolean muteParam;
       
  2263     muteParam.SetBoolean( iStateMachine->PhoneEngineInfo()->AudioMute() );
       
  2264     iViewCommandHandle->ExecuteCommand(EPhoneViewSetMuteFlag,&muteParam);
       
  2265     
       
  2266     const TPEAudioOutput audioOutput =
       
  2267         iStateMachine->PhoneEngineInfo()->AudioOutput();
       
  2268 
       
  2269     TBool btAvailable = iStateMachine->PhoneEngineInfo()->AudioOutputAvailable(
       
  2270         EPEBTAudioAccessory );
       
  2271     
       
  2272     TPhoneCmdParamBoolean btParam;
       
  2273     btParam.SetBoolean( audioOutput == EPEBTAudioAccessory );        
       
  2274     iViewCommandHandle->ExecuteCommand(EPhoneViewSetBlueToothFlag,&btParam);
       
  2275 
       
  2276     TPhoneCmdParamBoolean btAvailableParam;
       
  2277     btAvailableParam.SetBoolean( btAvailable );        
       
  2278     iViewCommandHandle->ExecuteCommand(
       
  2279             EPhoneViewSetBluetoothAvailableFlag,&btAvailableParam);
       
  2280            
       
  2281     TBool emergency( EPEStateIdle != 
       
  2282         iStateMachine->PhoneEngineInfo()->CallState( KPEEmergencyCallId ) );
       
  2283     TPhoneCmdParamBoolean booleanParam;
       
  2284     booleanParam.SetBoolean( emergency );
       
  2285 
       
  2286     TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
       
  2287                  EPhoneViewSetTouchPaneButtons,
       
  2288                  &booleanParam ) );
       
  2289     }
       
  2290 
       
  2291 // ---------------------------------------------------------
       
  2292 // CPhoneState::DeleteTouchPaneButtons
  1724 // CPhoneState::DeleteTouchPaneButtons
  2293 // ---------------------------------------------------------
  1725 // ---------------------------------------------------------
  2294 //
  1726 //
  2295 EXPORT_C void CPhoneState::DeleteTouchPaneButtons()
  1727 EXPORT_C void CPhoneState::DeleteTouchPaneButtons()
  2296     {
  1728     {
  2297     TPhoneCmdParamBoolean boolParam;
  1729     /*TPhoneCmdParamBoolean boolParam;
  2298     TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
  1730     TRAP_IGNORE( iViewCommandHandle->ExecuteCommand(
  2299                     EPhoneViewSetTouchPaneButtons,
  1731                     EPhoneViewSetTouchPaneButtons,
  2300                     &boolParam ) );
  1732                     &boolParam ) );*/
  2301     }
  1733     }
  2302 
  1734 
  2303 // -----------------------------------------------------------
  1735 // -----------------------------------------------------------
  2304 // CPhoneState::BeginUiUpdateLC
  1736 // CPhoneState::BeginUiUpdateLC
  2305 // -----------------------------------------------------------
  1737 // -----------------------------------------------------------
  2371 EXPORT_C void CPhoneState::SetDefaultFlagsL()
  1803 EXPORT_C void CPhoneState::SetDefaultFlagsL()
  2372     {
  1804     {
  2373     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetDefaultFlagsL()");
  1805     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetDefaultFlagsL()");
  2374     iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
  1806     iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
  2375     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateFSW );
  1807     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateFSW );
  2376 
       
  2377     // Reset Hold flag to view
       
  2378     TPhoneCmdParamBoolean holdFlag;
       
  2379     holdFlag.SetBoolean( EFalse );
       
  2380     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
  2381     
  1808     
  2382     TPhoneCmdParamBoolean globalNotifierParam;
  1809     TPhoneCmdParamBoolean globalNotifierParam;
  2383     globalNotifierParam.SetBoolean( EFalse );
  1810     globalNotifierParam.SetBoolean( EFalse );
  2384     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1811     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2385         &globalNotifierParam );
  1812         &globalNotifierParam );
  2417     TPhoneCmdParamBoolean globalNotifierParam;
  1844     TPhoneCmdParamBoolean globalNotifierParam;
  2418     globalNotifierParam.SetBoolean( EFalse );
  1845     globalNotifierParam.SetBoolean( EFalse );
  2419     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  1846     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
  2420         &globalNotifierParam );
  1847         &globalNotifierParam );
  2421     
  1848     
  2422     TPhoneCmdParamInteger uidParam;
  1849     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringPhoneAppToForeground );
  2423     uidParam.SetInteger( KUidPhoneApplication.iUid );
  1850     
  2424     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
  2425         &uidParam );
       
  2426     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
  2427         &uidParam );
       
  2428 
       
  2429     // Display error note
  1851     // Display error note
  2430     SExtendedError ext;
  1852     SExtendedError ext;
  2431     ext.iComponent = KUidPhoneApplication;
  1853     ext.iComponent = KUidPhoneApplication;
  2432     ext.iErrorNumber = KErrNoMemory;
  1854     ext.iErrorNumber = KErrNoMemory;
  2433     ext.iInformation = EFalse;
  1855     ext.iInformation = EFalse;
  2448     ESimUnaccepted  // The SIM lock is on, so the card is unaccepted.
  1870     ESimUnaccepted  // The SIM lock is on, so the card is unaccepted.
  2449     */
  1871     */
  2450     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SimSecurityStatus()" );
  1872     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SimSecurityStatus()" );
  2451     return CPhonePubSubProxy::Instance()->Value(
  1873     return CPhonePubSubProxy::Instance()->Value(
  2452                     KPSUidStartup, KStartupSimSecurityStatus );
  1874                     KPSUidStartup, KStartupSimSecurityStatus );
  2453     }
       
  2454 
       
  2455 // -----------------------------------------------------------------------------
       
  2456 // CPhoneState::CallWaitingNoteL
       
  2457 // -----------------------------------------------------------------------------
       
  2458 //
       
  2459 EXPORT_C void CPhoneState::CallWaitingNoteL( TInt aCallId )
       
  2460     {
       
  2461     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CallWaitingNoteL()" );
       
  2462     TBuf< KPhoneContactNameMaxLength > callText( KNullDesC );
       
  2463     // Set CLI text for the call header
       
  2464     const TBool contactInfoAvailable =
       
  2465         iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ).Length() ||
       
  2466         iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ).Length();
       
  2467 
       
  2468     __PHONELOG1( EBasic, EPhoneControl,
       
  2469         "CPhoneState::CallWaitingNoteL - contactInfoAvailable(%d)", contactInfoAvailable );
       
  2470     __PHONELOG1( EBasic, EPhoneControl,
       
  2471         "CPhoneState::CallWaitingNoteL - remote name(%S)",
       
  2472         &iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ) );
       
  2473     __PHONELOG1( EBasic, EPhoneControl,
       
  2474         "CPhoneState::CallWaitingNoteL - company name(%S)",
       
  2475         &iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ) );
       
  2476     
       
  2477     if ( contactInfoAvailable )
       
  2478         {
       
  2479         // Set Call Text flag to waiting note
       
  2480         callText = iStateMachine->PhoneEngineInfo()->RemoteName( aCallId );
       
  2481 
       
  2482         // if no remote name available then set company name
       
  2483         if ( callText == KNullDesC )
       
  2484             {
       
  2485             callText = iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId );
       
  2486             }
       
  2487 
       
  2488         TPhoneCmdParamGlobalNote globalNoteParam;
       
  2489         globalNoteParam.SetText( callText );
       
  2490         globalNoteParam.SetType( EPhoneNotificationDialog );
       
  2491         globalNoteParam.SetTextResourceId(
       
  2492             CPhoneMainResourceResolver::Instance()->
       
  2493             ResolveResourceID( EPhoneCallWaitingWithLabel ) );
       
  2494         globalNoteParam.SetNotificationDialog( ETrue );
       
  2495         iViewCommandHandle->ExecuteCommandL(
       
  2496                 EPhoneViewShowGlobalNote, &globalNoteParam );
       
  2497         }
       
  2498     else
       
  2499         {
       
  2500         SendGlobalInfoNoteL( EPhoneCallWaitingWithoutLabel, ETrue );
       
  2501         }
       
  2502     }
  1875     }
  2503 
  1876 
  2504 // ----------------------------------------------------------------------------
  1877 // ----------------------------------------------------------------------------
  2505 // CPhoneState::SetRingingTonePlaybackL()
  1878 // CPhoneState::SetRingingTonePlaybackL()
  2506 // ----------------------------------------------------------------------------
  1879 // ----------------------------------------------------------------------------
  2623                 EPhoneViewShowGlobalNote, &globalNoteParam );
  1996                 EPhoneViewShowGlobalNote, &globalNoteParam );
  2624         CleanupStack::PopAndDestroy( buf );
  1997         CleanupStack::PopAndDestroy( buf );
  2625         }
  1998         }
  2626     }
  1999     }
  2627 
  2000 
  2628 // -----------------------------------------------------------
       
  2629 // CPhoneState::CallheaderManagerL
       
  2630 // -----------------------------------------------------------
       
  2631 //
       
  2632 CPhoneCallHeaderManager* CPhoneState::CallheaderManagerL()
       
  2633     {
       
  2634     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::CallheaderManagerL() ");
       
  2635     if ( !iCallHeaderManager )
       
  2636         {
       
  2637         iCallHeaderManager = CPhoneCallHeaderManager::NewL(
       
  2638                 *iViewCommandHandle,
       
  2639                 *iStateMachine,
       
  2640                 iCustomization );
       
  2641         }
       
  2642     return iCallHeaderManager;
       
  2643     }
       
  2644 
       
  2645 // ---------------------------------------------------------------------------
  2001 // ---------------------------------------------------------------------------
  2646 // CPhoneState::LoadResource
  2002 // CPhoneState::LoadResource
  2647 // ---------------------------------------------------------------------------
  2003 // ---------------------------------------------------------------------------
  2648 //
  2004 //
  2649 void CPhoneState::LoadResource( TDes& aData, const TInt aResource ) const
  2005 void CPhoneState::LoadResource( TDes& aData, const TInt aResource ) const
  2650     {
  2006     {
  2651     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::LoadResource() ");
  2007     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::LoadResource() ");
  2652     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::LoadResource - aResource: %d", aResource );
  2008     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::LoadResource - aResource: %d", aResource );
  2653     StringLoader::Load(  aData,
  2009     StringLoader::Load(  
  2654                          CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
  2010             aData,
  2655                          &iEnv  );
  2011             CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
       
  2012             EikonEnv() );
  2656     }
  2013     }
  2657 
  2014 
  2658 // -----------------------------------------------------------
  2015 // -----------------------------------------------------------
  2659 // CPhoneState::IsAnyConnectedCalls
  2016 // CPhoneState::IsAnyConnectedCalls
  2660 // -----------------------------------------------------------
  2017 // -----------------------------------------------------------
  2671         }
  2028         }
  2672     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsAnyConnectedCalls: (%d)", connectedCall );
  2029     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsAnyConnectedCalls: (%d)", connectedCall );
  2673     return connectedCall;
  2030     return connectedCall;
  2674     }
  2031     }
  2675 
  2032 
  2676 // -----------------------------------------------------------
       
  2677 // CPhoneState::NumberEntryContentL
       
  2678 // -----------------------------------------------------------
       
  2679 //
       
  2680 CPhoneNumberEntryManager* CPhoneState::NumberEntryManagerL()
       
  2681     {
       
  2682     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::NumberEntryContentL() ");
       
  2683     if ( !iNumberEntryManager )
       
  2684         {
       
  2685         iNumberEntryManager = CPhoneNumberEntryManager::NewL(
       
  2686                 this,
       
  2687                 *iViewCommandHandle,
       
  2688                 *iStateMachine,
       
  2689                 iCustomization,
       
  2690                 *iCbaManager );
       
  2691         }
       
  2692     return iNumberEntryManager;
       
  2693     }
       
  2694 
       
  2695 // -----------------------------------------------------------
       
  2696 // CPhoneState::PhoneNumberFromEntryLC()
       
  2697 // -----------------------------------------------------------
       
  2698 //
       
  2699 EXPORT_C HBufC* CPhoneState::PhoneNumberFromEntryLC()
       
  2700     {
       
  2701     return NumberEntryManagerL()->PhoneNumberFromEntryLC();
       
  2702     }
       
  2703 
       
  2704 // -----------------------------------------------------------
       
  2705 // CPhoneState::IsNumberEntryUsedL
       
  2706 // -----------------------------------------------------------
       
  2707 //
       
  2708 EXPORT_C TBool CPhoneState::IsNumberEntryUsedL()
       
  2709     {
       
  2710     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNumberEntryUsedL( ) ");
       
  2711     return NumberEntryManagerL()->IsNumberEntryUsedL();
       
  2712     }
       
  2713 
       
  2714 // -----------------------------------------------------------
       
  2715 // CPhoneState::IsNumberEntryVisibleL
       
  2716 // -----------------------------------------------------------
       
  2717 //
       
  2718 EXPORT_C TBool CPhoneState::IsNumberEntryVisibleL()
       
  2719     {
       
  2720     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNumberEntryVisibleL( ) ");
       
  2721     return NumberEntryManagerL()->IsNumberEntryVisibleL();
       
  2722     }
       
  2723 
       
  2724 // -----------------------------------------------------------
       
  2725 // CPhoneState::HandleNumberEntryClearedL
       
  2726 // -----------------------------------------------------------
       
  2727 //
       
  2728 EXPORT_C void CPhoneState::HandleNumberEntryClearedL()
       
  2729     {
       
  2730     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleNumberEntryClearedL( ) ");
       
  2731     NumberEntryManagerL()->HandleNumberEntryClearedL();
       
  2732     }
       
  2733 
       
  2734 // -----------------------------------------------------------
       
  2735 // CPhoneState::SetNumberEntryVisibilityL
       
  2736 // -----------------------------------------------------------
       
  2737 //
       
  2738 EXPORT_C void CPhoneState::SetNumberEntryVisibilityL( const TBool aVisible )
       
  2739     {
       
  2740     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetNumberEntryVisibilityL( ) ");
       
  2741     TPhoneCmdParamBoolean booleanParam;
       
  2742     booleanParam.SetBoolean( ETrue );
       
  2743     if ( !aVisible )
       
  2744         {
       
  2745         booleanParam.SetBoolean( EFalse );
       
  2746         }
       
  2747     NumberEntryManagerL()->SetNumberEntryVisibilityL( booleanParam );
       
  2748     }
       
  2749 
       
  2750 // -----------------------------------------------------------
       
  2751 // CPhoneState::IsNumberEntryContentStored
       
  2752 // -----------------------------------------------------------
       
  2753 //
       
  2754 EXPORT_C TBool CPhoneState::IsNumberEntryContentStored()
       
  2755     {
       
  2756     TBool isNumberEntryContentStored( EFalse );
       
  2757     TRAP_IGNORE( isNumberEntryContentStored = NumberEntryManagerL()->IsNumberEntryContentStored() );
       
  2758     return isNumberEntryContentStored;
       
  2759     }
       
  2760 
       
  2761 // -----------------------------------------------------------
       
  2762 // CPhoneState::StoreNumberEntryContentL
       
  2763 // -----------------------------------------------------------
       
  2764 //
       
  2765 EXPORT_C void CPhoneState::StoreNumberEntryContentL()
       
  2766     {
       
  2767     NumberEntryManagerL()->StoreNumberEntryContentL();
       
  2768     }
       
  2769 
       
  2770 // -----------------------------------------------------------
       
  2771 // CPhoneState::ClearNumberEntryContentCache
       
  2772 // -----------------------------------------------------------
       
  2773 //
       
  2774 EXPORT_C void CPhoneState::ClearNumberEntryContentCache()
       
  2775     {
       
  2776     TRAP_IGNORE( NumberEntryManagerL()->ClearNumberEntryContentCache() );
       
  2777     }
       
  2778 
       
  2779 // -----------------------------------------------------------------------------
       
  2780 // CPhoneState::IsAlphanumericSupportedAndCharInput
       
  2781 // -----------------------------------------------------------------------------
       
  2782 //
       
  2783 EXPORT_C TBool CPhoneState::IsAlphanumericSupportedAndCharInput(
       
  2784         const TKeyEvent& aKeyEvent )
       
  2785     {
       
  2786     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::IsAlphanumericSupportedAndCharInput() ");
       
  2787     TBool alphaNumericSupport(EFalse);
       
  2788     TRAP_IGNORE( alphaNumericSupport = NumberEntryManagerL()->IsAlphanumericSupportedAndCharInput( aKeyEvent ) );
       
  2789     return alphaNumericSupport;
       
  2790     }
       
  2791 
       
  2792 // -----------------------------------------------------------
       
  2793 // CPhoneState::NumberEntryClearL
       
  2794 // -----------------------------------------------------------
       
  2795 //
       
  2796 void CPhoneState::NumberEntryClearL()
       
  2797     {
       
  2798     NumberEntryManagerL()->NumberEntryClearL();
       
  2799     }
       
  2800 
       
  2801 // -----------------------------------------------------------
       
  2802 // CPhoneState::GetBlockedKeyList
       
  2803 // -----------------------------------------------------------
       
  2804 //
       
  2805 EXPORT_C const RArray<TInt>& CPhoneState::GetBlockedKeyList() const
       
  2806     {
       
  2807     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::GetBlockedKeyList( ) ");
       
  2808     return iStateMachine->PhoneStorage()->GetBlockedKeyList();
       
  2809     }
       
  2810 
       
  2811 // -----------------------------------------------------------
       
  2812 // CPhoneState::DisableHWKeysL
       
  2813 // -----------------------------------------------------------
       
  2814 //
       
  2815 EXPORT_C void CPhoneState::DisableHWKeysL()
       
  2816     {
       
  2817     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisableHWKeysL( ) ");
       
  2818 
       
  2819     if( iStateMachine->PhoneStorage()->IsBlockedKeysListEmpty() )
       
  2820         {
       
  2821         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::DisableHWKeysL HW Keys Disabled " );
       
  2822         iStateMachine->PhoneStorage()->AppendBlockedKeysListL( EStdKeyNo );
       
  2823         iStateMachine->PhoneStorage()->AppendBlockedKeysListL( EStdKeyYes );
       
  2824         }
       
  2825     }
       
  2826 
       
  2827 // -----------------------------------------------------------
       
  2828 // CPhoneState::DisableCallUIL
       
  2829 // -----------------------------------------------------------
       
  2830 //
       
  2831 EXPORT_C void CPhoneState::DisableCallUIL()
       
  2832     {
       
  2833     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisableCallUIL( ) ");
       
  2834     // Set Call UI state to storage
       
  2835     if( !iStateMachine->PhoneStorage()->IsScreenLocked() )
       
  2836         {
       
  2837         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::DisableCallUIL CallUI Disabled " );
       
  2838         // Show keys locked note
       
  2839         TPhoneCmdParamNote noteParam;
       
  2840         noteParam.SetType( EPhoneNoteUIDisabled );
       
  2841         noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
  2842             ResolveResourceID( EPhoneInformationNote ) );
       
  2843     
       
  2844         HBufC* noteText = StringLoader::LoadLC( 
       
  2845             CPhoneMainResourceResolver::Instance()->
       
  2846                 ResolveResourceID( EPhoneIncomingCallKeysLocked ) );
       
  2847         noteParam.SetText( *noteText );
       
  2848     
       
  2849         iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
  2850         CleanupStack::PopAndDestroy( noteText );
       
  2851     
       
  2852         // Start capturing the key guard key
       
  2853         TPhoneCmdParamKeyCapture appKeyCaptureParam;
       
  2854         appKeyCaptureParam.SetKey( EStdKeyDevice7 );
       
  2855         appKeyCaptureParam.SetKeyCode( EKeyDeviceF );
       
  2856         appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
  2857         iViewCommandHandle->ExecuteCommandL( EPhoneViewStartCapturingKey, &appKeyCaptureParam );
       
  2858         // Set Call UI state to storage
       
  2859         iStateMachine->PhoneStorage()->SetScreenLocked( ETrue );
       
  2860         }
       
  2861     }
       
  2862 
       
  2863 // -----------------------------------------------------------
       
  2864 // CPhoneState::EnableCallUIL
       
  2865 // -----------------------------------------------------------
       
  2866 //
       
  2867 EXPORT_C void CPhoneState::EnableCallUIL()
       
  2868     {
       
  2869     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::EnableCallUIL( ) ");
       
  2870     if( iStateMachine->PhoneStorage()->IsScreenLocked() )
       
  2871         {
       
  2872         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::EnableCallUIL CallUI Enabled " );
       
  2873         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
       
  2874         iViewCommandHandle->ExecuteCommandL( EPhoneViewDisableKeyLockWithoutNote );
       
  2875 
       
  2876         // Stop capturing the key guard key
       
  2877         TPhoneCmdParamKeyCapture appKeyCaptureParam;
       
  2878         appKeyCaptureParam.SetKey( EStdKeyDevice7 );
       
  2879         appKeyCaptureParam.SetKeyCode( EKeyDeviceF );
       
  2880         appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
  2881         iViewCommandHandle->ExecuteCommandL( EPhoneViewStopCapturingKey, &appKeyCaptureParam );
       
  2882         
       
  2883         iStateMachine->PhoneStorage()->SetScreenLocked( EFalse );
       
  2884         }
       
  2885     }
       
  2886 
       
  2887 // -----------------------------------------------------------
       
  2888 // CPhoneState::CheckDisableHWKeysAndCallUIL
       
  2889 // -----------------------------------------------------------
       
  2890 //
       
  2891 EXPORT_C void CPhoneState::CheckDisableHWKeysAndCallUIL()
       
  2892     {
       
  2893     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneState::CheckDisableHWKeysAndCallUIL( ) ");
       
  2894     if( IsKeyLockOn() || IsAutoLockOn() )
       
  2895         {
       
  2896         // Disable HW keys if needed
       
  2897         if( CPhoneCenRepProxy::Instance()->
       
  2898                 IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  2899             {
       
  2900             DisableHWKeysL();
       
  2901             }
       
  2902 
       
  2903         // Disable Call UI if needed
       
  2904         if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke )
       
  2905                 && !CPhoneCenRepProxy::Instance()->
       
  2906                 IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) )
       
  2907             {
       
  2908             DisableCallUIL();
       
  2909             iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( ETrue );
       
  2910             }
       
  2911         }
       
  2912     }
       
  2913 
       
  2914 // -----------------------------------------------------------
       
  2915 // CPhoneState::HandleHoldSwitchL
       
  2916 // -----------------------------------------------------------
       
  2917 //
       
  2918 EXPORT_C void CPhoneState::HandleHoldSwitchL()
       
  2919     {
       
  2920     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneState::HandleHoldSwitchL( ) ");
       
  2921 
       
  2922     if( CPhoneCenRepProxy::Instance()->
       
  2923             IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  2924         {
       
  2925         if( iStateMachine->PhoneStorage()->IsBlockedKeysListEmpty() )
       
  2926             {
       
  2927             DisableHWKeysL();
       
  2928             }
       
  2929         else
       
  2930             {
       
  2931             iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
  2932             }
       
  2933         }
       
  2934     
       
  2935     if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) 
       
  2936             && !CPhoneCenRepProxy::Instance()->
       
  2937             IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) )
       
  2938         {
       
  2939         if( iStateMachine->PhoneStorage()->IsScreenLocked() )
       
  2940             {
       
  2941             EnableCallUIL();
       
  2942             }
       
  2943         else
       
  2944             {
       
  2945             iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLockWithoutNote );
       
  2946             DisableCallUIL();
       
  2947             }
       
  2948         }
       
  2949     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
  2950     }
       
  2951 
       
  2952 // -----------------------------------------------------------
       
  2953 // CPhoneState::RetainPreviousKeylockStateL
       
  2954 // -----------------------------------------------------------
       
  2955 //
       
  2956 EXPORT_C void CPhoneState::RetainPreviousKeylockStateL()
       
  2957     {
       
  2958     // Lock keypad, if keylock was enabled before incoming call.
       
  2959     // Also reset PhoneStorage keylock status.
       
  2960     if ( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) &&
       
  2961         iStateMachine->PhoneStorage()->NeedToEnableKeylock() )
       
  2962         {
       
  2963         iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( EFalse );
       
  2964         iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLockWithoutNote ); 
       
  2965         }
       
  2966     }
       
  2967 
       
  2968 // ---------------------------------------------------------
       
  2969 // CPhoneState::HandleKeyLockEnabledL
       
  2970 // ---------------------------------------------------------
       
  2971 //
       
  2972 EXPORT_C void CPhoneState::HandleKeyLockEnabled( TBool aKeylockEnabled )
       
  2973     {
       
  2974     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleKeyLockEnabledL( ) ");
       
  2975     if( !FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke )
       
  2976         && CPhoneCenRepProxy::Instance()->
       
  2977             IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  2978         {
       
  2979         if( !aKeylockEnabled )
       
  2980             {
       
  2981             // Reset blocked keys list
       
  2982             iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
  2983             }
       
  2984         }
       
  2985     }
       
  2986 
       
  2987 // ---------------------------------------------------------
  2033 // ---------------------------------------------------------
  2988 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
  2034 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
  2989 // ---------------------------------------------------------
  2035 // ---------------------------------------------------------
  2990 //
  2036 //
  2991 EXPORT_C void CPhoneState::SetToolbarButtonLoudspeakerEnabled()
  2037 EXPORT_C void CPhoneState::SetToolbarButtonLoudspeakerEnabled()
  3019 //
  2065 //
  3020 EXPORT_C void CPhoneState::OpenSoftRejectMessageEditorL()
  2066 EXPORT_C void CPhoneState::OpenSoftRejectMessageEditorL()
  3021     {
  2067     {
  3022     __LOGMETHODSTARTEND(EPhoneControl,
  2068     __LOGMETHODSTARTEND(EPhoneControl,
  3023         "CPhoneState::OpenSoftRejectMessageEditorL ()" );
  2069         "CPhoneState::OpenSoftRejectMessageEditorL ()" );
  3024     iCbaManager->SetSoftRejectStatus( EFalse );
  2070     iUiCommandManager->SetSoftRejectStatus( EFalse );
  3025     TPhoneCmdParamCallStateData callStateData;
  2071     TPhoneCmdParamCallStateData callStateData;
  3026     callStateData.SetCallState( EPEStateRinging );
  2072     callStateData.SetCallState( EPEStateRinging );
  3027     iViewCommandHandle->HandleCommandL(
  2073     iViewCommandHandle->HandleCommandL(
  3028         EPhoneViewGetCallIdByState, &callStateData );
  2074         EPhoneViewGetCallIdByState, &callStateData );
  3029 
  2075 
  3052             // store the number
  2098             // store the number
  3053             sfiDataParam.SetNumber( 
  2099             sfiDataParam.SetNumber( 
  3054                     iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( ringingCallId ) );
  2100                     iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( ringingCallId ) );
  3055             }
  2101             }
  3056         }
  2102         }
  3057 
  2103     UpdateUiCommands();
  3058     TPhoneCmdParamInteger activeCallCount;
       
  3059     iViewCommandHandle->ExecuteCommandL(
       
  3060         EPhoneViewGetCountOfActiveCalls, &activeCallCount );
       
  3061 
       
  3062     switch( activeCallCount.Integer() )
       
  3063         {
       
  3064         case EOneActiveCall:
       
  3065             iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
       
  3066             break;
       
  3067         default:
       
  3068             iCbaManager->UpdateCbaL( EPhoneCallHandlingIncomingRejectCBA );
       
  3069             break;
       
  3070         }
       
  3071     iViewCommandHandle->ExecuteCommandL( 
  2104     iViewCommandHandle->ExecuteCommandL( 
  3072             EPhoneViewOpenSoftRejectEditor, &sfiDataParam );
  2105             EPhoneViewOpenSoftRejectEditor, 
       
  2106             &sfiDataParam );
       
  2107     }
       
  2108 
       
  2109 // -----------------------------------------------------------
       
  2110 // CPhoneState::DisplayCallHeaderL()
       
  2111 // -----------------------------------------------------------
       
  2112 //
       
  2113 EXPORT_C void CPhoneState::DisplayCallHeaderL( 
       
  2114         TInt aCallId,
       
  2115         TNumberEntrySetRule aRule )
       
  2116     {
       
  2117     __LOGMETHODSTARTEND(EPhoneControl, 
       
  2118             "CPhoneState::BringIncomingCallHeaderToForegroundL( ) ");
       
  2119     BeginUiUpdateLC();
       
  2120     switch ( aRule )
       
  2121        {
       
  2122        case ESetNEVisibilityFalse:
       
  2123            iNumberEntryManager->
       
  2124                SetNumberEntryVisibilityL( EFalse );
       
  2125            break;
       
  2126        case ECheckIfNEUsedBeforeSettingVisibilityFalse:
       
  2127            iNumberEntryManager->
       
  2128                SetVisibilityIfNumberEntryUsedL(EFalse);
       
  2129            break;
       
  2130        default: // by default do nothing.
       
  2131            break;
       
  2132        }
       
  2133     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  2134     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringPhoneAppToForeground );
       
  2135     iViewCommandHandle->ExecuteCommandL( EPhoneViewCreateCallHeader, aCallId );
       
  2136     UpdateUiCommands();
       
  2137     EndUiUpdate();
       
  2138     }
       
  2139 
       
  2140 // ---------------------------------------------------------
       
  2141 // CPhoneState::SetTouchPaneButtons
       
  2142 // ---------------------------------------------------------
       
  2143 //
       
  2144 EXPORT_C void CPhoneState::UpdateUiCommands()
       
  2145     {
       
  2146     iUiCommandManager->UpdateUiCommands();
       
  2147     }
       
  2148 
       
  2149 // -----------------------------------------------------------
       
  2150 // CPhoneState::HandleNumberEntryClearedL
       
  2151 // -----------------------------------------------------------
       
  2152 //
       
  2153 EXPORT_C void CPhoneState::HandleNumberEntryClearedL()
       
  2154     {
       
  2155     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleNumberEntryClearedL( ) ");
       
  2156     }
       
  2157 
       
  2158 // -----------------------------------------------------------
       
  2159 // CPhoneState::IsCustomizedDialerVisibleL()
       
  2160 // -----------------------------------------------------------
       
  2161 //
       
  2162 EXPORT_C TBool CPhoneState::IsCustomizedDialerVisibleL() const
       
  2163     {
       
  2164     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsCustomizedDialerVisibleL( ) ");
       
  2165     return iNumberEntryManager->IsCustomizedDialerVisibleL();
  3073     }
  2166     }
  3074 
  2167 
  3075 //  End of File
  2168 //  End of File
  3076