1 /* |
|
2 * Copyright (c) 2007 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 "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: Class definition of CDiagExecPlanEntryImplSuite |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS DECLARATION |
|
20 #include "diagexecplanentryimplsuite.h" |
|
21 |
|
22 // SYSTEM INCLUDE FILES |
|
23 #include <DiagPlugin.h> // MDiagPlugin |
|
24 #include <DiagSuitePlugin.h> // MDiagSuitePlugin |
|
25 #include <DiagFrameworkDebug.h> // LOGSTRING |
|
26 #include <DiagSuiteExecParam.h> // TDiagSuiteExecParam |
|
27 |
|
28 // USER INCLUDE FILES |
|
29 #include "diagframework.pan" // Panics |
|
30 #include "diagexecplanentryimplobserver.h" // MDiagExecPlanEntryImplObserver |
|
31 |
|
32 // DATA |
|
33 |
|
34 // MACROS |
|
35 |
|
36 // LOCAL DATA TYPES |
|
37 |
|
38 |
|
39 // ======== LOCAL FUNCTIONS ======== |
|
40 |
|
41 // ======== MEMBER FUNCTIONS ======== |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CDiagExecPlanEntryImplSuite::NewL |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CDiagExecPlanEntryImplSuite* CDiagExecPlanEntryImplSuite::NewL( |
|
48 MDiagEngineCommon& aEngine, |
|
49 const TDiagEngineConfig& aEngineConfig, |
|
50 MDiagExecPlanEntryImplObserver& aObserver, |
|
51 MDiagSuitePlugin& aPlugin, |
|
52 TBool aAsDependency, |
|
53 CDiagExecPlanEntryImpl::TType aType ) |
|
54 { |
|
55 CDiagExecPlanEntryImplSuite* self = NewLC( aEngine, |
|
56 aEngineConfig, |
|
57 aObserver, |
|
58 aPlugin, |
|
59 aAsDependency, |
|
60 aType ); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CDiagExecPlanEntryImplSuite::NewLC |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CDiagExecPlanEntryImplSuite* CDiagExecPlanEntryImplSuite::NewLC( |
|
70 MDiagEngineCommon& aEngine, |
|
71 const TDiagEngineConfig& aEngineConfig, |
|
72 MDiagExecPlanEntryImplObserver& aObserver, |
|
73 MDiagSuitePlugin& aPlugin, |
|
74 TBool aAsDependency, |
|
75 CDiagExecPlanEntryImpl::TType aType ) |
|
76 { |
|
77 CDiagExecPlanEntryImplSuite* self = |
|
78 new ( ELeave ) CDiagExecPlanEntryImplSuite ( aEngine, |
|
79 aEngineConfig, |
|
80 aObserver, |
|
81 aPlugin, |
|
82 aAsDependency, |
|
83 aType ); |
|
84 CleanupStack::PushL( self ); |
|
85 return self; |
|
86 } |
|
87 |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CDiagExecPlanEntryImplSuite::CDiagExecPlanEntryImplSuite |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CDiagExecPlanEntryImplSuite::CDiagExecPlanEntryImplSuite( |
|
94 MDiagEngineCommon& aEngine, |
|
95 const TDiagEngineConfig& aEngineConfig, |
|
96 MDiagExecPlanEntryImplObserver& aObserver, |
|
97 MDiagSuitePlugin& aPlugin, |
|
98 TBool aAsDependency, |
|
99 CDiagExecPlanEntryImpl::TType aType ) |
|
100 : CDiagExecPlanEntryImpl( |
|
101 aEngine, |
|
102 aEngineConfig, |
|
103 aObserver, |
|
104 aPlugin, |
|
105 aAsDependency, |
|
106 aType ) |
|
107 { |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CDiagExecPlanEntryImplSuite::~CDiagExecPlanEntryImplSuite |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 CDiagExecPlanEntryImplSuite::~CDiagExecPlanEntryImplSuite() |
|
115 { |
|
116 Cancel(); |
|
117 |
|
118 if ( CDiagExecPlanEntryImpl::State() == EStateRunning ) |
|
119 { |
|
120 TRAP_IGNORE( SuitePlugin().ExecutionStopL( MDiagSuitePlugin::ESkip ) ) |
|
121 } |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CDiagExecPlanEntryImplSuite::SuitePlugin |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 MDiagSuitePlugin& CDiagExecPlanEntryImplSuite::SuitePlugin() |
|
129 { |
|
130 // It is safe to typecast here, since CDiagExecPlanEntryImplSuite::NewL |
|
131 // accepts only MDiagSuitePlugin&. |
|
132 return static_cast< MDiagSuitePlugin& >( Plugin() ); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // From CDiagExecPlanEntryImpl |
|
137 // CDiagExecPlanEntryImplSuite::ExecuteL |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CDiagExecPlanEntryImplSuite::ExecuteL() |
|
141 { |
|
142 #ifdef _DEBUG |
|
143 HBufC* pluginName = Plugin().GetPluginNameL( |
|
144 MDiagPlugin::ENameLayoutListSingle ); |
|
145 |
|
146 LOGSTRING4( "---- SUITE BEGIN ---- [ 0x%08x %S / %s ] ---- SUITE BEGIN ---- {", |
|
147 Plugin().Uid().iUid, |
|
148 pluginName, |
|
149 ( Type() == ETypeSuitePrepare ) ? L"PREPARE" : L"FINALIZE" ) |
|
150 |
|
151 delete pluginName; |
|
152 pluginName = NULL; |
|
153 #endif // _DEBUG |
|
154 |
|
155 __ASSERT_DEBUG( State() == EStateQueued, |
|
156 Panic( EDiagFrameworkCorruptStateMachine ) ); |
|
157 |
|
158 ResetWatchdog( EDiagEngineWatchdogTypeAutomatic ); |
|
159 ChangeStateL( EStateRunning ); |
|
160 |
|
161 // Notify observer that progress is 0 of 1 since suite does not have progress. |
|
162 Observer().ExecPlanEntryProgressL( *this, 0, 1 ); |
|
163 |
|
164 TDiagSuiteExecParam* execParam = new ( ELeave ) TDiagSuiteExecParam( *this, Engine() ); |
|
165 if ( Type() == CDiagExecPlanEntryImpl::ETypeSuitePrepare ) |
|
166 { |
|
167 SuitePlugin().PrepareChildrenExecutionL( execParam, // owership change |
|
168 Engine().IsDependencyDisabled(), |
|
169 AsDependency() ); |
|
170 } |
|
171 else |
|
172 { |
|
173 SuitePlugin().FinalizeChildrenExecutionL( execParam, // owership change |
|
174 Engine().IsDependencyDisabled(), |
|
175 AsDependency() ); |
|
176 } |
|
177 |
|
178 execParam = NULL; //lint !e423 execParam ownership changed. |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // From CDiagExecPlanEntryImpl |
|
183 // CDiagExecPlanEntryImplSuite::StopExecutionByWatchdogL |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void CDiagExecPlanEntryImplSuite::StopExecutionByWatchdogL() |
|
187 { |
|
188 StopSuitePluginL( MDiagSuitePlugin::EWatchdog ); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // From CDiagExecPlanEntryImpl |
|
193 // CDiagExecPlanEntryImplSuite::StopExecutionByClientL |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CDiagExecPlanEntryImplSuite::DoStopExecutionByClientL( |
|
197 MDiagEngineCommon::TCancelMode aCancelMode ) |
|
198 { |
|
199 MDiagSuitePlugin::TStopReason stopReason; |
|
200 |
|
201 switch ( aCancelMode ) |
|
202 { |
|
203 case MDiagEngineCommon::ECancelAll: |
|
204 stopReason = MDiagSuitePlugin::ECancelAll; |
|
205 break; |
|
206 |
|
207 case MDiagEngineCommon::ESkip: |
|
208 stopReason = MDiagSuitePlugin::ESkip; |
|
209 break; |
|
210 |
|
211 default: |
|
212 __ASSERT_DEBUG( 0, Panic( EDiagFrameworkInternal ) ); |
|
213 stopReason = MDiagSuitePlugin::ESkip; |
|
214 break; |
|
215 } |
|
216 |
|
217 StopSuitePluginL( stopReason ); |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CDiagExecPlanEntryImplSuite::StopSuitePluginL |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CDiagExecPlanEntryImplSuite::StopSuitePluginL( |
|
225 MDiagSuitePlugin::TStopReason aStopReason ) |
|
226 { |
|
227 LOGSTRING3( "CDiagExecPlanEntryImplSuite::StopSuitePluginL(): " |
|
228 L"Calling plugin uid = 0x%08x SuitePlugin::ExecutionStopL( %d )", |
|
229 Plugin().Uid().iUid, |
|
230 aStopReason ) |
|
231 |
|
232 Cancel(); |
|
233 |
|
234 switch ( State() ) |
|
235 { |
|
236 case EStateQueued: // fall through |
|
237 case EStateInitDelay: // fall through |
|
238 case EStateStopped: // fall through |
|
239 case EStateSuspended: // fall through |
|
240 case EStateCompleted: |
|
241 LOGSTRING3( "CDiagExecPlanEntryImplSuite::DoStopSuitePluginL(): " |
|
242 L"Plugin 0x%08x = %d. Do nothing.", |
|
243 Plugin().Uid().iUid, |
|
244 State() ) |
|
245 break; |
|
246 |
|
247 case EStateRunning: |
|
248 LOGSTRING2( "CDiagExecPlanEntryImplSuite::DoStopSuitePluginL(): " |
|
249 L"Plugin 0x%08x was in ERunning or ESuspended. Call Stop", |
|
250 Plugin().Uid().iUid ) |
|
251 SuitePlugin().ExecutionStopL( aStopReason ); |
|
252 break; |
|
253 |
|
254 default: |
|
255 LOGSTRING3( "CDiagExecPlanEntryImplSuite::DoStopSuitePluginL(): " |
|
256 L"Plugin 0x%08x = INVALID STATE! %d", |
|
257 Plugin().Uid().iUid, |
|
258 State() ) |
|
259 __ASSERT_DEBUG( 0, Panic( EDiagFrameworkCorruptStateMachine ) ); |
|
260 break; |
|
261 } |
|
262 |
|
263 // Notify observer as if plug-in itself would have done. |
|
264 ContinueExecutionL( SuitePlugin() ); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // CDiagExecPlanEntryImplSuite::SuspendL |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 void CDiagExecPlanEntryImplSuite::SuspendL() |
|
272 { |
|
273 Cancel(); |
|
274 |
|
275 switch ( State() ) |
|
276 { |
|
277 case EStateQueued: // fall through |
|
278 case EStateInitDelay: // fall through |
|
279 LOGSTRING3( "CDiagExecPlanEntryImplSuite::SuspendL(): " |
|
280 L"Plugin 0x%08x = %d. Reset to Queued state", |
|
281 Plugin().Uid().iUid, |
|
282 State() ) |
|
283 // force reset the execution state to queued so that |
|
284 // it will be restarted |
|
285 ChangeStateL( EStateQueued ); |
|
286 break; |
|
287 |
|
288 case EStateRunning: |
|
289 LOGSTRING2( "CDiagExecPlanEntryImplSuite::SuspendL(): " |
|
290 L"Plugin 0x%08x was in ERunning. Calling Stop", |
|
291 Plugin().Uid().iUid ) |
|
292 |
|
293 // Suites do not have suspend. Stop with cancel as reason. |
|
294 SuitePlugin().ExecutionStopL( MDiagSuitePlugin::ESkip ); |
|
295 // force reset the plugin execution to queued so that |
|
296 // it will be restarted |
|
297 ChangeStateL( EStateQueued ); |
|
298 break; |
|
299 |
|
300 case EStateStopped: |
|
301 LOGSTRING2( "CDiagExecPlanEntryImplSuite::SuspendL(): " |
|
302 L"Plugin 0x%08x = Stopped.", |
|
303 Plugin().Uid().iUid ) |
|
304 // plug-in is already stopped. |
|
305 ChangeStateL( EStateSuspended ); |
|
306 break; |
|
307 |
|
308 case EStateSuspended: |
|
309 LOGSTRING2( "CDiagExecPlanEntryImplSuite::SuspendL(): " |
|
310 L"Plugin 0x%08x = Suspended.", |
|
311 Plugin().Uid().iUid ) |
|
312 // already suspneded. nothing to do. |
|
313 break; |
|
314 |
|
315 case EStateCompleted: |
|
316 LOGSTRING2( "CDiagExecPlanEntryImplSuite::SuspendL(): " |
|
317 L"Plugin 0x%08x was already in completed state. No change", |
|
318 Plugin().Uid().iUid ) |
|
319 break; |
|
320 |
|
321 default: |
|
322 LOGSTRING3( "CDiagExecPlanEntryImplSuite::SuspendL(): " |
|
323 L"Plugin 0x%08x = INVALID STATE! %d", |
|
324 Plugin().Uid().iUid, |
|
325 State() ) |
|
326 __ASSERT_DEBUG( 0, Panic( EDiagFrameworkCorruptStateMachine ) ); |
|
327 break; |
|
328 } |
|
329 |
|
330 // Postcondition. Check acceptble states. |
|
331 __ASSERT_DEBUG( State() == EStateQueued || |
|
332 State() == EStateSuspended || |
|
333 State() == EStateCompleted, |
|
334 Panic( EDiagFrameworkCorruptStateMachine ) ); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // CDiagExecPlanEntryImplSuite::ResumeL |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void CDiagExecPlanEntryImplSuite::ResumeL() |
|
342 { |
|
343 LOGSTRING3( "CDiagExecPlanEntryImplTest::ResumeL(): " |
|
344 L"Plugin 0x%08x, State = %d", Plugin().Uid().iUid, State() ) |
|
345 |
|
346 __ASSERT_DEBUG( State() == EStateQueued || |
|
347 State() == EStateSuspended, |
|
348 Panic( EDiagFrameworkCorruptStateMachine ) ); |
|
349 |
|
350 if ( State() == EStateQueued ) |
|
351 { |
|
352 ExecuteL(); |
|
353 } |
|
354 else |
|
355 { |
|
356 ContinueExecutionL( SuitePlugin() ); |
|
357 } |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // From MDiagSuiteObserver |
|
362 // CDiagExecPlanEntryImplSuite::ContinueExecutionL |
|
363 // --------------------------------------------------------------------------- |
|
364 // |
|
365 void CDiagExecPlanEntryImplSuite::ContinueExecutionL( const MDiagSuitePlugin& aSender ) |
|
366 { |
|
367 __ASSERT_ALWAYS( aSender.Uid() == Plugin().Uid(), Panic( EDiagFrameworkPlugin ) ); |
|
368 |
|
369 // Need to do an empty request complete since by default, suite plug-ins |
|
370 // do nothing in prepare/finalize steps and just call ContinueExecutionL. |
|
371 // Doing empty request complete ensures that Plug-in call back does not |
|
372 // directly call application TestExecutionCompletedL() method. |
|
373 |
|
374 ChangeStateL( EStateStopped ); |
|
375 |
|
376 TRequestStatus* status = &iStatus; |
|
377 User::RequestComplete( status, KErrNone ); |
|
378 SetActive(); |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // From CActive |
|
383 // CDiagExecPlanEntryImplSuite::RunL |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 void CDiagExecPlanEntryImplSuite::RunL() |
|
387 { |
|
388 ChangeStateL( EStateCompleted ); |
|
389 |
|
390 #ifdef _DEBUG |
|
391 HBufC* pluginName = Plugin().GetPluginNameL( |
|
392 MDiagPlugin::ENameLayoutListSingle ); |
|
393 |
|
394 LOGSTRING4( "} ---- SUITE END ---- [ 0x%08x %S / %s ] ---- SUITE END ----", |
|
395 Plugin().Uid().iUid, |
|
396 pluginName, |
|
397 ( Type() == ETypeSuitePrepare ) ? L"PREPARE" : L"FINALIZE" ) |
|
398 |
|
399 delete pluginName; |
|
400 pluginName = NULL; |
|
401 #endif // _DEBUG |
|
402 |
|
403 Observer().ExecPlanEntryExecutedL( *this ); |
|
404 } |
|
405 |
|
406 |
|
407 // --------------------------------------------------------------------------- |
|
408 // From CActive |
|
409 // CDiagExecPlanEntryImplSuite::DoCancel |
|
410 // --------------------------------------------------------------------------- |
|
411 // |
|
412 void CDiagExecPlanEntryImplSuite::DoCancel() |
|
413 { |
|
414 // nothing to do |
|
415 } |
|
416 |
|
417 |
|
418 // End of File |
|
419 |
|