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