featuremgmt/featuremgr/src/serverexe/featmgrfeatureregistry.cpp
branchRCL_3
changeset 10 31a8f755b7fe
parent 9 667e88a979d7
child 21 28839de615b4
equal deleted inserted replaced
9:667e88a979d7 10:31a8f755b7fe
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   548     ReadFilesFromDirL( KZFeaturesDir );
   548     ReadFilesFromDirL( KZFeaturesDir );
   549 
   549 
   550     //check that there is at least one DSR 
   550     //check that there is at least one DSR 
   551     if (!iRangeList.Count()) 
   551     if (!iRangeList.Count()) 
   552     	{
   552     	{
   553     	_LIT( KPanicCategory, "FeatMgrServer" );
   553     	_LIT(KPanicCategory, "FeatMgrServer");
   554     	ERROR_LOG( "CFeatMgrFeatureRegistry::ReadFilesFromDirL() - no DSR found in ROM; this indicates a system integration error  - going to panic" );
   554     	ERROR_LOG( "CFeatMgrFeatureRegistry::ReadFilesFromDirL() - no DSR found in ROM; this indicates a system integration error  - going to panic" );
   555     	User::Panic( KPanicCategory, EPanicNoDSR );    
   555     	::FmgrFatalErrorL(KErrNotFound, KPanicCategory, EPanicNoDSR);    
   556     	}
   556     	}
   557     }
   557     }
   558 
   558 
   559 // -----------------------------------------------------------------------------
   559 // -----------------------------------------------------------------------------
   560 // CFeatMgrFeatureRegistry::ReadFilesFromDirL
   560 // CFeatMgrFeatureRegistry::ReadFilesFromDirL
   561 // -----------------------------------------------------------------------------
   561 // -----------------------------------------------------------------------------
   562 //
   562 //
   563 void CFeatMgrFeatureRegistry::ReadFilesFromDirL( const TDesC& aDirName )
   563 void CFeatMgrFeatureRegistry::ReadFilesFromDirL( const TDesC& aDirName )
   564     {
   564     {
   565 	_LIT( KPanicCategory, "FEATMGR-READFILE" );
   565     _LIT(KPanicCategory, "FEATMGR-READFILE");
   566 
   566 
   567     CDir* dir = NULL; 
   567     CDir* dir = NULL; 
   568     TInt err( KErrNone );
   568     TInt err( KErrNone );
   569 
   569 
   570     err = iFs.GetDir( aDirName, KEntryAttNormal, ESortByName, dir );
   570     err = iFs.GetDir( aDirName, KEntryAttNormal, ESortByName, dir );
   579             User::Leave( err );    
   579             User::Leave( err );    
   580             }
   580             }
   581         }  
   581         }  
   582     else if( err == KErrPathNotFound )
   582     else if( err == KErrPathNotFound )
   583     	{
   583     	{
   584     	__ASSERT_ALWAYS( EFalse, User::Panic( KPanicCategory, EPanicNoFeatureFiles) );
   584     	::FmgrFatalErrorL(err, KPanicCategory, EPanicNoFeatureFiles);
   585     	}
   585     	}
   586 	else
   586 	else
   587         {            
   587         {            
   588         ERROR_LOG1( "CFeatMgrFeatureRegistry::ReadFilesFromDirL() - err %d ", err );
   588         ERROR_LOG1( "CFeatMgrFeatureRegistry::ReadFilesFromDirL() - err %d ", err );
   589         User::Leave( err );    
   589         User::Leave( err );    
   720         		}
   720         		}
   721 
   721 
   722         	}
   722         	}
   723         else //File is not as runtime file.
   723         else //File is not as runtime file.
   724         	{
   724         	{
   725         	err = ValidateFeatureFlag(flags);
   725         	ValidateFeatureFlagL(flags);
   726         	}
   726         	}
   727         
   727         
   728         //If a feature flag defined in system drive (c:) is invalid, it will not be added to Feature Manager 
   728         //If a feature flag defined in system drive (c:) is invalid, it will not be added to Feature Manager 
   729         if ( (err != KErrNone) && flags.IsSet(EFeatureRuntime) )
   729         if ( (err != KErrNone) && flags.IsSet(EFeatureRuntime) )
   730         	{
   730         	{
  1023     TInt count = aList.Count();
  1023     TInt count = aList.Count();
  1024 
  1024 
  1025     for ( TInt i = 0; i < count; i++ )
  1025     for ( TInt i = 0; i < count; i++ )
  1026         {
  1026         {
  1027         //Check for feature flag errors
  1027         //Check for feature flag errors
  1028         ValidateFeatureFlag(aList[i].FeatureFlags()) ; 
  1028         ValidateFeatureFlagL(aList[i].FeatureFlags()) ; 
  1029         const TUid uid( aList[i].FeatureUid() );
  1029         const TUid uid( aList[i].FeatureUid() );
  1030         TInt index = SearchFeature( uid );
  1030         TInt index = SearchFeature( uid );
  1031         
  1031         
  1032         if( index != KErrNotFound )
  1032         if( index != KErrNotFound )
  1033             {
  1033             {
  1061 // Rule 1) If a feature flag is blacklisted then setting any of modifiable, persisted, Un-initialised bit will be an error
  1061 // Rule 1) If a feature flag is blacklisted then setting any of modifiable, persisted, Un-initialised bit will be an error
  1062 // Rule 2) If a feature flag is non blacklisted, non modifiable  setting any of Un-initialised, Persisted bit will be an error
  1062 // Rule 2) If a feature flag is non blacklisted, non modifiable  setting any of Un-initialised, Persisted bit will be an error
  1063 // -----------------------------------------------------------------------------
  1063 // -----------------------------------------------------------------------------
  1064 //  
  1064 //  
  1065    
  1065    
  1066 TInt CFeatMgrFeatureRegistry::ValidateFeatureFlag(TBitFlags32 aFlags)
  1066 void CFeatMgrFeatureRegistry::ValidateFeatureFlagL(TBitFlags32 aFlags)
  1067 	{
  1067 	{
  1068 	_LIT( KPanicCategory, "FEATMGR-FLAGS" );
  1068 	_LIT(KPanicCategory, "FEATMGR-FLAGS");
  1069 
       
  1070 	
  1069 	
  1071 	if(!aFlags.IsSet(EFeatureRuntime)) //ROM defined feature flag error check
  1070 	if(!aFlags.IsSet(EFeatureRuntime)) //ROM defined feature flag error check
  1072 		{
  1071 		{
  1073 		//Rule 1
  1072 		//Rule 1
  1074 		if(aFlags.IsSet(EFeatureBlackListed) )
  1073 		if(aFlags.IsSet(EFeatureBlackListed) )
  1075 	    	{
  1074 	    	{
  1076 	    	 if(aFlags.IsSet(EFeatureModifiable) || aFlags.IsSet(EFeaturePersisted) || aFlags.IsSet(EFeatureUninitialized) )
  1075 	    	 if(aFlags.IsSet(EFeatureModifiable) || aFlags.IsSet(EFeaturePersisted) || aFlags.IsSet(EFeatureUninitialized) )
  1077 	    	 	{
  1076 	    	 	{
  1078 	    	 	//error 
  1077 	    	 	//error 
  1079 	    	 	__ASSERT_ALWAYS(EFalse, User::Panic( KPanicCategory, EFmpInvalidFeatureBitFlagsRule1));
  1078 	    	 	::FmgrFatalErrorL(KErrArgument, KPanicCategory, EFmpInvalidFeatureBitFlagsRule1);
  1080                 return KErrArgument;
       
  1081 	    	  	}
  1079 	    	  	}
  1082 	    	}
  1080 	    	}
  1083 	    	
  1081 	    	
  1084 	    //Rule 2    	
  1082 	    //Rule 2    	
  1085 	    if (!aFlags.IsSet(EFeatureModifiable))
  1083 	    if (!aFlags.IsSet(EFeatureModifiable))
  1086 	       	{
  1084 	       	{
  1087 	       	if (aFlags.IsSet(EFeaturePersisted) || aFlags.IsSet(EFeatureUninitialized) )
  1085 	       	if (aFlags.IsSet(EFeaturePersisted) || aFlags.IsSet(EFeatureUninitialized) )
  1088 	       	 	{
  1086 	       	 	{
  1089 	        	//error 
  1087 	        	//error 
  1090 	        	__ASSERT_ALWAYS(EFalse, User::Panic( KPanicCategory, EFmpInvalidFeatureBitFlagsRule2));
  1088 	       	 	::FmgrFatalErrorL(KErrArgument, KPanicCategory, EFmpInvalidFeatureBitFlagsRule2);
  1091                 return KErrArgument;
       
  1092 	        	}	
  1089 	        	}	
  1093 	        }
  1090 	        }
  1094 		}
  1091 		}
  1095 	else // Runtime feature this should not be in the rom
  1092 	else // Runtime feature this should not be in the rom
  1096 		{		
  1093 		{		
  1097 		__ASSERT_ALWAYS(EFalse, User::Panic( KPanicCategory, EPanicInvalidFeatureInfo));
  1094 		::FmgrFatalErrorL(KErrArgument, KPanicCategory, EPanicInvalidFeatureInfo);
  1098 		return KErrArgument;
       
  1099 		}
  1095 		}
  1100 	return KErrNone;
       
  1101 	}
  1096 	}
  1102 
  1097 
  1103 /**
  1098 /**
  1104  * This function is used to validate feature flags that are read from the features file on the ffs.
  1099  * This function is used to validate feature flags that are read from the features file on the ffs.
  1105  * This function is also used to validate feature flags that are modified or added with the execption of MergePluginFeatures.
  1100  * This function is also used to validate feature flags that are modified or added with the execption of MergePluginFeatures.