homescreenpluginsrv/hspsmanager/src/hspsthemeserver.cpp
branchRCL_3
changeset 12 502e5d91ad42
parent 11 bd874ee5e5e2
child 14 15e4dd19031c
equal deleted inserted replaced
11:bd874ee5e5e2 12:502e5d91ad42
    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 <mw/MemoryManager.h>
    23 #include <centralrepository.h>
    23 #include <centralrepository.h>
    24 #include <f32file.h>
    24 #include <f32file.h>
    25 #include <bautils.h>
    25 #include <bautils.h>
    26 #include <sbdefs.h>
    26 #include <sbdefs.h>
    27 #include <sysversioninfo.h>
    27 #include <sysversioninfo.h>
  2267 TBool ChspsThemeServer::LocalizeL( 
  2267 TBool ChspsThemeServer::LocalizeL( 
  2268 		ChspsDefinitionEngineInterface& aEngine,
  2268 		ChspsDefinitionEngineInterface& aEngine,
  2269 		ChspsODT& aOdt )
  2269 		ChspsODT& aOdt )
  2270 	{		  			
  2270 	{		  			
  2271 	TBool localized = ETrue;
  2271 	TBool localized = ETrue;
       
  2272 	iFsSession.SetSessionToPrivate( EDriveC );
  2272 	
  2273 	
  2273 	TLanguage requestedLanguage = DeviceLanguage();
  2274 	TLanguage requestedLanguage = DeviceLanguage();
  2274 	if ( requestedLanguage == ELangNone )
  2275 	if ( requestedLanguage == ELangNone )
  2275 	    {
  2276 	    {
  2276 	    requestedLanguage = ELangTest;
  2277 	    requestedLanguage = ELangTest;
  2633                     udaName, 
  2634                     udaName, 
  2634                     KImportDirectoryC );
  2635                     KImportDirectoryC );
  2635             
  2636             
  2636             //install
  2637             //install
  2637             TRAPD( err, installer->InstallConfigurationL( *manifestBuf ) );
  2638             TRAPD( err, installer->InstallConfigurationL( *manifestBuf ) );
  2638 #ifdef HSPS_LOG_ACTIVE            
       
  2639             if ( err != KErrNone )
  2639             if ( err != KErrNone )
  2640                 {
  2640                 {
  2641                 iLogBus->LogText( _L( "ChspsThemeServer::InstallUDAWidgetsL(): - Installation failed" ) );
  2641 #ifdef HSPS_LOG_ACTIVE                            
       
  2642                 iLogBus->LogText( _L( "ChspsThemeServer::InstallUDAWidgetsL(): - Installation failed" ) );                
       
  2643 #endif
  2642                 }
  2644                 }
  2643 #endif
       
  2644             CleanupStack::PopAndDestroy( manifestBuf );
  2645             CleanupStack::PopAndDestroy( manifestBuf );
  2645             }
  2646             }
  2646         CleanupStack::PopAndDestroy( installer );
  2647         CleanupStack::PopAndDestroy( installer );
  2647         }
  2648         }
  2648     CleanupStack::PopAndDestroy( importDir ); 
  2649     CleanupStack::PopAndDestroy( importDir ); 
  2679     TBuf<KSysUtilVersionTextLength> fwVersion;
  2680     TBuf<KSysUtilVersionTextLength> fwVersion;
  2680     TInt errorCode = iCentralRepository->Get( key, fwVersion );
  2681     TInt errorCode = iCentralRepository->Get( key, fwVersion );
  2681     if( ( errorCode == KErrNone ) &&
  2682     if( ( errorCode == KErrNone ) &&
  2682         ( fwVersion.Length() == 0 ) )
  2683         ( fwVersion.Length() == 0 ) )
  2683         {
  2684         {
  2684         // Install manifest files from ROM
  2685         // Install widgets from \private\200159C0\install\ directories (ROM and UDA image)
  2685         InstallManifestsFromRomDriveL();
  2686         InstallWidgetsL();
  2686 
  2687 
  2687         // install widgets from UDA image
  2688         // Install widgets from \private\200159C0\imports\ directory (UDA image)
  2688         InstallUDAWidgetsL();
  2689         InstallUDAWidgetsL();
  2689         
  2690         
  2690         // Post RFS installations have been done, prevent re-installations at next startup
  2691         // Post RFS installations have been done, prevent re-installations at next startup
  2691         // by reading firmware version and saving it to cenrep.
  2692         // by reading firmware version and saving it to cenrep.
  2692         GetFWVersion( fwVersion );
  2693         GetFWVersion( fwVersion );
  2717         GetFWVersion( currentFWVersion );        
  2718         GetFWVersion( currentFWVersion );        
  2718         if ( fwVersion != currentFWVersion )
  2719         if ( fwVersion != currentFWVersion )
  2719             {
  2720             {
  2720             // Phone software has been updated.
  2721             // Phone software has been updated.
  2721             CreateBackupDataL();
  2722             CreateBackupDataL();
  2722             InstallManifestsFromRomDriveL();
  2723             InstallWidgetsL();
  2723             RestoreApplicationConfigurationsL();
  2724             RestoreApplicationConfigurationsL();
  2724             // Save new firmware version to cenrep
  2725             // Save new firmware version to cenrep
  2725             if ( errorCode == KErrNone )
  2726             if ( errorCode == KErrNone )
  2726                 {
  2727                 {
  2727                 errorCode = iCentralRepository->Set( key, currentFWVersion );                
  2728                 errorCode = iCentralRepository->Set( key, currentFWVersion );                
  2760     res.Close();    
  2761     res.Close();    
  2761     CleanupStack::PopAndDestroy(1, &res); 
  2762     CleanupStack::PopAndDestroy(1, &res); 
  2762     }
  2763     }
  2763 
  2764 
  2764 // -----------------------------------------------------------------------------
  2765 // -----------------------------------------------------------------------------
  2765 // ChspsThemeServer::InstallManifestsFromRomDriveL()
  2766 // ChspsThemeServer::InstallWidgetsL()
  2766 // -----------------------------------------------------------------------------
  2767 // -----------------------------------------------------------------------------
  2767 //
  2768 //
  2768 void ChspsThemeServer::InstallManifestsFromRomDriveL()
  2769 void ChspsThemeServer::InstallWidgetsL()
  2769 	{							
  2770     {    
  2770 	if ( iRomInstaller || iManifestFiles.Count() )
  2771     __ASSERT_DEBUG( !iRomInstaller, User::Leave( KErrGeneral) );	
  2771 	    {
       
  2772 	    // Invalid usage
       
  2773 	    User::Leave( KErrGeneral );
       
  2774 	    }	
       
  2775 	iRomInstaller = ChspsRomInstaller::NewL( *this, iFsSession );	
  2772 	iRomInstaller = ChspsRomInstaller::NewL( *this, iFsSession );	
  2776 #ifdef HSPS_LOG_ACTIVE            	
  2773 #ifdef HSPS_LOG_ACTIVE            	
  2777 	iRomInstaller->SetLogBus( iLogBus );
  2774 	iRomInstaller->SetLogBus( iLogBus );
  2778 #endif
  2775 #endif
  2779 	
  2776 		
  2780 	// An array for installation files with V2 directory structure
       
  2781 	RPointerArray<HBufC> pluginFolders;
  2777 	RPointerArray<HBufC> pluginFolders;
  2782     CleanupClosePushL( pluginFolders );				
  2778     CleanupClosePushL( pluginFolders );				
  2783 	        
  2779 	        
  2784     // Retrieve an array of folder names 
  2780     // Find UDA and ROM widgets to be installed     
  2785     iRomInstaller->GetInstallationFoldersL( pluginFolders );  
  2781     iRomInstaller->FindInstallationFilesL( pluginFolders );
  2786 		
  2782             
  2787     // Add manifest files from the subfolders
  2783 	// Install the manifest files    
  2788     FindRomInstallationsV2L( pluginFolders );
  2784     for( TInt index=0; index < pluginFolders.Count(); index++ )
  2789     
  2785         {         
  2790     pluginFolders.ResetAndDestroy();
  2786         TPtrC namePtr( pluginFolders[index]->Des() );                               
  2791         
       
  2792     if ( iManifestFiles.Count() < 1 )
       
  2793         {
       
  2794 #ifdef HSPS_LOG_ACTIVE            
  2787 #ifdef HSPS_LOG_ACTIVE            
  2795         iLogBus->LogText( _L( "ChspsThemeServer::InstallManifestsFromRomDriveL(): - mandatory plugins were not found from the ROM drive!" ) );
  2788         iLogBus->LogText( _L( "ChspsThemeServer::InstallWidgetsL(): - installing configuration: %S" ), &namePtr );
  2796 #endif                                  
  2789 #endif      
  2797         // Mandatory plugins were missing from the ROM drive
  2790                 
  2798         User::Leave( KErrGeneral );
  2791         // Synchronous method
  2799         }
  2792         ThspsServiceCompletedMessage ret = iRomInstaller->InstallThemeL( namePtr  );
  2800     
  2793         if ( ret != EhspsInstallThemeSuccess )
  2801 	CleanupStack::PopAndDestroy( 1, &pluginFolders );
  2794             {
  2802 	
       
  2803 	
       
  2804 	// Install configurations from the manifest files 
       
  2805     ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed;
       
  2806     for( TInt manifestIndex=0; manifestIndex < iManifestFiles.Count(); manifestIndex++ )
       
  2807         {                               
       
  2808         // Synchronous API call 
       
  2809         TPtr name( iManifestFiles[manifestIndex]->Des() );
       
  2810 #ifdef HSPS_LOG_ACTIVE            
  2795 #ifdef HSPS_LOG_ACTIVE            
  2811         iLogBus->LogText( _L( "ChspsThemeServer::InstallManifestsFromRomDriveL(): - installing ROM configuration from: %S" ), &name );
  2796             iLogBus->LogText( _L( "ChspsThemeServer::InstallWidgetsL(): - installation failed: %S" ), &namePtr );
  2812 #endif      
       
  2813         ret = iRomInstaller->InstallThemeL( name  );
       
  2814         if ( ret != EhspsInstallThemeSuccess )
       
  2815             {
       
  2816 #ifdef HSPS_LOG_ACTIVE            
       
  2817             iLogBus->LogText( _L( "ChspsThemeServer::InstallManifestsFromRomDriveL(): - configuration is corrupted, critical error - shutting down!" ) );
       
  2818 #endif                  
  2797 #endif                  
  2819 //            User::Leave( KErrAbort );
  2798 //            User::Leave( KErrAbort );
  2820             }
  2799             }
  2821         }
  2800         }
  2822         
  2801     
  2823     // Cancel any actions done in the previous functionality
  2802     if ( pluginFolders.Count() == 0 )
  2824     iManifestFiles.ResetAndDestroy();
  2803         {
       
  2804 #ifdef HSPS_LOG_ACTIVE            
       
  2805         iLogBus->LogText( _L( "ChspsThemeServer::InstallWidgetsL(): - mandatory plugins were not found!" ) );
       
  2806 #endif                                  
       
  2807         // Mandatory plugins were missing 
       
  2808         User::Leave( KErrCorrupt );
       
  2809         }
       
  2810         
       
  2811     pluginFolders.ResetAndDestroy();
       
  2812     CleanupStack::PopAndDestroy( 1, &pluginFolders );
  2825 		
  2813 		
  2826 	// The ROM installer is not needed anymore and therefore it can be released
  2814 	// The ROM installer is not needed anymore and therefore it can be released
  2827 	delete iRomInstaller;
  2815 	delete iRomInstaller;
  2828 	iRomInstaller = NULL;
  2816 	iRomInstaller = 0;
  2829 	
  2817 	
  2830 	// Force updating of the header cache
  2818 	// Force updating of the header cache
  2831     ThspsRepositoryInfo info( EhspsCacheUpdate );
  2819     ThspsRepositoryInfo info( EhspsCacheUpdate );
  2832     iDefinitionRepository->RegisterNotification( info );
  2820     iDefinitionRepository->RegisterNotification( info );
  2833 	}
  2821 	}
  2834 
       
  2835 // -----------------------------------------------------------------------------
       
  2836 // ChspsThemeServer::FindRomInstallationsV2L()
       
  2837 // -----------------------------------------------------------------------------
       
  2838 //
       
  2839 void ChspsThemeServer::FindRomInstallationsV2L(        
       
  2840         RPointerArray<HBufC>& aPluginFolders )
       
  2841     {    
       
  2842     _LIT(KHspsFolder, "hsps\\");
       
  2843     TFileName hspsPath;
       
  2844     for( TInt folderIndex=0; folderIndex < aPluginFolders.Count(); folderIndex++ )
       
  2845         {
       
  2846         // Set path
       
  2847         hspsPath.Copy( aPluginFolders[folderIndex]->Des() );
       
  2848         hspsPath.Append( KHspsFolder );        
       
  2849                         
       
  2850         // Add full path into the installation queue
       
  2851         TInt len = hspsPath.Length() + 3 + KDoubleBackSlash().Length() + KManifestFile().Length();
       
  2852         HBufC* manifestBuf = HBufC::NewLC( len );        
       
  2853         manifestBuf->Des().Copy( hspsPath );
       
  2854         manifestBuf->Des().Append( _L("00") );                        
       
  2855         manifestBuf->Des().Append( KDoubleBackSlash );
       
  2856         manifestBuf->Des().Append( KManifestFile );        
       
  2857                 
       
  2858         iManifestFiles.AppendL( manifestBuf );                
       
  2859         CleanupStack::Pop( manifestBuf );                       
       
  2860         }
       
  2861     }
       
  2862 
  2822 
  2863 // -----------------------------------------------------------------------------
  2823 // -----------------------------------------------------------------------------
  2864 // ChspsThemeServer::GetConfigurationHeader()
  2824 // ChspsThemeServer::GetConfigurationHeader()
  2865 // -----------------------------------------------------------------------------
  2825 // -----------------------------------------------------------------------------
  2866 //
  2826 //