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