mtpfws/mtpfw/src/cmtpserviceconfig.cpp
changeset 49 c20dd21d1eb4
parent 31 a26669f87b46
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    18 @internalComponent
    18 @internalComponent
    19 */ 
    19 */ 
    20 
    20 
    21 #include "mtpservicecommon.h"
    21 #include "mtpservicecommon.h"
    22 #include "cmtpserviceconfig.h"
    22 #include "cmtpserviceconfig.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "cmtpserviceconfigTraces.h"
       
    26 #endif
       
    27 
    23 
    28 
    24 
    29 
    25 // Class constants.
    30 // Class constants.
    26 __FLOG_STMT(_LIT8(KComponent,"ServiceConfigMgr");)
       
    27 _LIT(KMTPServiceCofigfile, "z:\\resource\\mtp\\services.rsc");
    31 _LIT(KMTPServiceCofigfile, "z:\\resource\\mtp\\services.rsc");
    28 
    32 
    29 
    33 
    30 
    34 
    31 CMTPServiceConfig::TSupportedService::TSupportedService( const TMTPTypeGuid& aGUID, const TUint aServiceType, const TUint aResID ):
    35 CMTPServiceConfig::TSupportedService::TSupportedService( const TMTPTypeGuid& aGUID, const TUint aServiceType, const TUint aResID ):
    52 /**
    56 /**
    53 Destructor
    57 Destructor
    54 */    
    58 */    
    55 CMTPServiceConfig::~CMTPServiceConfig()
    59 CMTPServiceConfig::~CMTPServiceConfig()
    56     {
    60     {
    57     __FLOG(_L8("CMTPServiceConfig::~CMTPServiceConfig() - Entry"));
    61     OstTraceFunctionEntry0( CMTPSERVICECONFIG_CMTPSERVICECONFIG_DES_ENTRY );
    58         
    62         
    59     iSupportedServices.Close();
    63     iSupportedServices.Close();
    60     iServiceInfos.ResetAndDestroy();
    64     iServiceInfos.ResetAndDestroy();
    61     __FLOG(_L8("CMTPServiceConfig::~CMTPServiceConfig() - Exit"));
    65     OstTraceFunctionExit0( CMTPSERVICECONFIG_CMTPSERVICECONFIG_DES_EXIT );
    62     __FLOG_CLOSE;
       
    63     }
    66     }
    64 
    67 
    65 TInt CMTPServiceConfig::SupportedServiceOrderFromAscending( const TSupportedService& aL, const TSupportedService& aR)
    68 TInt CMTPServiceConfig::SupportedServiceOrderFromAscending( const TSupportedService& aL, const TSupportedService& aR)
    66     {
    69     {
    67     return aL.iGUID.Compare( aR.iGUID );
    70     return aL.iGUID.Compare( aR.iGUID );
    78     
    81     
    79     }
    82     }
    80 
    83 
    81 void CMTPServiceConfig::ConstructL( const TDesC& aResourceFilename )
    84 void CMTPServiceConfig::ConstructL( const TDesC& aResourceFilename )
    82     {
    85     {
    83     __FLOG_OPEN(KMTPSubsystem, KComponent);
    86     OstTraceFunctionEntry0( CMTPSERVICECONFIG_CONSTRUCTL_ENTRY );
    84     __FLOG(_L8("CMTPServiceConfig::ConstructL - Entry"));
    87     
    85     
       
    86 
       
    87     
    88     
    88     RResourceFile file;
    89     RResourceFile file;
    89     file.OpenL( iRFs, aResourceFilename );
    90     file.OpenL( iRFs, aResourceFilename );
    90     CleanupClosePushL(file);
    91     CleanupClosePushL(file);
    91        
    92        
    99     InitializeL( reader );
   100     InitializeL( reader );
   100     
   101     
   101     CleanupStack::PopAndDestroy(buffer);
   102     CleanupStack::PopAndDestroy(buffer);
   102     CleanupStack::PopAndDestroy(&file);
   103     CleanupStack::PopAndDestroy(&file);
   103     
   104     
   104     __FLOG(_L8("CMTPServiceConfig::ConstructL - Exit"));
   105     OstTraceFunctionExit0( CMTPSERVICECONFIG_CONSTRUCTL_EXIT );
   105     }
   106     }
   106 
   107 
   107 
   108 
   108 void CMTPServiceConfig::InitializeL( TResourceReader& aReader )
   109 void CMTPServiceConfig::InitializeL( TResourceReader& aReader )
   109     {
   110     {
   110     __FLOG(_L8("CMTPServiceConfig::InitializeL - Entry"));
   111     OstTraceFunctionEntry0( CMTPSERVICECONFIG_INITIALIZEL_ENTRY );
   111     
   112     
   112     //read the supported services
   113     //read the supported services
   113     TUint serviceCount = aReader.ReadInt16();
   114     TUint serviceCount = aReader.ReadInt16();
   114 
   115 
   115     TUint resID(0);
   116     TUint resID(0);
   120         type = aReader.ReadUint32();
   121         type = aReader.ReadUint32();
   121         resID = aReader.ReadUint32();
   122         resID = aReader.ReadUint32();
   122         iSupportedServices.InsertInOrderL( TSupportedService( svcGUID, type, resID ), TLinearOrder<TSupportedService>(SupportedServiceOrderFromAscending) );      
   123         iSupportedServices.InsertInOrderL( TSupportedService( svcGUID, type, resID ), TLinearOrder<TSupportedService>(SupportedServiceOrderFromAscending) );      
   123         }
   124         }
   124     
   125     
   125     
   126 
   126     __FLOG(_L8("CMTPServiceConfig::InitializeL - Exit"));
   127     OstTraceFunctionExit0( CMTPSERVICECONFIG_INITIALIZEL_EXIT );
   127     }
   128     }
   128 
   129 
   129 TBool CMTPServiceConfig::IsSupportedService( const TMTPTypeGuid& aServiceGUID ) const
   130 TBool CMTPServiceConfig::IsSupportedService( const TMTPTypeGuid& aServiceGUID ) const
   130     {   
   131     {   
       
   132     OstTraceFunctionEntry0( CMTPSERVICECONFIG_ISSUPPORTEDSERVICE_ENTRY );
       
   133     OstTraceFunctionExit0( CMTPSERVICECONFIG_ISSUPPORTEDSERVICE_EXIT );
   131     return !( KErrNotFound == iSupportedServices.FindInOrder( aServiceGUID, SupportedServiceOrderFromKeyAscending  ) );
   134     return !( KErrNotFound == iSupportedServices.FindInOrder( aServiceGUID, SupportedServiceOrderFromKeyAscending  ) );
   132     }
   135     }
   133 
   136 
   134 void CMTPServiceConfig::LoadServiceDataL( const TMTPTypeGuid& aServiceGUID )
   137 void CMTPServiceConfig::LoadServiceDataL( const TMTPTypeGuid& aServiceGUID )
   135     {
   138     {
   136     __FLOG(_L8("CMTPServiceConfig::LoadServiceDataL - Entry"));
   139     OstTraceFunctionEntry0( CMTPSERVICECONFIG_LOADSERVICEDATAL_ENTRY );
   137     
   140     
   138     RResourceFile file;
   141     RResourceFile file;
   139     file.OpenL( iRFs, KMTPServiceCofigfile );
   142     file.OpenL( iRFs, KMTPServiceCofigfile );
   140     CleanupClosePushL(file);
   143     CleanupClosePushL(file);
   141    
   144    
   197     
   200     
   198     iServiceInfos.AppendL(serviceInfo);
   201     iServiceInfos.AppendL(serviceInfo);
   199     CleanupStack::Pop(serviceInfo);
   202     CleanupStack::Pop(serviceInfo);
   200     CleanupStack::PopAndDestroy(buffer);
   203     CleanupStack::PopAndDestroy(buffer);
   201     CleanupStack::PopAndDestroy(&file);
   204     CleanupStack::PopAndDestroy(&file);
   202     
   205 
   203     __FLOG(_L8("CMTPServiceConfig::LoadServiceDataL - Exit"));
   206     OstTraceFunctionExit0( CMTPSERVICECONFIG_LOADSERVICEDATAL_EXIT );
   204     }
   207     }
   205 
   208 
   206 void CMTPServiceConfig::StartReadUseServicesL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
   209 void CMTPServiceConfig::StartReadUseServicesL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
   207     {
   210     {
   208     __FLOG(_L8("CMTPServiceConfig::StartReadUseServices - Entry"));
   211     OstTraceFunctionEntry0( CMTPSERVICECONFIG_STARTREADUSESERVICESL_ENTRY );
   209     
   212     
   210     // Create the resource reader.
   213     // Create the resource reader.
   211     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   214     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   212     TResourceReader reader;
   215     TResourceReader reader;
   213     reader.SetBuffer(buffer);
   216     reader.SetBuffer(buffer);
   218         TMTPTypeGuid KGUID(ReadGUID(reader));
   221         TMTPTypeGuid KGUID(ReadGUID(reader));
   219         aServiceInfo.AppendUserServiceL( KGUID );
   222         aServiceInfo.AppendUserServiceL( KGUID );
   220         }
   223         }
   221     
   224     
   222     CleanupStack::PopAndDestroy(buffer);
   225     CleanupStack::PopAndDestroy(buffer);
   223     
   226 
   224     __FLOG(_L8("CMTPServiceConfig::StartReadUseServices - Exit"));
   227     OstTraceFunctionExit0( CMTPSERVICECONFIG_STARTREADUSESERVICESL_EXIT );
   225     }
   228     }
   226 
   229 
   227 void CMTPServiceConfig::StartReadServicePropertyNamespacesL(  RResourceFile& aResFile, const TUint aResID, RArray<TMTPTypeGuid>& aNamespaces )
   230 void CMTPServiceConfig::StartReadServicePropertyNamespacesL(  RResourceFile& aResFile, const TUint aResID, RArray<TMTPTypeGuid>& aNamespaces )
   228     {
   231     {
   229     __FLOG(_L8("CMTPServiceConfig::StartReadServicePropertyNamespacesL - Entry"));
   232     OstTraceFunctionEntry0( CMTPSERVICECONFIG_STARTREADSERVICEPROPERTYNAMESPACESL_ENTRY );
   230         
   233         
   231     // Create the resource reader.
   234     // Create the resource reader.
   232     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   235     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   233     TResourceReader reader;
   236     TResourceReader reader;
   234     reader.SetBuffer(buffer);
   237     reader.SetBuffer(buffer);
   239         {
   242         {
   240         aNamespaces.AppendL( ReadGUID(reader) );
   243         aNamespaces.AppendL( ReadGUID(reader) );
   241         }
   244         }
   242     
   245     
   243     CleanupStack::PopAndDestroy(buffer);
   246     CleanupStack::PopAndDestroy(buffer);
   244     __FLOG(_L8("CMTPServiceConfig::StartReadServicePropertyNamespacesL - Exit"));
   247     OstTraceFunctionExit0( CMTPSERVICECONFIG_STARTREADSERVICEPROPERTYNAMESPACESL_EXIT );
   245     }
   248     }
   246 
   249 
   247 void CMTPServiceConfig::StartReadServicePropertiesL(  RResourceFile& aResFile, const TUint aNamespaceResID, const TUint aPropertiesResID, CMTPServiceInfo& aServiceInfo )
   250 void CMTPServiceConfig::StartReadServicePropertiesL(  RResourceFile& aResFile, const TUint aNamespaceResID, const TUint aPropertiesResID, CMTPServiceInfo& aServiceInfo )
   248     {
   251     {
   249     __FLOG(_L8("CMTPServiceConfig::StartReadServicePropertyL - Entry"));
   252     OstTraceFunctionEntry0( CMTPSERVICECONFIG_STARTREADSERVICEPROPERTIESL_ENTRY );
   250     
   253     
   251     //read namespaces
   254     //read namespaces
   252     RArray<TMTPTypeGuid> namespaces;
   255     RArray<TMTPTypeGuid> namespaces;
   253     CleanupClosePushL(namespaces);
   256     CleanupClosePushL(namespaces);
   254     StartReadServicePropertyNamespacesL(aResFile, aNamespaceResID, namespaces);
   257     StartReadServicePropertyNamespacesL(aResFile, aNamespaceResID, namespaces);
   282         }
   285         }
   283     
   286     
   284     CleanupStack::PopAndDestroy(buffer);
   287     CleanupStack::PopAndDestroy(buffer);
   285     CleanupStack::PopAndDestroy(&namespaces);
   288     CleanupStack::PopAndDestroy(&namespaces);
   286     
   289     
   287     __FLOG(_L8("CMTPServiceConfig::StartReadServicePropertyL - Exit"));
   290     OstTraceFunctionExit0( CMTPSERVICECONFIG_STARTREADSERVICEPROPERTIESL_EXIT );
   288     }
   291     }
   289 
   292 
   290 void CMTPServiceConfig::StartReadServiceFormatsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
   293 void CMTPServiceConfig::StartReadServiceFormatsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
   291     {
   294     {
   292     __FLOG(_L8("CMTPServiceConfig::StartReadServiceFormatL - Entry"));
   295     OstTraceFunctionEntry0( CMTPSERVICECONFIG_STARTREADSERVICEFORMATSL_ENTRY );
   293     
   296     
   294     // Create the resource reader.
   297     // Create the resource reader.
   295     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   298     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   296     TResourceReader reader;
   299     TResourceReader reader;
   297     reader.SetBuffer(buffer);
   300     reader.SetBuffer(buffer);
   323         CleanupStack::Pop(newElement);
   326         CleanupStack::Pop(newElement);
   324         }
   327         }
   325     
   328     
   326     CleanupStack::PopAndDestroy(buffer);
   329     CleanupStack::PopAndDestroy(buffer);
   327     
   330     
   328     __FLOG(_L8("CMTPServiceConfig::StartReadServiceFormatL - Exit"));
   331     OstTraceFunctionExit0( CMTPSERVICECONFIG_STARTREADSERVICEFORMATSL_EXIT );
   329     }
   332     }
   330 
   333 
   331 
   334 
   332 void CMTPServiceConfig::StartReadServiceMethodsL(  RResourceFile& aResFile, const TUint aResID,  CMTPServiceInfo& aServiceInfo )
   335 void CMTPServiceConfig::StartReadServiceMethodsL(  RResourceFile& aResFile, const TUint aResID,  CMTPServiceInfo& aServiceInfo )
   333     {
   336     {
   334     __FLOG(_L8("CMTPServiceConfig::StartReadServiceMethodL - Entry"));
   337     OstTraceFunctionEntry0( CMTPSERVICECONFIG_STARTREADSERVICEMETHODSL_ENTRY );
   335     
   338     
   336     // Create the resource reader.
   339     // Create the resource reader.
   337     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   340     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   338     TResourceReader reader;
   341     TResourceReader reader;
   339     reader.SetBuffer(buffer);
   342     reader.SetBuffer(buffer);
   351         CleanupStack::Pop(newElement);
   354         CleanupStack::Pop(newElement);
   352         }
   355         }
   353     
   356     
   354     CleanupStack::PopAndDestroy(buffer);
   357     CleanupStack::PopAndDestroy(buffer);
   355     
   358     
   356     __FLOG(_L8("CMTPServiceConfig::StartReadServiceMethodL - Exit"));
   359     OstTraceFunctionExit0( CMTPSERVICECONFIG_STARTREADSERVICEMETHODSL_EXIT );
   357     }
   360     }
   358 
   361 
   359 void CMTPServiceConfig::StartReadServiceEventsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
   362 void CMTPServiceConfig::StartReadServiceEventsL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
   360     {
   363     {
   361     __FLOG(_L8("CMTPServiceConfig::StartReadServiceEventsL - Entry"));
   364     OstTraceFunctionEntry0( CMTPSERVICECONFIG_STARTREADSERVICEEVENTSL_ENTRY );
   362       
   365       
   363     // Create the resource reader.
   366     // Create the resource reader.
   364     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   367     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   365     TResourceReader reader;
   368     TResourceReader reader;
   366     reader.SetBuffer(buffer);
   369     reader.SetBuffer(buffer);
   377         aServiceInfo.InsertEventL( newElement );
   380         aServiceInfo.InsertEventL( newElement );
   378         CleanupStack::Pop(newElement);
   381         CleanupStack::Pop(newElement);
   379         }
   382         }
   380       
   383       
   381     CleanupStack::PopAndDestroy(buffer);
   384     CleanupStack::PopAndDestroy(buffer);
   382     
   385 
   383       __FLOG(_L8("CMTPServiceConfig::StartReadServiceEventsL - Exit"));
   386     OstTraceFunctionExit0( CMTPSERVICECONFIG_STARTREADSERVICEEVENTSL_EXIT );
   384     }
   387     }
   385 
   388 
   386 void CMTPServiceConfig::StartReadServiceDataBlockL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
   389 void CMTPServiceConfig::StartReadServiceDataBlockL(  RResourceFile& aResFile, const TUint aResID, CMTPServiceInfo& aServiceInfo )
   387     {
   390     {
   388     __FLOG(_L8("CMTPServiceConfig::StartReadServiceDataBlockL - Entry"));
   391     OstTraceFunctionEntry0( CMTPSERVICECONFIG_STARTREADSERVICEDATABLOCKL_ENTRY );
   389     
   392     
   390     // Create the resource reader.
   393     // Create the resource reader.
   391     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   394     HBufC8* buffer(aResFile.AllocReadLC( aResID ));
   392     TResourceReader reader;
   395     TResourceReader reader;
   393     reader.SetBuffer(buffer);
   396     reader.SetBuffer(buffer);
   399               
   402               
   400         aServiceInfo.AppendDataGUIDL( guid );
   403         aServiceInfo.AppendDataGUIDL( guid );
   401         }
   404         }
   402     
   405     
   403     CleanupStack::PopAndDestroy(buffer);
   406     CleanupStack::PopAndDestroy(buffer);
   404     __FLOG(_L8("CMTPServiceConfig::StartReadServiceDataBlockL - Exit"));
   407     OstTraceFunctionExit0( CMTPSERVICECONFIG_STARTREADSERVICEDATABLOCKL_EXIT );
   405     }
   408     }
   406 
   409 
   407 CMTPServiceInfo* CMTPServiceConfig::ServiceInfo(const TMTPTypeGuid& aServiceGUID ) const
   410 CMTPServiceInfo* CMTPServiceConfig::ServiceInfo(const TMTPTypeGuid& aServiceGUID ) const
   408     {
   411     {
   409     TInt count = iServiceInfos.Count();
   412     TInt count = iServiceInfos.Count();
   416     return NULL;
   419     return NULL;
   417     }
   420     }
   418 
   421 
   419 CMTPServiceInfo* CMTPServiceConfig::ServiceInfo(const TUint aServiceID) const
   422 CMTPServiceInfo* CMTPServiceConfig::ServiceInfo(const TUint aServiceID) const
   420 	{
   423 	{
   421 	__FLOG(_L8("CMTPServiceConfig::ServiceInfo - Entry"));
   424 	OstTraceFunctionEntry0( CMTPSERVICECONFIG_SERVICEINFO_ENTRY );
   422 	
   425 	
   423 	TInt count = iServiceInfos.Count();
   426 	TInt count = iServiceInfos.Count();
   424     for(TInt i(0); i < count; i++ )
   427     for(TInt i(0); i < count; i++ )
   425         {
   428         {
   426         if(iServiceInfos[i]->ServiceID() == aServiceID)
   429         if(iServiceInfos[i]->ServiceID() == aServiceID)
   427             return iServiceInfos[i] ;
   430             return iServiceInfos[i] ;
   428         }
   431         }
   429     
   432     
   430     __FLOG(_L8("CMTPServiceConfig::ServiceInfo - Exit"));
   433     OstTraceFunctionExit0( CMTPSERVICECONFIG_SERVICEINFO_EXIT );
   431     return NULL;
   434     return NULL;
   432 	
   435 	
   433 	}
   436 	}
   434 
   437 
   435 TInt CMTPServiceConfig::ServiceTypeOfSupportedService( const TMTPTypeGuid& aServiceGUID ) const
   438 TInt CMTPServiceConfig::ServiceTypeOfSupportedService( const TMTPTypeGuid& aServiceGUID ) const
   443 
   446 
   444 TUint CMTPServiceConfig::ServiceResourceIDL( const TMTPTypeGuid& aServiceGUID ) const
   447 TUint CMTPServiceConfig::ServiceResourceIDL( const TMTPTypeGuid& aServiceGUID ) const
   445     {
   448     {
   446     TInt index = iSupportedServices.FindInOrder( aServiceGUID, SupportedServiceOrderFromKeyAscending ) ;
   449     TInt index = iSupportedServices.FindInOrder( aServiceGUID, SupportedServiceOrderFromKeyAscending ) ;
   447     if( KErrNotFound == index)
   450     if( KErrNotFound == index)
       
   451         {
       
   452         OstTrace0( TRACE_ERROR, CMTPSERVICECONFIG_SERVICERESOURCEIDL, "serviceGUID not supported" );
   448         User::Leave( KErrNotFound );
   453         User::Leave( KErrNotFound );
       
   454         }
   449     
   455     
   450     return iSupportedServices[index].iResourceID;
   456     return iSupportedServices[index].iResourceID;
   451     }
   457     }
   452 
   458 
   453 TMTPTypeGuid CMTPServiceConfig::ReadGUID( TResourceReader& aReader )
   459 TMTPTypeGuid CMTPServiceConfig::ReadGUID( TResourceReader& aReader )