111 // CAiStateManager::~CAiStateManager() |
108 // CAiStateManager::~CAiStateManager() |
112 // C++ default destructor. |
109 // C++ default destructor. |
113 // ---------------------------------------------------------------------------- |
110 // ---------------------------------------------------------------------------- |
114 // |
111 // |
115 CAiStateManager::~CAiStateManager() |
112 CAiStateManager::~CAiStateManager() |
116 { |
113 { |
117 delete iCommandBuffer; |
114 iReloadPlugins.Reset(); |
118 iReloadPlugins.Close(); |
|
119 } |
115 } |
120 |
116 |
121 // ---------------------------------------------------------------------------- |
117 // ---------------------------------------------------------------------------- |
122 // CAiStateManager::CAiStateManager() |
118 // CAiStateManager::CAiStateManager() |
123 // C++ default constructor. |
119 // C++ default constructor. |
226 __PRINTS( "CAiStateManager::NotifyStateChange, aState: Unknown" ); |
220 __PRINTS( "CAiStateManager::NotifyStateChange, aState: Unknown" ); |
227 } |
221 } |
228 |
222 |
229 // State change evaluation and state change trial is done always here |
223 // State change evaluation and state change trial is done always here |
230 __PRINTS( "CAiStateManager::NotifyStateChange, Run state change" ); |
224 __PRINTS( "CAiStateManager::NotifyStateChange, Run state change" ); |
|
225 |
231 ProcessStateChange( EvaluateNextState() ); |
226 ProcessStateChange( EvaluateNextState() ); |
232 } |
227 } |
233 |
228 |
234 // ---------------------------------------------------------------------------- |
229 // ---------------------------------------------------------------------------- |
235 // CAiStateManager::NotifyLoadPlugin() |
230 // CAiStateManager::NotifyLoadPlugin() |
236 // |
231 // |
237 // ---------------------------------------------------------------------------- |
232 // ---------------------------------------------------------------------------- |
238 // |
233 // |
239 TInt CAiStateManager::NotifyLoadPlugin( const THsPublisherInfo& aPublisherInfo, |
234 void CAiStateManager::NotifyLoadPlugin( const TAiFwPublisherInfo& aInfo ) |
240 TAiFwLoadReason aReason ) |
|
241 { |
235 { |
242 __PRINT( __DBG_FORMAT( |
236 __PRINT( __DBG_FORMAT( |
243 "CAiStateManager::NotifyLoadPlugin: name: %S, reason: %d " ), |
237 "CAiStateManager::NotifyLoadPlugin: name: %S, reason: %d " ), |
244 &aPublisherInfo.Name(), (TInt) aReason ); |
238 &aInfo.Info().Name(), aInfo.Reason() ); |
245 |
239 |
246 __TIME_MARK( time ); |
240 __TIME_MARK( time ); |
247 |
241 |
248 // Create plugin |
242 iFactory.LoadPlugin( aInfo ); |
249 TInt retval( iFactory.CreatePlugin( aPublisherInfo ) ); |
243 |
250 |
244 __TIME_ENDMARK( "CAiStateManager::NotifyLoadPlugin - done", time ); |
251 if ( retval == KErrNone ) |
|
252 { |
|
253 CHsContentPublisher* plugin( iFactory.PluginByInfo( aPublisherInfo ) ); |
|
254 |
|
255 if( plugin ) |
|
256 { |
|
257 // Do startup state transition |
|
258 StartPlugin( *plugin, StartReason( aReason ) ); |
|
259 } |
|
260 } |
|
261 |
|
262 __TIME_ENDMARK( "CAiStateManager::NotifyLoadPlugin, construction", time ); |
|
263 |
|
264 return retval; |
|
265 } |
245 } |
266 |
246 |
267 // ---------------------------------------------------------------------------- |
247 // ---------------------------------------------------------------------------- |
268 // CAiStateManager::NotifyDestroyPlugin() |
248 // CAiStateManager::NotifyDestroyPlugin() |
269 // |
249 // |
270 // ---------------------------------------------------------------------------- |
250 // ---------------------------------------------------------------------------- |
271 // |
251 // |
272 void CAiStateManager::NotifyDestroyPlugin( |
252 void CAiStateManager::NotifyDestroyPlugin( const TAiFwPublisherInfo& aInfo ) |
273 const THsPublisherInfo& aPublisherInfo, TAiFwDestroyReason aReason ) |
|
274 { |
253 { |
275 __PRINT( __DBG_FORMAT( |
254 __PRINT( __DBG_FORMAT( |
276 "CAiStateManager::NotifyDestroyPlugin: name: %S, reason: %d " ), |
255 "CAiStateManager::NotifyDestroyPlugin: name: %S, reason: %d " ), |
277 &aPublisherInfo.Name(), (TInt)aReason ); |
256 &aInfo.Info().Name(), aInfo.Reason() ); |
278 |
257 |
279 __TIME_MARK( time ); |
258 __TIME_MARK( time ); |
280 |
259 |
281 // Resolve plugin |
260 iFactory.DestroyPlugin( aInfo ); |
282 CHsContentPublisher* plugin( iFactory.PluginByInfo( aPublisherInfo ) ); |
261 |
283 |
262 __TIME_ENDMARK( "CAiStateManager::DestroyPlugin - done", time ); |
284 if ( plugin ) |
|
285 { |
|
286 // Do shutdown state transition |
|
287 StopPlugin( *plugin, StopReason( aReason ) ); |
|
288 |
|
289 // Destroy plugin |
|
290 iFactory.DestroyPlugin( aPublisherInfo ); |
|
291 } |
|
292 |
|
293 __TIME_ENDMARK( "CAiStateManager::DestroyPlugin, done", time ); |
|
294 } |
|
295 |
|
296 // ---------------------------------------------------------------------------- |
|
297 // CAiStateManager::NotifyReloadPlugins() |
|
298 // |
|
299 // ---------------------------------------------------------------------------- |
|
300 // |
|
301 void CAiStateManager::NotifyReloadPlugins() |
|
302 { |
|
303 __PRINTS( "CAiStateManager::NotifyReloadPlugins" ); |
|
304 |
|
305 for ( TInt i = 0; i < iReloadPlugins.Count(); i++ ) |
|
306 { |
|
307 // Reload plugin |
|
308 NotifyLoadPlugin( iReloadPlugins[ i ], EAiFwSystemStartup ); |
|
309 } |
|
310 |
|
311 __PRINTS( "CAiStateManager::NotifyReloadPlugins, done" ); |
|
312 } |
263 } |
313 |
264 |
314 // ---------------------------------------------------------------------------- |
265 // ---------------------------------------------------------------------------- |
315 // CAiStateManager::EvaluateNextState() |
266 // CAiStateManager::EvaluateNextState() |
316 // |
267 // |
480 { |
431 { |
481 plugin->SetOffline(); |
432 plugin->SetOffline(); |
482 } |
433 } |
483 } |
434 } |
484 |
435 |
485 FlushCommandBuffer(); |
436 iFactory.FlushCommandBuffer(); |
|
437 |
|
438 __PRINTS( "CAiStateManager::ProcessOnlineStateChange - done" ); |
486 } |
439 } |
487 |
440 |
488 // ---------------------------------------------------------------------------- |
441 // ---------------------------------------------------------------------------- |
489 // CAiStateManager::StartPlugin() |
442 // CAiStateManager::StartPlugin() |
490 // |
443 // |
491 // ---------------------------------------------------------------------------- |
444 // ---------------------------------------------------------------------------- |
492 // |
445 // |
493 void CAiStateManager::StartPlugin( CHsContentPublisher& aPlugin, |
446 void CAiStateManager::StartPlugin( CHsContentPublisher& aPlugin, TInt aReason ) |
494 CHsContentPublisher::TStartReason aReason ) |
|
495 { |
447 { |
496 const THsPublisherInfo& info( aPlugin.PublisherInfo() ); |
448 const THsPublisherInfo& info( aPlugin.PublisherInfo() ); |
497 |
449 |
498 __PRINT( __DBG_FORMAT( |
450 __PRINT( __DBG_FORMAT( |
499 "CAiStateManager::StartPlugin: name: %S, reason: %d" ), &info.Name(), (TInt)aReason ); |
451 "CAiStateManager::StartPlugin: name: %S, reason: %d" ), &info.Name(), (TInt)aReason ); |
500 |
452 |
501 aPlugin.Start( aReason ); |
453 aPlugin.Start( StartReason( aReason ) ); |
502 |
454 |
503 if ( iCurrentState == EAlive ) |
455 if ( iCurrentState == EAlive ) |
504 { |
456 { |
505 __TIME( "CAiStateManager::StartPlugin, enter EAlive", |
457 __TIME( "CAiStateManager::StartPlugin, enter EAlive", |
506 |
458 |
523 { |
475 { |
524 __TIME( "CAiStateManager::StartPlugin, Set Offline", |
476 __TIME( "CAiStateManager::StartPlugin, Set Offline", |
525 |
477 |
526 aPlugin.SetOffline() ); |
478 aPlugin.SetOffline() ); |
527 } |
479 } |
528 |
480 |
529 FlushCommandBuffer(); |
|
530 |
|
531 __PRINTS( "CAiStateManager::StartPlugin - done" ); |
481 __PRINTS( "CAiStateManager::StartPlugin - done" ); |
532 } |
482 } |
533 |
483 |
534 // ---------------------------------------------------------------------------- |
484 // ---------------------------------------------------------------------------- |
535 // CAiStateManager::StopPlugin() |
485 // CAiStateManager::StopPlugin() |
536 // |
486 // |
537 // ---------------------------------------------------------------------------- |
487 // ---------------------------------------------------------------------------- |
538 // |
488 // |
539 void CAiStateManager::StopPlugin( CHsContentPublisher& aPlugin, |
489 void CAiStateManager::StopPlugin( CHsContentPublisher& aPlugin, TInt aReason ) |
540 CHsContentPublisher::TStopReason aReason ) |
|
541 { |
490 { |
542 const THsPublisherInfo& info( aPlugin.PublisherInfo() ); |
491 const THsPublisherInfo& info( aPlugin.PublisherInfo() ); |
543 |
492 |
544 __PRINT( __DBG_FORMAT( |
493 __PRINT( __DBG_FORMAT( |
545 "CAiStateManager::StopPlugin: name: %S, reason: %d" ), &info.Name(), (TInt)aReason ); |
494 "CAiStateManager::StopPlugin: name: %S, reason: %d" ), &info.Name(), (TInt)aReason ); |
549 __TIME( "CAiStateManager::StopPlugin, enter ESuspended", |
498 __TIME( "CAiStateManager::StopPlugin, enter ESuspended", |
550 |
499 |
551 aPlugin.Suspend( CHsContentPublisher::EBackground ) ); |
500 aPlugin.Suspend( CHsContentPublisher::EBackground ) ); |
552 } |
501 } |
553 |
502 |
554 aPlugin.Stop( aReason ); |
503 aPlugin.Stop( StopReason( aReason ) ); |
555 |
504 |
556 FlushCommandBuffer(); |
|
557 |
|
558 __PRINTS( "CAiStateManager::StopPlugin - done" ); |
505 __PRINTS( "CAiStateManager::StopPlugin - done" ); |
559 } |
506 } |
560 |
507 |
561 // ---------------------------------------------------------------------------- |
508 // ---------------------------------------------------------------------------- |
562 // CAiStateManager::DestroyPlugins() |
509 // CAiStateManager::NotifyReloadPlugins() |
563 // |
510 // |
564 // ---------------------------------------------------------------------------- |
511 // ---------------------------------------------------------------------------- |
565 // |
512 // |
566 void CAiStateManager::DestroyPlugins() |
513 void CAiStateManager::NotifyReloadPlugins() |
567 { |
514 { |
568 __PRINTS( "CAiStateManager::DestroyPlugins, start" ); |
515 __PRINTS( "CAiStateManager::NotifyReloadPlugins" ); |
569 __TIME_MARK( time ); |
516 |
570 |
517 // Factory needs to update its ecom plugins list |
571 RPointerArray< CHsContentPublisher >& plugins( iFactory.Publishers() ); |
518 TRAP_IGNORE( iFactory.ListImplementationsL() ); |
572 |
519 |
573 for ( TInt i = 0; i < plugins.Count(); i++ ) |
520 for ( TInt i = 0; i < iReloadPlugins.Count(); i++ ) |
574 { |
521 { |
575 CHsContentPublisher* plugin( plugins[i] ); |
522 TAiFwPublisherInfo info( iReloadPlugins[i], |
576 |
523 TAiFwCallback(), EAiFwSystemStartup ); |
577 // Do shutdown state transition |
524 |
578 StopPlugin( *plugin, CHsContentPublisher::ESystemShutdown ); |
525 // Reload plugin |
579 } |
526 NotifyLoadPlugin( info ); |
580 |
527 } |
581 FlushCommandBuffer(); |
528 |
582 |
529 iReloadPlugins.Reset(); |
583 // Finally get rid of all plugins |
530 |
584 plugins.ResetAndDestroy(); |
531 __PRINTS( "CAiStateManager::NotifyReloadPlugins - done" ); |
585 |
532 } |
586 __TIME_ENDMARK( "CAiStateManager::DestroyPlugins, done", time ); |
533 |
587 } |
|
588 |
|
589 // ---------------------------------------------------------------------------- |
|
590 // CAiStateManager::FlushCommandBuffer();() |
|
591 // |
|
592 // ---------------------------------------------------------------------------- |
|
593 // |
|
594 void CAiStateManager::FlushCommandBuffer() |
|
595 { |
|
596 __PRINTS( "CAiStateManager::FlushCommandBuffer, start" ); |
|
597 |
|
598 if ( iCommandBuffer ) |
|
599 { |
|
600 __TIME( "CAiStateManager::FlushCommandBuffer, flush", |
|
601 |
|
602 iCommandBuffer->Flush() ); |
|
603 } |
|
604 |
|
605 __PRINTS( "CAiStateManager::FlushCommandBuffer - done" ); |
|
606 } |
|
607 |
|
608 // ---------------------------------------------------------------------------- |
534 // ---------------------------------------------------------------------------- |
609 // CAiStateManager::NotifyReleasePlugins() |
535 // CAiStateManager::NotifyReleasePlugins() |
610 // |
536 // |
611 // ---------------------------------------------------------------------------- |
537 // ---------------------------------------------------------------------------- |
612 // |
538 // |
614 { |
540 { |
615 __PRINTS( "CAiStateManager::NotifyReleasePlugins" ); |
541 __PRINTS( "CAiStateManager::NotifyReleasePlugins" ); |
616 |
542 |
617 iReloadPlugins.Reset(); |
543 iReloadPlugins.Reset(); |
618 |
544 |
|
545 TBool flush( EFalse ); |
|
546 |
619 for ( TInt i = 0; i < aUidList.Count(); i++ ) |
547 for ( TInt i = 0; i < aUidList.Count(); i++ ) |
620 { |
548 { |
621 CHsContentPublisher* plugin = iFactory.PluginByUid( aUidList[ i ] ); |
549 const TUid& uid( aUidList[ i ] ); |
622 if ( plugin ) |
550 |
|
551 CHsContentPublisher* plugin( iFactory.PluginByUid( uid ) ); |
|
552 |
|
553 while ( plugin ) |
623 { |
554 { |
624 StopPlugin( *plugin, CHsContentPublisher::ESystemShutdown ); |
555 StopPlugin( *plugin, CHsContentPublisher::ESystemShutdown ); |
625 THsPublisherInfo info = plugin->PublisherInfo(); |
556 |
|
557 const THsPublisherInfo& info( plugin->PublisherInfo() ); |
626 iReloadPlugins.Append( info ); |
558 iReloadPlugins.Append( info ); |
627 iFactory.DestroyPlugin( aUidList[ i ] ); |
559 |
|
560 iFactory.DestroyPlugin( uid ); |
|
561 |
|
562 flush = ETrue; |
|
563 |
|
564 // Get next plugin with same uid |
|
565 plugin = iFactory.PluginByUid( uid ); |
628 } |
566 } |
629 } |
567 } |
630 __PRINTS( "CAiStateManager::NotifyReleasePlugins: return void" ); |
568 |
631 } |
569 if ( flush ) |
632 |
570 { |
|
571 iFactory.FlushCommandBuffer(); |
|
572 } |
|
573 |
|
574 __PRINTS( "CAiStateManager::NotifyReleasePlugins - done" ); |
|
575 } |
|
576 |
633 // End of file |
577 // End of file |