featuremgmt/featuremgr/src/serverexe/featmgrserver.cpp
branchRCL_3
changeset 10 31a8f755b7fe
parent 9 667e88a979d7
child 23 26645d81f48d
equal deleted inserted replaced
9:667e88a979d7 10:31a8f755b7fe
    26 #include "featmgrdebug.h"
    26 #include "featmgrdebug.h"
    27 #include "featmgrsecuritypolicy.h"
    27 #include "featmgrsecuritypolicy.h"
    28 #include <f32file.h>
    28 #include <f32file.h>
    29 #include <s32file.h>
    29 #include <s32file.h>
    30 
    30 
    31 // LOCAL CONSTANTS AND MACROS
    31 _LIT(KPanicCategory, "FeatMgrServer");
    32 #ifdef EXTENDED_FEATURE_MANAGER_TEST
       
    33 _LIT( KPanicCategory, "EnhancedFeatMgrServer" );
       
    34 #else
       
    35 _LIT( KPanicCategory, "FeatMgrServer" );
       
    36 #endif // EXTENDED_FEATURE_MANAGER_TEST
       
    37 
    32 
    38 // ============================ MEMBER FUNCTIONS ===============================
    33 // ============================ MEMBER FUNCTIONS ===============================
    39 
    34 
    40 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    41 // CFeatMgrServer::CFeatMgrServer
    36 // CFeatMgrServer::CFeatMgrServer
    96     TRAPD(err,iRegistry->ReadFeatureFilesL());
    91     TRAPD(err,iRegistry->ReadFeatureFilesL());
    97     switch (err)
    92     switch (err)
    98     	{
    93     	{
    99     	case KErrNotFound:
    94     	case KErrNotFound:
   100     		ERROR_LOG( "CFeatMgrServer::ConstructL() - no feature files found in ROM - going to panic");
    95     		ERROR_LOG( "CFeatMgrServer::ConstructL() - no feature files found in ROM - going to panic");
   101     		User::Panic( KPanicCategory, EPanicNoFeatureFiles );
    96     		::FmgrFatalErrorL(err, KPanicCategory, EPanicNoFeatureFiles);
   102     		break;
    97     		break;
   103     	case KErrCorrupt:
    98     	case KErrCorrupt:
   104     	    ERROR_LOG( "CFeatMgrServer::ConstructL() - feature information in ROM is invalid - going to panic");
    99     	    ERROR_LOG( "CFeatMgrServer::ConstructL() - feature information in ROM is invalid - going to panic");
   105     	    User::Panic( KPanicCategory, EPanicInvalidFeatureInfo );
   100     	    ::FmgrFatalErrorL(err, KPanicCategory, EPanicInvalidFeatureInfo);
   106     	    break;
   101     	    break;
   107     	default:
   102     	default:
   108     		User::LeaveIfError(err);
   103     		User::LeaveIfError(err);
   109     		break;
   104     		break;
   110     	}
   105     	}
   340                                         implInfoArray);
   335                                         implInfoArray);
   341     TIMESTAMP( "CFeatMgrServer::LoadPluginsL - ListImplementationsL end: " )
   336     TIMESTAMP( "CFeatMgrServer::LoadPluginsL - ListImplementationsL end: " )
   342     
   337     
   343     // Check if any plugin was found. 
   338     // Check if any plugin was found. 
   344     TInt count = implInfoArray.Count();
   339     TInt count = implInfoArray.Count();
   345     
   340     if(count == 0)
   346     if ( count > 0 )
   341         {
   347         {
   342         iPluginsReady = ETrue; // Plugins not found.
   348         
   343         INFO_LOG1("CFeatMgrServer::LoadPluginsL - interfaceUid.iUid == 0x%x, return plugins not found", KFeatureInfoPluginInterfaceUid);
   349         for(TInt i = 0; i < count; i ++)
   344         ret = EFalse;
       
   345         }
       
   346     else
       
   347         {
       
   348         for(TInt i=0;i<count;++i)
   350             {
   349             {
   351             CFeatMgrPluginHandler* pluginHandler = NULL;
   350             CFeatMgrPluginHandler* pluginHandler = NULL;
   352             TInt err( KErrNone );
   351             TRAPD(err, pluginHandler = CFeatMgrPluginHandler::NewL(implInfoArray[i]->ImplementationUid(), *this));
   353         
   352             if(err == KErrNone)
   354             // Create handler
       
   355             TRAP( err, pluginHandler = CFeatMgrPluginHandler::NewL( 
       
   356                   implInfoArray[i]->ImplementationUid(), *this) );
       
   357                 
       
   358             LOG_IF_ERROR1( err, "CFeatMgrServer::LoadPluginsL() - pluginHandler creation err %d", err );
       
   359             
       
   360             // Apply first request for plugin to process
       
   361             if ( err == KErrNone )
       
   362                 {
   353                 {
   363                 TRAP( err, pluginHandler->SendCommandL( 
   354                 CleanupStack::PushL(pluginHandler);
   364                     FeatureInfoCommand::ELoadFeatureInfoCmdId ) );
   355                 TRAP(err, pluginHandler->SendCommandL(FeatureInfoCommand::ELoadFeatureInfoCmdId));
   365                 }            
   356                 if(err == KErrNotSupported)
   366             
       
   367             // Panic if error sth else than not supported        
       
   368             if ( err != KErrNone && err != KErrNotSupported )
       
   369                 {
       
   370                 ERROR_LOG2( "CFeatMgrServer::LoadPluginsL() - implementationUid: 0x%x, error: %d - going to panic",
       
   371                                         implInfoArray[i]->ImplementationUid(), err );
       
   372                 User::Panic( KPanicCategory, EPanicLoadPluginError );                           
       
   373                 }
       
   374             // If simple features are not supported by the plugin search for enhanced ones
       
   375             else if ( err == KErrNotSupported )
       
   376             	{
       
   377             	// Reset error code
       
   378             	err = KErrNone;
       
   379                 TRAP( err, pluginHandler->SendCommandL(
       
   380                     FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId ) );
       
   381 
       
   382                 // Panic if error since in this case the plugin does not support any feature
       
   383             	if ( err != KErrNone )
       
   384 	            	{
       
   385 	                ERROR_LOG2( "CFeatMgrServer::LoadPluginsL() - implementationUid: 0x%x, error: %d - going to panic",
       
   386 	                        implInfoArray[i]->ImplementationUid(), err );
       
   387 	                User::Panic( KPanicCategory, EPanicLoadPluginError );
       
   388 	            	}
       
   389 	            }
       
   390             // If a simple or enhanced feature is supported by the plugin then append the plugin to the list
       
   391             if ( err == KErrNone )
       
   392             	{
       
   393                 INFO_LOG1( "CFeatMgrServer::LoadPluginsL() - Add info of implementationUid: 0x%x",
       
   394                                         implInfoArray[i]->ImplementationUid() );
       
   395             
       
   396                 // Add information of the plugin to the plugin list
       
   397                 SFeatMgrPluginInfo plugin;
       
   398                 plugin.iPluginHandler = pluginHandler;
       
   399                 // Set all plugins as not ready initially
       
   400                 plugin.iPluginReady = EFalse;
       
   401 
       
   402                 TInt err = iPluginList.Append(plugin);
       
   403             
       
   404                 if ( err != KErrNone )
       
   405                     {
   357                     {
   406                     ERROR_LOG2( "CFeatMgrServer::LoadPluginsL() - Saving plugin info of implementationUid: 0x%x, err %d",
   358                     TRAP(err, pluginHandler->SendCommandL(FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId));
   407                                                   implInfoArray[i]->ImplementationUid(), err );
       
   408                     User::Leave( err );
       
   409                     }
   359                     }
   410                 }
   360                 }
   411             }
   361             if(err == KErrNoMemory)
   412         INFO_LOG1( "CFeatMgrServer::LoadPluginsL - interfaceUid.iUid == 0x%x, return plugins found",
   362                 {
   413                            KFeatureInfoPluginInterfaceUid );
   363                 User::Leave(err);
       
   364                 }
       
   365             else if(err != KErrNone)
       
   366                 {
       
   367                 ERROR_LOG2("CFeatMgrServer::LoadPluginsL() - implementationUid: 0x%x, error: %d - going to panic", implInfoArray[i]->ImplementationUid(), err);
       
   368                 ::FmgrFatalErrorL(err, KPanicCategory, EPanicLoadPluginError);                           
       
   369                 }
       
   370             // Add information of the plugin to the plugin list. Set all plugins as not ready initially.
       
   371             SFeatMgrPluginInfo plugin;
       
   372             plugin.iPluginHandler = pluginHandler;
       
   373             plugin.iPluginReady = EFalse;
       
   374             User::LeaveIfError(iPluginList.Append(plugin));
       
   375             CleanupStack::Pop(pluginHandler);
       
   376             }
       
   377         INFO_LOG1("CFeatMgrServer::LoadPluginsL - interfaceUid.iUid == 0x%x, return plugins found", KFeatureInfoPluginInterfaceUid);
   414         ret = ETrue;
   378         ret = ETrue;
   415         }
       
   416     
       
   417     else
       
   418         {
       
   419         iPluginsReady = ETrue; // Plugins not found.
       
   420         INFO_LOG1( "CFeatMgrServer::LoadPluginsL - interfaceUid.iUid == 0x%x, return plugins not found",
       
   421                            KFeatureInfoPluginInterfaceUid );
       
   422         ret = EFalse;
       
   423         }
   379         }
   424     
   380     
   425     CleanupStack::PopAndDestroy(&implInfoArray);
   381     CleanupStack::PopAndDestroy(&implInfoArray);
   426     
   382     
   427     return ret;
   383     return ret;
   534                 FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId ) );
   490                 FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId ) );
   535             // Panic if error sth else than not supported
   491             // Panic if error sth else than not supported
   536             if ( err != KErrNone && err != KErrNotSupported )
   492             if ( err != KErrNone && err != KErrNotSupported )
   537                 {
   493                 {
   538                 ERROR_LOG1( "CFeatMgrServer::FeatureInfoL() - panicing due error %d", err );
   494                 ERROR_LOG1( "CFeatMgrServer::FeatureInfoL() - panicing due error %d", err );
   539                 User::Panic( KPanicCategory, EPanicLoadPluginError );
   495                 ::FmgrFatalErrorL(err, KPanicCategory, EPanicLoadPluginError);
   540                 }
   496                 }
   541             // At this point we have simple feature supported by the plugin.
   497             // At this point we have simple feature supported by the plugin.
   542             // If no enhanced feature is supported, but a simple one is, then
   498             // If no enhanced feature is supported, but a simple one is, then
   543             // the plugin is ready to be used. Otherwise continue to add the
   499             // the plugin is ready to be used. Otherwise continue to add the
   544             // enhanced features.
   500             // enhanced features.
   779     // Load ROM (Z)
   735     // Load ROM (Z)
   780 	TRAPD( err, iRegistry->ReadFeatureFilesL() );
   736 	TRAPD( err, iRegistry->ReadFeatureFilesL() );
   781 	if( KErrNotFound == err)
   737 	if( KErrNotFound == err)
   782 		{
   738 		{
   783 		ERROR_LOG( "CFeatMgrServer::ConstructL() & CallReadFeatureFilesL() - no feature files found in ROM - going to panic");
   739 		ERROR_LOG( "CFeatMgrServer::ConstructL() & CallReadFeatureFilesL() - no feature files found in ROM - going to panic");
   784 	    User::Panic( KPanicCategory, EPanicNoFeatureFiles );
   740 		::FmgrFatalErrorL(err, KPanicCategory, EPanicNoFeatureFiles);
   785 		}
   741 		}
   786 	else
   742 	else
   787 		{
   743 		{
   788 		User::LeaveIfError(err);
   744 		User::LeaveIfError(err);
   789 		}
   745 		}
   800 	else
   756 	else
   801 	    {
   757 	    {
   802 	    TRAPD( err, iRegistry->ReadRuntimeFeaturesL( iFeaturesReady ) );
   758 	    TRAPD( err, iRegistry->ReadRuntimeFeaturesL( iFeaturesReady ) );
   803 		if( KErrNotFound == err)
   759 		if( KErrNotFound == err)
   804 			{
   760 			{
   805 		    User::Panic( KPanicCategory, EPanicNoFeatureFiles );
   761 			::FmgrFatalErrorL(err, KPanicCategory, EPanicNoFeatureFiles);
   806 			}
   762 			}
   807 		else
   763 		else
   808 			{
   764 			{
   809 			User::LeaveIfError(err);
   765 			User::LeaveIfError(err);
   810 			}
   766 			}