20 #include <mtp/mmtpobjectmgr.h> |
20 #include <mtp/mmtpobjectmgr.h> |
21 #include <mtp/mmtpstoragemgr.h> |
21 #include <mtp/mmtpstoragemgr.h> |
22 #include <mtp/cmtptypearray.h> |
22 #include <mtp/cmtptypearray.h> |
23 #include <mtp/cmtptypestring.h> |
23 #include <mtp/cmtptypestring.h> |
24 #include <mtp/cmtptypeobjectproplist.h> |
24 #include <mtp/cmtptypeobjectproplist.h> |
|
25 #include <mtp/mmtpreferencemgr.h> |
25 |
26 |
26 #include "cmoveobject.h" |
27 #include "cmoveobject.h" |
27 #include "mmmtpdplogger.h" |
28 #include "mmmtpdplogger.h" |
28 #include "tmmmtpdppanic.h" |
29 #include "tmmmtpdppanic.h" |
29 #include "mmmtpdputility.h" |
30 #include "mmmtpdputility.h" |
139 RBuf newObjectName; |
140 RBuf newObjectName; |
140 newObjectName.CreateL( KMaxFileName ); |
141 newObjectName.CreateL( KMaxFileName ); |
141 newObjectName.CleanupClosePushL(); // + newObjectName |
142 newObjectName.CleanupClosePushL(); // + newObjectName |
142 newObjectName = *iDest; |
143 newObjectName = *iDest; |
143 |
144 |
144 const TDesC& suid( iObjectInfo->DesC( CMTPObjectMetaData::ESuid ) ); |
145 TPtrC suid( iObjectInfo->DesC( CMTPObjectMetaData::ESuid ) ); |
145 TParsePtrC fileNameParser( suid ); |
146 TParsePtrC fileNameParser( suid ); |
146 if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() ) |
147 if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() ) |
147 <= newObjectName.MaxLength() ) |
148 <= newObjectName.MaxLength() ) |
148 { |
149 { |
149 newObjectName.Append( fileNameParser.NameAndExt() ); |
150 newObjectName.Append( fileNameParser.NameAndExt() ); |
417 CMTPTypeObjectPropListElement& element = iPropertyList->GetNextElementL(); |
418 CMTPTypeObjectPropListElement& element = iPropertyList->GetNextElementL(); |
418 |
419 |
419 TUint32 handle = element.Uint32L( CMTPTypeObjectPropListElement::EObjectHandle ); |
420 TUint32 handle = element.Uint32L( CMTPTypeObjectPropListElement::EObjectHandle ); |
420 TUint16 propertyCode = element.Uint16L( CMTPTypeObjectPropListElement::EPropertyCode ); |
421 TUint16 propertyCode = element.Uint16L( CMTPTypeObjectPropListElement::EPropertyCode ); |
421 TUint16 dataType = element.Uint16L( CMTPTypeObjectPropListElement::EDatatype ); |
422 TUint16 dataType = element.Uint16L( CMTPTypeObjectPropListElement::EDatatype ); |
422 PRINT3( _L( "MM MTP <> CCopyObject::SetPreviousPropertiesL = 0x%x, propertyCode = 0x%x, dataType = 0x%x" ), |
423 PRINT3( _L( "MM MTP <> CMoveObject::SetPreviousPropertiesL = 0x%x, propertyCode = 0x%x, dataType = 0x%x" ), |
423 handle, |
424 handle, |
424 propertyCode, |
425 propertyCode, |
425 dataType ); |
426 dataType ); |
426 |
427 |
427 switch ( propertyCode ) |
428 switch ( propertyCode ) |
490 TUint32 formatCode = iObjectInfo->Uint( CMTPObjectMetaData::EFormatCode ); |
491 TUint32 formatCode = iObjectInfo->Uint( CMTPObjectMetaData::EFormatCode ); |
491 if ( formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist ) |
492 if ( formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist ) |
492 { |
493 { |
493 // This is used to keep the same behavior in mass storage and device file manager. |
494 // This is used to keep the same behavior in mass storage and device file manager. |
494 PRINT( _L( "MM MTP <> CMoveObject::SetPropertiesL Playlist file do not update the MPX DB" ) ); |
495 PRINT( _L( "MM MTP <> CMoveObject::SetPropertiesL Playlist file do not update the MPX DB" ) ); |
495 } |
496 iDpConfig.GetWrapperL().DeleteDummyFile( iObjectInfo->DesC( CMTPObjectMetaData::ESuid ) ); |
496 else |
497 iDpConfig.GetWrapperL().AddDummyFileL( aNewFileName ); |
497 // TODO: Need rollback mechanism for consistant with image dp in fw. |
498 } |
498 // Not sure if it should be trap if something wrong with MPX db. |
499 |
499 { |
500 if (iSameStorage) |
500 if ( iSameStorage ) |
501 { |
|
502 iDpConfig.GetWrapperL().RenameObjectL( *iObjectInfo, aNewFileName ); |
|
503 iObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, aNewFileName ); |
|
504 iObjectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId ); |
|
505 iObjectInfo->SetUint( CMTPObjectMetaData::EParentHandle, iNewParentHandle ); |
|
506 iFramework.ObjectMgr().ModifyObjectL( *iObjectInfo ); |
|
507 } |
|
508 else // if the two object in different storage, we should delete the old one and insert new one |
|
509 { |
|
510 iDpConfig.GetWrapperL().DeleteObjectL( *iObjectInfo ); |
|
511 |
|
512 HBufC* oldFileName = iObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocLC(); // + oldFileName |
|
513 iObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, aNewFileName ); |
|
514 iObjectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId ); |
|
515 iObjectInfo->SetUint( CMTPObjectMetaData::EParentHandle, iNewParentHandle ); |
|
516 iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo); |
|
517 |
|
518 iDpConfig.GetWrapperL().SetStorageRootL( aNewFileName ); |
|
519 iDpConfig.GetWrapperL().AddObjectL( *iObjectInfo ); |
|
520 |
|
521 if ( formatCode == EMTPFormatCodeAbstractAudioVideoPlaylist |
|
522 || formatCode == EMTPFormatCodeAbstractAudioAlbum ) |
501 { |
523 { |
502 iDpConfig.GetWrapperL().RenameObjectL( *iObjectInfo, aNewFileName ); |
524 MMTPReferenceMgr& referenceMgr = iFramework.ReferenceMgr(); |
|
525 CDesCArray* references = referenceMgr.ReferencesLC( aNewFileName ); // + references |
|
526 iDpConfig.GetWrapperL().SetReferenceL( *iObjectInfo, *references ); |
|
527 CleanupStack::PopAndDestroy( references ); // - references |
503 } |
528 } |
504 else // if the two object in different storage, we should delete the old one and insert new one |
529 CleanupStack::PopAndDestroy( oldFileName ); // - oldFileName |
505 { |
530 |
506 iDpConfig.GetWrapperL().DeleteObjectL( *iObjectInfo ); |
531 // Only leave when getting proplist element from data received by fw. |
507 iDpConfig.GetWrapperL().AddObjectL( *iObjectInfo ); |
532 // It should not happen after ReceiveDataL in which construction of proplist already succeed. |
508 |
533 SetPreviousPropertiesL(); |
509 // Only leave when getting proplist element from data received by fw. |
534 } |
510 // It should not happen after ReceiveDataL in which construction of proplist already succeed. |
|
511 SetPreviousPropertiesL(); |
|
512 } |
|
513 } |
|
514 |
|
515 iObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, aNewFileName ); |
|
516 iObjectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId ); |
|
517 iObjectInfo->SetUint( CMTPObjectMetaData::EParentHandle, iNewParentHandle ); |
|
518 iFramework.ObjectMgr().ModifyObjectL( *iObjectInfo ); |
|
519 |
|
520 // It's not necessary to change references of playlists since Reference DB is used PUID |
|
521 |
535 |
522 PRINT( _L( "MM MTP <= CMoveObject::SetPropertiesL" ) ); |
536 PRINT( _L( "MM MTP <= CMoveObject::SetPropertiesL" ) ); |
523 } |
537 } |
524 |
538 |
525 // end of file |
539 // end of file |