uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/states.cpp
changeset 0 15bf7259bb7c
child 8 10534483575f
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   State machine state implementations
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include  <akntranseffect.h> // for Transition effect enumerations
       
    21 #include <alflogger.h>
       
    22 #include "states.h"
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // ---------------------------------------------------------------------------
       
    26 // CRestingState construction
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 CRestingState::CRestingState(MAlfDrawerEngine& aEngine, CStateHandler& aHandler) : 
       
    30 	CStateBase(aEngine,aHandler)
       
    31 		{
       
    32 		}
       
    33 
       
    34 CStateBase* CRestingState::NewL(MAlfDrawerEngine& aEngine, CStateHandler& aHandler)
       
    35 	{
       
    36 	CRestingState* self = new (ELeave) CRestingState(aEngine,aHandler);
       
    37 	self->iStateInfo.iState = EResting;
       
    38 	return self;	
       
    39 	}
       
    40 	
       
    41 // ---------------------------------------------------------------------------
       
    42 // CRestingState Signal handling
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CStateBase* CRestingState::SignalL(TSignal aSignal)
       
    46 	{
       
    47 	__ALFFXLOGSTRING1("CRestingState::SignalL %d >>", aSignal);
       
    48 	TInt error = KErrNone;
       
    49 	switch( aSignal ) 
       
    50 		{
       
    51 		case EBeginFullscreen:
       
    52             if( !IsBlocked( iEngine.FromUid(), iEngine.ToUid() ) ) 
       
    53 		        {
       
    54     			iEngine.SendBeginFullscreen();
       
    55 			    return CPhase1State::NewL( iEngine,iHandler );
       
    56 			    }
       
    57 		    return NULL;
       
    58 
       
    59 		case EBeginComponent:
       
    60 		    error = iEngine.SendBeginControlTransition();
       
    61 		    if ( error == KErrNone )
       
    62 		        {
       
    63          		return CControlState::NewL( iEngine, iHandler );
       
    64 		        }
       
    65 		    return NULL;    
       
    66 
       
    67 		case EEndFullscreen:
       
    68 //		    iEngine.SendEndFullscreen(); // TODO: revise?
       
    69 //		    return CRestingState::NewL( iEngine, iHandler );
       
    70 
       
    71 		case EAbortFullscreen:
       
    72 			iEngine.SendAbortFullscreen();
       
    73 			return CRestingState::NewL( iEngine, iHandler );
       
    74 		}
       
    75 	return NULL;
       
    76 	}
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // ---------------------------------------------------------------------------
       
    81 // CControlState construction
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 CControlState::CControlState(MAlfDrawerEngine& aEngine, CStateHandler& aHandler) : 
       
    85 	CStateBase(aEngine,aHandler)
       
    86 		{
       
    87 		}
       
    88 
       
    89 CStateBase* CControlState::NewL(MAlfDrawerEngine& aEngine, CStateHandler& aHandler)
       
    90 	{
       
    91 	CControlState* self = new (ELeave) CControlState(aEngine,aHandler);
       
    92 	self->iStateInfo.iState = EComponent;
       
    93 	return self;	
       
    94 	}
       
    95 	
       
    96 // ---------------------------------------------------------------------------
       
    97 // CControlState signal handling
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 CStateBase* CControlState::SignalL(TSignal aSignal)
       
   101 	{
       
   102     __ALFFXLOGSTRING1("CControlState::SignalL %d >>", aSignal);
       
   103 
       
   104     TInt error = KErrNone;	
       
   105 	switch( aSignal )
       
   106 		{
       
   107 		case EAbort:
       
   108 		case EAbortComponent:
       
   109 			iEngine.SendAbortControlTransition();
       
   110 			return CRestingState::NewL( iEngine, iHandler );
       
   111 		case EFinishComponent:
       
   112 		    // do something to finish
       
   113 		    iEngine.SendFinishControlTransition();
       
   114 			return CRestingState::NewL( iEngine, iHandler );
       
   115 		case EBeginFullscreen:
       
   116 			if( !IsBlocked( iEngine.FromUid(), iEngine.ToUid() ) )
       
   117 				{
       
   118 				iEngine.SendBeginFullscreen();
       
   119 				return CPhase1State::NewL( iEngine,iHandler );
       
   120 				}
       
   121 			return NULL;
       
   122 		case EBeginComponent:
       
   123 		    // we don't limit control transitions
       
   124 		    // we don't have an ending signal for the controls now
       
   125 		    // We may need something to be able to call
       
   126 		    // SendFinishControlTransition
       
   127 		    error = iEngine.SendBeginControlTransition();
       
   128 		    if ( error == KErrNone )
       
   129 		        {
       
   130          		return CControlState::NewL( iEngine, iHandler );
       
   131 		        }
       
   132 		    return NULL;    
       
   133 		}
       
   134 	return NULL;
       
   135 	}
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // ---------------------------------------------------------------------------
       
   139 // CPhase1State construction
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 CPhase1State::CPhase1State(MAlfDrawerEngine& aEngine, CStateHandler& aHandler) : 
       
   143 	CStateBase(aEngine,aHandler)
       
   144 		{
       
   145 		}
       
   146 
       
   147 CStateBase* CPhase1State::NewL(MAlfDrawerEngine& aEngine, CStateHandler& aHandler)
       
   148 	{
       
   149 	CPhase1State* self = new (ELeave) CPhase1State(aEngine,aHandler);
       
   150 	self->iStateInfo.iState = EFullscreenPhase1;
       
   151 	self->iStateInfo.iAction = aEngine.Action();
       
   152 	return self;	
       
   153 	}
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // CPhase1State Signal handling
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 CStateBase* CPhase1State::SignalL(TSignal aSignal)
       
   160 	{
       
   161     TInt error = KErrNone;	
       
   162 	switch(aSignal)
       
   163 		{
       
   164 		case EAbort:
       
   165 		case EAbortFullscreen:
       
   166    			iEngine.SendAbortFullscreen();
       
   167 			return CRestingState::NewL(iEngine,iHandler);
       
   168         case EFinishFullscreen:
       
   169 		    if ( !iEngine.EffectFinishedFullScreen() )
       
   170 		        {
       
   171     			iEngine.SendAbortFullscreen();
       
   172 		        }
       
   173             return CRestingState::NewL(iEngine,iHandler);
       
   174 		case EEndFullscreen:
       
   175 			iEngine.SendEndFullscreen();
       
   176 			return CPhase2State::NewL(iEngine,iHandler);
       
   177 		case EBeginFullscreen:
       
   178 			if(!IsBlocked(iEngine.FromUid(),iEngine.ToUid())) 
       
   179 				{
       
   180     		    iEngine.SendBeginFullscreen();
       
   181 				}
       
   182 			return NULL;
       
   183 		case EBeginComponent:
       
   184 		    error = iEngine.SendBeginControlTransition();
       
   185 		    if ( error == KErrNone )
       
   186 		        {
       
   187          		return CControlState::NewL( iEngine, iHandler );
       
   188 		        }
       
   189 		    return NULL;    
       
   190 		}
       
   191 	return NULL;
       
   192 	}
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // ---------------------------------------------------------------------------
       
   196 // CPhase2State construction
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 CPhase2State::CPhase2State(MAlfDrawerEngine& aEngine, CStateHandler& aHandler) : 
       
   200 	CStateBase(aEngine,aHandler)
       
   201 		{
       
   202 		}
       
   203 
       
   204 CStateBase* CPhase2State::NewL(MAlfDrawerEngine& aEngine, CStateHandler& aHandler)
       
   205 	{
       
   206 	CPhase2State* self = new (ELeave) CPhase2State(aEngine,aHandler);
       
   207 	self->iStateInfo.iState = EFullscreenPhase2;
       
   208 	self->iStateInfo.iAction = aEngine.Action();
       
   209 	return self;	
       
   210 	}
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // CPhase2State Signal handling
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 CStateBase* CPhase2State::SignalL(TSignal aSignal)
       
   217 	{
       
   218     TInt error = KErrNone;	
       
   219 	switch(aSignal)
       
   220 		{
       
   221 		case EAbort:
       
   222 		case EAbortFullscreen:
       
   223 			iEngine.SendAbortFullscreen();
       
   224 			return CRestingState::NewL(iEngine,iHandler);
       
   225 		case EFinishFullscreen:
       
   226 		    if ( ( iEngine.Action() == 1001 || iEngine.Action() == AknTransEffect::EApplicationExit ) &&
       
   227 		        !iEngine.EffectFinishedFullScreen() )
       
   228 		        {
       
   229 		        iEngine.SendAbortFullscreen();
       
   230 		        }
       
   231 			return CRestingState::NewL(iEngine,iHandler);
       
   232 		case EBeginFullscreen:
       
   233 			if(!IsBlocked(iEngine.FromUid(),iEngine.ToUid()))
       
   234 				{
       
   235 				iEngine.SendBeginFullscreen();
       
   236 				return CPhase1State::NewL(iEngine,iHandler);
       
   237 				}
       
   238 			return NULL;
       
   239 		case EBeginComponent:
       
   240 		    error = iEngine.SendBeginControlTransition();
       
   241 		    if ( error == KErrNone )
       
   242 		        {
       
   243          		return CControlState::NewL( iEngine, iHandler );
       
   244 		        }
       
   245 		    return NULL;    
       
   246 		}
       
   247 	return NULL;
       
   248 	}