homescreenpluginsrv/hspsmanager/src/hspsthemeserver.cpp
branchRCL_3
changeset 18 bd874ee5e5e2
parent 9 d0529222e3f0
child 19 502e5d91ad42
equal deleted inserted replaced
9:d0529222e3f0 18:bd874ee5e5e2
    17 
    17 
    18 
    18 
    19 #define __INCLUDE_CAPABILITY_NAMES__
    19 #define __INCLUDE_CAPABILITY_NAMES__
    20 
    20 
    21 // INCLUDE FILES
    21 // INCLUDE FILES
       
    22 #include <mw/memorymanager.h>
    22 #include <centralrepository.h>
    23 #include <centralrepository.h>
    23 #include <f32file.h>
    24 #include <f32file.h>
    24 #include <bautils.h>
    25 #include <bautils.h>
    25 #include <sbdefs.h>
    26 #include <sbdefs.h>
    26 #include <sysversioninfo.h>
    27 #include <sysversioninfo.h>
   177 // Server process entry-point
   178 // Server process entry-point
   178 // -----------------------------------------------------------------------------
   179 // -----------------------------------------------------------------------------
   179 //
   180 //
   180 TInt E32Main()
   181 TInt E32Main()
   181     {
   182     {
       
   183     RAllocator* iAllocator = MemoryManager::SwitchToFastAllocator();
       
   184     
   182     __UHEAP_MARK;
   185     __UHEAP_MARK;
   183     CTrapCleanup* cleanup=CTrapCleanup::New();
   186     CTrapCleanup* cleanup=CTrapCleanup::New();
   184     TInt r=KErrNoMemory;
   187     TInt r=KErrNoMemory;
   185     if (cleanup)
   188     if (cleanup)
   186         {
   189         {
   187         TRAP(r,RunServerL());
   190         TRAP(r,RunServerL());
   188         delete cleanup;
   191         delete cleanup;
   189         }
   192         }
   190     __UHEAP_MARKEND;
   193     __UHEAP_MARKEND;
       
   194     
       
   195     MemoryManager::CloseFastAllocator(iAllocator);
       
   196     
   191     return r;
   197     return r;
   192     }
   198     }
   193     
   199     
   194 // ======== MEMBER FUNCTIONS ========
   200 // ======== MEMBER FUNCTIONS ========
   195 
   201 
   396     // Delete log bus as absolute last!
   402     // Delete log bus as absolute last!
   397     // Some members might log destructor activity to this object.
   403     // Some members might log destructor activity to this object.
   398     delete iLogBus;
   404     delete iLogBus;
   399     iLogBus = NULL;
   405     iLogBus = NULL;
   400 #endif    
   406 #endif    
       
   407     
       
   408     iSessions.Reset();
   401     }
   409     }
   402 
   410 
   403 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
   411 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
   404 // -----------------------------------------------------------------------------
   412 // -----------------------------------------------------------------------------
   405 // ChspsThemeServer::ShutdownInitiating
   413 // ChspsThemeServer::ShutdownInitiating
   487 // ChspsThemeServer::AddSession
   495 // ChspsThemeServer::AddSession
   488 // A new session is being created
   496 // A new session is being created
   489 // (other items were commented in a header).
   497 // (other items were commented in a header).
   490 // -----------------------------------------------------------------------------
   498 // -----------------------------------------------------------------------------
   491 //
   499 //
   492 void ChspsThemeServer::AddSession()
   500 void ChspsThemeServer::AddSession( ChspsThemeServerSession* aSession )
   493     {
   501     {
   494     iSessionCount++;
   502     if( aSession == NULL )
       
   503         {
       
   504         return;
       
   505         }
       
   506     
       
   507     iSessions.Append( aSession );    
   495 
   508 
   496 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_    
   509 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_    
   497     if( iShutdown->IsActive() )
   510     if( iShutdown->IsActive() )
   498         {
   511         {
   499         iShutdown->Cancel();
   512         iShutdown->Cancel();
   511 // ChspsThemeServer::DropSession
   524 // ChspsThemeServer::DropSession
   512 // A session is being destroyed
   525 // A session is being destroyed
   513 // (other items were commented in a header).
   526 // (other items were commented in a header).
   514 // -----------------------------------------------------------------------------
   527 // -----------------------------------------------------------------------------
   515 //
   528 //
   516 void ChspsThemeServer::DropSession()
   529 void ChspsThemeServer::DropSession( ChspsThemeServerSession* aSession )
   517     {
   530     {
   518     iSessionCount--;
   531     const TInt index = iSessions.Find( aSession );
       
   532     if( index != KErrNotFound )
       
   533         {
       
   534         iSessions.Remove( index );
       
   535         }
   519     
   536     
   520 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_    
   537 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_    
   521     if( iSessionCount == 0 )
   538     if( iSessions.Count() == 0 )
   522         {
   539         {
   523         iShutdown->Cancel();
   540         iShutdown->Cancel();
   524         iShutdown->Start();
   541         iShutdown->Start();
   525         }
   542         }
   526 #endif // _hsps_SERVER_SHUTDOWN_ENABLED_
   543 #endif // _hsps_SERVER_SHUTDOWN_ENABLED_
   575     TBool ret = EFalse;
   592     TBool ret = EFalse;
   576 
   593 
   577 #ifdef HSPS_LOG_ACTIVE
   594 #ifdef HSPS_LOG_ACTIVE
   578     iLogBus->LogText( _L( "--------------------------------------------------------" ) );
   595     iLogBus->LogText( _L( "--------------------------------------------------------" ) );
   579 #endif        
   596 #endif        
   580             
   597 
       
   598     if( aRepositoryInfo.iEventType & EhspsODTUpdated ||
       
   599         aRepositoryInfo.iEventType & EhspsODTModified ||
       
   600         aRepositoryInfo.iEventType & EhspsPluginReplaced )
       
   601         {
       
   602         for( TInt i = 0; i < iSessions.Count(); i++ )
       
   603             {
       
   604             if( iSessions[i]->AppUid() == aRepositoryInfo.iAppUid )
       
   605                 {
       
   606                 iSessions[i]->SetResourceFileCopyRequired( ETrue );
       
   607                 }
       
   608             }        
       
   609         }    
       
   610     
   581     // If header cache should be updated from files in the Plug-in Repository
   611     // If header cache should be updated from files in the Plug-in Repository
   582     if (mask & EhspsCacheUpdate)
   612     if (mask & EhspsCacheUpdate)
   583         {
   613         {
   584 #ifdef HSPS_LOG_ACTIVE        
   614 #ifdef HSPS_LOG_ACTIVE        
   585         iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsCacheUpdate occurred." ) );
   615         iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsCacheUpdate occurred." ) );
  3369 
  3399 
  3370         if ( err != KErrNone )        
  3400         if ( err != KErrNone )        
  3371             {
  3401             {
  3372             // Invalid configuration
  3402             // Invalid configuration
  3373             state.Set( KConfStateError );
  3403             state.Set( KConfStateError );
       
  3404             // Delete related resource files
       
  3405             const TInt count = aOdt.ResourceCount();
       
  3406             for( TInt j( 0 ); j < count; j++ )
       
  3407                 {
       
  3408                 ChspsResource& resource = aOdt.ResourceL( j );
       
  3409                 if( resource.ConfigurationUid() == uids[ i ] )
       
  3410                     {
       
  3411                     aOdt.DeleteResourceL( j );
       
  3412                     }
       
  3413                 }
  3374             }
  3414             }
  3375         else if ( state.CompareF( KConfStateError ) != 0 )
  3415         else if ( state.CompareF( KConfStateError ) != 0 )
  3376             {
  3416             {
  3377             state.Set( KConfStateNotConfirmed );
  3417             state.Set( KConfStateNotConfirmed );
  3378             }
  3418             }