|
1 /* |
|
2 * Copyright (c) 2004 - 2008 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: Implementation class for initializing the engine gradually. |
|
15 * Active object initializes one "subsystem" on each |
|
16 * round. In case of failure timer is started and |
|
17 * retrial is done after time-out. Uninitialization |
|
18 * is done is one shot. |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 * |
|
24 */ |
|
25 |
|
26 |
|
27 // INCLUDE FILES |
|
28 #include "CVtEngInitializer.h" |
|
29 #include "CVtEngStateManager.h" |
|
30 #include "CVtEngEventManager.h" |
|
31 #include "VtEngUtils.h" |
|
32 #include "CVtEngHandlerContainer.h" |
|
33 #include "CVtEngOperation.h" |
|
34 #include "VtEngPanic.h" |
|
35 #include "VtEngConstants.h" |
|
36 #include "VtEngDefs.hrh" |
|
37 #include <cvtlogger.h> |
|
38 #include <mvtprotocolhandler.h> |
|
39 #include <telcommsinfopskeys.h> |
|
40 #include <videotelephonyvariant.hrh> |
|
41 #include "VtEngUtils.h" |
|
42 #include "CVtEngSettings.h" |
|
43 |
|
44 // CONSTANTS |
|
45 const TInt KVtEngInitializerPriority = CActive::EPriorityStandard; |
|
46 const TInt KVtEngInitializerRetrials = 3; |
|
47 const TInt KVtEngInitializerRetrialTimeout = 500000; // 0.5 seconds |
|
48 const TInt KVtEngInitializerTimerPriority = CActive::EPriorityUserInput; |
|
49 |
|
50 _LIT( KVtEngCommDiagPortName, "PVDIAGPORT" ); |
|
51 _LIT( KVtEngCommTestPortName, "COMM::0" ); |
|
52 |
|
53 // ============================ MEMBER FUNCTIONS =============================== |
|
54 |
|
55 CVtEngInitializer* CVtEngInitializer::NewL( CVtEngHandlerContainer& aHandlers ) |
|
56 { |
|
57 __VTPRINTENTER( "Intlzr.NewL" ) |
|
58 CVtEngInitializer* self = new ( ELeave ) CVtEngInitializer( aHandlers ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop(); |
|
62 __VTPRINTEXIT( "Intlzr.NewL" ) |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CVtEngInitializer::CVtEngInitializer |
|
68 // C++ constructor can NOT contain any code, that |
|
69 // might leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CVtEngInitializer::CVtEngInitializer( |
|
73 CVtEngHandlerContainer& aHandlers ) : |
|
74 CActive( KVtEngInitializerPriority ), |
|
75 iHandlers( aHandlers ), |
|
76 iStep( EInitNone ), |
|
77 iDataportHandled( 0 ), |
|
78 iOwnershipInMH( EFalse ) |
|
79 { |
|
80 CActiveScheduler::Add( this ); |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CVtEngInitializer::ConstructL |
|
85 // Second phase constructor. |
|
86 // |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CVtEngInitializer::ConstructL() |
|
90 { |
|
91 iTimer = CPeriodic::NewL( KVtEngInitializerTimerPriority ); |
|
92 |
|
93 } |
|
94 |
|
95 // Destructor |
|
96 CVtEngInitializer::~CVtEngInitializer() |
|
97 { |
|
98 __VTPRINTENTER( "Intlzr.~" ) |
|
99 delete iTimer; |
|
100 Cancel(); |
|
101 |
|
102 if ( iSessionCommand && !iOwnershipInMH ) |
|
103 { |
|
104 VTProtocolFactory::DeleteSessionCommand( iSessionCommand ); |
|
105 iSessionCommand = NULL; |
|
106 } |
|
107 __VTPRINTEXIT( "Intlzr.~" ) |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CVtEngInitializer::InitializeL |
|
112 // Start initialization process. |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CVtEngInitializer::InitializeL( CVtEngOperation& aCallback ) |
|
117 { |
|
118 __VTPRINTENTER( "Intlzr.InitializeL" ) |
|
119 __VTPRINT( DEBUG_GEN, "Intlzr.Init") |
|
120 __ASSERT_ALWAYS( iStep != EInitComplete, |
|
121 Panic( EVtEngPanicInvalidInitializationEntry ) ); |
|
122 iCallback = &aCallback; |
|
123 if ( iStep == EInitComplete ) |
|
124 { |
|
125 __VTPRINTEXIT( "Intlzr.InitializeL" ) |
|
126 return; |
|
127 } |
|
128 ContinueOrRetry( EContinue ); |
|
129 __VTPRINTEXIT( "Intlzr.InitializeL" ) |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CVtEngInitializer::CancelInit |
|
134 // Cancels already started ini. |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 TBool CVtEngInitializer::CancelInit() |
|
139 { |
|
140 __VTPRINTENTER( "Intlzr.CancelInit" ) |
|
141 TBool cancelSignalled = EFalse; |
|
142 __VTPRINT2( DEBUG_GEN, "Intlzr.CancelInit %d", iStep ) |
|
143 if ( IsActive() ) |
|
144 { |
|
145 switch ( iStep ) |
|
146 { |
|
147 case EInitMedia: // media->InitializeL pending |
|
148 case EInitProto: // media->InitializeProviderL pending |
|
149 { |
|
150 if ( ! ( iDataportHandled & EDataportReceived ) ) |
|
151 { |
|
152 __VTPRINT( DEBUG_GEN, "Intlzr.CancelInit complete" ) |
|
153 if ( iStatus == KRequestPending ) |
|
154 { |
|
155 // Actual protocol init is not done yet. |
|
156 TRequestStatus* status = &iStatus; |
|
157 __VTPRINT( DEBUG_GEN, "Intlzr.CancelInit complete1" ) |
|
158 User::RequestComplete( status, KErrNone ); |
|
159 __VTPRINT( DEBUG_GEN, "Intlzr.CancelInit complete2" ) |
|
160 } |
|
161 iDataportHandled |= EDataportReceived; |
|
162 __VTPRINT( DEBUG_GEN, "Intlzr.CancelInit complete" ) |
|
163 } |
|
164 __VTPRINT( DEBUG_GEN, "Intlzr.CancelInit MH cancel" ) |
|
165 CVtEngMediaHandler* media = |
|
166 static_cast<CVtEngMediaHandler*>( &iHandlers.Media() ); |
|
167 media->CancelInitialize(); |
|
168 iStep = EResetMediaPhase2; |
|
169 } |
|
170 break; |
|
171 case EResetMedia: |
|
172 break; |
|
173 default: |
|
174 cancelSignalled = ETrue; |
|
175 Cancel(); |
|
176 } |
|
177 } |
|
178 __VTPRINTEXITR( "Intlzr.CancelInit %d", cancelSignalled ) |
|
179 return cancelSignalled; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CVtEngInitializer::Uninitialize |
|
184 // Start un-initialization process. |
|
185 // |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CVtEngInitializer::Uninitialize( CVtEngOperation& aCallback ) |
|
189 { |
|
190 __VTPRINTENTER( "Intlzr.Uninitialize" ) |
|
191 iCallback = &aCallback; |
|
192 ContinueOrRetry( EReset ); |
|
193 __VTPRINTEXIT( "Intlzr.Uninitialize" ) |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CVtEngInitializer::GetSessionCommand |
|
198 // Transfer ownership of Protocol and continue initialization. |
|
199 // |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 MVtSessionCommand* CVtEngInitializer::GetSessionCommand() |
|
203 { |
|
204 __VTPRINTENTER( "Intlzr.GetSessionCommand" ) |
|
205 __VTPRINT2( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.GetSessionCommand iSessionCommand: $%x", reinterpret_cast< TUint >( iSessionCommand ) ) |
|
206 MVtSessionCommand* sessionCommand = iSessionCommand; |
|
207 |
|
208 // Set ownership to media handler since media handler is requesting so. |
|
209 iOwnershipInMH = ETrue; |
|
210 if( iStep >= EInitDataportCompleted ) |
|
211 { |
|
212 // Ownership can be totally given to MH after dataport is loaned. |
|
213 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.GetSessionCommand iSessionCommand ownership to MH GetSessionCommand") |
|
214 |
|
215 iSessionCommand = NULL; |
|
216 iStep = EInitComplete; |
|
217 ContinueOrRetry( EContinue ); |
|
218 } |
|
219 if ( iStep != EResetMedia ) |
|
220 { |
|
221 __VTPRINT( DEBUG_GEN, "Intlzr.GetSessionCommand=>ContinueOrRetry( EContinue )") |
|
222 ContinueOrRetry( EContinue ); |
|
223 } |
|
224 else |
|
225 { |
|
226 // Reset requested. ContinueOrRetry with EReset was called |
|
227 // while protocol Init was ongoing. Now continue |
|
228 __VTPRINT( DEBUG_GEN, "Intlzr.GetSessionCommand=>ContinueOrRetry( EReset )") |
|
229 ContinueOrRetry( EReset ); |
|
230 } |
|
231 __VTPRINTEXIT( "Intlzr.GetSessionCommand" ) |
|
232 return sessionCommand; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CVtEngInitializer::Initialized |
|
237 // Returns if engine is initialized. |
|
238 // |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 TBool CVtEngInitializer::Initialized() const |
|
242 { |
|
243 return ( iStep == EInitComplete ); |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CVtEngInitializer::RunL |
|
248 // Perform initialization step |
|
249 // |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CVtEngInitializer::RunL() |
|
253 { |
|
254 __VTPRINTENTER( "Intlzr.RunL" ) |
|
255 __VTPRINT3( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.Run step=%d err=%d", |
|
256 iStep, iStatus.Int() ) |
|
257 if ( iStatus != KErrNone ) |
|
258 { |
|
259 Notify( iStatus.Int() ); |
|
260 __VTPRINTEXIT( "Intlzr.RunL" ) |
|
261 return; |
|
262 } |
|
263 CVtEngMediaHandler* media = |
|
264 static_cast<CVtEngMediaHandler*>( &iHandlers.Media() ); |
|
265 |
|
266 switch ( iStep ) |
|
267 { |
|
268 case EInitNone: |
|
269 return; |
|
270 case EInitMedia: |
|
271 // Initialize video source |
|
272 iStatus = KRequestPending; |
|
273 media->InitializeL( iStatus ); |
|
274 SetActive(); |
|
275 iStep++; // EInitProto |
|
276 __VTPRINTEXIT( "Intlzr.RunL" ) |
|
277 return; |
|
278 case EInitProto: |
|
279 // Initialize Protocol => create terminal only once. |
|
280 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.Run create Protocol") |
|
281 if ( !iSessionCommand ) |
|
282 { |
|
283 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.Run DOCREATE Protocol" ) |
|
284 TVt3G324MSupported protocolSupported; |
|
285 iSessionCommand = VTProtocolFactory::CreateSessionCommandL( |
|
286 media, ETrue, protocolSupported ); |
|
287 |
|
288 if (protocolSupported == EVt3G324MMissing) |
|
289 { |
|
290 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.Run init 3G324M stack is missing") |
|
291 Notify(KErrNotReady); |
|
292 return; |
|
293 } |
|
294 |
|
295 // Initialize Protocol immediately after it is created. |
|
296 if( iSessionCommand ) |
|
297 { |
|
298 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.Run InitL protocol") |
|
299 iSessionCommand->InitProtocolL( media->SdkInitInfo() ); |
|
300 } |
|
301 } |
|
302 if ( iSessionCommand ) |
|
303 { |
|
304 const TDesC* dataportName = NULL; |
|
305 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.Run init protocol") |
|
306 if(iCallback->Command() == KVtEngInitializeEngineTest ) |
|
307 { |
|
308 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, |
|
309 "Intlzr.Run init with COMM::0") |
|
310 CVtEngUtility::Settings().SetConnectReady(); |
|
311 iComms = VTProtocolFactory::CreateCommServerL( |
|
312 KVtEngCommTestPortName ); |
|
313 } |
|
314 else if( iCallback->Command() == KVtEngInitializeEngineDiag ) |
|
315 { |
|
316 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, |
|
317 "Intlzr.Run init with PVDIAGPORT") |
|
318 CVtEngUtility::Settings().SetConnectReady(); |
|
319 iComms = VTProtocolFactory::CreateCommServerL( |
|
320 KVtEngCommDiagPortName ); |
|
321 } |
|
322 else |
|
323 { // [MediatorChange]: |
|
324 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, |
|
325 "Intlzr.Run init with DATAPORT" ) |
|
326 dataportName = |
|
327 CVtEngUtility::Settings().DataportInfo(); |
|
328 if ( !dataportName ) |
|
329 { |
|
330 // not available yet, start waiting, |
|
331 // HandleSettingChangedL is called when dataport |
|
332 // becomes available |
|
333 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, |
|
334 "Intlzr.Run DATAPORT is not ready yet" ) |
|
335 |
|
336 CVtEngUtility::Settings().NotifyChangeL( |
|
337 CVtEngSettings::EDataportInfo, *this ); |
|
338 iStatus = KRequestPending; |
|
339 SetActive(); |
|
340 __VTPRINTEXIT( "Intlzr.RunL" ) |
|
341 return; |
|
342 } |
|
343 else |
|
344 { |
|
345 //RDebug::Print( _L("DataportName is:%S"), dataportName ); |
|
346 TBool bitReversed( BitReversalUsed() ); |
|
347 |
|
348 iComms = VTProtocolFactory::CreateCommServerL( |
|
349 *dataportName, bitReversed ); |
|
350 // not interested of DP info any more |
|
351 CVtEngUtility::Settings().CancelNotifyChange( |
|
352 CVtEngSettings::EDataportInfo, *this ); |
|
353 } |
|
354 } |
|
355 |
|
356 // Initialization is now completed |
|
357 iStep = EInitDataportCompleted; |
|
358 |
|
359 // Dataport is now loaned |
|
360 CVtEngUtility::Settings().SetDataportLoaned( ETrue ); |
|
361 |
|
362 // Update states since dataport is now loaned |
|
363 CVtEngStateManager* states = CVtEngUtility::StateManager(); |
|
364 states->Update(); |
|
365 |
|
366 // No need for ownership anymore, media handler owns the pointer and is |
|
367 // responsible of deletion. |
|
368 if( iOwnershipInMH ) |
|
369 { |
|
370 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.Run iSessionCommand ownership to MH") |
|
371 iSessionCommand = NULL; |
|
372 iStep = EInitComplete; |
|
373 ContinueOrRetry( EContinue ); |
|
374 } |
|
375 |
|
376 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, |
|
377 "Intlzr.Run init protocol port operation completed") |
|
378 // Media handler calls GetSessionCommand when InitL |
|
379 // is complete and initialization continues. |
|
380 __VTPRINTEXIT( "Intlzr.RunL" ) |
|
381 return; |
|
382 } |
|
383 break; |
|
384 case EInitSession: |
|
385 { |
|
386 CVtEngSessionHandler* session = |
|
387 static_cast<CVtEngSessionHandler*>( &iHandlers.Session() ); |
|
388 session->InitializeL(); |
|
389 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, |
|
390 "Intlzr.RunL StartMediatorListenerL" ) |
|
391 CVtEngUtility::EngineUtils()->StartMediatorListenerL(); |
|
392 } |
|
393 break; |
|
394 case EResetMedia: |
|
395 iHandlers.Uninitialize(); |
|
396 iStatus = KRequestPending; |
|
397 media->Uninitialize( iStatus ); |
|
398 SetActive(); |
|
399 iStep++; // EResetMediaPhase2 |
|
400 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, |
|
401 "Intlzr.RunL step reset media started" ) |
|
402 __VTPRINTEXIT( "Intlzr.RunL" ) |
|
403 return; |
|
404 case EResetMediaPhase2: |
|
405 if ( iComms ) |
|
406 { |
|
407 __VTPRINT( DEBUG_GEN | DEBUG_DETAIL, |
|
408 "Intlzr.RunL VTENgine deletes COMM server" ) |
|
409 CVtEngMediaHandler* media = |
|
410 static_cast<CVtEngMediaHandler*>( &iHandlers.Media() ); |
|
411 if ( media->ProtoInitialized() ) |
|
412 { |
|
413 TRAPD( err, VTProtocolFactory::DeleteCommServerL( iComms ) ); |
|
414 __VTPRINT2( DEBUG_GEN | DEBUG_DETAIL, |
|
415 "Intlzr.RunL VTENgine deletes COMM server err=%d", err ) |
|
416 __ASSERT_ALWAYS( err == KErrNone, |
|
417 Panic( EVtEngPanicCommsDestructOnInvalidState ) ); |
|
418 iComms = NULL; |
|
419 } |
|
420 else if ( !media->ProtoInitialized() && iSessionCommand ) |
|
421 { |
|
422 __VTPRINTEXIT( "Intlzr.RunL" ) |
|
423 return; |
|
424 } |
|
425 } |
|
426 break; |
|
427 case EInitComplete: |
|
428 break; |
|
429 default: |
|
430 Panic( EVtEngPanicInvalidInitializationState ); |
|
431 break; |
|
432 } |
|
433 ContinueOrRetry( EContinue ); |
|
434 __VTPRINTEXIT( "Intlzr.RunL" ) |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // CVtEngInitializer::DoCancel |
|
439 // Cancels initialization |
|
440 // |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 void CVtEngInitializer::DoCancel() |
|
444 { |
|
445 __VTPRINTENTER( "Intlzr.DoCancel" ) |
|
446 if ( iStatus == KRequestPending ) |
|
447 { |
|
448 __VTPRINT2( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.DoCancel step=%d", iStep ) |
|
449 TRequestStatus* status = &iStatus; |
|
450 User::RequestComplete( status, KErrCancel ); |
|
451 } |
|
452 iStep = EInitNone; |
|
453 iCallback = NULL; |
|
454 __VTPRINTEXIT( "Intlzr.DoCancel" ) |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CVtEngInitializer::RunError |
|
459 // Handler error on initialization. |
|
460 // |
|
461 // ----------------------------------------------------------------------------- |
|
462 // |
|
463 TInt CVtEngInitializer::RunError( TInt aError ) |
|
464 { |
|
465 __VTPRINTENTER( "Intlzr.RunError" ) |
|
466 __VTPRINT2( DEBUG_GEN, "Intlzr.RunError %d", aError ) |
|
467 if ( iRetrials ) |
|
468 { |
|
469 __VTPRINT2( DEBUG_GEN | DEBUG_DETAIL, "Intlzr.retrials %d", iRetrials ) |
|
470 TCallBack callback( CVtEngInitializer::HandleTimer, this ); |
|
471 iTimer->Start( |
|
472 KVtEngInitializerRetrialTimeout, |
|
473 KVtEngInitializerRetrialTimeout, |
|
474 callback ); |
|
475 } |
|
476 else |
|
477 { |
|
478 Notify( aError ); |
|
479 } |
|
480 __VTPRINTEXIT( "Intlzr.RunError" ) |
|
481 return KErrNone; |
|
482 } |
|
483 |
|
484 // ----------------------------------------------------------------------------- |
|
485 // CVtEngInitializer::HandleTimer |
|
486 // Handler for retrial timer. |
|
487 // |
|
488 // ----------------------------------------------------------------------------- |
|
489 // |
|
490 TInt CVtEngInitializer::HandleTimer( TAny* aAny ) |
|
491 { |
|
492 CVtEngInitializer* handler = |
|
493 reinterpret_cast<CVtEngInitializer*>( aAny ); |
|
494 handler->DoHandleTimer(); |
|
495 return KErrNone; |
|
496 } |
|
497 |
|
498 // ----------------------------------------------------------------------------- |
|
499 // CVtEngInitializer::DoHandleTimer |
|
500 // Handler for retrial timer. |
|
501 // |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 void CVtEngInitializer::DoHandleTimer() |
|
505 { |
|
506 iTimer->Cancel(); |
|
507 ContinueOrRetry( ERetry ); |
|
508 } |
|
509 |
|
510 TBool CVtEngInitializer::ActivateAndSignal( TInt aSignalValue ) |
|
511 { |
|
512 __VTPRINTENTER( "Intlzr.ActivateAndSignal" ) |
|
513 TRequestStatus* status = &iStatus; |
|
514 TBool signaled = EFalse; |
|
515 if ( iStatus.Int() != KRequestPending && !IsActive() ) |
|
516 { |
|
517 iStatus = KRequestPending; |
|
518 SetActive(); |
|
519 User::RequestComplete( status, aSignalValue ); |
|
520 signaled = ETrue; |
|
521 } |
|
522 __VTPRINTEXITR( "Intlzr.ActivateAndSignal signaled=%d", signaled ) |
|
523 return signaled; |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // CVtEngInitializer::CreateDtmfHandlerL |
|
528 // Creates handler for DTMF sending. |
|
529 // |
|
530 // ----------------------------------------------------------------------------- |
|
531 // |
|
532 void CVtEngInitializer::CreateDtmfHandlerL( MVtH324ConfigCommand* aH324Config ) |
|
533 { |
|
534 iHandlers.CreateDtmfHandlerL( aH324Config ); |
|
535 } |
|
536 |
|
537 // ----------------------------------------------------------------------------- |
|
538 // CVtEngInitializer::ContinueOrRetry |
|
539 // Proceed to next step, retry on failure or notify observer. |
|
540 // |
|
541 // ----------------------------------------------------------------------------- |
|
542 // |
|
543 void CVtEngInitializer::ContinueOrRetry( const TProcess aOperation ) |
|
544 { |
|
545 __VTPRINTENTER( "Intlzr.ContinueOrRetry" ) |
|
546 __VTPRINT2( DEBUG_GEN, "Intlzr.CoR op=%d", aOperation ) |
|
547 if ( aOperation == EContinue ) |
|
548 { |
|
549 const TBool resetComplete( iStep == EResetMediaPhase2 ); |
|
550 // check if last step complete and notify observer |
|
551 if ( iStep == EInitComplete || resetComplete ) |
|
552 { |
|
553 if ( resetComplete && |
|
554 // resetComplete is true also when clearing state is entered |
|
555 // while waiting for dataport. In that case Final Uninit must |
|
556 // not be done because MediaHandler's state is not ready for |
|
557 // it => need to wait for KVtEngResetEngine from UI |
|
558 iCallback->Command() == KVtEngResetEngine ) |
|
559 { |
|
560 CVtEngMediaHandler* media = |
|
561 static_cast<CVtEngMediaHandler*>( &iHandlers.Media() ); |
|
562 media->FinalizeUninitialization(); |
|
563 iStep = EInitNone; |
|
564 } |
|
565 Notify( KErrNone ); |
|
566 __VTPRINT2( DEBUG_GEN, "Intlzr.CoR op=EContinue, branch=%d", 1 ) |
|
567 return; |
|
568 } |
|
569 else if( iStep == EInitProto ) |
|
570 { |
|
571 __VTPRINT2( DEBUG_GEN, "Intlzr.CoR op=EContinue, branch=%d", 2 ) |
|
572 return; |
|
573 } |
|
574 __VTPRINT2( DEBUG_GEN, "Intlzr.CoR op=EContinue, branch=%d", 3 ) |
|
575 iStep++; |
|
576 iRetrials = KVtEngInitializerRetrials; |
|
577 } |
|
578 else if ( aOperation == EReset ) |
|
579 { |
|
580 __VTPRINT( DEBUG_GEN, "Intlzr.CoR op=EReset") |
|
581 iRetrials = KVtEngInitializerRetrials; |
|
582 const TInt step( iStep ); |
|
583 if ( step != EInitComplete && IsActive() ) |
|
584 { |
|
585 // Reset requested while init ongoing but |
|
586 // Protocol InitL not yet issued |
|
587 if ( CancelInit() == EFalse ) |
|
588 { // AO still active, must return here because end of this method |
|
589 __VTPRINT( DEBUG_GEN, " Initializer CoR 2") |
|
590 __VTPRINTEXIT( "Intlzr.ContinueOrRetry" ) |
|
591 return; |
|
592 } |
|
593 } |
|
594 iStep = EResetMedia; |
|
595 if ( ( step == EInitProto || |
|
596 step == EInitSession ) && !IsActive() ) |
|
597 { |
|
598 // Protocol InitL is pending. Wait until it completes. |
|
599 // GetSessionCommand is called and there we this is |
|
600 // again called. |
|
601 __VTPRINT( DEBUG_GEN, " Initializer reset while InitL") |
|
602 __VTPRINTEXIT( "Intlzr.ContinueOrRetry" ) |
|
603 return; |
|
604 } |
|
605 } |
|
606 else |
|
607 { |
|
608 iRetrials--; |
|
609 } |
|
610 ActivateAndSignal( KErrNone ); |
|
611 __VTPRINTEXIT( "Intlzr.ContinueOrRetry" ) |
|
612 } |
|
613 |
|
614 // ----------------------------------------------------------------------------- |
|
615 // CVtEngInitializer::Notify |
|
616 // Notifies observer on completion or error. |
|
617 // |
|
618 // ----------------------------------------------------------------------------- |
|
619 // |
|
620 void CVtEngInitializer::Notify( const TInt aResult ) |
|
621 { |
|
622 __VTPRINTENTER( "Intlzr.Notify" ) |
|
623 if ( iStep == EInitComplete ) |
|
624 { |
|
625 CVtEngStateManager* states = CVtEngUtility::StateManager(); |
|
626 states->Update(); |
|
627 } |
|
628 |
|
629 if ( iCallback ) |
|
630 { |
|
631 if ( aResult != KErrCancel ) |
|
632 { // UI is not interested on cancel completion |
|
633 iCallback->HandleOpComplete( aResult ); |
|
634 } |
|
635 iCallback = NULL; |
|
636 __VTPRINT2( DEBUG_GEN, "Intlzr.Notify res=%d", aResult ) |
|
637 } |
|
638 __VTPRINTEXIT( "Intlzr.Notify" ) |
|
639 } |
|
640 |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // CVtEngInitializer::BitReversalUsed |
|
644 // Checks if bit reversal should be used from locally variated information. |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 TBool CVtEngInitializer::BitReversalUsed() |
|
648 { |
|
649 __VTPRINT( DEBUG_GEN, "Intlzr.BitReversalUsed" ) |
|
650 return CVtEngUtility::Settings().CheckBits( |
|
651 KVTLVFlagEnableBitReversal ); |
|
652 } |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // CVtEngInitializer::HandleSettingChangedL |
|
656 // Notification of received dataport name. |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 void CVtEngInitializer::HandleSettingChangedL( |
|
660 CVtEngSettings::TSettingId aId, |
|
661 const TDesC& /*aValue*/ ) |
|
662 { |
|
663 __VTPRINTENTER( "Intlzr.HandleSettingChangedL" ) |
|
664 if ( !( iDataportHandled & EDataportReceived ) && |
|
665 aId == CVtEngSettings::EDataportInfo && |
|
666 iStatus == KRequestPending ) |
|
667 |
|
668 { |
|
669 iDataportHandled |= EDataportReceived; |
|
670 //dataport will be fetched in runl, otherwise, cancelinit can not work |
|
671 TRequestStatus* status = &iStatus; |
|
672 User::RequestComplete( status, KErrNone ); |
|
673 } |
|
674 __VTPRINTEXIT( "Intlzr.HandleSettingChangedL" ) |
|
675 } |
|
676 |
|
677 // ----------------------------------------------------------------------------- |
|
678 // CVtEngInitializer::GetVtComms |
|
679 // Return pointer to communication port. |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 MCommServer* CVtEngInitializer::GetVtComms() |
|
683 { |
|
684 return iComms; |
|
685 } |
|
686 |
|
687 // End of File |