mtpfws/mtpfw/dataproviders/dputility/src/cmtpfullenumservicehandler.cpp
changeset 47 63cf70d3ecd8
parent 17 aabe5387f5ce
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    23 #include <mtp/cmtpobjectmetadata.h>
    23 #include <mtp/cmtpobjectmetadata.h>
    24 
    24 
    25 #include "mtpsvcdpconst.h"
    25 #include "mtpsvcdpconst.h"
    26 #include "cmtpfullenumservicehandler.h"
    26 #include "cmtpfullenumservicehandler.h"
    27 #include "cmtpabstractdatacodemgr.h"
    27 #include "cmtpabstractdatacodemgr.h"
    28 
    28 #include "mtpdebug.h"
    29 // Class constants.
    29 #include "OstTraceDefinitions.h"
    30 __FLOG_STMT(_LIT8(KComponent, "FullEnumServiceHandler");)
    30 #ifdef OST_TRACE_COMPILER_IN_USE
       
    31 #include "cmtpfullenumservicehandlerTraces.h"
       
    32 #endif
       
    33 
       
    34 
    31 
    35 
    32 EXPORT_C CMTPFullEnumServiceHandler* CMTPFullEnumServiceHandler::NewL(MMTPDataProviderFramework& aFramework,
    36 EXPORT_C CMTPFullEnumServiceHandler* CMTPFullEnumServiceHandler::NewL(MMTPDataProviderFramework& aFramework,
    33 		const CMTPFullEnumDataCodeMgr& aDataCodeMgr,
    37 		const CMTPFullEnumDataCodeMgr& aDataCodeMgr,
    34 		CRepository& aRepository,
    38 		CRepository& aRepository,
    35 		TUint aNormalServiceID,
    39 		TUint aNormalServiceID,
    45 	return self;
    49 	return self;
    46 	}
    50 	}
    47 
    51 
    48 EXPORT_C CMTPFullEnumServiceHandler::~CMTPFullEnumServiceHandler()
    52 EXPORT_C CMTPFullEnumServiceHandler::~CMTPFullEnumServiceHandler()
    49 	{
    53 	{
    50 	__FLOG(_L8("~CMTPFullEnumServiceHandler - Destructed"));
    54 	OstTraceFunctionEntry0( CMTPFULLENUMSERVICEHANDLER_CMTPFULLENUMSERVICEHANDLER_DES_ENTRY );
    51 	__FLOG_CLOSE;
    55 	OstTraceFunctionExit0( CMTPFULLENUMSERVICEHANDLER_CMTPFULLENUMSERVICEHANDLER__DES_EXIT );
    52 	}
    56 	}
    53 
    57 
    54 CMTPFullEnumServiceHandler::CMTPFullEnumServiceHandler(MMTPDataProviderFramework& aFramework,
    58 CMTPFullEnumServiceHandler::CMTPFullEnumServiceHandler(MMTPDataProviderFramework& aFramework,
    55 		const CMTPFullEnumDataCodeMgr& aDataCodeMgr, CRepository& aRepository,
    59 		const CMTPFullEnumDataCodeMgr& aDataCodeMgr, CRepository& aRepository,
    56 		TUint aNormalServiceID, const TDesC& aKnowledgeObjectSUID,
    60 		TUint aNormalServiceID, const TDesC& aKnowledgeObjectSUID,
    61 	iNormalServiceFormatGUID = aServiceFormatGUID;
    65 	iNormalServiceFormatGUID = aServiceFormatGUID;
    62 	}
    66 	}
    63 
    67 
    64 void CMTPFullEnumServiceHandler::ConstructL()
    68 void CMTPFullEnumServiceHandler::ConstructL()
    65 	{
    69 	{
    66 	__FLOG_OPEN(KMTPSubsystem, KComponent);
    70 	OstTraceFunctionEntry0( CMTPFULLENUMSERVICEHANDLER_CONSTRUCTL_ENTRY );
    67 	__FLOG(_L8("ConstructL - Entry"));
       
    68 	// Initialize the service properties's value stored in iRepository
    71 	// Initialize the service properties's value stored in iRepository
    69 	LoadServicePropValueL();
    72 	LoadServicePropValueL();
    70 	__FLOG(_L8("ConstructL - Exit"));
    73 	OstTraceFunctionExit0( CMTPFULLENUMSERVICEHANDLER_CONSTRUCTL_EXIT );
    71 	}
    74 	}
    72 
    75 
    73 // GetServiceCapabilities
    76 // GetServiceCapabilities
    74 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServiceCapabilityL(
    77 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServiceCapabilityL(
    75 	TUint16 aServiceFormatCode, CMTPTypeServiceCapabilityList& aServiceCapabilityList) const
    78 	TUint16 aServiceFormatCode, CMTPTypeServiceCapabilityList& aServiceCapabilityList) const
    76 	{
    79 	{
    77 	__FLOG(_L8("GetServiceCapabilitiesL - Entry"));
    80 	OstTraceFunctionEntry0( CMTPFULLENUMSERVICEHANDLER_GETSERVICECAPABILITYL_ENTRY );
    78 
    81 
    79 	__ASSERT_DEBUG((aServiceFormatCode == iDataCodeMgr.KnowledgeFormat().iFormatCode), User::Invariant());
    82 	__ASSERT_DEBUG((aServiceFormatCode == iDataCodeMgr.KnowledgeFormat().iFormatCode), User::Invariant());
    80 
    83 
    81 	//only Knowledge format supported
    84 	//only Knowledge format supported
    82 	CMTPTypeFormatCapability* element = CMTPTypeFormatCapability::NewLC(aServiceFormatCode, NULL);
    85 	CMTPTypeFormatCapability* element = CMTPTypeFormatCapability::NewLC(aServiceFormatCode, NULL);
    95 			CleanupStack::Pop(objectProperty);
    98 			CleanupStack::Pop(objectProperty);
    96 			}
    99 			}
    97 		} // End of loop for every format
   100 		} // End of loop for every format
    98 	aServiceCapabilityList.AppendL(element);
   101 	aServiceCapabilityList.AppendL(element);
    99 	CleanupStack::Pop(element);
   102 	CleanupStack::Pop(element);
   100 	__FLOG(_L8("GetServiceCapabilitiesL - Exit"));
   103 	OstTraceFunctionExit0( CMTPFULLENUMSERVICEHANDLER_GETSERVICECAPABILITYL_EXIT );
   101 	return EMTPRespCodeOK;
   104 	return EMTPRespCodeOK;
   102 	}
   105 	}
   103 
   106 
   104 // GetServicePropDesc
   107 // GetServicePropDesc
   105 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServicePropDescL(
   108 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServicePropDescL(
   106 	TUint16 aServicePropertyCode, CMTPTypeServicePropDescList& aPropDescList) const
   109 	TUint16 aServicePropertyCode, CMTPTypeServicePropDescList& aPropDescList) const
   107 	{
   110 	{
   108 	__FLOG(_L8("GetServicePropDescL - Entry"));
   111 	OstTraceFunctionEntry0( CMTPFULLENUMSERVICEHANDLER_GETSERVICEPROPDESCL_ENTRY );
   109 	TMTPResponseCode respCode(EMTPRespCodeOK);
   112 	TMTPResponseCode respCode(EMTPRespCodeOK);
   110 	CMTPTypeServicePropDesc* servicePropDesc = NULL;
   113 	CMTPTypeServicePropDesc* servicePropDesc = NULL;
   111 	const TMTPServicePropertyInfo* pPropInfo = iDataCodeMgr.ServicePropertyInfo(aServicePropertyCode);
   114 	const TMTPServicePropertyInfo* pPropInfo = iDataCodeMgr.ServicePropertyInfo(aServicePropertyCode);
   112 	TUint16 servicePropEnum = pPropInfo ? pPropInfo->iIndex : EMTPAbstractServicePropertyEnd;
   115 	TUint16 servicePropEnum = pPropInfo ? pPropInfo->iIndex : EMTPAbstractServicePropertyEnd;
   113 	switch (servicePropEnum)
   116 	switch (servicePropEnum)
   232 	if (servicePropDesc)
   235 	if (servicePropDesc)
   233 		{
   236 		{
   234 		aPropDescList.AppendL(servicePropDesc);
   237 		aPropDescList.AppendL(servicePropDesc);
   235 		CleanupStack::Pop(servicePropDesc);
   238 		CleanupStack::Pop(servicePropDesc);
   236 		}
   239 		}
   237 	__FLOG(_L8("GetServicePropDescL - Exit"));
   240 	OstTraceFunctionExit0( CMTPFULLENUMSERVICEHANDLER_GETSERVICEPROPDESCL_EXIT );
   238 	return respCode;
   241 	return respCode;
   239 	}
   242 	}
   240 
   243 
   241 // Get specific property of the service
   244 // Get specific property of the service
   242 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServicePropetyL(TUint16 aPropertyCode, CMTPTypeServicePropList& aPropList) const
   245 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::GetServicePropetyL(TUint16 aPropertyCode, CMTPTypeServicePropList& aPropList) const
   243 	{
   246 	{
   244 	__FLOG(_L8("GetServicePropetyL - Entry"));
   247 	OstTraceFunctionEntry0( CMTPFULLENUMSERVICEHANDLER_GETSERVICEPROPETYL_ENTRY );
   245 
   248 
   246 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   249 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   247 	const TMTPServicePropertyInfo* pPropInfo = iDataCodeMgr.ServicePropertyInfo(aPropertyCode);
   250 	const TMTPServicePropertyInfo* pPropInfo = iDataCodeMgr.ServicePropertyInfo(aPropertyCode);
   248 	TUint16 servicePropEnum = pPropInfo ? pPropInfo->iIndex : EMTPAbstractServicePropertyEnd;
   251 	TUint16 servicePropEnum = pPropInfo ? pPropInfo->iIndex : EMTPAbstractServicePropertyEnd;
   249 	CMTPTypeServicePropListElement* propertyElement = NULL;
   252 	CMTPTypeServicePropListElement* propertyElement = NULL;
   369 	if (propertyElement)
   372 	if (propertyElement)
   370 		{
   373 		{
   371 		aPropList.AppendL(propertyElement);
   374 		aPropList.AppendL(propertyElement);
   372 		CleanupStack::Pop(propertyElement);
   375 		CleanupStack::Pop(propertyElement);
   373 		}
   376 		}
   374 	__FLOG_VA((_L8("GetServicePropetyL - Exit with responseCode = 0x%04X"), responseCode));
   377 	OstTrace1( TRACE_NORMAL, CMTPFULLENUMSERVICEHANDLER_GETSERVICEPROPETYL, "responseCode = 0x%04X", responseCode);
       
   378 	OstTraceFunctionExit0( CMTPFULLENUMSERVICEHANDLER_GETSERVICEPROPETYL_EXIT );
   375 	return responseCode;
   379 	return responseCode;
   376 	}
   380 	}
   377 
   381 
   378 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::SetServicePropetyL(
   382 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::SetServicePropetyL(
   379 	TUint16 aPropEnumIndex, const CMTPTypeServicePropListElement& aElement)
   383 	TUint16 aPropEnumIndex, const CMTPTypeServicePropListElement& aElement)
   380 	{
   384 	{
   381 	__FLOG(_L8("SetServicePropetyL - Entry"));
   385 	OstTraceFunctionEntry0( CMTPFULLENUMSERVICEHANDLER_SETSERVICEPROPETYL_ENTRY );
   382 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   386 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   383 
   387 
   384 	TUint16 dataType = aElement.Uint16L(CMTPTypeServicePropListElement::EDatatype);
   388 	TUint16 dataType = aElement.Uint16L(CMTPTypeServicePropListElement::EDatatype);
   385 	switch (aPropEnumIndex)
   389 	switch (aPropEnumIndex)
   386 		{
   390 		{
   470 			break;
   474 			break;
   471 		default:
   475 		default:
   472 			responseCode = EMTPRespCodeInvalidServicePropCode;
   476 			responseCode = EMTPRespCodeInvalidServicePropCode;
   473 			break;
   477 			break;
   474 		} //End of switch
   478 		} //End of switch
   475 	__FLOG_VA((_L8("SetServicePropertyL - Exit with responseCode = 0x%04X"), responseCode));
   479 	OstTrace1( TRACE_NORMAL, CMTPFULLENUMSERVICEHANDLER_SETSERVICEPROPETYL, "responseCode = 0x%04X", responseCode );
       
   480 	OstTraceFunctionExit0( CMTPFULLENUMSERVICEHANDLER_SETSERVICEPROPETYL_EXIT );
   476 	return responseCode;
   481 	return responseCode;
   477 	}
   482 	}
   478 
   483 
   479 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::DeleteServiceProperty(TUint16 aPropEnumIndex)
   484 EXPORT_C TMTPResponseCode CMTPFullEnumServiceHandler::DeleteServiceProperty(TUint16 aPropEnumIndex)
   480 	{
   485 	{
   481 	__FLOG(_L8("DeleteServiceProperty - Entry"));
   486 	OstTraceFunctionEntry0( CMTPFULLENUMSERVICEHANDLER_DELETESERVICEPROPERTY_ENTRY );
   482 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   487 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   483 	switch (aPropEnumIndex)
   488 	switch (aPropEnumIndex)
   484 		{
   489 		{
   485 			// Deleteserviceproplist set all preoperties to uninitialized value
   490 			// Deleteserviceproplist set all preoperties to uninitialized value
   486 		case EMTPServicePropertyReplicaID:
   491 		case EMTPServicePropertyReplicaID:
   521 			break;
   526 			break;
   522 			}
   527 			}
   523 		default:
   528 		default:
   524 			{
   529 			{
   525 			responseCode = EMTPRespCodeInvalidServicePropCode;
   530 			responseCode = EMTPRespCodeInvalidServicePropCode;
   526 			__FLOG(_L8("Invalid service propcode"));
   531 			OstTrace0( TRACE_ERROR, CMTPFULLENUMSERVICEHANDLER_DELETESERVICEPROPERTY, "Invalid service propcode" );
   527 			break;
   532 			break;
   528 			}
   533 			}
   529 		}
   534 		}
   530 	__FLOG(_L8("DeleteServiceProperty - Exit"));
   535 	OstTraceFunctionExit0( CMTPFULLENUMSERVICEHANDLER_DELETESERVICEPROPERTY_EXIT );
   531 	return responseCode;
   536 	return responseCode;
   532 	}
   537 	}
   533 
   538 
   534 void CMTPFullEnumServiceHandler::LoadServicePropValueL()
   539 void CMTPFullEnumServiceHandler::LoadServicePropValueL()
   535 	{
   540 	{
   536 	__FLOG(_L8("LoadServicePropValueL - Entry"));
   541 	OstTraceFunctionEntry0( CMTPFULLENUMSERVICEHANDLER_LOADSERVICEPROPVALUEL_ENTRY );
   537 	// Load ReplicaID:
   542 	// Load ReplicaID:
   538 	TPtr8 writeBuf(NULL, 0); //walkaroud for the TMTPTypeGuid
   543 	TPtr8 writeBuf(NULL, 0); //walkaroud for the TMTPTypeGuid
   539 	iReplicateID.FirstWriteChunk(writeBuf);
   544 	iReplicateID.FirstWriteChunk(writeBuf);
   540 	User::LeaveIfError(iRepository.Get(EReplicaID, writeBuf));
   545 	LEAVEIFERROR(iRepository.Get(EReplicaID, writeBuf),
       
   546 	        OstTrace0( TRACE_ERROR, CMTPFULLENUMSERVICEHANDLER_LOADSERVICEPROPVALUEL, "Can't load ReplicaID from iRepository!"));
   541 
   547 
   542 	//load LastSyncProxyID
   548 	//load LastSyncProxyID
   543 	iLastSyncProxyID.FirstWriteChunk(writeBuf);
   549 	iLastSyncProxyID.FirstWriteChunk(writeBuf);
   544 	User::LeaveIfError(iRepository.Get(ELastSyncProxyID, writeBuf));
   550 	LEAVEIFERROR(iRepository.Get(ELastSyncProxyID, writeBuf),
       
   551 	        OstTrace0( TRACE_ERROR, DUP1_CMTPFULLENUMSERVICEHANDLER_LOADSERVICEPROPVALUEL, "Can't load LastSyncProxyID from iRepository!"));
   545 
   552 
   546 	TInt value;
   553 	TInt value;
   547 	// Load LocalOnlyDelete
   554 	// Load LocalOnlyDelete
   548 	User::LeaveIfError(iRepository.Get(ELocalOnlyDelete, value));
   555 	LEAVEIFERROR(iRepository.Get(ELocalOnlyDelete, value),
       
   556 	        OstTrace0( TRACE_ERROR, DUP2_CMTPFULLENUMSERVICEHANDLER_LOADSERVICEPROPVALUEL, "Can't load LocalOnlyDelete from iRepository!"));        
   549 	iLocalOnlyDelete = static_cast<TMTPSyncSvcLocalOnlyDelete>(value);
   557 	iLocalOnlyDelete = static_cast<TMTPSyncSvcLocalOnlyDelete>(value);
   550 
   558 
   551 	// Load EFilterType
   559 	// Load EFilterType
   552 	User::LeaveIfError(iRepository.Get(EFilterType, value));
   560 	LEAVEIFERROR(iRepository.Get(EFilterType, value),
       
   561 	        OstTrace0( TRACE_ERROR, DUP3_CMTPFULLENUMSERVICEHANDLER_LOADSERVICEPROPVALUEL, "Can't load FilterType from iRepository!"));
   553 	iFilterType = static_cast<TMTPSyncSvcFilterType>(value);
   562 	iFilterType = static_cast<TMTPSyncSvcFilterType>(value);
   554 
   563 
   555 	//Load SyncObjectReferenceEnabled
   564 	//Load SyncObjectReferenceEnabled
   556 	//Only dp which support SyncObjectReference need to save it into central responsitory
   565 	//Only dp which support SyncObjectReference need to save it into central responsitory
   557 	value = EMTPSyncObjectReferencesDisabled;
   566 	value = EMTPSyncObjectReferencesDisabled;
   558 	TInt ret = iRepository.Get(ESyncObjectReference, value);
   567 	TInt ret = iRepository.Get(ESyncObjectReference, value);
   559 	if (ret != KErrNone && ret != KErrNotFound )
   568 	if (ret != KErrNone && ret != KErrNotFound )
   560 	    {
   569 	    {
       
   570         OstTrace1( TRACE_ERROR, DUP4_CMTPFULLENUMSERVICEHANDLER_LOADSERVICEPROPVALUEL, 
       
   571                 "can't load SyncObjectReferenceEnabled from iRepository! error code %d", ret );
   561 	    User::Leave(ret);
   572 	    User::Leave(ret);
   562 	    }
   573 	    }
   563 	iSyncObjectReference = static_cast<TMTPSyncSvcSyncObjectReferences>(value);
   574 	iSyncObjectReference = static_cast<TMTPSyncSvcSyncObjectReferences>(value);
   564 	
   575 	
   565 	__FLOG(_L8("LoadServicePropValueL - Exit"));
   576 	OstTraceFunctionExit0( CMTPFULLENUMSERVICEHANDLER_LOADSERVICEPROPVALUEL_EXIT );
   566 	return;
   577 	return;
   567 	}
   578 	}