phoneapp/phoneuistates/src/cphonecallsetupandwaiting.cpp
changeset 0 5f000ab63145
child 14 24062c24fe38
child 21 92ab7f8d0eab
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2005 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 CPhoneCallSetupAndWaiting class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <pevirtualengine.h>
       
    21 #include <StringLoader.h>
       
    22 #include <MediatorDomainUIDs.h>
       
    23 #include <videotelcontrolmediatorapi.h>
       
    24 
       
    25 #include "cphonecallsetupandwaiting.h"
       
    26 #include "tphonecmdparamboolean.h"
       
    27 #include "mphonestatemachine.h"
       
    28 #include "tphonecmdparamboolean.h"
       
    29 #include "tphonecmdparaminteger.h"
       
    30 #include "tphonecmdparamcallheaderdata.h"
       
    31 #include "tphonecmdparamglobalnote.h"
       
    32 #include "tphonecmdparamcallstatedata.h"
       
    33 #include "phoneviewcommanddefinitions.h"
       
    34 #include "phoneui.hrh"
       
    35 #include "cphonemainresourceresolver.h"
       
    36 #include "phonerssbase.h"
       
    37 #include "phonestatedefinitionsgsm.h"
       
    38 #include "phonelogger.h"
       
    39 #include "cphonemediatorfactory.h"
       
    40 #include "cphonemediatorsender.h"
       
    41 
       
    42 // ================= MEMBER FUNCTIONS =======================
       
    43 
       
    44 // C++ default constructor can NOT contain any code, that
       
    45 // might leave.
       
    46 //
       
    47 CPhoneCallSetupAndWaiting::CPhoneCallSetupAndWaiting( 
       
    48     MPhoneStateMachine* aStateMachine, 
       
    49     MPhoneViewCommandHandle* aViewCommandHandle,
       
    50     MPhoneCustomization* aPhoneCustomization ) : 
       
    51     CPhoneGsmInCall( aStateMachine, aViewCommandHandle, aPhoneCustomization )
       
    52     {
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------
       
    56 // CPhoneCallSetupAndWaiting::~CPhoneCallSetupAndWaiting()
       
    57 // Destructor
       
    58 // (other items were commented in a header).
       
    59 // -----------------------------------------------------------
       
    60 //
       
    61 CPhoneCallSetupAndWaiting::~CPhoneCallSetupAndWaiting()
       
    62     {
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------
       
    66 // CPhoneCallSetupAndWaiting::ConstructL()
       
    67 // Constructor
       
    68 // (other items were commented in a header).
       
    69 // -----------------------------------------------------------
       
    70 //
       
    71 void CPhoneCallSetupAndWaiting::ConstructL()
       
    72     {
       
    73     CPhoneGsmInCall::ConstructL();
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------
       
    77 // CPhoneCallSetupAndWaiting::NewL()
       
    78 // Constructor
       
    79 // (other items were commented in a header).
       
    80 // -----------------------------------------------------------
       
    81 //
       
    82 CPhoneCallSetupAndWaiting* CPhoneCallSetupAndWaiting::NewL( 
       
    83     MPhoneStateMachine* aStateMachine, 
       
    84     MPhoneViewCommandHandle* aViewCommandHandle,
       
    85     MPhoneCustomization* aPhoneCustomization )
       
    86     {
       
    87     CPhoneCallSetupAndWaiting* self = new( ELeave ) CPhoneCallSetupAndWaiting( 
       
    88         aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
    89     
       
    90     CleanupStack::PushL( self );
       
    91     self->ConstructL();
       
    92     CleanupStack::Pop( self );
       
    93     
       
    94     return self;
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------
       
    98 // CPhoneCallSetupAndWaiting::HandlePhoneEngineMessageL
       
    99 // -----------------------------------------------------------
       
   100 //
       
   101 void CPhoneCallSetupAndWaiting::HandlePhoneEngineMessageL( 
       
   102     const TInt aMessage, 
       
   103     TInt aCallId )
       
   104     {
       
   105     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   106         "CPhoneCallSetupAndWaiting::HandlePhoneEngineMessageL()");
       
   107     switch ( aMessage )
       
   108         {
       
   109         case MEngineMonitor::EPEMessageIdle:
       
   110             HandleIdleL( aCallId );
       
   111             break;
       
   112 
       
   113         case MEngineMonitor::EPEMessageConnected:
       
   114             HandleConnectedL( aCallId );
       
   115             break;
       
   116             
       
   117         default:
       
   118             CPhoneGsmInCall::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   119             break;
       
   120         }
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------
       
   124 // CPhoneCallSetupAndWaiting::OpenMenuBarL
       
   125 // -----------------------------------------------------------
       
   126 //
       
   127 void CPhoneCallSetupAndWaiting::OpenMenuBarL()
       
   128     {
       
   129     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   130         "CPhoneCallSetupAndWaiting::OpenMenuBarL()");
       
   131     TInt resourceId;
       
   132 
       
   133     if ( iOnScreenDialer && IsDTMFEditorVisibleL() )
       
   134         {
       
   135         resourceId = EPhoneDtmfDialerMenubar;
       
   136         }
       
   137     else if ( IsNumberEntryVisibleL() )
       
   138         {
       
   139         resourceId = EPhoneAlertingAndWaitingCallMenuBarWithNumberEntry;
       
   140         }
       
   141     else
       
   142         {
       
   143         resourceId = EPhoneAlertingAndWaitingCallMenuBar;
       
   144         }
       
   145 
       
   146     TPhoneCmdParamInteger integerParam;
       
   147     integerParam.SetInteger( 
       
   148         CPhoneMainResourceResolver::Instance()->
       
   149         ResolveResourceID( resourceId ) );
       
   150     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarOpen, 
       
   151         &integerParam );
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------
       
   155 // CPhoneCallSetupAndWaiting::HandleIdleL
       
   156 // -----------------------------------------------------------
       
   157 //
       
   158 void CPhoneCallSetupAndWaiting::HandleIdleL( TInt aCallId )
       
   159     {
       
   160     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   161         "CPhoneCallSetupAndWaiting::HandleIdleL()");
       
   162         
       
   163     BeginUiUpdateLC();
       
   164             
       
   165     // Remove call 
       
   166     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId );
       
   167 
       
   168     // Close menu bar, if it is displayed
       
   169     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   170 
       
   171     // Find out do we have waiting or outgoing call left
       
   172     TPhoneCmdParamCallStateData callStateData;
       
   173     callStateData.SetCallState( EPEStateRinging );
       
   174     iViewCommandHandle->HandleCommandL( EPhoneViewGetCallIdByState, 
       
   175         &callStateData );
       
   176         
       
   177     if( callStateData.CallId() > KErrNotFound )
       
   178         {
       
   179         // Idle message came for callSetup
       
   180 
       
   181         if ( iOnScreenDialer && IsDTMFEditorVisibleL()  )
       
   182             {
       
   183             CloseDTMFEditorL();
       
   184             }
       
   185                 
       
   186         // Display ringing bubble
       
   187         TPhoneCmdParamCallHeaderData callHeaderParam;
       
   188         callHeaderParam.SetCallState( EPEStateRinging );
       
   189          
       
   190         SetCallHeaderTextsForCallComingInL( callStateData.CallId(), EFalse, &callHeaderParam );
       
   191         
       
   192         iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, 
       
   193             callStateData.CallId(), 
       
   194             &callHeaderParam );
       
   195         
       
   196         // Show incoming call buttons
       
   197         SetTouchPaneButtons( EPhoneIncomingCallButtons ); 
       
   198         SetTouchPaneButtonEnabled( EPhoneCallComingCmdSilent );
       
   199         
       
   200         // Bring up callhandling view       
       
   201         BringIncomingToForegroundL();   
       
   202         
       
   203         // state changes to Incoming
       
   204         iCbaManager->UpdateIncomingCbaL( callStateData.CallId() );
       
   205         UpdateSilenceButtonDimming();
       
   206         SetRingingTonePlaybackL( callStateData.CallId() );
       
   207         iStateMachine->ChangeState( EPhoneStateIncoming );    
       
   208         }    
       
   209     
       
   210     else
       
   211         {
       
   212         // Show call setup buttons
       
   213         CPhoneState::SetTouchPaneButtons( EPhoneCallSetupButtons );
       
   214         // Waiting call was terminated
       
   215         UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   216         iStateMachine->ChangeState( EPhoneStateAlerting );            
       
   217         }
       
   218     
       
   219     EndUiUpdate();        
       
   220     }
       
   221         
       
   222 // -----------------------------------------------------------
       
   223 // CPhoneCallSetupAndWaiting::UpdateInCallCbaL
       
   224 // -----------------------------------------------------------
       
   225 //
       
   226 void CPhoneCallSetupAndWaiting::UpdateInCallCbaL()
       
   227     {
       
   228     __LOGMETHODSTARTEND( EPhoneControl, 
       
   229         "CPhoneCallSetupAndWaiting::UpdateInCallCbaL() ");
       
   230         
       
   231     UpdateCbaL( EPhoneCallHandlingIncomingRejectCBA );
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------
       
   235 // CPhoneCallSetupAndWaiting::HandleConnectedL
       
   236 // -----------------------------------------------------------
       
   237 //
       
   238 void CPhoneCallSetupAndWaiting::HandleConnectedL( TInt aCallId )
       
   239     {
       
   240     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneCallSetupAndWaiting::HandleConnectedL() ");
       
   241 
       
   242     // Close menu bar, if it is displayed
       
   243     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   244     
       
   245     CPhoneState::BeginUiUpdateLC();
       
   246 
       
   247     // Update bubble
       
   248     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   249     callHeaderParam.SetCallState( EPEStateConnected );
       
   250     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId, 
       
   251         &callHeaderParam );
       
   252       
       
   253     // Update Touch buttons    
       
   254     CPhoneState::SetTouchPaneButtons( EPhoneWaitingCallButtons );
       
   255     SetToolbarDimming( EFalse );
       
   256     
       
   257     CPhoneState::EndUiUpdate();
       
   258  
       
   259     if ( CPhoneState::IsNumberEntryUsedL() )
       
   260         {
       
   261         // Show number entry
       
   262         TPhoneCmdParamBoolean booleanParam;
       
   263         booleanParam.SetBoolean( ETrue );
       
   264         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetNumberEntryVisible, &booleanParam );
       
   265         }
       
   266  
       
   267     // Go to Single And Waiting state 
       
   268     UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );   
       
   269     iStateMachine->ChangeState( EPhoneStateWaitingInSingle );        
       
   270     }
       
   271     
       
   272 // End of File