phoneapp/phoneuicontrol/src/cphonestatemachine.cpp
branchRCL_3
changeset 62 5266b1f337bd
parent 61 41a7f70b3818
child 81 c26cc2a7c548
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
    27 #include "cphonestateincoming.h"
    27 #include "cphonestateincoming.h"
    28 #include "cphonestatecallsetup.h"
    28 #include "cphonestatecallsetup.h"
    29 #include "cphonestateincall.h"
    29 #include "cphonestateincall.h"
    30 #include "phonestatedefinitions.h"
    30 #include "phonestatedefinitions.h"
    31 #include "phonelogger.h"
    31 #include "phonelogger.h"
    32 #include "cphonestorage.h"
    32 #include "mphonesecuritymodeobserver.h"
    33 #include "mphonestorage.h"
    33 #include "mphonesecuritymessagehandler.h"
    34 
    34 
    35 // ================= MEMBER FUNCTIONS =======================
    35 // ================= MEMBER FUNCTIONS =======================
    36 
    36 
    37 // C++ default constructor can NOT contain any code, that
    37 // C++ default constructor can NOT contain any code, that
    38 // might leave.
    38 // might leave.
    39 //
    39 //
    40 EXPORT_C CPhoneStateMachine::CPhoneStateMachine(
    40 EXPORT_C CPhoneStateMachine::CPhoneStateMachine(
    41     MPhoneViewCommandHandle* aViewCommandHandle ) :
    41     MPhoneViewCommandHandle* aViewCommandHandle ) :
    42     iOldStateId( EPhoneStateNull ),
    42     iOldStateId( EPhoneStateNull ),
    43     iNewStateId( EPhoneStateNull ),
    43     iNewStateId( EPhoneStateNull ),
    44     iViewCommandHandle( aViewCommandHandle )
    44     iViewCommandHandle( aViewCommandHandle ),
       
    45     iEnv( CEikonEnv::Static() ) // codescanner::eikonenvstatic
    45     {
    46     {
    46     __ASSERT_ALWAYS( aViewCommandHandle,
    47     __ASSERT_ALWAYS( aViewCommandHandle,
    47         Panic( EPhoneCtrlParameterNotInitialized ) );
    48     	Panic( EPhoneCtrlParameterNotInitialized ) );
    48     }
    49     }
    49 
    50 
    50 // -----------------------------------------------------------
    51 // -----------------------------------------------------------
    51 // CPhoneStateMachine::~CPhoneStateMachine()
    52 // CPhoneStateMachine::~CPhoneStateMachine()
    52 // Destructor
    53 // Destructor
    53 // (other items were commented in a header).
    54 // (other items were commented in a header).
    54 // -----------------------------------------------------------
    55 // -----------------------------------------------------------
    55 //
    56 //
    56 EXPORT_C CPhoneStateMachine::~CPhoneStateMachine()
    57 EXPORT_C CPhoneStateMachine::~CPhoneStateMachine()
    57     {
    58     {
    58     if( iState == iIdleState )
    59 	if( iState == iIdleState )
    59         {
    60 		{
    60         delete iState;
    61 		// Avoid deleting idle state instance twice.
    61         iState = NULL;
    62 		// If state is idle, iState points to idle state instance.
    62         iIdleState = NULL;          
    63 		iIdleState = NULL;			
    63         }
    64 		}
    64     else
    65 	delete iState;
    65         {
    66 	delete iIdleState;
    66         if( iState )
    67 	delete iPhoneEngine;
    67             {
    68 	}
    68             delete iState;
       
    69             iState = NULL;          
       
    70             }
       
    71         if( iIdleState )
       
    72             {
       
    73             delete iIdleState;
       
    74             iIdleState = NULL;          
       
    75             }           
       
    76         }
       
    77     if( iPhoneEngine )
       
    78         {
       
    79         delete iPhoneEngine;
       
    80         iPhoneEngine = NULL;            
       
    81         }
       
    82     if( iPhoneStorage )
       
    83         {
       
    84         delete iPhoneStorage;
       
    85         iPhoneStorage = NULL;
       
    86         }
       
    87     }
       
    88 
    69 
    89 // ---------------------------------------------------------
    70 // ---------------------------------------------------------
    90 // CPhoneStateMachine::SetPhoneEngine
    71 // CPhoneStateMachine::SetPhoneEngine
    91 // ---------------------------------------------------------
    72 // ---------------------------------------------------------
    92 //
    73 //
    93 EXPORT_C void CPhoneStateMachine::SetPhoneEngine( 
    74 EXPORT_C void CPhoneStateMachine::SetPhoneEngine( 
    94     MPEPhoneModel* aPhoneEngine )
    75     MPEPhoneModel* aPhoneEngine )
    95     {
    76     {
    96     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateMachine::SetPhoneEngine ");
    77     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateMachine::SetPhoneEngine ");
    97     __ASSERT_ALWAYS( aPhoneEngine, 
    78     __ASSERT_ALWAYS( aPhoneEngine, 
    98         Panic( EPhoneCtrlParameterNotInitialized ) );
    79     	Panic( EPhoneCtrlParameterNotInitialized ) );
    99     
    80     
   100     iPhoneEngine = aPhoneEngine;
    81     iPhoneEngine = aPhoneEngine;
   101     }
    82     }
   102 
    83 
   103 // -----------------------------------------------------------
    84 // -----------------------------------------------------------
   181         "CALL ID: CPhoneStateMachine::SetCallId (%d)",
   162         "CALL ID: CPhoneStateMachine::SetCallId (%d)",
   182         aCallId);     
   163         aCallId);     
   183     PhoneEngineInfo()->SetCallId( aCallId );
   164     PhoneEngineInfo()->SetCallId( aCallId );
   184     }
   165     }
   185 
   166 
   186 // -----------------------------------------------------------
   167 
   187 // CPhoneStateMachine::PhoneStorage
   168 // -----------------------------------------------------------
   188 // -----------------------------------------------------------
   169 // CPhoneStateMachine::SecurityMode
   189 //
   170 // -----------------------------------------------------------
   190 EXPORT_C MPhoneStorage* CPhoneStateMachine::PhoneStorage()
   171 //
   191     {
   172 EXPORT_C MPhoneSecurityModeObserver* CPhoneStateMachine::SecurityMode()
   192     if ( iPhoneStorage == NULL )
   173 	{
   193         {
   174 	return iSecurityModeObserver;
   194         TInt err( KErrNone );
   175 	}
   195         TRAP( err, iPhoneStorage = CPhoneStorage::NewL());
   176 	
   196         __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
   177 // -----------------------------------------------------------
   197         }
   178 // CPhoneStateMachine::SetSecurityModeObserver
   198     return iPhoneStorage;
   179 // -----------------------------------------------------------
   199     }
   180 //
   200 
   181 EXPORT_C void CPhoneStateMachine::SetSecurityModeObserver( MPhoneSecurityModeObserver* aObserver )
       
   182 	{
       
   183 	iSecurityModeObserver = aObserver;
       
   184 	}
       
   185 
       
   186 // -----------------------------------------------------------
       
   187 // CPhoneStateMachine::SetSecurityMessageHandler
       
   188 // -----------------------------------------------------------
       
   189 //
       
   190 EXPORT_C void CPhoneStateMachine::SetSecurityMessageHandler( MPhoneSecurityMessageHandler* aHandler )
       
   191 	{
       
   192 	iSecurityMessageHandler = aHandler;
       
   193 	}
       
   194 
       
   195 // -----------------------------------------------------------
       
   196 // CPhoneStateMachine::HandlePhoneEngineMessageL
       
   197 // -----------------------------------------------------------
       
   198 //
       
   199 EXPORT_C void CPhoneStateMachine::HandlePhoneEngineMessageL(const TInt aMessage, 
       
   200      TInt aCallId )
       
   201 	{
       
   202 	// Forward engine messages to security mode state and current phone state
       
   203 	// instance.
       
   204 	if ( iSecurityMessageHandler )
       
   205 		{
       
   206 		iSecurityMessageHandler->HandlePhoneEngineMessageL( aMessage, aCallId );
       
   207 		}
       
   208 	
       
   209 	State()->HandlePhoneEngineMessageL( aMessage, aCallId );
       
   210 	}
       
   211 
       
   212 // -----------------------------------------------------------
       
   213 // CPhoneStateMachine::HandlePropertyChangedL
       
   214 // -----------------------------------------------------------
       
   215 //
       
   216 EXPORT_C void CPhoneStateMachine::HandlePropertyChangedL(const TUid& aCategory,
       
   217      const TUint aKey,
       
   218      const TInt aValue )
       
   219 	{
       
   220 	// Forward P&S key changes to security mode state and current phone state
       
   221 	// instance.
       
   222 	if ( iSecurityMessageHandler )
       
   223 		{
       
   224 		iSecurityMessageHandler->HandlePropertyChangedL( aCategory, aKey, aValue );
       
   225 		}
       
   226 	State()->HandlePropertyChangedL( aCategory, aKey, aValue );
       
   227 	}
       
   228 
       
   229 // -----------------------------------------------------------
       
   230 // CPhoneStateMachine::EikonEnv
       
   231 // -----------------------------------------------------------
       
   232 //
       
   233 EXPORT_C CEikonEnv* CPhoneStateMachine::EikonEnv() const
       
   234     {
       
   235     return iEnv;
       
   236     }
       
   237 	
   201 // End of File
   238 // End of File