18 // System includes |
18 // System includes |
19 |
19 |
20 // User includes |
20 // User includes |
21 #include <hscontentpublisher.h> |
21 #include <hscontentpublisher.h> |
22 #include <aifwdefs.h> |
22 #include <aifwdefs.h> |
23 |
23 #include <AknWaitDialog.h> |
|
24 #include <bautils.h> |
|
25 #include <ConeResLoader.h> |
|
26 #include <debug.h> |
|
27 |
|
28 #include "caicpscommandbuffer.h" |
24 #include "aipluginfactory.h" |
29 #include "aipluginfactory.h" |
25 |
30 |
26 #include "aistatemanager.h" |
31 #include "aistatemanager.h" |
27 |
32 |
28 #include "debug.h" |
33 #include <homescreen.rsg> |
29 |
34 |
30 // Constants |
35 _LIT( KResourceDrive, "Z:" ); |
31 _LIT( KOnlineOffline, "online_offline" ); |
36 _LIT( KResourceFile, "homescreen.rsc" ); |
|
37 _LIT( KResourcePath, "\\resource\\apps\\" ); |
32 |
38 |
33 // ======== LOCAL FUNCTIONS ======== |
39 // ======== LOCAL FUNCTIONS ======== |
34 // ---------------------------------------------------------------------------- |
40 // ---------------------------------------------------------------------------- |
35 // StartReason |
41 // StartReason |
36 // |
42 // |
112 // C++ default destructor. |
118 // C++ default destructor. |
113 // ---------------------------------------------------------------------------- |
119 // ---------------------------------------------------------------------------- |
114 // |
120 // |
115 CAiStateManager::~CAiStateManager() |
121 CAiStateManager::~CAiStateManager() |
116 { |
122 { |
|
123 if( iWaitDialog ) |
|
124 { |
|
125 delete iWaitDialog; |
|
126 } |
|
127 delete iCommandBuffer; |
|
128 iReloadPlugins.Close(); |
117 } |
129 } |
118 |
130 |
119 // ---------------------------------------------------------------------------- |
131 // ---------------------------------------------------------------------------- |
120 // CAiStateManager::CAiStateManager() |
132 // CAiStateManager::CAiStateManager() |
121 // C++ default constructor. |
133 // C++ default constructor. |
244 TInt retval( iFactory.CreatePlugin( aPublisherInfo ) ); |
259 TInt retval( iFactory.CreatePlugin( aPublisherInfo ) ); |
245 |
260 |
246 if ( retval == KErrNone ) |
261 if ( retval == KErrNone ) |
247 { |
262 { |
248 CHsContentPublisher* plugin( iFactory.PluginByInfo( aPublisherInfo ) ); |
263 CHsContentPublisher* plugin( iFactory.PluginByInfo( aPublisherInfo ) ); |
249 |
264 |
250 // Do startup state transition |
265 if( plugin ) |
251 StartPlugin( *plugin, StartReason( aReason ) ); |
266 { |
|
267 // Do startup state transition |
|
268 StartPlugin( *plugin, StartReason( aReason ) ); |
|
269 } |
252 } |
270 } |
253 |
271 |
254 __TIME_ENDMARK( "CAiStateManager::NotifyLoadPlugin, construction", time ); |
272 __TIME_ENDMARK( "CAiStateManager::NotifyLoadPlugin, construction", time ); |
255 |
273 |
256 return retval; |
274 return retval; |
284 |
302 |
285 __TIME_ENDMARK( "CAiStateManager::DestroyPlugin, done", time ); |
303 __TIME_ENDMARK( "CAiStateManager::DestroyPlugin, done", time ); |
286 } |
304 } |
287 |
305 |
288 // ---------------------------------------------------------------------------- |
306 // ---------------------------------------------------------------------------- |
289 // CAiStateManager::NotifyUpdatePlugins() |
307 // CAiStateManager::NotifyReloadPlugins() |
290 // |
308 // |
291 // ---------------------------------------------------------------------------- |
309 // ---------------------------------------------------------------------------- |
292 // |
310 // |
293 void CAiStateManager::NotifyUpdatePlugins() |
311 void CAiStateManager::NotifyReloadPlugins() |
294 { |
312 { |
295 __PRINTS( "CAiStateManager::NotifyUpdatePlugins" ); |
313 __PRINTS( "CAiStateManager::NotifyReloadPlugins" ); |
296 |
314 |
297 RArray< THsPublisherInfo > publishers; |
315 for ( TInt i = 0; i < iReloadPlugins.Count(); i++ ) |
298 |
316 { |
299 // Get plugins which has upgrade available |
317 // Reload plugin |
300 TRAP_IGNORE( iFactory.ResolvePluginsToUpgradeL( publishers ) ); |
318 NotifyLoadPlugin( iReloadPlugins[ i ], EAiFwSystemStartup ); |
301 |
319 } |
302 for ( TInt i = 0; i < publishers.Count(); i++ ) |
320 |
303 { |
321 __PRINTS( "CAiStateManager::NotifyReloadPlugins, done" ); |
304 THsPublisherInfo info( publishers[i] ); |
|
305 |
|
306 // Update by destroy - load sequence |
|
307 NotifyDestroyPlugin( info, EAiFwSystemShutdown ); |
|
308 NotifyLoadPlugin( info, EAiFwSystemStartup ); |
|
309 } |
|
310 |
|
311 publishers.Reset(); |
|
312 |
|
313 __PRINTS( "CAiStateManager::NotifyUpdatePlugins, done" ); |
|
314 } |
|
315 |
|
316 // ---------------------------------------------------------------------------- |
|
317 // CAiStateManager::OnlineStateInUse() |
|
318 // |
|
319 // ---------------------------------------------------------------------------- |
|
320 // |
|
321 TBool CAiStateManager::OnlineStateInUse() const |
|
322 { |
|
323 __PRINTS( "CAiStateManager::OnlineStateInUse" ); |
|
324 |
|
325 RPointerArray< CHsContentPublisher >& plugins( iFactory.Publishers() ); |
|
326 |
|
327 for( TInt i = 0; i < plugins.Count(); i++ ) |
|
328 { |
|
329 CHsContentPublisher* plugin( plugins[i] ); |
|
330 |
|
331 if ( plugin->HasMenuItem( KOnlineOffline() ) ) |
|
332 { |
|
333 return ETrue; |
|
334 } |
|
335 } |
|
336 |
|
337 return EFalse; |
|
338 } |
322 } |
339 |
323 |
340 // ---------------------------------------------------------------------------- |
324 // ---------------------------------------------------------------------------- |
341 // CAiStateManager::EvaluateNextState() |
325 // CAiStateManager::EvaluateNextState() |
342 // |
326 // |
590 |
595 |
591 // Do shutdown state transition |
596 // Do shutdown state transition |
592 StopPlugin( *plugin, CHsContentPublisher::ESystemShutdown ); |
597 StopPlugin( *plugin, CHsContentPublisher::ESystemShutdown ); |
593 } |
598 } |
594 |
599 |
|
600 FlushCommandBuffer(); |
|
601 |
595 // Finally get rid of all plugins |
602 // Finally get rid of all plugins |
596 plugins.ResetAndDestroy(); |
603 plugins.ResetAndDestroy(); |
597 |
604 |
598 __TIME_ENDMARK( "CAiStateManager::DestroyPlugins, done", time ); |
605 __TIME_ENDMARK( "CAiStateManager::DestroyPlugins, done", time ); |
599 } |
606 } |
600 |
607 |
|
608 // ---------------------------------------------------------------------------- |
|
609 // CAiStateManager::FlushCommandBuffer();() |
|
610 // |
|
611 // ---------------------------------------------------------------------------- |
|
612 // |
|
613 void CAiStateManager::FlushCommandBuffer() |
|
614 { |
|
615 __PRINTS( "CAiStateManager::FlushCommandBuffer, start" ); |
|
616 |
|
617 if ( iCommandBuffer ) |
|
618 { |
|
619 __TIME( "CAiStateManager::FlushCommandBuffer, flush", |
|
620 |
|
621 iCommandBuffer->Flush() ); |
|
622 } |
|
623 |
|
624 __PRINTS( "CAiStateManager::FlushCommandBuffer - done" ); |
|
625 } |
|
626 |
|
627 // ---------------------------------------------------------------------------- |
|
628 // CAiStateManager::NotifyReleasePlugins() |
|
629 // |
|
630 // ---------------------------------------------------------------------------- |
|
631 // |
|
632 void CAiStateManager::NotifyReleasePlugins( const RArray<TUid>& aUidList ) |
|
633 { |
|
634 __PRINTS( "CAiStateManager::NotifyReleasePlugins" ); |
|
635 |
|
636 iReloadPlugins.Reset(); |
|
637 |
|
638 for ( TInt i = 0; i < aUidList.Count(); i++ ) |
|
639 { |
|
640 CHsContentPublisher* plugin = iFactory.PluginByUid( aUidList[ i ] ); |
|
641 if ( plugin ) |
|
642 { |
|
643 StopPlugin( *plugin, CHsContentPublisher::ESystemShutdown ); |
|
644 THsPublisherInfo info = plugin->PublisherInfo(); |
|
645 iReloadPlugins.Append( info ); |
|
646 iFactory.DestroyPlugin( aUidList[ i ] ); |
|
647 } |
|
648 } |
|
649 __PRINTS( "CAiStateManager::NotifyReleasePlugins: return void" ); |
|
650 } |
|
651 |
|
652 // ---------------------------------------------------------------------------- |
|
653 // CAiStateManager::StartWaitDialogL() |
|
654 // |
|
655 // ---------------------------------------------------------------------------- |
|
656 // |
|
657 void CAiStateManager::StartWaitDialogL() |
|
658 { |
|
659 RConeResourceLoader resourceLoader( *CCoeEnv::Static() ); |
|
660 TFullName fileName( KResourceDrive ); |
|
661 fileName.Append( KResourcePath ); |
|
662 fileName.Append( KResourceFile ); |
|
663 |
|
664 // Get language of resource file. |
|
665 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), fileName ); |
|
666 |
|
667 // Open resource file. |
|
668 resourceLoader.OpenL( fileName ); |
|
669 |
|
670 if( iWaitDialog ) |
|
671 { |
|
672 delete iWaitDialog; |
|
673 iWaitDialog = NULL; |
|
674 } |
|
675 |
|
676 // For the wait dialog |
|
677 iWaitDialog = new (ELeave) CAknWaitDialog( |
|
678 REINTERPRET_CAST( CEikDialog**, &iWaitDialog ) ); |
|
679 iWaitDialog->SetCallback( this ); |
|
680 iWaitDialog->ExecuteLD( R_HOMESCREEN_WAIT_DIALOG ); |
|
681 resourceLoader.Close(); |
|
682 } |
|
683 |
|
684 // ---------------------------------------------------------------------------- |
|
685 // CAiStateManager::StopWaitDialogL() |
|
686 // |
|
687 // ---------------------------------------------------------------------------- |
|
688 // |
|
689 void CAiStateManager::StopWaitDialogL() |
|
690 { |
|
691 if( iWaitDialog ) |
|
692 { |
|
693 iWaitDialog->ProcessFinishedL(); |
|
694 } |
|
695 } |
|
696 |
|
697 // ---------------------------------------------------------------------------- |
|
698 // CAiStateManager::DialogDismissedL() |
|
699 // |
|
700 // ---------------------------------------------------------------------------- |
|
701 // |
|
702 void CAiStateManager::DialogDismissedL(TInt /*aButtonId*/) |
|
703 { |
|
704 // No implementation required. |
|
705 } |
|
706 |
601 // End of file |
707 // End of file |