mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetserviceinfo.cpp
changeset 49 c20dd21d1eb4
parent 17 aabe5387f5ce
child 52 866b4af7ffbe
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    31 
    31 
    32 #include "cmtpgetserviceinfo.h"
    32 #include "cmtpgetserviceinfo.h"
    33 #include "rmtpframework.h"
    33 #include "rmtpframework.h"
    34 #include "mtpdevdppanic.h"
    34 #include "mtpdevdppanic.h"
    35 #include "cmtpservicemgr.h"
    35 #include "cmtpservicemgr.h"
       
    36 #include "OstTraceDefinitions.h"
       
    37 #ifdef OST_TRACE_COMPILER_IN_USE
       
    38 #include "cmtpgetserviceinfoTraces.h"
       
    39 #endif
       
    40 
    36 
    41 
    37 
    42 
    38 
    43 
    39 // Class constants.
    44 // Class constants.
    40 __FLOG_STMT(_LIT8(KComponent,"GetServiceInfo");)
       
    41 
    45 
    42 /**
    46 /**
    43 Two-phase construction method
    47 Two-phase construction method
    44 @param aPlugin    The data provider plugin
    48 @param aPlugin    The data provider plugin
    45 @param aFramework    The data provider framework
    49 @param aFramework    The data provider framework
    58 /**
    62 /**
    59 Destructor.
    63 Destructor.
    60 */    
    64 */    
    61 CMTPGetServiceInfo::~CMTPGetServiceInfo()
    65 CMTPGetServiceInfo::~CMTPGetServiceInfo()
    62     {    
    66     {    
    63     __FLOG(_L8("~CMTPGetServiceInfo - Entry"));
    67     OstTraceFunctionEntry0( CMTPGETSERVICEINFO_CMTPGETSERVICEINFO_ENTRY );
    64     delete iServiceInfo;
    68     delete iServiceInfo;
    65 
    69 
    66     iSingletons.Close();
    70     iSingletons.Close();
    67     __FLOG(_L8("~CMTPGetServiceInfo - Exit"));
    71     OstTraceFunctionExit0( CMTPGETSERVICEINFO_CMTPGETSERVICEINFO_EXIT );
    68     __FLOG_CLOSE;
       
    69     }
    72     }
    70 
    73 
    71 /**
    74 /**
    72 Constructor.
    75 Constructor.
    73 */    
    76 */    
    80 /**
    83 /**
    81 GetServiceInfo request handler. Build and send device info data set.
    84 GetServiceInfo request handler. Build and send device info data set.
    82 */    
    85 */    
    83 void CMTPGetServiceInfo::ServiceL()
    86 void CMTPGetServiceInfo::ServiceL()
    84     {
    87     {
    85     __FLOG(_L8("ServiceL - Entry"));
    88     OstTraceFunctionEntry0( CMTPGETSERVICEINFO_SERVICEL_ENTRY );
    86        
    89        
    87     TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    90     TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    88     if ( KErrNotFound == iSingletons.ServiceMgr().GetServiceIDs().Find(serviceId) )
    91     if ( KErrNotFound == iSingletons.ServiceMgr().GetServiceIDs().Find(serviceId) )
    89     	{
    92     	{
    90     	SendResponseL(EMTPRespCodeInvalidServiceID);
    93     	SendResponseL(EMTPRespCodeInvalidServiceID);
   102         //    1. DP plugin does not register the ServiceID by the Supported() function. Mostly.
   105         //    1. DP plugin does not register the ServiceID by the Supported() function. Mostly.
   103         //    2. Framework have some errors while setup the router mapping table.
   106         //    2. Framework have some errors while setup the router mapping table.
   104         __DEBUG_ONLY(Panic(EMTPDevDpUnknownServiceID));
   107         __DEBUG_ONLY(Panic(EMTPDevDpUnknownServiceID));
   105         }
   108         }
   106     
   109     
   107     __FLOG(_L8("ServiceL - Exit"));
   110     OstTraceFunctionExit0( CMTPGETSERVICEINFO_SERVICEL_EXIT );
   108     }
   111     }
   109 
   112 
   110 /**
   113 /**
   111 Second-phase constructor.
   114 Second-phase constructor.
   112 */        
   115 */        
   113 void CMTPGetServiceInfo::ConstructL()
   116 void CMTPGetServiceInfo::ConstructL()
   114     {
   117     {
   115     __FLOG_OPEN(KMTPSubsystem, KComponent);
   118     OstTraceFunctionEntry0( CMTPGETSERVICEINFO_CONSTRUCTL_ENTRY );
   116     __FLOG(_L8("ConstructL - Entry")); 
       
   117     iSingletons.OpenL();
   119     iSingletons.OpenL();
   118     __FLOG(_L8("ConstructL - Exit")); 
   120     OstTraceFunctionExit0( CMTPGETSERVICEINFO_CONSTRUCTL_EXIT );
   119     }
   121     }
   120 
   122 
   121 /**
   123 /**
   122 Populates service info data set
   124 Populates service info data set
   123 */
   125 */
   124 void CMTPGetServiceInfo::BuildServiceInfoL()
   126 void CMTPGetServiceInfo::BuildServiceInfoL()
   125     {
   127     {
   126     __FLOG(_L8("BuildServiceInfoL - Entry")); 
   128     OstTraceFunctionEntry0( CMTPGETSERVICEINFO_BUILDSERVICEINFOL_ENTRY );
   127     
   129     
   128     delete iServiceInfo;
   130     delete iServiceInfo;
   129     iServiceInfo = CMTPTypeServiceInfo::NewL();
   131     iServiceInfo = CMTPTypeServiceInfo::NewL();
   130     
   132     
   131     TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   133     TUint32 serviceId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   132     CMTPServiceInfo* svcinfo = iSingletons.ServiceMgr().ServiceInfo( serviceId );
   134     CMTPServiceInfo* svcinfo = iSingletons.ServiceMgr().ServiceInfo( serviceId );
   133     if( NULL == svcinfo )
   135     if( NULL == svcinfo )
   134         {
   136         {
   135         __FLOG_1(_L8("BuildServiceInfoL - CMTPServiceInfo is NULL!!! ServiceID is %d."),serviceId ); 
   137         OstTrace1( TRACE_WARNING, CMTPGETSERVICEINFO_BUILDSERVICEINFOL, 
   136         __FLOG(_L8("BuildServiceInfoL - Exit")); 
   138                 "BuildServiceInfoL - CMTPServiceInfo is NULL!!! ServiceID is %d.", serviceId );        
       
   139         OstTraceFunctionExit0( CMTPGETSERVICEINFO_BUILDSERVICEINFOL_EXIT );
   137         return;
   140         return;
   138         }
   141         }
   139     BuildServiceInfoHeadL(*svcinfo);
   142     BuildServiceInfoHeadL(*svcinfo);
   140     BuildUsedServiceGUIDL(*svcinfo);
   143     BuildUsedServiceGUIDL(*svcinfo);
   141 	BuildServicePropertyL(*svcinfo);
   144 	BuildServicePropertyL(*svcinfo);
   142 	BuildServiceFormatL(*svcinfo);
   145 	BuildServiceFormatL(*svcinfo);
   143 	BuildServiceMethodL(*svcinfo);
   146 	BuildServiceMethodL(*svcinfo);
   144 	BuildDataBlockL(*svcinfo);    
   147 	BuildDataBlockL(*svcinfo);    
   145     
   148 
   146     __FLOG(_L8("BuildServiceInfoL - Exit")); 
   149     OstTraceFunctionExit0( DUP1_CMTPGETSERVICEINFO_BUILDSERVICEINFOL_EXIT );
   147     }
   150     }
   148 
   151 
   149 
   152 
   150 void CMTPGetServiceInfo::BuildServiceInfoHeadL(CMTPServiceInfo& aServiceInfo)
   153 void CMTPGetServiceInfo::BuildServiceInfoHeadL(CMTPServiceInfo& aServiceInfo)
   151 	{
   154 	{
   152 	__FLOG(_L8("BuildServiceInfoHeadL - Entry"));
   155 	OstTraceFunctionEntry0( CMTPGETSERVICEINFO_BUILDSERVICEINFOHEADL_ENTRY );
   153 	
   156 	
   154 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceID,aServiceInfo.ServiceID());
   157 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceID,aServiceInfo.ServiceID());
   155 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceStorageID,aServiceInfo.ServiceStorageID());
   158 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceStorageID,aServiceInfo.ServiceStorageID());
   156 	iServiceInfo->SetL(CMTPTypeServiceInfo::EServicePGUID,aServiceInfo.ServicePersistentGUID());
   159 	iServiceInfo->SetL(CMTPTypeServiceInfo::EServicePGUID,aServiceInfo.ServicePersistentGUID());
   157 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceVersion,aServiceInfo.ServiceVersion());
   160 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceVersion,aServiceInfo.ServiceVersion());
   158 	iServiceInfo->SetL(CMTPTypeServiceInfo::EServiceGUID,aServiceInfo.ServiceGUID());
   161 	iServiceInfo->SetL(CMTPTypeServiceInfo::EServiceGUID,aServiceInfo.ServiceGUID());
   159 	iServiceInfo->SetStringL(CMTPTypeServiceInfo::EServiceName,aServiceInfo.ServiceName());
   162 	iServiceInfo->SetStringL(CMTPTypeServiceInfo::EServiceName,aServiceInfo.ServiceName());
   160 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceType,aServiceInfo.ServiceType());
   163 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EServiceType,aServiceInfo.ServiceType());
   161 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EBaseServiceID,aServiceInfo.BaseServiceID());
   164 	iServiceInfo->SetUint32L(CMTPTypeServiceInfo::EBaseServiceID,aServiceInfo.BaseServiceID());
   162 	
   165 
   163 	__FLOG(_L8("BuildServiceInfoHeadL - Exit")); 
   166 	OstTraceFunctionExit0( CMTPGETSERVICEINFO_BUILDSERVICEINFOHEADL_EXIT );
   164 	}
   167 	}
   165 
   168 
   166 void CMTPGetServiceInfo::BuildUsedServiceGUIDL(CMTPServiceInfo& aServiceInfo)
   169 void CMTPGetServiceInfo::BuildUsedServiceGUIDL(CMTPServiceInfo& aServiceInfo)
   167 	{
   170 	{
   168 	__FLOG(_L8("BuildUsedServiceGUIDL - Entry"));
   171 	OstTraceFunctionEntry0( CMTPGETSERVICEINFO_BUILDUSEDSERVICEGUIDL_ENTRY );
   169 	TInt count = aServiceInfo.UsedServiceGUIDs().Count();
   172 	TInt count = aServiceInfo.UsedServiceGUIDs().Count();
   170 	const RArray<TMTPTypeGuid> UsedServiceGUIDs = aServiceInfo.UsedServiceGUIDs();
   173 	const RArray<TMTPTypeGuid> UsedServiceGUIDs = aServiceInfo.UsedServiceGUIDs();
   171 	for (TInt i=0;i<count;i++)
   174 	for (TInt i=0;i<count;i++)
   172 		{
   175 		{
   173           iServiceInfo->AppendUsedServiceL( UsedServiceGUIDs[i] );
   176           iServiceInfo->AppendUsedServiceL( UsedServiceGUIDs[i] );
   174 		}
   177 		}
   175 	
   178 	
   176 	__FLOG(_L8("BuildUsedServiceGUIDL - Exit"));
   179 	OstTraceFunctionExit0( CMTPGETSERVICEINFO_BUILDUSEDSERVICEGUIDL_EXIT );
   177 	}
   180 	}
   178 
   181 
   179 void CMTPGetServiceInfo::BuildServicePropertyL(CMTPServiceInfo& aServiceInfo)
   182 void CMTPGetServiceInfo::BuildServicePropertyL(CMTPServiceInfo& aServiceInfo)
   180 	{
   183 	{
   181 	__FLOG(_L8("BuildServicePropertyL - Entry"));
   184 	OstTraceFunctionEntry0( CMTPGETSERVICEINFO_BUILDSERVICEPROPERTYL_ENTRY );
   182 
   185 
   183 	TInt count = aServiceInfo.ServiceProperties().Count();
   186 	TInt count = aServiceInfo.ServiceProperties().Count();
   184 	CMTPTypeServicePropertyElement* PropElement = NULL;
   187 	CMTPTypeServicePropertyElement* PropElement = NULL;
   185 	CServiceProperty* prop = NULL;
   188 	CServiceProperty* prop = NULL;
   186 	const RPointerArray<CServiceProperty> ServiceProperties = aServiceInfo.ServiceProperties();
   189 	const RPointerArray<CServiceProperty> ServiceProperties = aServiceInfo.ServiceProperties();
   193 		PropElement = CMTPTypeServicePropertyElement::NewLC(prop->Code(),prop->Namespace(),prop->PKeyID(), prop->Name());
   196 		PropElement = CMTPTypeServicePropertyElement::NewLC(prop->Code(),prop->Namespace(),prop->PKeyID(), prop->Name());
   194 		iServiceInfo->ServicePropList().AppendL(PropElement);
   197 		iServiceInfo->ServicePropList().AppendL(PropElement);
   195 		CleanupStack::Pop(PropElement);
   198 		CleanupStack::Pop(PropElement);
   196 		}
   199 		}
   197 	
   200 	
   198 	__FLOG(_L8("BuildServicePropertyL - Exit"));
   201 	OstTraceFunctionExit0( CMTPGETSERVICEINFO_BUILDSERVICEPROPERTYL_EXIT );
   199 	}
   202 	}
   200 
   203 
   201 void CMTPGetServiceInfo::BuildServiceFormatL(CMTPServiceInfo& aServiceInfo)
   204 void CMTPGetServiceInfo::BuildServiceFormatL(CMTPServiceInfo& aServiceInfo)
   202 	{
   205 	{
   203 	__FLOG(_L8("BuildServiceFormatL - Entry"));
   206 	OstTraceFunctionEntry0( CMTPGETSERVICEINFO_BUILDSERVICEFORMATL_ENTRY );
   204 
   207 
   205 	CMTPTypeServiceFormatElement* FormatElement = NULL; 
   208 	CMTPTypeServiceFormatElement* FormatElement = NULL; 
   206 	CServiceFormat* format = NULL;  
   209 	CServiceFormat* format = NULL;  
   207 	TInt count = aServiceInfo.ServiceFormats().Count();
   210 	TInt count = aServiceInfo.ServiceFormats().Count();
   208 	const RPointerArray<CServiceFormat> ServiceFormats = aServiceInfo.ServiceFormats();
   211 	const RPointerArray<CServiceFormat> ServiceFormats = aServiceInfo.ServiceFormats();
   215 		FormatElement = CMTPTypeServiceFormatElement::NewLC( format->Code(), format->GUID(), format->Name(), format->FormatBase(), format->MIMEType1() );
   218 		FormatElement = CMTPTypeServiceFormatElement::NewLC( format->Code(), format->GUID(), format->Name(), format->FormatBase(), format->MIMEType1() );
   216 		iServiceInfo->ServiceFormatList().AppendL(FormatElement);
   219 		iServiceInfo->ServiceFormatList().AppendL(FormatElement);
   217 		CleanupStack::Pop(FormatElement);
   220 		CleanupStack::Pop(FormatElement);
   218 		}
   221 		}
   219 	
   222 	
   220 	__FLOG(_L8("BuildServiceFormatL - Exit"));
   223 	OstTraceFunctionExit0( CMTPGETSERVICEINFO_BUILDSERVICEFORMATL_EXIT );
   221 	}
   224 	}
   222 
   225 
   223 void CMTPGetServiceInfo::BuildServiceMethodL(CMTPServiceInfo& aServiceInfo)
   226 void CMTPGetServiceInfo::BuildServiceMethodL(CMTPServiceInfo& aServiceInfo)
   224 	{
   227 	{
   225 	__FLOG(_L8("BuildServiceMethodL - Entry"));
   228 	OstTraceFunctionEntry0( CMTPGETSERVICEINFO_BUILDSERVICEMETHODL_ENTRY );
   226 
   229 
   227 	CMTPTypeServiceMethodElement* methodElement = NULL;
   230 	CMTPTypeServiceMethodElement* methodElement = NULL;
   228 	CServiceMethod* method = NULL;
   231 	CServiceMethod* method = NULL;
   229 	TInt count = aServiceInfo.ServiceMethods().Count();
   232 	TInt count = aServiceInfo.ServiceMethods().Count();
   230 	const RPointerArray<CServiceMethod> ServiceMethods = aServiceInfo.ServiceMethods();
   233 	const RPointerArray<CServiceMethod> ServiceMethods = aServiceInfo.ServiceMethods();
   236 		methodElement = CMTPTypeServiceMethodElement::NewLC( method->Code(), method->GUID(), method->Name(), method->ObjAssociateFormatCode() );
   239 		methodElement = CMTPTypeServiceMethodElement::NewLC( method->Code(), method->GUID(), method->Name(), method->ObjAssociateFormatCode() );
   237 		iServiceInfo->ServiceMethodList().AppendL(methodElement);
   240 		iServiceInfo->ServiceMethodList().AppendL(methodElement);
   238 		CleanupStack::Pop(methodElement);		
   241 		CleanupStack::Pop(methodElement);		
   239 		}
   242 		}
   240 	
   243 	
   241 	__FLOG(_L8("BuildServiceMethodL - Exit"));
   244 	OstTraceFunctionExit0( CMTPGETSERVICEINFO_BUILDSERVICEMETHODL_EXIT );
   242 	}
   245 	}
   243 
   246 
   244 
   247 
   245 void CMTPGetServiceInfo::BuildDataBlockL(CMTPServiceInfo& aServiceInfo)
   248 void CMTPGetServiceInfo::BuildDataBlockL(CMTPServiceInfo& aServiceInfo)
   246     {
   249     {
   247     __FLOG(_L8("BuildDataBlockL - Entry"));
   250     OstTraceFunctionEntry0( CMTPGETSERVICEINFO_BUILDDATABLOCKL_ENTRY );
   248     TInt count = aServiceInfo.DataBlockGUIDs().Count();
   251     TInt count = aServiceInfo.DataBlockGUIDs().Count();
   249     const RArray<TMTPTypeGuid> DataBlockGUIDs = aServiceInfo.DataBlockGUIDs();
   252     const RArray<TMTPTypeGuid> DataBlockGUIDs = aServiceInfo.DataBlockGUIDs();
   250     for (TInt i=0;i<count;i++)
   253     for (TInt i=0;i<count;i++)
   251         {
   254         {
   252         iServiceInfo->AppendServiceDataBlockL( DataBlockGUIDs[i] );
   255         iServiceInfo->AppendServiceDataBlockL( DataBlockGUIDs[i] );
   253         }
   256         }
   254 
   257     
   255     __FLOG(_L8("BuildDataBlockL - Exit"));
   258     OstTraceFunctionExit0( CMTPGETSERVICEINFO_BUILDDATABLOCKL_EXIT );
   256     }
   259     }
   257 
   260 
   258 
   261