mtpfws/mtpfw/dataproviders/dputility/src/cmtpabstractdatacodemgr.cpp
changeset 49 c20dd21d1eb4
parent 0 d0791faffa3f
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    16 #include <mtp/mmtpstoragemgr.h>
    16 #include <mtp/mmtpstoragemgr.h>
    17 #include <mtp/mmtpdataproviderframework.h>
    17 #include <mtp/mmtpdataproviderframework.h>
    18 #include <mtp/mmtpdatacodegenerator.h>
    18 #include <mtp/mmtpdatacodegenerator.h>
    19 
    19 
    20 #include "cmtpabstractdatacodemgr.h"
    20 #include "cmtpabstractdatacodemgr.h"
    21 
    21 #include "mtpdebug.h"
    22 __FLOG_STMT(_LIT8(KComponent, "FullEnumDataCodeMgr");)
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "cmtpabstractdatacodemgrTraces.h"
       
    25 #endif
       
    26 
    23 
    27 
    24 EXPORT_C RMTPServiceFormat::~RMTPServiceFormat()
    28 EXPORT_C RMTPServiceFormat::~RMTPServiceFormat()
    25 	{
    29 	{
    26 	iProps.Close();
    30 	iProps.Close();
    27 	}
    31 	}
    51 	}
    55 	}
    52 
    56 
    53 
    57 
    54 EXPORT_C CMTPFullEnumDataCodeMgr::~CMTPFullEnumDataCodeMgr()
    58 EXPORT_C CMTPFullEnumDataCodeMgr::~CMTPFullEnumDataCodeMgr()
    55 	{
    59 	{
    56 	__FLOG(_L8("~CMTPFullEnumDataCodeMgr - Entry"));
    60 	OstTraceFunctionEntry0( CMTPFULLENUMDATACODEMGR_CMTPFULLENUMDATACODEMGR_DES_ENTRY );
    57 	delete iKnowledgeFormat;
    61 	delete iKnowledgeFormat;
    58 	iServiceProperties.Close();
    62 	iServiceProperties.Close();
    59 	__FLOG(_L8("~CMTPFullEnumDataCodeMgr - Exit"));
    63 	OstTraceFunctionExit0( CMTPFULLENUMDATACODEMGR_CMTPFULLENUMDATACODEMGR_DES_EXIT );
    60 	__FLOG_CLOSE;
       
    61 	}
    64 	}
    62 
    65 
    63 CMTPFullEnumDataCodeMgr::CMTPFullEnumDataCodeMgr(MMTPDataProviderFramework& aFramework) :
    66 CMTPFullEnumDataCodeMgr::CMTPFullEnumDataCodeMgr(MMTPDataProviderFramework& aFramework) :
    64 		iFramework(aFramework),
    67 		iFramework(aFramework),
    65 		iServiceGUID(MAKE_TUINT64(KMTPFullEnumServiceGUID[0], KMTPFullEnumServiceGUID[1]),
    68 		iServiceGUID(MAKE_TUINT64(KMTPFullEnumServiceGUID[0], KMTPFullEnumServiceGUID[1]),
    69 	{
    72 	{
    70 	}
    73 	}
    71 
    74 
    72 void CMTPFullEnumDataCodeMgr::ConstructL()
    75 void CMTPFullEnumDataCodeMgr::ConstructL()
    73 	{
    76 	{
    74 	__FLOG_OPEN(KMTPSubsystem, KComponent);
    77 	OstTraceFunctionEntry0( CMTPFULLENUMDATACODEMGR_CONSTRUCTL_ENTRY );
    75 	__FLOG(_L8("ConstructL - Entry"));
       
    76 	BuildServiceIDL();
    78 	BuildServiceIDL();
    77 	BuildFormatL();
    79 	BuildFormatL();
    78 	BuildServicePropertyL();
    80 	BuildServicePropertyL();
    79 	__FLOG(_L8("ConstructL - Exit"));
    81 	OstTraceFunctionExit0( CMTPFULLENUMDATACODEMGR_CONSTRUCTL_EXIT );
    80 	}
    82 	}
    81 
    83 
    82 EXPORT_C TUint CMTPFullEnumDataCodeMgr::ServiceID() const
    84 EXPORT_C TUint CMTPFullEnumDataCodeMgr::ServiceID() const
    83 	{
    85 	{
    84 	return iServiceID;
    86 	return iServiceID;
    89 	return iServiceGUID;
    91 	return iServiceGUID;
    90 	}
    92 	}
    91 
    93 
    92 void CMTPFullEnumDataCodeMgr::BuildServiceIDL()
    94 void CMTPFullEnumDataCodeMgr::BuildServiceIDL()
    93 	{
    95 	{
    94 	__FLOG(_L8("BuildServiceIDL - Entry"));
    96 	OstTraceFunctionEntry0( CMTPFULLENUMDATACODEMGR_BUILDSERVICEIDL_ENTRY );
    95 	//Allocate abstract service ID
    97 	//Allocate abstract service ID
    96 	User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServiceID(
    98 	LEAVEIFERROR(iFramework.DataCodeGenerator().AllocateServiceID(
    97 						   iPersistentServiceGUID,
    99 						   iPersistentServiceGUID,
    98 						   EMTPServiceTypeAbstract,
   100 						   EMTPServiceTypeAbstract,
    99 						   iServiceID));
   101 						   iServiceID),
   100 	__FLOG(_L8("BuildServiceIDL - Exit"));
   102                            OstTrace0( TRACE_ERROR, CMTPFULLENUMDATACODEMGR_BUILDSERVICEIDL, 
       
   103                                    "allocate abstract service ID faled!" ));
       
   104 						   
       
   105 	OstTraceFunctionExit0( CMTPFULLENUMDATACODEMGR_BUILDSERVICEIDL_EXIT );
   101 	}
   106 	}
   102 
   107 
   103 void CMTPFullEnumDataCodeMgr::BuildFormatL()
   108 void CMTPFullEnumDataCodeMgr::BuildFormatL()
   104 	{
   109 	{
   105 	__FLOG(_L8("BuildFormatL - Entry"));
   110 	OstTraceFunctionEntry0( CMTPFULLENUMDATACODEMGR_BUILDFORMATL_ENTRY );
   106 
   111 
   107 
   112 
   108 	iKnowledgeFormat = new(ELeave) RMTPServiceFormat;
   113 	iKnowledgeFormat = new(ELeave) RMTPServiceFormat;
   109 	iKnowledgeFormat->iIndex = EMTPFormatTypeFullEnumSyncKnowledge;
   114 	iKnowledgeFormat->iIndex = EMTPFormatTypeFullEnumSyncKnowledge;
   110 	iKnowledgeFormat->iFormatCode = 0;
   115 	iKnowledgeFormat->iFormatCode = 0;
   113 		MAKE_TUINT64(KMTPFullEnumSyncKnowledgeFormatGUID[2], KMTPFullEnumSyncKnowledgeFormatGUID[3]));
   118 		MAKE_TUINT64(KMTPFullEnumSyncKnowledgeFormatGUID[2], KMTPFullEnumSyncKnowledgeFormatGUID[3]));
   114 	iKnowledgeFormat->iFormatGUID = KMTPKnowledgeFormatGUID;
   119 	iKnowledgeFormat->iFormatGUID = KMTPKnowledgeFormatGUID;
   115 	iKnowledgeFormat->iBaseFormatCode = KBaseFormatCode;
   120 	iKnowledgeFormat->iBaseFormatCode = KBaseFormatCode;
   116 	iKnowledgeFormat->iFormatName.Set(KNameFullEnumSyncKnowledege());
   121 	iKnowledgeFormat->iFormatName.Set(KNameFullEnumSyncKnowledege());
   117 	iKnowledgeFormat->iMIMEType.Set(KNameFullEnumSyncKnowledegeMIMEType());
   122 	iKnowledgeFormat->iMIMEType.Set(KNameFullEnumSyncKnowledegeMIMEType());
   118 	User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServiceFormatCode(
   123 	LEAVEIFERROR(iFramework.DataCodeGenerator().AllocateServiceFormatCode(
   119 						   iPersistentServiceGUID,
   124 						   iPersistentServiceGUID,
   120 						   iKnowledgeFormat->iFormatGUID,
   125 						   iKnowledgeFormat->iFormatGUID,
   121 						   iKnowledgeFormat->iFormatCode));
   126 						   iKnowledgeFormat->iFormatCode),
       
   127 						   OstTrace0( TRACE_ERROR, CMTPFULLENUMDATACODEMGR_BUILDFORMATL, 
       
   128 						           "allocate service format code failed!" ));
       
   129 						   
   122 	TUint propertyCount = sizeof(KMTPFullEnumSyncKnowledgeObjectProperties) / sizeof(KMTPFullEnumSyncKnowledgeObjectProperties[0]);
   130 	TUint propertyCount = sizeof(KMTPFullEnumSyncKnowledgeObjectProperties) / sizeof(KMTPFullEnumSyncKnowledgeObjectProperties[0]);
   123 	for (TUint j = 0; j < propertyCount; j++)
   131 	for (TUint j = 0; j < propertyCount; j++)
   124 		{
   132 		{
   125 		iKnowledgeFormat->iProps.AppendL(KMTPFullEnumSyncKnowledgeObjectProperties[j]);
   133 		iKnowledgeFormat->iProps.AppendL(KMTPFullEnumSyncKnowledgeObjectProperties[j]);
   126 		}
   134 		}
   127 
   135 
   128 	__FLOG(_L8("BuildFormatL - Exit"));
   136 	OstTraceFunctionExit0( CMTPFULLENUMDATACODEMGR_BUILDFORMATL_EXIT );
   129 	}
   137 	}
   130 
   138 
   131 void CMTPFullEnumDataCodeMgr::BuildServicePropertyL()
   139 void CMTPFullEnumDataCodeMgr::BuildServicePropertyL()
   132 	{
   140 	{
   133 	__FLOG(_L8("BuildServicePropertyL - Entry"));
   141 	OstTraceFunctionEntry0( CMTPFULLENUMDATACODEMGR_BUILDSERVICEPROPERTYL_ENTRY );
   134 
   142 
   135 	const TMTPTypeGuid KMTPFullEnumSyncServiceNamespace(
   143 	const TMTPTypeGuid KMTPFullEnumSyncServiceNamespace(
   136 		MAKE_TUINT64(KMTPFullEnumSyncServiceNSGUID[0], KMTPFullEnumSyncServiceNSGUID[1]),
   144 		MAKE_TUINT64(KMTPFullEnumSyncServiceNSGUID[0], KMTPFullEnumSyncServiceNSGUID[1]),
   137 		MAKE_TUINT64(KMTPFullEnumSyncServiceNSGUID[2], KMTPFullEnumSyncServiceNSGUID[3]));
   145 		MAKE_TUINT64(KMTPFullEnumSyncServiceNSGUID[2], KMTPFullEnumSyncServiceNSGUID[3]));
   138 
   146 
   157 	TUint propCount = sizeof(KMTPFullEnumSyncServiceProperties) / sizeof(KMTPFullEnumSyncServiceProperties[0]);
   165 	TUint propCount = sizeof(KMTPFullEnumSyncServiceProperties) / sizeof(KMTPFullEnumSyncServiceProperties[0]);
   158 
   166 
   159 	for (TUint i = 0; i < propCount; i++)
   167 	for (TUint i = 0; i < propCount; i++)
   160 		{
   168 		{
   161 		TMTPServicePropertyInfo servicePropertyInfo = KMTPFullEnumSyncServiceProperties[i];
   169 		TMTPServicePropertyInfo servicePropertyInfo = KMTPFullEnumSyncServiceProperties[i];
   162 		User::LeaveIfError(iFramework.DataCodeGenerator().AllocateServicePropertyCode(iPersistentServiceGUID,
   170 		LEAVEIFERROR(iFramework.DataCodeGenerator().AllocateServicePropertyCode(iPersistentServiceGUID,
   163 						   servicePropertyInfo.iServicePropPKeyNamespace, servicePropertyInfo.iServicePropPKeyID, servicePropertyInfo.iServicePropCode));
   171 						   servicePropertyInfo.iServicePropPKeyNamespace, servicePropertyInfo.iServicePropPKeyID, servicePropertyInfo.iServicePropCode),
       
   172 						   OstTrace0( TRACE_ERROR, CMTPFULLENUMDATACODEMGR_BUILDSERVICEPROPERTYL, "allocate service property code failed!" ));
   164 		iServiceProperties.InsertInOrder(servicePropertyInfo, TMTPServicePropertyInfo::LinearOrderServicePropOrder);
   173 		iServiceProperties.InsertInOrder(servicePropertyInfo, TMTPServicePropertyInfo::LinearOrderServicePropOrder);
   165 		}
   174 		}
   166 
   175 
   167 	__FLOG(_L8("BuildServicePropertyL - Exit"));
   176 	OstTraceFunctionExit0( CMTPFULLENUMDATACODEMGR_BUILDSERVICEPROPERTYL_EXIT );
   168 	}
   177 	}
   169 
   178 
   170 EXPORT_C void CMTPFullEnumDataCodeMgr::GetSevicePropCodesL(RArray<TUint32>& aArray) const
   179 EXPORT_C void CMTPFullEnumDataCodeMgr::GetSevicePropCodesL(RArray<TUint32>& aArray) const
   171 	{
   180 	{
   172 	__FLOG(_L8("GetSevicePropCodesL - Entry"));
   181 	OstTraceFunctionEntry0( CMTPFULLENUMDATACODEMGR_GETSEVICEPROPCODESL_ENTRY );
   173 	TInt count = iServiceProperties.Count();
   182 	TInt count = iServiceProperties.Count();
   174 	for (TInt i = 0; i < count; i++)
   183 	for (TInt i = 0; i < count; i++)
   175 		{
   184 		{
   176 		aArray.AppendL(iServiceProperties[i].iServicePropCode);
   185 		aArray.AppendL(iServiceProperties[i].iServicePropCode);
   177 		}
   186 		}
   178 	__FLOG(_L8("GetSevicePropCodesL - Exit"));
   187 	OstTraceFunctionExit0( CMTPFULLENUMDATACODEMGR_GETSEVICEPROPCODESL_EXIT );
   179 	}
   188 	}
   180 
   189 
   181 EXPORT_C const RMTPServiceFormat& CMTPFullEnumDataCodeMgr::KnowledgeFormat() const
   190 EXPORT_C const RMTPServiceFormat& CMTPFullEnumDataCodeMgr::KnowledgeFormat() const
   182 	{
   191 	{
   183 	// only Knowledge Format supported in FullEnum Sync Service
   192 	// only Knowledge Format supported in FullEnum Sync Service
   188 /**
   197 /**
   189 The property code must be valid to call this func
   198 The property code must be valid to call this func
   190 */
   199 */
   191 EXPORT_C const TMTPServicePropertyInfo* CMTPFullEnumDataCodeMgr::ServicePropertyInfo(TUint16 aPropCode) const
   200 EXPORT_C const TMTPServicePropertyInfo* CMTPFullEnumDataCodeMgr::ServicePropertyInfo(TUint16 aPropCode) const
   192 	{
   201 	{
   193 	__FLOG(_L8("ServicePropertyInfo - Entry"));
   202 	OstTraceFunctionEntry0( CMTPFULLENUMDATACODEMGR_SERVICEPROPERTYINFO_ENTRY );
   194 	const TMTPServicePropertyInfo* pPropInfo = NULL;
   203 	const TMTPServicePropertyInfo* pPropInfo = NULL;
   195 	TInt index = iServiceProperties.FindInOrder(aPropCode, TMTPServicePropertyInfo::LinearOrderServicePropOrder);
   204 	TInt index = iServiceProperties.FindInOrder(aPropCode, TMTPServicePropertyInfo::LinearOrderServicePropOrder);
   196 	if (KErrNotFound != index)
   205 	if (KErrNotFound != index)
   197 		{
   206 		{
   198 		pPropInfo = &(iServiceProperties[index]);
   207 		pPropInfo = &(iServiceProperties[index]);
   199 		}
   208 		}
   200 	__FLOG(_L8("ServicePropertyInfo - Exit"));
   209 	OstTraceFunctionExit0( CMTPFULLENUMDATACODEMGR_SERVICEPROPERTYINFO_EXIT );
   201 	return pPropInfo;
   210 	return pPropInfo;
   202 	}
   211 	}
   203 
   212 
   204 
   213