installationservices/swinstallationfw/inc/siftransporttask.h
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 /*
       
     2 * Copyright (c) 2008-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 * The file defines a base class for SIF Transport tasks and a factory function for them.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @publishedAll
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef SIFTRANSPORTTASK_H
       
    27 #define SIFTRANSPORTTASK_H
       
    28 
       
    29 #include <f32file.h>
       
    30 #include <usif/sif/sifcommon.h>
       
    31 
       
    32 namespace Usif
       
    33 	{
       
    34 
       
    35 	/** An auxiliary data structure for passing task's parameters across the SIF Transport library. */
       
    36 	struct TTransportTaskParams
       
    37 		{
       
    38 		IMPORT_C TTransportTaskParams();
       
    39 		CComponentInfo* iComponentInfo;
       
    40 		TComponentId iComponentId;
       
    41 		const TDesC* iFileName;
       
    42 		RFile* iFileHandle;
       
    43 		const COpaqueNamedParams* iCustomArguments;
       
    44 		COpaqueNamedParams* iCustomResults;
       
    45 		const TSecurityContext* iSecurityContext;
       
    46 		TRequestStatus* iRequestStatus;
       
    47 		enum { EInvalidComponentId = -1 };
       
    48 		};
       
    49 
       
    50 // ===========================================================================================================
       
    51 
       
    52 	/**
       
    53 	The core class of the SIF Transport library.
       
    54 	
       
    55 	It defines an abstract interface for SIF Transport tasks. These tasks are instantiated
       
    56 	and executed to handle processing of incoming software management requests.
       
    57 	
       
    58 	Each Transport task is executed in the context of the active object. If a task issues
       
    59 	a request to an asynchronous service provider, it should use a @see TRequestStatus
       
    60 	object provided in @see TTransportTaskParams. Otherwise, tasks that don't issue
       
    61 	asynchronous requests must complete this request status themselves before they leave
       
    62 	the @see CSifTransportTask::ExecuteImplL method. In order to simplify tasks that don't
       
    63 	deal with asynchronous service providers the AutoCompletion mode has been implementd. In this
       
    64 	mode the request status is completed automatically by the base class. The AutoCompletion
       
    65 	mode is enabled by default and should be disabled in constructors of tasks that issue
       
    66 	asynchronous requests.
       
    67 	
       
    68 	An implementation of the Transport Task Factory defined below is responsible for
       
    69 	instantiating Transport tasks.
       
    70 	*/
       
    71 	class CSifTransportTask : public CBase
       
    72 		{
       
    73 	protected:
       
    74 		/**
       
    75 		Constructs the object.
       
    76 		
       
    77 		@param aParams Parameters needed to execute the task. Please
       
    78 		see @see TTransportTaskParams for details.
       
    79 		@param aAutoCompletion Enables the AutoCompletion mode. 
       
    80 		*/
       
    81 		IMPORT_C CSifTransportTask(TTransportTaskParams& aParams, TBool aAutoCompletion = ETrue);
       
    82 
       
    83 		/** Destroys the object. */
       
    84 		IMPORT_C virtual ~CSifTransportTask();
       
    85 
       
    86 		/**
       
    87 		Implementation of this abstract method is supposed to process an incoming software
       
    88 		management request.
       
    89 		
       
    90 		If this method leaves with any error code the execution of the task terminates
       
    91 		immediately. The leave code is passed to the user as a request completion code.
       
    92 		
       
    93 		@return TBool, ETrue it the processing of a software management request has been
       
    94 		completed and the task can be cleaned up, EFalse if the method must be called again
       
    95 		for further processing.
       
    96 		*/
       
    97 		IMPORT_C virtual TBool ExecuteImplL() = 0;
       
    98 		
       
    99 		/**
       
   100 		Cancels the execution of an asynchronous task.
       
   101 		
       
   102 		The default implementation is empty. Tasks that issue requests to asynchronous
       
   103 		service providers must implement this method in order to cancel them.
       
   104 		*/
       
   105 		IMPORT_C virtual void CancelImpl();
       
   106 
       
   107 		/** Gets the id of a component */
       
   108 		IMPORT_C TComponentId ComponentId() const;
       
   109 		/** Gets the file name of a package */
       
   110 		IMPORT_C const TDesC* FileName() const;
       
   111 		/** Gets the file handle of a package */
       
   112 		IMPORT_C RFile* FileHandle();
       
   113 		/** Gets custom arguments */
       
   114 		IMPORT_C const COpaqueNamedParams* CustomArguments() const;
       
   115 		/** Gets custom results */
       
   116 		IMPORT_C COpaqueNamedParams* CustomResults();
       
   117 		/** Gets security context */
       
   118 		IMPORT_C const TSecurityContext* SecurityContext() const;
       
   119 		/** Gets request status associated with the task */
       
   120 		IMPORT_C TRequestStatus* RequestStatus();
       
   121 		/** Gets component info */
       
   122 		IMPORT_C CComponentInfo* ComponentInfo();
       
   123 
       
   124 	private:
       
   125 		// These methods are used only by the CSifTransportRequest class to execute and cancel SIF Transport tasks
       
   126 		friend class CSifTransportRequest;
       
   127 		TBool Execute();
       
   128 		void Cancel();
       
   129 
       
   130 	private:
       
   131 		CSifTransportTask(const CSifTransportTask&);
       
   132 		CSifTransportTask& operator=(const CSifTransportTask&);
       
   133 		
       
   134 		TTransportTaskParams& iParams;
       
   135 		TBool iAutoCompletion;
       
   136 		};
       
   137 
       
   138 // ===========================================================================================================
       
   139 
       
   140 	/**
       
   141 	Definition of a factory function for the SIF Transport library. The @see SifTransportRequest class uses implementations
       
   142 	of this function to instantiate and execute appropriate SIF Transport tasks. It happens in response to incoming software
       
   143 	management requests.
       
   144 	*/
       
   145 	namespace TransportTaskFactory
       
   146 		{
       
   147 		enum TTaskType
       
   148 			{
       
   149 			EGetComponentInfo,
       
   150 			EInstall,
       
   151 			EUninstall,
       
   152 			EActivate,
       
   153 			EDeactivate
       
   154 			};
       
   155 
       
   156 		typedef CSifTransportTask* (*GenerateTask)(TTaskType aTaskType, TTransportTaskParams& aParams);
       
   157 		}
       
   158 
       
   159 	} // namespace Usif
       
   160 
       
   161 #endif // SIFTRANSPORTTASK_H