vtuis/videotelui/src/CVtUiActiveExec.cpp
branchRCL_3
changeset 24 f15ac8e65a02
parent 23 890b5dd735f8
child 25 779871d1e4f4
equal deleted inserted replaced
23:890b5dd735f8 24:f15ac8e65a02
     1 /*
       
     2 * Copyright (c) 2004 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 the CVtUiActiveExec class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CVtUiActiveExec.h"
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS ===============================
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CVtUiActiveExec::CVtUiActiveExec
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CVtUiActiveExec::CVtUiActiveExec(
       
    30         const TInt aPriority )
       
    31     : CActive( aPriority )
       
    32     {
       
    33     CActiveScheduler::Add( this );
       
    34     }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CVtUiActiveExec::~CVtUiActiveExec
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CVtUiActiveExec::~CVtUiActiveExec()
       
    41     {
       
    42     Cancel();
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CVtUiActiveExec::Start
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CVtUiActiveExec::Start( 
       
    50         TInt aStartState, 
       
    51         MVtUiActiveExec& aExec )
       
    52     {
       
    53     Cancel();
       
    54 
       
    55     iInitialState = aStartState;
       
    56     iCurrentState = aStartState;
       
    57     iNextState = aStartState;
       
    58 
       
    59     iActiveExec = &aExec;
       
    60 
       
    61     TRequestStatus* status = &iStatus;
       
    62     User::RequestComplete( status, KErrNone );
       
    63     SetActive();
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CVtUiActiveExec::InitialState
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 TInt CVtUiActiveExec::InitialState() const
       
    71     {
       
    72     return iInitialState;
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CVtUiActiveExec::RequestStatus
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TInt CVtUiActiveExec::RequestStatus() const
       
    80     {
       
    81     return iStatus.Int();
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CVtUiActiveExec::RunL
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CVtUiActiveExec::RunL()
       
    89     {
       
    90     User::LeaveIfError( iStatus.Int() );
       
    91     TBool synch = ETrue;
       
    92 
       
    93     // Execute to the next asynchronous operation.
       
    94     while ( synch )
       
    95         {
       
    96         iCurrentState = iNextState;
       
    97         if ( iCurrentState )
       
    98             {
       
    99             synch = iActiveExec->ActiveExecExecuteL( 
       
   100                 *this,
       
   101                 iCurrentState, 
       
   102                 iNextState, 
       
   103                 iStatus );
       
   104 
       
   105             if ( !synch )
       
   106                 {
       
   107                 SetActive();
       
   108                 }
       
   109             }
       
   110         else
       
   111             {   
       
   112             iActiveExec->ActiveExecDone( *this, iInitialState );
       
   113             if ( !IsActive() )
       
   114                 {
       
   115                 iInitialState = 0;
       
   116                 }
       
   117 
       
   118             synch = EFalse;
       
   119             }
       
   120         }
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CVtUiActiveExec::DoCancel
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 void CVtUiActiveExec::DoCancel()
       
   128     {
       
   129     if ( iActiveExec )
       
   130         {
       
   131         iActiveExec->ActiveExecCancel( *this, iCurrentState );
       
   132         
       
   133         iCurrentState = 0;
       
   134         iActiveExec = NULL;
       
   135         iInitialState = 0;
       
   136         }
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CVtUiActiveExec::RunError
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 TInt CVtUiActiveExec::RunError( TInt aError )
       
   144     {
       
   145     if ( iActiveExec->ActiveExecContinue( *this, iCurrentState, aError ) )
       
   146         {
       
   147         iNextState = iCurrentState;
       
   148 
       
   149         TRequestStatus* status = &iStatus;
       
   150         User::RequestComplete( status, KErrNone );
       
   151         SetActive();
       
   152         }
       
   153     else
       
   154         {
       
   155         if ( !IsActive() )
       
   156             {
       
   157             iInitialState = 0;
       
   158             }
       
   159         }
       
   160     
       
   161     return KErrNone;
       
   162     }
       
   163 
       
   164 //  End of File