mtpfws/mtpfw/src/cmtpobjectstore.cpp
branchRCL_3
changeset 11 4843bb5893b6
parent 6 f8e15b44d440
child 14 60a94a45d437
equal deleted inserted replaced
6:f8e15b44d440 11:4843bb5893b6
   278 	return i;
   278 	return i;
   279 	}
   279 	}
   280 
   280 
   281 void CMTPObjectStore::CommitReservedObjectHandleL(CMTPObjectMetaData& aObject)
   281 void CMTPObjectStore::CommitReservedObjectHandleL(CMTPObjectMetaData& aObject)
   282 	{
   282 	{
       
   283 	TFileName suid;
       
   284 	suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
       
   285 	TUint32 handle = HandleL(suid);
       
   286 	if (handle != KMTPHandleNone)
       
   287 	    {
       
   288 	    __FLOG(_L8("CommitReserverd leave for duplicate suid."));
       
   289 	    User::Leave(KErrAlreadyExists);
       
   290 	    }
       
   291 	TUint32 suidHash = DefaultHash::Des16(suid);
       
   292 	
   283 	//After the PutL called the cursor's position is not well defined.
   293 	//After the PutL called the cursor's position is not well defined.
   284 	iCachedHandle = 0;
   294 	iCachedHandle = 0;
   285 	iCachedSuidHash = 0;
   295 	iCachedSuidHash = 0;
   286 	TInt64 id = iHandleAllocator->NextPOUIDL();
   296 	TInt64 id = iHandleAllocator->NextPOUIDL();
   287 	aObject.SetUint(CMTPObjectMetaData::EIdentifier, id);
   297 	aObject.SetUint(CMTPObjectMetaData::EIdentifier, id);
   288 
   298 
   289 	TFileName suid;
   299 	handle = aObject.Uint(CMTPObjectMetaData::EHandle);
   290 	suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
       
   291 	TUint32 suidHash = DefaultHash::Des16(suid);
       
   292 
       
   293 	TUint32 handle = aObject.Uint(CMTPObjectMetaData::EHandle);
       
   294 	CleanupStack::PushL(TCleanupItem(CMTPObjectStore::DBUpdateFailRecover, &iBatched));
   300 	CleanupStack::PushL(TCleanupItem(CMTPObjectStore::DBUpdateFailRecover, &iBatched));
   295 	iBatched.InsertL();
   301 	iBatched.InsertL();
   296 	iBatched.SetColL(EObjectStoreHandleId, handle);
   302 	iBatched.SetColL(EObjectStoreHandleId, handle);
   297 	iBatched.SetColL(EObjectStoreSUIDHash, suidHash);
   303 	iBatched.SetColL(EObjectStoreSUIDHash, suidHash);
   298 	DbColWriteStreamL(iBatched, EObjectStoreSUID, aObject.DesC(CMTPObjectMetaData::ESuid));	
   304 	DbColWriteStreamL(iBatched, EObjectStoreSUID, aObject.DesC(CMTPObjectMetaData::ESuid));	
   556 	suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
   562 	suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
   557 	TUint32 suidHash = DefaultHash::Des16(suid);
   563 	TUint32 suidHash = DefaultHash::Des16(suid);
   558 
   564 
   559 	if (LocateByHandleL(handle))
   565 	if (LocateByHandleL(handle))
   560 		{
   566 		{
       
   567 		//To avoid this modification will not generate duplicate SUID
       
   568 		TUint32 handle2 = HandleL(suid);
       
   569 		if (handle2 != KMTPHandleNone && handle2 != handle)
       
   570 		    {
       
   571 		    __FLOG(_L8("ModifyObjectL leave for duplicate suid."));
       
   572 		    User::Leave(KErrAlreadyExists); 
       
   573 		    }
       
   574 		
   561 		//After the PutL called the cursor's position is not well defined.
   575 		//After the PutL called the cursor's position is not well defined.
   562 		iCachedHandle = 0;
   576 		iCachedHandle = 0;
   563 		iCachedSuidHash = 0;
   577 		iCachedSuidHash = 0;
   564 		TInt64 id = iBatched.ColInt64(EObjectStorePOUID);
   578 		TInt64 id = iBatched.ColInt64(EObjectStorePOUID);
   565 		TUint32 suidHashOld = iBatched.ColUint32(EObjectStoreSUIDHash);
   579 		TUint32 suidHashOld = iBatched.ColUint32(EObjectStoreSUIDHash);