phoneapp/phoneuicontrol/src/cphoneuicontroller.cpp
branchRCL_3
changeset 61 41a7f70b3818
parent 58 40a3f856b14d
child 62 5266b1f337bd
--- a/phoneapp/phoneuicontrol/src/cphoneuicontroller.cpp	Thu Aug 19 09:54:27 2010 +0300
+++ b/phoneapp/phoneuicontrol/src/cphoneuicontroller.cpp	Tue Aug 31 15:14:29 2010 +0300
@@ -19,7 +19,6 @@
 // INCLUDE FILES
 #include <featmgr.h>        // for FeatureManager
 #include <settingsinternalcrkeys.h>
-#include <phoneappcommands.hrh>
 
 #include "cphoneuicontroller.h"
 #include "pevirtualengine.h"
@@ -27,16 +26,14 @@
 #include "cphoneenginehandler.h"
 #include "cphonesystemeventhandler.h"
 #include "cphoneremotecontrolhandler.h"
+#include "mphoneviewcommandhandle.h"
 #include "phonestatedefinitions.h"
 #include "phonelogger.h"
 #include "phoneconstants.h"
 #include "phoneui.pan"
-#include "cphonekeyeventforwarder.h"
 #include "cphonecenrepproxy.h"
 #include "cphonemediatorfactory.h"
 #include "tphonecmdparamnumberentryobserver.h"
-#include "cphonesecuritymodeobserver.h"
-#include "cphoneviewcontroller.h"
 
 // ================= MEMBER FUNCTIONS =======================
 
@@ -55,11 +52,12 @@
 // (other items were commented in a header).
 // -----------------------------------------------------------
 //
-void CPhoneUIController::ConstructL( CPhoneViewController& aViewController )
+void CPhoneUIController::ConstructL( 
+    MPhoneViewCommandHandle* aViewCommandHandle )
     {
     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::ConstructL()");
     // Creates correct protocol DLL
-    CreateProtocolDllL( aViewController );
+    CreateProtocolDllL( aViewCommandHandle );
 
     // Reference the phone state machine
     iStateMachine = CPhoneStateHandle::Instance()->StateMachine();
@@ -68,10 +66,8 @@
     iEngineHandler = CPhoneEngineHandler::NewL( iStateMachine );
     // Create the system event handler
     iSystemEventHandler = CPhoneSystemEventHandler::NewL( iStateMachine );
-
-    // Create the key event forwarder
-    iKeyEventForwarder = CPhoneKeyEventForwarder::NewL( 
-        CEikonEnv::Static()->EikAppUi()->ClientRect(), iStateMachine, &aViewController ); // codescanner::eikonenvstatic
+     // Create the remote control handler
+    iRemoteControlHandler = CPhoneRemoteControlHandler::NewL( iStateMachine );
 
     TInt leaveCode( 0 );
     TInt retry( 0 );
@@ -111,27 +107,12 @@
 
     // Store the phone engine information in the state machine
     iStateMachine->SetPhoneEngine( iPhoneEngine );
-	
-	// Set up security mode observer.
-	iSecurityModeObserver = CPhoneSecurityModeObserver::NewL();
-	iSecurityModeObserver->SetPhoneEngineInfo( iPhoneEngine->EngineInfo() );
-	iStateMachine->SetSecurityModeObserver( iSecurityModeObserver );
-	iStateMachine->SetSecurityMessageHandler( iSecurityModeObserver );
-	
-    // Set Number Entry observer
-    TPhoneCmdParamNumberEntryObserver cmdParamNumberEntryObserver;
-    cmdParamNumberEntryObserver.SetObserver( TCallBack( HandlePhoneNumberEditorCallBack, this ) );
-    aViewController.ExecuteCommand( EPhoneViewSetNumberEntryObserver, 
-                                            &cmdParamNumberEntryObserver);
     
-	// Set up controller to observe security mode state changes.
-    iStateMachine->SecurityMode()->RegisterStateObserver( aViewController );
-	
     // Go to the startup state
     iStateMachine->ChangeState( EPhoneStateStartup );
 
-	  CPhoneMediatorFactory::Instance()->CommandListener( this, iStateMachine,
-		    iStateMachine->PhoneEngineInfo() );
+      CPhoneMediatorFactory::Instance()->CommandListener( this, iStateMachine,
+            iStateMachine->PhoneEngineInfo() );
     }
 
 // -----------------------------------------------------------------------------
@@ -140,10 +121,12 @@
 // -----------------------------------------------------------------------------
 //
 EXPORT_C CPhoneUIController* CPhoneUIController::NewL( 
-    CPhoneViewController& aViewCommandHandle )
+    MPhoneViewCommandHandle* aViewCommandHandle )
     {
-
-    CPhoneUIController* self = new( ELeave ) CPhoneUIController();
+    __ASSERT_DEBUG( aViewCommandHandle,
+        Panic( EPhoneCtrlParameterNotInitialized ) );
+    
+    CPhoneUIController* self = new( ELeave ) CPhoneUIController;
     
     CleanupStack::PushL( self );
     self->ConstructL( aViewCommandHandle );
@@ -160,12 +143,10 @@
 EXPORT_C CPhoneUIController::~CPhoneUIController()
     {
     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneUIController::~CPhoneUIController()");
-	delete iSecurityModeObserver;
-	delete iRemoteControlHandler;
-	delete iSystemEventHandler;
-	delete iEngineHandler;
-	delete iKeyEventForwarder;
-//    delete iStateHandle; <-- CCoeStatic objects are destroyed outside application
+    delete iRemoteControlHandler;
+    delete iSystemEventHandler;
+    delete iEngineHandler;
+    delete iStateHandle;
     }
 
 // ---------------------------------------------------------
@@ -177,14 +158,6 @@
     const TInt aCallId ) 
     {
     __PHONELOGENGINEMSG( aMessage, aCallId );
-    
-    // PhoneCmdHandler is using Call information API so 
-	// Remote Control Handler can be constructed only after CCCE is constructed.
-	if ( aMessage == EPEMessagePEConstructionReady )
-		{
-		TRAP_IGNORE( ConstructRemoteControlHandlerL() );
-		}
-        	
     TRAPD( err, iEngineHandler->DoHandleMessageL( aMessage, aCallId ) );
 
     if ( err != KErrNone )
@@ -209,7 +182,7 @@
     {
     TInt err( KErrNone );
     
-   	TRAP( err, iStateMachine->State()->HandleErrorL( aErrorInfo ) );	    	
+       TRAP( err, iStateMachine->State()->HandleErrorL( aErrorInfo ) );            
     
     if( err != KErrNone )
         {
@@ -218,7 +191,7 @@
             EPhoneControl,
             "PHONEUI_ERROR: CPhoneUIController::HandleError -  leave (err=%d)",
             err);
-       	__ASSERT_DEBUG( EFalse, Panic( EPhoneCtrlUnknownPanic ) );
+           __ASSERT_DEBUG( EFalse, Panic( EPhoneCtrlUnknownPanic ) );
         }
     }    
 
@@ -230,34 +203,26 @@
     const TKeyEvent& aKeyEvent,
     TEventCode aEventCode )
     {
-    __ASSERT_DEBUG( iKeyEventForwarder, Panic( EPhoneCtrlInvariant ) );
-    return iKeyEventForwarder->OfferKeyEventAfterControlStackL( 
-                aKeyEvent,
-                aEventCode );
-    }
-
-// ---------------------------------------------------------
-// CPhoneUIController::DynInitMenuPaneL
-// ---------------------------------------------------------
-//
-EXPORT_C void CPhoneUIController::DynInitMenuPaneL( 
-    TInt aResourceId, 
-    CEikMenuPane* aMenuPane )
-    {
-    __ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
-    iSystemEventHandler->DynInitMenuPaneL( aResourceId, aMenuPane );
-    }
-
-// ---------------------------------------------------------
-// CPhoneUIController::DynInitMenuBarL
-// ---------------------------------------------------------
-//
-EXPORT_C void CPhoneUIController::DynInitMenuBarL( 
-    TInt aResourceId, 
-    CEikMenuBar* aMenuBar )
-    {
-    __ASSERT_DEBUG( iSystemEventHandler, Panic( EPhoneCtrlInvariant ) );
-    iSystemEventHandler->DynInitMenuBarL( aResourceId, aMenuBar );
+    if ( aEventCode == EEventKey )
+        {
+        iStateMachine->State()->HandleKeyMessageL( 
+                        MPhoneKeyEvents::EPhoneKeyShortPress, 
+                        TKeyCode( aKeyEvent.iCode ) );
+        
+        iStateMachine->State()->HandleDtmfKeyToneL( aKeyEvent, aEventCode );
+        }
+    else if ( aEventCode == EEventLongPress )
+        {
+        iStateMachine->State()->HandleKeyMessageL( 
+                        MPhoneKeyEvents::EPhoneKeyLongPress, 
+                        TKeyCode( aKeyEvent.iCode ) );    
+        }
+    else 
+        {
+        iStateMachine->State()->HandleDtmfKeyToneL( aKeyEvent, aEventCode );
+        }
+        
+    return EKeyWasNotConsumed;
     }
 
 // ---------------------------------------------------------
@@ -339,17 +304,6 @@
     {
     __ASSERT_DEBUG( iStateMachine->State(), Panic( EPhoneCtrlInvariant ) );
 
-	// Send key up message to engine so that we wouldn't accidentally play
-	// any DTMF tone.
-    
-    // DTMF tone is not ended if command is EPhoneDialerValidNumber or
-    // EPhoneDialerInvalidNumber. These commands result from
-    // user pressing numbers, and they must not interfere with tones.
-    if ( ! ( aCommand == EPhoneDialerValidNumber || aCommand == EPhoneDialerInvalidNumber ) )
-        {
-        iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageEndDTMF );
-        }
-
     return iStateMachine->State()->HandleCommandL( aCommand );
     }
 
@@ -363,41 +317,52 @@
     return iStateMachine->State()->ProcessCommandL( aCommand );
     }
 
+
+// ---------------------------------------------------------
+// CPhoneUIController::HandleKeyLockEnabled
+// ---------------------------------------------------------
+//
+EXPORT_C void CPhoneUIController::HandleKeyLockEnabled( TBool aKeylockEnabled )
+    {
+    iSystemEventHandler->HandleKeyLockEnabled( aKeylockEnabled );
+    }
+
 // ---------------------------------------------------------
 // CPhoneUIController::CreateProtocolDllL
 // ---------------------------------------------------------
 //
-void CPhoneUIController::CreateProtocolDllL( CPhoneViewController& aViewController )
-	{
-	TBool voipSupported( EFalse );
+void CPhoneUIController::CreateProtocolDllL( 
+    MPhoneViewCommandHandle* aViewCommandHandle )
+    {
+    TBool voipSupported( EFalse );
 
     if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
-	    {
-	    TInt dynamicVoIP( KDynamicVoIPOff );
-		CPhoneCenRepProxy::Instance()->GetInt( 
-	        KCRUidTelephonySettings, KDynamicVoIP, dynamicVoIP );
-	        
-	    if( dynamicVoIP == KDynamicVoIPOn )
-		    {
-			voipSupported = ETrue;		    	
-		    }
-	    }
+        {
+        TInt dynamicVoIP( KDynamicVoIPOff );
+        CPhoneCenRepProxy::Instance()->GetInt( 
+            KCRUidTelephonySettings, KDynamicVoIP, dynamicVoIP );
+            
+        if( dynamicVoIP == KDynamicVoIPOn )
+            {
+            voipSupported = ETrue;                
+            }
+        }
 
     if( voipSupported )
-	    {
-	    iStateHandle = CPhoneStateHandle::CreateL(
-	        &aViewController,
-	        KVoIPExtension,
-	        KUidAppVoIPExtensionStates );				    	
-	    }
-	else
-		{
-	    iStateHandle = CPhoneStateHandle::CreateL(
-	        &aViewController,
-	        KGSMProtocol,
-	        KUidAppGSMStates );			
-		}		
-	}
+        {
+        iStateHandle = CPhoneStateHandle::CreateL(
+            aViewCommandHandle,
+            KVoIPExtension,
+            KUidAppVoIPExtensionStates );                        
+        }
+    else
+        {
+        iStateHandle = CPhoneStateHandle::CreateL(
+            aViewCommandHandle,
+            KGSMProtocol,
+            KUidAppGSMStates );            
+        }        
+    }
 
 // ---------------------------------------------------------
 // CPhoneUIController::HandlePhoneNumberEditorCallBack
@@ -419,17 +384,6 @@
 //
 void CPhoneUIController::DoHandlePhoneNumberEditorCallBack()
     {
-    iStateMachine->State()->HandleNumberEntryEdited();
-    }
-
-// ---------------------------------------------------------
-// CPhoneUIController::ConstructRemoteControlHandlerL
-// ---------------------------------------------------------
-//
-void CPhoneUIController::ConstructRemoteControlHandlerL()
-    { 
-	// Create the remote control handler
-	iRemoteControlHandler = CPhoneRemoteControlHandler::NewL( iStateMachine );
     }
 
 //  End of File