phoneapp/phoneuistates/src/cphonecallsetupandwaiting.cpp
changeset 37 ba76fc04e6c2
child 50 377c906a8701
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     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 
       
    24 #include "cphonecallsetupandwaiting.h"
       
    25 #include "tphonecmdparamboolean.h"
       
    26 #include "mphonestatemachine.h"
       
    27 #include "tphonecmdparamboolean.h"
       
    28 #include "tphonecmdparaminteger.h"
       
    29 #include "tphonecmdparamcallheaderdata.h"
       
    30 #include "tphonecmdparamglobalnote.h"
       
    31 #include "tphonecmdparamcallstatedata.h"
       
    32 #include "phoneviewcommanddefinitions.h"
       
    33 #include "phoneui.hrh"
       
    34 #include "cphonemainresourceresolver.h"
       
    35 #include "phonerssbase.h"
       
    36 #include "phonestatedefinitionsgsm.h"
       
    37 #include "phonelogger.h"
       
    38 #include "cphonemediatorfactory.h"
       
    39 #include "cphonemediatorsender.h"
       
    40 
       
    41 // ================= MEMBER FUNCTIONS =======================
       
    42 
       
    43 // C++ default constructor can NOT contain any code, that
       
    44 // might leave.
       
    45 //
       
    46 CPhoneCallSetupAndWaiting::CPhoneCallSetupAndWaiting(
       
    47     MPhoneStateMachine* aStateMachine,
       
    48     MPhoneViewCommandHandle* aViewCommandHandle,
       
    49     MPhoneCustomization* aPhoneCustomization ) :
       
    50     CPhoneGsmInCall( aStateMachine, aViewCommandHandle, aPhoneCustomization )
       
    51     {
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------
       
    55 // CPhoneCallSetupAndWaiting::~CPhoneCallSetupAndWaiting()
       
    56 // Destructor
       
    57 // (other items were commented in a header).
       
    58 // -----------------------------------------------------------
       
    59 //
       
    60 CPhoneCallSetupAndWaiting::~CPhoneCallSetupAndWaiting()
       
    61     {
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------
       
    65 // CPhoneCallSetupAndWaiting::ConstructL()
       
    66 // Constructor
       
    67 // (other items were commented in a header).
       
    68 // -----------------------------------------------------------
       
    69 //
       
    70 void CPhoneCallSetupAndWaiting::ConstructL()
       
    71     {
       
    72     CPhoneGsmInCall::ConstructL();
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------
       
    76 // CPhoneCallSetupAndWaiting::NewL()
       
    77 // Constructor
       
    78 // (other items were commented in a header).
       
    79 // -----------------------------------------------------------
       
    80 //
       
    81 CPhoneCallSetupAndWaiting* CPhoneCallSetupAndWaiting::NewL(
       
    82     MPhoneStateMachine* aStateMachine,
       
    83     MPhoneViewCommandHandle* aViewCommandHandle,
       
    84     MPhoneCustomization* aPhoneCustomization )
       
    85     {
       
    86     CPhoneCallSetupAndWaiting* self = new( ELeave ) CPhoneCallSetupAndWaiting(
       
    87         aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
    88 
       
    89     CleanupStack::PushL( self );
       
    90     self->ConstructL();
       
    91     CleanupStack::Pop( self );
       
    92 
       
    93     return self;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------
       
    97 // CPhoneCallSetupAndWaiting::HandlePhoneEngineMessageL
       
    98 // -----------------------------------------------------------
       
    99 //
       
   100 void CPhoneCallSetupAndWaiting::HandlePhoneEngineMessageL(
       
   101     const TInt aMessage,
       
   102     TInt aCallId )
       
   103     {
       
   104     __LOGMETHODSTARTEND( EPhoneUIStates,
       
   105         "CPhoneCallSetupAndWaiting::HandlePhoneEngineMessageL()");
       
   106     switch ( aMessage )
       
   107         {
       
   108         case MEngineMonitor::EPEMessageIdle:
       
   109             HandleIdleL( aCallId );
       
   110             break;
       
   111 
       
   112         case MEngineMonitor::EPEMessageConnected:
       
   113             HandleConnectedL( aCallId );
       
   114             break;
       
   115 
       
   116         default:
       
   117             CPhoneGsmInCall::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   118             break;
       
   119         }
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------
       
   123 // CPhoneCallSetupAndWaiting::OpenMenuBarL
       
   124 // -----------------------------------------------------------
       
   125 //
       
   126 void CPhoneCallSetupAndWaiting::OpenMenuBarL()
       
   127     {
       
   128     __LOGMETHODSTARTEND( EPhoneUIStates,
       
   129         "CPhoneCallSetupAndWaiting::OpenMenuBarL()");
       
   130     TInt resourceId;
       
   131 
       
   132     if ( iOnScreenDialer && IsDTMFEditorVisibleL() )
       
   133         {
       
   134         resourceId = EPhoneDtmfDialerMenubar;
       
   135         }
       
   136     else if ( IsNumberEntryVisibleL() )
       
   137         {
       
   138         resourceId = EPhoneAlertingAndWaitingCallMenuBarWithNumberEntry;
       
   139         }
       
   140     else
       
   141         {
       
   142         resourceId = EPhoneAlertingAndWaitingCallMenuBar;
       
   143         }
       
   144 
       
   145     TPhoneCmdParamInteger integerParam;
       
   146     integerParam.SetInteger(
       
   147         CPhoneMainResourceResolver::Instance()->
       
   148         ResolveResourceID( resourceId ) );
       
   149     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarOpen,
       
   150         &integerParam );
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------
       
   154 // CPhoneCallSetupAndWaiting::HandleIdleL
       
   155 // -----------------------------------------------------------
       
   156 //
       
   157 void CPhoneCallSetupAndWaiting::HandleIdleL( TInt aCallId )
       
   158     {
       
   159     __LOGMETHODSTARTEND( EPhoneUIStates,
       
   160         "CPhoneCallSetupAndWaiting::HandleIdleL()");
       
   161 
       
   162     BeginUiUpdateLC();
       
   163 
       
   164     // Remove call
       
   165     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId );
       
   166 
       
   167     // Close menu bar, if it is displayed
       
   168     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   169 
       
   170     // Find out do we have waiting or outgoing call left
       
   171     TPhoneCmdParamCallStateData callStateData;
       
   172     callStateData.SetCallState( EPEStateRinging );
       
   173     iViewCommandHandle->HandleCommandL( EPhoneViewGetCallIdByState,
       
   174         &callStateData );
       
   175 
       
   176     if( callStateData.CallId() > KErrNotFound )
       
   177         {
       
   178         // Idle message came for callSetup
       
   179 
       
   180         if ( iOnScreenDialer && IsDTMFEditorVisibleL()  )
       
   181             {
       
   182             CloseDTMFEditorL();
       
   183             }
       
   184 
       
   185         // Display ringing bubble
       
   186         TPhoneCmdParamCallHeaderData callHeaderParam;
       
   187         callHeaderParam.SetCallState( EPEStateRinging );
       
   188 
       
   189         SetCallHeaderTextsForCallComingInL( callStateData.CallId(), EFalse, &callHeaderParam );
       
   190 
       
   191         iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble,
       
   192             callStateData.CallId(),
       
   193             &callHeaderParam );
       
   194 
       
   195         // Show incoming call buttons
       
   196         SetTouchPaneButtons( EPhoneIncomingCallButtons );
       
   197         SetTouchPaneButtonEnabled( EPhoneCallComingCmdSilent );
       
   198 
       
   199         // Bring up callhandling view
       
   200         BringIncomingToForegroundL();
       
   201 
       
   202         // state changes to Incoming
       
   203         iCbaManager->UpdateIncomingCbaL( callStateData.CallId() );
       
   204         UpdateSilenceButtonDimming();
       
   205         SetRingingTonePlaybackL( callStateData.CallId() );
       
   206         SetBackButtonActive(EFalse);
       
   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