sysstatemgmt/systemstatemgr/test/tss/src/asstopper.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 
       
    19 #include "asstopper.h"
       
    20 #include "tss_step_base.h"
       
    21 
       
    22 /**
       
    23  A little AO which supplies its TRS and stops the AS when it is completed,
       
    24  allowing a pause before doing so.
       
    25 */
       
    26 CAsStopper::CAsStopper( TInt aTimeout )
       
    27 : CActive( EPriorityStandard ), iTimeout( aTimeout )
       
    28 	{
       
    29 	CActiveScheduler::Add( this );
       
    30 	SetActive();
       
    31 	
       
    32 	iTimer.CreateLocal();
       
    33 	}
       
    34 
       
    35 
       
    36 /**
       
    37  Overload of constructor for notifications
       
    38  */
       
    39 CAsStopper::CAsStopper( TInt aTimeout, MSsTestAsyncNotifier* aNotify )
       
    40 : CActive( EPriorityStandard ), iTimeout( aTimeout ), iNotify( aNotify )
       
    41 	{
       
    42 	CActiveScheduler::Add( this );
       
    43 	SetActive();
       
    44 	
       
    45 	iTimer.CreateLocal();	
       
    46 	}
       
    47 
       
    48 
       
    49 
       
    50 CAsStopper::~CAsStopper()
       
    51 	{
       
    52 	Cancel();
       
    53 	iTimer.Close();
       
    54 	}
       
    55 
       
    56 
       
    57 
       
    58 TRequestStatus& CAsStopper::Trs()
       
    59 	{
       
    60 	return iStatus;
       
    61 	}
       
    62 
       
    63 
       
    64 
       
    65 TInt CAsStopper::CompletionCode()
       
    66 	{
       
    67 	return iCompletionCode;
       
    68 	}
       
    69 
       
    70 
       
    71 
       
    72 void CAsStopper::RunL()
       
    73 	{
       
    74 	if( !iRunning )
       
    75 		{
       
    76 		iRunning = ETrue;
       
    77 		iCompletionCode = iStatus.Int();
       
    78 		
       
    79 		if( iNotify )
       
    80 			{
       
    81 			iNotify->SsTestNotify( iCompletionCode );
       
    82 			}
       
    83 		
       
    84 		SetActive();
       
    85 		iTimer.After( iStatus, iTimeout );
       
    86 		}
       
    87 	else
       
    88 		{
       
    89 		CActiveScheduler::Stop();
       
    90 		}
       
    91 
       
    92 	}
       
    93 
       
    94 
       
    95 
       
    96 void CAsStopper::DoCancel()
       
    97 	{
       
    98 	iTimer.Close();
       
    99 	}
       
   100 
       
   101 //
       
   102 /**
       
   103  Another little AO which allows a pause of aTimeout before stopping the sched.
       
   104 */
       
   105 CAsPauseStopper::CAsPauseStopper( TInt aTimeout )
       
   106 : CActive( EPriorityStandard ), iTimeout( aTimeout )
       
   107 	{
       
   108 	CActiveScheduler::Add( this );
       
   109 	SetActive();
       
   110 	
       
   111 	iTimer.CreateLocal();
       
   112 	iTimer.After( iStatus, iTimeout );
       
   113 	}
       
   114 
       
   115 
       
   116 
       
   117 CAsPauseStopper::~CAsPauseStopper()
       
   118 	{
       
   119 	Cancel();
       
   120 	iTimer.Close();
       
   121 	}
       
   122 
       
   123 
       
   124 
       
   125 void CAsPauseStopper::RunL()
       
   126 	{
       
   127 	CActiveScheduler::Stop();
       
   128 	}
       
   129 
       
   130 
       
   131 
       
   132 void CAsPauseStopper::DoCancel()
       
   133 	{
       
   134 	iTimer.Close();
       
   135 	}
       
   136 
       
   137 
       
   138 //
       
   139 /**
       
   140  AO which allows a pause of aTimeout before deleting the CSsmStartSafe object.
       
   141 */
       
   142 CSsPauseDeleter::CSsPauseDeleter( TInt aTimeout, CSsmStartSafe* aSsmStartSafe )
       
   143 : CActive( EPriorityStandard ), iTimeout( aTimeout ), iSsmStartSafe( aSsmStartSafe )
       
   144 	{
       
   145 	CActiveScheduler::Add( this );
       
   146 	SetActive();
       
   147 	
       
   148 	iTimer.CreateLocal();
       
   149 	iTimer.After( iStatus, iTimeout );
       
   150 	}
       
   151 
       
   152 
       
   153 
       
   154 CSsPauseDeleter::~CSsPauseDeleter()
       
   155 	{
       
   156 	Cancel();
       
   157 	iTimer.Close();
       
   158 	}
       
   159 
       
   160 
       
   161 
       
   162 void CSsPauseDeleter::RunL()
       
   163 	{
       
   164 	delete iSsmStartSafe;
       
   165 	}
       
   166 
       
   167 
       
   168 
       
   169 void CSsPauseDeleter::DoCancel()
       
   170 	{
       
   171 	iTimer.Close();
       
   172 	}
       
   173 
       
   174