installationservices/swi/test/tasynccancel/canceltimer.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 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 the License "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 *
       
    16 */
       
    17 
       
    18 /**
       
    19  @test
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #ifndef CANCELTIMER_H
       
    24 #define CANCELTIMER_H
       
    25 
       
    26 #include "common.h"
       
    27 #include "installer.h"
       
    28 
       
    29 /**
       
    30  * This class defines the timer that is used to start and cancel
       
    31  * the installation process at a given time.
       
    32  */
       
    33 class CCancelTimer : public CTimer
       
    34 	{
       
    35 	public:
       
    36 	
       
    37 		CCancelTimer();
       
    38 		void ConstructL();		
       
    39 		static CCancelTimer* NewLC(CInstallPrefs* aPrefs=NULL);
       
    40 		static CCancelTimer* NewL(CInstallPrefs* aPrefs=NULL);
       
    41 		
       
    42 		virtual ~CCancelTimer();
       
    43 		
       
    44 		/**
       
    45  		 * Sets up the installation (but without starting the Active Scheduler)
       
    46  		 * @param aSisToInstall		Full path to sis file to be installed
       
    47  		 * @param aWhenToCancel		Point in time (microseconds) when to cancel the installation
       
    48  		 * @param aDontCancel		Set to 1 if the installation is not to be canceled
       
    49  		 */
       
    50 		void StartL(const TDesC& aSisToInstall, TInt aWhenToCancel, TInt aDontCancel=0);
       
    51 		
       
    52 		// Used to determine how long did the installation process last
       
    53 		TInt Time()
       
    54 			{
       
    55 			return iTime;
       
    56 			}
       
    57 		
       
    58 		TInt CancelationSuccess()
       
    59 			{
       
    60 			return iInstaller->CancelationSuccess();
       
    61 			}
       
    62 		
       
    63 		TInt FinishedInstallation()
       
    64 			{
       
    65 			return iInstaller->FinishedInstallation();
       
    66 			}
       
    67 			
       
    68 		TInt InstallerStatus()
       
    69 			{
       
    70 			return iInstaller->Status();
       
    71 			}
       
    72 		
       
    73 	private:
       
    74 	
       
    75 		// Ticks and cancels the installation at reqested time.
       
    76 		// Since cancelation takes some time to complete, this function also waits
       
    77 		// for its completition and than stops the Active Scheduler
       
    78 		void RunL();
       
    79 
       
    80 		// Sets the interval after which the next tick will occur
       
    81 		void SetNextTick(TInt aTime=1);
       
    82 		
       
    83 		// Stop the Active Scheduler
       
    84 		void StopScheduler();
       
    85 	
       
    86 		// Keeps the time in order to know when to cancel.
       
    87 		// Also useful to determine how long did the installation process last
       
    88 		TInt iTime;
       
    89 		
       
    90 		TInt iWhenToCancel;
       
    91 		
       
    92 		// Is equal to 1 if ActiveScheduler should be stopped the next time
       
    93 		// RunL executes
       
    94 		TInt iStopScheduler;
       
    95 		// Is equal to 1 if the CancelOperation() was requested and the program
       
    96 		// is waiting for the cancelation to finish
       
    97 		TInt iWaitWhileCanceling;
       
    98 		
       
    99 		// Runs the installation and cancelation
       
   100 		CInstaller* iInstaller;
       
   101 		
       
   102 	};
       
   103 	
       
   104 	
       
   105 #endif
       
   106 // End of file