mtpfws/mtpfw/dataproviders/dputility/src/cmtpmoveobject.cpp
changeset 49 c20dd21d1eb4
parent 31 a26669f87b46
child 60 841f70763fbe
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    25 
    25 
    26 #include "cmtpfsentrycache.h"
    26 #include "cmtpfsentrycache.h"
    27 #include "cmtpstoragemgr.h"
    27 #include "cmtpstoragemgr.h"
    28 #include "cmtpmoveobject.h"
    28 #include "cmtpmoveobject.h"
    29 #include "mtpdppanic.h"
    29 #include "mtpdppanic.h"
    30 
    30 #include "mtpdebug.h"
    31 
    31 #include "OstTraceDefinitions.h"
    32 __FLOG_STMT(_LIT8(KComponent,"MoveObject");)
    32 #ifdef OST_TRACE_COMPILER_IN_USE
       
    33 #include "cmtpmoveobjectTraces.h"
       
    34 #endif
       
    35 
       
    36 
    33 
    37 
    34 /**
    38 /**
    35 Verification data for the MoveObject request
    39 Verification data for the MoveObject request
    36 */    
    40 */    
    37 const TMTPRequestElementInfo KMTPMoveObjectPolicy[] = 
    41 const TMTPRequestElementInfo KMTPMoveObjectPolicy[] = 
    61 /**
    65 /**
    62 Destructor
    66 Destructor
    63 */	
    67 */	
    64 EXPORT_C CMTPMoveObject::~CMTPMoveObject()
    68 EXPORT_C CMTPMoveObject::~CMTPMoveObject()
    65 	{
    69 	{
       
    70 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_CMTPMOVEOBJECT_ENTRY );
    66 	Cancel();
    71 	Cancel();
    67 	iDpSingletons.Close();
    72 	iDpSingletons.Close();
    68 	iSingletons.Close();
    73 	iSingletons.Close();
    69 	
    74 	
    70 	delete iTimer;
    75 	delete iTimer;
    71 	delete iNewFileName;
    76 	delete iNewFileName;
    72 	delete iDest;
    77 	delete iDest;
    73 	delete iFileMan;
    78 	delete iFileMan;
    74 	delete iPathToMove;
    79 	delete iPathToMove;
    75 	delete iNewRootFolder;	
    80 	delete iNewRootFolder;	
    76 	__FLOG_CLOSE;
    81 	OstTraceFunctionExit0( CMTPMOVEOBJECT_CMTPMOVEOBJECT_EXIT );
    77 	}
    82 	}
    78 
    83 
    79 /**
    84 /**
    80 Standard c++ constructor
    85 Standard c++ constructor
    81 */	
    86 */	
    82 CMTPMoveObject::CMTPMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
    87 CMTPMoveObject::CMTPMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
    83 	CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPMoveObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPMoveObjectPolicy),
    88 	CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPMoveObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPMoveObjectPolicy),
    84 	iMoveObjectIndex(0), iTimer(NULL)
    89 	iMoveObjectIndex(0), iTimer(NULL)
    85 	{
    90 	{
    86 	__FLOG_OPEN(KMTPSubsystem, KComponent);
       
    87 	}
    91 	}
    88 
    92 
    89 TMTPResponseCode CMTPMoveObject::CheckRequestL()
    93 TMTPResponseCode CMTPMoveObject::CheckRequestL()
    90 	{
    94 	{
    91     __FLOG(_L8("CheckRequestL - Entry"));
    95     OstTraceFunctionEntry0( CMTPMOVEOBJECT_CHECKREQUESTL_ENTRY );
    92 	TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
    96 	TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL();
    93 	if (EMTPRespCodeOK != result)
    97 	if (EMTPRespCodeOK != result)
    94 		{
    98 		{
    95 		__FLOG(_L8("CheckRequestL with error- Exit"));
    99 		OstTraceFunctionExit0( CMTPMOVEOBJECT_CHECKREQUESTL_EXIT );
    96 		return result;
   100 		return result;
    97 		}
   101 		}
    98 	
   102 	
    99 	const TUint32 KObjectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   103 	const TUint32 KObjectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   100 	//not taking owernship
   104 	//not taking owernship
   112 	
   116 	
   113 	if(result == EMTPRespCodeOK)
   117 	if(result == EMTPRespCodeOK)
   114 		{
   118 		{
   115 		const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
   119 		const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
   116 		iIsFolder = EFalse;
   120 		iIsFolder = EFalse;
   117 		User::LeaveIfError(BaflUtils::IsFolder(iFramework.Fs(), suid, iIsFolder));
   121 		LEAVEIFERROR(BaflUtils::IsFolder(iFramework.Fs(), suid, iIsFolder),
       
   122 		        OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_CHECKREQUESTL, "can't judge whether %S is folder", suid));
       
   123 		        
   118 		if(!iIsFolder)
   124 		if(!iIsFolder)
   119 			{
   125 			{
   120 			if(iDpSingletons.MovingBigFileCache().IsOnGoing())
   126 			if(iDpSingletons.MovingBigFileCache().IsOnGoing())
   121 				{
   127 				{
   122 				__FLOG(_L8("CheckRequestL - A big file moving is ongoing, respond with access denied"));
   128 				OstTrace0( TRACE_NORMAL, CMTPMOVEOBJECT_CHECKREQUESTL, 
       
   129 				        "CheckRequestL - A big file moving is ongoing, respond with access denied" );
   123 				result = EMTPRespCodeAccessDenied;
   130 				result = EMTPRespCodeAccessDenied;
   124 				}
   131 				}
   125 			}
   132 			}
   126 		}
   133 		}
   127 	
   134 
   128     __FLOG(_L8("CheckRequestL - Exit"));
   135 	OstTraceFunctionExit0( DUP1_CMTPMOVEOBJECT_CHECKREQUESTL_EXIT );
   129 	return result;	
   136 	return result;	
   130 	} 
   137 	} 
   131 
   138 
   132 /**
   139 /**
   133 MoveObject request handler
   140 MoveObject request handler
   134 */		
   141 */		
   135 void CMTPMoveObject::ServiceL()
   142 void CMTPMoveObject::ServiceL()
   136 	{
   143 	{
   137 	__FLOG(_L8("ServiceL - Entry"));
   144 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_SERVICEL_ENTRY );
   138 	TMTPResponseCode ret = EMTPRespCodeOK;
   145 	TMTPResponseCode ret = EMTPRespCodeOK;
   139 	TRAPD(err, ret = MoveObjectL());
   146 	TRAPD(err, ret = MoveObjectL());
   140 	if (err != KErrNone)
   147 	if (err != KErrNone)
   141 		{
   148 		{
   142 		SendResponseL(EMTPRespCodeAccessDenied);
   149 		SendResponseL(EMTPRespCodeAccessDenied);
   143 		}
   150 		}
   144 	else if (EMTPRespCodeOK != ret)
   151 	else if (EMTPRespCodeOK != ret)
   145 		{
   152 		{
   146 		SendResponseL(ret);
   153 		SendResponseL(ret);
   147 		}
   154 		}
   148 	__FLOG(_L8("ServiceL - Exit"));
   155 	OstTraceFunctionExit0( CMTPMOVEOBJECT_SERVICEL_EXIT );
   149 	}
   156 	}
   150 
   157 
   151 /**
   158 /**
   152  Second phase constructor
   159  Second phase constructor
   153 */
   160 */
   154 void CMTPMoveObject::ConstructL()
   161 void CMTPMoveObject::ConstructL()
   155     {
   162     {
       
   163 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_CONSTRUCTL_ENTRY );
   156 	iSingletons.OpenL();
   164 	iSingletons.OpenL();
   157 	iDpSingletons.OpenL(iFramework);
   165 	iDpSingletons.OpenL(iFramework);
       
   166     OstTraceFunctionExit0( CMTPMOVEOBJECT_CONSTRUCTL_EXIT );
   158     }
   167     }
   159     
   168     
   160 
   169 
   161 /**
   170 /**
   162 A helper function of MoveObjectL.
   171 A helper function of MoveObjectL.
   163 @param aNewFileName the new file name after the object is moved.
   172 @param aNewFileName the new file name after the object is moved.
   164 */
   173 */
   165 void CMTPMoveObject::MoveFileL(const TDesC& aNewFileName)	
   174 void CMTPMoveObject::MoveFileL(const TDesC& aNewFileName)	
   166 	{
   175 	{
   167 	__FLOG(_L8("MoveFileL - Entry"));
   176 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_MOVEFILEL_ENTRY );
   168 	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
   177 	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
   169 	GetPreviousPropertiesL(suid);
   178 	GetPreviousPropertiesL(suid);
   170 	
   179 	
   171 	if(iFramework.StorageMgr().DriveNumber(iObjectInfo->Uint(CMTPObjectMetaData::EStorageId)) ==
   180 	if(iFramework.StorageMgr().DriveNumber(iObjectInfo->Uint(CMTPObjectMetaData::EStorageId)) ==
   172 			iFramework.StorageMgr().DriveNumber(iStorageId))
   181 			iFramework.StorageMgr().DriveNumber(iStorageId))
   173 		//Move file to the same storage
   182 		//Move file to the same storage
   174 		{
   183 		{
   175 		User::LeaveIfError(iFileMan->Move(suid, *iDest));
   184 		LEAVEIFERROR(iFileMan->Move(suid, *iDest),
       
   185 		        OstTraceExt2( TRACE_ERROR, CMTPMOVEOBJECT_MOVEFILEL, "move %S to %S failed!", suid, *iDest ));
   176 		SetPreviousPropertiesL(aNewFileName);
   186 		SetPreviousPropertiesL(aNewFileName);
   177 		iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewFileName);
   187 		iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewFileName);
   178 		iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
   188 		iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
   179 		iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
   189 		iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
   180 		iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
   190 		iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
   185 		{
   195 		{
   186 		delete iNewFileName;
   196 		delete iNewFileName;
   187 		iNewFileName = NULL;
   197 		iNewFileName = NULL;
   188 		iNewFileName = aNewFileName.AllocL(); // Store the new file name
   198 		iNewFileName = aNewFileName.AllocL(); // Store the new file name
   189 		
   199 		
   190 		User::LeaveIfError(iFileMan->Move(suid, *iDest, CFileMan::EOverWrite, iStatus));
   200 		LEAVEIFERROR(iFileMan->Move(suid, *iDest, CFileMan::EOverWrite, iStatus),
       
   201 		        OstTraceExt2( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_MOVEFILEL, "move %S to %S failed!", suid, *iDest));
   191 		if ( !IsActive() )
   202 		if ( !IsActive() )
   192 		{  
   203 		{  
   193 		SetActive();
   204 		SetActive();
   194 		}
   205 		}
   195 		
   206 		
   197 		iTimer = NULL;
   208 		iTimer = NULL;
   198 		iTimer = CPeriodic::NewL(EPriorityStandard);
   209 		iTimer = CPeriodic::NewL(EPriorityStandard);
   199 		TTimeIntervalMicroSeconds32 KMoveObjectIntervalNone = 0;	
   210 		TTimeIntervalMicroSeconds32 KMoveObjectIntervalNone = 0;	
   200 		iTimer->Start(TTimeIntervalMicroSeconds32(KMoveObjectTimeOut), KMoveObjectIntervalNone, TCallBack(CMTPMoveObject::OnTimeoutL, this));		
   211 		iTimer->Start(TTimeIntervalMicroSeconds32(KMoveObjectTimeOut), KMoveObjectIntervalNone, TCallBack(CMTPMoveObject::OnTimeoutL, this));		
   201 		}
   212 		}
   202 	__FLOG(_L8("MoveFileL - Exit"));
   213 	OstTraceFunctionExit0( CMTPMOVEOBJECT_MOVEFILEL_EXIT );
   203 	}
   214 	}
   204 
   215 
   205 /**
   216 /**
   206 A helper function of MoveObjectL.
   217 A helper function of MoveObjectL.
   207 @param aNewFolderName the new file folder name after the folder is moved.
   218 @param aNewFolderName the new file folder name after the folder is moved.
   208 */
   219 */
   209 void CMTPMoveObject::MoveFolderL()
   220 void CMTPMoveObject::MoveFolderL()
   210 	{
   221 	{
   211 	__FLOG(_L8("MoveFolderL - Entry"));
   222 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_MOVEFOLDERL_ENTRY );
   212 	
   223 	
   213 	RBuf oldFolderName;
   224 	RBuf oldFolderName;
   214 	oldFolderName.CreateL(KMaxFileName);
   225 	oldFolderName.CreateL(KMaxFileName);
   215 	oldFolderName.CleanupClosePushL();
   226 	oldFolderName.CleanupClosePushL();
   216 	oldFolderName = iObjectInfo->DesC(CMTPObjectMetaData::ESuid);
   227 	oldFolderName = iObjectInfo->DesC(CMTPObjectMetaData::ESuid);
   230 		iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
   241 		iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
   231 		iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
   242 		iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
   232 		}
   243 		}
   233 	
   244 	
   234 	CleanupStack::PopAndDestroy(); // oldFolderName.
   245 	CleanupStack::PopAndDestroy(); // oldFolderName.
   235 		
   246 
   236 	__FLOG(_L8("MoveFolderL - Exit"));
   247 	OstTraceFunctionExit0( CMTPMOVEOBJECT_MOVEFOLDERL_EXIT );
   237 	}
   248 	}
   238 		
   249 		
   239 /**
   250 /**
   240 move object operations
   251 move object operations
   241 @return A valid MTP response code.
   252 @return A valid MTP response code.
   242 */
   253 */
   243 TMTPResponseCode CMTPMoveObject::MoveObjectL()
   254 TMTPResponseCode CMTPMoveObject::MoveObjectL()
   244 	{
   255 	{
   245 	__FLOG(_L8("MoveObjectL - Entry"));
   256 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_MOVEOBJECTL_ENTRY );
   246 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   257 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   247 	
   258 	
   248 	GetParametersL();
   259 	GetParametersL();
   249 				
   260 				
   250 	RBuf newObjectName;
   261 	RBuf newObjectName;
   265 		responseCode = CanMoveObjectL(suid, newObjectName);			
   276 		responseCode = CanMoveObjectL(suid, newObjectName);			
   266 		}
   277 		}
   267 	else // It is a folder.
   278 	else // It is a folder.
   268 		{
   279 		{
   269 		TFileName rightMostFolderName;		
   280 		TFileName rightMostFolderName;		
   270 		User::LeaveIfError(BaflUtils::MostSignificantPartOfFullName(suid, rightMostFolderName));
   281 		LEAVEIFERROR(BaflUtils::MostSignificantPartOfFullName(suid, rightMostFolderName),
       
   282 		        OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_MOVEOBJECTL, "extract most significant part of %S failed", suid));
       
   283 		        
   271 		if((newObjectName.Length() + rightMostFolderName.Length() + 1) <= newObjectName.MaxLength())
   284 		if((newObjectName.Length() + rightMostFolderName.Length() + 1) <= newObjectName.MaxLength())
   272 			{
   285 			{
   273 			newObjectName.Append(rightMostFolderName);
   286 			newObjectName.Append(rightMostFolderName);
   274 			// Add backslash.
   287 			// Add backslash.
   275 			_LIT(KBackSlash, "\\");
   288 			_LIT(KBackSlash, "\\");
   276 			newObjectName.Append(KBackSlash);
   289 			newObjectName.Append(KBackSlash);
   277 			}
   290 			}
   278 		}
   291 		}
   279 		
   292 		
   280 	iNewRootFolder = newObjectName.AllocL();
   293 	iNewRootFolder = newObjectName.AllocL();
   281 	__FLOG(*iNewRootFolder);
   294 	OstTraceExt1( TRACE_NORMAL, CMTPMOVEOBJECT_MOVEOBJECTL, "%S", *iNewRootFolder );
   282 		
   295 
   283 	if(responseCode == EMTPRespCodeOK)
   296 	if(responseCode == EMTPRespCodeOK)
   284 		{			
   297 		{			
   285 		delete iFileMan;
   298 		delete iFileMan;
   286 		iFileMan = NULL;
   299 		iFileMan = NULL;
   287 		iFileMan = CFileMan::NewL(iFramework.Fs());
   300 		iFileMan = CFileMan::NewL(iFramework.Fs());
   295 			MoveFolderL();
   308 			MoveFolderL();
   296 			SendResponseL(responseCode);
   309 			SendResponseL(responseCode);
   297 			}
   310 			}
   298 		}
   311 		}
   299 	CleanupStack::PopAndDestroy(); // newObjectName.
   312 	CleanupStack::PopAndDestroy(); // newObjectName.
   300 	__FLOG(_L8("MoveObjectL - Exit"));
   313 	OstTraceFunctionExit0( CMTPMOVEOBJECT_MOVEOBJECTL_EXIT );
   301 	return responseCode;
   314 	return responseCode;
   302 	}
   315 	}
   303 
   316 
   304 /**
   317 /**
   305 Retrieve the parameters of the request
   318 Retrieve the parameters of the request
   306 */	
   319 */	
   307 void CMTPMoveObject::GetParametersL()
   320 void CMTPMoveObject::GetParametersL()
   308 	{
   321 	{
   309 	__FLOG(_L8("GetParametersL - Entry"));
   322 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_GETPARAMETERSL_ENTRY );
   310 	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
   323 	__ASSERT_DEBUG(iRequestChecker, Panic(EMTPDpRequestCheckNull));
   311 	
   324 	
   312 	iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   325 	iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   313 	iNewParentHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
   326 	iNewParentHandle  = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
   314 
   327 
   322 		__ASSERT_DEBUG(parentObjectInfo, Panic(EMTPDpObjectNull));
   335 		__ASSERT_DEBUG(parentObjectInfo, Panic(EMTPDpObjectNull));
   323 		delete iDest;
   336 		delete iDest;
   324 		iDest = NULL;
   337 		iDest = NULL;
   325 		iDest = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
   338 		iDest = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL();
   326 		}
   339 		}
   327 	__FLOG(_L8("GetParametersL - Exit"));	
   340 	OstTraceFunctionExit0( CMTPMOVEOBJECT_GETPARAMETERSL_EXIT );
   328 	}
   341 	}
   329 	
   342 	
   330 /**
   343 /**
   331 Get a default parent object, ff the request does not specify a parent object, 
   344 Get a default parent object, ff the request does not specify a parent object, 
   332 */
   345 */
   333 void CMTPMoveObject::SetDefaultParentObjectL()
   346 void CMTPMoveObject::SetDefaultParentObjectL()
   334 	{
   347 	{
   335 	__FLOG(_L8("SetDefaultParentObjectL - Entry"));
   348 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_SETDEFAULTPARENTOBJECTL_ENTRY );
   336 	const CMTPStorageMetaData& storageMetaData( iFramework.StorageMgr().StorageL(iStorageId) );
   349 	const CMTPStorageMetaData& storageMetaData( iFramework.StorageMgr().StorageL(iStorageId) );
   337 	const TDesC& driveBuf( storageMetaData.DesC(CMTPStorageMetaData::EStorageSuid) );
   350 	const TDesC& driveBuf( storageMetaData.DesC(CMTPStorageMetaData::EStorageSuid) );
   338 	delete iDest;
   351 	delete iDest;
   339 	iDest = NULL;
   352 	iDest = NULL;
   340 	iDest = driveBuf.AllocL();
   353 	iDest = driveBuf.AllocL();
   341 	iNewParentHandle = KMTPHandleNoParent;
   354 	iNewParentHandle = KMTPHandleNoParent;
   342 	__FLOG(_L8("SetDefaultParentObjectL - Exit"));
   355 	OstTraceFunctionExit0( CMTPMOVEOBJECT_SETDEFAULTPARENTOBJECTL_EXIT );
   343 	}
   356 	}
   344 
   357 
   345 /**
   358 /**
   346 Check if we can move the file to the new location
   359 Check if we can move the file to the new location
   347 */
   360 */
   348 TMTPResponseCode CMTPMoveObject::CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const
   361 TMTPResponseCode CMTPMoveObject::CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const
   349 	{
   362 	{
   350 	__FLOG(_L8("CanMoveObjectL - Entry"));
   363 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_CANMOVEOBJECTL_ENTRY );
   351 	TMTPResponseCode result = EMTPRespCodeOK;
   364 	TMTPResponseCode result = EMTPRespCodeOK;
   352 
   365 
   353 	TEntry fileEntry;
   366 	TEntry fileEntry;
   354 	User::LeaveIfError(iFramework.Fs().Entry(aOldName, fileEntry));
   367 	LEAVEIFERROR(iFramework.Fs().Entry(aOldName, fileEntry),
       
   368 	        OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_CANMOVEOBJECTL, "can't get entry details from %S", aOldName));
   355 	TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
   369 	TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
   356 	User::LeaveIfError(drive);
   370 	LEAVEIFERROR(drive,
       
   371 	        OstTrace1( TRACE_ERROR, DUP2_CMTPMOVEOBJECT_CANMOVEOBJECTL, "can't get driver number for storage %d", iStorageId));
   357 	TVolumeInfo volumeInfo;
   372 	TVolumeInfo volumeInfo;
   358 	User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
   373 	LEAVEIFERROR(iFramework.Fs().Volume(volumeInfo, drive),
       
   374 	        OstTrace1( TRACE_ERROR, DUP3_CMTPMOVEOBJECT_CANMOVEOBJECTL, "can't get volume info for drive %d", drive));        
   359 	
   375 	
   360 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   376 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   361     if(volumeInfo.iFree < fileEntry.FileSize())
   377     if(volumeInfo.iFree < fileEntry.FileSize())
   362 #else
   378 #else
   363     if(volumeInfo.iFree < fileEntry.iSize)
   379     if(volumeInfo.iFree < fileEntry.iSize)
   367 		}
   383 		}
   368 	else if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
   384 	else if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
   369 		{
   385 		{
   370 		result = EMTPRespCodeInvalidParentObject;
   386 		result = EMTPRespCodeInvalidParentObject;
   371 		}
   387 		}
   372 	__FLOG_VA((_L8("CanMoveObjectL - Exit with response code 0x%04X"), result));
   388 	OstTraceFunctionExit0( CMTPMOVEOBJECT_CANMOVEOBJECTL_EXIT );
       
   389 	OstTrace1( TRACE_NORMAL, CMTPMOVEOBJECT_CANMOVEOBJECTL, "response code 0x%04X", result );
   373 	return result;	
   390 	return result;	
   374 	}
   391 	}
   375 
   392 
   376 /**
   393 /**
   377 Save the object properties before moving
   394 Save the object properties before moving
   378 */
   395 */
   379 void CMTPMoveObject::GetPreviousPropertiesL(const TDesC& aFileName)
   396 void CMTPMoveObject::GetPreviousPropertiesL(const TDesC& aFileName)
   380 	{
   397 	{
   381 	__FLOG(_L8("GetPreviousPropertiesL - Entry"));
   398 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_GETPREVIOUSPROPERTIESL_ENTRY );
   382 	User::LeaveIfError(iFramework.Fs().Modified(aFileName, iPreviousModifiedTime));
   399 	LEAVEIFERROR(iFramework.Fs().Modified(aFileName, iPreviousModifiedTime),
   383 	__FLOG(_L8("GetPreviousPropertiesL - Exit"));
   400 	        OstTraceExt1( TRACE_ERROR, CMTPMOVEOBJECT_GETPREVIOUSPROPERTIESL, 
       
   401 	                "Can't get the last modification date and time for %S", aFileName));
       
   402 	if ( iIsFolder )
       
   403 	    {
       
   404 	    TEntry fileEntry;
       
   405 	    User::LeaveIfError(iFramework.Fs().Entry( aFileName, fileEntry ));
       
   406 	    iIsHidden = fileEntry.IsHidden();
       
   407 	    }
       
   408 	OstTraceFunctionExit0( CMTPMOVEOBJECT_GETPREVIOUSPROPERTIESL_EXIT );
   384 	}
   409 	}
   385 
   410 
   386 /**
   411 /**
   387 Set the object properties after moving
   412 Set the object properties after moving
   388 */
   413 */
   389 void CMTPMoveObject::SetPreviousPropertiesL(const TDesC& aFileName)
   414 void CMTPMoveObject::SetPreviousPropertiesL(const TDesC& aFileName)
   390 	{
   415 	{
   391 	__FLOG(_L8("SetPreviousPropertiesL - Entry"));
   416 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_SETPREVIOUSPROPERTIESL_ENTRY );
   392 	User::LeaveIfError(iFramework.Fs().SetModified(aFileName, iPreviousModifiedTime));
   417 	LEAVEIFERROR(iFramework.Fs().SetModified(aFileName, iPreviousModifiedTime),
   393 	__FLOG(_L8("SetPreviousPropertiesL - Exit"));
   418 	        OstTraceExt1( TRACE_ERROR, CMTPMOVEOBJECT_SETPREVIOUSPROPERTIESL, "Sets the date and time for %S failed", aFileName));
       
   419 	if ( iIsFolder && iIsHidden )
       
   420 	    {
       
   421 	    TEntry fileEntry;
       
   422 	    User::LeaveIfError(iFramework.Fs().Entry( aFileName, fileEntry ));
       
   423 	    fileEntry.iAtt &= ~KEntryAttHidden;
       
   424 	    fileEntry.iAtt |= KEntryAttHidden;
       
   425 	    User::LeaveIfError(iFramework.Fs().SetAtt( aFileName, fileEntry.iAtt, ~fileEntry.iAtt));
       
   426 	    }
       
   427 	OstTraceFunctionExit0( CMTPMOVEOBJECT_SETPREVIOUSPROPERTIESL_EXIT );
   394 	}
   428 	}
   395 
   429 
   396 /**
   430 /**
   397  Call back function, called when the timer expired for big file moving.
   431  Call back function, called when the timer expired for big file moving.
   398  Send response to initiator and cache the target file entry info, which is used to send response 
   432  Send response to initiator and cache the target file entry info, which is used to send response 
   405 	return KErrNone;
   439 	return KErrNone;
   406 	}
   440 	}
   407 
   441 
   408 void CMTPMoveObject::DoOnTimeoutL()
   442 void CMTPMoveObject::DoOnTimeoutL()
   409 	{
   443 	{
   410 	__FLOG(_L8("DoOnTimeoutL - Entry"));
   444 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_DOONTIMEOUTL_ENTRY );
   411 	
   445 	
   412 	if (iTimer)
   446 	if (iTimer)
   413 		{
   447 		{
   414 		if (iTimer->IsActive())
   448 		if (iTimer->IsActive())
   415 			{
   449 			{
   419 		iTimer = NULL;
   453 		iTimer = NULL;
   420 		}
   454 		}
   421 	
   455 	
   422 	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
   456 	const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
   423 	TEntry fileEntry;
   457 	TEntry fileEntry;
   424 	User::LeaveIfError(iFramework.Fs().Entry(suid, fileEntry));
   458 	LEAVEIFERROR(iFramework.Fs().Entry(suid, fileEntry),
       
   459 	        OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_DOONTIMEOUTL, "Gets the entry details for %S failed!", suid));
   425 	TUint32 handle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);
   460 	TUint32 handle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);
   426 	
   461 	
   427 	iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewFileName);
   462 	iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewFileName);
   428 	iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
   463 	iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
   429 	iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
   464 	iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
   434 	// Cache the target file entry info, which is used to send response to getobjectproplist and getobjectinfo
   469 	// Cache the target file entry info, which is used to send response to getobjectproplist and getobjectinfo
   435 	aCache.SetOnGoing(ETrue);
   470 	aCache.SetOnGoing(ETrue);
   436 	aCache.SetTargetHandle(handle);
   471 	aCache.SetTargetHandle(handle);
   437 	aCache.SetFileEntry(fileEntry);	
   472 	aCache.SetFileEntry(fileEntry);	
   438 	
   473 	
   439 	__FLOG(_L8("UpdateFSEntryCache, sending response with respond code OK for a big file move"));
   474 	OstTrace0( TRACE_NORMAL, CMTPMOVEOBJECT_DOONTIMEOUTL, 
       
   475 	        "UpdateFSEntryCache, sending response with respond code OK for a big file move" );
   440 	SendResponseL(EMTPRespCodeOK);
   476 	SendResponseL(EMTPRespCodeOK);
   441 	
   477 	
   442 	__FLOG(_L8("DoOnTimeoutL - Exit"));
   478 	OstTraceFunctionExit0( CMTPMOVEOBJECT_DOONTIMEOUTL_EXIT );
   443 	}
   479 	}
   444 
   480 
   445 /**
   481 /**
   446  CMTPMoveObject::RunL
   482  CMTPMoveObject::RunL
   447 */
   483 */
   448 void CMTPMoveObject::RunL()
   484 void CMTPMoveObject::RunL()
   449 	{
   485 	{
   450 	__FLOG(_L8("RunL - Entry"));
   486 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_RUNL_ENTRY );
   451 	
   487 	
   452 	User::LeaveIfError(iStatus.Int());
   488 	LEAVEIFERROR(iStatus.Int(),
       
   489 	        OstTrace1( TRACE_ERROR, DUP2_CMTPMOVEOBJECT_RUNL, "wrong istatus %d", iStatus.Int()));
   453 	SetPreviousPropertiesL(*iNewFileName);
   490 	SetPreviousPropertiesL(*iNewFileName);
   454 	CMTPFSEntryCache& aCache = iDpSingletons.MovingBigFileCache();
   491 	CMTPFSEntryCache& aCache = iDpSingletons.MovingBigFileCache();
   455 	// Check to see if we are moving a big file
   492 	// Check to see if we are moving a big file
   456 	if(aCache.IsOnGoing())
   493 	if(aCache.IsOnGoing())
   457 		{
   494 		{
   458 		__FLOG(_L8("RunL - Big file move complete"));
   495 		OstTrace0( TRACE_NORMAL, CMTPMOVEOBJECT_RUNL, "RunL - Big file move complete" );
   459 		aCache.SetOnGoing(EFalse);
   496 		aCache.SetOnGoing(EFalse);
   460 		aCache.SetTargetHandle(KMTPHandleNone);
   497 		aCache.SetTargetHandle(KMTPHandleNone);
   461 		}
   498 		}
   462 	else
   499 	else
   463 		{
   500 		{
   475 		iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewFileName);
   512 		iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewFileName);
   476 		iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
   513 		iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
   477 		iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
   514 		iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
   478 		iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
   515 		iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
   479 
   516 
   480 		__FLOG(_L8("RunL, sending response with respond code OK for a normal file move"));
   517 		OstTrace0( TRACE_NORMAL, DUP1_CMTPMOVEOBJECT_RUNL, 
       
   518 		        "RunL, sending response with respond code OK for a normal file move" );
   481 		SendResponseL(EMTPRespCodeOK);
   519 		SendResponseL(EMTPRespCodeOK);
   482 		}
   520 		}
   483 	__FLOG(_L8("RunL - Exit"));
   521 	OstTraceFunctionExit0( CMTPMOVEOBJECT_RUNL_EXIT );
   484 	}
   522 	}
   485 
   523 
   486 /**
   524 /**
   487 Override to handle the complete phase of move object
   525 Override to handle the complete phase of move object
   488 */
   526 */
   507 @param aConnection The connection from which the request comes
   545 @param aConnection The connection from which the request comes
   508 @return ETrue if the processor can handle the request, otherwise EFalse
   546 @return ETrue if the processor can handle the request, otherwise EFalse
   509 */        
   547 */        
   510 TBool CMTPMoveObject::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
   548 TBool CMTPMoveObject::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const
   511 	{
   549 	{
   512 	__FLOG(_L8("Match - Entry"));
   550 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_MATCH_ENTRY );
   513 	TBool result = EFalse;
   551 	TBool result = EFalse;
   514 	TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
   552 	TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode);
   515 	if ((operationCode == EMTPOpCodeMoveObject) && &iConnection == &aConnection)
   553 	if ((operationCode == EMTPOpCodeMoveObject) && &iConnection == &aConnection)
   516 	{
   554 	{
   517 	result = ETrue;
   555 	result = ETrue;
   518 	}    
   556 	}    
   519 	__FLOG_VA((_L8("Match -- Exit with result = %d"), result));
   557 	OstTrace1( TRACE_NORMAL, CMTPMOVEOBJECT_MATCH, "with result = %d", result );
       
   558 	OstTraceFunctionExit0( CMTPMOVEOBJECT_MATCH_EXIT );
   520 	return result;
   559 	return result;
   521 	}
   560 	}