// ----------------------------------------------------------------------------- // CMoveObject::MoveObjectL // Move object operation // ----------------------------------------------------------------------------- // void CMoveObject::MoveObjectL() { PRINT( _L( "MM MTP => CMoveObject::MoveObjectL" ) ); TMTPResponseCode responseCode = EMTPRespCodeOK; GetParametersL(); RBuf newObjectName; newObjectName.CreateL( KMaxFileName ); newObjectName.CleanupClosePushL(); // + newObjectName newObjectName = *iDest; TPtrC suid( iObjectInfo->DesC( CMTPObjectMetaData::ESuid ) ); TParsePtrC fileNameParser( suid ); if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() ) <= newObjectName.MaxLength() ) { newObjectName.Append( fileNameParser.NameAndExt() ); responseCode = CanMoveObjectL( suid, newObjectName ); if ( responseCode == EMTPRespCodeOK ) MoveFileL( newObjectName ); } else // Destination is not appropriate for the full path name shouldn't be longer than 255 responseCode = EMTPRespCodeInvalidDataset; SendResponseL( responseCode ); CleanupStack::PopAndDestroy( &newObjectName ); // - newObjectName PRINT1( _L( "MM MTP <= CMoveObject::MoveObjectL responseCode = 0x%x" ), responseCode ); }
/** move object operations @return A valid MTP response code. */ TMTPResponseCode CMTPMoveObject::MoveObjectL() { OstTraceFunctionEntry0( CMTPMOVEOBJECT_MOVEOBJECTL_ENTRY ); TMTPResponseCode responseCode = EMTPRespCodeOK; GetParametersL(); RBuf newObjectName; newObjectName.CreateL(KMaxFileName); newObjectName.CleanupClosePushL(); newObjectName = *iDest; const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid)); TParsePtrC fileNameParser(suid); // Check if the object is a folder or a file. if(!iIsFolder) { if((newObjectName.Length() + fileNameParser.NameAndExt().Length()) <= newObjectName.MaxLength()) { newObjectName.Append(fileNameParser.NameAndExt()); } responseCode = CanMoveObjectL(suid, newObjectName); } else // It is a folder. { TFileName rightMostFolderName; LEAVEIFERROR(BaflUtils::MostSignificantPartOfFullName(suid, rightMostFolderName), OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_MOVEOBJECTL, "extract most significant part of %S failed", suid)); if((newObjectName.Length() + rightMostFolderName.Length() + 1) <= newObjectName.MaxLength()) { newObjectName.Append(rightMostFolderName); // Add backslash. _LIT(KBackSlash, "\\"); newObjectName.Append(KBackSlash); } } iNewRootFolder = newObjectName.AllocL(); OstTraceExt1( TRACE_NORMAL, CMTPMOVEOBJECT_MOVEOBJECTL, "%S", *iNewRootFolder ); if(responseCode == EMTPRespCodeOK) { delete iFileMan; iFileMan = NULL; iFileMan = CFileMan::NewL(iFramework.Fs()); if(!iIsFolder) { MoveFileL(newObjectName); } else { MoveFolderL(); SendResponseL(responseCode); } } CleanupStack::PopAndDestroy(); // newObjectName. OstTraceFunctionExit0( CMTPMOVEOBJECT_MOVEOBJECTL_EXIT ); return responseCode; }