sysstatemgmt/systemstarter/startuppropertiessrc/startupproperties.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 #include "startupproperties.h"
       
    17 #include <barsread.h>
       
    18 #include <e32debug.h>
       
    19 #include <s32mem.h>
       
    20 #include <e32hal.h>
       
    21 #include <e32modes.h>
       
    22 
       
    23 #include "SysStartDebug.h"
       
    24 #include "sysstartpanic.h"
       
    25 
       
    26 /** Internal version for the CStartupProperties object created by the NewL factory 
       
    27 @internalTechnology
       
    28 */
       
    29 const TInt KParameterObjectVersion = 1; 
       
    30 
       
    31 /**
       
    32 Used to create an instance of CStartupProperties class.
       
    33 @return An instance of CStartupProperties
       
    34 @publishedAll
       
    35 @deprecated
       
    36 */
       
    37 EXPORT_C CStartupProperties* CStartupProperties::NewL()
       
    38 	{
       
    39     CStartupProperties* properties = CStartupProperties::NewLC();
       
    40 	CleanupStack::Pop(properties);
       
    41     return properties;
       
    42 	}
       
    43 
       
    44 /**
       
    45 Used to create an instance of CStartupProperties class.
       
    46 The new instance is put on the CleanupStack.
       
    47 @return An instance of CStartupProperties
       
    48 @publishedAll
       
    49 @deprecated
       
    50 */
       
    51 EXPORT_C CStartupProperties* CStartupProperties::NewLC()
       
    52 	{
       
    53 	CStartupProperties* properties = new(ELeave) CStartupProperties();
       
    54 	CleanupStack::PushL(properties);
       
    55 	properties->ConstructL();
       
    56 	return properties;
       
    57 	}
       
    58 
       
    59 /**
       
    60 Used to create an instance of CStartupProperties class with the specified process 
       
    61 filename and arguments.
       
    62 @param aFileName A file name containing full path to be used to start up a component.
       
    63 @param aArgs A string that will be used as an argument to the component when starting.
       
    64 @return An instance of CStartupProperties
       
    65 @publishedAll
       
    66 @deprecated
       
    67 */
       
    68 EXPORT_C CStartupProperties* CStartupProperties::NewL(const TDesC& aFileName, const TDesC& aArgs)
       
    69 	{
       
    70 	CStartupProperties* properties = CStartupProperties::NewLC(aFileName, aArgs);
       
    71 	CleanupStack::Pop(properties);
       
    72     return properties;
       
    73 	}	
       
    74 	
       
    75 /**
       
    76 Used to create an instance of CStartupProperties class with the specified process 
       
    77 filename and arguments. The new instance is pushed onto the CleanupStack.
       
    78 @see CStartupProperties::NewL(const TDesC& aFileName, const TDesC& aArgs)
       
    79 @publishedAll
       
    80 @deprecated
       
    81 */
       
    82 EXPORT_C CStartupProperties* CStartupProperties::NewLC(const TDesC& aFileName, const TDesC& aArgs)
       
    83 	{
       
    84 	CStartupProperties* properties = CStartupProperties::NewLC();
       
    85 	properties->SetFileParamsL(aFileName, aArgs);
       
    86 	return properties;
       
    87 	}	
       
    88 
       
    89 /**
       
    90 Used to create an instance of CStartupProperties class from a resource definition.
       
    91 Supported resource structs are @c START_PROCESS_INFO, @c START_PROCESS_INFO2, 
       
    92 @c START_APP_INFO and @c START_APP_INFO2. 
       
    93 @return An instance of CStartupProperties
       
    94 @param aSource The resource reader with which to access the resource values
       
    95 @publishedAll
       
    96 @deprecated
       
    97 @panic if struct is not supported.
       
    98 */
       
    99 EXPORT_C CStartupProperties* CStartupProperties::NewL(TResourceReader& aSource)
       
   100 	{
       
   101 	CStartupProperties* properties = CStartupProperties::NewLC(aSource);
       
   102 	CleanupStack::Pop(properties);
       
   103 	return properties;
       
   104 	}
       
   105 
       
   106 /**
       
   107 Used to create an instance of CStartupProperties class from a resource definition.
       
   108 The new instance is put on the CleanupStack.
       
   109 @see CStartupProperties::NewL(TResourceReader& aResourceReader)
       
   110 @publishedAll
       
   111 @deprecated
       
   112 @panic if struct is not supported.
       
   113 */
       
   114 EXPORT_C CStartupProperties* CStartupProperties::NewLC(TResourceReader& aSource)
       
   115 	{
       
   116 	CStartupProperties* properties = CStartupProperties::NewLC();
       
   117 	properties->ConstructFromResourceL(aSource);
       
   118 	return properties;
       
   119 	}
       
   120 
       
   121 CStartupProperties::CStartupProperties() : 
       
   122 	iVersion(KParameterObjectVersion),
       
   123 	iStartupType(EStartProcess), 	
       
   124 	iStartMethod(EFireAndForget),
       
   125 	iRestartMode(EStartupModeUndefined)
       
   126 	{
       
   127 	iRecoveryMethod.iRecoveryMethod = EIgnoreOnFailure;
       
   128 	}
       
   129 	
       
   130 void CStartupProperties::ConstructL()
       
   131 	{
       
   132 	}
       
   133 
       
   134 /**
       
   135 Reset all variables in this instance back to constructor defaults.
       
   136 @publishedAll
       
   137 @deprecated
       
   138 */
       
   139 EXPORT_C void CStartupProperties::Reset()
       
   140 	{
       
   141 	//from constructor
       
   142 	iVersion = KParameterObjectVersion;
       
   143 	iStartupType = EStartProcess;	
       
   144 	iStartMethod = EFireAndForget;
       
   145 	iRestartMode = EStartupModeUndefined;
       
   146 	iRecoveryMethod.iRecoveryMethod = EIgnoreOnFailure;
       
   147 	//from CBase
       
   148 	delete iArgs;
       
   149 	delete iFileName;
       
   150 	iNoOfRetries = 0;
       
   151 	iTimeout = 0;
       
   152 	iMonitored = EFalse;
       
   153 	iViewless = EFalse;
       
   154 	iStartInBackground = EFalse;
       
   155 	}
       
   156 
       
   157 /**
       
   158 Destructor for CStartupProperties class
       
   159 @publishedAll
       
   160 @deprecated
       
   161 */
       
   162 EXPORT_C CStartupProperties::~CStartupProperties()
       
   163 	{
       
   164 	delete iArgs;
       
   165 	delete iFileName;
       
   166 	}
       
   167 
       
   168 /** Accessor function returning internal version of the parameter object
       
   169 @publishedAll
       
   170 @deprecated
       
   171 @return Internal version of the parameter object
       
   172 */
       
   173 EXPORT_C TInt CStartupProperties::Version() const
       
   174 	{ 
       
   175 	return iVersion; 
       
   176 	}
       
   177 
       
   178 /** Sets file parameters
       
   179 @publishedAll
       
   180 @deprecated
       
   181 @param aFileName A file name containing full path to be used to start up a component.
       
   182 @param aArgs A string that will be used as an argument to the component when starting.
       
   183 */
       
   184 EXPORT_C void CStartupProperties::SetFileParamsL(const TDesC& aFileName, const TDesC& aArgs)
       
   185 	{
       
   186 	HBufC* fname = aFileName.AllocL();
       
   187 	delete iFileName;
       
   188 	iFileName = fname;
       
   189 	TPtr writeableFilename = iFileName->Des();
       
   190 	writeableFilename.TrimAll();
       
   191 	
       
   192 	HBufC* args = aArgs.AllocL();
       
   193 	delete iArgs; 
       
   194 	iArgs = args;	
       
   195 	TPtr writeableArgs = iArgs->Des();
       
   196 	writeableArgs.TrimAll();
       
   197 	}
       
   198 
       
   199 /** Sets startup type parameter
       
   200 @publishedAll
       
   201 @deprecated
       
   202 @param aStartupType EStartProcess for starting processes, EStartApp for starting applications
       
   203 */
       
   204 EXPORT_C void CStartupProperties::SetStartupType(TStartupType aStartupType) 
       
   205 	{ 
       
   206 	iStartupType = aStartupType; 
       
   207 	}
       
   208 
       
   209 /** Sets startup method parameter.
       
   210 @publishedAll
       
   211 @deprecated
       
   212 @param aStartMethod The method to be used to start up the component. 
       
   213 */
       
   214 EXPORT_C void CStartupProperties::SetStartMethod(TStartMethod aStartMethod)
       
   215 	{ 
       
   216 	iStartMethod = aStartMethod; 
       
   217 	}
       
   218 
       
   219 /** Sets failure parameter @c NoOfRetries. Only valid when @c TStartMethod = @c EWaitForStart.
       
   220 @publishedAll
       
   221 @deprecated
       
   222 @param aNoOfRetries Number of retries to attempt if the component fails to start for the first 
       
   223 					time during system startup. Also determines if a monitored component should be
       
   224 					restarted when it fails. Only valid when @c TStartMethod = @c EWaitForStart.
       
   225 */
       
   226 EXPORT_C void CStartupProperties::SetNoOfRetries(TInt aNoOfRetries)
       
   227 	{ 
       
   228 	iNoOfRetries = aNoOfRetries;
       
   229 	}
       
   230 
       
   231 /** Sets failure parameter Timeout. Used together with start-method @c EWaitStart to determine 
       
   232 how long to wait for the component being started to rendevouz before aborting an attempt. 
       
   233 @publishedAll
       
   234 @deprecated
       
   235 @param aTimeout The time in milliseconds to wait before terminating a component 
       
   236 				that's taking longer to start (rendezvouz) than this specified timeout value. 
       
   237 				A value of zero means "do not time this component out". Only valid when 
       
   238 				@c TStartMethod = @c EWaitForStart.
       
   239 */
       
   240 EXPORT_C void CStartupProperties::SetTimeout(TInt aTimeout)
       
   241 	{ 
       
   242 	iTimeout = aTimeout;
       
   243 	}
       
   244 
       
   245 /** Sets the monitoring parameter. Monitoring a component means the System Monitor server
       
   246 observes the component and takes action when it exits. When a monitored component
       
   247 exits, the System Monitor server will try to restart it the number of times specified in 
       
   248 @c NoOfRetries. If the number of retries is 0, or the number of retries have been exhausted, 
       
   249 the @c TRecoveryMethod is executed.
       
   250 @publishedAll
       
   251 @deprecated
       
   252 @param aMonitored ETrue if the component should be monitored for failure
       
   253 */
       
   254 EXPORT_C void CStartupProperties::SetMonitored(TBool aMonitored)
       
   255 	{ 
       
   256 	iMonitored = aMonitored;
       
   257 	}
       
   258 
       
   259 /** Sets recovery parameters. When a component being monitored exits and the system fails 
       
   260 to restart the component within the specified  number of retries, the @c TRecoveryMethod 
       
   261 is executed. 
       
   262 Used to set the retry_failure_recovery_method within START_PROCESS_INFO2 and 
       
   263 START_APP_INFO2 structures.
       
   264 
       
   265 @publishedAll
       
   266 @deprecated
       
   267 @param aRecoveryMethod The method to use to recover when a monitored component fails.
       
   268 @param aRestartMode The startup mode to restart the OS if recovery method is @c ERestartOSWithMode.
       
   269 					If aRecoveryMethod==ERestartOS this parameter should be zero.
       
   270 */
       
   271 EXPORT_C void CStartupProperties::SetRecoveryParams(TRecoveryMethod aRecoveryMethod, TInt aRestartMode)
       
   272 	{ 
       
   273 	iRecoveryMethod.iRecoveryMethod = aRecoveryMethod;
       
   274 	iRestartMode = aRestartMode;
       
   275 	}
       
   276 
       
   277 /** Action to be taken on command failure. Provides backward compatibility with earlier SSC format.
       
   278 Used to set the fail_on_error fields within START_PROCESS_INFO, START_APP_INFO, START_DLL_INFO, 
       
   279 and MULTIPLE_WAIT structures.
       
   280 
       
   281 @publishedAll
       
   282 @deprecated
       
   283 @param aActionOnCommandFailure Action to be taken if the system starter command fails.
       
   284 */
       
   285 EXPORT_C void CStartupProperties::SetActionOnCommandFailure(TActionOnCommandFailure aActionOnCommandFailure)
       
   286 	{ 
       
   287 	iRecoveryMethod.iActionOnCommandFailure = aActionOnCommandFailure;
       
   288 	}
       
   289 
       
   290 /** Sets extra startup viewless parameter only needed if starting an application
       
   291 @publishedAll
       
   292 @deprecated
       
   293 @param aViewless ETrue if the application should be viewless
       
   294 */
       
   295 EXPORT_C void CStartupProperties::SetViewless(TBool aViewless)
       
   296 	{ 
       
   297 	iViewless = aViewless; 
       
   298 	}
       
   299 	
       
   300 /** Sets extra startup start in background parameter only needed if starting an application
       
   301 @publishedAll
       
   302 @deprecated
       
   303 @param aStartInBackground ETrue if the application should start in the background
       
   304 */
       
   305 EXPORT_C void CStartupProperties::SetStartInBackground(TBool aStartInBackground)
       
   306 	{ 
       
   307 	iStartInBackground = aStartInBackground; 	
       
   308 	}
       
   309 
       
   310 /** Accessor function returning filename property
       
   311 @publishedAll
       
   312 @deprecated
       
   313 @return Filename property
       
   314 */
       
   315 EXPORT_C TPtrC CStartupProperties::FileName() const
       
   316 	{
       
   317 	return (iFileName) ? *iFileName : KNullDesC();
       
   318 	}
       
   319 
       
   320 /** Accessor function returning arguments property
       
   321 @publishedAll
       
   322 @deprecated
       
   323 @return Arguments property
       
   324 */
       
   325 EXPORT_C TPtrC CStartupProperties::Args() const
       
   326 	{
       
   327 	return (iArgs) ? *iArgs : KNullDesC();
       
   328 	}
       
   329 
       
   330 /** Accessor function returning startup type property
       
   331 @publishedAll
       
   332 @deprecated
       
   333 @return Startup type property
       
   334 */
       
   335 EXPORT_C TStartupType CStartupProperties::StartupType() const
       
   336 	{ 
       
   337 	return iStartupType; 
       
   338 	}
       
   339 
       
   340 /** Accessor function returning start method property
       
   341 @publishedAll
       
   342 @deprecated
       
   343 @return Start method property
       
   344 */
       
   345 EXPORT_C TStartMethod CStartupProperties::StartMethod() const
       
   346 	{ 
       
   347 	return iStartMethod; 
       
   348 	}
       
   349 
       
   350 /** Accessor function returning number of retries property. 
       
   351 Only valid when @c TStartMethod = @c EWaitForStart.
       
   352 @publishedAll
       
   353 @deprecated
       
   354 @return Number of retries property
       
   355 */
       
   356 EXPORT_C TInt CStartupProperties::NoOfRetries() const
       
   357 	{ 
       
   358 	return iNoOfRetries; 
       
   359 	}
       
   360 
       
   361 /** Accessor function returning timeout property.
       
   362 Only valid when @c TStartMethod = @c EWaitForStart.
       
   363 @publishedAll
       
   364 @deprecated
       
   365 @return Timeout property
       
   366 */
       
   367 EXPORT_C TInt CStartupProperties::Timeout() const
       
   368 	{ 
       
   369 	return iTimeout; 
       
   370 	}
       
   371 
       
   372 /** Accessor function returning the legacy fail_on_error property
       
   373 used by the old resource structs START_APP_INFO and START_PROCESS_INFO.
       
   374 @publishedAll
       
   375 @deprecated
       
   376 @return Recovery method property
       
   377 */
       
   378 EXPORT_C TActionOnCommandFailure CStartupProperties::ActionOnCommandFailure() const
       
   379 	{ 
       
   380 	return iRecoveryMethod.iActionOnCommandFailure;
       
   381 	}
       
   382 
       
   383 /** Accessor function returning recovery method property read from
       
   384 the retry_failure_recovery_method property in the resource structs 
       
   385 START_PROCESS_INFO2 and START_APP_INFO2.
       
   386 @publishedAll
       
   387 @deprecated
       
   388 @return Recovery method property
       
   389 */
       
   390 EXPORT_C TRecoveryMethod CStartupProperties::RecoveryMethod() const
       
   391 	{ 
       
   392 	return iRecoveryMethod.iRecoveryMethod;
       
   393 	}
       
   394 
       
   395 /** Accessor function returning restart mode property
       
   396 @publishedAll
       
   397 @deprecated
       
   398 @return Restart mode property
       
   399 */
       
   400 EXPORT_C TInt CStartupProperties::RestartMode() const
       
   401 	{ 
       
   402 	return iRestartMode; 
       
   403 	}
       
   404 
       
   405 /** Accessor function returning monitored property
       
   406 @publishedAll
       
   407 @deprecated
       
   408 @return Monitored property
       
   409 */
       
   410 EXPORT_C TBool CStartupProperties::Monitored() const
       
   411 	{ 
       
   412 	return iMonitored; 
       
   413 	}
       
   414 
       
   415 /** Accessor function returning viewless property
       
   416 @publishedAll
       
   417 @deprecated
       
   418 @return Viewless property
       
   419 */
       
   420 EXPORT_C TBool CStartupProperties::Viewless() const
       
   421 	{ 
       
   422 	return iViewless; 
       
   423 	}
       
   424 
       
   425 /** Accessor function returning start in background property
       
   426 @publishedAll
       
   427 @deprecated
       
   428 @return Start in background property
       
   429 */
       
   430 EXPORT_C TBool CStartupProperties::StartInBackground() const
       
   431 	{ 
       
   432 	return iStartInBackground; 
       
   433 	}
       
   434 
       
   435 /** Externalize the class into a buffer.
       
   436 This function has to be updated every time a member has been added to the class to maintain binary 
       
   437 compatibility. 
       
   438 @internalTechnology
       
   439 @deprecated
       
   440 @param aBufPtr A buffer of sufficient size to contain the externalized class data on function return
       
   441 */
       
   442 EXPORT_C void CStartupProperties::ExternalizeL(CBufBase& aBufPtr) const
       
   443 	{
       
   444     RBufWriteStream writeStream(aBufPtr);
       
   445 
       
   446     writeStream.WriteInt32L(iVersion);
       
   447     writeStream << FileName();	
       
   448     writeStream << Args();	
       
   449     writeStream.WriteInt8L(iStartupType); //enumeration has few values so 8bit should be enough
       
   450     writeStream.WriteInt8L(iStartMethod); //enumeration has few values so 8bit should be enough
       
   451     writeStream.WriteInt32L(iNoOfRetries); 
       
   452     writeStream.WriteInt32L(iTimeout); 
       
   453     writeStream.WriteInt8L(iRecoveryMethod.iRecoveryMethod); //enumeration has few values so 8bit should be enough       
       
   454     writeStream.WriteInt32L(iRestartMode); 
       
   455     writeStream.WriteInt8L(iMonitored); //8bit should be enough for bool also
       
   456     writeStream.WriteInt8L(iViewless); //8bit should be enough for bool also
       
   457     writeStream.WriteInt8L(iStartInBackground); //8bit should be enough for bool also
       
   458     
       
   459     // Add any new data member externalization code here, before CommitL
       
   460     // e.g. writeStream.WriteInt32L(iSomethingElse);        
       
   461     
       
   462     writeStream.CommitL();
       
   463 	writeStream.Release();
       
   464     
       
   465 	}
       
   466 
       
   467 /** Internalize the class from a buffer.
       
   468 This function has to be updated every time a member has been added to the class to maintain binary 
       
   469 compatibility. 
       
   470 @internalTechnology
       
   471 @deprecated
       
   472 @param aBufPtr A buffer containing the externalized class data
       
   473 */
       
   474 EXPORT_C void CStartupProperties::InternalizeL(const TPtrC8& aBufPtr)
       
   475 	{
       
   476     RDesReadStream readStream;
       
   477     readStream.Open(aBufPtr);
       
   478     CleanupClosePushL(readStream);
       
   479 
       
   480 	iVersion = readStream.ReadInt32L();
       
   481 
       
   482 	delete iFileName;
       
   483 	iFileName=NULL;
       
   484 	iFileName = HBufC::NewL(readStream,KMaxFileName);
       
   485 	delete iArgs;
       
   486 	iArgs=NULL;	
       
   487 	iArgs = HBufC::NewL(readStream,KMaxFileName);
       
   488 
       
   489     iStartupType = static_cast<TStartupType>(readStream.ReadInt8L());
       
   490     iStartMethod = static_cast<TStartMethod>(readStream.ReadInt8L());
       
   491 	iNoOfRetries = readStream.ReadInt32L();
       
   492 	iTimeout = readStream.ReadInt32L();	
       
   493     iRecoveryMethod.iRecoveryMethod = static_cast<TRecoveryMethod>(readStream.ReadInt8L());	
       
   494 	iRestartMode = readStream.ReadInt32L();	    
       
   495     iMonitored = static_cast<TBool>(readStream.ReadInt8L());
       
   496     iViewless = static_cast<TBool>(readStream.ReadInt8L());
       
   497     iStartInBackground = static_cast<TBool>(readStream.ReadInt8L());        
       
   498 	
       
   499     // Add any new data member internalization code here
       
   500     // e.g. iSomethingElse = readStream.ReadInt32L();       
       
   501         
       
   502 	CleanupStack::PopAndDestroy(&readStream);
       
   503 	}
       
   504 
       
   505 /** 
       
   506 @return The size in bytes for this particular object.
       
   507 */
       
   508 EXPORT_C TInt CStartupProperties::Size() const
       
   509 	{
       
   510 	const TInt nameSize = iFileName ? iFileName->Size() : 0;
       
   511 	const TInt argsSize = iArgs ? iArgs->Size() : 0;
       
   512 	return sizeof(CStartupProperties) + nameSize + argsSize; 
       
   513 	}
       
   514 
       
   515 void CStartupProperties::ConstructFromResourceL(TResourceReader& aSource)
       
   516 	{
       
   517 	const TStartupCommandType commandType = static_cast<TStartupCommandType>(aSource.ReadUint16());	
       
   518 	iStartupType = ((commandType==EStartupApp)||(commandType==EStartupApp2)) ? EStartApp : EStartProcess;
       
   519 	
       
   520 	iFileName = aSource.ReadHBufCL();
       
   521 	if(iFileName)
       
   522 		{
       
   523 		TPtr writeableFilename = iFileName->Des();
       
   524 		writeableFilename.TrimAll();		
       
   525 		}
       
   526 	
       
   527 	iArgs = aSource.ReadHBufCL(); 
       
   528 	if(iArgs)
       
   529 		{
       
   530 		TPtr writeableArgs = iArgs->Des();
       
   531 		writeableArgs.TrimAll();
       
   532 		}
       
   533 	
       
   534 	iStartMethod = static_cast<TStartMethod>(aSource.ReadUint16());	
       
   535 	
       
   536 	switch(commandType)
       
   537 		{
       
   538 		case EStartupApp:
       
   539 			delete iArgs; // deleted for backwards compatibility
       
   540 			iArgs = NULL;
       
   541 			iViewless = static_cast<TUint16>(aSource.ReadUint16());
       
   542 			iStartInBackground = static_cast<TUint16>(aSource.ReadUint16());
       
   543 			iTimeout = aSource.ReadInt32();
       
   544 			iRecoveryMethod.iActionOnCommandFailure = static_cast<TActionOnCommandFailure> (aSource.ReadUint16());
       
   545 			iNoOfRetries = static_cast<TUint16> (aSource.ReadUint16());
       
   546 			break;
       
   547 			
       
   548 		case EStartupApp2:
       
   549 			iViewless = static_cast<TUint16>(aSource.ReadUint16());
       
   550 			iStartInBackground = static_cast<TUint16>(aSource.ReadUint16());
       
   551 			iTimeout = aSource.ReadInt32();
       
   552 			iRecoveryMethod.iRecoveryMethod = static_cast<TRecoveryMethod> (aSource.ReadUint16());
       
   553 			iNoOfRetries = static_cast<TUint16> (aSource.ReadUint16());
       
   554 			iMonitored = static_cast<TUint16>(aSource.ReadUint16());
       
   555 			iRestartMode = aSource.ReadInt16();
       
   556 			break;
       
   557 			
       
   558 		case EStartupProcess:
       
   559 			iTimeout = aSource.ReadInt32();
       
   560 			iRecoveryMethod.iActionOnCommandFailure = static_cast<TActionOnCommandFailure>(aSource.ReadUint16());
       
   561 			iNoOfRetries = static_cast<TUint16> (aSource.ReadUint16());	
       
   562 			break;
       
   563 			
       
   564 		case EStartupProcess2:
       
   565 			iTimeout = aSource.ReadInt32();
       
   566 			iRecoveryMethod.iRecoveryMethod = static_cast<TRecoveryMethod>(aSource.ReadUint16());
       
   567 			iNoOfRetries = static_cast<TUint16> (aSource.ReadUint16());	
       
   568 			iMonitored = static_cast<TUint16>(aSource.ReadUint16());	
       
   569 			iRestartMode = aSource.ReadInt16();
       
   570 			break;
       
   571 			
       
   572 		default:
       
   573 			PanicNow(KPanicStartupProperties, EInvalidCommandType);
       
   574 			break;
       
   575 		}
       
   576 	
       
   577 	DoSanityCheck(commandType);
       
   578 	}
       
   579 
       
   580 void CStartupProperties::DoSanityCheck(TStartupCommandType aCommandType) const
       
   581 	{
       
   582 	if ((iStartMethod < EFireAndForget) || (iStartMethod > EDeferredWaitForStart))
       
   583 		{	
       
   584 		DEBUGPRINT2(_L("Invalid start_method value of %d"), iStartMethod);
       
   585 		PanicNow(KPanicStartupProperties, EInvalidStartMethod);
       
   586 		} 
       
   587 	
       
   588 	// The timeout and no_of_retries_on_failure fields can only be used
       
   589  	// with EWaitForStart. Check that no values other than the defaults have been 
       
   590  	// provisioned
       
   591  	if (iStartMethod != EWaitForStart)
       
   592  		{
       
   593  		if (iTimeout)   
       
   594 			{	
       
   595 			DEBUGPRINT2(_L("Timeout should be 0, invalid timeout value of %d"), iTimeout);
       
   596 			PanicNow(KPanicStartupProperties, EInvalidTimeout);
       
   597 			} 
       
   598 		if (iNoOfRetries)
       
   599 			{
       
   600 			DEBUGPRINT2(_L("no_of_retries_on_failure should be 0, invalid value of %d"), iNoOfRetries);
       
   601 			PanicNow(KPanicStartupProperties, EInvalidNoOfRetries);
       
   602 			}
       
   603  		}
       
   604  	
       
   605 	if ((aCommandType == EStartupApp) || (aCommandType == EStartupProcess))
       
   606 		{
       
   607 		// Check that the fail_on_error value is valid for version 1 struct.
       
   608 		if ((iRecoveryMethod.iActionOnCommandFailure != EIgnoreCommandFailure) && (iRecoveryMethod.iActionOnCommandFailure != EPanicOnCommandFailure))
       
   609 			{	
       
   610 			DEBUGPRINT2(_L("Invalid fail_on_error: %d"), iRecoveryMethod.iActionOnCommandFailure);
       
   611 			PanicNow(KPanicStartupProperties, EInvalidRecoveryMethod);
       
   612 			} 
       
   613 		}
       
   614 	else if ((aCommandType == EStartupApp2) || (aCommandType == EStartupProcess2))
       
   615 		{
       
   616 		// Check that the fail_on_error value is valid for version 2 struct.	
       
   617 		if ((iRecoveryMethod.iRecoveryMethod > ERestartOSWithMode) || (iRecoveryMethod.iRecoveryMethod < EIgnoreOnFailure))
       
   618 			{	
       
   619 			DEBUGPRINT2(_L("Invalid retry_failure_recovery_method: %d"), iRecoveryMethod.iRecoveryMethod);
       
   620 			PanicNow(KPanicStartupProperties, EInvalidRecoveryMethod);
       
   621 			} 
       
   622 		}
       
   623 	}