mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectinfo.cpp
changeset 49 c20dd21d1eb4
parent 18 1b39655331a3
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    22 #include <mtp/cmtptypestring.h>
    22 #include <mtp/cmtptypestring.h>
    23 
    23 
    24 #include "cmtpgetobjectinfo.h"
    24 #include "cmtpgetobjectinfo.h"
    25 #include "mtpdppanic.h"
    25 #include "mtpdppanic.h"
    26 #include "cmtpfsentrycache.h"
    26 #include "cmtpfsentrycache.h"
    27 
    27 #include "mtpdebug.h"
    28 __FLOG_STMT(_LIT8(KComponent,"MTPGetObjectInfo");)
    28 #include "OstTraceDefinitions.h"
       
    29 #ifdef OST_TRACE_COMPILER_IN_USE
       
    30 #include "cmtpgetobjectinfoTraces.h"
       
    31 #endif
       
    32 
    29 
    33 
    30 /**
    34 /**
    31 Verification data for GetObjectInfo request
    35 Verification data for GetObjectInfo request
    32 */
    36 */
    33 const TMTPRequestElementInfo KMTPGetObjectInfoPolicy[] = 
    37 const TMTPRequestElementInfo KMTPGetObjectInfoPolicy[] = 
    54 /**
    58 /**
    55 Destructor
    59 Destructor
    56 */	
    60 */	
    57 EXPORT_C CMTPGetObjectInfo::~CMTPGetObjectInfo()
    61 EXPORT_C CMTPGetObjectInfo::~CMTPGetObjectInfo()
    58 	{	
    62 	{	
       
    63 	OstTraceFunctionEntry0( CMTPGETOBJECTINFO_CMTPGETOBJECTINFO_DES_ENTRY );
    59 	delete iObjectInfoToBuild;
    64 	delete iObjectInfoToBuild;
    60 	iDpSingletons.Close();
    65 	iDpSingletons.Close();
    61 	__FLOG_CLOSE;
    66 	OstTraceFunctionExit0( CMTPGETOBJECTINFO_CMTPGETOBJECTINFO_DES_EXIT );
    62 	}
    67 	}
    63 
    68 
    64 /**
    69 /**
    65 Standard c++ constructor
    70 Standard c++ constructor
    66 */	
    71 */	
    67 CMTPGetObjectInfo::CMTPGetObjectInfo(MMTPDataProviderFramework& aFramework,
    72 CMTPGetObjectInfo::CMTPGetObjectInfo(MMTPDataProviderFramework& aFramework,
    68 									MMTPConnection& aConnection)
    73 									MMTPConnection& aConnection)
    69 	:CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectInfoPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectInfoPolicy),
    74 	:CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectInfoPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectInfoPolicy),
    70 	iRfs(aFramework.Fs())
    75 	iRfs(aFramework.Fs())
    71 	{
    76 	{
    72 	__FLOG_OPEN(KMTPSubsystem, KComponent);
       
    73 	}
    77 	}
    74 
    78 
    75 /**
    79 /**
    76 GetObjectInfo request handler
    80 GetObjectInfo request handler
    77 */		
    81 */		
    84 /**
    88 /**
    85 Second-phase construction
    89 Second-phase construction
    86 */		
    90 */		
    87 void CMTPGetObjectInfo::ConstructL()
    91 void CMTPGetObjectInfo::ConstructL()
    88 	{
    92 	{
       
    93 	OstTraceFunctionEntry0( CMTPGETOBJECTINFO_CONSTRUCTL_ENTRY );
    89 	iObjectInfoToBuild = CMTPTypeObjectInfo::NewL();
    94 	iObjectInfoToBuild = CMTPTypeObjectInfo::NewL();
    90 	iDpSingletons.OpenL(iFramework);
    95 	iDpSingletons.OpenL(iFramework);
       
    96 	OstTraceFunctionExit0( CMTPGETOBJECTINFO_CONSTRUCTL_EXIT );
    91 	}
    97 	}
    92 
    98 
    93 /**
    99 /**
    94 Populate the object info dataset
   100 Populate the object info dataset
    95 */		
   101 */		
    96 void CMTPGetObjectInfo::BuildObjectInfoL()	
   102 void CMTPGetObjectInfo::BuildObjectInfoL()	
    97 	{
   103 	{
       
   104 	OstTraceFunctionEntry0( CMTPGETOBJECTINFO_BUILDOBJECTINFOL_ENTRY );
    98 	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
   105 	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
    99 	TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   106 	TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   100 	//does not take owernship
   107 	//does not take owernship
   101 	CMTPObjectMetaData* objectInfoFromStore = iRequestChecker->GetObjectInfo(objectHandle);
   108 	CMTPObjectMetaData* objectInfoFromStore = iRequestChecker->GetObjectInfo(objectHandle);
   102 	__ASSERT_DEBUG(objectInfoFromStore, Panic(EMTPDpObjectNull));
   109 	__ASSERT_DEBUG(objectInfoFromStore, Panic(EMTPDpObjectNull));
   108 		{
   115 		{
   109 		if( (iDpSingletons.CopyingBigFileCache().TargetHandle() == objectHandle) &&
   116 		if( (iDpSingletons.CopyingBigFileCache().TargetHandle() == objectHandle) &&
   110 				(iDpSingletons.CopyingBigFileCache().IsOnGoing()))
   117 				(iDpSingletons.CopyingBigFileCache().IsOnGoing()))
   111 			{
   118 			{
   112 			// The object is being copied, it is not created in fs yet. Use its cache entry to get objectinfo
   119 			// The object is being copied, it is not created in fs yet. Use its cache entry to get objectinfo
   113 			__FLOG(_L8("BuildObjectInfoL - The object is being copied, use its cache entry to get objectinfo"));
   120 			OstTrace0( TRACE_NORMAL, CMTPGETOBJECTINFO_BUILDOBJECTINFOL, 
       
   121 			        "BuildObjectInfoL - The object is being copied, use its cache entry to get objectinfo" );
   114 			fileEntry = iDpSingletons.CopyingBigFileCache().FileEntry();
   122 			fileEntry = iDpSingletons.CopyingBigFileCache().FileEntry();
   115 			err = KErrNone;
   123 			err = KErrNone;
   116 			}
   124 			}
   117 		else if( (iDpSingletons.MovingBigFileCache().TargetHandle() == objectHandle) &&
   125 		else if( (iDpSingletons.MovingBigFileCache().TargetHandle() == objectHandle) &&
   118 							(iDpSingletons.MovingBigFileCache().IsOnGoing()))
   126 							(iDpSingletons.MovingBigFileCache().IsOnGoing()))
   119 			{
   127 			{
   120 			// The object is being moved, it is not created in fs yet. Use its cache entry to get objectinfo
   128 			// The object is being moved, it is not created in fs yet. Use its cache entry to get objectinfo
   121 			__FLOG(_L8("BuildObjectInfoL - The object is being moved, use its cache entry to get objectinfo"));
   129 			OstTrace0( TRACE_NORMAL, DUP1_CMTPGETOBJECTINFO_BUILDOBJECTINFOL, 
       
   130 			        "BuildObjectInfoL - The object is being moved, use its cache entry to get objectinfo" );
   122 			fileEntry = iDpSingletons.MovingBigFileCache().FileEntry();
   131 			fileEntry = iDpSingletons.MovingBigFileCache().FileEntry();
   123 			err = KErrNone;
   132 			err = KErrNone;
   124 			}	
   133 			}	
   125 		}
   134 		}
   126 	
   135 	
   127 	User::LeaveIfError(err);	
   136 	LEAVEIFERROR(err,
   128 			
   137 	        OstTraceExt2( TRACE_ERROR, DUP2_CMTPGETOBJECTINFO_BUILDOBJECTINFOL, 
       
   138 	                "Can't get entry details for %S even after error handling! error code %d",  objectInfoFromStore->DesC(CMTPObjectMetaData::ESuid), err));
       
   139 	
   129 	//1. storage id
   140 	//1. storage id
   130 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EStorageID, objectInfoFromStore->Uint(CMTPObjectMetaData::EStorageId));	
   141 	iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EStorageID, objectInfoFromStore->Uint(CMTPObjectMetaData::EStorageId));	
   131 	
   142 	
   132 	//2. object format
   143 	//2. object format
   133 	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, objectInfoFromStore->Uint(CMTPObjectMetaData::EFormatCode));
   144 	iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, objectInfoFromStore->Uint(CMTPObjectMetaData::EFormatCode));
   188 	//file creation time, set it as the same as modified time, as Symbian does not support this field
   199 	//file creation time, set it as the same as modified time, as Symbian does not support this field
   189 	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateCreated, dateString);	
   200 	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EDateCreated, dateString);	
   190 		
   201 		
   191 	//19. keyword
   202 	//19. keyword
   192 	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC);
   203 	iObjectInfoToBuild->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC);
   193 	}
   204 	OstTraceFunctionExit0( CMTPGETOBJECTINFO_BUILDOBJECTINFOL_EXIT );
   194 
   205 	}
       
   206