testexecmdw/tef/tef/utils/src/activecallback.cpp
branchRCL_3
changeset 3 9397a16b6eb8
parent 1 6edeef394eb7
equal deleted inserted replaced
1:6edeef394eb7 3:9397a16b6eb8
     1 /*
       
     2 * Copyright (c) 2005-2009 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:  
       
    15 * @file
       
    16 * This contains CActiveCallback
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @prototype
       
    24  @test
       
    25 */
       
    26 
       
    27 #include "activecallback.h"
       
    28 
       
    29 EXPORT_C CActiveCallback::~CActiveCallback()
       
    30 /**
       
    31  * Destructor
       
    32  */
       
    33 	{
       
    34 	Cancel();
       
    35 	}
       
    36 
       
    37 EXPORT_C CActiveCallback* CActiveCallback::NewL(MActiveCallback& aCallback, TInt aPriority)
       
    38 /**
       
    39  * Two phase constructor that allocates and constructs
       
    40  * a new Active object whos actions are performed by a callback
       
    41  *
       
    42  * @param	aCallback - object to inform on RunL.
       
    43  * @param	aPriority - priority of active object.
       
    44  *
       
    45  * @see		MActiveCallback
       
    46  *
       
    47  * @leave	system wide error
       
    48  *
       
    49  * @return	New Callback active object.
       
    50  */
       
    51 	{
       
    52 	CActiveCallback*	self=NewLC(aCallback, aPriority);
       
    53 	CleanupStack::Pop();
       
    54 	return self;
       
    55 	}
       
    56 
       
    57 EXPORT_C CActiveCallback* CActiveCallback::NewLC(MActiveCallback& aCallback, TInt aPriority)
       
    58 /**
       
    59  * Two phase constructor that allocates and constructs
       
    60  * a new Active object whos actions are performed by a callback
       
    61  *
       
    62  * @param	aCallback - object to inform on RunL.
       
    63  * @param	aPriority - priority of active object.
       
    64  *
       
    65  * @see		MActiveCallback
       
    66  *
       
    67  * @leave	system wide error
       
    68  *
       
    69  * @return	New Callback active object.
       
    70  */
       
    71 	{
       
    72 	CActiveCallback*	self=new(ELeave) CActiveCallback(aCallback, aPriority);
       
    73 	CleanupStack::PushL(self);
       
    74 	self->ConstructL();
       
    75 	return self;
       
    76 	}
       
    77 
       
    78 EXPORT_C void CActiveCallback::Activate( TInt aIndex )
       
    79 /**
       
    80  * Activate the object
       
    81  *
       
    82  * @param	aIndex - command index
       
    83  */
       
    84 	{
       
    85 	iIndex = aIndex;
       
    86 	SetActive();
       
    87 	}
       
    88 
       
    89 EXPORT_C void CActiveCallback::KickState()
       
    90 /**
       
    91  * Kick Start the object
       
    92  */
       
    93 	{
       
    94 	TRequestStatus* status = &iStatus;
       
    95 	User::RequestComplete(status, KErrNone);
       
    96 	SetActive();
       
    97 	}
       
    98 
       
    99 EXPORT_C CActiveCallback::CActiveCallback(MActiveCallback& aCallback, TInt aPriority)
       
   100 /**
       
   101  * Protected constructor with timer completion callback and priority.
       
   102  *
       
   103  * Called by two phase constructor.
       
   104  *
       
   105  * @param	aTestTimerCallback - object to inform on timer completion.
       
   106  * @param	aPriority - priority of active object.
       
   107  *
       
   108  * @see		MActiveCallback
       
   109  */
       
   110 :	CActive(aPriority)
       
   111 ,	iCallback(aCallback)
       
   112 ,	iIndex(0)
       
   113 	{
       
   114 	}
       
   115 
       
   116 EXPORT_C void CActiveCallback::ConstructL()
       
   117 /**
       
   118  * This is internal and not intended for use.
       
   119  *
       
   120  * Second phase of two phase constructor.
       
   121  *
       
   122  * @leave	system wide error
       
   123  */
       
   124 	{
       
   125 	CActiveScheduler::Add(this);
       
   126 	}
       
   127 
       
   128 EXPORT_C void CActiveCallback::RunL()
       
   129 /**
       
   130  * Active object RunL implementation.
       
   131  *
       
   132  * Calls the MActiveCallback::RunL to inform user that the RunL has been reached.
       
   133  *
       
   134  * @see		MActiveCallback::RunL
       
   135  * @leave	system wide error
       
   136  */
       
   137 	{
       
   138 	iCallback.RunL(this,iIndex);
       
   139 	}
       
   140 
       
   141 EXPORT_C void CActiveCallback::DoCancel()
       
   142 /**
       
   143  * Active object DoCancel implementation.
       
   144  *
       
   145  * Calls the MActiveCallback::DoCancel to inform user that the DoCancel has been reached.
       
   146  *
       
   147  * @see		MActiveCallback::DoCancel
       
   148  */
       
   149 	{
       
   150 	iCallback.DoCancel(this,iIndex);
       
   151 	}