phoneapp/phoneuistates/src/cphonesinglecall.cpp
branchRCL_3
changeset 62 5266b1f337bd
parent 61 41a7f70b3818
child 69 8baf28733c3d
--- a/phoneapp/phoneuistates/src/cphonesinglecall.cpp	Tue Aug 31 15:14:29 2010 +0300
+++ b/phoneapp/phoneuistates/src/cphonesinglecall.cpp	Wed Sep 01 12:30:10 2010 +0100
@@ -27,7 +27,7 @@
 #include <connect/sbdefs.h>
 #include <videotelcontrolmediatorapi.h>
 #include <MediatorDomainUIDs.h>
-#include <telephonyvariant.hrh>
+#include <ScreensaverInternalPSKeys.h>
 
 #include "cphonesinglecall.h"
 #include "tphonecmdparamstring.h"
@@ -47,8 +47,6 @@
 #include "cphonemediatorfactory.h"
 #include "cphonemediatorsender.h"
 #include "cphoneswitchtovideoorvoicecommand.h"
-#include "mphonestorage.h"
-#include "cphonecenrepproxy.h"
 
 // ================= MEMBER FUNCTIONS =======================
 
@@ -116,7 +114,14 @@
 
     iCallId = callStateData.CallId();
     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
-      
+
+    CPhonePubSubProxy::Instance()->ChangePropertyValue(
+                    KPSUidScreenSaver,
+                    KScreenSaverAllowScreenSaver,
+                    EPhoneScreensaverAllowed );
+    
+    // Update phone number availability for menu use
+    PhoneNumberAvailableInPhoneEngineL( callStateData.CallId() );
     }
 
 // -----------------------------------------------------------
@@ -223,7 +228,7 @@
             break;
                 
         case MEngineMonitor::EPEMessageDialing:
-            HandleDiallingL( aCallId );
+            HandleDialingL( aCallId );
             break;
         
         /* Flow through */ 
@@ -234,7 +239,7 @@
             break;
         
         case MEngineMonitor::EPEMessageInValidEmergencyNumber:
-            SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed, ETrue );
+            SendGlobalErrorNoteL( EPhoneNoteTextNotAllowed );
             break;
             
         case MEngineMonitor::EPEMessageValidEmergencyNumber:
@@ -265,9 +270,11 @@
             break;
             
         case EPhoneInCallCmdNewCall:
+            LaunchNewCallQueryL();
             break;
             
         case EPhoneInCallCmdNewCallCall:
+            CallFromNewCallQueryL();
             break;
 
         case EPhoneInCallCmdSwitchToVideo:
@@ -288,28 +295,30 @@
         /* Flow through */ 
         case EPhoneCmdNoSwitchToVideo:
         case EPhoneCmdNoSwitchToVoice:
+            // Sets touch buttons to correct status if 'No' command has occured.    
+            iViewCommandHandle->ExecuteCommand( EPhoneResetTouchButtons );    
             break;        
                 
         case EPhoneCmdYesSwitchToVoice:
             // Set current call id
             iStateMachine->SetCallId( iCallId );
-                        if( IsVideoCall( iCallId ) )
-                        {
-                           // Video call can be released only after we get response to VT Shutdown Command
-                           CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
-                                                                                      KCatPhoneToVideotelCommands, 
-                                                                                      EVtCmdReleaseDataport,
-                                                                                      TVersion( KPhoneToVideotelCmdVersionMajor,
-                                                                                            KPhoneToVideotelCmdVersionMinor, 
-                                                                                            KPhoneToVideotelCmdVersionBuild ),
-                                                                                      KNullDesC8,
-                                                                                      CPhoneSwitchToVideoOrVoiceCommand::NewL( *iStateMachine ) );
-                        }
-                        else
-                        {
-                          iStateMachine->SendPhoneEngineMessage(
-                              CPEPhoneModelIF::EPEMessageSwitchToVideoOrVoice );                    
-                        }
+						if( IsVideoCall( iCallId ) )
+						{
+						   // Video call can be released only after we get response to VT Shutdown Command
+						   CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( KMediatorVideoTelephonyDomain,
+						                                                              KCatPhoneToVideotelCommands, 
+						                                                              EVtCmdReleaseDataport,
+						                                                              TVersion( KPhoneToVideotelCmdVersionMajor,
+						            	                                                    KPhoneToVideotelCmdVersionMinor, 
+						            	                                                    KPhoneToVideotelCmdVersionBuild ),
+						                                                              KNullDesC8,
+						                                                              CPhoneSwitchToVideoOrVoiceCommand::NewL( *iStateMachine ) );
+						}
+						else
+						{
+						  iStateMachine->SendPhoneEngineMessage(
+						      CPEPhoneModelIF::EPEMessageSwitchToVideoOrVoice );					
+						}
             break;
 
         case EPhoneVideoSharing:
@@ -332,6 +341,24 @@
     }
 
 // -----------------------------------------------------------
+// CPhoneSingleCall::OpenMenuBarL
+// -----------------------------------------------------------
+//
+EXPORT_C void CPhoneSingleCall::OpenMenuBarL()
+    {
+    __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneSingleCall::OpenMenuBarL()");
+
+    if ( IsVideoCall ( iCallId ))
+        {
+        OpenVideoCallMenuBarL();
+        }
+    else
+        {
+        CPhoneGsmInCall::OpenMenuBarL();            
+        }
+    }
+
+// -----------------------------------------------------------
 // CPhoneSingleCall::CallId
 // -----------------------------------------------------------
 //
@@ -347,7 +374,26 @@
 void CPhoneSingleCall::OpenVideoCallMenuBarL()
     {
     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneSingleCall::OpenVideoCallMenuBarL()");
-                   
+    if( FeatureManager::FeatureSupported( KFeatureIdCsVideoTelephony ) )
+        {
+        TInt resourceId;
+
+        if ( IsNumberEntryUsedL() )
+            {
+            resourceId = EPhoneVideoCallMenubarWithNumberEntry;
+            }
+        else
+            {
+            resourceId = EPhoneVideoCallMenubar;
+            }
+        
+        TPhoneCmdParamInteger integerParam;
+        integerParam.SetInteger( 
+            CPhoneMainResourceResolver::Instance()->
+            ResolveResourceID( resourceId ) );
+        iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarOpen, 
+            &integerParam );
+        }                    
     }
     
 // -----------------------------------------------------------
@@ -386,7 +432,6 @@
         }
 
     UpdateInCallCbaL();
-    SetTouchPaneButtons( EPhoneIncallHeldButtons );
     }
     
 // -----------------------------------------------------------
@@ -421,7 +466,6 @@
         }
 
     UpdateInCallCbaL();  
-    SetTouchPaneButtons( EPhoneIncallButtons );
     }
     
 // -----------------------------------------------------------
@@ -432,25 +476,16 @@
     {
     __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneSingleCall::ToggleHoldL()");
-
-    TPECallControlCaps callControlCaps =
-        iStateMachine->PhoneEngineInfo()->CallControlCaps( iCallId );
-    
-    if ( callControlCaps & MCCECallObserver::ECCECapsHold  )
+    TPhoneCmdParamBoolean hold;
+    iViewCommandHandle->ExecuteCommandL( EPhoneViewGetHoldFlag, &hold );
+   
+    if( hold.Boolean() )
         {
-        iStateMachine->SetCallId( iCallId );         
-        iStateMachine->SendPhoneEngineMessage( 
-            CPEPhoneModelIF::EPEMessageHold );    
-        }
-    else if ( callControlCaps & MCCECallObserver::ECCECapsResume )
-        {
-        iStateMachine->SetCallId( iCallId );         
-        iStateMachine->SendPhoneEngineMessage( 
-            CPEPhoneModelIF::EPEMessageResume );    
+        SetCallResumeL();
         }
     else
         {
-        SendGlobalInfoNoteL( EPhoneNoteTextNotAllowed, ETrue );    
+        SetCallHoldL();
         }
     }
         
@@ -463,53 +498,44 @@
     __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneSingleCall::HandleIncomingL()");
     
+    CPhonePubSubProxy::Instance()->ChangePropertyValue(
+                    KPSUidScreenSaver,
+                    KScreenSaverAllowScreenSaver,
+                    EPhoneScreensaverNotAllowed );
+    IsNumberEntryUsedL() ? 
+        BeginTransEffectLC( ECallUiAppear ) :
+        BeginTransEffectLC( ENumberEntryOpen );
     BeginUiUpdateLC();
     
+    // Hide the number entry if it exists
+    if ( IsNumberEntryUsedL() )
+        {
+        SetNumberEntryVisibilityL( EFalse );    
+        }
+    
     TPhoneCmdParamBoolean dialerParam;
     dialerParam.SetBoolean( ETrue );
     
     // Get allow waiting call header param value.
     AllowShowingOfWaitingCallHeaderL( dialerParam );    
 
+    // Close fast swap window if it's displayed
+    EikonEnv()->DismissTaskList();
+
+    // Show incoming call buttons
+    SetTouchPaneButtons( EPhoneWaitingCallButtons );    
+
     // Display incoming call
     DisplayIncomingCallL( aCallId, dialerParam );
-    
-    // Show incoming call buttons
-    SetTouchPaneButtons( EPhoneWaitingCallButtons ); 
-    
-    if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) 
-            && !CPhoneCenRepProxy::Instance()->
-            IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) 
-            && ( IsKeyLockOn() || IsAutoLockOn() ) )
-        {
-        DisableCallUIL();
-        }
-    else
-        {
-        // if keys have been locked, disable keylock without information note
-        if ( IsKeyLockOn() )
-            {
-            iViewCommandHandle->ExecuteCommandL( EPhoneViewDisableKeyLockWithoutNote );
-            }
-        }
-    
-    if( CPhoneCenRepProxy::Instance()->
-            IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) 
-            && ( IsKeyLockOn() || IsAutoLockOn() ) )
-        {
-        DisableHWKeysL();
-        }
-        
+
     EndUiUpdate();
-
+    EndTransEffect();
     // This query is required to dismiss
     // Operation cannot be completed in waiting and single state
     if ( iSwitchToVideoQuery )
         {
         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
         }
-    
-    // Go to incoming state
     UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
     iStateMachine->ChangeState( EPhoneStateWaitingInSingle );        
     }
@@ -520,32 +546,26 @@
 //
 void CPhoneSingleCall::DisplayIncomingCallL( 
     TInt aCallId, 
-    const TPhoneCmdParamBoolean aCommandParam )
+    const TPhoneCmdParamBoolean /*aCommandParam*/ )
     {
     __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneSingleCall::DisplayIncomingCallL()");
+    // Close menu bar, if it is displayed
+    iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
 
-    // Cannot delete active note, e.g. New call query, 
-    // but show waiting note with or without caller name
-    if ( IsAnyQueryActiveL() || 
-        ( !aCommandParam.Boolean() && iOnScreenDialer ) )
+    // Remove any phone dialogs if they are displayed
+    iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
+
+    // if keys have been locked, disable keylock without information note
+    if ( IsKeyLockOn() )
         {
-        CallWaitingNoteL( aCallId );        
-        }
-    else
-        {
-        // Remove any phone dialogs if they are displayed
-        iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
+        iViewCommandHandle->ExecuteCommandL( EPhoneViewDisableKeyLockWithoutNote );
         }
     
     // Indicate that the Phone needs to be sent to the background if
     // an application other than the top application is in the foreground
-    TPhoneCmdParamBoolean booleanParam;
-    booleanParam.SetBoolean( !TopAppIsDisplayedL() );
-    iViewCommandHandle->ExecuteCommandL( 
-        EPhoneViewSetNeedToSendToBackgroundStatus,
-        &booleanParam );
-
+    SetNeedToReturnToForegroundAppStatusL( !TopAppIsDisplayedL() );
+    
     // Bring Phone app in the foreground
     TPhoneCmdParamInteger uidParam;
     uidParam.SetInteger( KUidPhoneApplication.iUid );
@@ -558,54 +578,112 @@
 
     DisplayHeaderForCallComingInL( aCallId, ETrue ); //waiting call 
     }    
+    
+// ---------------------------------------------------------
+// CPhoneSingleCall::CallFromNewCallQueryL
+// ---------------------------------------------------------
+//
+void CPhoneSingleCall::CallFromNewCallQueryL()
+    {
+    __LOGMETHODSTARTEND( EPhoneUIStates, 
+        "CPhoneSingleCall::CallFromNewCallQueryL()");
+    // First get the phone number from the dialog
+    TPhoneCmdParamString phoneNumberParam;
+    HBufC *content = HBufC::NewLC( KPhoneNumberEntryBufferSize );
+    TPtr ptr( content->Des() );
+    phoneNumberParam.SetString( &ptr );
+    iViewCommandHandle->ExecuteCommandL( EPhoneViewGetTextQueryContent,
+        &phoneNumberParam );
+
+    // Store the phone number
+    iStateMachine->PhoneEngineInfo()->SetPhoneNumber( ptr );
+
+    // clean up stack
+    CleanupStack::PopAndDestroy( content );
+    
+    DialVoiceCallL();
+    }
+
 // -----------------------------------------------------------
-// CPhoneSingleCall::HandleDiallingL
+// CPhoneSingleCall::HandleDialingL
 // -----------------------------------------------------------
 //
-void CPhoneSingleCall::HandleDiallingL( TInt aCallId )
+void CPhoneSingleCall::HandleDialingL( TInt aCallId )
     {
     __LOGMETHODSTARTEND( EPhoneUIStates, 
-        "CPhoneSingleCall::HandleDiallingL()");
-    BeginUiUpdateLC();
+        "CPhoneSingleCall::HandleDialingL()");
     
-    SetNumberEntryVisibilityL(EFalse);
-
+    CPhonePubSubProxy::Instance()->ChangePropertyValue(
+                    KPSUidScreenSaver,
+                    KScreenSaverAllowScreenSaver,
+                    EPhoneScreensaverNotAllowed );
     // Display call setup 
     DisplayCallSetupL( aCallId );
-    
+    iStateMachine->ChangeState( EPhoneStateCallSetupInSingle );
+    }
+
+// -----------------------------------------------------------
+// CPhoneSingleCall::DoStateSpecificCallSetUpDefinitionsL
+// -----------------------------------------------------------
+//
+EXPORT_C void CPhoneSingleCall::DoStateSpecificCallSetUpDefinitionsL()
+    {
     // Show incoming call buttons
     SetTouchPaneButtons( EPhoneCallSetupAndSingleButtons );
-
-    EndUiUpdate();
+    }
 
-    // Go to call setup state
-    UpdateCbaL( EPhoneCallHandlingCallSetupCBA );
-    iStateMachine->ChangeState( EPhoneStateCallSetupInSingle );
+// -----------------------------------------------------------
+// CPhoneSingleCall::SetCallHoldL
+// -----------------------------------------------------------
+//
+void CPhoneSingleCall::SetCallHoldL()
+    {
+    __LOGMETHODSTARTEND( EPhoneUIStates, 
+        "CPhoneSingleCall::SetCallHold()");
+    
+    TPhoneCmdParamCallStateData callStateData;
+    callStateData.SetCallId( iCallId );
+    iViewCommandHandle->HandleCommandL( EPhoneViewGetCallState,
+        &callStateData );
+    
+    if( callStateData.CallState() == EPEStateConnected && !IsVideoCallActiveL() )
+        {
+        iStateMachine->SetCallId( iCallId );         
+        iStateMachine->SendPhoneEngineMessage( 
+            CPEPhoneModelIF::EPEMessageHold );    
+        }
+    else
+        {
+        // Show not allowed note
+        SendGlobalInfoNoteL( EPhoneNoteTextNotAllowed );    
+        }
     }
     
 // -----------------------------------------------------------
-// CPhoneSingleCall::DisplayCallSetupL
+// CPhoneSingleCall::SetCallResumeL
 // -----------------------------------------------------------
 //
-void CPhoneSingleCall::DisplayCallSetupL( TInt aCallId )
+void CPhoneSingleCall::SetCallResumeL()
     {
     __LOGMETHODSTARTEND( EPhoneUIStates, 
-        "CPhoneSingleCall::DisplayCallSetupL()");
-
-    // Remove dialogs if necessary
-    iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
-
-    // Capture keys when the phone is dialling
-    CaptureKeysDuringCallNotificationL( ETrue );
+        "CPhoneSingleCall::SetCallHold()");
 
-    // Force telephony to the foreground
-    TPhoneCmdParamInteger uidParam;
-    uidParam.SetInteger( KUidPhoneApplication.iUid );
-    iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
-        &uidParam );
-
-    // Display call setup header
-    DisplayHeaderForOutgoingCallL( aCallId );
+    TPhoneCmdParamCallStateData callStateData;
+    callStateData.SetCallId( iCallId );
+    iViewCommandHandle->HandleCommandL( EPhoneViewGetCallState,
+        &callStateData );
+    
+    if( callStateData.CallState() == EPEStateHeld )
+        {
+        iStateMachine->SetCallId( iCallId );
+        iStateMachine->SendPhoneEngineMessage(
+            CPEPhoneModelIF::EPEMessageResume );
+        }
+    else
+        {
+        // Show not allowed note
+        SendGlobalInfoNoteL( EPhoneNoteTextNotAllowed );    
+        }                
     }
 
 // -----------------------------------------------------------
@@ -618,28 +696,38 @@
         "CPhoneSingleCall::SwitchToVideoL()");
 
     if( FeatureManager::FeatureSupported( KFeatureIdCsVideoTelephony ) )
-        {        
+    	{        
         TInt networkMode( CPhonePubSubProxy::Instance()->Value( KPSUidNetworkInfo,
             KNWTelephonyNetworkMode ) );
         TBool restoreOngoing( CPhonePubSubProxy::Instance()->Value( KUidSystemCategory,
             conn::KUidBackupRestoreKey ));
+    
+        TBool resetTouchButtons = EFalse;
         
         if ( networkMode != ENWNetworkModeWcdma )
             {
             // We aren't in 3G, video call not possible
             SendGlobalInfoNoteL( EPhoneInformationNoNetworkSupportForVideoCallNote );    
+            resetTouchButtons = ETrue;
             }
         else if ( restoreOngoing & ( conn::EBURRestoreFull | conn::EBURRestorePartial ))
             {
             // MC restore ongoing
             SendGlobalInfoNoteL( EPhoneInformationVideoCallNotAllowedDuringRestoreNote );
+            resetTouchButtons = ETrue;    
             }
         else
             {
-            iSwitchToVideoQuery = ETrue;
-            //ShowQueryL( EPhoneSwitchToVideoQuery );
-            iSwitchToVideoQuery = EFalse;
-            }    
+        iSwitchToVideoQuery = ETrue;
+        ShowQueryL( EPhoneSwitchToVideoQuery );
+        iSwitchToVideoQuery = EFalse;
+        }    
+    
+        if( resetTouchButtons )
+            {
+            // Sets touch buttons to correct status if error has occured.    
+            iViewCommandHandle->ExecuteCommand( EPhoneResetTouchButtons ); 
+            }
         }
     }
 
@@ -652,7 +740,7 @@
     __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneSingleCall::SwitchToVoiceL()");
     
-    //ShowQueryL( EPhoneSwitchToVoiceQuery );
+    ShowQueryL( EPhoneSwitchToVoiceQuery );
     }
 
 // End of File