diff -r c2817bb2a55c -r cb506ec2d869 idlefw/src/framework/aistatemanager.cpp --- a/idlefw/src/framework/aistatemanager.cpp Wed Mar 31 13:30:40 2010 +0300 +++ b/idlefw/src/framework/aistatemanager.cpp Wed May 12 13:35:37 2010 +0300 @@ -20,16 +20,16 @@ // User includes #include #include +#include +#include +#include +#include +#include "caicpscommandbuffer.h" #include "aipluginfactory.h" #include "aistatemanager.h" -#include "debug.h" - -// Constants -_LIT( KOnlineOffline, "online_offline" ); - // ======== LOCAL FUNCTIONS ======== // ---------------------------------------------------------------------------- // StartReason @@ -114,6 +114,8 @@ // CAiStateManager::~CAiStateManager() { + delete iCommandBuffer; + iReloadPlugins.Close(); } // ---------------------------------------------------------------------------- @@ -133,6 +135,9 @@ // void CAiStateManager::ConstructL() { + iCommandBuffer = CAiCpsCommandBuffer::NewL(); + + iFactory.SetCommandBuffer( iCommandBuffer ); } // ---------------------------------------------------------------------------- @@ -246,9 +251,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 +294,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 +379,8 @@ plugin->Suspend( CHsContentPublisher::EBackground ) ); } } + + FlushCommandBuffer(); } else { @@ -439,6 +415,8 @@ } } + FlushCommandBuffer(); + __TIME_ENDMARK( "CAiStateManager::ProcessGeneralThemeChange, done", time ); } @@ -473,6 +451,8 @@ } } } + + FlushCommandBuffer(); __TIME_ENDMARK( "CAiStateManager::ProcessBackupRestore, done", time ); } @@ -501,6 +481,8 @@ plugin->SetOffline(); } } + + FlushCommandBuffer(); } // ---------------------------------------------------------------------------- @@ -544,6 +526,8 @@ aPlugin.SetOffline() ); } + FlushCommandBuffer(); + __PRINTS( "CAiStateManager::StartPlugin - done" ); } @@ -569,6 +553,8 @@ aPlugin.Stop( aReason ); + FlushCommandBuffer(); + __PRINTS( "CAiStateManager::StopPlugin - done" ); } @@ -592,10 +578,56 @@ 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" ); + } + // End of file