phoneapp/phoneuicontrol/src/cphoneuicontroller.cpp
branchRCL_3
changeset 17 38529f706030
parent 15 2a26698d78ba
child 25 91c2fb4b78df
equal deleted inserted replaced
15:2a26698d78ba 17:38529f706030
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <featmgr.h>        // for FeatureManager
    20 #include <featmgr.h>        // for FeatureManager
    21 #include <settingsinternalcrkeys.h>
    21 #include <settingsinternalcrkeys.h>
       
    22 #include <phoneappcommands.hrh>
    22 
    23 
    23 #include "cphoneuicontroller.h"
    24 #include "cphoneuicontroller.h"
    24 #include "pevirtualengine.h"
    25 #include "pevirtualengine.h"
    25 #include "cphonestatehandle.h"
    26 #include "cphonestatehandle.h"
    26 #include "cphoneenginehandler.h"
    27 #include "cphoneenginehandler.h"
    27 #include "cphonesystemeventhandler.h"
    28 #include "cphonesystemeventhandler.h"
    28 #include "cphoneremotecontrolhandler.h"
    29 #include "cphoneremotecontrolhandler.h"
    29 #include "mphoneviewcommandhandle.h"
       
    30 #include "phonestatedefinitions.h"
    30 #include "phonestatedefinitions.h"
    31 #include "phonelogger.h"
    31 #include "phonelogger.h"
    32 #include "phoneconstants.h"
    32 #include "phoneconstants.h"
    33 #include "phoneui.pan"
    33 #include "phoneui.pan"
    34 #include "cphonekeyeventforwarder.h"
    34 #include "cphonekeyeventforwarder.h"
    35 #include "cphonecenrepproxy.h"
    35 #include "cphonecenrepproxy.h"
    36 #include "cphonemediatorfactory.h"
    36 #include "cphonemediatorfactory.h"
    37 #include "tphonecmdparamnumberentryobserver.h"
    37 #include "tphonecmdparamnumberentryobserver.h"
    38 #include <phoneappcommands.hrh>
    38 #include "cphonesecuritymodeobserver.h"
       
    39 #include "cphoneviewcontroller.h"
    39 
    40 
    40 // ================= MEMBER FUNCTIONS =======================
    41 // ================= MEMBER FUNCTIONS =======================
    41 
    42 
    42 // -----------------------------------------------------------
    43 // -----------------------------------------------------------
    43 // CPhoneUIController::CPhoneUIController
    44 // CPhoneUIController::CPhoneUIController
    52 // -----------------------------------------------------------
    53 // -----------------------------------------------------------
    53 // CPhoneUIController::ConstructL()
    54 // CPhoneUIController::ConstructL()
    54 // (other items were commented in a header).
    55 // (other items were commented in a header).
    55 // -----------------------------------------------------------
    56 // -----------------------------------------------------------
    56 //
    57 //
    57 void CPhoneUIController::ConstructL( 
    58 void CPhoneUIController::ConstructL( CPhoneViewController& aViewController )
    58     MPhoneViewCommandHandle* aViewCommandHandle )
       
    59     {
    59     {
    60     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::ConstructL()");
    60     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::ConstructL()");
    61     // Creates correct protocol DLL
    61     // Creates correct protocol DLL
    62     CreateProtocolDllL( aViewCommandHandle );
    62     CreateProtocolDllL( aViewController );
    63 
    63 
    64     // Reference the phone state machine
    64     // Reference the phone state machine
    65     iStateMachine = CPhoneStateHandle::Instance()->StateMachine();
    65     iStateMachine = CPhoneStateHandle::Instance()->StateMachine();
    66 
    66 
    67     // Create the phone engine handler
    67     // Create the phone engine handler
    70     iSystemEventHandler = CPhoneSystemEventHandler::NewL( iStateMachine );
    70     iSystemEventHandler = CPhoneSystemEventHandler::NewL( iStateMachine );
    71      // Create the remote control handler
    71      // Create the remote control handler
    72     iRemoteControlHandler = CPhoneRemoteControlHandler::NewL( iStateMachine );
    72     iRemoteControlHandler = CPhoneRemoteControlHandler::NewL( iStateMachine );
    73     // Create the key event forwarder
    73     // Create the key event forwarder
    74     iKeyEventForwarder = CPhoneKeyEventForwarder::NewL( 
    74     iKeyEventForwarder = CPhoneKeyEventForwarder::NewL( 
    75         CEikonEnv::Static()->EikAppUi()->ClientRect(), iStateMachine, aViewCommandHandle );
    75         CEikonEnv::Static()->EikAppUi()->ClientRect(), iStateMachine, &aViewController );
    76 
    76 
    77     TInt leaveCode( 0 );
    77     TInt leaveCode( 0 );
    78     TInt retry( 0 );
    78     TInt retry( 0 );
    79     RTimer timer;
    79     RTimer timer;
    80     TRequestStatus timerReady;
    80     TRequestStatus timerReady;
   110         ( CCoeEnv::Static( KUidPhoneUILoggerSingleton ) );
   110         ( CCoeEnv::Static( KUidPhoneUILoggerSingleton ) );
   111     phoneLogger->SetPhoneEngine( iPhoneEngine );
   111     phoneLogger->SetPhoneEngine( iPhoneEngine );
   112 
   112 
   113     // Store the phone engine information in the state machine
   113     // Store the phone engine information in the state machine
   114     iStateMachine->SetPhoneEngine( iPhoneEngine );
   114     iStateMachine->SetPhoneEngine( iPhoneEngine );
   115 
   115 	
       
   116 	// Set up security mode observer.
       
   117 	iSecurityModeObserver = CPhoneSecurityModeObserver::NewL();
       
   118 	iSecurityModeObserver->SetPhoneEngineInfo( iPhoneEngine->EngineInfo() );
       
   119 	iStateMachine->SetSecurityModeObserver( iSecurityModeObserver );
       
   120 	iStateMachine->SetSecurityMessageHandler( iSecurityModeObserver );
       
   121 	
   116     // Set Number Entry observer
   122     // Set Number Entry observer
   117     TPhoneCmdParamNumberEntryObserver cmdParamNumberEntryObserver;
   123     TPhoneCmdParamNumberEntryObserver cmdParamNumberEntryObserver;
   118     cmdParamNumberEntryObserver.SetObserver( TCallBack( HandlePhoneNumberEditorCallBack, this ) );
   124     cmdParamNumberEntryObserver.SetObserver( TCallBack( HandlePhoneNumberEditorCallBack, this ) );
   119     aViewCommandHandle->ExecuteCommand( EPhoneViewSetNumberEntryObserver, 
   125     aViewController.ExecuteCommand( EPhoneViewSetNumberEntryObserver, 
   120                                             &cmdParamNumberEntryObserver);
   126                                             &cmdParamNumberEntryObserver);
   121     
   127     
       
   128 	// Set up controller to observe security mode state changes.
       
   129     iStateMachine->SecurityMode()->RegisterStateObserver( aViewController );
       
   130 	
   122     // Go to the startup state
   131     // Go to the startup state
   123     iStateMachine->ChangeState( EPhoneStateStartup );
   132     iStateMachine->ChangeState( EPhoneStateStartup );
   124 
   133 
   125 	  CPhoneMediatorFactory::Instance()->CommandListener( this, iStateMachine,
   134 	  CPhoneMediatorFactory::Instance()->CommandListener( this, iStateMachine,
   126 		    iStateMachine->PhoneEngineInfo() );
   135 		    iStateMachine->PhoneEngineInfo() );
   130 // CPhoneUIController::NewL
   139 // CPhoneUIController::NewL
   131 // Two-phased constructor.
   140 // Two-phased constructor.
   132 // -----------------------------------------------------------------------------
   141 // -----------------------------------------------------------------------------
   133 //
   142 //
   134 EXPORT_C CPhoneUIController* CPhoneUIController::NewL( 
   143 EXPORT_C CPhoneUIController* CPhoneUIController::NewL( 
   135     MPhoneViewCommandHandle* aViewCommandHandle )
   144     CPhoneViewController& aViewCommandHandle )
   136     {
   145     {
   137 	__ASSERT_DEBUG( aViewCommandHandle,
   146 
   138 		Panic( EPhoneCtrlParameterNotInitialized ) );
   147     CPhoneUIController* self = new( ELeave ) CPhoneUIController();
   139     
       
   140     CPhoneUIController* self = new( ELeave ) CPhoneUIController;
       
   141     
   148     
   142     CleanupStack::PushL( self );
   149     CleanupStack::PushL( self );
   143     self->ConstructL( aViewCommandHandle );
   150     self->ConstructL( aViewCommandHandle );
   144     CleanupStack::Pop( self );
   151     CleanupStack::Pop( self );
   145 
   152 
   152 // -----------------------------------------------------------
   159 // -----------------------------------------------------------
   153 
   160 
   154 EXPORT_C CPhoneUIController::~CPhoneUIController()
   161 EXPORT_C CPhoneUIController::~CPhoneUIController()
   155     {
   162     {
   156     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::~CPhoneUIController()");
   163     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::~CPhoneUIController()");
       
   164 	delete iSecurityModeObserver;
   157 	delete iRemoteControlHandler;
   165 	delete iRemoteControlHandler;
   158 	delete iSystemEventHandler;
   166 	delete iSystemEventHandler;
   159 	delete iEngineHandler;
   167 	delete iEngineHandler;
   160 	delete iKeyEventForwarder;
   168 	delete iKeyEventForwarder;
   161 //    delete iStateHandle; <-- CCoeStatic objects are destroyed outside application
   169 //    delete iStateHandle; <-- CCoeStatic objects are destroyed outside application
   322 //
   330 //
   323 EXPORT_C TBool CPhoneUIController::HandleCommandL( TInt aCommand )
   331 EXPORT_C TBool CPhoneUIController::HandleCommandL( TInt aCommand )
   324     {
   332     {
   325     __ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) );
   333     __ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) );
   326 
   334 
   327     
       
   328 	// Send key up message to engine so that we wouldn't accidentally play
   335 	// Send key up message to engine so that we wouldn't accidentally play
   329 	// any DTMF tone.
   336 	// any DTMF tone.
   330     
   337     
   331     // DTMF tone is not ended if command is EPhoneDialerValidNumber or
   338     // DTMF tone is not ended if command is EPhoneDialerValidNumber or
   332     // EPhoneDialerInvalidNumber. These commands result from
   339     // EPhoneDialerInvalidNumber. These commands result from
   351 
   358 
   352 // ---------------------------------------------------------
   359 // ---------------------------------------------------------
   353 // CPhoneUIController::CreateProtocolDllL
   360 // CPhoneUIController::CreateProtocolDllL
   354 // ---------------------------------------------------------
   361 // ---------------------------------------------------------
   355 //
   362 //
   356 void CPhoneUIController::CreateProtocolDllL( 
   363 void CPhoneUIController::CreateProtocolDllL( CPhoneViewController& aViewController )
   357 	MPhoneViewCommandHandle* aViewCommandHandle )
       
   358 	{
   364 	{
   359 	TBool voipSupported( EFalse );
   365 	TBool voipSupported( EFalse );
   360 
   366 
   361     if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
   367     if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
   362 	    {
   368 	    {
   371 	    }
   377 	    }
   372 
   378 
   373     if( voipSupported )
   379     if( voipSupported )
   374 	    {
   380 	    {
   375 	    iStateHandle = CPhoneStateHandle::CreateL(
   381 	    iStateHandle = CPhoneStateHandle::CreateL(
   376 	        aViewCommandHandle,
   382 	        &aViewController,
   377 	        KVoIPExtension,
   383 	        KVoIPExtension,
   378 	        KUidAppVoIPExtensionStates );				    	
   384 	        KUidAppVoIPExtensionStates );				    	
   379 	    }
   385 	    }
   380 	else
   386 	else
   381 		{
   387 		{
   382 	    iStateHandle = CPhoneStateHandle::CreateL(
   388 	    iStateHandle = CPhoneStateHandle::CreateL(
   383 	        aViewCommandHandle,
   389 	        &aViewController,
   384 	        KGSMProtocol,
   390 	        KGSMProtocol,
   385 	        KUidAppGSMStates );			
   391 	        KUidAppGSMStates );			
   386 		}		
   392 		}		
   387 	}
   393 	}
   388 
   394