phoneapp/phoneuistates/src/cphonetwosingles.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 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     SetTouchPaneButtons( EPhoneIncallButtons );
       
   301     }
       
   302     
       
   303 // -----------------------------------------------------------
       
   304 // CPhoneTwoSingles::HandleHeldL
       
   305 // -----------------------------------------------------------
       
   306 //
       
   307 void CPhoneTwoSingles::HandleHeldL( TInt aCallId )
       
   308     {
       
   309     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   310         "CPhoneTwoSingles::HandleHeldL()");
       
   311     // Display hold bubble
       
   312     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   313     callHeaderParam.SetCallState( EPEStateHeld );
       
   314     
       
   315     TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
       
   316     TInt callLabelId = CPhoneMainResourceResolver::Instance()->
       
   317             ResolveResourceID( EPhoneCallOnHold );
       
   318 
       
   319     StringLoader::Load( 
       
   320         labelText, 
       
   321         callLabelId, 
       
   322         CCoeEnv::Static() );        
       
   323     callHeaderParam.SetLabelText( labelText );
       
   324     
       
   325     iViewCommandHandle->ExecuteCommandL( EPhoneViewUpdateBubble, aCallId, 
       
   326         &callHeaderParam );
       
   327     
       
   328     SetTouchPaneButtons( EPhoneIncallButtons );
       
   329     }
       
   330     
       
   331 // -----------------------------------------------------------
       
   332 // CPhoneTwoSingles::HandleNumberEntryClearedL()
       
   333 // -----------------------------------------------------------
       
   334 //
       
   335 EXPORT_C void CPhoneTwoSingles::HandleNumberEntryClearedL()
       
   336     {
       
   337     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   338         "CPhoneTwoSingles::HandleNumberEntryClearedL()");
       
   339     UpdateCbaL( EPhoneCallHandlingNewCallSwapCBA );
       
   340     }
       
   341 
       
   342 // -----------------------------------------------------------
       
   343 // CPhoneTwoSingles::HandleConnectedConferenceL
       
   344 // -----------------------------------------------------------
       
   345 //
       
   346 EXPORT_C void CPhoneTwoSingles::HandleConnectedConferenceL( TInt aCallId )
       
   347     {
       
   348     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   349         "CPhoneTwoSingles::HandleConnectedConferenceL()");
       
   350     // Update call state
       
   351     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   352 
       
   353     TInt callLabelId;
       
   354     TBuf<KPhoneCallHeaderLabelMaxLength> conferenceText( KNullDesC );
       
   355     callLabelId = CPhoneMainResourceResolver::Instance()->
       
   356             ResolveResourceID( EPhoneCLIConferenceCall );
       
   357 
       
   358     StringLoader::Load( 
       
   359         conferenceText, 
       
   360         callLabelId, 
       
   361         CCoeEnv::Static() );
       
   362     callHeaderParam.SetCLIText( conferenceText, TPhoneCmdParamCallHeaderData::ERight );
       
   363     
       
   364     callHeaderParam.SetCallState(EPEStateConnectedConference);
       
   365     BeginUiUpdateLC();
       
   366     
       
   367     callHeaderParam.SetCiphering(
       
   368         iStateMachine->PhoneEngineInfo()->IsSecureCall( aCallId ) );
       
   369         
       
   370     callHeaderParam.SetCipheringIndicatorAllowed(
       
   371         iStateMachine->PhoneEngineInfo()->SecureSpecified() );
       
   372     
       
   373     // Service identifier must be given so that service specific settings
       
   374     // can be taken into account at phoneuiview.
       
   375     callHeaderParam.SetServiceId( 
       
   376         iStateMachine->PhoneEngineInfo()->ServiceId( aCallId ) );
       
   377     
       
   378     iViewCommandHandle->ExecuteCommandL( EPhoneViewCreateConference, aCallId,
       
   379         &callHeaderParam );
       
   380 
       
   381     // Set Hold flag to view
       
   382     TPhoneCmdParamBoolean holdFlag;
       
   383     holdFlag.SetBoolean( EFalse );
       
   384     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetHoldFlag, &holdFlag );
       
   385 
       
   386     SetTouchPaneButtons( EPhoneConferenceButtons );
       
   387     SetTouchPaneButtonEnabled( EPhoneInCallCmdPrivate );
       
   388     EndUiUpdate();
       
   389     
       
   390     UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   391     
       
   392     // Go to conference state
       
   393     // No need for CBA update
       
   394     iStateMachine->ChangeState( EPhoneStateConference );
       
   395     }
       
   396 
       
   397 // -----------------------------------------------------------
       
   398 // CPhoneTwoSingles::HandleIncomingL
       
   399 // -----------------------------------------------------------
       
   400 //
       
   401 void CPhoneTwoSingles::HandleIncomingL( TInt aCallId )
       
   402     {
       
   403     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   404         "CPhoneTwoSingles::HandleIncomingL()");
       
   405     
       
   406     BeginUiUpdateLC();
       
   407     
       
   408     TPhoneCmdParamBoolean dialerParam;
       
   409     dialerParam.SetBoolean( ETrue );
       
   410     
       
   411     // Get allow waiting call header param value.
       
   412     AllowShowingOfWaitingCallHeaderL( dialerParam );
       
   413     
       
   414     // Close fast swap window if it's displayed
       
   415     CEikonEnv::Static()->DismissTaskList();
       
   416 
       
   417     // Display incoming call
       
   418     DisplayIncomingCallL( aCallId, dialerParam );
       
   419     
       
   420     // Set touch controls
       
   421     SetTouchPaneButtonDisabled( EPhoneCallComingCmdAnswer );
       
   422     
       
   423     // Check if HW Keys or Call UI should be disabled
       
   424     CheckDisableHWKeysAndCallUIL();
       
   425     
       
   426     SetTouchPaneButtons( EPhoneWaitingCallButtons );
       
   427 
       
   428     EndUiUpdate();
       
   429 
       
   430     // Go to incoming state
       
   431     iCbaManager->SetCbaL( EPhoneCallHandlingIncomingRejectCBA );
       
   432     
       
   433     iStateMachine->ChangeState( EPhoneStateTwoSinglesAndWaiting );        
       
   434     }
       
   435 
       
   436 // -----------------------------------------------------------
       
   437 // CPhoneTwoSingles::DisplayIncomingCallL
       
   438 // -----------------------------------------------------------
       
   439 //
       
   440 void CPhoneTwoSingles::DisplayIncomingCallL( 
       
   441     TInt aCallId, 
       
   442     const TPhoneCmdParamBoolean aCommandParam )
       
   443     {
       
   444     __LOGMETHODSTARTEND( EPhoneUIStates,
       
   445          "CPhoneTwoSingles::DisplayIncomingCallL()"); 
       
   446     // Close menu bar, if it is displayed
       
   447     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   448 
       
   449     // Cannot delete active note, e.g. New call query, 
       
   450     // but show waiting note with or without caller name
       
   451     if ( IsAnyQueryActiveL() ||  
       
   452         ( !aCommandParam.Boolean() && iOnScreenDialer ) )
       
   453         {
       
   454         CallWaitingNoteL( aCallId );        
       
   455         }
       
   456     else
       
   457         {
       
   458         // Remove any phone dialogs if they are displayed
       
   459         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
   460         }
       
   461 
       
   462     // Indicate that the Phone needs to be sent to the background if
       
   463     // an application other than the top application is in the foreground
       
   464     TPhoneCmdParamBoolean booleanParam;
       
   465     booleanParam.SetBoolean( !TopAppIsDisplayedL() );
       
   466     iViewCommandHandle->ExecuteCommandL( 
       
   467         EPhoneViewSetNeedToSendToBackgroundStatus,
       
   468         &booleanParam );
       
   469 
       
   470     // Bring Phone app in the foreground
       
   471     TPhoneCmdParamInteger uidParam;
       
   472     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   473     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
   474         &uidParam );
       
   475 
       
   476     // Set Phone as the top application
       
   477     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
   478         &uidParam );
       
   479 
       
   480     CPhoneState::DisplayHeaderForCallComingInL( aCallId, ETrue ); //waiting call 
       
   481     }
       
   482     
       
   483 // -----------------------------------------------------------
       
   484 // CPhoneTwoSingles::UpdateInCallCbaL
       
   485 // -----------------------------------------------------------
       
   486 //
       
   487 EXPORT_C void CPhoneTwoSingles::UpdateInCallCbaL()
       
   488     {
       
   489     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneTwoSingles::UpdateInCallCbaL() ");
       
   490     UpdateCbaL( EPhoneCallHandlingNewCallSwapCBA );
       
   491     }
       
   492 
       
   493 // End of File