mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/crenameobject.cpp
changeset 25 d881023c13eb
parent 0 a2952bb97e68
child 27 cbb1bfb7ebfb
--- a/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/crenameobject.cpp	Fri Apr 16 15:28:14 2010 +0300
+++ b/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/crenameobject.cpp	Mon May 03 12:58:40 2010 +0300
@@ -18,9 +18,7 @@
 
 #include <f32file.h>
 
-#include <mtp/mmtpdataproviderframework.h>
 #include <mtp/mmtpobjectmgr.h>
-#include <mtp/cmtpobjectmetadata.h>
 #include <mtp/tmtptypeuint32.h>
 
 #include "crenameobject.h"
@@ -34,7 +32,7 @@
 // -----------------------------------------------------------------------------
 //
 EXPORT_C CRenameObject* CRenameObject::NewL( MMTPDataProviderFramework& aFramework,
-        CMmMtpDpMetadataAccessWrapper& aWrapper )
+    CMmMtpDpMetadataAccessWrapper& aWrapper )
     {
     PRINT( _L( "MM MTP => CRenameObject::NewL" ) );
 
@@ -59,6 +57,7 @@
     iObjectHandles( KMmMtpRArrayGranularity ),
     iWrapper ( aWrapper )
     {
+    // Do nothing
     }
 
 // -----------------------------------------------------------------------------
@@ -121,7 +120,7 @@
 //
 EXPORT_C void CRenameObject::DoCancel()
     {
-
+    // Do nothing
     }
 
 // -----------------------------------------------------------------------------
@@ -146,6 +145,8 @@
 
             if ( iNewFolderName.Length() + iRightPartName.Length() <= KMaxFileName )
                 {
+                PerformAdditionalActionL();
+
                 iFileName.Zero();
                 iFileName.Append( iNewFolderName );
                 iFileName.Append( iRightPartName );
@@ -154,8 +155,6 @@
                 iObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, iFileName );
                 iObjectInfo->SetUint( CMTPObjectMetaData::EObjectMetaDataUpdate, 1 );
                 iFramework.ObjectMgr().ModifyObjectL( *iObjectInfo );
-
-                PerformAdditionalActionL();
                 }
             }
 
@@ -220,8 +219,7 @@
     CleanupClosePushL( context ); // + context
     CleanupClosePushL( handles ); // + handles
 
-    TMTPObjectMgrQueryParams params( KMTPStorageAll, KMTPFormatsAll,
-            aParentHandle );
+    TMTPObjectMgrQueryParams params( KMTPStorageAll, KMTPFormatsAll, aParentHandle );
     do
         {
         iFramework.ObjectMgr().GetObjectHandlesL( params, context, handles );
@@ -232,14 +230,8 @@
             if ( iFramework.ObjectMgr().ObjectOwnerId( handles[i] ) == iFramework.DataProviderId() )
                 {
                 iObjectHandles.AppendL( handles[i] );
-                continue;
-                }
+                // NOTE: Fw changed the mechanism of notification, no need to iterate
 
-            // Folder
-            // TODO: need to modify, should not know device dp id
-            if ( iFramework.ObjectMgr().ObjectOwnerId( handles[i] ) == 0 ) // We know that the device dp id is always 0, otherwise the whole MTP won't work.
-                {
-                GenerateObjectHandleListL( handles[i] );
                 }
             }
         }
@@ -260,7 +252,8 @@
     const TDesC& aFolderName )
     {
     PRINT2( _L( "MM MTP => CRenameObject::GetParentSuidL aHandle(0x%x), aFolderName(%S)" ),
-        aHandle, &aFolderName );
+        aHandle,
+        &aFolderName );
     CMTPObjectMetaData* objectInfo( CMTPObjectMetaData::NewLC() ); // + objectInfo
     // get the old folder suid
     if ( iFramework .ObjectMgr().ObjectL( aHandle, *objectInfo ) )
@@ -268,15 +261,10 @@
         iNewFolderName.Zero();
         iNewFolderName = objectInfo->DesC( CMTPObjectMetaData::ESuid );
         PRINT1( _L( "MM MTP <> CRenameObject::GetParentSuidL new folder full file name(%S)" ), &iNewFolderName );
-        const TInt length = iNewFolderName.Length();
-
-        TParsePtrC parentSuid( iNewFolderName.Left( length - 1 ) );
 
         iOldFolderFullName.Zero();
-        iOldFolderFullName.Append( parentSuid.DriveAndPath() );
         iOldFolderFullName.Append( aFolderName ); // just name not suid
-        _LIT( KBackSlash, "\\" );
-        iOldFolderFullName.Append( KBackSlash );
+
         PRINT1( _L( "MM MTP <> CRenameObject::GetParentSuidL = %S" ), &iOldFolderFullName );
         }
     else
@@ -297,7 +285,7 @@
     PRINT( _L( "MM MTP => CRenameObject::PerformAdditionalActionL" ) );
 
     // update MPX DB
-    TRAPD( err, iWrapper.RenameObjectL( iOldFileName, iFileName ) );
+    TRAPD( err, iWrapper.RenameObjectL( *iObjectInfo, iFileName ) );
 
     // should not fail for 1 file, keep it going, as folder already renamed
     if ( err != KErrNone )