phoneapp/phoneuistates/src/cphonetwosingles.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
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 CPhoneTwoSingles class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <eikmenub.h> 
       
    21 #include <eikenv.h>
       
    22 #include <StringLoader.h>
       
    23 #include <pevirtualengine.h>
       
    24 #include <mpeengineinfo.h>
       
    25 #include <cpephonemodelif.h>
       
    26 #include <featmgr.h>
       
    27 #include "cphonetwosingles.h"
       
    28 #include "mphonestatemachine.h"
       
    29 #include "phoneviewcommanddefinitions.h"
       
    30 #include "phoneui.hrh"
       
    31 #include "cphonemainresourceresolver.h"
       
    32 #include "phonerssbase.h"
       
    33 #include "phonestatedefinitions.h"
       
    34 #include "tphonecmdparaminteger.h"
       
    35 #include "tphonecmdparamappinfo.h"
       
    36 #include "tphonecmdparamboolean.h"
       
    37 #include "tphonecmdparamstring.h"
       
    38 #include "tphonecmdparamcallheaderdata.h"
       
    39 #include "tphonecmdparamcallstatedata.h"
       
    40 #include "phonestatedefinitionsgsm.h"
       
    41 #include "phonelogger.h"
       
    42 
       
    43 // ================= MEMBER FUNCTIONS =======================
       
    44 
       
    45 // C++ default constructor can NOT contain any code, that
       
    46 // might leave.
       
    47 //
       
    48 EXPORT_C CPhoneTwoSingles::CPhoneTwoSingles(
       
    49     MPhoneStateMachine* aStateMachine, 
       
    50     MPhoneViewCommandHandle* aViewCommandHandle,
       
    51     MPhoneCustomization* aPhoneCustomization ) : 
       
    52     CPhoneGsmInCall( aStateMachine, aViewCommandHandle, aPhoneCustomization )
       
    53     {
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------
       
    57 // CPhoneTwoSingles::~CPhoneTwoSingles()
       
    58 // Destructor
       
    59 // (other items were commented in a header).
       
    60 // -----------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CPhoneTwoSingles::~CPhoneTwoSingles()
       
    63     {
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------
       
    67 // CPhoneTwoSingles::ConstructL()
       
    68 // Constructor
       
    69 // (other items were commented in a header).
       
    70 // -----------------------------------------------------------
       
    71 //
       
    72 EXPORT_C void CPhoneTwoSingles::ConstructL()
       
    73     {
       
    74     CPhoneGsmInCall::ConstructL();
       
    75     
       
    76     // Re-enable global notes
       
    77     TPhoneCmdParamBoolean globalNotifierParam;
       
    78     globalNotifierParam.SetBoolean( EFalse );
       
    79     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
    80         &globalNotifierParam );
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------
       
    84 // CPhoneTwoSingles::NewL()
       
    85 // Constructor
       
    86 // (other items were commented in a header).
       
    87 // -----------------------------------------------------------
       
    88 //
       
    89 CPhoneTwoSingles* CPhoneTwoSingles::NewL( 
       
    90     MPhoneStateMachine* aStateMachine, 
       
    91     MPhoneViewCommandHandle* aViewCommandHandle,
       
    92     MPhoneCustomization* aPhoneCustomization )
       
    93     {
       
    94     CPhoneTwoSingles* self = new( ELeave ) CPhoneTwoSingles( 
       
    95         aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
    96     
       
    97     CleanupStack::PushL( self );
       
    98     self->ConstructL();
       
    99     CleanupStack::Pop( self );
       
   100     
       
   101     return self;
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------
       
   105 // CPhoneTwoSingles::HandlePhoneEngineMessageL
       
   106 // -----------------------------------------------------------
       
   107 //
       
   108 EXPORT_C void CPhoneTwoSingles::HandlePhoneEngineMessageL( 
       
   109     const TInt aMessage, 
       
   110     TInt aCallId )
       
   111     {
       
   112     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   113         "CPhoneTwoSingles::HandlePhoneEngineMessageL()");
       
   114     switch ( aMessage )
       
   115         {
       
   116         case MEngineMonitor::EPEMessageIdle:
       
   117             HandleIdleL( aCallId );
       
   118             break;
       
   119             
       
   120         case MEngineMonitor::EPEMessageConnected:
       
   121             HandleConnectedL( aCallId );
       
   122             break;
       
   123             
       
   124         case MEngineMonitor::EPEMessageHeld:
       
   125             HandleHeldL( aCallId );
       
   126             break;
       
   127             
       
   128         case MEngineMonitor::EPEMessageConnectedConference:
       
   129             HandleConnectedConferenceL( aCallId );
       
   130             break;
       
   131             
       
   132         case MEngineMonitor::EPEMessageIncoming:
       
   133             HandleIncomingL( aCallId );
       
   134             break;
       
   135 
       
   136         default:
       
   137             CPhoneGsmInCall::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   138             break;
       
   139         }
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------
       
   143 // CPhoneTwoSingles::OpenMenuBarL
       
   144 // -----------------------------------------------------------
       
   145 //
       
   146 EXPORT_C void CPhoneTwoSingles::OpenMenuBarL()
       
   147     {
       
   148     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   149         "CPhoneTwoSingles::OpenMenuBarL()");
       
   150     TInt resourceId;
       
   151 
       
   152     if ( iOnScreenDialer && IsDTMFEditorVisibleL() )
       
   153         {
       
   154         resourceId = EPhoneDtmfDialerMenubar;
       
   155         }
       
   156     if ( iOnScreenDialer && IsCustomizedDialerVisibleL() )
       
   157         {
       
   158         resourceId = CustomizedDialerMenuResourceIdL();
       
   159         }
       
   160     else if ( IsNumberEntryVisibleL() )
       
   161         {
       
   162         resourceId = EPhoneCallActiveAndHeldMenubarWithNumberEntry;
       
   163         }
       
   164     else
       
   165         {
       
   166         resourceId = EPhoneCallActiveAndHeldMenubar;
       
   167         }
       
   168 
       
   169     TPhoneCmdParamInteger integerParam;
       
   170     integerParam.SetInteger( 
       
   171         CPhoneMainResourceResolver::Instance()->
       
   172         ResolveResourceID( resourceId ) );
       
   173 
       
   174     // Set Hold flag to view
       
   175     TPhoneCmdParamBoolean holdFlag;
       
   176     holdFlag.SetBoolean( EFalse );
       
   177     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
   178 
       
   179     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarOpen, 
       
   180         &integerParam );
       
   181     }
       
   182       
       
   183 // -----------------------------------------------------------
       
   184 // CPhoneTwoSingles:HandleIdleL
       
   185 // -----------------------------------------------------------
       
   186 //    
       
   187 void CPhoneTwoSingles::HandleIdleL( TInt aCallId )
       
   188     {
       
   189     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   190         "CPhoneTwoSingles::HandleIdleL()");
       
   191     BeginUiUpdateLC();
       
   192 
       
   193     // Remove call 
       
   194     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId );
       
   195 
       
   196     TPhoneCmdParamInteger activeCallCount;
       
   197     iViewCommandHandle->ExecuteCommandL(
       
   198         EPhoneViewGetCountOfActiveCalls, &activeCallCount );
       
   199 
       
   200     switch( activeCallCount.Integer() )
       
   201         {
       
   202         case EOneActiveCall:
       
   203             {   
       
   204             if ( IsNumberEntryUsedL() )
       
   205                 {
       
   206                 // Show the number entry if it exists
       
   207                 SetNumberEntryVisibilityL(ETrue);
       
   208                 }
       
   209             else
       
   210                 {
       
   211                 // Close menu bar if number entry is not open.
       
   212                 iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   213                 
       
   214                 // Set incall CBAs
       
   215                 UpdateCbaL( EPhoneCallHandlingInCallCBA );                
       
   216                 }
       
   217             
       
   218             TPhoneCmdParamCallStateData callStateData;  
       
   219             callStateData.SetCallState( EPEStateHeld );
       
   220             iViewCommandHandle->HandleCommandL(
       
   221                 EPhoneViewGetCallIdByState, &callStateData );
       
   222             TInt holdCallId = callStateData.CallId();
       
   223             
       
   224             // Set Hold flag to view
       
   225             TPhoneCmdParamBoolean holdFlag;
       
   226             
       
   227             if ( holdCallId < 0 )
       
   228                 {
       
   229                 holdFlag.SetBoolean( EFalse );
       
   230                 }
       
   231             else
       
   232                 {
       
   233                 holdFlag.SetBoolean( ETrue );
       
   234                 // Close the dtmf query if it exists
       
   235                 CloseDtmfQueryL(); 
       
   236                 }
       
   237 
       
   238             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
   239 
       
   240     	    SetTouchPaneButtons( EPhoneIncallButtons );         
       
   241             // Go to single state
       
   242             // CBA updates in above if-else conditions
       
   243             iStateMachine->ChangeState( EPhoneStateSingle ); 
       
   244             }
       
   245             
       
   246         default:
       
   247             break;
       
   248         }
       
   249     EndUiUpdate(); 
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------
       
   253 // CPhoneTwoSingles::HandleKeyMessageL
       
   254 // -----------------------------------------------------------
       
   255 //
       
   256 EXPORT_C void CPhoneTwoSingles::HandleKeyMessageL( 
       
   257     TPhoneKeyEventMessages aMessage,
       
   258     TKeyCode aCode )
       
   259     {
       
   260     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   261         "CPhoneTwoSingles::HandleKeyMessageL()");
       
   262     switch ( aCode )
       
   263         {
       
   264         // send-key
       
   265         case EKeyYes:
       
   266             {
       
   267             // Check is number entry open
       
   268             if ( !IsNumberEntryVisibleL() )
       
   269                 {
       
   270                 iStateMachine->SendPhoneEngineMessage(
       
   271                     CPEPhoneModelIF::EPEMessageSwap );
       
   272                 }
       
   273             else
       
   274                 {
       
   275                 CallFromNumberEntryL();
       
   276                 }
       
   277             break;    
       
   278             }
       
   279 
       
   280         default:
       
   281             CPhoneGsmInCall::HandleKeyMessageL( aMessage, aCode );   
       
   282             break;
       
   283         }
       
   284     }
       
   285     
       
   286 // -----------------------------------------------------------
       
   287 // CPhoneTwoSingles::HandleConnectedL
       
   288 // -----------------------------------------------------------
       
   289 //
       
   290 void CPhoneTwoSingles::HandleConnectedL( TInt aCallId )
       
   291     {
       
   292     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   293         "CPhoneTwoSingles::HandleConnectedL()");
       
   294     // Show bubble
       
   295     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   296     callHeaderParam.SetCallState( EPEStateConnected );
       
   297     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId, 
       
   298         &callHeaderParam );
       
   299     }
       
   300     
       
   301 // -----------------------------------------------------------
       
   302 // CPhoneTwoSingles::HandleHeldL
       
   303 // -----------------------------------------------------------
       
   304 //
       
   305 void CPhoneTwoSingles::HandleHeldL( TInt aCallId )
       
   306     {
       
   307     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   308         "CPhoneTwoSingles::HandleHeldL()");
       
   309     // Display hold bubble
       
   310     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   311     callHeaderParam.SetCallState( EPEStateHeld );
       
   312     
       
   313     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
       
   314     TInt callLabelId = CPhoneMainResourceResolver::Instance()->
       
   315             ResolveResourceID( EPhoneCallOnHold );
       
   316 
       
   317     StringLoader::Load( 
       
   318         labelText, 
       
   319         callLabelId, 
       
   320         CCoeEnv::Static() );        
       
   321     callHeaderParam.SetLabelText( labelText );
       
   322     
       
   323     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId, 
       
   324         &callHeaderParam );
       
   325     }
       
   326     
       
   327 // -----------------------------------------------------------
       
   328 // CPhoneTwoSingles::HandleNumberEntryClearedL()
       
   329 // -----------------------------------------------------------
       
   330 //
       
   331 EXPORT_C void CPhoneTwoSingles::HandleNumberEntryClearedL()
       
   332     {
       
   333     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   334         "CPhoneTwoSingles::HandleNumberEntryClearedL()");
       
   335     UpdateCbaL( EPhoneCallHandlingNewCallSwapCBA );
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------
       
   339 // CPhoneTwoSingles::HandleConnectedConferenceL
       
   340 // -----------------------------------------------------------
       
   341 //
       
   342 EXPORT_C void CPhoneTwoSingles::HandleConnectedConferenceL( TInt aCallId )
       
   343     {
       
   344     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   345         "CPhoneTwoSingles::HandleConnectedConferenceL()");
       
   346     // Update call state
       
   347     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   348 
       
   349     TInt callLabelId;
       
   350     TBuf<KPhoneCallHeaderLabelMaxLength> conferenceText( KNullDesC );
       
   351     callLabelId = CPhoneMainResourceResolver::Instance()->
       
   352             ResolveResourceID( EPhoneCLIConferenceCall );
       
   353 
       
   354     StringLoader::Load( 
       
   355         conferenceText, 
       
   356         callLabelId, 
       
   357         CCoeEnv::Static() );
       
   358     callHeaderParam.SetCLIText( conferenceText, CBubbleManager::ERight );
       
   359     BeginUiUpdateLC();
       
   360     
       
   361     callHeaderParam.SetCiphering(
       
   362         iStateMachine->PhoneEngineInfo()->IsSecureCall( aCallId ) );
       
   363         
       
   364     callHeaderParam.SetCipheringIndicatorAllowed(
       
   365         iStateMachine->PhoneEngineInfo()->SecureSpecified() );
       
   366     
       
   367     // Service identifier must be given so that service specific settings
       
   368     // can be taken into account at phoneuiview.
       
   369     callHeaderParam.SetServiceId( 
       
   370         iStateMachine->PhoneEngineInfo()->ServiceId( aCallId ) );
       
   371     
       
   372     iViewCommandHandle->ExecuteCommandL( EPhoneViewCreateConference, aCallId,
       
   373         &callHeaderParam );
       
   374 
       
   375     // Set Hold flag to view
       
   376     TPhoneCmdParamBoolean holdFlag;
       
   377     holdFlag.SetBoolean( EFalse );
       
   378     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
   379 
       
   380     SetTouchPaneButtons( EPhoneConferenceButtons );
       
   381     SetTouchPaneButtonEnabled( EPhoneInCallCmdPrivate );
       
   382     EndUiUpdate();
       
   383     
       
   384     UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   385     
       
   386     // Go to conference state
       
   387     // No need for CBA update
       
   388     iStateMachine->ChangeState( EPhoneStateConference );
       
   389     }
       
   390 
       
   391 // -----------------------------------------------------------
       
   392 // CPhoneTwoSingles::HandleIncomingL
       
   393 // -----------------------------------------------------------
       
   394 //
       
   395 void CPhoneTwoSingles::HandleIncomingL( TInt aCallId )
       
   396     {
       
   397     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   398         "CPhoneTwoSingles::HandleIncomingL()");
       
   399     
       
   400     BeginUiUpdateLC();
       
   401     
       
   402     TPhoneCmdParamBoolean dialerParam;
       
   403     dialerParam.SetBoolean( ETrue );
       
   404     
       
   405     // Get allow waiting call header param value.
       
   406     AllowShowingOfWaitingCallHeaderL( dialerParam );
       
   407     
       
   408     // Close fast swap window if it's displayed
       
   409     CEikonEnv::Static()->DismissTaskList();
       
   410 
       
   411     // Display incoming call
       
   412     DisplayIncomingCallL( aCallId, dialerParam );
       
   413     
       
   414     // Set touch controls
       
   415     SetTouchPaneButtonDisabled( EPhoneCallComingCmdAnswer );
       
   416     
       
   417     // Check if HW Keys or Call UI should be disabled
       
   418     CheckDisableHWKeysAndCallUIL();
       
   419     
       
   420     SetTouchPaneButtons( EPhoneWaitingCallButtons );
       
   421 
       
   422     EndUiUpdate();
       
   423 
       
   424     // Go to incoming state
       
   425     UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
       
   426     iStateMachine->ChangeState( EPhoneStateTwoSinglesAndWaiting );        
       
   427     }
       
   428 
       
   429 // -----------------------------------------------------------
       
   430 // CPhoneTwoSingles::DisplayIncomingCallL
       
   431 // -----------------------------------------------------------
       
   432 //
       
   433 void CPhoneTwoSingles::DisplayIncomingCallL( 
       
   434     TInt aCallId, 
       
   435     const TPhoneCmdParamBoolean aCommandParam )
       
   436     {
       
   437     __LOGMETHODSTARTEND( EPhoneUIStates,
       
   438          "CPhoneTwoSingles::DisplayIncomingCallL()"); 
       
   439     // Close menu bar, if it is displayed
       
   440     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   441 
       
   442     // Cannot delete active note, e.g. New call query, 
       
   443     // but show waiting note with or without caller name
       
   444     if ( IsAnyQueryActiveL() ||  
       
   445         ( !aCommandParam.Boolean() && iOnScreenDialer ) )
       
   446         {
       
   447         CallWaitingNoteL( aCallId );        
       
   448         }
       
   449     else
       
   450         {
       
   451         // Remove any phone dialogs if they are displayed
       
   452         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
   453         }
       
   454 
       
   455     // Indicate that the Phone needs to be sent to the background if
       
   456     // an application other than the top application is in the foreground
       
   457     TPhoneCmdParamBoolean booleanParam;
       
   458     booleanParam.SetBoolean( !TopAppIsDisplayedL() );
       
   459     iViewCommandHandle->ExecuteCommandL( 
       
   460         EPhoneViewSetNeedToSendToBackgroundStatus,
       
   461         &booleanParam );
       
   462 
       
   463     // Bring Phone app in the foreground
       
   464     TPhoneCmdParamInteger uidParam;
       
   465     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   466     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
   467         &uidParam );
       
   468 
       
   469     // Set Phone as the top application
       
   470     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
   471         &uidParam );
       
   472 
       
   473     CPhoneState::DisplayHeaderForCallComingInL( aCallId, ETrue ); //waiting call 
       
   474     }
       
   475     
       
   476 // -----------------------------------------------------------
       
   477 // CPhoneTwoSingles::UpdateInCallCbaL
       
   478 // -----------------------------------------------------------
       
   479 //
       
   480 EXPORT_C void CPhoneTwoSingles::UpdateInCallCbaL()
       
   481     {
       
   482     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneTwoSingles::UpdateInCallCbaL() ");
       
   483 	UpdateCbaL( EPhoneCallHandlingNewCallSwapCBA );
       
   484     }
       
   485 
       
   486 // End of File