homescreenpluginsrv/hspsmanager/src/hspsthemeserver.cpp
branchRCL_3
changeset 23 ace62b58f4b2
parent 22 1b207dd38b72
child 25 9e077f9a342c
equal deleted inserted replaced
22:1b207dd38b72 23:ace62b58f4b2
    72 _LIT( KDoubleBackSlash, "\\" );
    72 _LIT( KDoubleBackSlash, "\\" );
    73 _LIT( KUpgradePluginWild, "upgrade_plugin_*.dat" );
    73 _LIT( KUpgradePluginWild, "upgrade_plugin_*.dat" );
    74 // Just in case emulator cannot read system version we use this to
    74 // Just in case emulator cannot read system version we use this to
    75 // prevent ROM installation on every boot up
    75 // prevent ROM installation on every boot up
    76 _LIT( KDummyVersionInfo, "dummyversioninfo" );
    76 _LIT( KDummyVersionInfo, "dummyversioninfo" );
       
    77 
       
    78 _LIT( KProcessFindString, "hspsthemeserver*" ); 
    77 
    79 
    78 const TUint KAppId_hspsAS =  270486738; //  0x101F4CD2 from S60 3.1 Xuikon AppShell in 3.1 product.
    80 const TUint KAppId_hspsAS =  270486738; //  0x101F4CD2 from S60 3.1 Xuikon AppShell in 3.1 product.
    79 const TUint KAppId_hspsAI =  271012080 ; // 0x102750F0 support for Xuikon-based ActiveIdle 
    81 const TUint KAppId_hspsAI =  271012080 ; // 0x102750F0 support for Xuikon-based ActiveIdle 
    80 const TUint KAppId_LE =    270551469 ; // 0x102049AD LayoutTest
    82 const TUint KAppId_LE =    270551469 ; // 0x102049AD LayoutTest
    81 
    83 
   175 // E32Main
   177 // E32Main
   176 // Server process entry-point
   178 // Server process entry-point
   177 // -----------------------------------------------------------------------------
   179 // -----------------------------------------------------------------------------
   178 //
   180 //
   179 TInt E32Main()
   181 TInt E32Main()
   180     {
   182     {                   
       
   183     TFindProcess processFinder( KProcessFindString );
       
   184     TFullName fullName;
       
   185     TInt count = 0;
       
   186     while( processFinder.Next( fullName ) == KErrNone )
       
   187         {
       
   188         count++;
       
   189         }
       
   190     if( count > 1 )
       
   191         {
       
   192         return KErrAlreadyExists;
       
   193         }
       
   194     fullName = KNullDesC();
       
   195     
   181     RAllocator* iAllocator = MemoryManager::SwitchToFastAllocator();
   196     RAllocator* iAllocator = MemoryManager::SwitchToFastAllocator();
   182     
   197     
   183     __UHEAP_MARK;
   198     __UHEAP_MARK;
   184     CTrapCleanup* cleanup=CTrapCleanup::New();
   199     CTrapCleanup* cleanup=CTrapCleanup::New();
   185     TInt r=KErrNoMemory;
   200     TInt r=KErrNoMemory;
   331      iSecurityEnforcer->SetLogBus( iLogBus );
   346      iSecurityEnforcer->SetLogBus( iLogBus );
   332 #endif     
   347 #endif     
   333     
   348     
   334     // Find header files from the Plug-in Repository
   349     // Find header files from the Plug-in Repository
   335 	UpdateHeaderListCacheL();  
   350 	UpdateHeaderListCacheL();  
   336     
   351        
   337     // Adds the server with the specified name to the active scheduler, and issues the 
       
   338     // first request for messages, and leaves if the operation fails
       
   339     StartL( KhspsThemeServerName );
       
   340     
       
   341     // Initialize remove index
   352     // Initialize remove index
   342     iThemeIndexToRemove = KErrNotFound;
   353     iThemeIndexToRemove = KErrNotFound;
   343                            
   354                            
   344     // Listen to changes in any key
   355     // Listen to changes in any key
   345     iCenRepListener->SetupAll();     
   356     iCenRepListener->SetupAll();     
   384 
   395 
   385 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_    
   396 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_    
   386     iShutdown = CShutdown::NewL( *this );
   397     iShutdown = CShutdown::NewL( *this );
   387 #endif // _hsps_SERVER_SHUTDOWN_ENABLED_
   398 #endif // _hsps_SERVER_SHUTDOWN_ENABLED_
   388     
   399     
       
   400     // Adds the server with the specified name to the active scheduler, and issues the 
       
   401     // first request for messages, and leaves if the operation fails
       
   402     StartL( KhspsThemeServerName );
       
   403         
   389 #ifdef HSPS_LOG_ACTIVE	
   404 #ifdef HSPS_LOG_ACTIVE	
   390     iLogBus->LogText( _L( "hspsThemeServer: server fully constructed" ) );
   405     iLogBus->LogText( _L( "hspsThemeServer: server fully constructed" ) );
   391     iLogBus->LogText( _L( "--------------------------------------------------------" ) );
   406     iLogBus->LogText( _L( "--------------------------------------------------------" ) );
   392 #endif    
   407 #endif    
   393     }
   408     }
   434     {
   449     {
   435 #ifdef HSPS_LOG_ACTIVE      
   450 #ifdef HSPS_LOG_ACTIVE      
   436     iLogBus->LogText( _L( "hspsThemeServer: server is shutting down" ) );
   451     iLogBus->LogText( _L( "hspsThemeServer: server is shutting down" ) );
   437 #endif    
   452 #endif    
   438             
   453             
       
   454     delete iFileMan;
   439     if( iDefinitionRepository )
   455     if( iDefinitionRepository )
   440         {
   456         {
   441         iDefinitionRepository->UnregisterObserver( *this );
   457         iDefinitionRepository->UnregisterObserver( *this );
   442         }
   458         }
   443 
   459 
   480     delete iBRObserver;
   496     delete iBRObserver;
   481     delete iActiveBackupClient;
   497     delete iActiveBackupClient;
   482     delete iBRHandler;
   498     delete iBRHandler;
   483 
   499 
   484     iCacheMask = NULL;
   500     iCacheMask = NULL;
   485     
   501         
   486     iFsSession.Close();    
   502     iFsSession.Close();    
   487     }
   503     }
   488 
   504 
   489 // -----------------------------------------------------------------------------
   505 // -----------------------------------------------------------------------------
   490 // ChspsThemeServer::NewSessionL
   506 // ChspsThemeServer::NewSessionL
  1454 
  1470 
  1455                 if( !err )                    
  1471                 if( !err )                    
  1456                     {
  1472                     {
  1457                     started = ETrue;
  1473                     started = ETrue;
  1458                     }
  1474                     }
       
  1475                 else
       
  1476                     {
       
  1477                     delete iInstalledSisxThemes[ iThemeIndexToRemove ];
       
  1478                     iInstalledSisxThemes[ iThemeIndexToRemove ] = NULL;
       
  1479                     iInstalledSisxThemes.Remove( iThemeIndexToRemove );
       
  1480                     }
  1459                 }
  1481                 }
  1460             }
  1482             }
  1461             break;
  1483             break;
  1462         default:    
  1484         default:    
  1463             {
  1485             {
  2140 void ChspsThemeServer::HandleLanguageChangeL()
  2162 void ChspsThemeServer::HandleLanguageChangeL()
  2141 	{
  2163 	{
  2142 #ifdef HSPS_LOG_ACTIVE          
  2164 #ifdef HSPS_LOG_ACTIVE          
  2143         iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL()") );
  2165         iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL()") );
  2144 #endif
  2166 #endif
  2145         
  2167         	
  2146 	// Set key for fetching previously used language from the cenrep
       
  2147 	const TInt KCenrepLangKey = 100000001;
       
  2148 	
       
  2149 	// The key should already exist
  2168 	// The key should already exist
  2150 	const TUint32 fullMask = 0xFFFFFFFF;
  2169 	const TUint32 fullMask = 0xFFFFFFFF;
  2151 	RArray<TUint32> res;	
  2170 	RArray<TUint32> res;	
  2152 	CleanupClosePushL( res );
  2171 	CleanupClosePushL( res );
  2153 	
  2172 	
  2154 	iCentralRepository->FindL( KCenrepLangKey, fullMask, res );
  2173 	iCentralRepository->FindL( KCenrepKeyLang, fullMask, res );
  2155    	if ( res.Count() == 0 )
  2174    	if ( res.Count() == 0 )
  2156    		{
  2175    		{
  2157 #ifdef HSPS_LOG_ACTIVE   		
  2176 #ifdef HSPS_LOG_ACTIVE   		
  2158    		iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL(): - Couldn't find %d key from the HSPS cenrep!" ), KCenrepLangKey );
  2177    		iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL(): - Couldn't find %d key from the HSPS cenrep!" ), KCenrepLangKey );
  2159 #endif   		             
  2178 #endif   		             
  2161    		User::Leave( KErrNotFound );
  2180    		User::Leave( KErrNotFound );
  2162    		}	
  2181    		}	
  2163 	
  2182 	
  2164    	// Check the cenrep key's value
  2183    	// Check the cenrep key's value
  2165 	TInt prevLanguage = ELangNone;
  2184 	TInt prevLanguage = ELangNone;
  2166     iCentralRepository->Get( KCenrepLangKey, prevLanguage );
  2185     iCentralRepository->Get( KCenrepKeyLang, prevLanguage );
  2167     
  2186     
  2168     // If the language has been changed
  2187     // If the language has been changed
  2169     if( iDeviceLanguage != prevLanguage )
  2188     if( iDeviceLanguage != prevLanguage )
  2170     	{
  2189     	{
  2171     	// Update all the ODTs so that the localized configurations can be fetched    	
  2190     	// Update all the ODTs so that the localized configurations can be fetched    	
  2172     	LocalizeConfigurationsL();
  2191     	LocalizeConfigurationsL();
       
  2192     	
       
  2193     	UpdateHeaderListCacheL();
  2173     		
  2194     		
  2174     	// Finally, update the cenrep with the new language
  2195     	// Finally, update the cenrep with the new language
  2175     	TInt errorCode = iCentralRepository->Set( KCenrepLangKey, iDeviceLanguage );
  2196     	TInt errorCode = iCentralRepository->Set( KCenrepKeyLang, iDeviceLanguage );
  2176     	if ( errorCode  )
  2197     	if ( errorCode  )
  2177     		{
  2198     		{
  2178 #ifdef HSPS_LOG_ACTIVE    		
  2199 #ifdef HSPS_LOG_ACTIVE    		
  2179 	        iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL(): - Failed to update the cenrep!" ) );
  2200 	        iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL(): - Failed to update the cenrep!" ) );
  2180 #endif    		        
  2201 #endif    		        
  2255 		
  2276 		
  2256 		} // count
  2277 		} // count
  2257 	}
  2278 	}
  2258 
  2279 
  2259 // -----------------------------------------------------------------------------
  2280 // -----------------------------------------------------------------------------
       
  2281 // ChspsThemeServer::ResetResourcesL()
       
  2282 // -----------------------------------------------------------------------------
       
  2283 //
       
  2284 void ChspsThemeServer::ResetResourcesL(
       
  2285         ChspsODT& aAppODT )
       
  2286     {
       
  2287     // If active configuration
       
  2288     TInt confUid = -1;
       
  2289     iCentralRepository->Get( aAppODT.RootUid(), confUid );        
       
  2290     if( confUid == aAppODT.ThemeUid() )
       
  2291         {
       
  2292         if( !iFileMan )
       
  2293             {
       
  2294             iFileMan= CFileMan::NewL( iFsSession );
       
  2295             }
       
  2296                         
       
  2297         // Find unique plug-in UIDs from the app configuration
       
  2298         RArray<TInt> uidArray;
       
  2299         CleanupClosePushL( uidArray );
       
  2300         hspsServerUtil::FindUniquePluginsL( aAppODT, uidArray );
       
  2301         
       
  2302         // Remove old copies from the client path, localized copies will be  
       
  2303         // restored when the app configuration is fetched again        
       
  2304         for( TInt i=0; i < uidArray.Count(); i++ )
       
  2305             {                    
       
  2306             ChspsODT* pluginODT = ChspsODT::NewL();
       
  2307             CleanupStack::PushL( pluginODT );
       
  2308             
       
  2309             GetConfigurationL(
       
  2310                 0, 
       
  2311                 uidArray[i],
       
  2312                 *pluginODT );
       
  2313             
       
  2314             if( pluginODT->ThemeUid() )
       
  2315                 {
       
  2316                 hspsServerUtil::RemoveResourceFilesL(                               
       
  2317                     *iFileMan,
       
  2318                     iFsSession,
       
  2319                     aAppODT.RootUid(),
       
  2320                     *pluginODT );
       
  2321                 }
       
  2322             
       
  2323             CleanupStack::PopAndDestroy();            
       
  2324             }
       
  2325         
       
  2326         uidArray.Reset();
       
  2327         CleanupStack::PopAndDestroy( &uidArray );             
       
  2328         }
       
  2329     }
       
  2330 
       
  2331 // -----------------------------------------------------------------------------
  2260 // ChspsThemeServer::LocalizeL()
  2332 // ChspsThemeServer::LocalizeL()
  2261 // -----------------------------------------------------------------------------
  2333 // -----------------------------------------------------------------------------
  2262 //
  2334 //
  2263 TBool ChspsThemeServer::LocalizeL( 
  2335 TBool ChspsThemeServer::LocalizeL( 
  2264 		ChspsDefinitionEngineInterface& aEngine,
  2336 		ChspsDefinitionEngineInterface& aEngine,
  2284     	    // Apply plugin and application specific DTD files 
  2356     	    // Apply plugin and application specific DTD files 
  2285     	    domChanged = LocalizeApplicationConfigurationL( 
  2357     	    domChanged = LocalizeApplicationConfigurationL( 
  2286     	            aEngine, 
  2358     	            aEngine, 
  2287     	            aOdt,
  2359     	            aOdt,
  2288     	            requestedLanguage );
  2360     	            requestedLanguage );
       
  2361     	                            
       
  2362             ResetResourcesL( aOdt );
  2289     	    }
  2363     	    }
  2290     	else
  2364     	else
  2291     	    {	    
  2365     	    {	    
  2292     	    // Apply plugin specific DTD files only
  2366     	    // Apply plugin specific DTD files only
  2293     	    domChanged = LocalizePluginConfigurationL( 
  2367     	    domChanged = LocalizePluginConfigurationL(