diff -r 502e5d91ad42 -r 15e4dd19031c idlefw/src/framework/aistatemanager.cpp --- a/idlefw/src/framework/aistatemanager.cpp Mon Mar 15 12:41:53 2010 +0200 +++ b/idlefw/src/framework/aistatemanager.cpp Wed Mar 31 22:04:35 2010 +0300 @@ -20,15 +20,21 @@ // User includes #include #include +#include +#include +#include +#include +#include "caicpscommandbuffer.h" #include "aipluginfactory.h" #include "aistatemanager.h" -#include "debug.h" +#include -// Constants -_LIT( KOnlineOffline, "online_offline" ); +_LIT( KResourceDrive, "Z:" ); +_LIT( KResourceFile, "homescreen.rsc" ); +_LIT( KResourcePath, "\\resource\\apps\\" ); // ======== LOCAL FUNCTIONS ======== // ---------------------------------------------------------------------------- @@ -114,6 +120,12 @@ // CAiStateManager::~CAiStateManager() { + if( iWaitDialog ) + { + delete iWaitDialog; + } + delete iCommandBuffer; + iReloadPlugins.Close(); } // ---------------------------------------------------------------------------- @@ -133,6 +145,9 @@ // void CAiStateManager::ConstructL() { + iCommandBuffer = CAiCpsCommandBuffer::NewL(); + + iFactory.SetCommandBuffer( iCommandBuffer ); } // ---------------------------------------------------------------------------- @@ -246,9 +261,12 @@ if ( retval == KErrNone ) { CHsContentPublisher* plugin( iFactory.PluginByInfo( aPublisherInfo ) ); - - // Do startup state transition - StartPlugin( *plugin, StartReason( aReason ) ); + + if( plugin ) + { + // Do startup state transition + StartPlugin( *plugin, StartReason( aReason ) ); + } } __TIME_ENDMARK( "CAiStateManager::NotifyLoadPlugin, construction", time ); @@ -286,55 +304,21 @@ } // ---------------------------------------------------------------------------- -// CAiStateManager::NotifyUpdatePlugins() +// CAiStateManager::NotifyReloadPlugins() // // ---------------------------------------------------------------------------- // -void CAiStateManager::NotifyUpdatePlugins() +void CAiStateManager::NotifyReloadPlugins() { - __PRINTS( "CAiStateManager::NotifyUpdatePlugins" ); - - RArray< THsPublisherInfo > publishers; - - // Get plugins which has upgrade available - TRAP_IGNORE( iFactory.ResolvePluginsToUpgradeL( publishers ) ); - - for ( TInt i = 0; i < publishers.Count(); i++ ) - { - THsPublisherInfo info( publishers[i] ); - - // Update by destroy - load sequence - NotifyDestroyPlugin( info, EAiFwSystemShutdown ); - NotifyLoadPlugin( info, EAiFwSystemStartup ); + __PRINTS( "CAiStateManager::NotifyReloadPlugins" ); + + for ( TInt i = 0; i < iReloadPlugins.Count(); i++ ) + { + // Reload plugin + NotifyLoadPlugin( iReloadPlugins[ i ], EAiFwSystemStartup ); } - publishers.Reset(); - - __PRINTS( "CAiStateManager::NotifyUpdatePlugins, done" ); - } - -// ---------------------------------------------------------------------------- -// CAiStateManager::OnlineStateInUse() -// -// ---------------------------------------------------------------------------- -// -TBool CAiStateManager::OnlineStateInUse() const - { - __PRINTS( "CAiStateManager::OnlineStateInUse" ); - - RPointerArray< CHsContentPublisher >& plugins( iFactory.Publishers() ); - - for( TInt i = 0; i < plugins.Count(); i++ ) - { - CHsContentPublisher* plugin( plugins[i] ); - - if ( plugin->HasMenuItem( KOnlineOffline() ) ) - { - return ETrue; - } - } - - return EFalse; + __PRINTS( "CAiStateManager::NotifyReloadPlugins, done" ); } // ---------------------------------------------------------------------------- @@ -405,6 +389,8 @@ plugin->Suspend( CHsContentPublisher::EBackground ) ); } } + + FlushCommandBuffer(); } else { @@ -439,6 +425,8 @@ } } + FlushCommandBuffer(); + __TIME_ENDMARK( "CAiStateManager::ProcessGeneralThemeChange, done", time ); } @@ -454,6 +442,15 @@ iHalt = aStart; + if ( aStart ) + { + TRAP_IGNORE( StartWaitDialogL() ); + } + else + { + TRAP_IGNORE( StopWaitDialogL() ); + } + RPointerArray< CHsContentPublisher >& plugins( iFactory.Publishers() ); for( TInt i = 0; i < plugins.Count(); i++ ) @@ -473,6 +470,8 @@ } } } + + FlushCommandBuffer(); __TIME_ENDMARK( "CAiStateManager::ProcessBackupRestore, done", time ); } @@ -501,6 +500,8 @@ plugin->SetOffline(); } } + + FlushCommandBuffer(); } // ---------------------------------------------------------------------------- @@ -544,6 +545,8 @@ aPlugin.SetOffline() ); } + FlushCommandBuffer(); + __PRINTS( "CAiStateManager::StartPlugin - done" ); } @@ -569,6 +572,8 @@ aPlugin.Stop( aReason ); + FlushCommandBuffer(); + __PRINTS( "CAiStateManager::StopPlugin - done" ); } @@ -592,10 +597,111 @@ StopPlugin( *plugin, CHsContentPublisher::ESystemShutdown ); } + FlushCommandBuffer(); + // Finally get rid of all plugins plugins.ResetAndDestroy(); __TIME_ENDMARK( "CAiStateManager::DestroyPlugins, done", time ); } +// ---------------------------------------------------------------------------- +// CAiStateManager::FlushCommandBuffer();() +// +// ---------------------------------------------------------------------------- +// +void CAiStateManager::FlushCommandBuffer() + { + __PRINTS( "CAiStateManager::FlushCommandBuffer, start" ); + + if ( iCommandBuffer ) + { + __TIME( "CAiStateManager::FlushCommandBuffer, flush", + + iCommandBuffer->Flush() ); + } + + __PRINTS( "CAiStateManager::FlushCommandBuffer - done" ); + } + +// ---------------------------------------------------------------------------- +// CAiStateManager::NotifyReleasePlugins() +// +// ---------------------------------------------------------------------------- +// +void CAiStateManager::NotifyReleasePlugins( const RArray& aUidList ) + { + __PRINTS( "CAiStateManager::NotifyReleasePlugins" ); + + iReloadPlugins.Reset(); + + for ( TInt i = 0; i < aUidList.Count(); i++ ) + { + CHsContentPublisher* plugin = iFactory.PluginByUid( aUidList[ i ] ); + if ( plugin ) + { + StopPlugin( *plugin, CHsContentPublisher::ESystemShutdown ); + THsPublisherInfo info = plugin->PublisherInfo(); + iReloadPlugins.Append( info ); + iFactory.DestroyPlugin( aUidList[ i ] ); + } + } + __PRINTS( "CAiStateManager::NotifyReleasePlugins: return void" ); + } + +// ---------------------------------------------------------------------------- +// CAiStateManager::StartWaitDialogL() +// +// ---------------------------------------------------------------------------- +// +void CAiStateManager::StartWaitDialogL() + { + RConeResourceLoader resourceLoader( *CCoeEnv::Static() ); + TFullName fileName( KResourceDrive ); + fileName.Append( KResourcePath ); + fileName.Append( KResourceFile ); + + // Get language of resource file. + BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), fileName ); + + // Open resource file. + resourceLoader.OpenL( fileName ); + + if( iWaitDialog ) + { + delete iWaitDialog; + iWaitDialog = NULL; + } + + // For the wait dialog + iWaitDialog = new (ELeave) CAknWaitDialog( + REINTERPRET_CAST( CEikDialog**, &iWaitDialog ) ); + iWaitDialog->SetCallback( this ); + iWaitDialog->ExecuteLD( R_HOMESCREEN_WAIT_DIALOG ); + resourceLoader.Close(); + } + +// ---------------------------------------------------------------------------- +// CAiStateManager::StopWaitDialogL() +// +// ---------------------------------------------------------------------------- +// +void CAiStateManager::StopWaitDialogL() + { + if( iWaitDialog ) + { + iWaitDialog->ProcessFinishedL(); + } + } + +// ---------------------------------------------------------------------------- +// CAiStateManager::DialogDismissedL() +// +// ---------------------------------------------------------------------------- +// +void CAiStateManager::DialogDismissedL(TInt /*aButtonId*/) + { + // No implementation required. + } + // End of file