phoneapp/phoneuicontrol/src/cphonestate.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Implementation of CPhoneState class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <avkon.rsg>
       
    21 #include <bautils.h>
       
    22 #include <eikenv.h>
       
    23 #include <StringLoader.h>
       
    24 #include <pevirtualengine.h>
       
    25 #include <mpeclientinformation.h>
       
    26 #include <mpeengineinfo.h>
       
    27 #include <cpephonemodelif.h>
       
    28 #include <featmgr.h>
       
    29 #include <rconnmon.h>
       
    30 #include <Profile.hrh>
       
    31 #include <PUAcodes.hrh>
       
    32 #include <AknUtils.h>
       
    33 #include <telephonyvariant.hrh>
       
    34 #include <aknsoundsystem.h>
       
    35 #include <wlaninternalpskeys.h>
       
    36 #include <btengdomainpskeys.h>
       
    37 #include <btengdomaincrkeys.h>
       
    38 #include <settingsinternalcrkeys.h>
       
    39 #include <starterclient.h>
       
    40 #include <rsssettings.h>
       
    41 #include <UikonInternalPSKeys.h>
       
    42 #include <telephonydomainpstypes.h>
       
    43 #include <telinformationpskeys.h>
       
    44 #include <coreapplicationuisdomainpskeys.h>
       
    45 #include <mccecall.h>
       
    46 #include <ccpdefs.h>
       
    47 #include <LogsDomainCRKeys.h>
       
    48 #include <spsettings.h>
       
    49 #include <startupdomainpskeys.h>
       
    50 #include <MediatorDomainUIDs.h>
       
    51 #include <videotelcontrolmediatorapi.h>
       
    52 #include <textresolver.h>
       
    53 #include <phoneappvoipcommands.hrh>
       
    54 #include <hwrmdomainpskeys.h>
       
    55 
       
    56 #include "phoneui.pan"
       
    57 #include "cphonestate.h"
       
    58 #include "mphonestatemachine.h"
       
    59 #include "mphoneviewcommandhandle.h"
       
    60 #include "tphonecmdparamboolean.h"
       
    61 #include "tphonecmdparaminteger.h"
       
    62 #include "tphonecmdparamkeyevent.h"
       
    63 #include "tphonecmdparamdynmenu.h"
       
    64 #include "tphonecmdparamcallheaderdata.h"
       
    65 #include "tphonecmdparamincallindicatordata.h"
       
    66 #include "tphonecmdparamnote.h"
       
    67 #include "tphonecmdparamkeycapture.h"
       
    68 #include "tphonecmdparamglobalnote.h"
       
    69 #include "tphonecmdparamquery.h"
       
    70 #include "tphonecmdparamstring.h"
       
    71 #include "tphonecmdparamcallstatedata.h"
       
    72 #include "tphonecmdparambitmap.h"
       
    73 #include "tphonecmdparamaudiooutput.h"
       
    74 #include "tphonecmdparamaudioavailability.h"
       
    75 #include "tphonecmdparamappinfo.h"
       
    76 #include "tphonecmdparamtranseffect.h"
       
    77 #include "tphonecmdparamringtone.h"
       
    78 #include "tphonecmdparamcustomdialer.h"
       
    79 #include "cphonekeys.h"
       
    80 #include "phoneui.hrh"
       
    81 #include "phonerssbase.h"
       
    82 #include "cphonebtaadisconnecthandler.h"
       
    83 #include "cphonemainresourceresolver.h"
       
    84 #include "cphonecenrepproxy.h"
       
    85 #include "cphonepubsubproxy.h"
       
    86 #include "phoneviewcommanddefinitions.h"
       
    87 #include "phonelogger.h"
       
    88 #include "phonestatedefinitions.h"
       
    89 #include "cphonetimer.h"
       
    90 #include "cphonereconnectquery.h"
       
    91 #include "mphoneerrormessageshandler.h"
       
    92 #include "cphoneclearblacklist.h"
       
    93 #include "mphonecustomization.h"
       
    94 #include "cphonemainerrormessageshandler.h"
       
    95 #include "cphoneaccessorybthandler.h"
       
    96 #include "cphonemediatorfactory.h"
       
    97 #include "mphonemediatormessage.h"
       
    98 #include "cphonemediatorsender.h"
       
    99 #include "cphonereleasecommand.h"
       
   100 #include "cphonecontinueemergencycallcommand.h"
       
   101 #include "cphonecallheadermanager.h"
       
   102 #include "cphonenumberentrymanager.h"
       
   103 #include "tphonecmdparamsfidata.h" 
       
   104 #include "mphonestorage.h"
       
   105 #include "phoneconstants.h"
       
   106 #include "cphoneclearblacklist.h"
       
   107 
       
   108 // ================= MEMBER FUNCTIONS =======================
       
   109 
       
   110 EXPORT_C CPhoneState::CPhoneState(
       
   111     MPhoneStateMachine* aStateMachine,
       
   112     MPhoneViewCommandHandle* aViewCommandHandle,
       
   113     MPhoneCustomization* aCustomization) :
       
   114     iStateMachine( aStateMachine ),
       
   115     iViewCommandHandle( aViewCommandHandle ),
       
   116     iCustomization( aCustomization ),
       
   117     iEnv( *CEikonEnv::Static() )
       
   118     {
       
   119     // Need to get current SimState for inherited classis
       
   120     iPreviousSimState = SimState();
       
   121     __ASSERT_ALWAYS(
       
   122         aStateMachine && aViewCommandHandle,
       
   123         Panic( EPhoneCtrlParameterNotInitialized ) );
       
   124     if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) )
       
   125         {
       
   126         iOnScreenDialer = ETrue;
       
   127         }
       
   128     }
       
   129 
       
   130 EXPORT_C void CPhoneState::BaseConstructL()
       
   131     {
       
   132     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::BaseConstructL() ");
       
   133     if ( !iCbaManager )
       
   134         {
       
   135         iCbaManager = CPhoneCbaManager::NewL(
       
   136                         this,
       
   137                         *iViewCommandHandle,
       
   138                         *iStateMachine );
       
   139         }
       
   140     }
       
   141 
       
   142 EXPORT_C CPhoneState::~CPhoneState()
       
   143     {
       
   144     if( iAlsLineChangeKeyPressTimer )
       
   145         {
       
   146         if( iAlsLineChangeKeyPressTimer->IsActive() )
       
   147             {
       
   148             iAlsLineChangeKeyPressTimer->CancelTimer();
       
   149             }
       
   150         delete iAlsLineChangeKeyPressTimer;
       
   151         }
       
   152     delete iNumberEntryManager;
       
   153     delete iCallHeaderManager;
       
   154     delete iCbaManager;
       
   155     }
       
   156 
       
   157 // <-------------------------- PHONE ENGINE EVENTS --------------------------->
       
   158 
       
   159 // -----------------------------------------------------------
       
   160 // CPhoneState::HandlePhoneEngineMessageL
       
   161 // Default handling for Phone Engine messages
       
   162 // (other items were commented in a header).
       
   163 // -----------------------------------------------------------
       
   164 //
       
   165 EXPORT_C void CPhoneState::HandlePhoneEngineMessageL(
       
   166     const TInt aMessage,
       
   167     TInt aCallId )
       
   168     {
       
   169     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneEngineMessageL() ");
       
   170 
       
   171     CPhoneAccessoryBTHandler* accessoryBtHandler;
       
   172 
       
   173     switch ( aMessage )
       
   174         {
       
   175         case MEngineMonitor::EPEMessageNetworkRegistrationStatusChange:
       
   176             {
       
   177             __PHONELOG1( EBasic, EPhoneControl,
       
   178                "PHONEUI_ERROR: EPEMessageNetworkRegistrationStatusChange - RegistrationStatus =%d ",
       
   179                iStateMachine->PhoneEngineInfo()->NetworkRegistrationStatus());
       
   180             }
       
   181             break;
       
   182 
       
   183         case MEngineMonitor::EPEMessageAudioMuteChanged:
       
   184             HandleAudioMuteChangedL();
       
   185             break;
       
   186 
       
   187         case MEngineMonitor::EPEMessageAudioOutputChanged:
       
   188             HandleAudioOutputChangedL();
       
   189             // Go to current state implementation
       
   190             iCbaManager->UpdateInCallCbaL();
       
   191             break;
       
   192 
       
   193         case MEngineMonitor::EPEMessageAvailableAudioOutputsChanged:
       
   194             HandleAudioAvailableOutputChangedL();
       
   195             if ( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPENotActive )
       
   196                 {
       
   197                 // Go to current state implementation
       
   198                 iCbaManager->UpdateInCallCbaL();
       
   199                 }
       
   200             break;
       
   201 
       
   202         case MEngineMonitor::EPEMessageChangedCallDuration:
       
   203             HandleChangedCallDurationL( aCallId );
       
   204             break;
       
   205 
       
   206         case MEngineMonitor::EPEMessageRemoteBusy:
       
   207             HandleRemoteBusyL( aCallId );
       
   208             break;
       
   209 
       
   210         case MEngineMonitor::EPEMessageCallWaiting:
       
   211             SendGlobalInfoNoteL( EPhoneWaitingText );
       
   212             break;
       
   213 
       
   214         case MEngineMonitor::EPEMessageProfileChanged:
       
   215             {
       
   216             TPhoneCmdParamBoolean keypadVolumeParam;
       
   217             if ( iStateMachine->PhoneEngineInfo()->KeypadVolume() == 0 )
       
   218                 {
       
   219                 iViewCommandHandle->ExecuteCommandL( EPhoneViewKeypadAudioDisabled );
       
   220                 }
       
   221             else
       
   222                 {
       
   223                 iViewCommandHandle->ExecuteCommandL( EPhoneViewKeypadAudioEnabled );
       
   224                 }
       
   225             UpdateProfileDisplayL();
       
   226             }
       
   227             break;
       
   228 
       
   229         case MEngineMonitor::EPEMessageRemoteTerminated:
       
   230             // Close menu bar, if it is displayed, for call ending note
       
   231             iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   232             /* Flow through */
       
   233         case MEngineMonitor::EPEMessageDisconnecting:
       
   234             HandleDisconnectingL( aCallId );
       
   235             break;
       
   236 
       
   237         case MEngineMonitor::EPEMessageTransferDone:
       
   238             SendGlobalInfoNoteL( EPhoneInCallTransferred );
       
   239             break;
       
   240 
       
   241        case MEngineMonitor::EPEMessageInitiatedEmergencyCall:
       
   242             HandleInitiatedEmergencyCallL( aCallId );
       
   243             break;
       
   244 
       
   245        case MEngineMonitor::EPEMessageInitiatedEmergencyWhileActiveVideo:
       
   246            HandleInitiatedEmergencyWhileActiveVideoL();
       
   247            break;
       
   248 
       
   249         case MEngineMonitor::EPEMessageShowIMEI:
       
   250             // Stop playing DTMF tone
       
   251             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   252             HandleShowImeiL();
       
   253             break;
       
   254 
       
   255         case MEngineMonitor::EPEMessageCallSecureStatusChanged:
       
   256             HandleCallSecureStatusChangeL( aCallId );
       
   257 
       
   258             if ( iCustomization )
       
   259                 {
       
   260                 iCustomization->HandlePhoneEngineMessageL( aMessage,
       
   261                     aCallId );
       
   262                 }
       
   263             break;
       
   264 
       
   265         case MEngineMonitor::EPEMessageActivateWarrantyMode:
       
   266             // Stop playing DTMF tone
       
   267             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   268             HandleShowLifeTimerL();
       
   269             break;
       
   270 
       
   271         case MEngineMonitor::EPEMessageIssuingUSSDRequest:
       
   272             {
       
   273              // Enable global notes
       
   274             TPhoneCmdParamBoolean globalNotifierParam;
       
   275             globalNotifierParam.SetBoolean( EFalse );
       
   276             iViewCommandHandle->ExecuteCommandL(
       
   277                 EPhoneViewSetGlobalNotifiersDisabled,
       
   278                 &globalNotifierParam );
       
   279 
       
   280             if ( !IsOnScreenDialerSupported() && IsNumberEntryUsedL() )
       
   281                 {
       
   282                 // Remove number entry from screen
       
   283                 iViewCommandHandle->ExecuteCommandL(
       
   284                     EPhoneViewRemoveNumberEntry );
       
   285                 }
       
   286             else if ( IsOnScreenDialerSupported() )
       
   287                 {
       
   288                 NumberEntryClearL();
       
   289                 }
       
   290             }
       
   291             break;
       
   292 
       
   293         case MEngineMonitor::EPEMessageIssuedUSSDRequest:
       
   294             // Go to current state implementation
       
   295             iCbaManager->UpdateInCallCbaL();
       
   296             break;
       
   297 
       
   298         // *#9990#
       
   299         case MEngineMonitor::EPEMessageShowBTLoopback:
       
   300             // Stop playing DTMF tone
       
   301             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   302             accessoryBtHandler = CPhoneAccessoryBTHandler::NewLC(
       
   303                 iViewCommandHandle, iStateMachine, this );
       
   304             accessoryBtHandler->ShowBTLoopbackL();
       
   305             CleanupStack::PopAndDestroy( accessoryBtHandler );
       
   306             break;
       
   307 
       
   308         // *#2820#
       
   309         case MEngineMonitor::EPEMessageShowBTDeviceAddress:
       
   310             // Stop playing DTMF tone
       
   311             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   312             accessoryBtHandler = CPhoneAccessoryBTHandler::NewLC(
       
   313                 iViewCommandHandle, iStateMachine, this );
       
   314             accessoryBtHandler->ShowBTAddressL();
       
   315             CleanupStack::PopAndDestroy( accessoryBtHandler );
       
   316             break;
       
   317 
       
   318         // *#7370#
       
   319         case MEngineMonitor::EPEMessageActivateRfsDeep:
       
   320             // Stop playing DTMF tone
       
   321             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   322             // Launch RFS
       
   323             iViewCommandHandle->ExecuteCommandL( EPhoneViewLaunchRfsDeep );
       
   324             if ( !IsOnScreenDialerSupported() )
       
   325                 {
       
   326                 // Do state-specific operation when number entry is cleared
       
   327                 HandleNumberEntryClearedL();
       
   328                 }
       
   329             break;
       
   330 
       
   331         // *#7780#
       
   332         case MEngineMonitor::EPEMessageActivateRfsNormal:
       
   333             // Stop playing DTMF tone
       
   334             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   335             // Launch RFS
       
   336             iViewCommandHandle->ExecuteCommandL( EPhoneViewLaunchRfsNormal );
       
   337             if ( !IsOnScreenDialerSupported() )
       
   338                 {
       
   339                 // Do state-specific operation when number entry is cleared
       
   340                 HandleNumberEntryClearedL();
       
   341                 }
       
   342             break;
       
   343         // *#62209526#
       
   344         case MEngineMonitor::EPEMessageShowWlanMacAddress:
       
   345             // Stop playing DTMF tone
       
   346             iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
   347             ShowWlanMacAddressL();
       
   348             break;
       
   349 
       
   350         case MEngineMonitor::EPEMessageThumbnailLoadingCompleted:
       
   351             // Update call buble
       
   352             UpdateRemoteInfoDataL( aCallId );
       
   353             break;
       
   354 
       
   355         case MEngineMonitor::EPEMessageRemotePartyInfoChanged:
       
   356             UpdateRemoteInfoDataL ( aCallId );
       
   357             break;
       
   358 
       
   359         case MEngineMonitor::EPEMessageSIMStateChanged:
       
   360             __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::HandlePhoneEngineMessageL - simStateChanged =%d", SimState()  );
       
   361             HandleSimStateChangedL();
       
   362             break;
       
   363 
       
   364         case MEngineMonitor::EPEMessageShowIncCallGroupIndex:
       
   365             HandleCugInUseNoteL();
       
   366             break;
       
   367 
       
   368         // *#2873#
       
   369         case MEngineMonitor::EPEMessageBTDebugMode:
       
   370             accessoryBtHandler = CPhoneAccessoryBTHandler::NewLC(
       
   371                 iViewCommandHandle, iStateMachine, this );
       
   372             accessoryBtHandler->SetBTDebugModeL();
       
   373             CleanupStack::PopAndDestroy( accessoryBtHandler );
       
   374             break;
       
   375 
       
   376         default:
       
   377 
       
   378             TBool handled( EFalse );
       
   379 
       
   380             if ( iCustomization )
       
   381                 {
       
   382                 handled = iCustomization->HandlePhoneEngineMessageL(
       
   383                                 aMessage, aCallId );
       
   384                 }
       
   385 
       
   386             if ( EFalse == handled )
       
   387                 {
       
   388                 MPhoneMediatorMessage* mediatorMessage = CPhoneMediatorFactory::Instance()->MediatorMessage( aMessage, aCallId );
       
   389                 if( mediatorMessage )
       
   390                     {
       
   391                     CleanupDeletePushL( mediatorMessage );
       
   392                     mediatorMessage->ExecuteL();
       
   393                     CleanupStack::PopAndDestroy( mediatorMessage );
       
   394                     mediatorMessage = NULL;
       
   395                     }
       
   396                 }
       
   397             break;
       
   398         }
       
   399     }
       
   400 
       
   401 // -----------------------------------------------------------
       
   402 // CPhoneState::HandleAudioMuteChangedL
       
   403 // Default handling for EPEMessageAudioMuteChanged message
       
   404 // (other items were commented in a header).
       
   405 // -----------------------------------------------------------
       
   406 //
       
   407 EXPORT_C void CPhoneState::HandleAudioMuteChangedL()
       
   408     {
       
   409     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleAudioMuteChangedL() ");
       
   410     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
   411         Panic( EPhoneCtrlInvariant ) );
       
   412 
       
   413     TPhoneCmdParamBoolean booleanParam;
       
   414     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
       
   415     booleanParam.SetBoolean( audioMute );
       
   416     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateMuteUIChanges,
       
   417         &booleanParam );
       
   418     }
       
   419 
       
   420 // -----------------------------------------------------------
       
   421 // CPhoneState::HandleAudioOutputChangedL
       
   422 // Default handling for EPEMessageAudioOutputChanged message
       
   423 // (other items were commented in a header).
       
   424 // -----------------------------------------------------------
       
   425 //
       
   426 EXPORT_C void CPhoneState::HandleAudioOutputChangedL()
       
   427     {
       
   428     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleAudioOutputChangedL() ");
       
   429     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
   430         Panic( EPhoneCtrlInvariant ) );
       
   431 
       
   432     TPhoneCmdParamAudioOutput outputParam;
       
   433 
       
   434     // Output
       
   435     const TPEAudioOutput audioOutput =
       
   436         iStateMachine->PhoneEngineInfo()->AudioOutput();
       
   437     outputParam.SetAudioOutput( audioOutput );
       
   438 
       
   439     // view update
       
   440     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateAudioPathUIChanges,
       
   441         &outputParam );
       
   442 
       
   443     // Previous Output
       
   444     TPEPhoneAudioRouteParameters RouteParameters = iStateMachine->
       
   445         PhoneEngineInfo()->RouteParameters();
       
   446     const TPEAudioOutput previousOutput =
       
   447         RouteParameters.iPreviousOutput;
       
   448 
       
   449     // BT availability
       
   450     TBool btAvailable = iStateMachine->PhoneEngineInfo()->AudioOutputAvailable(
       
   451             EPEBTAudioAccessory );
       
   452 
       
   453     // Show note or BT disconnect handler
       
   454     if ( audioOutput != EPENotActive &&
       
   455          previousOutput == EPEBTAudioAccessory &&
       
   456          !btAvailable )
       
   457         {
       
   458         CPhoneBtaaDisconnectHandler::InstanceL()->HandleConnectionLostL();
       
   459         }
       
   460     else if ( audioOutput == EPEBTAudioAccessory && 
       
   461             previousOutput != EPEBTAudioAccessory &&
       
   462             btAvailable )
       
   463         {
       
   464         CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
       
   465             iViewCommandHandle, iStateMachine, this );
       
   466         bt->ShowBTActivatedL();
       
   467         CleanupStack::PopAndDestroy( bt );
       
   468         }
       
   469     else if ( audioOutput == EPENotActive &&
       
   470               CPhoneBtaaDisconnectHandler::InstanceL()->IsQuery() )
       
   471         {
       
   472         CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
       
   473         }
       
   474     else if ( RouteParameters.iShowNote && audioOutput == EPELoudspeaker )
       
   475         {
       
   476         CAknKeySoundSystem* keySounds =
       
   477                static_cast<CAknAppUi*>( iEnv.EikAppUi() )->KeySounds();
       
   478         keySounds->PlaySound( EAvkonSIDIHFActive );
       
   479         }
       
   480     }
       
   481 
       
   482 // -----------------------------------------------------------
       
   483 // CPhoneState::HandleSimStateChangedL
       
   484 // Handles changes in the SIM card state.
       
   485 // -----------------------------------------------------------
       
   486 //
       
   487 void CPhoneState::HandleSimStateChangedL()
       
   488     {
       
   489     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::HandleSimStateChangedL()" );
       
   490     CPhoneMainResourceResolver& resolver = *CPhoneMainResourceResolver::Instance();
       
   491     TPESimState simState = SimState();
       
   492 
       
   493     __PHONELOG2( EBasic, EPhoneControl, "SIM state was changed from %d to %d", iPreviousSimState, simState );
       
   494 
       
   495     switch ( simState )
       
   496         {
       
   497         case EPESimUsable: // Falls through.
       
   498         case EPESimReadable: // Falls through.
       
   499         case EPESimNotReady:
       
   500             {
       
   501             if ( iPreviousSimState == EPESimNotPresent )
       
   502                 {
       
   503                 __PHONELOG( EBasic, EPhoneControl, "SIM card was inserted, rebooting the phone" );
       
   504                 RStarterSession starterSession;
       
   505                 User::LeaveIfError( starterSession.Connect() );
       
   506                 CleanupClosePushL( starterSession );
       
   507 
       
   508                 HBufC* queryText = StringLoader::LoadLC( resolver.ResolveResourceID( EPhoneRebootRequired ) );
       
   509 
       
   510                 TPhoneCmdParamQuery queryParams;
       
   511                 queryParams.SetCommandParamId( TPhoneCommandParam::EPhoneParamRebootQuery );
       
   512                 queryParams.SetQueryPrompt( *queryText );
       
   513                 queryParams.SetDefaultCba( R_AVKON_SOFTKEYS_OK_EMPTY );
       
   514                 iViewCommandHandle->ExecuteCommandL( EPhoneViewShowQuery, &queryParams );
       
   515 
       
   516                 starterSession.Reset( RStarterSession::ESIMStatusChangeReset );
       
   517                 CleanupStack::PopAndDestroy( 2, &starterSession ); // queryText
       
   518                 }
       
   519             break;
       
   520             }
       
   521         case EPESimNotPresent:
       
   522             {
       
   523             if ( iPreviousSimState == EPESimUsable ||
       
   524                  iPreviousSimState == EPESimReadable ||
       
   525                  iPreviousSimState == EPESimNotReady )
       
   526                 {
       
   527                 __PHONELOG( EBasic, EPhoneControl, "SIM card was removed" );
       
   528 
       
   529                 TPhoneCmdParamGlobalNote globalNoteParam;
       
   530                 globalNoteParam.SetType( EAknGlobalInformationNote );
       
   531                 globalNoteParam.SetTone( EAvkonSIDNoSound );
       
   532 
       
   533                 globalNoteParam.SetTextResourceId(
       
   534                     CPhoneMainResourceResolver::Instance()->
       
   535                     ResolveResourceID( EPhoneSimRemoved ) );
       
   536 
       
   537                 iViewCommandHandle->ExecuteCommandL(
       
   538                     EPhoneViewShowGlobalNote, &globalNoteParam );
       
   539 
       
   540                 }
       
   541             // Show security note, if SIM not present and KFeatureIdFfSimlessOfflineSupport is disabled.
       
   542             else if ( !FeatureManager::FeatureSupported( KFeatureIdFfSimlessOfflineSupport ) &&
       
   543                     ( iPreviousSimState != EPESimNotSupported ) )
       
   544                 {
       
   545                 StartShowSecurityNoteL();
       
   546                 }
       
   547             break;
       
   548             }
       
   549         default:
       
   550             break;
       
   551         }
       
   552 
       
   553     iPreviousSimState = simState;
       
   554     }
       
   555 
       
   556 // -----------------------------------------------------------------------------
       
   557 // CPhoneState::IsValidAlphaNumericKey
       
   558 // Checks is the key event a number, a special character
       
   559 // or if VoIP is enabled some other character
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 TBool CPhoneState::IsValidAlphaNumericKey( const TKeyEvent& aKeyEvent,
       
   563         TEventCode aEventCode )
       
   564     {
       
   565     TBool ret(EFalse);
       
   566 
       
   567     const TBool numericKeyEntered( CPhoneKeys::IsNumericKey(
       
   568           aKeyEvent, aEventCode ) );
       
   569 
       
   570     // a numeric key (1,2,3,4,6,7,8,9,0,+,*,p,w )
       
   571     // or
       
   572     // a letter from fullscreen qwerty, miniqwerty or handwriting
       
   573     // when voip is enabled
       
   574     if ( numericKeyEntered
       
   575         || IsAlphanumericSupportedAndCharInput( aKeyEvent ) )
       
   576         {
       
   577         ret= ETrue;
       
   578         }
       
   579 
       
   580     return ret;
       
   581     }
       
   582 
       
   583 // -----------------------------------------------------------------------------
       
   584 // CPhoneState::CustomizeCBAForPhoneNumber
       
   585 //
       
   586 // -----------------------------------------------------------------------------
       
   587 //
       
   588 void CPhoneState::CustomizeCbaForPhoneNumberL()
       
   589     {
       
   590     if ( !FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) &&
       
   591          iCustomization &&
       
   592          iCustomization->AllowAlphaNumericMode() )
       
   593         {
       
   594         // Get the number entry contents
       
   595         HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
   596 
       
   597         TPhoneCmdParamInteger integerParam;
       
   598 
       
   599         //only charaters from set { 0, .., 9, *, #, +, p, w, P, W } used
       
   600         if ( CPhoneKeys::Validate( phoneNumber->Des()) )
       
   601             {
       
   602             integerParam.SetInteger( CPhoneMainResourceResolver::Instance()->
       
   603                                     ResolveResourceID( EPhoneNumberAcqCBA ) );
       
   604             }
       
   605         //other characters
       
   606         else
       
   607             {
       
   608             integerParam.SetInteger( iCustomization->CustomizeSoftKeys() );
       
   609             }
       
   610 
       
   611         iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateCba, &integerParam );
       
   612         CleanupStack::PopAndDestroy( phoneNumber );
       
   613         }
       
   614 
       
   615     }
       
   616 
       
   617 // -----------------------------------------------------------------------------
       
   618 // CPhoneState::IsTouchDTmfDialerOn
       
   619 // -----------------------------------------------------------------------------
       
   620 //
       
   621 TBool CPhoneState::IsTouchDTmfDialerOn() const
       
   622     {
       
   623     TBool status( EFalse );
       
   624     if ( IsOnScreenDialerSupported() )
       
   625         {
       
   626         TBool isDialerVisible( EFalse );
       
   627         TRAP_IGNORE( isDialerVisible = IsDTMFEditorVisibleL() );
       
   628 
       
   629         if ( isDialerVisible )
       
   630             {
       
   631             status = ETrue;
       
   632             }
       
   633         }
       
   634     return status;
       
   635     }
       
   636 // -----------------------------------------------------------------------------
       
   637 // CPhoneState::SendDtmfKeyEventL
       
   638 // send dtmf event when,
       
   639 // -touch dtmf dialer is NOT visible
       
   640 // -query is not active
       
   641 // -menubar is not open
       
   642 // -----------------------------------------------------------------------------
       
   643 //
       
   644 void CPhoneState::SendDtmfKeyEventL( const TKeyEvent& aKeyEvent,
       
   645                TEventCode aEventCode  )
       
   646     {
       
   647 
       
   648     if ( !IsTouchDTmfDialerOn()
       
   649         && !IsAnyQueryActiveL()
       
   650         && !IsMenuBarVisibleL() )
       
   651         {
       
   652         // Send the key event to the phone engine.
       
   653         SendKeyEventL( aKeyEvent, aEventCode );
       
   654         }
       
   655     }
       
   656 
       
   657 // -----------------------------------------------------------------------------
       
   658 // CPhoneState::IsKeyEventFurtherProcessed
       
   659 // -----------------------------------------------------------------------------
       
   660 //
       
   661 TBool CPhoneState::IsKeyEventFurtherProcessedL( const TKeyEvent& aKeyEvent ) const
       
   662     {
       
   663     // While being in some special keyboard mode (Full Screen&mini QWERTY,
       
   664     // handwriting mode) FEP sends only EEventKey -event and thus manual
       
   665     // DTMFs can not be played with the user specified tone lengths. Also,
       
   666     // in general, DTMFs are tried to play only in numeric mode.
       
   667     TBool numericMode = iViewCommandHandle->HandleCommandL(
       
   668       EPhoneViewIsNumberEntryNumericMode ) == EPhoneViewResponseSuccess;
       
   669 
       
   670     if ( ( aKeyEvent.iModifiers & EModifierSpecial ) != 0 || !numericMode )
       
   671         {
       
   672         return EFalse;
       
   673         }
       
   674 
       
   675     return ETrue;
       
   676     }
       
   677 
       
   678 // -----------------------------------------------------------
       
   679 // CPhoneState::HandleErrorL
       
   680 // Default handling for HandleError message
       
   681 // (other items were commented in a header).
       
   682 // -----------------------------------------------------------
       
   683 //
       
   684 EXPORT_C void CPhoneState::HandleErrorL( const TPEErrorInfo& aErrorInfo )
       
   685     {
       
   686     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleErrorL()");
       
   687 
       
   688     __PHONELOG1( EBasic, EPhoneControl,
       
   689             "PhoneUIControl: CPhoneState::HandleErrorL - aErrorInfo.iErrorCode =%d ",
       
   690             aErrorInfo.iErrorCode );
       
   691 
       
   692     __PHONELOG1( EBasic, EPhoneControl,
       
   693         "PhoneUIControl: CPhoneState::HandleErrorL - aErrorInfo.iCallId =%d ",
       
   694         aErrorInfo.iCallId );
       
   695 
       
   696 
       
   697     // Sets touch buttons to correct status if error has occured.
       
   698     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
   699         {
       
   700         iViewCommandHandle->ExecuteCommand( EPhoneResetTouchButtons );
       
   701         }
       
   702 
       
   703     // Do the common error handling (display proper notes etc)
       
   704     CPhoneMainErrorMessagesHandler::Instance()->ShowErrorSpecificNoteL( aErrorInfo );
       
   705 
       
   706     switch( aErrorInfo.iErrorCode )
       
   707         {
       
   708         case ECCPErrorCCUserAlertingNoAnswer:
       
   709         case ECCPErrorCCResourceNotAvailable:
       
   710             {
       
   711             if( aErrorInfo.iCallId > KErrNotFound )
       
   712                 {
       
   713                 if ( iStateMachine->PhoneEngineInfo()->CallDirection(
       
   714                         aErrorInfo.iCallId ) != RMobileCall::EMobileTerminated )
       
   715                     {
       
   716                     if( IsVideoCall( aErrorInfo.iCallId ) )
       
   717                         {
       
   718                         // Active MO video call lost 3G network.
       
   719                         __PHONELOG1( EBasic, EPhoneControl,
       
   720                         "PhoneUIControl: CPhoneState::HandleErrorL - ShowReconnectQueryL vid 1, callid%d ",
       
   721                         aErrorInfo.iCallId );
       
   722                         CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
       
   723                         }
       
   724                     else
       
   725                         {
       
   726                          __PHONELOG1( EBasic, EPhoneControl,
       
   727                             "PhoneUIControl: CPhoneState::HandleErrorL - No video call =%d ",
       
   728                             aErrorInfo.iCallId );
       
   729                         }
       
   730                     }
       
   731                 }
       
   732             }
       
   733             break;
       
   734 
       
   735             case ECCPErrorCCServiceNotAvailable:
       
   736                 {
       
   737                 if( IsVideoCall( aErrorInfo.iCallId ) )
       
   738                     {
       
   739                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( EFalse );
       
   740                     }
       
   741                 }
       
   742                 break;
       
   743 
       
   744             case ECCPErrorBadRequest:
       
   745                 {
       
   746                 TPECallType callType =
       
   747                     iStateMachine->PhoneEngineInfo()->CallTypeCommand();
       
   748 
       
   749                 if( callType == EPECallTypeVideo )
       
   750                     {
       
   751                         // Dialling MO video call cannot reach 3G network.
       
   752                         __PHONELOG1( EBasic, EPhoneControl,
       
   753                             "PhoneUIControl: CPhoneState::HandleErrorL - ShowReconnectQueryL vid 2, callid%d ",
       
   754                             aErrorInfo.iCallId );
       
   755                         CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
       
   756                     }
       
   757                 }
       
   758                 break;
       
   759 
       
   760         case ECCPErrorVideoCallNotSupportedByNetwork:
       
   761         case ECCPErrorVideoCallSetupFailed:
       
   762         case ECCPErrorNotReached:
       
   763            // If call id found and seems to be Video Call
       
   764             if ( IsVideoCall( aErrorInfo.iCallId ) )
       
   765                 {
       
   766                 // Get active call count
       
   767                 TPhoneCmdParamInteger activeCallCount;
       
   768                 iViewCommandHandle->ExecuteCommandL(
       
   769                     EPhoneViewGetCountOfActiveCalls, &activeCallCount );
       
   770 
       
   771                 if ( activeCallCount.Integer() == 0
       
   772                      || iStateMachine->PhoneEngineInfo()->CallDirection(
       
   773                         aErrorInfo.iCallId ) != RMobileCall::EMobileTerminated )
       
   774                     {
       
   775                     // Dialling MO video call attempted in 2G network or
       
   776                     // dialing MO video to unvalid number
       
   777                     // Reconnect query include video label if errorcode is unvalid number.
       
   778                     __PHONELOG1( EBasic, EPhoneControl,
       
   779                     "PhoneUIControl: CPhoneState::HandleErrorL - ShowReconnectQueryL vid 3, callid%d ",
       
   780                     aErrorInfo.iCallId );
       
   781                     CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL(
       
   782                               ECCPErrorNotReached == aErrorInfo.iErrorCode );
       
   783                     }
       
   784                 }
       
   785             break;
       
   786 
       
   787         case ECCPErrorNoService:
       
   788             // No network -> hide volume popup
       
   789             iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
       
   790             break;
       
   791 
       
   792         case ECCPErrorSatControl:
       
   793             {
       
   794             // check, that there really was a call established before completing SAT request
       
   795             if( aErrorInfo.iCallId != KPECallIdNotUsed )
       
   796                 {
       
   797                 }
       
   798 
       
   799             // remove number entry
       
   800             if ( !IsOnScreenDialerSupported() && IsNumberEntryUsedL() )
       
   801                 {
       
   802                 iViewCommandHandle->ExecuteCommandL(
       
   803                     EPhoneViewRemoveNumberEntry );
       
   804                 }
       
   805             else if ( IsOnScreenDialerSupported() )
       
   806                 {
       
   807                 NumberEntryClearL();
       
   808                 }
       
   809             }
       
   810             break;
       
   811 
       
   812         default:
       
   813             break;
       
   814         }
       
   815 
       
   816     // clear call blacklist if call failure occurs
       
   817     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
       
   818     }
       
   819 
       
   820 // -----------------------------------------------------------
       
   821 // CPhoneState::HandleChangedCallDurationL
       
   822 // Default handling for EPEMessageChangedCallDuration message
       
   823 // (other items were commented in a header).
       
   824 // -----------------------------------------------------------
       
   825 void CPhoneState::HandleChangedCallDurationL( TInt aCallId )
       
   826     {
       
   827      __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleChangedCallDurationL() ");
       
   828     // Get the call duration
       
   829     TTimeIntervalSeconds seconds =
       
   830         iStateMachine->PhoneEngineInfo()->CallDuration( aCallId );
       
   831 
       
   832     TPhoneCmdParamInteger time;
       
   833     time.SetInteger(seconds.Int());
       
   834     iViewCommandHandle->ExecuteCommandL(EPhoneViewUpdateCallHeaderCallDuration, aCallId, &time);
       
   835     }
       
   836 
       
   837 // -----------------------------------------------------------------------------
       
   838 // CPhoneState::HandleRemoteBusyL
       
   839 // -----------------------------------------------------------------------------
       
   840 //
       
   841 void CPhoneState::HandleRemoteBusyL( TInt aCallId )
       
   842     {
       
   843     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleRemoteBusyL( ) ");
       
   844     ShowNumberBusyNoteL();
       
   845 
       
   846     const TPECallType callType =
       
   847         iStateMachine->PhoneEngineInfo()->CallTypeCommand();
       
   848 
       
   849     if( callType == EPECallTypeVideo )
       
   850         {
       
   851          // Launch reconnect query including video call menu item
       
   852          __PHONELOG1( EBasic, EPhoneControl,
       
   853             "PhoneUIControl: CPhoneState::HandleRemoteBusyL - ShowReconnectQueryL vid 5, callid%d ",
       
   854                 aCallId );
       
   855         CPhoneReconnectQuery::InstanceL()->ShowReconnectQueryL( ETrue );
       
   856         }
       
   857     }
       
   858 
       
   859 // -----------------------------------------------------------
       
   860 // CPhoneState::HandleDisconnectingL
       
   861 // -----------------------------------------------------------
       
   862 //
       
   863 EXPORT_C void CPhoneState::HandleDisconnectingL( TInt aCallId )
       
   864     {
       
   865     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleDisconnectingL( ) ");
       
   866     // If there is no call in connected state then EPhoneDtmfTextQuery and EPhoneDtmfListQueryDialog
       
   867     // must be dismmissed from UI, therefore we must set EPhoneViewSetNoConnectedCalls to ETrue this
       
   868     // way we can ensure that CPhoneQueryController doesnt relaunch EPhoneDtmfListQueryDialog.
       
   869     if ( !IsAnyConnectedCalls() )
       
   870         {
       
   871         TPhoneCmdParamBoolean booleanParam;
       
   872         booleanParam.SetBoolean(ETrue);
       
   873         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetNoConnectedCalls, &booleanParam );
       
   874         }
       
   875 
       
   876     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   877     callHeaderParam.SetCallState( EPEStateDisconnecting );
       
   878 
       
   879     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
       
   880     LoadResource( labelText, EPhoneInCallDisconnected );
       
   881 
       
   882     callHeaderParam.SetLabelText( labelText );
       
   883 
       
   884     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
   885 
       
   886     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
       
   887         &callHeaderParam );    
       
   888 
       
   889     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
       
   890     }
       
   891 
       
   892 // -----------------------------------------------------------
       
   893 // CPhoneState::IsCustomizedDialerVisibleL()
       
   894 // -----------------------------------------------------------
       
   895 //
       
   896 EXPORT_C TBool CPhoneState::IsCustomizedDialerVisibleL() const
       
   897     {
       
   898     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsCustomizedDialerVisibleL( ) ");
       
   899     return iViewCommandHandle->HandleCommandL(
       
   900         EPhoneIsCustomizedDialerVisible ) == EPhoneViewResponseSuccess;
       
   901     }
       
   902 
       
   903 // <------------------------------- KEY EVENTS ------------------------------->
       
   904 
       
   905 // -----------------------------------------------------------
       
   906 // CPhoneState::HandleKeyMessageL( aMessage, aKeyCode )
       
   907 // -----------------------------------------------------------
       
   908 //
       
   909 EXPORT_C void CPhoneState::HandleKeyMessageL(
       
   910     TPhoneKeyEventMessages /*aMessage*/,
       
   911     TKeyCode /*aKeyCode*/ )
       
   912     {
       
   913     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleKeyMessageL( ) ");
       
   914     }
       
   915 
       
   916 // -----------------------------------------------------------
       
   917 // CPhoneState::HandleKeyEventL( aKeyEvent, aEventCode )
       
   918 // -----------------------------------------------------------
       
   919 //
       
   920 EXPORT_C void CPhoneState::HandleKeyEventL(
       
   921     const TKeyEvent& aKeyEvent,
       
   922     TEventCode aEventCode )
       
   923     {
       
   924     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleKeyEventL( ) ");
       
   925     if ( ( IsNumberEntryVisibleL() ) || OnlySideVolumeKeySupported() )
       
   926         {
       
   927         // Handle numeric keys when key events are received in single state
       
   928         HandleNumericKeyEventL( aKeyEvent, aEventCode );
       
   929         }
       
   930     else if ( aKeyEvent.iScanCode == EStdKeyUpArrow &&
       
   931               aEventCode == EEventKey )
       
   932         {
       
   933         // Increace audio volume
       
   934         IncreaseAudioVolumeL();
       
   935         }
       
   936     else if ( aKeyEvent.iScanCode == EStdKeyDownArrow &&
       
   937             aEventCode == EEventKey )
       
   938         {
       
   939         // Decreace audio volume
       
   940         DecreaseAudioVolumeL();
       
   941         }
       
   942     else
       
   943         {
       
   944         // Handle numeric keys when key events are received in single state
       
   945         HandleNumericKeyEventL( aKeyEvent, aEventCode );
       
   946         }
       
   947     }
       
   948 
       
   949 // -----------------------------------------------------------
       
   950 // CPhoneState::OnlySideVolumeKeySupported
       
   951 // -----------------------------------------------------------
       
   952 //
       
   953 TBool CPhoneState::OnlySideVolumeKeySupported()
       
   954     {
       
   955     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::OnlySideVolumeKeySupported( ) ");
       
   956     TBool onlySideVolumeKeySupported(EFalse);
       
   957     if ( !CPhoneCenRepProxy::Instance()->
       
   958             IsTelephonyFeatureSupported( KTelephonyLVFlagScrollVolumeKeys ) &&
       
   959          FeatureManager::FeatureSupported( KFeatureIdSideVolumeKeys ) )
       
   960         {
       
   961         onlySideVolumeKeySupported = ETrue;
       
   962         }
       
   963     __PHONELOG1( EBasic, EPhoneControl,
       
   964             "OnlySideVolumeKeySupported: %d",
       
   965             onlySideVolumeKeySupported );
       
   966     return onlySideVolumeKeySupported;
       
   967     }
       
   968 
       
   969 // -----------------------------------------------------------
       
   970 // CPhoneState::HandleKeyPressDurationL( aScanCode, aKeyPressDuration )
       
   971 // -----------------------------------------------------------
       
   972 //
       
   973 EXPORT_C void CPhoneState::HandleKeyPressDurationL(
       
   974     TKeyCode aCode,
       
   975     TTimeIntervalMicroSeconds /*aKeyPressDuration*/ )
       
   976     {
       
   977     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleKeyPressDurationL( ) ");
       
   978 
       
   979     if( aCode == KPhoneDtmfHashCharacter )
       
   980         {
       
   981         if( iAlsLineChangeKeyPressTimer )
       
   982             {
       
   983             if( iAlsLineChangeKeyPressTimer->IsActive() )
       
   984                 {
       
   985                 iAlsLineChangeKeyPressTimer->Cancel();
       
   986                 }
       
   987             }
       
   988         }
       
   989     }
       
   990 
       
   991 // -----------------------------------------------------------
       
   992 // CPhoneState::IsNoteVisibleL
       
   993 // -----------------------------------------------------------
       
   994 //
       
   995 EXPORT_C TBool CPhoneState::IsNoteVisibleL()
       
   996     {
       
   997     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNoteVisibleL( ) ");
       
   998     TPhoneCmdParamBoolean booleanParam;
       
   999     iViewCommandHandle->ExecuteCommandL(
       
  1000         EPhoneViewGetIsNoteVisible, &booleanParam );
       
  1001     return booleanParam.Boolean();
       
  1002     }
       
  1003 
       
  1004 // -----------------------------------------------------------
       
  1005 // CPhoneState::IsMenuBarVisibleL
       
  1006 // -----------------------------------------------------------
       
  1007 //
       
  1008 EXPORT_C TBool CPhoneState::IsMenuBarVisibleL() const
       
  1009     {
       
  1010     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsMenuBarVisibleL( ) ");
       
  1011     return iViewCommandHandle->HandleCommandL(
       
  1012         EPhoneViewIsMenuBarVisible ) ==
       
  1013         EPhoneViewResponseSuccess;
       
  1014     }
       
  1015 
       
  1016 // -----------------------------------------------------------
       
  1017 // CPhoneState::HandleNumericKeyEventL
       
  1018 // -----------------------------------------------------------
       
  1019 //
       
  1020 EXPORT_C void CPhoneState::HandleNumericKeyEventL(
       
  1021     const TKeyEvent& aKeyEvent,
       
  1022     TEventCode aEventCode )
       
  1023     {
       
  1024     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleNumericKeyEventL( ) ");
       
  1025 
       
  1026     TBool numberEntryUsed = IsNumberEntryUsedL();
       
  1027 
       
  1028     if ( numberEntryUsed && ( aKeyEvent.iRepeats == 0 ||
       
  1029               aKeyEvent.iScanCode == EStdKeyBackspace ||
       
  1030               aKeyEvent.iScanCode ==EStdKeyLeftArrow  ||
       
  1031               aKeyEvent.iScanCode ==EStdKeyRightArrow ))
       
  1032         {
       
  1033         // Number entry exists but may be hidden
       
  1034         KeyEventForExistingNumberEntryL( aKeyEvent, aEventCode );
       
  1035         }
       
  1036 
       
  1037     }
       
  1038 
       
  1039 // -----------------------------------------------------------------------------
       
  1040 // CPhoneState::IsAnyQueryActiveL
       
  1041 // -----------------------------------------------------------------------------
       
  1042 //
       
  1043 EXPORT_C TBool CPhoneState::IsAnyQueryActiveL()
       
  1044     {
       
  1045     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsAnyQueryActiveL( ) ");
       
  1046     TBool isActive( EFalse );
       
  1047 
       
  1048     // If IsNoteDismissableL returns true then shown note is dismissable by key event
       
  1049     // and then there is no actual query and IsAnyQueryActiveL returns false.
       
  1050     if ( !IsNoteDismissableL() )
       
  1051         {
       
  1052         // Check is query displayed
       
  1053         TPhoneCmdParamBoolean isQueryDisplayed;
       
  1054         iViewCommandHandle->ExecuteCommandL( EPhoneViewIsQuery, &isQueryDisplayed );
       
  1055         // Check is Blocking Dialog active ( e.g. RFS query )
       
  1056         TPhoneCmdParamBoolean blockingDialogStatus;
       
  1057         iViewCommandHandle->ExecuteCommandL( EPhoneViewGetBlockingDialogStatus,
       
  1058             &blockingDialogStatus );
       
  1059         // Check is note displayed
       
  1060         TPhoneCmdParamBoolean isNoteActive;
       
  1061         iViewCommandHandle->ExecuteCommandL(
       
  1062             EPhoneViewIsNoteActive, &isNoteActive );
       
  1063 
       
  1064         if ( isQueryDisplayed.Boolean() || blockingDialogStatus.Boolean() || isNoteActive.Boolean() )
       
  1065             {
       
  1066             isActive = ETrue;
       
  1067             }
       
  1068         }
       
  1069     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsAnyQueryActiveL: %d ", isActive );
       
  1070     return isActive;
       
  1071     }
       
  1072 
       
  1073 // -----------------------------------------------------------------------------
       
  1074 // CPhoneState::IsNoteDismissable
       
  1075 // -----------------------------------------------------------------------------
       
  1076 //
       
  1077 TBool CPhoneState::IsNoteDismissableL()
       
  1078     {
       
  1079     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNoteDismissableL( ) ");
       
  1080     TBool dismiss = EFalse;
       
  1081     if ( !FeatureManager::FeatureSupported( KFeatureIdFfSimlessOfflineSupport ) ||
       
  1082          (FeatureManager::FeatureSupported( KFeatureIdFfSimlessOfflineSupport ) &&
       
  1083                   SimSecurityStatus() == ESimRejected )  )
       
  1084         {
       
  1085         // Check if note is dismissed by key event.
       
  1086         TPhoneCmdParamBoolean isNoteDismissed;
       
  1087         iViewCommandHandle->ExecuteCommandL(
       
  1088                 EPhoneViewIsActiveNoteDissmissableByKeyEvent, &isNoteDismissed );
       
  1089         if ( isNoteDismissed.Boolean() )
       
  1090             {
       
  1091             dismiss = ETrue;
       
  1092             }
       
  1093         }
       
  1094     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsNoteDismissableL: %d ", dismiss );
       
  1095     return dismiss;
       
  1096     }
       
  1097 
       
  1098 // -----------------------------------------------------------
       
  1099 // CPhoneState::SendKeyEventL
       
  1100 // -----------------------------------------------------------
       
  1101 //
       
  1102 void CPhoneState::SendKeyEventL(
       
  1103     const TKeyEvent& aKeyEvent,
       
  1104     TEventCode aEventCode )
       
  1105     {
       
  1106     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendKeyEventL( ) ");
       
  1107     switch( aEventCode )
       
  1108         {
       
  1109         // EEventKey
       
  1110         case EEventKey:
       
  1111             // Send the key press to the phone engine, if applicable
       
  1112             SendKeyPressL( aKeyEvent, aEventCode );
       
  1113             break;
       
  1114 
       
  1115         // EEventKeyUp
       
  1116         case EEventKeyUp:
       
  1117             // Send a key up event for the last key code sent to
       
  1118             // the phone engine
       
  1119             iStateMachine->SendPhoneEngineMessage(
       
  1120                 MPEPhoneModel::EPEMessageEndDTMF );
       
  1121             break;
       
  1122 
       
  1123         default:
       
  1124             break;
       
  1125         }
       
  1126     }
       
  1127 
       
  1128 // -----------------------------------------------------------
       
  1129 // CPhoneState::SendKeyPressL
       
  1130 // -----------------------------------------------------------
       
  1131 //
       
  1132 void CPhoneState::SendKeyPressL(
       
  1133     const TKeyEvent& aKeyEvent,
       
  1134     TEventCode aEventCode )
       
  1135     {
       
  1136     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendKeyPressL( ) ");
       
  1137     const TBool dtmfToneKeyEntered =
       
  1138         CPhoneKeys::IsDtmfTone( aKeyEvent, aEventCode );
       
  1139 
       
  1140     if ( dtmfToneKeyEntered ||
       
  1141         aKeyEvent.iCode == EKeyBackspace )
       
  1142         {
       
  1143         // Get the number entry contents, if it exists
       
  1144         if ( IsNumberEntryUsedL() )
       
  1145             {
       
  1146             HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
  1147             // Save the phone number
       
  1148             __PHONELOG1( EBasic, EPhoneControl, "SetPhoneNumber: %S ", phoneNumber );
       
  1149             iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
       
  1150 
       
  1151             // Convert key code to western.
       
  1152             TBuf<1> buffer; // one character
       
  1153             buffer.Append( aKeyEvent.iCode );
       
  1154             __PHONELOG1( EBasic, EPhoneControl,
       
  1155                 "CPhoneState::SendKeyPressL(%S)",
       
  1156                 &buffer );
       
  1157             AknTextUtils::ConvertDigitsTo( buffer, EDigitTypeWestern );
       
  1158             __PHONELOG1( EBasic, EPhoneControl,
       
  1159                 "CPhoneState::SendKeyPressL(%S)",
       
  1160                 &buffer );
       
  1161             TLex code( buffer );
       
  1162 
       
  1163             // Save the key code
       
  1164             iStateMachine->PhoneEngineInfo()->SetKeyCode( code.Peek() );
       
  1165 
       
  1166             // Plays a DTMF tone if active call
       
  1167             iStateMachine->SendPhoneEngineMessage(
       
  1168                 MPEPhoneModel::EPEMessagePlayDTMF );
       
  1169             // remove the phone number from the cleanup stack
       
  1170             CleanupStack::PopAndDestroy( phoneNumber );
       
  1171             }
       
  1172         }
       
  1173     }
       
  1174 
       
  1175 // <------------------------------ SYSTEM EVENTS ----------------------------->
       
  1176 
       
  1177 // -----------------------------------------------------------
       
  1178 // CPhoneState::DynInitMenuPaneL
       
  1179 // -----------------------------------------------------------
       
  1180 //
       
  1181 EXPORT_C void CPhoneState::DynInitMenuPaneL(
       
  1182     TInt aResourceId,
       
  1183     CEikMenuPane* aMenuPane )
       
  1184     {
       
  1185     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DynInitMenuPaneL( ) ");
       
  1186     __ASSERT_DEBUG( aMenuPane && aResourceId,
       
  1187         Panic( EPhoneCtrlParameterNotInitialized ) );
       
  1188 
       
  1189     // Save the number of digits in the number entry before processing
       
  1190     // the menu pane
       
  1191     if ( IsNumberEntryUsedL() )
       
  1192         {
       
  1193         TPhoneCmdParamBoolean serviceCodeParam;
       
  1194             serviceCodeParam.SetBoolean(
       
  1195             iStateMachine->PhoneEngineInfo()->PhoneNumberIsServiceCode() );
       
  1196         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetServiceCodeFlag,
       
  1197             &serviceCodeParam );
       
  1198         }
       
  1199 
       
  1200     // Process the menu pane
       
  1201     TPhoneCmdParamDynMenu dynMenuPane;
       
  1202     dynMenuPane.SetResourceId( aResourceId );
       
  1203     dynMenuPane.SetDynMenu( aMenuPane );
       
  1204     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuPane, &dynMenuPane );
       
  1205 
       
  1206     if ( iCustomization )
       
  1207         {
       
  1208         // Menu pane is customized after default items are decided
       
  1209         iCustomization->CustomizeMenuPaneL(aResourceId, aMenuPane);
       
  1210         }
       
  1211     }
       
  1212 
       
  1213 // -----------------------------------------------------------
       
  1214 // CPhoneState::DynInitMenuBarL
       
  1215 // -----------------------------------------------------------
       
  1216 //
       
  1217 EXPORT_C void CPhoneState::DynInitMenuBarL(
       
  1218     TInt aResourceId,
       
  1219     CEikMenuBar* aMenuBar )
       
  1220     {
       
  1221     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DynInitMenuBarL( ) ");
       
  1222     __ASSERT_DEBUG( aMenuBar && aResourceId,
       
  1223         Panic( EPhoneCtrlParameterNotInitialized ) );
       
  1224 
       
  1225     TPhoneCmdParamDynMenu dynMenuBar;
       
  1226     dynMenuBar.SetResourceId( aResourceId );
       
  1227     dynMenuBar.SetDynMenu( aMenuBar );
       
  1228     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBar, &dynMenuBar );
       
  1229 
       
  1230     if ( iCustomization )
       
  1231         {
       
  1232         // Menu bar is customized after default items are decided
       
  1233         iCustomization->CustomizeMenuBarL(aResourceId, aMenuBar);
       
  1234         }
       
  1235 
       
  1236     }
       
  1237 
       
  1238 // -----------------------------------------------------------
       
  1239 // CPhoneState::HandleSystemEventL
       
  1240 // -----------------------------------------------------------
       
  1241 //
       
  1242 EXPORT_C void CPhoneState::HandleSystemEventL( const TWsEvent& /*aEvent*/ )
       
  1243     {
       
  1244     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleSystemEventL( ) ");
       
  1245     }
       
  1246 
       
  1247 // -----------------------------------------------------------
       
  1248 // CPhoneState::HandleForegroundEventL
       
  1249 // -----------------------------------------------------------
       
  1250 //
       
  1251 EXPORT_C void CPhoneState::HandleForegroundEventL( TBool aForeground )
       
  1252     {
       
  1253     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleForegroundEventL( ) ");
       
  1254     if ( !aForeground && IsNumberEntryUsedL() )
       
  1255         {
       
  1256         // Going out from foreground and number entry is open.
       
  1257         // Make sure that dtmf playing is stopped ( EEventKeyUp may be missed ).
       
  1258         iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
       
  1259         }
       
  1260     }
       
  1261 
       
  1262 // -----------------------------------------------------------
       
  1263 // CPhoneState::HandlePhoneForegroundEventL
       
  1264 // -----------------------------------------------------------
       
  1265 //
       
  1266 EXPORT_C void CPhoneState::HandlePhoneForegroundEventL()
       
  1267     {
       
  1268     }
       
  1269 
       
  1270 // -----------------------------------------------------------
       
  1271 // CPhoneState::HandlePhoneFocusLostEventL
       
  1272 // -----------------------------------------------------------
       
  1273 //
       
  1274 EXPORT_C void CPhoneState::HandlePhoneFocusLostEventL()
       
  1275     {
       
  1276     // Notify that this method is called always when Idle is brought to foreground
       
  1277     // See implementation in CPhoneAppUI::HandleWsEventL
       
  1278 
       
  1279     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneFocusLostEventL( ) ");
       
  1280     // Phone app focus lost -> close Dtmf dialer when visible
       
  1281     if ( IsOnScreenDialerSupported() && IsDTMFEditorVisibleL() )
       
  1282         {
       
  1283         CloseDTMFEditorL();
       
  1284         }
       
  1285     else if ( IsOnScreenDialerSupported() && IsCustomizedDialerVisibleL() )
       
  1286         {
       
  1287         CloseCustomizedDialerL();
       
  1288         }
       
  1289     }
       
  1290 // ---------------------------------------------------------
       
  1291 // CPhoneState::HandleIdleForegroundEventL
       
  1292 // ---------------------------------------------------------
       
  1293 //
       
  1294 EXPORT_C void CPhoneState::HandleIdleForegroundEventL()
       
  1295     {
       
  1296     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleIdleForegroundEventL( ) ");
       
  1297     // Empty implementation
       
  1298     }
       
  1299 
       
  1300 // -----------------------------------------------------------
       
  1301 // CPhoneState::HandleEnvironmentChangeL
       
  1302 // -----------------------------------------------------------
       
  1303 //
       
  1304 EXPORT_C void CPhoneState::HandleEnvironmentChangeL( const TInt aChanges )
       
  1305     {
       
  1306     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleEnvironmentChangeL( ) ");
       
  1307     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::HandleEnvironmentChangeL - Changes:  %d ", aChanges );
       
  1308     // Update the profile display if required
       
  1309     if ( aChanges &
       
  1310         ( EChangesLocale | EChangesMidnightCrossover | EChangesSystemTime ) )
       
  1311         {
       
  1312         UpdateProfileDisplayL();
       
  1313         }
       
  1314     }
       
  1315 
       
  1316 // -----------------------------------------------------------
       
  1317 // CPhoneState::HandlePhoneStartupL
       
  1318 // -----------------------------------------------------------
       
  1319 //
       
  1320 EXPORT_C void CPhoneState::HandlePhoneStartupL()
       
  1321     {
       
  1322     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePhoneStartupL( ) ");
       
  1323     // Empty implementation
       
  1324     }
       
  1325 
       
  1326 // -----------------------------------------------------------
       
  1327 // CPhoneState::HandlePropertyChangedL
       
  1328 // -----------------------------------------------------------
       
  1329 //
       
  1330 EXPORT_C void CPhoneState::HandlePropertyChangedL(
       
  1331     const TUid& aCategory,
       
  1332     const TUint aKey,
       
  1333     const TInt aValue )
       
  1334     {
       
  1335 
       
  1336     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandlePropertyChangedL( ) ");
       
  1337 
       
  1338     __PHONELOG1( EBasic, EPhoneControl,
       
  1339             "CPhoneState::HandlePropertyChangedL - aCategory= %d", aCategory  );
       
  1340     __PHONELOG1( EBasic, EPhoneControl,
       
  1341             "CPhoneState::HandlePropertyChangedL - aKey= %d", aKey  );
       
  1342     __PHONELOG1( EBasic, EPhoneControl,
       
  1343             "CPhoneState::HandlePropertyChangedL - aValue= %d", aValue  );
       
  1344     if ( aCategory == KPSUidCtsyCallInformation )
       
  1345         {
       
  1346         // Call state event
       
  1347         if ( aKey == KCTsyCallState )
       
  1348             {
       
  1349             // Update the incall indicator
       
  1350             UpdateIncallIndicatorL( aValue );
       
  1351             }
       
  1352         }
       
  1353 
       
  1354     // Telephony information category
       
  1355     else if ( aCategory == KPSUidTelInformation
       
  1356               && SimState() == EPESimUsable )
       
  1357         {
       
  1358         // Telephony display event
       
  1359         if ( aKey == KTelDisplayInfo )
       
  1360             {
       
  1361             __PHONELOG( EBasic, EPhoneControl, "CPhoneState::HandlePropertyChangedL - telephony display info received" );
       
  1362             // Update the operator and profile display
       
  1363             UpdateProfileDisplayL();
       
  1364             }
       
  1365         }
       
  1366     else if ( aCategory == KPSUidStartup && aKey == KStartupSimSecurityStatus )
       
  1367         {
       
  1368         // Show security note, SIM is not valid.
       
  1369         if ( aValue == ESimRejected ||  aValue == ESimUnaccepted )
       
  1370             {
       
  1371             __PHONELOG( EBasic, EPhoneControl, "CPhoneStateStartup::HandlePropertyChangedL - SimSecurity status received" );
       
  1372             StartShowSecurityNoteL();
       
  1373             }
       
  1374         }
       
  1375     else if ( aCategory == KPSUidHWRM && aKey == KHWRMGripStatus )
       
  1376         {
       
  1377         UpdateCbaSwivelStateChangedL();
       
  1378         }
       
  1379     }
       
  1380 
       
  1381 // -----------------------------------------------------------
       
  1382 // CPhoneState::HandleCenRepChangeL
       
  1383 // -----------------------------------------------------------
       
  1384 //
       
  1385 EXPORT_C void CPhoneState::HandleCenRepChangeL(
       
  1386     const TUid& /*aUid*/,
       
  1387     const TUint /*aId*/ )
       
  1388     {
       
  1389     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCenRepChangeL( ) ");
       
  1390     }
       
  1391 
       
  1392 // -----------------------------------------------------------
       
  1393 // CPhoneState::NeedToSendToBackgroundL
       
  1394 // -----------------------------------------------------------
       
  1395 //
       
  1396 EXPORT_C TBool CPhoneState::NeedToSendToBackgroundL() const
       
  1397     {
       
  1398     return iViewCommandHandle->HandleCommandL(
       
  1399         EPhoneViewGetNeedToSendToBackgroundStatus ) ==
       
  1400         EPhoneViewResponseSuccess;
       
  1401     }
       
  1402 
       
  1403 // -----------------------------------------------------------
       
  1404 // CPhoneState::TopAppIsDisplayedL
       
  1405 // -----------------------------------------------------------
       
  1406 //
       
  1407 EXPORT_C TBool CPhoneState::TopAppIsDisplayedL() const
       
  1408     {
       
  1409     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::TopAppIsDisplayedL( ) ");
       
  1410     return iViewCommandHandle->HandleCommandL(
       
  1411         EPhoneViewGetTopApplicationIsDisplayedStatus ) ==
       
  1412         EPhoneViewResponseSuccess;
       
  1413     }
       
  1414 
       
  1415 // -----------------------------------------------------------
       
  1416 // CPhoneState::TitlePaneIsVisibleL
       
  1417 // -----------------------------------------------------------
       
  1418 //
       
  1419 TBool CPhoneState::TitlePaneIsVisibleL() const
       
  1420     {
       
  1421     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::TitlePaneIsVisibleL( ) ");
       
  1422     return iViewCommandHandle->HandleCommandL(
       
  1423         EPhoneViewGetTitlePaneIsVisibleStatus ) ==
       
  1424         EPhoneViewResponseSuccess;
       
  1425     }
       
  1426 
       
  1427 // <---------------------------- MENU AND CBA EVENTS ------------------------->
       
  1428 
       
  1429 EXPORT_C TBool CPhoneState::HandleCommandL( TInt aCommand )
       
  1430     {
       
  1431     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCommandL( ) ");
       
  1432     TBool commandStatus = ETrue;
       
  1433     switch( aCommand )
       
  1434         {
       
  1435         case EPhoneEmergencyCmdExit:
       
  1436             {
       
  1437             //cancel emergency mode.
       
  1438             TPhoneCmdParamBoolean booleanParam;
       
  1439             booleanParam.SetBoolean( EFalse );
       
  1440             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetRetrictedDialer,&booleanParam );
       
  1441             }
       
  1442             // this should be bypasses?
       
  1443         case EPhoneDialerCallHandling:
       
  1444         case EPhoneCmdBack:
       
  1445             BeginTransEffectLC( ENumberEntryClose );
       
  1446             // Remove number entry from screen
       
  1447             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1448             // Do state-specific behaviour if number entry is cleared
       
  1449             HandleNumberEntryClearedL();
       
  1450             EndTransEffect();
       
  1451             break;
       
  1452 
       
  1453         case EPhoneDialerCmdTouchInput:
       
  1454             OpenVkbL();
       
  1455             break;
       
  1456 
       
  1457         case EPhoneNumberAcqCmdSendMessage:
       
  1458             // Open the mms editor
       
  1459             iViewCommandHandle->ExecuteCommandL(
       
  1460                 EPhoneViewSendMessage );
       
  1461             if ( !IsOnScreenDialerSupported() )
       
  1462                 {
       
  1463                 // Remove number entry from screen
       
  1464                 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  1465                 // Do state-specific behaviour if number entry is cleared
       
  1466                 HandleNumberEntryClearedL();
       
  1467                 }
       
  1468             break;
       
  1469 
       
  1470         case EPhoneNumberAcqCmdSave:
       
  1471             // Open Create contact
       
  1472             iViewCommandHandle->ExecuteCommandL(
       
  1473                 EPhoneViewAddContact );
       
  1474             break;
       
  1475 
       
  1476         case EPhoneNumberAcqCmdAddToName:
       
  1477             // Open the message editor
       
  1478             iViewCommandHandle->ExecuteCommandL(
       
  1479                 EPhoneViewUpdateContact );
       
  1480             break;
       
  1481 
       
  1482         case EPhoneNumberAcqCmdAddToContacts:
       
  1483             {
       
  1484             if ( IsOnScreenDialerSupported() )
       
  1485                 {
       
  1486                 TPhoneCmdParamQuery queryDialogParam;
       
  1487                     queryDialogParam.SetQueryType( EPhoneContactsListQuery );
       
  1488                     queryDialogParam.SetQueryResourceId(
       
  1489                     CPhoneMainResourceResolver::Instance()->
       
  1490                     ResolveResourceID( EPhoneAddtoContactsListQuery )  );
       
  1491 
       
  1492                  // Display dialog
       
  1493                 iViewCommandHandle->ExecuteCommandL( EPhoneViewShowQuery,
       
  1494                     &queryDialogParam );
       
  1495                 }
       
  1496             }
       
  1497             break;
       
  1498 
       
  1499         case EPhoneCmdWaitNoteOk:
       
  1500             // Remove number entry from screen
       
  1501             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
       
  1502             if ( !IsOnScreenDialerSupported() )
       
  1503                 {
       
  1504                 HandleNumberEntryClearedL();
       
  1505                 }
       
  1506             break;
       
  1507 
       
  1508         case EPhoneInCallCmdEndThisOutgoingCall:
       
  1509             DisconnectCallL();
       
  1510             break;
       
  1511 
       
  1512         case EPhoneCmdYesAlsLineChange:
       
  1513             if( IsAlsLineChangePossible() )
       
  1514                 {
       
  1515                 ChangeAlsLineL();
       
  1516                 }
       
  1517             else
       
  1518                 {
       
  1519                 SendGlobalErrorNoteL( EPhoneLineBlockingNote );
       
  1520                 HandleNumberEntryClearedL(); // Set back CBAs
       
  1521                 }
       
  1522             break;
       
  1523 
       
  1524         case EPhoneCmdNoAlsLineChange:
       
  1525             if ( !IsOnScreenDialerSupported() )
       
  1526                 {
       
  1527                 HandleNumberEntryClearedL();
       
  1528                 }
       
  1529             break;
       
  1530 
       
  1531         case EPhoneCmdYesBtDisconnectQuery:
       
  1532         case EPhoneCmdNoBtDisconnectQuery:
       
  1533             CPhoneBtaaDisconnectHandler::InstanceL()->HandleQueryDismissL( aCommand );
       
  1534             // Make sure that query is removed
       
  1535             // if there has been also another ( by Cover UI ).
       
  1536             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
       
  1537             break;
       
  1538 
       
  1539         case EPhoneInCallCmdDeactivateIhf: // fall through
       
  1540         case EPhoneInCallCmdActivateIhf:
       
  1541             SetHandsfreeModeL( aCommand == EPhoneInCallCmdActivateIhf );
       
  1542              break;
       
  1543 
       
  1544         case EPhoneInCallCmdHandset:    // fall through
       
  1545         case EPhoneInCallCmdBtHandsfree:
       
  1546             CPhoneState::SetBTHandsfreeModeL(
       
  1547                  aCommand == EPhoneInCallCmdBtHandsfree );
       
  1548             break;
       
  1549 
       
  1550         case EPhoneInCallCmdActivatEPhonebook:
       
  1551             {
       
  1552             // Launch Phonebook application
       
  1553             TPhoneCmdParamAppInfo appInfoParam;
       
  1554             appInfoParam.SetAppUid( KPhoneUidAppPhonebook );
       
  1555             iViewCommandHandle->ExecuteCommandL(
       
  1556                 EPhoneViewActivateApp, &appInfoParam );
       
  1557             }
       
  1558             break;
       
  1559 
       
  1560         case EPhoneNumberAcqSecurityDialer:
       
  1561             {
       
  1562             if ( IsOnScreenDialerSupported() && !IsNumberEntryUsedL() )
       
  1563                 {
       
  1564                 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
       
  1565                 TPhoneCmdParamBoolean visibleMode;
       
  1566                 visibleMode.SetBoolean( ETrue );
       
  1567                 iViewCommandHandle->ExecuteCommandL(
       
  1568                             EPhoneViewSetStatusPaneVisible, &visibleMode );
       
  1569 
       
  1570 
       
  1571                 // Set emergency CBA, empty - exit
       
  1572                 iCbaManager->SetCbaL( EPhoneEmergencyModeNoteCBA );
       
  1573 
       
  1574                 // Set dialer to restricted mode.
       
  1575                 TPhoneCmdParamBoolean booleanParam;
       
  1576                 booleanParam.SetBoolean( ETrue );
       
  1577                 iViewCommandHandle->ExecuteCommandL( EPhoneViewSetRetrictedDialer,&booleanParam );
       
  1578 
       
  1579                 NumberEntryManagerL()->CreateNumberEntryL();
       
  1580                 }
       
  1581             }
       
  1582             break;
       
  1583 
       
  1584         case EPhoneDialerCmdContacts:
       
  1585             {
       
  1586             // Launch Phonebook application
       
  1587             TPhoneCmdParamAppInfo appInfoParam;
       
  1588             appInfoParam.SetAppUid( KPhoneUidAppPhonebook );
       
  1589             iViewCommandHandle->ExecuteCommandL(
       
  1590                 EPhoneViewActivateApp, &appInfoParam );
       
  1591             }
       
  1592             break;
       
  1593 
       
  1594         case EPhoneViewYesSingleItemFetch:
       
  1595             {
       
  1596             if ( IsOnScreenDialerSupported() )
       
  1597                 {
       
  1598                 TBuf<KPhoneNumberEntryBufferSize> fetchContent;
       
  1599                 fetchContent = iViewCommandHandle->FetchContent();
       
  1600                 if ( fetchContent.Length() )
       
  1601                     {
       
  1602                     iViewCommandHandle->ExecuteCommandL(
       
  1603                                             EPhoneViewSetNumberEntryContent,
       
  1604                                             0,
       
  1605                                             fetchContent );
       
  1606 
       
  1607                     CallFromNumberEntryL();
       
  1608                     }
       
  1609                 }
       
  1610             }
       
  1611             break;
       
  1612         case EPhoneNumberAcqCmdToggleNeAlphaMode:
       
  1613         case EPhoneNumberAcqCmdToggleNeNumericMode:
       
  1614             {
       
  1615             // Toggle mode
       
  1616             NumberEntryManagerL()->NumberEntryToggleAlphaNumericModeL();
       
  1617             }
       
  1618             break;
       
  1619 
       
  1620         case EPhoneCmdYesVideoFailedNoMemorySwitchToVoice:
       
  1621             DialVoiceCallL();
       
  1622             break;
       
  1623 
       
  1624         case EPhoneCmdNoVideoFailedNoMemorySwitchToVoice:
       
  1625             if ( IsNumberEntryUsedL() )
       
  1626                 {
       
  1627                 // Show the number entry if it exists
       
  1628                 SetNumberEntryVisibilityL(ETrue);
       
  1629                 }
       
  1630             else if ( NeedToSendToBackgroundL() )
       
  1631                 {
       
  1632                 // Continue displaying current app but set up the
       
  1633                 // idle screen in the background
       
  1634                 SetupIdleScreenInBackgroundL();
       
  1635                 }
       
  1636             else
       
  1637                 {
       
  1638                  // Display idle screen
       
  1639                 DisplayIdleScreenL();
       
  1640                 }
       
  1641             break;
       
  1642 
       
  1643         case EPhoneInCallCmdSetVolumeLevel:
       
  1644             {
       
  1645             // This command comes from ui control, no need to update
       
  1646             // value to control (second parameter set false).
       
  1647             ChangeAudioVolumeL( GetVolumeLevel(), EFalse );
       
  1648             }
       
  1649             break;
       
  1650 
       
  1651         case EPhoneDialerCmdHelp:
       
  1652             if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
  1653                 {
       
  1654                 TPtrC contextName;
       
  1655                 contextName.Set( KDATA_DIALER_HLP_MAIN() );
       
  1656                 iViewCommandHandle->ExecuteCommandL(
       
  1657                     EPhoneViewLaunchHelpApplication, 0, contextName );
       
  1658                 }
       
  1659             break;
       
  1660 
       
  1661         case EPhoneCmdVideoCallOutOfMemory:
       
  1662             ShowVideoCallOutOfMemoryNoteL();
       
  1663             DisconnectCallL();
       
  1664             break;
       
  1665             
       
  1666         case EPhoneCallComingCmdSoftReject:
       
  1667             // Open Soft reject message editor
       
  1668             OpenSoftRejectMessageEditorL();
       
  1669             break;
       
  1670             
       
  1671         case EPhoneInCallCmdContacts:
       
  1672             iViewCommandHandle->ExecuteCommand( EPhoneViewOpenContacts );
       
  1673             break;
       
  1674             
       
  1675         default:
       
  1676 
       
  1677             /*if ( IsOnScreenDialerSupported() )
       
  1678                 {
       
  1679                 // Offer command to view.
       
  1680                 TPhoneViewResponseId resId =
       
  1681                             iViewCommandHandle->HandleCommandL( aCommand );
       
  1682 
       
  1683                 if( resId == EPhoneViewResponseFailed )
       
  1684                     {
       
  1685                     commandStatus = EFalse;
       
  1686                     }
       
  1687                 }
       
  1688             else*/
       
  1689 
       
  1690                 {
       
  1691                 commandStatus = EFalse;
       
  1692                 }
       
  1693             break;
       
  1694         }
       
  1695 
       
  1696     if( !commandStatus && iCustomization )
       
  1697         {
       
  1698         commandStatus = iCustomization->HandleCommandL( aCommand );
       
  1699         }
       
  1700 
       
  1701     return commandStatus;
       
  1702     }
       
  1703 
       
  1704 // -----------------------------------------------------------------------------
       
  1705 // CPhoneState::ProcessCommandL
       
  1706 // -----------------------------------------------------------------------------
       
  1707 //
       
  1708 EXPORT_C TBool CPhoneState::ProcessCommandL( TInt /*aCommand*/ )
       
  1709     {
       
  1710     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateIdle::ProcessCommandL() ");
       
  1711     // no implementation.
       
  1712     return EFalse;
       
  1713     }
       
  1714 
       
  1715 // <-------------------------- REMOTE CONTROL EVENTS ------------------------->
       
  1716 
       
  1717 // -----------------------------------------------------------------------------
       
  1718 // CPhoneState::HandleRemConCommandL
       
  1719 // -----------------------------------------------------------------------------
       
  1720 //
       
  1721 EXPORT_C TBool CPhoneState::HandleRemConCommandL(
       
  1722     TRemConCoreApiOperationId aOperationId,
       
  1723     TRemConCoreApiButtonAction /*aButtonAct*/ )
       
  1724     {
       
  1725     TBool handled = EFalse;
       
  1726 
       
  1727     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::MrccatoCommand() ");
       
  1728     switch ( aOperationId )
       
  1729         {
       
  1730         case ERemConCoreApiVolumeUp:
       
  1731             __PHONELOG( EBasic, EPhoneControl, "CPhoneState::MrccatoCommand ERemConCoreApiVolumeUp" );
       
  1732             IncreaseAudioVolumeL();
       
  1733             handled = ETrue;
       
  1734             break;
       
  1735 
       
  1736         case ERemConCoreApiVolumeDown:
       
  1737             __PHONELOG( EBasic, EPhoneControl, "CPhoneState::MrccatoCommand ERemConCoreApiVolumeDown" );
       
  1738             DecreaseAudioVolumeL();
       
  1739             handled = ETrue;
       
  1740             break;
       
  1741         case ERemConCoreApiMute:
       
  1742             {
       
  1743             __PHONELOG( EBasic, EPhoneControl, "CPhoneState::MrccatoCommand ERemConCoreApiMute" );
       
  1744             iStateMachine->PhoneEngineInfo()->AudioMute() ?
       
  1745                 iStateMachine->PhoneEngineInfo()->SetAudioMuteCommand( EFalse ):
       
  1746                 iStateMachine->PhoneEngineInfo()->SetAudioMuteCommand( ETrue );
       
  1747             iStateMachine->SendPhoneEngineMessage(
       
  1748                 MPEPhoneModel::EPEMessageSetAudioMute );
       
  1749             handled = ETrue;
       
  1750             break;
       
  1751             }
       
  1752 
       
  1753          default:
       
  1754              __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::MrccatoCommand MrccatoCmd.Other(%d)", aOperationId );
       
  1755             // Other commands ignored.
       
  1756             break;
       
  1757         }
       
  1758 
       
  1759     return handled;
       
  1760     }
       
  1761 
       
  1762 // -----------------------------------------------------------
       
  1763 // CPhoneState::DecreaseAudioVolume()
       
  1764 // -----------------------------------------------------------
       
  1765 //
       
  1766 EXPORT_C void CPhoneState::DecreaseAudioVolumeL()
       
  1767     {
       
  1768     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DecreaceAudioVolumeL( ) ");
       
  1769     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  1770         Panic( EPhoneCtrlInvariant ) );
       
  1771 
       
  1772     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
       
  1773      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::DecreaseAudioVolumeL - audio output =%d", output );
       
  1774     if( output == EPETTY )
       
  1775         {
       
  1776         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl );
       
  1777         }
       
  1778     else
       
  1779         {
       
  1780         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
       
  1781         audioVolume--;
       
  1782         ChangeAudioVolumeL( audioVolume, ETrue );
       
  1783         }
       
  1784     }
       
  1785 
       
  1786 // -----------------------------------------------------------
       
  1787 // CPhoneState::IncreaceAudioVolume()
       
  1788 // -----------------------------------------------------------
       
  1789 //
       
  1790 EXPORT_C void CPhoneState::IncreaseAudioVolumeL()
       
  1791     {
       
  1792      __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IncreaceAudioVolumeL( ) ");
       
  1793     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  1794         Panic( EPhoneCtrlInvariant ) );
       
  1795 
       
  1796     TPEAudioOutput output( iStateMachine->PhoneEngineInfo()->AudioOutput() );
       
  1797      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IncreaseAudioVolumeL - audio output =%d", output );
       
  1798     if( output == EPETTY )
       
  1799         {
       
  1800         SendGlobalInfoNoteL( EPhoneNoteTTYNoAudioControl );
       
  1801         }
       
  1802     else
       
  1803         {
       
  1804         TInt audioVolume( iStateMachine->PhoneEngineInfo()->AudioVolume() );
       
  1805         audioVolume++;
       
  1806         ChangeAudioVolumeL( audioVolume, ETrue );
       
  1807         }
       
  1808     }
       
  1809 
       
  1810 // -----------------------------------------------------------
       
  1811 // CPhoneState::ChangeAudioVolumeL()
       
  1812 // -----------------------------------------------------------
       
  1813 //
       
  1814 void CPhoneState::ChangeAudioVolumeL( TInt aLevel, TBool aUpdateControl )
       
  1815     {
       
  1816      __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::ChangeAudioVolumeL( ) ");
       
  1817      __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::ChangeAudioVolumeL - set volume =%d", aLevel );
       
  1818 
       
  1819     TInt valueToControl = aLevel;
       
  1820 
       
  1821     // sets value between 1 -10
       
  1822     if ( aLevel>=KPhoneVolumeMinValue && aLevel<=KPhoneVolumeMaxValue )
       
  1823         {
       
  1824         iStateMachine->PhoneEngineInfo()->SetAudioVolumeCommand( aLevel );
       
  1825         // Syncronizes audio volume level between engine and ui
       
  1826         // causes EPEMessageAudioVolumeChanged message to phoneUI
       
  1827         iStateMachine->SendPhoneEngineMessage(
       
  1828             MPEPhoneModel::EPEMessageSetAudioVolume );
       
  1829         }
       
  1830         
       
  1831     if ( aUpdateControl )        
       
  1832         {
       
  1833         // Update the volume display.
       
  1834         // Upper max (11) and under min (-1)
       
  1835         // values are also updated to volume popup.
       
  1836         TPhoneCmdParamInteger volumeParam;
       
  1837         volumeParam.SetInteger( valueToControl );
       
  1838         iViewCommandHandle->ExecuteCommandL(
       
  1839             EPhoneViewSetNaviPaneAudioVolume,
       
  1840             &volumeParam );
       
  1841         }
       
  1842     }
       
  1843 
       
  1844 // <-------------------------- COMMON STATE FUNCTIONS ------------------------>
       
  1845 
       
  1846 // -----------------------------------------------------------
       
  1847 // CPhoneState::DialMultimediaCallL
       
  1848 // -----------------------------------------------------------
       
  1849 //
       
  1850 EXPORT_C void CPhoneState::DialMultimediaCallL()
       
  1851     {
       
  1852     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialMultimediaCall() ");
       
  1853     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  1854         Panic( EPhoneCtrlInvariant ) );
       
  1855     iStateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeVideo );
       
  1856     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
       
  1857     }
       
  1858 
       
  1859 // -----------------------------------------------------------
       
  1860 // CPhoneState::DialVoiceCallL
       
  1861 // -----------------------------------------------------------
       
  1862 //
       
  1863 EXPORT_C void CPhoneState::DialVoiceCallL()
       
  1864     {
       
  1865     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialVoiceCallL() ");
       
  1866     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  1867         Panic( EPhoneCtrlInvariant ) );
       
  1868 
       
  1869     // Disable global notes
       
  1870     TPhoneCmdParamBoolean globalNotifierParam;
       
  1871     globalNotifierParam.SetBoolean( ETrue );
       
  1872     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
  1873             &globalNotifierParam );
       
  1874    iStateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeCSVoice );
       
  1875     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
       
  1876     }
       
  1877 
       
  1878 // -----------------------------------------------------------
       
  1879 // CPhoneState::DisconnectCallL
       
  1880 // -----------------------------------------------------------
       
  1881 //
       
  1882 EXPORT_C TBool CPhoneState::DisconnectCallL()
       
  1883     {
       
  1884     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
       
  1885     TPhoneCmdParamInteger callIdParam;
       
  1886     iViewCommandHandle->ExecuteCommandL( 
       
  1887             EPhoneViewGetExpandedBubbleCallId, &callIdParam );
       
  1888 
       
  1889     TBool ret = EFalse;
       
  1890     if( callIdParam.Integer() > KErrNotFound )
       
  1891         {
       
  1892         // Release the call
       
  1893         iStateMachine->SetCallId( callIdParam.Integer() );
       
  1894 
       
  1895         if( IsVideoCall( callIdParam.Integer() ) )
       
  1896             {
       
  1897             // Video call can be released only after we get response to VT Shutdown Command
       
  1898             CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
       
  1899                                                                                  KCatPhoneToVideotelCommands,
       
  1900                                                                                  EVtCmdReleaseDataport,
       
  1901                                                                        TVersion( KPhoneToVideotelCmdVersionMajor,
       
  1902                                                                                  KPhoneToVideotelCmdVersionMinor,
       
  1903                                                                                  KPhoneToVideotelCmdVersionBuild ),
       
  1904                                                                        KNullDesC8,
       
  1905                                                                        CPhoneReleaseCommand::NewL( *iStateMachine ) );
       
  1906             }
       
  1907         else
       
  1908             {
       
  1909             // Release the call
       
  1910             iStateMachine->SendPhoneEngineMessage(
       
  1911                 MPEPhoneModel::EPEMessageRelease );
       
  1912             }
       
  1913         ret = ETrue;
       
  1914         }
       
  1915     else
       
  1916         {
       
  1917         __PHONELOG( EOnlyFatal, EPhoneControl,
       
  1918             "CPhoneState::DisconnectCallL has negative call id!" );
       
  1919         }
       
  1920 
       
  1921     return ret;
       
  1922     }
       
  1923 
       
  1924 // -----------------------------------------------------------
       
  1925 // CPhoneState::DisplayIdleScreenL
       
  1926 // -----------------------------------------------------------
       
  1927 //
       
  1928 EXPORT_C void CPhoneState::DisplayIdleScreenL()
       
  1929     {
       
  1930     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisplayIdleScreenL( ) ");
       
  1931 
       
  1932     // Don't remove reconnect query if it's shown
       
  1933     if( !CPhoneReconnectQuery::InstanceL()->IsDisplayingQuery() )
       
  1934         {
       
  1935         // Remove dialogs if necessary
       
  1936         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  1937         }
       
  1938 
       
  1939     // Set Empty CBA
       
  1940     iCbaManager->SetCbaL( EPhoneEmptyCBA );
       
  1941     // Bring Idle app to the foreground
       
  1942     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringIdleToForeground );
       
  1943     }
       
  1944 
       
  1945 // -----------------------------------------------------------
       
  1946 // CPhoneState::SetupIdleScreenInBackgroundL()
       
  1947 // -----------------------------------------------------------
       
  1948 //
       
  1949 EXPORT_C void CPhoneState::SetupIdleScreenInBackgroundL()
       
  1950     {
       
  1951     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetupIdleScreenInBackgroundL( ) ");
       
  1952     // Don't remove reconnect query if it's shown
       
  1953     if( !CPhoneReconnectQuery::InstanceL()->IsDisplayingQuery() )
       
  1954         {
       
  1955         // Remove dialogs if necessary
       
  1956         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  1957         }
       
  1958     // Return phone to the background
       
  1959     iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
       
  1960 
       
  1961     // Set Idle app as the top app
       
  1962     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetIdleTopApplication );
       
  1963 
       
  1964     // Set Empty CBA
       
  1965     iCbaManager->SetCbaL( EPhoneEmptyCBA );
       
  1966     }
       
  1967 
       
  1968 // ---------------------------------------------------------
       
  1969 // CPhoneState::CallFromNumberEntryL
       
  1970 // ---------------------------------------------------------
       
  1971 //
       
  1972 EXPORT_C void CPhoneState::CallFromNumberEntryL()
       
  1973     {
       
  1974     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CallFromNumberEntryL( ) ");
       
  1975     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  1976         Panic( EPhoneCtrlInvariant ) );
       
  1977 
       
  1978     if ( IsOnScreenDialerSupported() )
       
  1979         {
       
  1980         if ( IsDTMFEditorVisibleL() ||
       
  1981              IsCustomizedDialerVisibleL() )
       
  1982             {
       
  1983             return;
       
  1984             }
       
  1985 
       
  1986         else if( IsNumberEntryUsedL() )
       
  1987             {
       
  1988             // Query on top of dialer
       
  1989             if ( IsAnyQueryActiveL() )
       
  1990                 {
       
  1991                 return;
       
  1992                 }
       
  1993             else if ( IsMenuBarVisibleL() )
       
  1994                 {
       
  1995                 iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
  1996                 return;
       
  1997                 }
       
  1998             // Open recent calls list when the number entry is empty
       
  1999             TPhoneCmdParamInteger numberEntryCountParam;
       
  2000             iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
       
  2001             &numberEntryCountParam );
       
  2002             TInt neLength( numberEntryCountParam.Integer() );
       
  2003             TBool startLogs = neLength == 0 ? ETrue : EFalse;
       
  2004 
       
  2005             if ( startLogs )
       
  2006                 {
       
  2007                 iViewCommandHandle->HandleCommandL(
       
  2008                 EPhoneDialerCmdLog );
       
  2009                 return;
       
  2010                 }
       
  2011             }
       
  2012         }
       
  2013 
       
  2014     // Get the number entry contents
       
  2015     HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
  2016 
       
  2017     // Call the number
       
  2018     iStateMachine->PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
       
  2019 
       
  2020     if ( phoneNumber->Des().Length() < KPhoneValidPhoneNumberLength )
       
  2021         {
       
  2022         // Closing effect is shown when dialer exist.
       
  2023         BeginTransEffectLC( ENumberEntryClose );
       
  2024         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  2025         EndTransEffect();
       
  2026 
       
  2027         HandleNumberEntryClearedL();
       
  2028         }
       
  2029 
       
  2030     CleanupStack::PopAndDestroy( phoneNumber );
       
  2031 
       
  2032     if ( !iCustomization ||
       
  2033          !iCustomization->HandleCallFromNumberEntryL() )
       
  2034         {
       
  2035         // Customization didn't handle call. Dial voice call
       
  2036         // as normally
       
  2037         DialVoiceCallL();
       
  2038         }
       
  2039 
       
  2040     }
       
  2041 
       
  2042 // -----------------------------------------------------------
       
  2043 // CPhoneState::DisplayHeaderForCallComingInL
       
  2044 // -----------------------------------------------------------
       
  2045 //
       
  2046 EXPORT_C void CPhoneState::DisplayHeaderForCallComingInL(
       
  2047     TInt aCallId,
       
  2048     TBool aWaitingCall )
       
  2049     {
       
  2050     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisplayHeaderForCallComingInL( ) ");
       
  2051     CallheaderManagerL()->DisplayHeaderForCallComingInL( aCallId, aWaitingCall );
       
  2052     }
       
  2053 
       
  2054 // -----------------------------------------------------------
       
  2055 // CPhoneState::SetCallHeaderTextsForCallComingInL
       
  2056 // -----------------------------------------------------------
       
  2057 //
       
  2058 EXPORT_C void CPhoneState::SetCallHeaderTextsForCallComingInL(
       
  2059         TInt aCallId,
       
  2060         TBool aWaitingCall,
       
  2061         TPhoneCmdParamCallHeaderData* aCallHeaderData )
       
  2062     {
       
  2063     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetCallHeaderTextsForCallComingInL( ) ");
       
  2064     CallheaderManagerL()->SetCallHeaderTextsForCallComingIn( aCallId, aWaitingCall, aCallHeaderData );
       
  2065     }
       
  2066 
       
  2067 // -----------------------------------------------------------
       
  2068 // CPhoneState::DisplayHeaderForOutgoingCallL
       
  2069 // -----------------------------------------------------------
       
  2070 //
       
  2071 EXPORT_C void CPhoneState::DisplayHeaderForOutgoingCallL(
       
  2072     TInt aCallId )
       
  2073     {
       
  2074     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisplayHeaderForOutgoingCallL( ) ");
       
  2075     CallheaderManagerL()->DisplayHeaderForOutgoingCallL(aCallId);
       
  2076     }
       
  2077 
       
  2078 // -----------------------------------------------------------
       
  2079 // CPhoneState::UpdateSingleActiveCallL
       
  2080 // -----------------------------------------------------------
       
  2081 //
       
  2082 EXPORT_C void CPhoneState::UpdateSingleActiveCallL( TInt aCallId )
       
  2083     {
       
  2084     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateSingleActiveCallL( ) ");
       
  2085 
       
  2086     // Stop capturing keys
       
  2087     CaptureKeysDuringCallNotificationL( EFalse );
       
  2088 
       
  2089     BeginUiUpdateLC();
       
  2090 
       
  2091     // Update call state
       
  2092     TPhoneCmdParamCallHeaderData callHeaderParam;
       
  2093     callHeaderParam.SetCallState( EPEStateConnected );
       
  2094     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId,
       
  2095         &callHeaderParam );
       
  2096 
       
  2097     // Update remote info data
       
  2098     UpdateRemoteInfoDataL( aCallId );
       
  2099 
       
  2100     // Create call duration label if enabled
       
  2101     // This key will be moved to some other area, but since key
       
  2102     // is supported we can still use it.
       
  2103     TBool callDuration( EFalse );
       
  2104     CPhoneCenRepProxy::Instance()->GetInt(
       
  2105             KCRUidLogs, KLogsShowCallDuration, callDuration );
       
  2106 
       
  2107     if ( callDuration )
       
  2108         {
       
  2109         HandleChangedCallDurationL( aCallId );
       
  2110         }
       
  2111 
       
  2112     EndUiUpdate();
       
  2113 
       
  2114      // Go to current state implementation
       
  2115     iCbaManager->UpdateInCallCbaL();
       
  2116 
       
  2117     //Update state of switch to video or voice call touch button.
       
  2118     TPECallType type = iStateMachine->PhoneEngineInfo()->CallType( aCallId );
       
  2119 
       
  2120     if( type == EPECallTypeVideo )
       
  2121         {
       
  2122         TPhoneCmdParamBoolean booleanParam;
       
  2123         booleanParam.SetBoolean( ETrue );
       
  2124         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetVideoCallFlag, &booleanParam );
       
  2125         }
       
  2126     else
       
  2127         {
       
  2128         TPhoneCmdParamBoolean booleanParam;
       
  2129         booleanParam.SetBoolean( EFalse );
       
  2130         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetVideoCallFlag, &booleanParam );
       
  2131         }
       
  2132 
       
  2133     // Go to background if necessary
       
  2134     if ( NeedToSendToBackgroundL() ||  IsAutoLockOn() )
       
  2135         {
       
  2136         // If number entry is used set control and visibility.
       
  2137         if ( IsNumberEntryUsedL() )
       
  2138            {
       
  2139            iViewCommandHandle->ExecuteCommandL( EPhoneViewSetControlAndVisibility );
       
  2140            }
       
  2141         }
       
  2142     // If there is no need to send back ground and number entry is used then
       
  2143     // we must show number entry.
       
  2144     else if ( !NeedToSendToBackgroundL() && IsNumberEntryUsedL() )
       
  2145         {
       
  2146         SetNumberEntryVisibilityL(ETrue);
       
  2147         }
       
  2148     }
       
  2149 
       
  2150 // -----------------------------------------------------------
       
  2151 // CPhoneState::CaptureKeysDuringCallNotificationL
       
  2152 // -----------------------------------------------------------
       
  2153 //
       
  2154 EXPORT_C void CPhoneState::CaptureKeysDuringCallNotificationL(
       
  2155     TBool aCaptured )
       
  2156     {
       
  2157     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CaptureKeysDuringCallNotificationL( ) ");
       
  2158     // Determine which view command to execute based on the capture status
       
  2159     const TInt viewCommandId = aCaptured ?
       
  2160         EPhoneViewStartCapturingKey :
       
  2161         EPhoneViewStopCapturingKey;
       
  2162 
       
  2163     // Capture the App key
       
  2164     TPhoneCmdParamKeyCapture appKeyCaptureParam;
       
  2165     appKeyCaptureParam.SetKey( EStdKeyApplication0 );
       
  2166     appKeyCaptureParam.SetKeyCode( EKeyApplication0 );
       
  2167     appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
  2168     iViewCommandHandle->ExecuteCommandL( viewCommandId, &appKeyCaptureParam );
       
  2169 
       
  2170     // Capture the Camera key, if it exists
       
  2171     if ( FeatureManager::FeatureSupported( KFeatureIdCamera ) )
       
  2172         {
       
  2173         TPhoneCmdParamKeyCapture cameraKeyCaptureParam;
       
  2174         cameraKeyCaptureParam.SetKey( EStdKeyDevice7 );
       
  2175         cameraKeyCaptureParam.SetKeyCode( EKeyDevice7 );
       
  2176         cameraKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
  2177         iViewCommandHandle->ExecuteCommandL( viewCommandId,
       
  2178             &cameraKeyCaptureParam );
       
  2179         }
       
  2180     }
       
  2181 
       
  2182 // -----------------------------------------------------------
       
  2183 // CPhoneState::IsWaitingCallL
       
  2184 // -----------------------------------------------------------
       
  2185 //
       
  2186 TBool CPhoneState::IsWaitingCallL( const TInt aCallId  )
       
  2187     {
       
  2188     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsWaitingCallL( ) ");
       
  2189     return CallheaderManagerL()->IsWaitingCallL( aCallId );
       
  2190     }
       
  2191 
       
  2192 // -----------------------------------------------------------
       
  2193 // CPhoneState::UpdateCallHeaderInfoL
       
  2194 // -----------------------------------------------------------
       
  2195 //
       
  2196 TPhoneCmdParamCallHeaderData CPhoneState::UpdateCallHeaderInfoL( TInt aCallId )
       
  2197     {
       
  2198     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateCallHeaderInfoL( ) ");
       
  2199     return CallheaderManagerL()->UpdateCallHeaderInfoL( aCallId );
       
  2200     }
       
  2201 
       
  2202 // -----------------------------------------------------------
       
  2203 // CPhoneState::UpdateRemoteInfoDataL
       
  2204 // -----------------------------------------------------------
       
  2205 //
       
  2206 EXPORT_C void CPhoneState::UpdateRemoteInfoDataL( TInt aCallId )
       
  2207     {
       
  2208     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::UpdateRemoteInfoDataL() ");
       
  2209     TPhoneCmdParamCallHeaderData callHeaderParam = UpdateCallHeaderInfoL( aCallId );
       
  2210 
       
  2211     if( iCustomization )
       
  2212         {
       
  2213         TBuf<KCntMaxTextFieldLength> inCallNumberText( KNullDesC );
       
  2214         // incall number text could be 'Call 1', 'Call 2', ...
       
  2215         CallheaderManagerL()->GetInCallNumberTextL( aCallId, inCallNumberText );
       
  2216         // to check if we have VoIP call in question and fix
       
  2217         // parameters if needed
       
  2218         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
       
  2219             inCallNumberText );
       
  2220         }
       
  2221 
       
  2222 
       
  2223     // Update the remote info data in the call header
       
  2224     iViewCommandHandle->ExecuteCommandL(
       
  2225         EPhoneViewUpdateCallHeaderRemoteInfoData,
       
  2226         aCallId,
       
  2227         &callHeaderParam );
       
  2228     }
       
  2229 
       
  2230 // -----------------------------------------------------------
       
  2231 // CPhoneState::SetCallHeaderType
       
  2232 // -----------------------------------------------------------
       
  2233 //
       
  2234 EXPORT_C void CPhoneState::SetCallHeaderType(
       
  2235     TInt aCallHeaderType )
       
  2236     {
       
  2237     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetCallHeaderType() ");
       
  2238     TRAP_IGNORE( CallheaderManagerL()->SetCallHeaderType( aCallHeaderType ) );
       
  2239     }
       
  2240 
       
  2241 // -----------------------------------------------------------
       
  2242 // CPhoneState::GetRemoteInfoDataL
       
  2243 // -----------------------------------------------------------
       
  2244 //
       
  2245 EXPORT_C void CPhoneState::GetRemoteInfoDataL(
       
  2246     TInt aCallId,
       
  2247     TDes& aData )
       
  2248     {
       
  2249     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::GetRemoteInfoDataL() ");
       
  2250     CallheaderManagerL()->GetRemoteInfoDataL( aCallId, aData );
       
  2251     }
       
  2252 
       
  2253 // -----------------------------------------------------------
       
  2254 // CPhoneState::UpdateCbaSwivelStateChangedL
       
  2255 // -----------------------------------------------------------
       
  2256 //
       
  2257 void CPhoneState::UpdateCbaSwivelStateChangedL()
       
  2258     {
       
  2259     __LOGMETHODSTARTEND(EPhoneControl,"CPhoneState::UpdateCbaSwivelStateChangedL()" );
       
  2260 
       
  2261     TPhoneCmdParamCallStateData callStateData;
       
  2262     callStateData.SetCallState( EPEStateRinging );
       
  2263     iViewCommandHandle->HandleCommandL(
       
  2264         EPhoneViewGetCallIdByState, &callStateData );
       
  2265     TInt incomingCall = callStateData.CallId();
       
  2266 
       
  2267     TPhoneCmdParamInteger activeCallCount;
       
  2268     iViewCommandHandle->ExecuteCommandL(
       
  2269             EPhoneViewGetCountOfActiveCalls, &activeCallCount );
       
  2270 
       
  2271     if ( incomingCall > KErrNotFound )
       
  2272         {
       
  2273        if( activeCallCount.Integer() == ENoActiveCalls )
       
  2274             {
       
  2275             iCbaManager->UpdateIncomingCbaL( incomingCall );
       
  2276             UpdateSilenceButtonDimming();
       
  2277             }
       
  2278         else
       
  2279             {
       
  2280             iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
       
  2281             }
       
  2282         }
       
  2283     else if ( activeCallCount.Integer() != ENoActiveCalls )
       
  2284         {
       
  2285         iCbaManager->UpdateInCallCbaL();
       
  2286         }
       
  2287     }
       
  2288 
       
  2289 // -----------------------------------------------------------------------------
       
  2290 // CPhoneState::IsSwivelClosed
       
  2291 // This function checks from PubSubProxy that is
       
  2292 // Swivel closed or not in product.
       
  2293 //
       
  2294 // -----------------------------------------------------------------------------
       
  2295 //
       
  2296 EXPORT_C TBool CPhoneState::IsSwivelClosed() const
       
  2297     {
       
  2298     if( CPhoneCenRepProxy::Instance()->
       
  2299             IsTelephonyFeatureSupported( KTelephonyLVFlagSwivelInDevice ))
       
  2300         {
       
  2301         return CPhonePubSubProxy::Instance()->
       
  2302             Value( KPSUidHWRM, KHWRMGripStatus ) == EPSHWRMGripClosed;
       
  2303         }
       
  2304     else
       
  2305         {
       
  2306         return EFalse;
       
  2307         }
       
  2308     }
       
  2309 
       
  2310 // <-------------------------- CONTEXT MENU ------------------------->
       
  2311 
       
  2312 // -----------------------------------------------------------------------------
       
  2313 // CPhoneState::SetContextMenu
       
  2314 // -----------------------------------------------------------------------------
       
  2315 //
       
  2316 EXPORT_C void CPhoneState::SetContextMenuL( TInt aResourceId )
       
  2317     {
       
  2318     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetContextMenuL() ");
       
  2319 
       
  2320     TPhoneCmdParamInteger integerParam;
       
  2321     TInt resId( CPhoneMainResourceResolver::Instance()->
       
  2322                             ResolveResourceID( aResourceId ) );
       
  2323     integerParam.SetInteger( resId );
       
  2324     __PHONELOG1( EBasic, EPhoneControl,
       
  2325                   "CPhoneState::SetContextMenuL : resId =%d",resId );
       
  2326 
       
  2327     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateContextMenu,
       
  2328                                       &integerParam );
       
  2329     }
       
  2330 // -----------------------------------------------------------------------------
       
  2331 // CPhoneState::UpdateInCallContextMenuL
       
  2332 // -----------------------------------------------------------------------------
       
  2333 //
       
  2334 EXPORT_C void CPhoneState::UpdateInCallContextMenuL()
       
  2335     {
       
  2336     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateInCallContextMenuL() ");
       
  2337 
       
  2338     SetContextMenuL( EPhoneNumberAcqMenubar );
       
  2339 
       
  2340     }
       
  2341 
       
  2342 // -----------------------------------------------------------------------------
       
  2343 // CPhoneState::UpdateIncomingContextMenuL
       
  2344 // -----------------------------------------------------------------------------
       
  2345 //
       
  2346 EXPORT_C void CPhoneState::UpdateIncomingContextMenuL( TInt aCallId )
       
  2347     {
       
  2348     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateIncomingContextMenuL() ");
       
  2349 
       
  2350     if( CPhoneState::IsVideoCall ( aCallId ) )
       
  2351         {
       
  2352         SetContextMenuL( EPhoneIncomingVideoCallMenubar );
       
  2353         }
       
  2354     else
       
  2355         {
       
  2356         SetContextMenuL( EPhoneIncomingCallMenubar );
       
  2357         }
       
  2358 
       
  2359     }
       
  2360 
       
  2361 // -----------------------------------------------------------
       
  2362 // CPhoneState::ShowNoteL
       
  2363 // -----------------------------------------------------------
       
  2364 //
       
  2365 EXPORT_C void CPhoneState::ShowNoteL( TInt aResourceId )
       
  2366     {
       
  2367     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::ShowNoteL( ) ");
       
  2368     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
  2369     TPhoneCmdParamNote noteParam;
       
  2370     noteParam.SetType( EPhoneNotePermanent );
       
  2371     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
  2372         ResolveResourceID( aResourceId ) );
       
  2373 
       
  2374     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
  2375     }
       
  2376 
       
  2377 // -----------------------------------------------------------
       
  2378 // CPhoneState::ShowQueryL
       
  2379 // -----------------------------------------------------------
       
  2380 //
       
  2381 EXPORT_C void CPhoneState::ShowQueryL( TInt aResourceId )
       
  2382     {
       
  2383     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::ShowQueryL( ) ");
       
  2384     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
  2385     TPhoneCmdParamQuery queryParam;
       
  2386     queryParam.SetQueryType( EPhoneQueryDialog );
       
  2387     queryParam.SetQueryResourceId( CPhoneMainResourceResolver::Instance()->
       
  2388         ResolveResourceID( aResourceId ) );
       
  2389 
       
  2390     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowQuery, &queryParam );
       
  2391     }
       
  2392 
       
  2393 // -----------------------------------------------------------
       
  2394 // CPhoneState::ShowTextQueryL
       
  2395 // -----------------------------------------------------------
       
  2396 //
       
  2397 EXPORT_C void CPhoneState::ShowTextQueryL(
       
  2398     TInt aDialogResourceId,
       
  2399     TInt aDefaultCbaResourceId,
       
  2400     TInt aContentCbaResourceId,
       
  2401     TDes* aDataText,
       
  2402     TBool aSendKeyEnabled )
       
  2403     {
       
  2404     __ASSERT_DEBUG( aDialogResourceId &&
       
  2405         aDefaultCbaResourceId &&
       
  2406         aContentCbaResourceId &&
       
  2407         aDataText,
       
  2408         Panic( EPhoneCtrlParameterNotInitialized ) );
       
  2409     TPhoneCmdParamQuery queryDialogParam;
       
  2410     queryDialogParam.SetQueryType( EPhoneTextQueryDialog );
       
  2411     queryDialogParam.SetQueryResourceId( aDialogResourceId );
       
  2412     queryDialogParam.SetDefaultCba( aDefaultCbaResourceId );
       
  2413     queryDialogParam.SetContentCba( aContentCbaResourceId );
       
  2414     queryDialogParam.SetDataText( aDataText );
       
  2415     queryDialogParam.SetSendKeyEnabled( aSendKeyEnabled );
       
  2416 
       
  2417     // Display dialog
       
  2418     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowQuery,
       
  2419         &queryDialogParam );
       
  2420     }
       
  2421 
       
  2422 // -----------------------------------------------------------
       
  2423 // CPhoneState::DisplayCallTerminationNoteL
       
  2424 // -----------------------------------------------------------
       
  2425 //
       
  2426 EXPORT_C void CPhoneState::DisplayCallTerminationNoteL()
       
  2427     {
       
  2428     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisplayCallTerminationNoteL( ) ");
       
  2429     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  2430         Panic( EPhoneCtrlInvariant ) );
       
  2431     if ( CheckIfShowCallTerminationNote() )
       
  2432         {
       
  2433         TBuf<KPhoneMaxCharsInNote> noteText;
       
  2434         TBuf<KPhoneMaxCharsInNote> postCallLineText;
       
  2435 
       
  2436         // Post call Line 1: Call Summary
       
  2437         LoadResource( postCallLineText, EPhoneNoteTextCallSummary );
       
  2438         noteText.Append( postCallLineText );
       
  2439         noteText.Append( KPhoneLineFeed );
       
  2440 
       
  2441         // Post call Line 2: Duration
       
  2442         LoadResource( postCallLineText, EPhoneNoteTextCallDuration );
       
  2443         noteText.Append( postCallLineText );
       
  2444         noteText.Append( KPhoneLineFeed );
       
  2445 
       
  2446         // Post call Line 3: Time, get the format for last call time.
       
  2447         LoadResource( postCallLineText, EPhoneCallDurationFormatString );
       
  2448         TPtrC durationFormat( postCallLineText );
       
  2449 
       
  2450         // Get the last call duration
       
  2451         TTime time( 0 );
       
  2452         TTimeIntervalSeconds timeInterval =
       
  2453             iStateMachine->PhoneEngineInfo()->CallDuration();
       
  2454         time += timeInterval;
       
  2455 
       
  2456         // Format the time
       
  2457         TBuf<KPhoneMaxTimeDisplayTextLength> timeString( KNullDesC );
       
  2458         time.FormatL( timeString, durationFormat );
       
  2459 
       
  2460         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString );
       
  2461 
       
  2462         noteText.Append( timeString );
       
  2463 
       
  2464         TPhoneCmdParamGlobalNote globalNoteParam;
       
  2465         globalNoteParam.SetType( EAknGlobalInformationNote );
       
  2466         globalNoteParam.SetText( noteText );
       
  2467         globalNoteParam.SetTone( CAknNoteDialog::ENoTone );
       
  2468         iViewCommandHandle->ExecuteCommandL(
       
  2469             EPhoneViewShowGlobalNote, &globalNoteParam );
       
  2470         }
       
  2471     }
       
  2472 
       
  2473 // ---------------------------------------------------------
       
  2474 // CPhoneState::SendGlobalInfoNoteL
       
  2475 // ---------------------------------------------------------
       
  2476 //
       
  2477 EXPORT_C void CPhoneState::SendGlobalInfoNoteL( TInt aResourceId )
       
  2478     {
       
  2479     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalInfoNoteL( ) ");
       
  2480     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
  2481     if ( CPhonePubSubProxy::Instance()->Value(
       
  2482             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
       
  2483         {
       
  2484         // Re-enable global notes
       
  2485         TPhoneCmdParamBoolean globalNotifierParam;
       
  2486         globalNotifierParam.SetBoolean( EFalse );
       
  2487         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
  2488             &globalNotifierParam );
       
  2489 
       
  2490         TPhoneCmdParamGlobalNote globalNoteParam;
       
  2491 
       
  2492         globalNoteParam.SetType( EAknGlobalInformationNote );
       
  2493         globalNoteParam.SetTextResourceId(
       
  2494             CPhoneMainResourceResolver::Instance()->
       
  2495             ResolveResourceID( aResourceId ) );
       
  2496         globalNoteParam.SetTone( EAvkonSIDInformationTone );
       
  2497 
       
  2498         iViewCommandHandle->ExecuteCommandL(
       
  2499             EPhoneViewShowGlobalNote, &globalNoteParam );
       
  2500         }
       
  2501     }
       
  2502 
       
  2503 // ---------------------------------------------------------
       
  2504 //  CPhoneUIController::SendGlobalWarningNoteL
       
  2505 // ---------------------------------------------------------
       
  2506 //
       
  2507 EXPORT_C void CPhoneState::SendGlobalWarningNoteL( TInt aResourceId )
       
  2508     {
       
  2509     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalWarningNoteL( ) ");
       
  2510     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
  2511     if ( CPhonePubSubProxy::Instance()->Value(
       
  2512             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 ||
       
  2513             SimState() == EPESimReadable )
       
  2514         {
       
  2515         // Re-enable global notes
       
  2516         TPhoneCmdParamBoolean globalNotifierParam;
       
  2517         globalNotifierParam.SetBoolean( EFalse );
       
  2518         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
  2519             &globalNotifierParam );
       
  2520 
       
  2521         TPhoneCmdParamGlobalNote globalNoteParam;
       
  2522         globalNoteParam.SetType( EAknGlobalWarningNote );
       
  2523         globalNoteParam.SetTextResourceId(
       
  2524             CPhoneMainResourceResolver::Instance()->
       
  2525             ResolveResourceID( aResourceId ) );
       
  2526         globalNoteParam.SetTone( EAvkonSIDWarningTone );
       
  2527 
       
  2528         iViewCommandHandle->ExecuteCommandL(
       
  2529             EPhoneViewShowGlobalNote, &globalNoteParam );
       
  2530         }
       
  2531     }
       
  2532 
       
  2533 // ---------------------------------------------------------
       
  2534 //  CPhoneUIController::SendGlobalErrorNoteL
       
  2535 // ---------------------------------------------------------
       
  2536 //
       
  2537 EXPORT_C void CPhoneState::SendGlobalErrorNoteL( TInt aResourceId )
       
  2538     {
       
  2539     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SendGlobalErrorNoteL( ) ");
       
  2540     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
  2541     if ( CPhonePubSubProxy::Instance()->Value(
       
  2542             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
       
  2543         {
       
  2544         // Re-enable global notes
       
  2545         TPhoneCmdParamBoolean globalNotifierParam;
       
  2546         globalNotifierParam.SetBoolean( EFalse );
       
  2547         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
  2548             &globalNotifierParam );
       
  2549 
       
  2550         TPhoneCmdParamGlobalNote globalNoteParam;
       
  2551         globalNoteParam.SetType( EAknGlobalErrorNote );
       
  2552         globalNoteParam.SetTextResourceId(
       
  2553             CPhoneMainResourceResolver::Instance()->
       
  2554             ResolveResourceID( aResourceId ) );
       
  2555         globalNoteParam.SetTone( CAknNoteDialog::EErrorTone );
       
  2556 
       
  2557         iViewCommandHandle->ExecuteCommandL(
       
  2558             EPhoneViewShowGlobalNote, &globalNoteParam );
       
  2559         }
       
  2560     }
       
  2561 
       
  2562 // ---------------------------------------------------------
       
  2563 // CPhoneState::SetHandsfreeModeL
       
  2564 // ---------------------------------------------------------
       
  2565 //
       
  2566 EXPORT_C void CPhoneState::SetHandsfreeModeL( TBool aHandsfreeMode )
       
  2567     {
       
  2568     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetHandsfreeModeL( ) ");
       
  2569     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
       
  2570         iViewCommandHandle, iStateMachine, this );
       
  2571     if ( !bt->SetHandsfreeModeL( aHandsfreeMode ))
       
  2572         {
       
  2573         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
       
  2574         }
       
  2575     CleanupStack::PopAndDestroy( bt );
       
  2576     }
       
  2577 
       
  2578 // ---------------------------------------------------------
       
  2579 // CPhoneState::SetBTHandsfreeModeL
       
  2580 // ---------------------------------------------------------
       
  2581 //
       
  2582 EXPORT_C void CPhoneState::SetBTHandsfreeModeL( TBool aHandsfreeMode )
       
  2583     {
       
  2584     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetBTHandsfreeModeL( ) ");
       
  2585     CPhoneAccessoryBTHandler* bt = CPhoneAccessoryBTHandler::NewLC(
       
  2586         iViewCommandHandle, iStateMachine, this );
       
  2587     if ( !bt->SetBTHandsfreeModeL( aHandsfreeMode ))
       
  2588         {
       
  2589         SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
       
  2590         }
       
  2591     CleanupStack::PopAndDestroy( bt );
       
  2592     }
       
  2593 
       
  2594 // <-------------------------- INTERNAL FUNCTIONS ------------------------>
       
  2595 
       
  2596 // -----------------------------------------------------------
       
  2597 // CPhoneState::UpdateIncallIndicatorL
       
  2598 // -----------------------------------------------------------
       
  2599 //
       
  2600 void CPhoneState::UpdateIncallIndicatorL( TInt aCallState )
       
  2601     {
       
  2602     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateIncallIndicatorL( ) ");
       
  2603     TPhoneCmdParamIncallIndicatorData incallIndicatorParam;
       
  2604 
       
  2605     // Set the state
       
  2606     incallIndicatorParam.SetCallState( aCallState );
       
  2607 
       
  2608     // Set mode
       
  2609     incallIndicatorParam.SetMode(
       
  2610        CPhonePubSubProxy::Instance()->Value(
       
  2611             KPSUidCtsyCallInformation,
       
  2612             KCTsyCallType ) );
       
  2613 
       
  2614     TInt activeCallId = GetActiveCallIdL();
       
  2615     if ( activeCallId > KErrNotFound )
       
  2616         {
       
  2617         if ( iStateMachine->PhoneEngineInfo()->CallALSLine( activeCallId )
       
  2618              == CCCECallParameters::ECCELineTypeAux )
       
  2619             {
       
  2620             incallIndicatorParam.SetLine2( ETrue );
       
  2621             }
       
  2622         }
       
  2623 
       
  2624     // Set the mute status
       
  2625     const TBool audioMute = iStateMachine->PhoneEngineInfo()->AudioMute();
       
  2626     incallIndicatorParam.SetMute( audioMute );
       
  2627 
       
  2628     // Set the voice privacy status
       
  2629     if ( activeCallId > KErrNotFound &&
       
  2630          activeCallId != KConferenceCallId  )
       
  2631         {
       
  2632         incallIndicatorParam.SetCiphering(
       
  2633             iStateMachine->PhoneEngineInfo()->IsSecureCall( activeCallId ) );
       
  2634         }
       
  2635     else
       
  2636         {
       
  2637         incallIndicatorParam.SetCiphering( ETrue );
       
  2638         }
       
  2639 
       
  2640     incallIndicatorParam.SetCipheringIndicatorAllowed(
       
  2641         iStateMachine->PhoneEngineInfo()->SecureSpecified() );
       
  2642 
       
  2643     // Set the emergency status
       
  2644     if( EPEStateIdle != iStateMachine->PhoneEngineInfo()->CallState( KPEEmergencyCallId ) )
       
  2645         {
       
  2646         incallIndicatorParam.SetEmergency( ETrue );
       
  2647         }
       
  2648 
       
  2649     if( aCallState == EPSCTsyCallStateDisconnecting )
       
  2650         {
       
  2651         if ( TopAppIsDisplayedL() )
       
  2652             {
       
  2653             if ( ( !IsOnScreenDialerSupported() ) ||
       
  2654                  ( IsOnScreenDialerSupported() && !IsNumberEntryVisibleL() ) )
       
  2655                 {
       
  2656                 // Phone application is in the foreground so we don't need to
       
  2657                 // display the little bubble. If we don't hide it here then
       
  2658                 // it will appear for a short time. We don't want that.
       
  2659                 incallIndicatorParam.SetLittleBubbleVisible( EFalse );
       
  2660                 }
       
  2661             }
       
  2662         }
       
  2663 
       
  2664     // Update the in-call indicator
       
  2665     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateIncallIndicator,
       
  2666         &incallIndicatorParam );
       
  2667     }
       
  2668 
       
  2669 // -----------------------------------------------------------
       
  2670 // CPhoneState::UpdateProfileDisplayL
       
  2671 // -----------------------------------------------------------
       
  2672 //
       
  2673 void CPhoneState::UpdateProfileDisplayL()
       
  2674     {
       
  2675     }
       
  2676 
       
  2677 // -----------------------------------------------------------
       
  2678 // CPhoneState::UpdateOperatorDisplayL
       
  2679 // -----------------------------------------------------------
       
  2680 //
       
  2681 void CPhoneState::UpdateOperatorDisplayL()
       
  2682     {
       
  2683     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::UpdateOperatorDisplayL( ) ");
       
  2684     __PHONELOG( EBasic, EPhoneControl, "CPhoneState::UpdateOperatorDisplayL" );
       
  2685     // Get current title pane content.
       
  2686     TTelTitleDisplay titleContent;
       
  2687     titleContent.iDisplayTag.Zero();
       
  2688     titleContent.iLogoHandle = 0;
       
  2689     TPckg<TTelTitleDisplay> titlePckg( titleContent );
       
  2690 
       
  2691     RProperty::Get(
       
  2692         KPSUidTelInformation,
       
  2693         KTelDisplayInfo,
       
  2694         titlePckg );
       
  2695 
       
  2696     if ( TitlePaneIsVisibleL() )
       
  2697         {
       
  2698         // There is a title pane icon.
       
  2699         if ( titleContent.iLogoHandle != 0 )
       
  2700             {
       
  2701             // Set new logo.
       
  2702             __PHONELOG( EBasic, EPhoneControl,
       
  2703                 "CPhoneState::UpdateOperatorDisplayL - logo found" );
       
  2704 
       
  2705             if( iLogoHandle != titleContent.iLogoHandle )
       
  2706                 {
       
  2707                  __PHONELOG( EBasic, EPhoneControl,
       
  2708                   "CPhoneState::UpdateOperatorDisplayL - set new logo" );
       
  2709 
       
  2710                  TPhoneCmdParamBitmap bitmapParam;
       
  2711 
       
  2712                  // Duplicate bitmap from handle.
       
  2713                  CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
  2714                  CleanupStack::PushL( bitmap );
       
  2715                  User::LeaveIfError(
       
  2716                          bitmap->Duplicate( titleContent.iLogoHandle ) );
       
  2717                  bitmapParam.SetBitmap( bitmap );
       
  2718 
       
  2719                  // Duplicate and set bitmap mask if needed
       
  2720                  CFbsBitmap* maskBitmap = NULL;
       
  2721                  if( titleContent.iLogoMaskHandle != 0 )
       
  2722                      {
       
  2723                      maskBitmap = new( ELeave )CFbsBitmap;
       
  2724                      CleanupStack::PushL( maskBitmap );
       
  2725                      User::LeaveIfError( maskBitmap->Duplicate(
       
  2726                              titleContent.iLogoMaskHandle ) );
       
  2727                      bitmapParam.SetMaskBitmap( maskBitmap );
       
  2728                      }
       
  2729 
       
  2730                  iViewCommandHandle->ExecuteCommandL(
       
  2731                          EPhoneViewSetTitlePanePicture,
       
  2732                          &bitmapParam );
       
  2733 
       
  2734                  // The title pane takes ownership of the bitmaps so no need
       
  2735                  // to destroy it here.
       
  2736                  if( maskBitmap )
       
  2737                      {
       
  2738                      // Pop maskBitmap only, if it has been created
       
  2739                      CleanupStack::Pop( maskBitmap );
       
  2740                      }
       
  2741                  CleanupStack::Pop( bitmap );
       
  2742                 }
       
  2743             }
       
  2744         else
       
  2745             {
       
  2746             __PHONELOG1( EBasic, EPhoneControl,
       
  2747             "CPhoneState::UpdateOperatorDisplayL - set text=%S", &titleContent.iDisplayTag );
       
  2748             iLogoHandle = titleContent.iLogoHandle;
       
  2749 
       
  2750             iViewCommandHandle->ExecuteCommandL(
       
  2751                 EPhoneViewSetTitlePaneContent,
       
  2752                 0,
       
  2753                 titleContent.iDisplayTag );
       
  2754             }
       
  2755         }
       
  2756 
       
  2757     // Check background image.
       
  2758     TPhoneCmdParamBitmap savedBitmapParam;
       
  2759     iViewCommandHandle->ExecuteCommandL(
       
  2760         EPhoneViewGetBackgroundImageBitmap,
       
  2761         &savedBitmapParam );
       
  2762 
       
  2763     if ( titleContent.iBackgroundImageHandle !=
       
  2764         savedBitmapParam.Bitmap()->Handle() )
       
  2765         {
       
  2766         __PHONELOG2( EBasic, EPhoneControl,
       
  2767         "CPhoneState::UpdateOperatorDisplayL - update background image since different titleContent(%d), saved(%d)",
       
  2768             titleContent.iBackgroundImageHandle, savedBitmapParam.Bitmap()->Handle() );
       
  2769         // Background image has changed. Duplicate bitmap from handle if
       
  2770         // available; otherwise reset the background image
       
  2771         CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
  2772         CleanupStack::PushL( bitmap );
       
  2773         TInt err = KErrNone;
       
  2774         if ( titleContent.iBackgroundImageHandle != 0 )
       
  2775             {
       
  2776             err = bitmap->Duplicate( titleContent.iBackgroundImageHandle );
       
  2777             }
       
  2778         else
       
  2779             {
       
  2780             bitmap->Reset();
       
  2781             }
       
  2782 
       
  2783         if ( err == KErrNone )
       
  2784             {
       
  2785             iBitmapRedrawCounter = titleContent.iBackgroundImageRedrawCounter;
       
  2786             TPhoneCmdParamBitmap bitmapParam;
       
  2787             bitmapParam.SetBitmap( bitmap );
       
  2788             iViewCommandHandle->ExecuteCommandL(
       
  2789                 EPhoneViewSetBackgroundImageBitmap,
       
  2790                 &bitmapParam );
       
  2791             }
       
  2792 
       
  2793         CleanupStack::PopAndDestroy( bitmap );
       
  2794         }
       
  2795     else if ( titleContent.iBackgroundImageRedrawCounter !=
       
  2796                   iBitmapRedrawCounter  )
       
  2797         {
       
  2798         iBitmapRedrawCounter = titleContent.iBackgroundImageRedrawCounter;
       
  2799         iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateView );
       
  2800         }
       
  2801     }
       
  2802 
       
  2803 // -----------------------------------------------------------
       
  2804 // CPhoneState::HandleInitiatedEmergencyCallL
       
  2805 // Default handling for EPEMessageInitiatedEmergencyCallL message
       
  2806 // (other items were commented in a header).
       
  2807 // -----------------------------------------------------------
       
  2808 //
       
  2809 void CPhoneState::HandleInitiatedEmergencyCallL( TInt /*aCallId*/ )
       
  2810     {
       
  2811     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleInitiatedEmergencyCallL( ) ");
       
  2812 
       
  2813     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  2814 
       
  2815     // Stop tone playing, if necessary
       
  2816     iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
  2817 
       
  2818     // Reset Hold flag to view
       
  2819     TPhoneCmdParamBoolean holdFlag;
       
  2820     holdFlag.SetBoolean( EFalse );
       
  2821     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
  2822 
       
  2823     // Undim Answer button for sure.
       
  2824     SetTouchPaneButtonEnabled( EPhoneCallComingCmdAnswer );
       
  2825 
       
  2826     // Go to emergency call state
       
  2827     // No need update cba
       
  2828     iStateMachine->ChangeState( EPhoneStateEmergency );
       
  2829     }
       
  2830 
       
  2831 // -----------------------------------------------------------
       
  2832 // CPhoneState::HandleInitiatedEmergencyWhileActiveVideoL
       
  2833 // -----------------------------------------------------------
       
  2834 //
       
  2835 void CPhoneState::HandleInitiatedEmergencyWhileActiveVideoL()
       
  2836     {
       
  2837     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleInitiatedEmergencyWhileActiveVideoL( ) ");
       
  2838 
       
  2839     // We have existing video call so need to release dataport before continuing
       
  2840     // emergency call. Otherwise we will face problems with dataport use later.
       
  2841     CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
       
  2842                                                                      KCatPhoneToVideotelCommands,
       
  2843                                                                      EVtCmdReleaseDataport,
       
  2844                                                                TVersion( KPhoneToVideotelCmdVersionMajor,
       
  2845                                                                          KPhoneToVideotelCmdVersionMinor,
       
  2846                                                                          KPhoneToVideotelCmdVersionBuild ),
       
  2847                                                                KNullDesC8,
       
  2848                                                                CPhoneContinueEmergencyCallCommand::NewL( *iStateMachine ) );
       
  2849     }
       
  2850 
       
  2851 // -----------------------------------------------------------
       
  2852 // CPhoneState::HandleShowImeiL
       
  2853 // -----------------------------------------------------------
       
  2854 //
       
  2855 void CPhoneState::HandleShowImeiL()
       
  2856     {
       
  2857     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleShowImeiL( ) ");
       
  2858     
       
  2859     // Fetch IMEI
       
  2860     TBuf<RMobilePhone::KPhoneSerialNumberSize> serialNumber;
       
  2861     TPEPhoneIdentityParameters phoneIdentityParameters = 
       
  2862         iStateMachine->PhoneEngineInfo()->PhoneIdentityParameters();
       
  2863     serialNumber = phoneIdentityParameters.iSerialNumber;
       
  2864     
       
  2865     HBufC* imeiNoteText = StringLoader::LoadLC(
       
  2866         CPhoneMainResourceResolver::Instance()->
       
  2867         ResolveResourceID(
       
  2868         EPhonePhoneImeiString ), serialNumber );
       
  2869     
       
  2870     TPhoneCmdParamGlobalNote noteParam;
       
  2871     noteParam.SetType( EAknGlobalInformationNote );
       
  2872     noteParam.SetTone( EAvkonSIDInformationTone );
       
  2873     noteParam.SetText( *imeiNoteText );
       
  2874     noteParam.SetTimeout( KPhoneNoteNoTimeout );
       
  2875     
       
  2876     iViewCommandHandle->ExecuteCommandL( 
       
  2877         EPhoneViewShowGlobalNote, 
       
  2878         &noteParam );
       
  2879     
       
  2880     CleanupStack::PopAndDestroy( imeiNoteText );
       
  2881     }
       
  2882 
       
  2883 // -----------------------------------------------------------
       
  2884 // CPhoneState::HandleCallSecureStatusChangeL
       
  2885 // -----------------------------------------------------------
       
  2886 //
       
  2887 void CPhoneState::HandleCallSecureStatusChangeL( TInt aCallId )
       
  2888     {
       
  2889     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCallSecureStatusChangeL( ) ");
       
  2890 
       
  2891     TBool ciphering( ETrue );
       
  2892     TBool secureSpecified( ETrue );
       
  2893 
       
  2894     if ( aCallId > KErrNotFound )
       
  2895         {
       
  2896         ciphering = iStateMachine->PhoneEngineInfo()->IsSecureCall( aCallId );
       
  2897         secureSpecified = iStateMachine->PhoneEngineInfo()->SecureSpecified();
       
  2898         }
       
  2899 
       
  2900     TPhoneCmdParamCallHeaderData callHeaderParam;
       
  2901 
       
  2902     callHeaderParam.SetCiphering( ciphering );
       
  2903     callHeaderParam.SetCipheringIndicatorAllowed( secureSpecified );
       
  2904 
       
  2905     iViewCommandHandle->ExecuteCommandL(
       
  2906         EPhoneViewCipheringInfoChange,
       
  2907         aCallId,
       
  2908         &callHeaderParam );
       
  2909     }
       
  2910 
       
  2911 // -----------------------------------------------------------
       
  2912 // CPhoneState::HandleShowLifeTimerL
       
  2913 // -----------------------------------------------------------
       
  2914 //
       
  2915 void CPhoneState::HandleShowLifeTimerL()
       
  2916    {
       
  2917     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleShowLifeTimerL( ) ");
       
  2918     
       
  2919     // Fetch LifeTime
       
  2920     TPELifeTimeData lifeTimeData = 
       
  2921         iStateMachine->PhoneEngineInfo()->LifeTimerData();
       
  2922     
       
  2923     TLocale locale;
       
  2924     TBuf<KTimerTextLength> lifetimerText;
       
  2925     lifetimerText.NumFixedWidth(
       
  2926         lifeTimeData.iHours,
       
  2927         EDecimal,
       
  2928         KPhoneLifeTimerHoursLength );
       
  2929     
       
  2930     lifetimerText.Append(locale.TimeSeparator( KTimerMinuteSeparator ) );
       
  2931     
       
  2932     TBuf<KPhoneLifeTimerMinutesLength> mins;
       
  2933     mins.NumFixedWidth(
       
  2934         lifeTimeData.iMinutes,
       
  2935         EDecimal,
       
  2936         KPhoneLifeTimerMinutesLength );
       
  2937     
       
  2938     lifetimerText.Append(mins);
       
  2939     
       
  2940     HBufC* buf = StringLoader::LoadLC(
       
  2941         CPhoneMainResourceResolver::Instance()->
       
  2942         ResolveResourceID(
       
  2943         EPhoneLifeTimeFormat ), lifetimerText );
       
  2944     
       
  2945     TPhoneCmdParamGlobalNote noteParam;
       
  2946     noteParam.SetType( EAknGlobalInformationNote );
       
  2947     noteParam.SetTone( EAvkonSIDInformationTone );
       
  2948     noteParam.SetText( *buf );
       
  2949     noteParam.SetTimeout( KPhoneNoteNoTimeout );
       
  2950     
       
  2951     iViewCommandHandle->ExecuteCommandL( 
       
  2952         EPhoneViewShowGlobalNote, 
       
  2953         &noteParam );
       
  2954     
       
  2955     CleanupStack::PopAndDestroy( buf );
       
  2956     }
       
  2957 
       
  2958 // ---------------------------------------------------------
       
  2959 // CPhoneState::IsVideoCall
       
  2960 // ---------------------------------------------------------
       
  2961 //
       
  2962 EXPORT_C TBool CPhoneState::IsVideoCall( const TInt aCallId )
       
  2963     {
       
  2964     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsVideoCall( ) ");
       
  2965     TBool isVideoCall( EFalse );
       
  2966     TRAP_IGNORE( isVideoCall = CallheaderManagerL()->IsVideoCall( aCallId ) );
       
  2967     __PHONELOG1( EBasic, EPhoneControl, 
       
  2968         "CPhoneState::IsVideoCall isVideoCall(%d)",
       
  2969         isVideoCall );
       
  2970     return isVideoCall;
       
  2971     }
       
  2972 
       
  2973 // ---------------------------------------------------------
       
  2974 // CPhoneState::ChangeAlsLineL
       
  2975 // ---------------------------------------------------------
       
  2976 //
       
  2977 void CPhoneState::ChangeAlsLineL()
       
  2978     {
       
  2979     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::ChangeAlsLineL( ) ");
       
  2980 
       
  2981     if ( !IsOnScreenDialerSupported() )
       
  2982         {
       
  2983         // Do state-specific operation when number entry is cleared
       
  2984         HandleNumberEntryClearedL();
       
  2985         }
       
  2986 
       
  2987     CCCECallParameters::TCCELineType currentLine;
       
  2988     TSSSettingsAlsValue newLine( ESSSettingsAlsPrimary );
       
  2989 
       
  2990     currentLine = iStateMachine->PhoneEngineInfo()->ALSLine();
       
  2991 
       
  2992     if ( currentLine == CCCECallParameters::ECCELineTypePrimary )
       
  2993         {
       
  2994         newLine = ESSSettingsAlsAlternate;
       
  2995         }
       
  2996     else if ( currentLine == CCCECallParameters::ECCELineTypeAux )
       
  2997         {
       
  2998         newLine = ESSSettingsAlsPrimary;
       
  2999         }
       
  3000 
       
  3001     RSSSettings ssSettings;
       
  3002     TInt retValue = ssSettings.Open();
       
  3003     __PHONELOG1( EBasic, EPhoneControl,
       
  3004             "CPhoneState::ChangeAlsLineL : Open %d", retValue );
       
  3005     if ( retValue == KErrNone )
       
  3006         {
       
  3007         retValue = ssSettings.Set( ESSSettingsAls, newLine );
       
  3008         __PHONELOG1( EBasic, EPhoneControl,
       
  3009             "CPhoneState::ChangeAlsLineL : Set %d", retValue );
       
  3010         ssSettings.Close();
       
  3011         }
       
  3012     }
       
  3013 
       
  3014 // ---------------------------------------------------------
       
  3015 // CPhoneState::GetActiveCallIdL()
       
  3016 // ---------------------------------------------------------
       
  3017 //
       
  3018 TInt CPhoneState::GetActiveCallIdL()
       
  3019     {
       
  3020     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::GetActiveCallId()( ) ");
       
  3021 
       
  3022     // Fetch active call's id from view
       
  3023     TPhoneViewResponseId response;
       
  3024     TPhoneCmdParamCallStateData callStateData;
       
  3025     callStateData.SetCallState( EPEStateConnected );
       
  3026     response = iViewCommandHandle->HandleCommandL(
       
  3027         EPhoneViewGetCallIdByState, &callStateData );
       
  3028 
       
  3029     if ( response == EPhoneViewResponseSuccess &&
       
  3030          callStateData.CallId() < 0 )  // no connected calls
       
  3031         {
       
  3032         // check for held call
       
  3033         callStateData.SetCallState( EPEStateHeld );
       
  3034         response = iViewCommandHandle->HandleCommandL(
       
  3035             EPhoneViewGetCallIdByState, &callStateData );
       
  3036         }
       
  3037 
       
  3038     return callStateData.CallId();
       
  3039     }
       
  3040 
       
  3041 // ---------------------------------------------------------
       
  3042 // CPhoneState::SimState()
       
  3043 // ---------------------------------------------------------
       
  3044 //
       
  3045 EXPORT_C TPESimState CPhoneState::SimState() const
       
  3046     {
       
  3047 
       
  3048     /*
       
  3049     SIM states:
       
  3050 
       
  3051     EPESimStatusUninitialized = KPEStartupEnumerationFirstValue =100,
       
  3052     EPESimUsable,       // The Sim card is fully usable.
       
  3053     EPESimReadable,     // The SIM card is not fully usable, but the emergency number can be read.
       
  3054     EPESimNotReady,     // The Sim card is present but not ready or usable.
       
  3055     EPESimNotPresent,   // The Sim card is not present.
       
  3056     EPESimNotSupported  // SIM/RUIM is not supported. Some CDMA phones do not support a SIM/RUIM at all.
       
  3057     */
       
  3058     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SimState()");
       
  3059     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  3060         Panic( EPhoneCtrlInvariant ) );
       
  3061     TPESimState simState = iStateMachine->PhoneEngineInfo()->SimState();
       
  3062 
       
  3063     __PHONELOG1( EBasic, EPhoneControl,
       
  3064             "CPhoneState::SimState - value= %d", simState );
       
  3065     return simState;
       
  3066     }
       
  3067 
       
  3068 // ---------------------------------------------------------
       
  3069 // CPhoneState::IsSimOk()
       
  3070 // ---------------------------------------------------------
       
  3071 //
       
  3072 EXPORT_C TBool CPhoneState::IsSimOk()
       
  3073     {
       
  3074 
       
  3075     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsSimOk()");
       
  3076     // Phone is interested on Sim state and sim security statuses
       
  3077     // Check first Sim state status:
       
  3078     TBool retVal( ETrue );
       
  3079     switch ( SimState() )
       
  3080         {
       
  3081         case EPESimNotSupported:
       
  3082             retVal = EFalse;
       
  3083             break;
       
  3084 
       
  3085         case EPESimNotPresent:
       
  3086             {
       
  3087             if ( !FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) ||
       
  3088                  !FeatureManager::FeatureSupported( KFeatureIdFfSimlessOfflineSupport ) )
       
  3089                 {
       
  3090                 retVal = EFalse;
       
  3091                 }
       
  3092             break;
       
  3093             }
       
  3094 
       
  3095         default:
       
  3096             break;
       
  3097         }
       
  3098     if ( retVal != EFalse )
       
  3099         {
       
  3100         // Sim state is valid, check also Sim security status
       
  3101         switch ( SimSecurityStatus() )
       
  3102             {
       
  3103             case ESimRejected:
       
  3104             case ESimUnaccepted:
       
  3105                 retVal = EFalse;
       
  3106                 break;
       
  3107 
       
  3108             default:
       
  3109                 break;
       
  3110             }
       
  3111         }
       
  3112     __PHONELOG1( EBasic, EPhoneControl,
       
  3113             "CPhoneState::IsSimOK - value= %d", retVal );
       
  3114     return retVal;
       
  3115     }
       
  3116 
       
  3117 // -----------------------------------------------------------
       
  3118 // CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled
       
  3119 // -----------------------------------------------------------
       
  3120 //
       
  3121 EXPORT_C TBool CPhoneState::IsSimStateNotPresentWithSecurityModeEnabled()
       
  3122     {
       
  3123     TPhoneCmdParamBoolean isSecurityMode;
       
  3124     TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode ) );
       
  3125     if ( SimState() == EPESimNotPresent && isSecurityMode.Boolean() )
       
  3126         {
       
  3127         return ETrue;
       
  3128         }
       
  3129     else
       
  3130         {
       
  3131         return EFalse;
       
  3132         }
       
  3133     }
       
  3134 
       
  3135 // ---------------------------------------------------------
       
  3136 // CPhoneState::SetDivertIndication
       
  3137 // ---------------------------------------------------------
       
  3138 //
       
  3139 EXPORT_C void CPhoneState::SetDivertIndication( const TBool aDivertIndication )
       
  3140     {
       
  3141     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::SetDivertIndication()");
       
  3142     TRAP_IGNORE( CallheaderManagerL()->SetDivertIndication( aDivertIndication ) );
       
  3143     }
       
  3144 
       
  3145 // ---------------------------------------------------------
       
  3146 // CPhoneState::StartAlsLineChangeTimerL
       
  3147 // ---------------------------------------------------------
       
  3148 //
       
  3149 EXPORT_C void CPhoneState::StartAlsLineChangeTimerL()
       
  3150     {
       
  3151     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::StartAlsLineChangeTimerL()");
       
  3152     TBool alsLineAvailable = iStateMachine->PhoneEngineInfo()->ALSLineSupport();
       
  3153 
       
  3154     if( alsLineAvailable )
       
  3155         {
       
  3156         if( !iAlsLineChangeKeyPressTimer )
       
  3157             {
       
  3158             iAlsLineChangeKeyPressTimer = CPhoneTimer::NewL();
       
  3159             }
       
  3160 
       
  3161         iAlsLineChangeKeyPressTimer->After( KAlsLineChangeTimerValue,
       
  3162             TCallBack( AlsLineChangeTimerCallbackL, this ) );
       
  3163         }
       
  3164     else
       
  3165         {
       
  3166          // Don't bother launching the timer. ALS not supported.
       
  3167         __PHONELOG( EBasic, EPhoneControl,
       
  3168             "CPhoneState::StartAlsLineChangeTimerL - ALS not supported " );
       
  3169         }
       
  3170     }
       
  3171 
       
  3172 // -----------------------------------------------------------------------------
       
  3173 // CPhoneState::StartShowSecurityNoteL
       
  3174 // -----------------------------------------------------------------------------
       
  3175 //
       
  3176 EXPORT_C void CPhoneState::StartShowSecurityNoteL()
       
  3177     {
       
  3178     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::StartShowSecurityNoteL ");
       
  3179 
       
  3180     // Set security mode on.
       
  3181     TPhoneCmdParamBoolean securityMode;
       
  3182     securityMode.SetBoolean( ETrue );
       
  3183     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSecurityMode, &securityMode );
       
  3184 
       
  3185     // Remove number entry from screen
       
  3186     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  3187 
       
  3188     TPhoneCmdParamBoolean visibleMode;
       
  3189     visibleMode.SetBoolean( EFalse );
       
  3190     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetStatusPaneVisible, &visibleMode );
       
  3191     
       
  3192     iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
       
  3193 
       
  3194     TPhoneCmdParamInteger uidParam;
       
  3195     // Bring Phone app in the foreground
       
  3196     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
  3197     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
  3198         &uidParam );
       
  3199 
       
  3200     // Set Phone as the top application
       
  3201     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
  3202         &uidParam );
       
  3203 
       
  3204     TInt resourceId ( KErrNone );
       
  3205 
       
  3206     if ( SimSecurityStatus() == ESimRejected )
       
  3207         {
       
  3208         resourceId = CPhoneMainResourceResolver::Instance()->
       
  3209             ResolveResourceID( EPhoneSimRejected );
       
  3210         }
       
  3211     else if ( SimState() == EPESimNotPresent )
       
  3212         {
       
  3213         // insert sim card -note
       
  3214         resourceId = CPhoneMainResourceResolver::Instance()->
       
  3215             ResolveResourceID( EPhoneSimRemoved );
       
  3216         }
       
  3217     else if ( SimSecurityStatus() == ESimUnaccepted )
       
  3218         {
       
  3219         resourceId = CPhoneMainResourceResolver::Instance()->
       
  3220             ResolveResourceID( EPhoneSimUnaccepted );
       
  3221         }
       
  3222 
       
  3223     if ( resourceId != KErrNone )
       
  3224         {
       
  3225         // Add it to the resource string
       
  3226         HBufC* buf = StringLoader::LoadLC( resourceId );
       
  3227 
       
  3228         TPhoneCmdParamNote noteParam;
       
  3229 
       
  3230         noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
  3231            ResolveResourceID( EPhoneSecurityInformationNote ) );
       
  3232 
       
  3233         noteParam.SetText( *buf );
       
  3234         noteParam.SetTone( CAknNoteDialog::EConfirmationTone );
       
  3235         noteParam.SetType( EPhoneNoteSecurity );
       
  3236         // Display note
       
  3237         iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
  3238 
       
  3239         CleanupStack::PopAndDestroy( buf );
       
  3240            
       
  3241            
       
  3242         // Capture the App key
       
  3243         TPhoneCmdParamKeyCapture appKeyCaptureParam;
       
  3244         appKeyCaptureParam.SetKey( EStdKeyApplication0 );
       
  3245         appKeyCaptureParam.SetKeyCode( EKeyApplication0 );
       
  3246         appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
  3247         iViewCommandHandle->ExecuteCommandL( 
       
  3248                EPhoneViewStartCapturingKey, &appKeyCaptureParam );
       
  3249         }
       
  3250     }
       
  3251 
       
  3252 // ---------------------------------------------------------
       
  3253 // CPhoneState::AlsLineChangeTimerCallbackL
       
  3254 // ---------------------------------------------------------
       
  3255 //
       
  3256 TInt CPhoneState::AlsLineChangeTimerCallbackL( TAny* aAny )
       
  3257     {
       
  3258     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::AlsLineChangeTimerCallbackL()");
       
  3259 
       
  3260     // Send a key up event for stopping keypad tone
       
  3261     reinterpret_cast<CPhoneState*>( aAny )->
       
  3262         iStateMachine->SendPhoneEngineMessage(
       
  3263         MPEPhoneModel::EPEMessageEndDTMF );
       
  3264 
       
  3265     if ( !( reinterpret_cast<CPhoneState*>( aAny )->
       
  3266             IsOnScreenDialerSupported() ) )
       
  3267         {
       
  3268         // If dialer is undefined remove the number entry.
       
  3269         reinterpret_cast<CPhoneState*>( aAny )->
       
  3270             iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  3271         }
       
  3272     else
       
  3273         {
       
  3274         // If on screen dialer is in use just clear entry
       
  3275         // do not remove dialer.
       
  3276         reinterpret_cast<CPhoneState*>( aAny )->
       
  3277             NumberEntryClearL();
       
  3278         }
       
  3279 
       
  3280     // Show the als line changing confirmation query
       
  3281     reinterpret_cast<CPhoneState*>( aAny )->
       
  3282         ShowQueryL( EPhoneAlsLineChangeConfirmationQuery );
       
  3283 
       
  3284     return KErrNone;
       
  3285     }
       
  3286 
       
  3287 // ---------------------------------------------------------
       
  3288 // CPhoneState::ShowWlanMacAddressL
       
  3289 // ---------------------------------------------------------
       
  3290 //
       
  3291 void CPhoneState::ShowWlanMacAddressL()
       
  3292     {
       
  3293     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::ShowWlanMacAddressL()");
       
  3294     if ( IsOnScreenDialerSupported() )
       
  3295         {
       
  3296         NumberEntryClearL();
       
  3297         }
       
  3298     else
       
  3299         {
       
  3300         // Remove number entry from screen
       
  3301         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  3302         }
       
  3303 
       
  3304     // Fetch WLAN MAC address
       
  3305     TBuf8<KPhoneWlanMacAddressLength> address;
       
  3306     RProperty::Get(
       
  3307         KPSUidWlan,
       
  3308         KPSWlanMacAddress,
       
  3309         address );
       
  3310 
       
  3311     // Format fetched address
       
  3312     TBuf<KPhoneWlanMacAddressLength> wlanMACAddress;
       
  3313     for ( TInt i( 0 ); i < address.Length(); i++ )
       
  3314         {
       
  3315         // Set separator
       
  3316         if( i > 0 )
       
  3317             {
       
  3318             wlanMACAddress.Append( KPhoneWlanSeparator );
       
  3319             }
       
  3320         // Set data
       
  3321         TBuf<10> tmp;
       
  3322         tmp.Format( KWLanMACDataFormat, address[i] );
       
  3323         wlanMACAddress.Append( tmp );
       
  3324         }
       
  3325 
       
  3326     // Now we need the localised text
       
  3327     HBufC* wlanMacAddress = StringLoader::LoadLC(
       
  3328         CPhoneMainResourceResolver::Instance()->
       
  3329         ResolveResourceID( EPhoneWlanMacAddress ), wlanMACAddress );
       
  3330 
       
  3331     TPhoneCmdParamNote noteParam;
       
  3332     noteParam.SetType( EPhoneNoteCustom );
       
  3333     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
  3334         ResolveResourceID( EPhoneInformationWaitNote ) );
       
  3335     noteParam.SetText( *wlanMacAddress );
       
  3336     noteParam.SetTone( CAknNoteDialog::EConfirmationTone );
       
  3337 
       
  3338     // Display note
       
  3339     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
  3340 
       
  3341     CleanupStack::PopAndDestroy( wlanMacAddress );
       
  3342     }
       
  3343 
       
  3344 // -----------------------------------------------------------
       
  3345 // CPhoneState::HandleAudioAvailableOutputChangedL
       
  3346 // Default handling for EPEMessageAvailableAudioOutputsChanged message
       
  3347 // (other items were commented in a header).
       
  3348 // -----------------------------------------------------------
       
  3349 //
       
  3350 void CPhoneState::HandleAudioAvailableOutputChangedL()
       
  3351     {
       
  3352     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleAudioAvailableOutputChangedL() ");
       
  3353     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
  3354         Panic( EPhoneCtrlInvariant ) );
       
  3355 
       
  3356     TPhoneCmdParamAudioAvailability outputParam;
       
  3357 
       
  3358     // Output
       
  3359     const TPEAudioOutput audioOutput =
       
  3360         iStateMachine->PhoneEngineInfo()->AudioOutput();
       
  3361 
       
  3362     // BT availability
       
  3363     TBool btAvailable = iStateMachine->PhoneEngineInfo()->AudioOutputAvailable(
       
  3364             EPEBTAudioAccessory );
       
  3365     outputParam.SetBTAccAvailable( btAvailable );
       
  3366 
       
  3367     // Wired availability
       
  3368     TBool wiredAvailable = iStateMachine->PhoneEngineInfo()->AudioOutputAvailable(
       
  3369             EPEWiredAudioAccessory );
       
  3370     outputParam.SetWiredAccAvailable( wiredAvailable );
       
  3371 
       
  3372     // BTA disconnect handler check
       
  3373     if( btAvailable )
       
  3374         {
       
  3375         CPhoneBtaaDisconnectHandler::InstanceL()->Cancel();
       
  3376         }
       
  3377 
       
  3378     // view update
       
  3379     iViewCommandHandle->ExecuteCommandL( EPhoneViewActivateAudioAvailabilityUIChanges,
       
  3380         &outputParam );
       
  3381     }
       
  3382 
       
  3383 
       
  3384 // ---------------------------------------------------------
       
  3385 // CPhoneState::IsAlsLineChangePossible
       
  3386 // ---------------------------------------------------------
       
  3387 //
       
  3388 TBool CPhoneState::IsAlsLineChangePossible()
       
  3389     {
       
  3390     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsAlsLineChangePossible( ) ");
       
  3391 
       
  3392     TBool isAlsLineChangePossible( ETrue );
       
  3393     TSSSettingsAlsBlockingValue AlsBlockingValue( ESSSettingsAlsBlockingNotSupported );
       
  3394     TInt value( 0 );
       
  3395 
       
  3396     RSSSettings ssSettings;
       
  3397     TInt retValue = ssSettings.Open();
       
  3398 
       
  3399     if ( retValue == KErrNone )
       
  3400         {
       
  3401         ssSettings.Get( ESSSettingsAlsBlocking, value );
       
  3402         ssSettings.Close();
       
  3403 
       
  3404         AlsBlockingValue = static_cast< TSSSettingsAlsBlockingValue > ( value );
       
  3405 
       
  3406         if( AlsBlockingValue == ESSSettingsAlsAlternate )
       
  3407             {
       
  3408             isAlsLineChangePossible = EFalse;
       
  3409             }
       
  3410         }
       
  3411 
       
  3412     return isAlsLineChangePossible;
       
  3413     }
       
  3414 
       
  3415 // ---------------------------------------------------------
       
  3416 // CPhoneState::ShowNumberBusyNoteL
       
  3417 // ---------------------------------------------------------
       
  3418 //
       
  3419 EXPORT_C void CPhoneState::ShowNumberBusyNoteL()
       
  3420     {
       
  3421     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::ShowNumberBusyNoteL( ) ");
       
  3422     // Re-enable global notes
       
  3423     TPhoneCmdParamBoolean globalNotifierParam;
       
  3424     globalNotifierParam.SetBoolean( EFalse );
       
  3425     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
  3426         &globalNotifierParam );
       
  3427 
       
  3428     TInt resource( EPhoneNumberBusy );
       
  3429 
       
  3430     if( iCustomization )
       
  3431         {
       
  3432         // Get customized text resource for busy note
       
  3433         resource = iCustomization->CustomizeBusyNoteText();
       
  3434         }
       
  3435 
       
  3436     // Show number busy note
       
  3437     TPhoneCmdParamGlobalNote globalNoteParam;
       
  3438     globalNoteParam.SetType( EAknGlobalInformationNote );
       
  3439     globalNoteParam.SetTextResourceId(
       
  3440         CPhoneMainResourceResolver::Instance()->
       
  3441         ResolveResourceID( resource ) );
       
  3442     globalNoteParam.SetTone( EAvkonSIDInformationTone );
       
  3443     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowGlobalNote,
       
  3444         &globalNoteParam );
       
  3445     }
       
  3446 
       
  3447 // ---------------------------------------------------------
       
  3448 // CPhoneState::IsAutoLockOn
       
  3449 // ---------------------------------------------------------
       
  3450 //
       
  3451 EXPORT_C TBool CPhoneState::IsAutoLockOn() const
       
  3452     {
       
  3453     // Check if phone is locked
       
  3454     const TBool phoneIsLocked =
       
  3455                 CPhonePubSubProxy::Instance()->Value(
       
  3456                 KPSUidCoreApplicationUIs,
       
  3457                 KCoreAppUIsAutolockStatus ) > EAutolockOff;
       
  3458 
       
  3459     return phoneIsLocked;
       
  3460     }
       
  3461 
       
  3462 // ---------------------------------------------------------
       
  3463 // CPhoneState::IsKeyLockOn
       
  3464 // ---------------------------------------------------------
       
  3465 //
       
  3466 EXPORT_C TBool CPhoneState::IsKeyLockOn() const
       
  3467     {
       
  3468     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsKeyLockOn( ) ");
       
  3469     TPhoneCmdParamBoolean keyLockStatus;
       
  3470     keyLockStatus.SetBoolean( EFalse );
       
  3471 
       
  3472     iViewCommandHandle->ExecuteCommand(
       
  3473             EPhoneViewGetKeyLockStatus,
       
  3474             &keyLockStatus );
       
  3475 
       
  3476     __PHONELOG1( EBasic,
       
  3477             EPhoneControl,
       
  3478             "CPhoneState::IsKeyLockOn() Lock Status: %d",
       
  3479             keyLockStatus.Boolean() );
       
  3480     return keyLockStatus.Boolean();
       
  3481     }
       
  3482 
       
  3483 // ---------------------------------------------------------
       
  3484 // CPhoneState::CompleteSatRequestL
       
  3485 // ---------------------------------------------------------
       
  3486 //
       
  3487 EXPORT_C void CPhoneState::CompleteSatRequestL( const TInt aCallId )
       
  3488     {
       
  3489     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CompleteSatRequestL( ) ");
       
  3490     iStateMachine->SetCallId( aCallId );
       
  3491     iStateMachine->SendPhoneEngineMessage(
       
  3492         MPEPhoneModel::EPEMessageSatCallRequestCompleted );
       
  3493     }
       
  3494 
       
  3495 // ---------------------------------------------------------
       
  3496 // CPhoneState::SetTouchPaneButtons
       
  3497 // ---------------------------------------------------------
       
  3498 //
       
  3499 EXPORT_C void CPhoneState::SetTouchPaneButtons( TInt /*aResourceId*/ )
       
  3500     {
       
  3501     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3502         {
       
  3503         TBool emergency( EPEStateIdle != 
       
  3504             iStateMachine->PhoneEngineInfo()->CallState( KPEEmergencyCallId ) );
       
  3505         TPhoneCmdParamBoolean booleanParam;
       
  3506         booleanParam.SetBoolean( emergency );
       
  3507 
       
  3508         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
       
  3509                      EPhoneViewSetTouchPaneButtons,
       
  3510                      &booleanParam ) );
       
  3511         SetTouchPaneVisible( ETrue );
       
  3512         }
       
  3513     }
       
  3514 
       
  3515 // ---------------------------------------------------------
       
  3516 // CPhoneState::DeleteTouchPaneButtons
       
  3517 // ---------------------------------------------------------
       
  3518 //
       
  3519 EXPORT_C void CPhoneState::DeleteTouchPaneButtons()
       
  3520     {
       
  3521     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3522         {
       
  3523         TPhoneCmdParamBoolean boolParam;
       
  3524         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
       
  3525                         EPhoneViewSetTouchPaneButtons,
       
  3526                         &boolParam ) );
       
  3527         SetTouchPaneVisible( EFalse );
       
  3528         }
       
  3529     }
       
  3530 
       
  3531 // ---------------------------------------------------------
       
  3532 // CPhoneState::SetTouchPaneVisible
       
  3533 // ---------------------------------------------------------
       
  3534 //
       
  3535 EXPORT_C void CPhoneState::SetTouchPaneVisible( TBool aVisible )
       
  3536     {
       
  3537     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3538         {
       
  3539         TPhoneCmdParamBoolean booleanParam;
       
  3540         booleanParam.SetBoolean( aVisible );
       
  3541         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
       
  3542                         EPhoneViewSetTouchPaneVisible,
       
  3543                         &booleanParam ) );
       
  3544         }
       
  3545     }
       
  3546 
       
  3547 // ----------------------------------------------------------------------------
       
  3548 // CPhoneState::SetTouchButtonEnabled
       
  3549 // ----------------------------------------------------------------------------
       
  3550 //
       
  3551 EXPORT_C void CPhoneState::SetTouchPaneButtonEnabled( TInt aCommandId )
       
  3552     {
       
  3553     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3554         {
       
  3555         TPhoneCmdParamInteger commandParam;
       
  3556         commandParam.SetInteger( aCommandId );
       
  3557         iViewCommandHandle->ExecuteCommand( EPhoneViewEnableTouchButton,
       
  3558                                             &commandParam );
       
  3559         }
       
  3560     }
       
  3561 
       
  3562 // ----------------------------------------------------------------------------
       
  3563 // CPhoneState::SetTouchButtonDisabled
       
  3564 // ----------------------------------------------------------------------------
       
  3565 //
       
  3566 EXPORT_C void CPhoneState::SetTouchPaneButtonDisabled( TInt aCommandId )
       
  3567     {
       
  3568     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  3569         {
       
  3570         TPhoneCmdParamInteger commandParam;
       
  3571         commandParam.SetInteger( aCommandId );
       
  3572 
       
  3573         iViewCommandHandle->ExecuteCommand( EPhoneViewDisableTouchButton,
       
  3574                                             &commandParam );
       
  3575         }
       
  3576     }
       
  3577 
       
  3578 // ---------------------------------------------------------
       
  3579 // CPhoneState::HandleLongHashL
       
  3580 // ---------------------------------------------------------
       
  3581 //
       
  3582 EXPORT_C void CPhoneState::HandleLongHashL()
       
  3583     {
       
  3584     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::HandleLongHashL() ");
       
  3585 
       
  3586     TPhoneCmdParamInteger numberEntryCountParam;
       
  3587     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetNumberEntryCount,
       
  3588             &numberEntryCountParam );
       
  3589     TInt neLength( numberEntryCountParam.Integer() );
       
  3590 
       
  3591     if( iCustomization && iCustomization->AllowAlphaNumericMode() )
       
  3592         {
       
  3593         if ( NumberEntryManagerL()->NumberEntryInNumericModeL() )
       
  3594             {
       
  3595             if ( neLength == 0 )
       
  3596                 {
       
  3597                 OnlyHashInNumberEntryL();
       
  3598                 }
       
  3599 
       
  3600             if ( neLength == 1 )
       
  3601                 {
       
  3602                 NumberEntryClearL();
       
  3603                 }
       
  3604             }
       
  3605         NumberEntryManagerL()->NumberEntryToggleAlphaNumericModeL();
       
  3606         }
       
  3607     else
       
  3608         {
       
  3609         if( neLength == 1 )
       
  3610             {
       
  3611             TPhoneCmdParamBoolean isSecurityMode;
       
  3612             iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );
       
  3613 
       
  3614             if ( !isSecurityMode.Boolean() )
       
  3615                 {
       
  3616                 OnlyHashInNumberEntryL();
       
  3617                 }
       
  3618             }
       
  3619         }
       
  3620     }
       
  3621 
       
  3622 // -----------------------------------------------------------
       
  3623 // CPhoneState::OpenVKBL
       
  3624 // -----------------------------------------------------------
       
  3625 //
       
  3626 void CPhoneState::OpenVkbL()
       
  3627     {
       
  3628     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::OpenVKB() ");
       
  3629     iViewCommandHandle->ExecuteCommandL( EPhoneViewOpenVirtualKeyBoard );
       
  3630     }
       
  3631 
       
  3632 // -----------------------------------------------------------
       
  3633 // CPhoneState::BeginUiUpdateLC
       
  3634 // -----------------------------------------------------------
       
  3635 //
       
  3636 EXPORT_C void CPhoneState::BeginUiUpdateLC()
       
  3637     {
       
  3638 
       
  3639     iViewCommandHandle->ExecuteCommand( EPhoneViewBeginUpdate );
       
  3640 
       
  3641     TCleanupItem operation( UiUpdateCleanup, this );
       
  3642     CleanupStack::PushL( operation );
       
  3643     }
       
  3644 
       
  3645 // -----------------------------------------------------------
       
  3646 // CPhoneState::BeginTransEffectLC
       
  3647 // -----------------------------------------------------------
       
  3648 //
       
  3649 EXPORT_C void CPhoneState::BeginTransEffectLC(  TStateTransEffectType aType )
       
  3650     {
       
  3651     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::BeginTransEffectLC( ) ");
       
  3652     TPhoneCmdParamTransEffect effectParam;
       
  3653 
       
  3654     switch ( aType )
       
  3655         {
       
  3656         case ENumberEntryOpen:
       
  3657             effectParam.SetType( EPhoneTransEffectDialerOpen );
       
  3658             break;
       
  3659         case ENumberEntryClose:
       
  3660             effectParam.SetType( EPhoneTransEffectDialerClose );
       
  3661             break;
       
  3662         case ENumberEntryCreate:
       
  3663             effectParam.SetType( EPhoneTransEffectDialerCreate );
       
  3664             break;
       
  3665         default:
       
  3666             effectParam.SetType( EPhoneTransEffectNone );
       
  3667         }
       
  3668 
       
  3669     iViewCommandHandle->ExecuteCommand( EPhoneViewBeginTransEffect,  &effectParam );
       
  3670 
       
  3671     TCleanupItem operation( EffectCleanup, this );
       
  3672     CleanupStack::PushL( operation );
       
  3673     }
       
  3674 
       
  3675 // -----------------------------------------------------------
       
  3676 // CPhoneState::EndUiUpdate
       
  3677 // -----------------------------------------------------------
       
  3678 //
       
  3679 EXPORT_C void CPhoneState::EndUiUpdate()
       
  3680     {
       
  3681     CleanupStack::PopAndDestroy(); // Call UiUpdateCleanup
       
  3682     }
       
  3683 
       
  3684 // -----------------------------------------------------------
       
  3685 // CPhoneState::EndTransEffect
       
  3686 // -----------------------------------------------------------
       
  3687 //
       
  3688 EXPORT_C void CPhoneState::EndTransEffect()
       
  3689     {
       
  3690     CleanupStack::PopAndDestroy(); // Call EffectCleanup
       
  3691     }
       
  3692 
       
  3693 // -----------------------------------------------------------
       
  3694 // CPhoneState::CheckIfShowTerminationNote
       
  3695 // This method is intended to be overridden in states
       
  3696 // that contain more info about decision.
       
  3697 // -----------------------------------------------------------
       
  3698 //
       
  3699 EXPORT_C TBool CPhoneState::CheckIfShowCallTerminationNote( )
       
  3700     {
       
  3701     TBool show = EFalse;
       
  3702     TInt callSummaryActivated = 0;
       
  3703     const TInt err = CPhoneCenRepProxy::Instance()->GetInt(
       
  3704         KCRUidCommonTelephonySettings,
       
  3705         KSettingsSummaryAfterCall,
       
  3706         callSummaryActivated );
       
  3707 
       
  3708     if ( err == KErrNone && callSummaryActivated )
       
  3709         {
       
  3710           show = ETrue;
       
  3711         }
       
  3712 
       
  3713     return show;
       
  3714     }
       
  3715 
       
  3716 // -----------------------------------------------------------------------------
       
  3717 // CPhoneState::HandleDtmfKeyTone
       
  3718 // Called from KeyEventForwarder
       
  3719 // Allow only special characters to pass from
       
  3720 // keyEventForwarder to phoneEngine
       
  3721 // -----------------------------------------------------------------------------
       
  3722 //
       
  3723 
       
  3724 EXPORT_C void CPhoneState::HandleDtmfKeyToneL( const TKeyEvent& aKeyEvent,
       
  3725                 TEventCode aEventCode )
       
  3726     {
       
  3727     SendDtmfKeyEventL( aKeyEvent, aEventCode );
       
  3728     }
       
  3729 
       
  3730 // -----------------------------------------------------------------------------
       
  3731 // CPhoneState::UiUpdateCleanup
       
  3732 // -----------------------------------------------------------------------------
       
  3733 //
       
  3734 void CPhoneState::UiUpdateCleanup(TAny* aThis )
       
  3735     {
       
  3736     static_cast<CPhoneState*>( aThis )->iViewCommandHandle->ExecuteCommand(
       
  3737         EPhoneViewEndUpdate );
       
  3738     }
       
  3739 
       
  3740 // -----------------------------------------------------------------------------
       
  3741 // CPhoneState::EffectCleanup
       
  3742 // -----------------------------------------------------------------------------
       
  3743 //
       
  3744 void CPhoneState::EffectCleanup(TAny* aThis )
       
  3745     {
       
  3746     TPhoneCmdParamTransEffect effectParam;
       
  3747     effectParam.SetType( EPhoneTransEffectStop );
       
  3748 
       
  3749     static_cast<CPhoneState*>( aThis )->iViewCommandHandle->ExecuteCommand(
       
  3750         EPhoneViewEndTransEffect, &effectParam );
       
  3751     }
       
  3752 
       
  3753 // -----------------------------------------------------------------------------
       
  3754 // CPhoneState::IsDTMFEditorVisibleL
       
  3755 // -----------------------------------------------------------------------------
       
  3756 //
       
  3757 EXPORT_C TBool CPhoneState::IsDTMFEditorVisibleL() const
       
  3758     {
       
  3759     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsDTMFEditorVisibleL( ) ");
       
  3760     return iViewCommandHandle->HandleCommandL(
       
  3761         EPhoneViewIsDTMFEditorVisible ) ==
       
  3762         EPhoneViewResponseSuccess;
       
  3763     }
       
  3764 
       
  3765 // -----------------------------------------------------------------------------
       
  3766 // CPhoneState::CloseDTMFEditorL
       
  3767 // -----------------------------------------------------------------------------
       
  3768 //
       
  3769 EXPORT_C void CPhoneState::CloseDTMFEditorL()
       
  3770     {
       
  3771     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CloseDTMFEditorL()");
       
  3772     if ( iOnScreenDialer ) // Touch
       
  3773         {
       
  3774         TPhoneCmdParamBoolean booleanParam;
       
  3775         booleanParam.SetBoolean( EFalse );
       
  3776         // Disable dialer DTMF mode
       
  3777         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetDtmfDialerViewVisible,
       
  3778                                              &booleanParam );
       
  3779 
       
  3780         // Closing effect is shown when DTMF dialer exist.
       
  3781         BeginTransEffectLC( ENumberEntryClose );
       
  3782         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  3783         EndTransEffect();
       
  3784         }
       
  3785     else // Non-Touch
       
  3786         {
       
  3787         // If dtmf query is visible then remove number entry
       
  3788         // because it should not be shown if user has pressed end key.
       
  3789         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  3790         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
       
  3791         }
       
  3792 
       
  3793     // Do state-specific behaviour if number entry is cleared
       
  3794     HandleNumberEntryClearedL();
       
  3795     }
       
  3796 
       
  3797 // -----------------------------------------------------------
       
  3798 // CPhoneState::SetDefaultFlagsL()
       
  3799 // -----------------------------------------------------------
       
  3800 //
       
  3801 EXPORT_C void CPhoneState::SetDefaultFlagsL()
       
  3802     {
       
  3803     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetDefaultFlagsL()");
       
  3804     iViewCommandHandle->ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
       
  3805 
       
  3806     // Reset Hold flag to view
       
  3807     TPhoneCmdParamBoolean holdFlag;
       
  3808     holdFlag.SetBoolean( EFalse );
       
  3809     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
  3810 
       
  3811     // Update FSW
       
  3812     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateFSW );
       
  3813 
       
  3814     // Re-enable global notes
       
  3815     TPhoneCmdParamBoolean globalNotifierParam;
       
  3816     globalNotifierParam.SetBoolean( EFalse );
       
  3817     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
  3818         &globalNotifierParam );
       
  3819     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
       
  3820         &globalNotifierParam );
       
  3821 
       
  3822     // uncapture App and Camera keys if not security mode
       
  3823     TPhoneCmdParamBoolean isSecurityMode;
       
  3824     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );
       
  3825     if ( !isSecurityMode.Boolean() )
       
  3826         {
       
  3827         CaptureKeysDuringCallNotificationL( EFalse );
       
  3828         }
       
  3829 
       
  3830     // Restore keylock if phone has been locked before call.
       
  3831     if ( iStateMachine->PhoneStorage()->NeedToEnableKeylock() )
       
  3832         {
       
  3833         iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLock );
       
  3834         iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( EFalse );
       
  3835         }
       
  3836     }
       
  3837 
       
  3838 // -----------------------------------------------------------
       
  3839 // CPhoneState::GetVolumeLevel
       
  3840 // -----------------------------------------------------------
       
  3841 //
       
  3842 TInt CPhoneState::GetVolumeLevel()
       
  3843     {
       
  3844     TPhoneCmdParamInteger integerParam;
       
  3845 
       
  3846     iViewCommandHandle->ExecuteCommand( EPhoneViewGetAudioVolumeLevel,
       
  3847                                         &integerParam );
       
  3848     return integerParam.Integer();
       
  3849     }
       
  3850 
       
  3851 // -----------------------------------------------------------
       
  3852 // CPhoneState::ShowVideoCallOutOfMemoryNoteL
       
  3853 // -----------------------------------------------------------
       
  3854 //
       
  3855 void CPhoneState::ShowVideoCallOutOfMemoryNoteL()
       
  3856     {
       
  3857     __LOGMETHODSTARTEND(EPhoneControl,
       
  3858         "CPhoneState::ShowVideoCallOutOfMemoryNoteL()" );
       
  3859 
       
  3860     // Re-enable global notes
       
  3861     TPhoneCmdParamBoolean globalNotifierParam;
       
  3862     globalNotifierParam.SetBoolean( EFalse );
       
  3863     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
  3864         &globalNotifierParam );
       
  3865 
       
  3866     // Bring Phone app in the foreground
       
  3867     TPhoneCmdParamInteger uidParam;
       
  3868     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
  3869     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
  3870         &uidParam );
       
  3871 
       
  3872     // Set Phone as the top application
       
  3873     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
  3874         &uidParam );
       
  3875 
       
  3876     // Display error note
       
  3877     SExtendedError ext;
       
  3878     ext.iComponent = KUidPhoneApplication;
       
  3879     ext.iErrorNumber = KErrNoMemory;
       
  3880     ext.iInformation = EFalse;
       
  3881     TBuf<1> ignore;
       
  3882     iAvkonAppUi->HandleError( KErrNoMemory, ext, ignore, ignore );
       
  3883     }
       
  3884 
       
  3885 // -----------------------------------------------------------------------------
       
  3886 // CPhoneState::SimSecurityStatus
       
  3887 // -----------------------------------------------------------------------------
       
  3888 //
       
  3889 TInt CPhoneState::SimSecurityStatus() const
       
  3890     {
       
  3891     /*
       
  3892     Sim security statuses:
       
  3893 
       
  3894     ESimSecurityStatusUninitialized = KStartupEnumerationFirstValue,
       
  3895     ESimRejected,   // The PUK code has been entered incorrectly, so the card is rejected.
       
  3896     ESimUnaccepted  // The SIM lock is on, so the card is unaccepted.
       
  3897     */
       
  3898     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SimSecurityStatus()" );
       
  3899     return CPhonePubSubProxy::Instance()->Value(
       
  3900                     KPSUidStartup, KStartupSimSecurityStatus );
       
  3901     }
       
  3902 
       
  3903 // -----------------------------------------------------------------------------
       
  3904 // CPhoneState::CallWaitingNoteL
       
  3905 // -----------------------------------------------------------------------------
       
  3906 //
       
  3907 EXPORT_C void CPhoneState::CallWaitingNoteL( TInt aCallId )
       
  3908     {
       
  3909     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CallWaitingNoteL()" );
       
  3910 
       
  3911     TBuf< KPhoneContactNameMaxLength > callText( KNullDesC );
       
  3912 
       
  3913     // Set CLI text for the call header
       
  3914     const TBool contactInfoAvailable =
       
  3915         iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ).Length() ||
       
  3916         iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ).Length();
       
  3917 
       
  3918     __PHONELOG1( EBasic, EPhoneControl,
       
  3919         "CPhoneState::CallWaitingNoteL - contactInfoAvailable(%d)", contactInfoAvailable );
       
  3920 
       
  3921     __PHONELOG1( EBasic, EPhoneControl,
       
  3922         "CPhoneState::CallWaitingNoteL - remote name(%S)",
       
  3923         &iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ) );
       
  3924 
       
  3925     __PHONELOG1( EBasic, EPhoneControl,
       
  3926         "CPhoneState::CallWaitingNoteL - company name(%S)",
       
  3927         &iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ) );
       
  3928 
       
  3929     if ( contactInfoAvailable )
       
  3930         {
       
  3931         // Set Call Text flag to waiting note
       
  3932         callText = iStateMachine->PhoneEngineInfo()->RemoteName( aCallId );
       
  3933 
       
  3934         // if no remote name available then set company name
       
  3935         if ( callText == KNullDesC )
       
  3936             {
       
  3937             callText = iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId );
       
  3938             }
       
  3939 
       
  3940         TPhoneCmdParamGlobalNote globalNoteParam;
       
  3941         globalNoteParam.SetText( callText );
       
  3942         globalNoteParam.SetType( EAknGlobalInformationNote );
       
  3943         globalNoteParam.SetTone( EAvkonSIDInformationTone );
       
  3944         globalNoteParam.SetTextResourceId(
       
  3945             CPhoneMainResourceResolver::Instance()->
       
  3946             ResolveResourceID( EPhoneCallWaitingWithLabel ) );
       
  3947 
       
  3948         iViewCommandHandle->ExecuteCommandL(
       
  3949                 EPhoneViewShowGlobalNote, &globalNoteParam );
       
  3950         }
       
  3951     else
       
  3952         {
       
  3953         SendGlobalInfoNoteL( EPhoneCallWaitingWithoutLabel );
       
  3954         }
       
  3955     }
       
  3956 
       
  3957 // ----------------------------------------------------------------------------
       
  3958 // CPhoneState::SetRingingTonePlaybackL()
       
  3959 // ----------------------------------------------------------------------------
       
  3960 //
       
  3961 EXPORT_C void CPhoneState::SetRingingTonePlaybackL( TInt aCallId )
       
  3962     {
       
  3963     __LOGMETHODSTARTEND(EPhoneControl,
       
  3964         "CPhoneState::SetRingingTonePlaybackL()" );
       
  3965 
       
  3966     TPhoneCmdParamRingTone ringToneParam;
       
  3967     ringToneParam.SetVolume(
       
  3968         iStateMachine->PhoneEngineInfo()->RingingVolume() );
       
  3969 
       
  3970     TArray< TContactItemId > alertGroups =
       
  3971         iStateMachine->PhoneEngineInfo()->AlertForGroup();
       
  3972 
       
  3973     TInt alertGroupCount = alertGroups.Count();
       
  3974     TInt contactGroupCount =
       
  3975         iStateMachine->PhoneEngineInfo()->ContactGroups( aCallId ).Count();
       
  3976     TBool alertingGroupFound( EFalse );
       
  3977 
       
  3978     // Check contents of both the alerting groups array and call contact group
       
  3979     // array, if any of the group ids match then allow playing.
       
  3980     if ( alertGroupCount > 0 )
       
  3981         {
       
  3982         for ( TInt i = 0 ; i < alertGroupCount ; i++ )
       
  3983             {
       
  3984             for ( TInt j = 0 ; j < contactGroupCount ; j++ )
       
  3985                 {
       
  3986                 if ( alertGroups[ i ] ==
       
  3987                      ( iStateMachine->PhoneEngineInfo()->ContactGroups(
       
  3988                            aCallId ) )[ j ] )
       
  3989                     {
       
  3990                     alertingGroupFound = ETrue;
       
  3991                     }
       
  3992                 }
       
  3993             }
       
  3994         if ( alertingGroupFound == EFalse )
       
  3995             {
       
  3996             ringToneParam.SetRingingType( EProfileRingingTypeSilent );
       
  3997             }
       
  3998         else
       
  3999             {
       
  4000             ringToneParam.SetRingingType(
       
  4001                 iStateMachine->PhoneEngineInfo()->RingingType() );
       
  4002             }
       
  4003         }
       
  4004     else // no alerting groups set
       
  4005         {
       
  4006         ringToneParam.SetRingingType(
       
  4007             iStateMachine->PhoneEngineInfo()->RingingType() );
       
  4008         }
       
  4009 
       
  4010     // Set ring tone
       
  4011     if ( iStateMachine->PhoneEngineInfo()->PersonalRingingTone(
       
  4012              aCallId ).Length() )
       
  4013         {
       
  4014         // Set the personal ring tone
       
  4015         ringToneParam.SetRingTone(
       
  4016             iStateMachine->PhoneEngineInfo()->PersonalRingingTone( aCallId ) );
       
  4017         ringToneParam.SetType( EPhoneRingTonePersonal );
       
  4018         }
       
  4019     else if ( iStateMachine->PhoneEngineInfo()->RingingTone(
       
  4020                   aCallId ).Length() )
       
  4021         {
       
  4022         // Set the profile ring tone
       
  4023         ringToneParam.SetRingTone(
       
  4024             iStateMachine->PhoneEngineInfo()->RingingTone( aCallId ) );
       
  4025         ringToneParam.SetType( EPhoneRingToneProfile );
       
  4026 
       
  4027         if ( ( iStateMachine->PhoneEngineInfo()->CallerImage( aCallId ).Length() > 0 &&
       
  4028                 BaflUtils::FileExists( CCoeEnv::Static()->FsSession(),
       
  4029                         iStateMachine->PhoneEngineInfo()->CallerImage( aCallId ) ) ) ||
       
  4030                iStateMachine->PhoneEngineInfo()->HasCallerThumbnail( aCallId ) )
       
  4031             {
       
  4032             // Caller image set
       
  4033             ringToneParam.SetCallerImageStatus( ETrue );
       
  4034             }
       
  4035         }
       
  4036 
       
  4037     // Set text to say, if enabled
       
  4038     if ( iStateMachine->PhoneEngineInfo()->TextToSpeech() )
       
  4039         {
       
  4040         ringToneParam.SetTextToSay(
       
  4041             iStateMachine->PhoneEngineInfo()->RemoteTextToSpeechText(
       
  4042                 aCallId ) );
       
  4043         }
       
  4044 
       
  4045     if ( iStateMachine->PhoneEngineInfo()->CallerText( aCallId ).Length() > 0 )
       
  4046         {
       
  4047         ringToneParam.SetCallerTextStatus( ETrue );
       
  4048         }
       
  4049 
       
  4050     // Play the ring tone
       
  4051     iViewCommandHandle->ExecuteCommandL( EPhoneViewPlayRingTone, &ringToneParam );
       
  4052     }
       
  4053 
       
  4054 // -----------------------------------------------------------
       
  4055 // CPhoneState::HandleCugNoteL
       
  4056 // -----------------------------------------------------------
       
  4057 //
       
  4058 void CPhoneState::HandleCugInUseNoteL()
       
  4059     {
       
  4060     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleCugInUseNoteL() ");
       
  4061 
       
  4062     TInt cugIndex( 0 );
       
  4063 
       
  4064     RSSSettings ssSettings;
       
  4065     TInt retValue = ssSettings.Open();
       
  4066 
       
  4067     if ( retValue == KErrNone )
       
  4068         {
       
  4069         ssSettings.Get( ESSSettingsCug, cugIndex  );
       
  4070         }
       
  4071     ssSettings.Close();
       
  4072 
       
  4073     if ( cugIndex )
       
  4074         {
       
  4075         // Add it to the resource string
       
  4076         HBufC* buf = StringLoader::LoadLC(
       
  4077             CPhoneMainResourceResolver::Instance()->
       
  4078             ResolveResourceID(
       
  4079             EPhoneInfoCugInUse ), cugIndex );
       
  4080 
       
  4081         TPhoneCmdParamGlobalNote globalNoteParam;
       
  4082         globalNoteParam.SetText( *buf );
       
  4083         globalNoteParam.SetType( EAknGlobalInformationNote );
       
  4084         globalNoteParam.SetTone( EAvkonSIDInformationTone );
       
  4085 
       
  4086         iViewCommandHandle->ExecuteCommandL(
       
  4087                 EPhoneViewShowGlobalNote, &globalNoteParam );
       
  4088 
       
  4089         CleanupStack::PopAndDestroy( buf );
       
  4090         }
       
  4091     }
       
  4092 
       
  4093 // -----------------------------------------------------------
       
  4094 // CPhoneState::CallheaderManagerL
       
  4095 // -----------------------------------------------------------
       
  4096 //
       
  4097 CPhoneCallHeaderManager* CPhoneState::CallheaderManagerL()
       
  4098     {
       
  4099     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::CallheaderManagerL() ");
       
  4100     if ( !iCallHeaderManager )
       
  4101         {
       
  4102         iCallHeaderManager = CPhoneCallHeaderManager::NewL(
       
  4103                 *iViewCommandHandle,
       
  4104                 *iStateMachine,
       
  4105                 iCustomization );
       
  4106         }
       
  4107     return iCallHeaderManager;
       
  4108     }
       
  4109 
       
  4110 // -----------------------------------------------------------------------------
       
  4111 // CPhoneState::CloseCustomizedDialerL
       
  4112 // -----------------------------------------------------------------------------
       
  4113 //
       
  4114 EXPORT_C void CPhoneState::CloseCustomizedDialerL()
       
  4115     {
       
  4116     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::CloseCustomizedDialerL( ) ");
       
  4117 
       
  4118     // Set dialer back to default mode.
       
  4119     iViewCommandHandle->HandleCommandL( EPhoneViewHideCustomizedDialer );
       
  4120 
       
  4121     // Closing effect is shown when customized dialer exist.
       
  4122     BeginTransEffectLC( ENumberEntryClose );
       
  4123 
       
  4124     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
  4125 
       
  4126     EndTransEffect();
       
  4127     // Do state-specific behaviour if number entry is cleared
       
  4128     HandleNumberEntryClearedL();
       
  4129     }
       
  4130 
       
  4131 // -----------------------------------------------------------------------------
       
  4132 // CPhoneState::CustomizedDialerMenuResourceId
       
  4133 // -----------------------------------------------------------------------------
       
  4134 //
       
  4135 EXPORT_C TInt CPhoneState::CustomizedDialerMenuResourceIdL()
       
  4136     {
       
  4137     __LOGMETHODSTARTEND(EPhoneControl,
       
  4138         "CPhoneState::CustomizedDialerMenuResourceId( ) ");
       
  4139     // Get and return customized dialer menu resource id
       
  4140     TPhoneCmdParamInteger integerParam;
       
  4141     iViewCommandHandle->HandleCommandL(
       
  4142         EPhoneViewGetCustomizedDialerMenuResourceId,
       
  4143         &integerParam );
       
  4144     return integerParam.Integer();
       
  4145     }
       
  4146 
       
  4147 // -----------------------------------------------------------------------------
       
  4148 // CPhoneState::CustomizedDialerCbaResourceId
       
  4149 // -----------------------------------------------------------------------------
       
  4150 //
       
  4151 EXPORT_C TInt CPhoneState::CustomizedDialerCbaResourceIdL()
       
  4152     {
       
  4153     __LOGMETHODSTARTEND(EPhoneControl,
       
  4154            "CPhoneState::CustomizedDialerCbaResourceId( ) ");
       
  4155     // Get and return customized dialer CBA resource id
       
  4156     TPhoneCmdParamInteger integerParam;
       
  4157     iViewCommandHandle->HandleCommandL(
       
  4158             EPhoneViewGetCustomizedDialerCbaResourceId,
       
  4159         &integerParam );
       
  4160     return integerParam.Integer();
       
  4161     }
       
  4162 
       
  4163 // -----------------------------------------------------------
       
  4164 // CPhoneState::ShowDtmfDialerL
       
  4165 // -----------------------------------------------------------
       
  4166 //
       
  4167 void CPhoneState::ShowDtmfDialerL()
       
  4168     {
       
  4169     __LOGMETHODSTARTEND(EPhoneControl,
       
  4170         "CPhoneState::ShowDtmfDialerL()" );
       
  4171 
       
  4172     // Set dialer to DTMF mode.
       
  4173     TPhoneCmdParamBoolean booleanParam;
       
  4174     booleanParam.SetBoolean( ETrue );
       
  4175     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetDtmfDialerViewVisible,
       
  4176                                          &booleanParam );
       
  4177 
       
  4178     BeginTransEffectLC( ENumberEntryCreate );
       
  4179 
       
  4180     if ( IsNumberEntryUsedL() )
       
  4181         {
       
  4182         // Store the number entry content to cache
       
  4183         if ( !IsNumberEntryContentStored() )
       
  4184             {
       
  4185             StoreNumberEntryContentL();
       
  4186             }
       
  4187         // Clear and display DTMF dialer
       
  4188         NumberEntryClearL();
       
  4189         SetNumberEntryVisibilityL(ETrue);
       
  4190         }
       
  4191     else
       
  4192         {
       
  4193         // Create and display DTMF dialer
       
  4194         NumberEntryManagerL()->CreateNumberEntryL();
       
  4195         }
       
  4196 
       
  4197     EndTransEffect();
       
  4198 
       
  4199     // Update CBA
       
  4200     iCbaManager->UpdateInCallCbaL();
       
  4201     }
       
  4202 
       
  4203 // -----------------------------------------------------------
       
  4204 // CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer
       
  4205 // -----------------------------------------------------------
       
  4206 //
       
  4207 EXPORT_C void CPhoneState::CheckIfRestoreNEContentAfterDtmfDialer()
       
  4208     {
       
  4209     if ( IsOnScreenDialerSupported() )
       
  4210         {
       
  4211         TBool isDialerVisible( EFalse );
       
  4212         TRAP_IGNORE( isDialerVisible = IsDTMFEditorVisibleL() );
       
  4213 
       
  4214          if ( isDialerVisible )
       
  4215              {
       
  4216              TRAP_IGNORE( CloseDTMFEditorL() );
       
  4217              }
       
  4218 
       
  4219          // if the DTMF dialer is used before the idle message, we have to
       
  4220          // restore the original content of the number entry
       
  4221          if ( IsNumberEntryContentStored() )
       
  4222              {
       
  4223              TBool isNumberEntryUsed( EFalse );
       
  4224              TRAP_IGNORE( isNumberEntryUsed = IsNumberEntryUsedL() );
       
  4225 
       
  4226              if ( !isNumberEntryUsed )
       
  4227                  {
       
  4228                  TRAP_IGNORE( NumberEntryManagerL()->CreateNumberEntryL() );
       
  4229                  }
       
  4230              // Restore the number entry content from cache
       
  4231              TRAP_IGNORE( RestoreNumberEntryContentL() );
       
  4232              }
       
  4233          }
       
  4234     }
       
  4235 
       
  4236 // -----------------------------------------------------------
       
  4237 // CPhoneState::IsOnScreenDialerSupported
       
  4238 // -----------------------------------------------------------
       
  4239 //
       
  4240 EXPORT_C TBool CPhoneState::IsOnScreenDialerSupported() const
       
  4241     {
       
  4242     return iOnScreenDialer;
       
  4243     }
       
  4244 
       
  4245 // ---------------------------------------------------------------------------
       
  4246 // CPhoneState::LoadResource
       
  4247 // ---------------------------------------------------------------------------
       
  4248 //
       
  4249 void CPhoneState::LoadResource( TDes& aData, const TInt aResource ) const
       
  4250     {
       
  4251     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::LoadResource() ");
       
  4252     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::LoadResource - aResource: %d", aResource );
       
  4253     StringLoader::Load(  aData,
       
  4254                          CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
       
  4255                          &iEnv  );
       
  4256     }
       
  4257 
       
  4258 // -----------------------------------------------------------
       
  4259 // CPhoneState::IsAnyConnectedCalls
       
  4260 // -----------------------------------------------------------
       
  4261 //
       
  4262 TBool CPhoneState::IsAnyConnectedCalls()
       
  4263     {
       
  4264     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::IsAnyConnectedCalls() ");
       
  4265     TBool connectedCall(EFalse);
       
  4266     if ( iStateMachine->PhoneEngineInfo()->CheckIfCallStateExists( EPEStateConnected ) ||
       
  4267         iStateMachine->PhoneEngineInfo()->CheckIfCallStateExists( EPEStateConnecting ) ||
       
  4268         iStateMachine->PhoneEngineInfo()->CheckIfCallStateExists( EPEStateConnectedConference ) )
       
  4269         {
       
  4270         connectedCall = ETrue;
       
  4271         }
       
  4272     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsAnyConnectedCalls: (%d)", connectedCall );
       
  4273     return connectedCall;
       
  4274     }
       
  4275 
       
  4276 // -----------------------------------------------------------
       
  4277 // CPhoneState::NumberEntryContentL
       
  4278 // -----------------------------------------------------------
       
  4279 //
       
  4280 CPhoneNumberEntryManager* CPhoneState::NumberEntryManagerL()
       
  4281     {
       
  4282     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::NumberEntryContentL() ");
       
  4283     if ( !iNumberEntryManager )
       
  4284         {
       
  4285         iNumberEntryManager = CPhoneNumberEntryManager::NewL(
       
  4286                 this,
       
  4287                 *iViewCommandHandle,
       
  4288                 *iStateMachine,
       
  4289                 iCustomization,
       
  4290                 *iCbaManager );
       
  4291         }
       
  4292     return iNumberEntryManager;
       
  4293     }
       
  4294 
       
  4295 // -----------------------------------------------------------
       
  4296 // CPhoneState::PhoneNumberFromEntryLC()
       
  4297 // -----------------------------------------------------------
       
  4298 //
       
  4299 EXPORT_C HBufC* CPhoneState::PhoneNumberFromEntryLC()
       
  4300     {
       
  4301     return NumberEntryManagerL()->PhoneNumberFromEntryLC();
       
  4302     }
       
  4303 
       
  4304 // -----------------------------------------------------------
       
  4305 // CPhoneState::IsNumberEntryUsedL
       
  4306 // -----------------------------------------------------------
       
  4307 //
       
  4308 EXPORT_C TBool CPhoneState::IsNumberEntryUsedL()
       
  4309     {
       
  4310     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNumberEntryUsedL( ) ");
       
  4311     return NumberEntryManagerL()->IsNumberEntryUsedL();
       
  4312     }
       
  4313 
       
  4314 // -----------------------------------------------------------
       
  4315 // CPhoneState::IsNumberEntryVisibleL
       
  4316 // -----------------------------------------------------------
       
  4317 //
       
  4318 EXPORT_C TBool CPhoneState::IsNumberEntryVisibleL()
       
  4319     {
       
  4320     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsNumberEntryVisibleL( ) ");
       
  4321     return NumberEntryManagerL()->IsNumberEntryVisibleL();
       
  4322     }
       
  4323 
       
  4324 // -----------------------------------------------------------
       
  4325 // CPhoneState::KeyEventForExistingNumberEntryL
       
  4326 // -----------------------------------------------------------
       
  4327 //
       
  4328 void CPhoneState::KeyEventForExistingNumberEntryL( const TKeyEvent& aKeyEvent,
       
  4329     TEventCode aEventCode )
       
  4330     {
       
  4331     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::KeyEventForExistingNumberEntryL( ) ");
       
  4332     NumberEntryManagerL()->KeyEventForExistingNumberEntryL( aKeyEvent, aEventCode );
       
  4333     }
       
  4334 
       
  4335 // -----------------------------------------------------------
       
  4336 // CPhoneState::HandleNumberEntryClearedL
       
  4337 // -----------------------------------------------------------
       
  4338 //
       
  4339 EXPORT_C void CPhoneState::HandleNumberEntryClearedL()
       
  4340     {
       
  4341     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleNumberEntryClearedL( ) ");
       
  4342     NumberEntryManagerL()->HandleNumberEntryClearedL();
       
  4343     }
       
  4344 
       
  4345 // -----------------------------------------------------------
       
  4346 // CPhoneState::SetNumberEntryVisibilityL
       
  4347 // -----------------------------------------------------------
       
  4348 //
       
  4349 EXPORT_C void CPhoneState::SetNumberEntryVisibilityL( const TBool aVisible )
       
  4350     {
       
  4351     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::SetNumberEntryVisibilityL( ) ");
       
  4352     TPhoneCmdParamBoolean booleanParam;
       
  4353     booleanParam.SetBoolean( ETrue );
       
  4354     if ( !aVisible )
       
  4355         {
       
  4356         booleanParam.SetBoolean( EFalse );
       
  4357         }
       
  4358     NumberEntryManagerL()->SetNumberEntryVisibilityL( booleanParam );
       
  4359     }
       
  4360 
       
  4361 // ---------------------------------------------------------
       
  4362 // CPhoneState::HandleCreateNumberEntryL
       
  4363 // ---------------------------------------------------------
       
  4364 //
       
  4365 EXPORT_C void CPhoneState::HandleCreateNumberEntryL(
       
  4366         const TKeyEvent& /*aKeyEvent*/,
       
  4367         TEventCode /*aEventCode*/ )
       
  4368     {
       
  4369     NumberEntryManagerL()->HandleCreateNumberEntryL();
       
  4370     }
       
  4371 
       
  4372 // -----------------------------------------------------------
       
  4373 // CPhoneState::IsNumberEntryContentStored
       
  4374 // -----------------------------------------------------------
       
  4375 //
       
  4376 EXPORT_C TBool CPhoneState::IsNumberEntryContentStored()
       
  4377     {
       
  4378     TBool isNumberEntryContentStored( EFalse );
       
  4379     TRAP_IGNORE( isNumberEntryContentStored = NumberEntryManagerL()->IsNumberEntryContentStored() );
       
  4380     return isNumberEntryContentStored;
       
  4381     }
       
  4382 
       
  4383 // -----------------------------------------------------------
       
  4384 // CPhoneState::StoreNumberEntryContentL
       
  4385 // -----------------------------------------------------------
       
  4386 //
       
  4387 EXPORT_C void CPhoneState::StoreNumberEntryContentL()
       
  4388     {
       
  4389     NumberEntryManagerL()->StoreNumberEntryContentL();
       
  4390     }
       
  4391 
       
  4392 // -----------------------------------------------------------
       
  4393 // CPhoneState::RestoreNumberEntryContentL
       
  4394 // -----------------------------------------------------------
       
  4395 //
       
  4396 EXPORT_C void CPhoneState::RestoreNumberEntryContentL()
       
  4397     {
       
  4398     NumberEntryManagerL()->RestoreNumberEntryContentL();
       
  4399     }
       
  4400 
       
  4401 // -----------------------------------------------------------
       
  4402 // CPhoneState::ClearNumberEntryContentCache
       
  4403 // -----------------------------------------------------------
       
  4404 //
       
  4405 EXPORT_C void CPhoneState::ClearNumberEntryContentCache()
       
  4406     {
       
  4407     TRAP_IGNORE( NumberEntryManagerL()->ClearNumberEntryContentCache() );
       
  4408     }
       
  4409 
       
  4410 // -----------------------------------------------------------
       
  4411 // CPhoneState::HandleNumberEntryEdited
       
  4412 // -----------------------------------------------------------
       
  4413 //
       
  4414 EXPORT_C void CPhoneState::HandleNumberEntryEdited()
       
  4415     {
       
  4416     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::HandleNumberEntryEdited() ");
       
  4417     TRAP_IGNORE( NumberEntryManagerL()->HandleNumberEntryEdited() );
       
  4418     }
       
  4419 
       
  4420 // -----------------------------------------------------------------------------
       
  4421 // CPhoneState::IsAlphanumericSupportedAndCharInput
       
  4422 // -----------------------------------------------------------------------------
       
  4423 //
       
  4424 EXPORT_C TBool CPhoneState::IsAlphanumericSupportedAndCharInput(
       
  4425         const TKeyEvent& aKeyEvent )
       
  4426     {
       
  4427     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::IsAlphanumericSupportedAndCharInput() ");
       
  4428     TBool alphaNumericSupport(EFalse);
       
  4429     TRAP_IGNORE( alphaNumericSupport = NumberEntryManagerL()->IsAlphanumericSupportedAndCharInput( aKeyEvent ) );
       
  4430     return alphaNumericSupport;
       
  4431     }
       
  4432 
       
  4433 // ---------------------------------------------------------
       
  4434 // CPhoneState::OnlyHashInNumberEntryL
       
  4435 // ---------------------------------------------------------
       
  4436 //
       
  4437 EXPORT_C void CPhoneState::OnlyHashInNumberEntryL()
       
  4438     {
       
  4439     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::OnlyHashInNumberEntryL( ) ");
       
  4440     // 0.8 seconds has passed, start ALS line change timer
       
  4441     StartAlsLineChangeTimerL();
       
  4442     }
       
  4443 
       
  4444 // -----------------------------------------------------------
       
  4445 // CPhoneState::NumberEntryClearL
       
  4446 // -----------------------------------------------------------
       
  4447 //
       
  4448 void CPhoneState::NumberEntryClearL()
       
  4449     {
       
  4450     NumberEntryManagerL()->NumberEntryClearL();
       
  4451     }
       
  4452     
       
  4453 // -----------------------------------------------------------
       
  4454 // CPhoneState::UpdateSilenceButtonDimming
       
  4455 // -----------------------------------------------------------
       
  4456 //
       
  4457 EXPORT_C void CPhoneState::UpdateSilenceButtonDimming()
       
  4458     {
       
  4459     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  4460         {
       
  4461         const TProfileRingingType ringingType =
       
  4462             iStateMachine->PhoneEngineInfo()->RingingType();
       
  4463         
       
  4464         TBool callIsAlerting =
       
  4465                 !(( ringingType == EProfileRingingTypeSilent ) ||
       
  4466                   ( ringingType == EProfileRingingTypeBeepOnce ));
       
  4467 
       
  4468         if ( !callIsAlerting )
       
  4469             {
       
  4470             SetTouchPaneButtonDisabled( EPhoneCallComingCmdSilent );
       
  4471             }
       
  4472         }
       
  4473     }
       
  4474 
       
  4475 // -----------------------------------------------------------
       
  4476 // CPhoneState::GetBlockedKeyList
       
  4477 // -----------------------------------------------------------
       
  4478 //
       
  4479 EXPORT_C const RArray<TInt>& CPhoneState::GetBlockedKeyList() const
       
  4480     {
       
  4481     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::GetBlockedKeyList( ) ");
       
  4482     return iStateMachine->PhoneStorage()->GetBlockedKeyList();
       
  4483     }
       
  4484 
       
  4485 // -----------------------------------------------------------
       
  4486 // CPhoneState::DisableHWKeysL
       
  4487 // -----------------------------------------------------------
       
  4488 //
       
  4489 EXPORT_C void CPhoneState::DisableHWKeysL()
       
  4490     {
       
  4491     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisableHWKeysL( ) ");
       
  4492 
       
  4493     if( iStateMachine->PhoneStorage()->IsBlockedKeysListEmpty() )
       
  4494         {
       
  4495         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::DisableHWKeysL HW Keys Disabled " );
       
  4496 
       
  4497         iStateMachine->PhoneStorage()->AppendBlockedKeysListL( EStdKeyNo );
       
  4498         iStateMachine->PhoneStorage()->AppendBlockedKeysListL( EStdKeyYes );
       
  4499         }
       
  4500     }
       
  4501 
       
  4502 // -----------------------------------------------------------
       
  4503 // CPhoneState::DisableCallUIL
       
  4504 // -----------------------------------------------------------
       
  4505 //
       
  4506 EXPORT_C void CPhoneState::DisableCallUIL()
       
  4507     {
       
  4508     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisableCallUIL( ) ");
       
  4509 
       
  4510     // Set Call UI state to storage
       
  4511     if( !iStateMachine->PhoneStorage()->IsScreenLocked() )
       
  4512         {
       
  4513         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::DisableCallUIL CallUI Disabled " );
       
  4514 
       
  4515         // Show keys locked note
       
  4516         TPhoneCmdParamNote noteParam;
       
  4517         noteParam.SetType( EPhoneNoteUIDisabled );
       
  4518         noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
  4519             ResolveResourceID( EPhoneInformationNote ) );
       
  4520     
       
  4521         HBufC* noteText = StringLoader::LoadLC( 
       
  4522             CPhoneMainResourceResolver::Instance()->
       
  4523                 ResolveResourceID( EPhoneIncomingCallKeysLocked ) );
       
  4524         noteParam.SetText( *noteText );
       
  4525     
       
  4526         iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
  4527         CleanupStack::PopAndDestroy( noteText );
       
  4528     
       
  4529         // Start capturing the key guard key
       
  4530         TPhoneCmdParamKeyCapture appKeyCaptureParam;
       
  4531         appKeyCaptureParam.SetKey( EStdKeyDevice7 );
       
  4532         appKeyCaptureParam.SetKeyCode( EKeyDeviceF );
       
  4533         appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
  4534         iViewCommandHandle->ExecuteCommandL( EPhoneViewStartCapturingKey, &appKeyCaptureParam );
       
  4535         
       
  4536         // Set Call UI state to storage
       
  4537         iStateMachine->PhoneStorage()->SetScreenLocked( ETrue );
       
  4538         }
       
  4539     }
       
  4540 
       
  4541 // -----------------------------------------------------------
       
  4542 // CPhoneState::EnableCallUIL
       
  4543 // -----------------------------------------------------------
       
  4544 //
       
  4545 EXPORT_C void CPhoneState::EnableCallUIL()
       
  4546     {
       
  4547     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::EnableCallUIL( ) ");
       
  4548 
       
  4549     if( iStateMachine->PhoneStorage()->IsScreenLocked() )
       
  4550         {
       
  4551         __PHONELOG( EBasic, EPhoneControl, " CPhoneState::EnableCallUIL CallUI Enabled " );
       
  4552 
       
  4553         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNote );
       
  4554         iViewCommandHandle->ExecuteCommandL( EPhoneViewDisableKeyLockWithoutNote );
       
  4555 
       
  4556         // Stop capturing the key guard key
       
  4557         TPhoneCmdParamKeyCapture appKeyCaptureParam;
       
  4558         appKeyCaptureParam.SetKey( EStdKeyDevice7 );
       
  4559         appKeyCaptureParam.SetKeyCode( EKeyDeviceF );
       
  4560         appKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
  4561         iViewCommandHandle->ExecuteCommandL( EPhoneViewStopCapturingKey, &appKeyCaptureParam );
       
  4562         
       
  4563         iStateMachine->PhoneStorage()->SetScreenLocked( EFalse );
       
  4564         }
       
  4565     }
       
  4566 
       
  4567 // -----------------------------------------------------------
       
  4568 // CPhoneState::CheckDisableHWKeysAndCallUIL
       
  4569 // -----------------------------------------------------------
       
  4570 //
       
  4571 EXPORT_C void CPhoneState::CheckDisableHWKeysAndCallUIL()
       
  4572     {
       
  4573     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneState::CheckDisableHWKeysAndCallUIL( ) ");
       
  4574 
       
  4575     if( IsKeyLockOn() || IsAutoLockOn() )
       
  4576         {
       
  4577         // Disable HW keys if needed
       
  4578         if( CPhoneCenRepProxy::Instance()->
       
  4579                 IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  4580             {
       
  4581             DisableHWKeysL();
       
  4582             }
       
  4583 
       
  4584         // Disable Call UI if needed
       
  4585         if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke )
       
  4586                 && !CPhoneCenRepProxy::Instance()->
       
  4587                 IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) )
       
  4588             {
       
  4589             DisableCallUIL();
       
  4590             iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( ETrue );
       
  4591             }
       
  4592         }
       
  4593     }
       
  4594 
       
  4595 // -----------------------------------------------------------
       
  4596 // CPhoneState::HandleHoldSwitchL
       
  4597 // -----------------------------------------------------------
       
  4598 //
       
  4599 EXPORT_C void CPhoneState::HandleHoldSwitchL()
       
  4600     {
       
  4601     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneState::HandleHoldSwitchL( ) ");
       
  4602 
       
  4603     if( CPhoneCenRepProxy::Instance()->
       
  4604             IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  4605         {
       
  4606         if( iStateMachine->PhoneStorage()->IsBlockedKeysListEmpty() )
       
  4607             {
       
  4608             // Disable HW Keys if needed
       
  4609             DisableHWKeysL();
       
  4610             }
       
  4611         else
       
  4612             {
       
  4613             // Reset blocked keys list
       
  4614             iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
  4615             }
       
  4616         }
       
  4617     
       
  4618     if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) 
       
  4619             && !CPhoneCenRepProxy::Instance()->
       
  4620             IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) )
       
  4621         {
       
  4622         if( iStateMachine->PhoneStorage()->IsScreenLocked() )
       
  4623             {
       
  4624             // Enable Call
       
  4625             EnableCallUIL();
       
  4626             }
       
  4627         else
       
  4628             {
       
  4629             // Set keylock enabled
       
  4630             iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLockWithoutNote );
       
  4631             // Disable Call
       
  4632             DisableCallUIL();
       
  4633             }
       
  4634         }
       
  4635         
       
  4636         // Stop ringingtone
       
  4637         iViewCommandHandle->ExecuteCommandL( EPhoneViewStopRingTone );
       
  4638     }
       
  4639 
       
  4640 // -----------------------------------------------------------
       
  4641 // CPhoneState::RetainPreviousKeylockStateL
       
  4642 // -----------------------------------------------------------
       
  4643 //
       
  4644 EXPORT_C void CPhoneState::RetainPreviousKeylockStateL()
       
  4645     {
       
  4646     // Lock keypad, if keylock was enabled before incoming call.
       
  4647     // Also reset PhoneStorage keylock status.
       
  4648     if ( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) &&
       
  4649         iStateMachine->PhoneStorage()->NeedToEnableKeylock() )
       
  4650         {
       
  4651         iStateMachine->PhoneStorage()->SetNeedToEnableKeylock( EFalse );
       
  4652         iViewCommandHandle->ExecuteCommandL( EPhoneViewEnableKeyLockWithoutNote ); 
       
  4653         }
       
  4654     }
       
  4655 
       
  4656 // ---------------------------------------------------------
       
  4657 // CPhoneState::HandleKeyLockEnabledL
       
  4658 // ---------------------------------------------------------
       
  4659 //
       
  4660 EXPORT_C void CPhoneState::HandleKeyLockEnabled( TBool aKeylockEnabled )
       
  4661     {
       
  4662     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::HandleKeyLockEnabledL( ) ");
       
  4663     if( !FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke )
       
  4664         && CPhoneCenRepProxy::Instance()->
       
  4665             IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) )
       
  4666         {
       
  4667         if( !aKeylockEnabled )
       
  4668             {
       
  4669             // Keylock disabled
       
  4670             // Reset blocked keys list
       
  4671             iStateMachine->PhoneStorage()->ResetBlockedKeysList();
       
  4672             }
       
  4673         }
       
  4674     }
       
  4675     
       
  4676 // ---------------------------------------------------------
       
  4677 // CPhoneState::SetToolbarDimming
       
  4678 // ---------------------------------------------------------
       
  4679 //
       
  4680 EXPORT_C void CPhoneState::SetToolbarDimming( TBool aDimmed )
       
  4681     {
       
  4682     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  4683         {
       
  4684         TPhoneCmdParamBoolean booleanParam;
       
  4685         booleanParam.SetBoolean( aDimmed );
       
  4686         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
       
  4687             EPhoneViewSetToolbarDimming, &booleanParam ));
       
  4688         }
       
  4689     }
       
  4690 
       
  4691 // ---------------------------------------------------------
       
  4692 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
       
  4693 // ---------------------------------------------------------
       
  4694 //
       
  4695 EXPORT_C void CPhoneState::SetToolbarButtonLoudspeakerEnabled()
       
  4696     {
       
  4697     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  4698         {
       
  4699         TPhoneCmdParamInteger integerParam;
       
  4700         integerParam.SetInteger( EPhoneInCallCmdActivateIhf );
       
  4701         TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL(
       
  4702             EPhoneViewEnableToolbarButton, &integerParam ));
       
  4703         }
       
  4704     }
       
  4705 
       
  4706 // ---------------------------------------------------------
       
  4707 // CPhoneState::SetToolbarDimming
       
  4708 // ---------------------------------------------------------
       
  4709 //
       
  4710 EXPORT_C void CPhoneState::SetBackButtonActive( TBool aActive )
       
  4711     {
       
  4712     if ( FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling ) )
       
  4713         {
       
  4714         TPhoneCmdParamBoolean booleanParam;
       
  4715         booleanParam.SetBoolean( aActive );
       
  4716         iViewCommandHandle->ExecuteCommand(
       
  4717             EPhoneViewBackButtonActive, &booleanParam );
       
  4718         }
       
  4719     }
       
  4720 
       
  4721 // -----------------------------------------------------------
       
  4722 // CPhoneState::OpenSoftRejectMessageEditorL
       
  4723 // -----------------------------------------------------------
       
  4724 //
       
  4725 EXPORT_C void CPhoneState::OpenSoftRejectMessageEditorL()
       
  4726     {
       
  4727     __LOGMETHODSTARTEND(EPhoneControl,
       
  4728         "CPhoneState::OpenSoftRejectMessageEditorL ()" );
       
  4729 
       
  4730     // Fetch incoming call's id from view
       
  4731     TPhoneCmdParamCallStateData callStateData;
       
  4732     callStateData.SetCallState( EPEStateRinging );
       
  4733     iViewCommandHandle->HandleCommandL(
       
  4734         EPhoneViewGetCallIdByState, &callStateData );
       
  4735 
       
  4736     TInt ringingCallId( KErrNotFound );
       
  4737     // Do nothing if negative incoming call id
       
  4738     if( callStateData.CallId() > KErrNotFound  )
       
  4739         {
       
  4740         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
       
  4741         
       
  4742         ringingCallId = callStateData.CallId();
       
  4743         }
       
  4744     
       
  4745     
       
  4746     TPhoneCmdParamSfiData sfiDataParam;
       
  4747 
       
  4748     if (KErrNotFound != ringingCallId) 
       
  4749         {
       
  4750         if ( iStateMachine->PhoneEngineInfo()->RemoteName( ringingCallId ).Length() )
       
  4751             {
       
  4752             // store both the name and the number
       
  4753             sfiDataParam.SetNumber( iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( ringingCallId ) );
       
  4754             sfiDataParam.SetName( iStateMachine->PhoneEngineInfo()->RemoteName( ringingCallId ) );
       
  4755             }
       
  4756         else
       
  4757             {
       
  4758             // store the number
       
  4759             sfiDataParam.SetNumber( iStateMachine->PhoneEngineInfo()->RemotePhoneNumber( ringingCallId ) );
       
  4760             }
       
  4761         }
       
  4762 
       
  4763     iViewCommandHandle->ExecuteCommandL(
       
  4764         EPhoneViewOpenSoftRejectEditor, &sfiDataParam );
       
  4765     }
       
  4766 
       
  4767 //  End of File
       
  4768