homescreenpluginsrv/hspsmanager/src/hspsmaintenancehandler.cpp
branchRCL_3
changeset 27 2c7f27287390
parent 25 9e077f9a342c
equal deleted inserted replaced
25:9e077f9a342c 27:2c7f27287390
  1889                 instanceCount );                                                        
  1889                 instanceCount );                                                        
  1890                 
  1890                 
  1891             // Remove plugin resources from the application configuration:
  1891             // Remove plugin resources from the application configuration:
  1892             // By default remove all plugin's resources from all instances
  1892             // By default remove all plugin's resources from all instances
  1893             // - otherwise, after upgrades, there might be various versions of the same resources
  1893             // - otherwise, after upgrades, there might be various versions of the same resources
  1894             err = RemovePluginResourcesL( aAppODT, pluginUid );
  1894             err = hspsServerUtil::RemovePluginResourcesL( aAppODT, pluginUid );
  1895             if ( !err )
  1895             if ( !err )
  1896                 {
  1896                 {
  1897                 // If the application configuration holds other instances of the same plugin                     
  1897                 // If the application configuration holds other instances of the same plugin                     
  1898                 if ( instanceCount > 1 )
  1898                 if ( instanceCount > 1 )
  1899                     {
  1899                     {
  2013         node = iter->NextL();        
  2013         node = iter->NextL();        
  2014         }
  2014         }
  2015     CleanupStack::PopAndDestroy( iter );    
  2015     CleanupStack::PopAndDestroy( iter );    
  2016     }
  2016     }
  2017 
  2017 
  2018 // -----------------------------------------------------------------------------
  2018 
  2019 // Removes plugin resources from the provided ODT
       
  2020 // -----------------------------------------------------------------------------
       
  2021 //
       
  2022 TInt ChspsMaintenanceHandler::RemovePluginResourcesL(
       
  2023         ChspsODT& aAppODT,
       
  2024         const TInt aPluginUid )        
       
  2025     {            
       
  2026     // Loop resources of the application configuration            
       
  2027     for(TInt aresIndex = 0; aresIndex < aAppODT.ResourceCount(); aresIndex++ )
       
  2028         {
       
  2029         ChspsResource& ares = aAppODT.ResourceL( aresIndex );
       
  2030                                 
       
  2031         // If the plugin resource was found at  resource list of the application configuration                        
       
  2032         if ( ares.ConfigurationUid() == aPluginUid )
       
  2033             {
       
  2034             // Deletes resource from the application configuration
       
  2035             aAppODT.DeleteResourceL( aresIndex );
       
  2036             aresIndex--;
       
  2037             }
       
  2038         
       
  2039         }                
       
  2040     
       
  2041     return KErrNone;
       
  2042     }
       
  2043 
  2019 
  2044 // -----------------------------------------------------------------------------
  2020 // -----------------------------------------------------------------------------
  2045 // Adds plugin resources to the provided application ODT
  2021 // Adds plugin resources to the provided application ODT
  2046 // -----------------------------------------------------------------------------
  2022 // -----------------------------------------------------------------------------
  2047 //
  2023 //
  2781     
  2757     
  2782     // Get service parameters from IPC slot #1
  2758     // Get service parameters from IPC slot #1
  2783     ThspsParamRestoreActiveAppConf params;        
  2759     ThspsParamRestoreActiveAppConf params;        
  2784     TPckg<ThspsParamRestoreActiveAppConf> packagedStruct( params );    
  2760     TPckg<ThspsParamRestoreActiveAppConf> packagedStruct( params );    
  2785     aMessage.ReadL( 1, packagedStruct );                      
  2761     aMessage.ReadL( 1, packagedStruct );                      
       
  2762             
       
  2763     // Get active root configuration for the application
       
  2764     TInt confUid = 0;
       
  2765     User::LeaveIfError( 
       
  2766             iCentralRepository.Get( params.appUid, confUid ) 
       
  2767             );
  2786     
  2768     
  2787     // Create search criteria
  2769     // Create search criteria
  2788     ChspsODT* searchMask = ChspsODT::NewL();
  2770     ChspsODT* searchMask = ChspsODT::NewL();
  2789     CleanupStack::PushL( searchMask );
  2771     CleanupStack::PushL( searchMask );
  2790     searchMask->SetRootUid( params.appUid );
  2772     searchMask->SetRootUid( params.appUid );
  2791     searchMask->SetThemeUid( params.confUid );
  2773     searchMask->SetThemeUid( confUid );
  2792 
  2774 
  2793     // Get configuration header
  2775     // Get configuration header
  2794     ChspsODT* confHeader( NULL );
  2776     ChspsODT* confHeader( NULL );
  2795     TInt pos( 0 );
  2777     TInt pos( 0 );
  2796     iThemeServer.GetConfigurationHeader( *searchMask, confHeader, pos );
  2778     iThemeServer.GetConfigurationHeader( *searchMask, confHeader, pos );
  3467         }
  3449         }
  3468     
  3450     
  3469     if ( processedCount )
  3451     if ( processedCount )
  3470         {
  3452         {
  3471         // Remove uninstalled resources from the server (copies will remain in client's private directory)
  3453         // Remove uninstalled resources from the server (copies will remain in client's private directory)
  3472         RemovePluginResourcesL( aAppODT, aPluginUid );
  3454         hspsServerUtil::RemovePluginResourcesL( aAppODT, aPluginUid );
  3473         
  3455         
  3474         // Store changes
  3456         // Store changes
  3475         User::LeaveIfError( iDefinitionRepository.SetOdtL( aAppODT ) );
  3457         User::LeaveIfError( iDefinitionRepository.SetOdtL( aAppODT ) );
  3476         }       
  3458         }       
  3477     
  3459     
  3658         RArray<TInt>& aPluginIds )
  3640         RArray<TInt>& aPluginIds )
  3659     {
  3641     {
  3660     TInt err(KErrNone);
  3642     TInt err(KErrNone);
  3661     
  3643     
  3662     // remove old resources
  3644     // remove old resources
  3663     err = RemovePluginResourcesL( aOdt, aPluginOdt.ThemeUid() );
  3645     err = hspsServerUtil::RemovePluginResourcesL( aOdt, aPluginOdt.ThemeUid() );
  3664     
  3646     
  3665     if( err )
  3647     if( err )
  3666         {
  3648         {
  3667         return err;
  3649         return err;
  3668         }
  3650         }
  3842 // ChspsMaintenanceHandler::hspsRestoreActiveAppConf()
  3824 // ChspsMaintenanceHandler::hspsRestoreActiveAppConf()
  3843 // Not supported - inherited from an interface and not used.
  3825 // Not supported - inherited from an interface and not used.
  3844 // -----------------------------------------------------------------------------
  3826 // -----------------------------------------------------------------------------
  3845 //
  3827 //
  3846 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsRestoreActiveAppConf(
  3828 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsRestoreActiveAppConf(
  3847     const TInt /*aAppUid*/,
  3829     const TInt /*aAppUid*/ )
  3848     const TInt /*aConfUid*/ )
       
  3849     {
  3830     {
  3850     return EhspsServiceNotSupported;
  3831     return EhspsServiceNotSupported;
  3851     }
  3832     }
  3852 
  3833 
  3853 // -----------------------------------------------------------------------------
  3834 // -----------------------------------------------------------------------------
  4520 // -----------------------------------------------------------------------------
  4501 // -----------------------------------------------------------------------------
  4521 //
  4502 //
  4522 void ChspsMaintenanceHandler::RestoreDefaultAppConfL(
  4503 void ChspsMaintenanceHandler::RestoreDefaultAppConfL(
  4523     ChspsODT*& aHeader,
  4504     ChspsODT*& aHeader,
  4524     ChspsODT& aOdt)
  4505     ChspsODT& aOdt)
  4525     {
  4506     {    
  4526     
  4507     // If active application configuration is not "LicenceeRestorable" 
  4527     // If active application configuration is LicenceeRestorable 
  4508     if ( !(aHeader->Flags() & EhspsThemeStatusLicenceeRestorable) )
  4528     if ( aHeader->Flags() & EhspsThemeStatusLicenceeRestorable )
  4509         {        
  4529         {
       
  4530         // Reinstall the configuration from ROM
       
  4531         iThemeServer.ReinstallConfL( aHeader->RootUid(), aHeader->ThemeUid() );
       
  4532         }
       
  4533     else
       
  4534         {
       
  4535         // Try to activate a configuation with the LicenceeRestorable status
  4510         // Try to activate a configuation with the LicenceeRestorable status
  4536         ChspsODT* searchMask = ChspsODT::NewL();
  4511         ChspsODT* searchMask = ChspsODT::NewL();
  4537         CleanupStack::PushL( searchMask );
  4512         CleanupStack::PushL( searchMask );
  4538         searchMask->SetRootUid( aHeader->RootUid() );
  4513         searchMask->SetRootUid( aHeader->RootUid() );
       
  4514         searchMask->SetFamily( aHeader->Family() );
  4539         searchMask->SetFlags( EhspsThemeStatusLicenceeRestorable );
  4515         searchMask->SetFlags( EhspsThemeStatusLicenceeRestorable );
  4540         TInt pos( 0 );
  4516         TInt pos( 0 );
  4541         iThemeServer.GetConfigurationHeader( *searchMask, aHeader, pos );
  4517         iThemeServer.GetConfigurationHeader( *searchMask, aHeader, pos );
  4542         if ( aHeader )
  4518         if ( aHeader )
  4543             {
  4519             {
  4546             ThspsRepositoryInfo info( EhspsODTActivated );
  4522             ThspsRepositoryInfo info( EhspsODTActivated );
  4547             iDefinitionRepository.RegisterNotification( info );
  4523             iDefinitionRepository.RegisterNotification( info );
  4548             }
  4524             }
  4549         else
  4525         else
  4550             {
  4526             {
  4551             // Licensee restorable configuration not found
  4527             // Licensee restorable configuration not found. There must be  
  4552             // There must be at least one licensee restorable configuration
  4528             // at least one licensee restorable configuration per application
  4553             User::Leave( KErrNotFound );
  4529             User::Leave( KErrNotFound );
  4554             }
  4530             }
  4555         CleanupStack::PopAndDestroy( searchMask );
  4531         CleanupStack::PopAndDestroy( searchMask );
  4556         }    
  4532         }
       
  4533     else
       
  4534         {        
       
  4535         // Reinstall the application configuration from ROM
       
  4536         iThemeServer.ReinstallConfL( aHeader->RootUid(), aHeader->ThemeUid() );
       
  4537         }
  4557     }
  4538     }
  4558 
  4539 
  4559 // -----------------------------------------------------------------------------
  4540 // -----------------------------------------------------------------------------
  4560 // ChspsMaintenanceHandler::AddErrorConfigurationL()
  4541 // ChspsMaintenanceHandler::AddErrorConfigurationL()
  4561 // -----------------------------------------------------------------------------
  4542 // -----------------------------------------------------------------------------
  4735 // ChspsMaintenanceHandler::HandleReinstallationL
  4716 // ChspsMaintenanceHandler::HandleReinstallationL
  4736 // -----------------------------------------------------------------------------
  4717 // -----------------------------------------------------------------------------
  4737 //
  4718 //
  4738 void ChspsMaintenanceHandler::HandleReinstallationL(
  4719 void ChspsMaintenanceHandler::HandleReinstallationL(
  4739         const TBool aInstallUdaEmmc ) 
  4720         const TBool aInstallUdaEmmc ) 
  4740     {
  4721     {       
  4741     // Install plug-in configurations from the "install" directories
  4722     // Install plug-in configurations from the "install" directories
  4742     iThemeServer.InstallWidgetsL( aInstallUdaEmmc );
  4723     iThemeServer.InstallWidgetsL( aInstallUdaEmmc );
  4743     if( aInstallUdaEmmc )
       
  4744         {
       
  4745         // Install plug-in configurations from the "import" directories in C 
       
  4746         // and emmc(if exists)
       
  4747         iThemeServer.InstallUDAWidgetsL( KImportDirectoryC );
       
  4748 
       
  4749         TInt drive = hspsServerUtil::GetEmmcDrivePath( 
       
  4750                 iServerSession->FileSystem() );
       
  4751         if ( drive != KErrNotFound )
       
  4752             {
       
  4753             TDriveUnit unit(drive);
       
  4754             HBufC* importDirectoryE = HBufC::NewLC( 
       
  4755                     KImportDirectory().Length() + unit.Name().Length() ); 
       
  4756             importDirectoryE->Des().Append( unit.Name() );
       
  4757             importDirectoryE->Des().Append( KImportDirectory );
       
  4758             
       
  4759             iThemeServer.InstallUDAWidgetsL( *importDirectoryE );
       
  4760             CleanupStack::PopAndDestroy( importDirectoryE );
       
  4761             }
       
  4762         }
       
  4763     
  4724     
  4764     // Force updating of the header cache
  4725     // Force updating of the header cache
  4765     iThemeServer.UpdateHeaderListCacheL();   
  4726     iThemeServer.UpdateHeaderListCacheL();   
  4766     }                    
  4727     }                    
  4767     
  4728