phoneapp/phoneuistates/src/cphoneconferenceandcallsetup.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2005-2008 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 CPhoneConferenceAndCallSetup class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "cphoneconferenceandcallsetup.h"
       
    21 #include "mphonestatemachine.h"
       
    22 #include "phoneviewcommanddefinitions.h"
       
    23 #include "tphonecmdparamcallheaderdata.h"
       
    24 #include "tphonecmdparamcallstatedata.h"
       
    25 #include "phonestatedefinitionsgsm.h"
       
    26 #include "phonelogger.h"
       
    27 #include "tphonecmdparamboolean.h"
       
    28 #include "tphonecmdparaminteger.h"
       
    29 #include "cphonemainresourceresolver.h"
       
    30 #include "phonerssbase.h"
       
    31 #include "tphonecmdparamglobalnote.h"
       
    32 #include "phoneui.hrh"
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 //
       
    39 CPhoneConferenceAndCallSetup::CPhoneConferenceAndCallSetup( 
       
    40     MPhoneStateMachine* aStateMachine, 
       
    41     MPhoneViewCommandHandle* aViewCommandHandle,
       
    42     MPhoneCustomization* aPhoneCustomization ) : 
       
    43     CPhoneConference( aStateMachine, aViewCommandHandle, aPhoneCustomization )
       
    44     {
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------
       
    48 // CPhoneConferenceAndCallSetup::~CPhoneConferenceAndCallSetup()
       
    49 // Destructor
       
    50 // (other items were commented in a header).
       
    51 // -----------------------------------------------------------
       
    52 //
       
    53 CPhoneConferenceAndCallSetup::~CPhoneConferenceAndCallSetup()
       
    54     {
       
    55     // Reset flag
       
    56     if ( iViewCommandHandle )
       
    57         {
       
    58         TPhoneCmdParamBoolean dtmfSendFlag;
       
    59         dtmfSendFlag.SetBoolean( EFalse );
       
    60         iViewCommandHandle->ExecuteCommand( EPhoneViewSetDtmfOptionsFlag, 
       
    61             &dtmfSendFlag );
       
    62         }
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------
       
    66 // CPhoneConferenceAndCallSetup::ConstructL()
       
    67 // Constructor
       
    68 // (other items were commented in a header).
       
    69 // -----------------------------------------------------------
       
    70 //
       
    71 void CPhoneConferenceAndCallSetup::ConstructL()
       
    72     {
       
    73     CPhoneConference::ConstructL();
       
    74   
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------
       
    78 // CPhoneConferenceAndCallSetup::NewL()
       
    79 // Constructor
       
    80 // (other items were commented in a header).
       
    81 // -----------------------------------------------------------
       
    82 //
       
    83 CPhoneConferenceAndCallSetup* CPhoneConferenceAndCallSetup::NewL( 
       
    84     MPhoneStateMachine* aStateMachine, 
       
    85     MPhoneViewCommandHandle* aViewCommandHandle,
       
    86     MPhoneCustomization* aPhoneCustomization )
       
    87     {
       
    88     CPhoneConferenceAndCallSetup* self = new( ELeave ) CPhoneConferenceAndCallSetup( 
       
    89         aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
    90     
       
    91     CleanupStack::PushL( self );
       
    92     self->ConstructL();
       
    93     CleanupStack::Pop( self );
       
    94     
       
    95     return self;
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------
       
    99 // CPhoneConferenceAndCallSetup::HandlePhoneEngineMessageL
       
   100 // -----------------------------------------------------------
       
   101 //
       
   102 void CPhoneConferenceAndCallSetup::HandlePhoneEngineMessageL( 
       
   103     const TInt aMessage, 
       
   104     TInt aCallId )
       
   105     {
       
   106     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneConferenceAndCallSetup::HandlePhoneEngineMessageL()");
       
   107     switch ( aMessage )
       
   108         {
       
   109         case MEngineMonitor::EPEMessageConnecting:
       
   110             iAlerting = ETrue;
       
   111             HandleConnectingL( aCallId );
       
   112             break;
       
   113             
       
   114         case MEngineMonitor::EPEMessageConnected:
       
   115             HandleConnectedL( aCallId );
       
   116             break;
       
   117             
       
   118         case MEngineMonitor::EPEMessageIdle:
       
   119             HandleIdleL( aCallId );
       
   120             break;
       
   121             
       
   122         case MEngineMonitor::EPEMessageConferenceIdle:
       
   123             HandleConferenceIdleL();
       
   124             break;
       
   125             
       
   126         default:
       
   127             CPhoneConference::HandlePhoneEngineMessageL( aMessage, 
       
   128                 aCallId );
       
   129             break;
       
   130         }
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------
       
   134 // CPhoneConferenceAndCallSetup::HandleCommandL
       
   135 // -----------------------------------------------------------
       
   136 //
       
   137 TBool CPhoneConferenceAndCallSetup::HandleCommandL( TInt aCommand )
       
   138     {
       
   139     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   140         "CPhoneConferenceAndCallSetup::HandleCommandL()");
       
   141     TBool commandStatus = ETrue;
       
   142     
       
   143     switch( aCommand )
       
   144         {   
       
   145         case EPhoneDtmfDialerCancel:
       
   146             {
       
   147             CloseDTMFEditorL();
       
   148             }
       
   149             break;    
       
   150     
       
   151         default:
       
   152             commandStatus = CPhoneConference::HandleCommandL( aCommand );
       
   153             break;
       
   154         }
       
   155 
       
   156     return commandStatus;
       
   157     }
       
   158     
       
   159 // --------------------------------------------------------------
       
   160 // CPhoneConferenceAndCallSetup::HandleKeyMessageL
       
   161 // --------------------------------------------------------------
       
   162 //
       
   163 void CPhoneConferenceAndCallSetup::HandleKeyMessageL( 
       
   164     TPhoneKeyEventMessages aMessage,
       
   165     TKeyCode aCode )
       
   166     {
       
   167     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   168         "CPhoneConferenceAndCallSetup::HandleKeyMessageL()");
       
   169     switch ( aCode )
       
   170         {
       
   171         // End-key
       
   172         case EKeyNo:
       
   173             if ( aMessage == EPhoneKeyLongPress )
       
   174                 {
       
   175                 iStateMachine->SendPhoneEngineMessage(
       
   176                         MPEPhoneModel::EPEMessageTerminateAllConnections );   
       
   177                 }
       
   178             else
       
   179                 {
       
   180                 DisconnectOutgoingCallL();
       
   181                 }
       
   182             break;
       
   183             
       
   184         default:
       
   185             // do base operation
       
   186             CPhoneConference::HandleKeyMessageL( aMessage, aCode );
       
   187             break;
       
   188         }
       
   189     }
       
   190 // -----------------------------------------------------------
       
   191 // CPhoneConferenceAndCallSetup::OpenMenuBarL
       
   192 // -----------------------------------------------------------
       
   193 //
       
   194 void CPhoneConferenceAndCallSetup::OpenMenuBarL()
       
   195     {
       
   196     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneConferenceAndCallSetup::OpenMenuBarL()");
       
   197     TInt resourceId;
       
   198     
       
   199     // Set specific flag to view so that DTMF menu item available
       
   200     TPhoneCmdParamBoolean dtmfSendFlag;
       
   201     dtmfSendFlag.SetBoolean( ETrue );
       
   202     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetDtmfOptionsFlag, 
       
   203         &dtmfSendFlag );
       
   204      
       
   205     if ( iOnScreenDialer &&  IsDTMFEditorVisibleL() )
       
   206         {
       
   207         resourceId = EPhoneDtmfDialerMenubar;
       
   208         }
       
   209     else if ( IsNumberEntryVisibleL() )
       
   210         {
       
   211         resourceId = EPhoneAlertingAndConfHeldCallMenuBarWithNumberEntry;
       
   212         }
       
   213     else if ( IsConferenceBubbleInSelectionMode() )
       
   214         {
       
   215         resourceId = EPhoneConfCallParticipantsDropMenubar;    
       
   216         }        
       
   217     else
       
   218         {
       
   219         resourceId = EPhoneAlertingAndConfHeldCallMenuBar;
       
   220         }
       
   221 
       
   222     TPhoneCmdParamInteger integerParam;
       
   223     integerParam.SetInteger( 
       
   224                 CPhoneMainResourceResolver::Instance()->
       
   225                 ResolveResourceID( resourceId ) );
       
   226         
       
   227     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarOpen, 
       
   228         &integerParam );
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------
       
   232 // CPhoneConferenceAndCallSetup::HandleConnectingL
       
   233 // -----------------------------------------------------------
       
   234 //
       
   235 void CPhoneConferenceAndCallSetup::HandleConnectingL( TInt aCallId )
       
   236     {
       
   237     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneConferenceAndCallSetup::HandleConnectingL()");
       
   238     
       
   239     BeginUiUpdateLC();
       
   240         
       
   241     UpdateRemoteInfoDataL ( aCallId );
       
   242     
       
   243     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveGlobalNote );
       
   244     
       
   245     // Re-enable global notes
       
   246     TPhoneCmdParamBoolean globalNotifierParam;
       
   247     globalNotifierParam.SetBoolean( EFalse );
       
   248     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   249         &globalNotifierParam );
       
   250 
       
   251     // Stop capturing keys
       
   252     CaptureKeysDuringCallNotificationL( EFalse );
       
   253 
       
   254     // Remove the number entry if it isn't DTMF dialer
       
   255     if ( !iOnScreenDialer || !IsNumberEntryVisibleL() || ! IsDTMFEditorVisibleL() )
       
   256         {
       
   257         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
   258         }
       
   259     
       
   260     // Set Hold flag to view EFalse that IHF is on RSK not unhold
       
   261     TPhoneCmdParamBoolean holdFlag;
       
   262     holdFlag.SetBoolean( EFalse );
       
   263     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
   264     
       
   265     // Updated connecting cba's   
       
   266     UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   267 
       
   268     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   269     callHeaderParam.SetCallState( EPEStateConnecting );
       
   270     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId, 
       
   271         &callHeaderParam );       
       
   272         
       
   273     EndUiUpdate();        
       
   274     }
       
   275     
       
   276 // -----------------------------------------------------------
       
   277 // CPhoneConferenceAndCallSetup::HandleConnectedL
       
   278 // -----------------------------------------------------------
       
   279 //
       
   280 void CPhoneConferenceAndCallSetup::HandleConnectedL( TInt aCallId )
       
   281     {
       
   282     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneConferenceAndCallSetup::HandleConnectedL()");
       
   283     
       
   284     // Close menu bar, if it is displayed
       
   285     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   286     
       
   287     // Keep Phone in the foreground
       
   288     TPhoneCmdParamBoolean booleanParam;
       
   289     booleanParam.SetBoolean( EFalse );
       
   290     iViewCommandHandle->ExecuteCommandL( 
       
   291         EPhoneViewSetNeedToSendToBackgroundStatus, &booleanParam );
       
   292     
       
   293     BeginUiUpdateLC();
       
   294         
       
   295     // Show bubble
       
   296     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   297     callHeaderParam.SetCallState( EPEStateConnected );
       
   298     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId, 
       
   299         &callHeaderParam );
       
   300     
       
   301     // Capturing keys and number entry must be removed because some
       
   302     // networks jump over connecting state directly to connected state.
       
   303     CaptureKeysDuringCallNotificationL( EFalse );
       
   304     
       
   305     // Remove the number entry if it isn't DTMF dialer
       
   306     if ( !iOnScreenDialer || !IsNumberEntryVisibleL() || ! IsDTMFEditorVisibleL() )
       
   307         {
       
   308         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
   309         }
       
   310     
       
   311     SetTouchPaneButtons( EPhoneConferenceAndSingleButtons );
       
   312     SetTouchPaneButtonDisabled( EPhoneInCallCmdPrivate );
       
   313     EndUiUpdate(); 
       
   314 
       
   315     HandleColpNoteL( aCallId );
       
   316     UpdateCbaL ( EPhoneCallHandlingNewCallSwapCBA );
       
   317    
       
   318     iStateMachine->ChangeState( EPhoneStateConferenceAndSingle );                     
       
   319     }
       
   320 
       
   321 // -----------------------------------------------------------
       
   322 // CPhoneConferenceAndCallSetup:HandleIdleL
       
   323 // -----------------------------------------------------------
       
   324 //
       
   325 void CPhoneConferenceAndCallSetup::HandleIdleL( TInt aCallId )
       
   326     {
       
   327     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   328         "CPhoneConferenceAndCallSetup::HandleIdleL()");
       
   329     // Re-enable global notes
       
   330     TPhoneCmdParamBoolean globalNotifierParam;
       
   331     globalNotifierParam.SetBoolean( EFalse );
       
   332     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   333         &globalNotifierParam );
       
   334 
       
   335     // Stop capturing keys
       
   336     CaptureKeysDuringCallNotificationL( EFalse );
       
   337 
       
   338     // Close menu bar, if it is displayed
       
   339     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   340 
       
   341     TPhoneCmdParamBoolean conferenceExistsForCallId;
       
   342     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetCallExistsInConference,
       
   343         aCallId, &conferenceExistsForCallId );
       
   344     
       
   345     if( conferenceExistsForCallId.Boolean() )
       
   346         {
       
   347         // Remove 'Conference on hold' global note
       
   348         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveGlobalNote );
       
   349     
       
   350         // Remove conference member from conference bubble
       
   351         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveFromConference, 
       
   352             aCallId );
       
   353         
       
   354         //Check if removed call was last one to be able to be in conference mode
       
   355         //If there is no confrence call, go to single and call setup state
       
   356         TPhoneCmdParamBoolean conferenceExists;
       
   357         iViewCommandHandle->ExecuteCommandL( EPhoneViewGetIsConference, 
       
   358             &conferenceExists );
       
   359         
       
   360         __PHONELOG1( EBasic, EPhoneControl,
       
   361             "CPhoneConferenceAndCallSetup::HandleIdleL - conferenceExists =%d ",
       
   362             conferenceExists.Boolean() );
       
   363                 
       
   364         if( !conferenceExists.Boolean() )
       
   365             {
       
   366             if( iAlerting )
       
   367                 {
       
   368                 iStateMachine->ChangeState( EPhoneStateAlertingInSingle ); 
       
   369                 }
       
   370             else
       
   371                 {
       
   372                 iStateMachine->ChangeState( EPhoneStateCallSetupInSingle );     
       
   373                 }
       
   374             }
       
   375         }
       
   376     else
       
   377         {       
       
   378         // Remove  outgoing call 
       
   379         BeginTransEffectLC( ENumberEntryOpen );
       
   380         BeginUiUpdateLC();
       
   381         
       
   382         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId );
       
   383         
       
   384         CheckIfRestoreNEContentAfterDtmfDialer();
       
   385          
       
   386         if ( IsNumberEntryUsedL() )
       
   387             {
       
   388             // Show the number entry if it exists
       
   389             SetNumberEntryVisibilityL(ETrue);
       
   390             }
       
   391             
       
   392         SetTouchPaneButtons( EPhoneConferenceButtons );
       
   393         EndUiUpdate();
       
   394         EndTransEffect(); 
       
   395 
       
   396         // Go to conference state
       
   397         UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   398         iStateMachine->ChangeState( EPhoneStateConference );
       
   399         } 
       
   400 
       
   401     }
       
   402    
       
   403     
       
   404 // -----------------------------------------------------------
       
   405 // CPhoneConferenceAndCallSetup::UpdateInCallCbaL
       
   406 // -----------------------------------------------------------
       
   407 //
       
   408 void CPhoneConferenceAndCallSetup::UpdateInCallCbaL()
       
   409     {
       
   410     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneConferenceAndCallSetup::UpdateInCallCbaL() ");
       
   411 
       
   412     if ( iAlerting )
       
   413         {
       
   414         UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   415         }
       
   416     else
       
   417         {
       
   418         UpdateCbaL( EPhoneCallHandlingCallSetupCBA );
       
   419         }
       
   420     } 
       
   421 
       
   422 // -----------------------------------------------------------
       
   423 // CPhoneConferenceAndCallSetup:HandleConferenceIdleL
       
   424 // -----------------------------------------------------------
       
   425 //
       
   426 void CPhoneConferenceAndCallSetup::HandleConferenceIdleL()
       
   427     {
       
   428     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   429         "CPhoneConferenceAndCallSetup::HandleConferenceIdleL()");
       
   430         
       
   431     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveConferenceBubble );
       
   432         
       
   433     // Fetch alerting call's id from view
       
   434     TPhoneCmdParamCallStateData callStateData;
       
   435     callStateData.SetCallState( EPEStateConnecting );
       
   436     iViewCommandHandle->HandleCommandL(
       
   437         EPhoneViewGetCallIdByState, &callStateData );
       
   438 
       
   439     if ( callStateData.CallId() > KErrNotFound )
       
   440         {
       
   441         // Set Hold flag to view EFalse that dtmf menu item not delete
       
   442         TPhoneCmdParamBoolean holdFlag;
       
   443         holdFlag.SetBoolean( EFalse );
       
   444         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
   445         // Go to alerting and single state
       
   446         UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   447         iStateMachine->ChangeState( EPhoneStateAlertingInSingle );     
       
   448         }
       
   449     else
       
   450         {
       
   451         // Go to callsetup and single state
       
   452         UpdateCbaL( EPhoneCallHandlingCallSetupCBA );
       
   453         iStateMachine->ChangeState( EPhoneStateCallSetupInSingle );
       
   454         }           
       
   455     }
       
   456 
       
   457 // End of File