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