147 TParsePtrC fileNameParser( suid ); |
147 TParsePtrC fileNameParser( suid ); |
148 if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() ) |
148 if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() ) |
149 <= newObjectName.MaxLength() ) |
149 <= newObjectName.MaxLength() ) |
150 { |
150 { |
151 newObjectName.Append( fileNameParser.NameAndExt() ); |
151 newObjectName.Append( fileNameParser.NameAndExt() ); |
152 } |
152 responseCode = CanMoveObjectL( suid, newObjectName ); |
153 responseCode = CanMoveObjectL( suid, newObjectName ); |
153 |
154 |
154 if ( responseCode == EMTPRespCodeOK ) |
155 if ( responseCode == EMTPRespCodeOK ) |
155 MoveFileL( newObjectName ); |
156 MoveFileL( newObjectName ); |
156 } |
|
157 else |
|
158 // Destination is not appropriate for the full path name shouldn't be longer than 255 |
|
159 responseCode = EMTPRespCodeInvalidDataset; |
157 |
160 |
158 SendResponseL( responseCode ); |
161 SendResponseL( responseCode ); |
159 |
162 |
160 CleanupStack::PopAndDestroy( &newObjectName ); // - newObjectName |
163 CleanupStack::PopAndDestroy( &newObjectName ); // - newObjectName |
161 |
164 |
287 |
290 |
288 if ( iStorageId == iObjectInfo->Uint( CMTPObjectMetaData::EStorageId ) ) |
291 if ( iStorageId == iObjectInfo->Uint( CMTPObjectMetaData::EStorageId ) ) |
289 iSameStorage = ETrue; |
292 iSameStorage = ETrue; |
290 else |
293 else |
291 iSameStorage = EFalse; |
294 iSameStorage = EFalse; |
|
295 |
|
296 // Move the file first no matter if it will fail in Get/SetPreviousPropertiesL |
|
297 // Already trapped inside |
292 GetPreviousPropertiesL( *iObjectInfo ); |
298 GetPreviousPropertiesL( *iObjectInfo ); |
293 SetPropertiesL( oldFileName, aNewFileName ); |
299 TRAPD( err, SetPropertiesL( oldFileName, aNewFileName ) ); |
294 |
300 |
295 CFileMan* fileMan = CFileMan::NewL( iFramework.Fs() ); |
301 CFileMan* fileMan = CFileMan::NewL( iFramework.Fs() ); |
296 CleanupStack::PushL( fileMan ); |
302 err = fileMan->Move( oldFileName, aNewFileName ); |
297 User::LeaveIfError( fileMan->Move( oldFileName, aNewFileName ) ); |
303 |
298 CleanupStack::PopAndDestroy( fileMan ); |
304 if ( err != KErrNone ) |
299 |
305 PRINT1( _L( "MM MTP <> CMoveObject::MoveFileL err = %d" ), err ); |
300 User::LeaveIfError( iFramework.Fs().SetModified( aNewFileName, |
|
301 iPreviousModifiedTime ) ); |
|
302 |
306 |
303 PRINT( _L( "MM MTP <= CMoveObject::MoveFileL" ) ); |
307 PRINT( _L( "MM MTP <= CMoveObject::MoveFileL" ) ); |
304 } |
308 } |
305 |
309 |
306 // ----------------------------------------------------------------------------- |
310 // ----------------------------------------------------------------------------- |
311 void CMoveObject::GetPreviousPropertiesL( const CMTPObjectMetaData& aObject ) |
315 void CMoveObject::GetPreviousPropertiesL( const CMTPObjectMetaData& aObject ) |
312 { |
316 { |
313 PRINT( _L( "MM MTP => CMoveObject::GetPreviousPropertiesL" ) ); |
317 PRINT( _L( "MM MTP => CMoveObject::GetPreviousPropertiesL" ) ); |
314 |
318 |
315 const TDesC& suid( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
319 const TDesC& suid( aObject.DesC( CMTPObjectMetaData::ESuid ) ); |
316 User::LeaveIfError( iFramework.Fs().Modified( suid, iPreviousModifiedTime ) ); |
|
317 |
320 |
318 // same storage, not necessary to get the properties |
321 // same storage, not necessary to get the properties |
319 if ( iSameStorage ) |
322 if ( iSameStorage ) |
320 return; |
323 return; |
321 |
324 |
373 { |
376 { |
374 iPropertyElement = &( iPropertyList->ReservePropElemL( handle, propCode ) ); |
377 iPropertyElement = &( iPropertyList->ReservePropElemL( handle, propCode ) ); |
375 iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue, |
378 iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue, |
376 textData->StringChars() ); |
379 textData->StringChars() ); |
377 } |
380 } |
378 else if ( err == KErrNotFound ) |
381 else |
379 { |
382 { |
380 iPropertyElement = NULL; |
383 iPropertyElement = NULL; |
381 } |
|
382 else |
|
383 { |
|
384 User::Leave( err ); |
|
385 } |
384 } |
386 |
385 |
387 CleanupStack::PopAndDestroy( textData ); // - textData |
386 CleanupStack::PopAndDestroy( textData ); // - textData |
388 } |
387 } |
389 break; |
388 break; |
445 break; |
444 break; |
446 |
445 |
447 case EMTPObjectPropCodeNonConsumable: |
446 case EMTPObjectPropCodeNonConsumable: |
448 iObjectInfo->SetUint( CMTPObjectMetaData::ENonConsumable, |
447 iObjectInfo->SetUint( CMTPObjectMetaData::ENonConsumable, |
449 element.Uint8L( CMTPTypeObjectPropListElement::EValue ) ); |
448 element.Uint8L( CMTPTypeObjectPropListElement::EValue ) ); |
|
449 iFramework.ObjectMgr().ModifyObjectL( *iObjectInfo ); |
450 break; |
450 break; |
451 |
451 |
452 case EMTPObjectPropCodeName: |
452 case EMTPObjectPropCodeName: |
453 { |
453 { |
454 CMTPTypeString *stringData = CMTPTypeString::NewLC( element.StringL( CMTPTypeObjectPropListElement::EValue ) ); // + stringData |
454 CMTPTypeString *stringData = CMTPTypeString::NewLC( element.StringL( CMTPTypeObjectPropListElement::EValue ) ); // + stringData |
455 |
455 |
456 respcode = iDpConfig.PropSettingUtility()->SetMetaDataToWrapperL( iDpConfig, |
456 respcode = iDpConfig.PropSettingUtility()->SetMetaDataToWrapper( iDpConfig, |
457 propertyCode, |
457 propertyCode, |
458 *stringData, |
458 *stringData, |
459 *iObjectInfo ); |
459 *iObjectInfo ); |
460 |
460 |
461 CleanupStack::PopAndDestroy( stringData ); // - stringData |
461 CleanupStack::PopAndDestroy( stringData ); // - stringData |
487 const TDesC& aNewFileName ) |
491 const TDesC& aNewFileName ) |
488 { |
492 { |
489 PRINT2( _L( "MM MTP => CMoveObject::SetPropertiesL aOldFileName = %S, aNewFileName = %S" ), |
493 PRINT2( _L( "MM MTP => CMoveObject::SetPropertiesL aOldFileName = %S, aNewFileName = %S" ), |
490 &aOldFileName, |
494 &aOldFileName, |
491 &aNewFileName ); |
495 &aNewFileName ); |
492 |
496 |
493 iObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, aNewFileName ); |
497 iObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, aNewFileName ); |
494 iObjectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId ); |
498 iObjectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId ); |
495 iObjectInfo->SetUint( CMTPObjectMetaData::EParentHandle, iNewParentHandle ); |
499 iObjectInfo->SetUint( CMTPObjectMetaData::EParentHandle, iNewParentHandle ); |
|
500 iFramework.ObjectMgr().ModifyObjectL( *iObjectInfo ); |
496 |
501 |
497 TUint32 formatCode = iObjectInfo->Uint( CMTPObjectMetaData::EFormatCode ); |
502 TUint32 formatCode = iObjectInfo->Uint( CMTPObjectMetaData::EFormatCode ); |
498 if ( formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist ) |
503 if ( formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist ) |
499 { |
504 { |
500 // This is used to keep the same behavior in mass storage and device file manager. |
505 // This is used to keep the same behavior in mass storage and device file manager. |
501 PRINT( _L( "MM MTP <> CMoveObject::SetPropertiesL Playlist file do not update the MPX DB" ) ); |
506 PRINT( _L( "MM MTP <> CMoveObject::SetPropertiesL Playlist file do not update the MPX DB" ) ); |
502 } |
507 } |
503 else |
508 else |
|
509 // TODO: Need rollback mechanism for consistant with image dp in fw. |
|
510 // Not sure if it should be trap if something wrong with MPX db. |
504 { |
511 { |
505 if ( iSameStorage ) |
512 if ( iSameStorage ) |
|
513 { |
506 iDpConfig.GetWrapperL().RenameObjectL( aOldFileName, aNewFileName ); |
514 iDpConfig.GetWrapperL().RenameObjectL( aOldFileName, aNewFileName ); |
507 // if the two object in different storage, we should delete the old one and insert new one |
515 } |
508 else |
516 else // if the two object in different storage, we should delete the old one and insert new one |
509 { |
517 { |
510 iDpConfig.GetWrapperL().DeleteObjectL( aOldFileName, formatCode ); |
518 iDpConfig.GetWrapperL().DeleteObjectL( aOldFileName, formatCode ); |
511 |
519 |
512 TUint32 subFormatCode = iObjectInfo->Uint( CMTPObjectMetaData::EFormatSubCode ); |
520 TUint32 subFormatCode = iObjectInfo->Uint( CMTPObjectMetaData::EFormatSubCode ); |
513 iDpConfig.GetWrapperL().AddObjectL( aNewFileName, |
521 iDpConfig.GetWrapperL().AddObjectL( aNewFileName, |
514 formatCode, |
522 formatCode, |
515 subFormatCode ); |
523 subFormatCode ); |
516 |
524 |
|
525 // Only leave when getting proplist element from data received by fw. |
|
526 // It should not happen after ReceiveDataL in which construction of proplist already succeed. |
517 SetPreviousPropertiesL(); |
527 SetPreviousPropertiesL(); |
518 } |
528 } |
519 } |
529 } |
520 |
530 |
521 iFramework.ObjectMgr().ModifyObjectL( *iObjectInfo ); |
|
522 |
|
523 // It's not necessary to change references of playlists since Reference DB is used PUID |
531 // It's not necessary to change references of playlists since Reference DB is used PUID |
524 |
532 |
525 PRINT( _L( "MM MTP <= CMoveObject::SetPropertiesL" ) ); |
533 PRINT( _L( "MM MTP <= CMoveObject::SetPropertiesL" ) ); |
526 } |
534 } |
527 |
535 |