phoneapp/phoneuistates/src/cphoneconferenceandsingleandwaiting.cpp
branchRCL_3
changeset 25 5266b1f337bd
parent 24 41a7f70b3818
child 26 8baf28733c3d
--- a/phoneapp/phoneuistates/src/cphoneconferenceandsingleandwaiting.cpp	Tue Aug 31 15:14:29 2010 +0300
+++ b/phoneapp/phoneuistates/src/cphoneconferenceandsingleandwaiting.cpp	Wed Sep 01 12:30:10 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -32,19 +32,16 @@
 #include "phonerssbase.h"
 #include "tphonecmdparamglobalnote.h"
 #include "phoneui.hrh"
-#include "mphonestorage.h"
-#include "cphonecenrepproxy.h"
-#include <telephonyvariant.hrh>
 
 // ================= MEMBER FUNCTIONS =======================
 
 // C++ default constructor can NOT contain any code, that
 // might leave.
 //
-CPhoneConferenceAndSingleAndWaiting::CPhoneConferenceAndSingleAndWaiting(
-    MPhoneStateMachine* aStateMachine,
+CPhoneConferenceAndSingleAndWaiting::CPhoneConferenceAndSingleAndWaiting( 
+    MPhoneStateMachine* aStateMachine, 
     MPhoneViewCommandHandle* aViewCommandHandle,
-    MPhoneCustomization* aPhoneCustomization ) :
+    MPhoneCustomization* aPhoneCustomization ) : 
     CPhoneConferenceAndSingle( aStateMachine, aViewCommandHandle, aPhoneCustomization )
     {
     }
@@ -57,6 +54,16 @@
 //
 CPhoneConferenceAndSingleAndWaiting::~CPhoneConferenceAndSingleAndWaiting()
     {
+    // Need to check iViewCommandHandle validity here to not
+    // trigger a high/can panic error in a Codescanner run.
+    // coverity[var_compare_op]
+    if ( iViewCommandHandle )
+        {
+        TPhoneCmdParamBoolean dtmfSendFlag;
+        dtmfSendFlag.SetBoolean( EFalse );
+        TRAP_IGNORE( iViewCommandHandle->ExecuteCommandL( EPhoneViewSetDtmfOptionsFlag, 
+    	&dtmfSendFlag ) );
+        }
     }
 
 // -----------------------------------------------------------
@@ -76,18 +83,18 @@
 // (other items were commented in a header).
 // -----------------------------------------------------------
 //
-CPhoneConferenceAndSingleAndWaiting* CPhoneConferenceAndSingleAndWaiting::NewL(
-    MPhoneStateMachine* aStateMachine,
+CPhoneConferenceAndSingleAndWaiting* CPhoneConferenceAndSingleAndWaiting::NewL( 
+    MPhoneStateMachine* aStateMachine, 
     MPhoneViewCommandHandle* aViewCommandHandle,
     MPhoneCustomization* aPhoneCustomization )
     {
-    CPhoneConferenceAndSingleAndWaiting* self = new( ELeave ) CPhoneConferenceAndSingleAndWaiting(
+    CPhoneConferenceAndSingleAndWaiting* self = new( ELeave ) CPhoneConferenceAndSingleAndWaiting( 
         aStateMachine, aViewCommandHandle, aPhoneCustomization );
-
+    
     CleanupStack::PushL( self );
     self->ConstructL();
     CleanupStack::Pop( self );
-
+    
     return self;
     }
 
@@ -95,65 +102,126 @@
 // CPhoneConferenceAndSingleAndWaiting::HandlePhoneEngineMessageL
 // -----------------------------------------------------------
 //
-void CPhoneConferenceAndSingleAndWaiting::HandlePhoneEngineMessageL(
-    const TInt aMessage,
+void CPhoneConferenceAndSingleAndWaiting::HandlePhoneEngineMessageL( 
+    const TInt aMessage, 
     TInt aCallId )
     {
     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneConferenceAndSingleAndWaiting::HandlePhoneEngineMessageL()");
     switch ( aMessage )
-        {
+        {           
         case MEngineMonitor::EPEMessageAddedConferenceMember:
             HandleAddedConferenceMemberL( aCallId );
             break;
-
+            
         case MEngineMonitor::EPEMessageIdle:
             HandleIdleL( aCallId );
             break;
-
+            
         default:
-            CPhoneConferenceAndSingle::HandlePhoneEngineMessageL( aMessage,
+            CPhoneConferenceAndSingle::HandlePhoneEngineMessageL( aMessage, 
                 aCallId );
             break;
         }
     }
 
 // -----------------------------------------------------------
+// CPhoneConferenceAndSingleAndWaiting::OpenMenuBarL
+// -----------------------------------------------------------
+//
+void CPhoneConferenceAndSingleAndWaiting::OpenMenuBarL()
+    {
+    __LOGMETHODSTARTEND( EPhoneUIStates, 
+        "CPhoneConferenceAndSingleAndWaiting::OpenMenuBarL()");
+    TInt resourceId = NULL;
+
+   // Set specific flag to view so that DTMF menu item available
+    TPhoneCmdParamBoolean dtmfSendFlag;
+    dtmfSendFlag.SetBoolean( ETrue );
+    iViewCommandHandle->ExecuteCommandL( EPhoneViewSetDtmfOptionsFlag, 
+    	&dtmfSendFlag );
+  
+
+    TPhoneCmdParamCallStateData callStateData;
+    callStateData.SetCallState( EPEStateHeld );
+    iViewCommandHandle->HandleCommandL( EPhoneViewGetCallIdByState, 
+        &callStateData );
+    if( callStateData.CallId() == KConferenceCallId )
+        {
+        // Conference call is on hold and single is active
+        if ( IsNumberEntryVisibleL() )
+            {
+            resourceId = EPhoneCallActiveHeldConfAndWaitingMenubarWithNumberEntry;
+            }
+        else if ( IsConferenceBubbleInSelectionMode() )
+            {
+            resourceId = EPhoneConfCallParticipantsDropMenubar;    
+            }                    
+        else
+            {
+            resourceId = EPhoneCallActiveHeldConfAndWaitingMenubar;
+            }
+        }
+    else if( callStateData.CallId() >= 0 )
+        {
+        // Single call is on hold and conference is active
+        if ( IsNumberEntryVisibleL() )
+            {
+            resourceId = EPhoneConfCallActiveHeldAndWaitingMenubarWithNumberEntry;
+            }
+        else if ( IsConferenceBubbleInSelectionMode() )
+            {
+            resourceId = EPhoneConfCallParticipantsDropMenubar;    
+            }                    
+        else
+            {
+            resourceId = EPhoneConfCallActiveHeldAndWaitingMenubar;
+            }
+        }
+    else
+        {
+        return; // negative call id, don't do anything            
+        }
+
+    TPhoneCmdParamInteger integerParam;
+    integerParam.SetInteger( 
+        CPhoneMainResourceResolver::Instance()->
+        ResolveResourceID( resourceId ) );
+    iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarOpen, 
+        &integerParam );
+    }
+
+// -----------------------------------------------------------
 // CPhoneConferenceAndSingleAndWaiting::HandleIdleL
 // -----------------------------------------------------------
 //
 void CPhoneConferenceAndSingleAndWaiting::HandleIdleL( TInt aCallId )
     {
-    __LOGMETHODSTARTEND( EPhoneUIStates,
+    __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneConferenceAndSingleAndWaiting::HandleIdleL()");
-
     BeginUiUpdateLC();
-    // Set touch controls
+    SetTouchPaneButtonEnabled( EPhoneCallComingCmdAnswer );
     SetTouchPaneButtons( EPhoneWaitingCallButtons );
 
-
     TPhoneCmdParamBoolean conferenceExistsForCallId;
     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetCallExistsInConference,
         aCallId, &conferenceExistsForCallId );
-
     if( conferenceExistsForCallId.Boolean() )
         {
         // Remove conference member from conference bubble
-        iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveFromConference,
+        iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveFromConference, 
             aCallId );
         }
     else
         {
-        // Remove call
         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId );
-
         TPhoneCmdParamBoolean conferenceBubbleExists;
-        iViewCommandHandle->ExecuteCommandL( EPhoneViewGetIsConference,
+        iViewCommandHandle->ExecuteCommandL( EPhoneViewGetIsConference, 
             &conferenceBubbleExists );
         if( !conferenceBubbleExists.Boolean() )
             {
             // Idle message came for conference member.
             MakeTransitionAccordingToActiveCallsL();
-            }
+            }            
         else
             {
             TPhoneCmdParamCallStateData callStateData;
@@ -187,7 +255,7 @@
 
     UpdateConferenceSecurityStatusL( aCallId );
 
-    MakeStateTransitionToConferenceAndWaitingL( KConferenceCallId );
+    MakeStateTransitionToConferenceAndWaitingL( KConferenceCallId );        
     }
 
 // -----------------------------------------------------------
@@ -196,14 +264,17 @@
 //
 void CPhoneConferenceAndSingleAndWaiting::MakeStateTransitionToConferenceAndWaitingL( TInt /*aCallId*/ )
     {
-    __LOGMETHODSTARTEND( EPhoneUIStates,
+    __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneConferenceAndSingleAndWaiting::MakeStateTransitionToConferenceAndWaitingL()");
-
-    SetTouchPaneButtons( EPhoneWaitingCallButtons );
-
-    // Check if HW Keys or Call UI should be disabled
-    CheckDisableHWKeysAndCallUIL();
-
+    if ( !IsNumberEntryUsedL() )
+        {
+        // Close menu bar, if number entry isnt open.
+        iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
+        }
+  
+    SetTouchPaneButtons( EPhoneWaitingCallButtons ); 
+    SetTouchPaneButtonEnabled( EPhoneCallComingCmdAnswer );
+    
     // Go to Conference And Waiting state
     UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
     iStateMachine->ChangeState( EPhoneStateConferenceAndWaiting );
@@ -215,49 +286,50 @@
 //
 void CPhoneConferenceAndSingleAndWaiting::MakeStateTransitionToConferenceAndSingleL( TInt /*aCallId*/ )
     {
-    __LOGMETHODSTARTEND( EPhoneUIStates,
+    __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneConferenceAndSingleAndWaiting::MakeStateTransitionToConferenceAndSingleL()");
 
-    if( /*FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke )
-        */ 1 &&  iStateMachine->PhoneStorage()->IsScreenLocked() )
+    if ( !IsNumberEntryUsedL() )
         {
-        EnableCallUIL();
+        // Close menu bar, if number entry isnt open.
+        iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );       
         }
 
-    // Reset blocked keys list
-    iStateMachine->PhoneStorage()->ResetBlockedKeysList();
-
     if ( IsNumberEntryUsedL() )
         {
-        if ( NeedToSendToBackgroundL() )
+        if ( NeedToReturnToForegroundAppL() ) 
             {
             // Return phone to the background if send to background is needed.
             iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
 
+            iViewCommandHandle->ExecuteCommandL( EPhoneViewSetControlAndVisibility );
+ 
             UpdateCbaL( EPhoneCallHandlingInCallCBA );
             }
         else
             {
             // Show the number entry if it exists
-            SetNumberEntryVisibilityL(ETrue);
+            SetNumberEntryVisibilityL(ETrue);    
             }
         }
     else
         {
         UpdateCbaL( EPhoneCallHandlingNewCallSwapCBA );
-        // If numberentry is not open just check NeedToSendToBackgroundL and
+        // If numberentry is not open just check NeedToReturnToForegroundAppL and 
         // sendbackround if needed.
-        if ( NeedToSendToBackgroundL() )
+        if ( NeedToReturnToForegroundAppL() ) 
             {
             // Return phone to the background if send to background is needed.
             iViewCommandHandle->ExecuteCommandL( EPhoneViewSendToBackground );
             }
-        }
+        }  
 
-    SetTouchPaneButtons( EPhoneConferenceAndSingleButtons );
+    SetTouchPaneButtons( EPhoneConferenceAndSingleButtons );       
+    SetTouchPaneButtonEnabled( EPhoneCallComingCmdAnswer );
+    SetTouchPaneButtonDisabled( EPhoneInCallCmdPrivate );
     // Go to conference and single state
     // CBA updates in above if-else conditions
-    iStateMachine->ChangeState( EPhoneStateConferenceAndSingle );
+    iStateMachine->ChangeState( EPhoneStateConferenceAndSingle );                             
     }
 
 // -----------------------------------------------------------
@@ -266,47 +338,50 @@
 //
 void CPhoneConferenceAndSingleAndWaiting::HandleConferenceIdleL()
     {
-    __LOGMETHODSTARTEND( EPhoneUIStates,
+    __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneConferenceAndSingleAndWaiting::HandleConferenceIdleL()");
-
-    BeginUiUpdateLC();
-
-    iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveConferenceBubble );
+    
+    BeginUiUpdateLC();    
+    
+    iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveConferenceBubble );    
+        
+    // Close menu bar, if it is displayed
+    iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
 
     // Remove any phone dialogs if they are displayed
     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
 
     MakeTransitionAccordingToActiveCallsL();
-
-    EndUiUpdate();
+    
+    EndUiUpdate();    	    
     }
 
 // --------------------------------------------------------------
 // CPhoneConferenceAndSingleAndWaiting::HandleKeyMessageL
 // --------------------------------------------------------------
 //
-void CPhoneConferenceAndSingleAndWaiting::HandleKeyMessageL(
+void CPhoneConferenceAndSingleAndWaiting::HandleKeyMessageL( 
     TPhoneKeyEventMessages aMessage,
     TKeyCode aCode )
     {
-    __LOGMETHODSTARTEND( EPhoneUIStates,
+    __LOGMETHODSTARTEND( EPhoneUIStates, 
         "CPhoneConferenceAndSingleAndWaiting::HandleKeyMessageL()");
     switch ( aCode )
         {
         // send-key
         case EKeyYes:
             if( IsNumberEntryVisibleL() )
-                {
-                CallFromNumberEntryL();
-                }
-            else
-                {
+ 				{
+                CallFromNumberEntryL();    	 					
+ 				}
+ 			else
+	 			{
                 // Not allowed to answer
-                SendGlobalWarningNoteL(
-                    EPhoneNoteTextCallNotAllowed, ETrue );
-                }
+                SendGlobalWarningNoteL( 
+                    EPhoneNoteTextCallNotAllowed );		 				
+	 			}
             break;
-
+            
         default:
             // do base operation
             CPhoneConferenceAndSingle::HandleKeyMessageL( aMessage, aCode );
@@ -315,18 +390,24 @@
     }
 
 // -----------------------------------------------------------
-// CPhoneConferenceAndSingleAndWaiting::HandleKeyEventL
+// CPhoneConferenceAndSingleAndWaiting::HandleErrorL
 // -----------------------------------------------------------
 //
-void CPhoneConferenceAndSingleAndWaiting::HandleKeyEventL(
-    const TKeyEvent& aKeyEvent,
-    TEventCode /*aEventCode*/ )
+EXPORT_C void CPhoneConferenceAndSingleAndWaiting::HandleErrorL( 
+        const TPEErrorInfo& aErrorInfo )
     {
-    if( EKeyDeviceF == aKeyEvent.iCode )
+    __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneConferenceAndSingleAndWaiting::HandleErrorL()");
+    
+    if( aErrorInfo.iErrorCode == ECCPErrorCCUserAlertingNoAnswer )
         {
-        __PHONELOG( EBasic, EPhoneUIStates,
-            "CPhoneConferenceAndSingleAndWaiting::HandleKeyMessageL-deviceF" );
-        HandleHoldSwitchL();
+        // Should not shown "No Answer" note
+        __PHONELOG1( EBasic, EPhoneUIStates,
+       "PhoneUIStates: CPhoneConferenceAndSingleAndWaiting::HandleErrorL - aErrorInfo.iErrorCode =%d ",
+            aErrorInfo.iErrorCode);
+        }
+    else
+        {
+        CPhoneState::HandleErrorL( aErrorInfo );
         }
     }
 
@@ -337,7 +418,7 @@
 void CPhoneConferenceAndSingleAndWaiting::UpdateInCallCbaL()
     {
     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneConferenceAndSingleAndWaiting::UpdateInCallCbaL() ");
-
+    
     UpdateCbaL ( EPhoneCallHandlingCallWaitingCBA );
     }
 
@@ -350,48 +431,46 @@
     TPhoneCmdParamInteger activeCallCount;
     iViewCommandHandle->ExecuteCommandL(
         EPhoneViewGetCountOfActiveCalls, &activeCallCount );
-
+    
     switch( activeCallCount.Integer() )
          {
          case ENoActiveCalls: // Go to incoming state
             {
             // Get Waiting call's Call Id
-            TPhoneCmdParamCallStateData callStateData;
+            TPhoneCmdParamCallStateData callStateData;    
             callStateData.SetCallState( EPEStateRinging );
-            iViewCommandHandle->HandleCommandL( EPhoneViewGetCallIdByState,
+            iViewCommandHandle->HandleCommandL( EPhoneViewGetCallIdByState, 
                 &callStateData );
-
+            
             if ( callStateData.CallId() != KErrNotFound )
                 {
                 // Display ringing bubble
                 TPhoneCmdParamCallHeaderData callHeaderParam;
                 callHeaderParam.SetCallState( EPEStateRinging );
-
+                
                 SetCallHeaderTextsForCallComingInL( callStateData.CallId(), EFalse, &callHeaderParam );
-
-                iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble,
-                    callStateData.CallId(),
+                
+                iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, 
+                    callStateData.CallId(), 
                     &callHeaderParam );
-
+        
                 // Capture keys when there is an incoming call
-                CaptureKeysDuringCallNotificationL( ETrue );
-
+                CaptureKeysDuringCallNotificationL( ETrue );    
+                
                 // Go to Incoming state
                 iCbaManager->UpdateIncomingCbaL( callStateData.CallId() );
-
-                // Check if HW Keys or Call UI should be disabled
-                CheckDisableHWKeysAndCallUIL();
-
                 SetTouchPaneButtons( EPhoneIncomingCallButtons );
-                SetRingingTonePlaybackL( callStateData.CallId() );
-                SetBackButtonActive(EFalse);
-                iStateMachine->ChangeState( EPhoneStateIncoming );
+                UpdateSilenceButtonDimming();
+                SetTouchPaneButtonEnabled( EPhoneCallComingCmdAnswer );
+                SetRingingTonePlaybackL( callStateData.CallId() );      
+                SetToolbarDimming( ETrue );
+                iStateMachine->ChangeState( EPhoneStateIncoming );          
                 }
             else
                 {
                 SetDefaultFlagsL();
                 UpdateCbaL( EPhoneEmptyCBA );
-                iStateMachine->ChangeState( EPhoneStateIdle );
+                iStateMachine->ChangeState( EPhoneStateIdle );          
                 }
             }
             break;
@@ -399,34 +478,27 @@
             {
             // Go to Single And Waiting state
             UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
-            SetTouchPaneButtons( EPhoneWaitingCallButtons );
-
-            // Check if HW Keys or Call UI should be disabled
-            CheckDisableHWKeysAndCallUIL();
-
-            iStateMachine->ChangeState( EPhoneStateWaitingInSingle );
+            SetTouchPaneButtons( EPhoneWaitingCallButtons );        
+            SetTouchPaneButtonEnabled( EPhoneCallComingCmdAnswer );
+            iStateMachine->ChangeState( EPhoneStateWaitingInSingle );        
             }
             break;
          case ETwoActiveCalls:
             {
             // Go to Two Singles And Waiting state
             UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
-
-            // Check if HW Keys or Call UI should be disabled
-            CheckDisableHWKeysAndCallUIL();
-
-            SetTouchPaneButtons( EPhoneWaitingCallButtons );
+            SetTouchPaneButtons( EPhoneWaitingCallButtons );        
             iStateMachine->ChangeState( EPhoneStateTwoSinglesAndWaiting );
             }
             break;
          default:
            // Too many active calls to handle reliable state change now.
            // Waiting for all conference member idles
-           // This case may happen when 'End all calls' because conferenceIdle may
+           // This case may happen when 'End all calls' because conferenceIdle may 
            // come earlier than idle for conference member
             break;
          }
 
     }
-
+    
 // End of File