phoneapp/phoneuistates/src/cphonestatemachinegsm.cpp
branchRCL_3
changeset 62 5266b1f337bd
parent 61 41a7f70b3818
child 81 c26cc2a7c548
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
     1 /*
     1 /*
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    38 #include "cphonetwosinglesandwaiting.h"
    38 #include "cphonetwosinglesandwaiting.h"
    39 #include "cphoneconferenceandsingleandwaiting.h"
    39 #include "cphoneconferenceandsingleandwaiting.h"
    40 #include "cphoneemergency.h"
    40 #include "cphoneemergency.h"
    41 #include "cphoneconferenceandwaitingandcallsetup.h"
    41 #include "cphoneconferenceandwaitingandcallsetup.h"
    42 #include "cphoneidle.h"
    42 #include "cphoneidle.h"
       
    43 #include "cphonestartup.h"
    43 #include "cphoneincoming.h"
    44 #include "cphoneincoming.h"
    44 #include "cphonestartup.h"
    45 #include "cphonestartupsimlockui.h"
       
    46 #include "cphonepubsubproxy.h"
       
    47 #include <startupdomainpskeys.h>
       
    48 #include "phoneconstants.h"
       
    49 #include <featmgr.h>
    45 
    50 
    46 // ================= MEMBER FUNCTIONS =======================
    51 // ================= MEMBER FUNCTIONS =======================
    47 
    52 
    48 // -----------------------------------------------------------------------------
    53 // -----------------------------------------------------------------------------
    49 // CPhoneStateMachineGSM::CPhoneStateMachineGSM
    54 // CPhoneStateMachineGSM::CPhoneStateMachineGSM
    65 //
    70 //
    66 EXPORT_C CPhoneStateMachineGSM::~CPhoneStateMachineGSM()
    71 EXPORT_C CPhoneStateMachineGSM::~CPhoneStateMachineGSM()
    67     {
    72     {
    68     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneStateMachineGSM::~CPhoneStateMachineGSM() ");
    73     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneStateMachineGSM::~CPhoneStateMachineGSM() ");
    69     if( iEmergencyState )
    74     if( iEmergencyState )
    70         {
    75 	    {
    71         delete iEmergencyState;
    76 	    delete iEmergencyState;
    72         iEmergencyState = NULL;         
    77 	    iEmergencyState = NULL;	    	
    73         }
    78 	    }
    74     Dll::FreeTls();
    79     Dll::FreeTls();
    75     }
    80     }
    76 
    81 
    77 // ---------------------------------------------------------
    82 // ---------------------------------------------------------
    78 // CPhoneStateMachineGSM::State
    83 // CPhoneStateMachineGSM::State
    97         if ( deleteOldState )
   102         if ( deleteOldState )
    98             {
   103             {
    99             // Possible that derived class has been deleted iState,
   104             // Possible that derived class has been deleted iState,
   100             // so this delete statement may be useless.
   105             // so this delete statement may be useless.
   101             delete iState;
   106             delete iState;
   102             iState = NULL;                      
   107             iState = NULL;	            		
   103             }
   108             }
   104         
   109         
   105         // State transition need to be made - construct new state and
   110         // State transition need to be made - construct new state and
   106         // destruct old
   111         // destruct old
   107         switch( iNewStateId )
   112         switch( iNewStateId )
   108             {
   113             {
   109             case EPhoneStateCallSetup:
   114             case EPhoneStateCallSetup:
   110                 TRAP( err, iState = CPhoneCallSetup::NewL( 
   115                 TRAP( err, iState = CPhoneCallSetup::NewL( 
   111                     this, iViewCommandHandle, iCustomization ));
   116                 	this, iViewCommandHandle, iCustomization ));
   112                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   117                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   113                 madeStateTransition = ETrue;
   118                 madeStateTransition = ETrue;
   114                 break;
   119                 break;
   115                 
   120                 
   116             case EPhoneStateAlerting:
   121             case EPhoneStateAlerting:
   117                 TRAP( err, iState = CPhoneAlerting::NewL(
   122                 TRAP( err, iState = CPhoneAlerting::NewL(
   118                     this, iViewCommandHandle, iCustomization ));
   123                 	this, iViewCommandHandle, iCustomization ));
   119                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   124                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   120                 madeStateTransition = ETrue;
   125                 madeStateTransition = ETrue;
   121                 break;
   126                 break;
   122                 
   127                 
   123             case EPhoneStateSingle:
   128             case EPhoneStateSingle:
   124                 TRAP( err, iState = CPhoneSingleCall::NewL( 
   129                 TRAP( err, iState = CPhoneSingleCall::NewL( 
   125                     this, iViewCommandHandle, iCustomization ));
   130                 	this, iViewCommandHandle, iCustomization ));
   126                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   131                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   127                 madeStateTransition = ETrue;
   132                 madeStateTransition = ETrue;
   128                 break;
   133                 break;
   129                 
   134                 
   130             case EPhoneStateWaitingInSingle:
   135             case EPhoneStateWaitingInSingle:
   131                 TRAP( err, iState = CPhoneSingleAndWaiting::NewL( 
   136                 TRAP( err, iState = CPhoneSingleAndWaiting::NewL( 
   132                     this, iViewCommandHandle, iCustomization ));
   137                 	this, iViewCommandHandle, iCustomization ));
   133                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   138                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   134                 madeStateTransition = ETrue;
   139                 madeStateTransition = ETrue;
   135                 break;
   140                 break;
   136                 
   141                 
   137             case EPhoneStateTwoSingles:
   142             case EPhoneStateTwoSingles:
   138                 TRAP( err, iState = CPhoneTwoSingles::NewL( 
   143                 TRAP( err, iState = CPhoneTwoSingles::NewL( 
   139                     this, iViewCommandHandle, iCustomization ));
   144                 	this, iViewCommandHandle, iCustomization ));
   140                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   145                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   141                 madeStateTransition = ETrue;
   146                 madeStateTransition = ETrue;
   142                 break;
   147                 break;
   143                 
   148                 
   144             case EPhoneStateCallSetupInSingle:
   149             case EPhoneStateCallSetupInSingle:
   145                 TRAP( err, iState = CPhoneSingleAndCallSetup::NewL( 
   150                 TRAP( err, iState = CPhoneSingleAndCallSetup::NewL( 
   146                     this, iViewCommandHandle, iCustomization ));
   151                 	this, iViewCommandHandle, iCustomization ));
   147                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   152                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   148                 madeStateTransition = ETrue;
   153                 madeStateTransition = ETrue;
   149                 break;
   154                 break;
   150                 
   155                 
   151             case EPhoneStateAlertingInSingle:
   156             case EPhoneStateAlertingInSingle:
   152                 TRAP( err, iState = CPhoneSingleAndAlerting::NewL( 
   157                 TRAP( err, iState = CPhoneSingleAndAlerting::NewL( 
   153                     this, iViewCommandHandle, iCustomization ));
   158                 	this, iViewCommandHandle, iCustomization ));
   154                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   159                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   155                 madeStateTransition = ETrue;
   160                 madeStateTransition = ETrue;
   156                 break;
   161                 break;
   157                 
   162                 
   158             case EPhoneStateConference:
   163             case EPhoneStateConference:
   159                 TRAP( err, iState = CPhoneConference::NewL( 
   164                 TRAP( err, iState = CPhoneConference::NewL( 
   160                     this, iViewCommandHandle, iCustomization ));
   165                 	this, iViewCommandHandle, iCustomization ));
   161                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   166                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   162                 madeStateTransition = ETrue;
   167                 madeStateTransition = ETrue;
   163                 break;
   168                 break;
   164                 
   169                 
   165             case EPhoneStateConferenceAndCallSetup:
   170             case EPhoneStateConferenceAndCallSetup:
   166                 TRAP( err, iState = CPhoneConferenceAndCallSetup::NewL( 
   171                 TRAP( err, iState = CPhoneConferenceAndCallSetup::NewL( 
   167                     this, iViewCommandHandle, iCustomization ) );
   172                 	this, iViewCommandHandle, iCustomization ) );
   168                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   173                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   169                 madeStateTransition = ETrue;
   174                 madeStateTransition = ETrue;
   170                 break;
   175                 break;
   171  
   176  
   172             case EPhoneStateConferenceAndSingle:
   177             case EPhoneStateConferenceAndSingle:
   173                 TRAP( err, iState = CPhoneConferenceAndSingle::NewL( 
   178                 TRAP( err, iState = CPhoneConferenceAndSingle::NewL( 
   174                     this, iViewCommandHandle, iCustomization ) );
   179                 	this, iViewCommandHandle, iCustomization ) );
   175                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   180                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   176                 madeStateTransition = ETrue;
   181                 madeStateTransition = ETrue;
   177                 break;
   182                 break;
   178                 
   183                 
   179             case EPhoneStateConferenceAndWaiting:
   184             case EPhoneStateConferenceAndWaiting:
   180                 TRAP( err, iState = CPhoneConferenceAndWaiting::NewL( 
   185                 TRAP( err, iState = CPhoneConferenceAndWaiting::NewL( 
   181                     this, iViewCommandHandle, iCustomization ) );
   186                 	this, iViewCommandHandle, iCustomization ) );
   182                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   187                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   183                 madeStateTransition = ETrue;
   188                 madeStateTransition = ETrue;
   184                 break;
   189                 break;
   185                 
   190                 
   186             case EPhoneStateSingleAndCallSetupAndWaiting:
   191             case EPhoneStateSingleAndCallSetupAndWaiting:
   187                 TRAP( err, iState = CPhoneSingleAndCallSetupAndWaiting::NewL( 
   192                 TRAP( err, iState = CPhoneSingleAndCallSetupAndWaiting::NewL( 
   188                     this, iViewCommandHandle, iCustomization ) );
   193                 	this, iViewCommandHandle, iCustomization ) );
   189                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   194                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   190                 madeStateTransition = ETrue;
   195                 madeStateTransition = ETrue;
   191                 break;
   196                 break;
   192                 
   197                 
   193             case EPhoneStateCallSetupAndWaiting:
   198             case EPhoneStateCallSetupAndWaiting:
   194                 TRAP( err, iState = CPhoneCallSetupAndWaiting::NewL( 
   199                 TRAP( err, iState = CPhoneCallSetupAndWaiting::NewL( 
   195                     this, iViewCommandHandle, iCustomization ) );
   200                 	this, iViewCommandHandle, iCustomization ) );
   196                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   201                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   197                 madeStateTransition = ETrue;
   202                 madeStateTransition = ETrue;
   198                 break;
   203                 break;
   199 
   204 
   200             case EPhoneStateTwoSinglesAndWaiting:
   205             case EPhoneStateTwoSinglesAndWaiting:
   201                 TRAP( err, iState = CPhoneTwoSinglesAndWaiting::NewL( 
   206                 TRAP( err, iState = CPhoneTwoSinglesAndWaiting::NewL( 
   202                     this, iViewCommandHandle, iCustomization ) );
   207                 	this, iViewCommandHandle, iCustomization ) );
   203                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   208                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   204                 madeStateTransition = ETrue;
   209                 madeStateTransition = ETrue;
   205                 break;
   210                 break;
   206                 
   211                 
   207             case EPhoneStateConferenceAndSingleAndWaiting:
   212             case EPhoneStateConferenceAndSingleAndWaiting:
   208                 TRAP( err, iState = CPhoneConferenceAndSingleAndWaiting::NewL( 
   213                 TRAP( err, iState = CPhoneConferenceAndSingleAndWaiting::NewL( 
   209                     this, iViewCommandHandle, iCustomization ));
   214                 	this, iViewCommandHandle, iCustomization ));
   210                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   215                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   211                 madeStateTransition = ETrue;
   216                 madeStateTransition = ETrue;
   212                 break;
   217                 break;
   213                 
   218                 
   214             case EPhoneStateEmergency:
   219             case EPhoneStateEmergency:
   215                 if( !iEmergencyStateConstructed )
   220                 if( !iEmergencyStateConstructed )
   216                     {
   221 	                {
   217                     TRAP( err, iEmergencyState = CPhoneEmergency::NewL( 
   222 	                TRAP( err, iEmergencyState = CPhoneEmergency::NewL( 
   218                         this, iViewCommandHandle, iCustomization ) );
   223 	                	this, iViewCommandHandle, iCustomization ) );
   219                     __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );                                          
   224 	                __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );						                	
   220                     iEmergencyStateConstructed = ETrue;
   225 					iEmergencyStateConstructed = ETrue;
   221                     }
   226 	                }
   222                 static_cast< CPhoneEmergency* >( iEmergencyState )->
   227                 static_cast< CPhoneEmergency* >( iEmergencyState )->
   223                     SetStartupInterrupted( iOldStateId == EPhoneStateStartup );
   228                     SetStartupInterrupted( iOldStateId == EPhoneStateStartup );
   224                 iState = iEmergencyState;
   229 				iState = iEmergencyState;
   225                 madeStateTransition = ETrue;
   230                 madeStateTransition = ETrue;
   226                 break;
   231                 break;
   227                 
   232                 
   228             case EPhoneStateConferenceAndWaitingAndCallSetup:
   233             case EPhoneStateConferenceAndWaitingAndCallSetup:
   229                 TRAP( err, iState = 
   234                 TRAP( err, iState = 
   230                     CPhoneConferenceAndWaitingAndCallSetup::NewL( 
   235           			CPhoneConferenceAndWaitingAndCallSetup::NewL( 
   231                         this, iViewCommandHandle, iCustomization ) );
   236           				this, iViewCommandHandle, iCustomization ) );
   232                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   237                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   233                 madeStateTransition = ETrue;
   238                 madeStateTransition = ETrue;
   234                 break;
   239                 break;
   235                 
   240                 
   236             case EPhoneStateIdle:
   241             case EPhoneStateIdle:
   237                 if ( iOldStateId != EPhoneStateEmergency )
   242             	if ( iOldStateId != EPhoneStateEmergency )
   238                     {
   243 	            	{
   239                     if( !iEmergencyStateConstructed )
   244                     if( !iEmergencyStateConstructed )
   240                         {
   245 	                    {
   241                         TRAP( err, iEmergencyState = CPhoneEmergency::NewL( 
   246 	                    TRAP( err, iEmergencyState = CPhoneEmergency::NewL( 
   242                             this, iViewCommandHandle, iCustomization ) );
   247 	                    	this, iViewCommandHandle, iCustomization ) );
   243                         __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );                                          
   248 	                    __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );						                	
   244                         iEmergencyStateConstructed = ETrue;
   249 					    iEmergencyStateConstructed = ETrue;
   245                         }
   250 	                    }
   246                     }
   251 	            	}
   247                 if( iIdleState == NULL )
   252 	            if( iIdleState == NULL )
   248                     {
   253 		            {
   249                     TRAP( err, iIdleState = 
   254 	                TRAP( err, iIdleState = 
   250                         CPhoneIdle::NewL( this, iViewCommandHandle, iCustomization ) );
   255 	          			CPhoneIdle::NewL( this, iViewCommandHandle, iCustomization ) );
   251                     __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   256 	                __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   252                     }
   257 		            }
   253                 iState = iIdleState;
   258 				iState = iIdleState;
   254                 madeStateTransition = ETrue;
   259                 madeStateTransition = ETrue;
   255                 break;
   260                 break;
   256                 
   261                 
   257             case EPhoneStateIncoming:
   262             case EPhoneStateIncoming:
   258                 TRAP( err, iState = 
   263                 TRAP( err, iState = 
   259                     CPhoneIncoming::NewL( this, iViewCommandHandle, iCustomization ) );
   264           			CPhoneIncoming::NewL( this, iViewCommandHandle, iCustomization ) );
   260                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   265                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   261                 madeStateTransition = ETrue;
   266                 madeStateTransition = ETrue;
   262                 break;
   267                 break;
   263 
   268 
   264             case EPhoneStateStartup:
   269             case EPhoneStateStartup:
   265                 TRAP( err, iState = 
   270             	
   266                     CPhoneStartup::NewL( this, iViewCommandHandle, 
   271                 if( IsSimlockStartupStateCreated() )
   267                     iOldStateId == EPhoneStateEmergency ) );
   272                     {
       
   273                     TRAP( err, iState =
       
   274                         CPhoneStartupSimlockUi::NewL( this, iViewCommandHandle,
       
   275                             iOldStateId == EPhoneStateEmergency ) );
       
   276                     }
       
   277                 else
       
   278                     {
       
   279                     TRAP( err, iState =
       
   280                         CPhoneStartup::NewL( this, iViewCommandHandle,
       
   281                             iOldStateId == EPhoneStateEmergency ) );
       
   282                     }
       
   283 
   268                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   284                 __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   269                 madeStateTransition = ETrue;
   285                 madeStateTransition = ETrue;
   270                 break;
   286                 break;
   271 
   287 
   272             default:
   288             default:
   277 
   293 
   278     if ( madeStateTransition )
   294     if ( madeStateTransition )
   279         {
   295         {
   280         __PHONELOGSTATECHANGE( iOldStateId, iNewStateId );
   296         __PHONELOGSTATECHANGE( iOldStateId, iNewStateId );
   281         iOldStateId = iNewStateId;
   297         iOldStateId = iNewStateId;
       
   298         
       
   299         // Needs to be set or any attempts to access eikon env handle
       
   300         // will fail
       
   301         iState->SetEikonEnv( EikonEnv() );
   282         }
   302         }
   283 
   303 
   284     return iState;
   304     return iState;
   285     }
   305     }
       
   306 
       
   307 
       
   308 // -----------------------------------------------------------
       
   309 // CPhoneStateMachineGSM::IsSimlockStartupStateCreated
       
   310 // -----------------------------------------------------------
       
   311 //
       
   312 TBool CPhoneStateMachineGSM::IsSimlockStartupStateCreated() const
       
   313     {
       
   314     if ( FeatureManager::FeatureSupported( KFeatureIdFfSimlockUi ) )
       
   315         {
       
   316         TInt securityStatus =
       
   317                 CPhonePubSubProxy::Instance()->Value(
       
   318                         KPSUidStartup, KStartupSimSecurityStatus );
       
   319         if ( securityStatus == ESimUnaccepted )
       
   320             {
       
   321             return ETrue;
       
   322             }
       
   323         }
       
   324 
       
   325     return EFalse;
       
   326     }
       
   327 
   286 
   328 
   287 // -----------------------------------------------------------
   329 // -----------------------------------------------------------
   288 // CPhoneStateMachineGSM::NewL()
   330 // CPhoneStateMachineGSM::NewL()
   289 // Constructor
   331 // Constructor
   290 // (other items were commented in a header).
   332 // (other items were commented in a header).