mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cdeleteobject.cpp
branchRCL_3
changeset 14 05b0d2323768
parent 9 bee149131e4b
child 17 780c925249c1
equal deleted inserted replaced
9:bee149131e4b 14:05b0d2323768
    25 #include "mmmtpdplogger.h"
    25 #include "mmmtpdplogger.h"
    26 #include "mmmtpdpconfig.h"
    26 #include "mmmtpdpconfig.h"
    27 #include "cmmmtpdpmetadataaccesswrapper.h"
    27 #include "cmmmtpdpmetadataaccesswrapper.h"
    28 #include "mmmtpdputility.h"
    28 #include "mmmtpdputility.h"
    29 
    29 
    30 // static const TInt KMTPDriveGranularity = 5;
    30 static const TInt KMaxDeletionTimes = 10;
       
    31 const TInt KDeletionThreshold = 100 * 1000; // (100 millisec)
    31 
    32 
    32 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    33 // Verification data for the DeleteObject request
    34 // Verification data for the DeleteObject request
    34 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    35 //
    36 //
   225 void CDeleteObject::DeleteObjectL( const CMTPObjectMetaData& aObjectInfo )
   226 void CDeleteObject::DeleteObjectL( const CMTPObjectMetaData& aObjectInfo )
   226     {
   227     {
   227     TFileName fileName( aObjectInfo.DesC( CMTPObjectMetaData::ESuid ) );
   228     TFileName fileName( aObjectInfo.DesC( CMTPObjectMetaData::ESuid ) );
   228     PRINT1( _L( "MM MTP <> CDeleteObject::DeleteObjectL fileName = %S" ), &fileName );
   229     PRINT1( _L( "MM MTP <> CDeleteObject::DeleteObjectL fileName = %S" ), &fileName );
   229 
   230 
   230     TParsePtrC parse( fileName );
   231     iDpConfig.GetWrapperL().SetStorageRootL( fileName );
   231     iDpConfig.GetWrapperL().SetStorageRootL( parse.Drive() );
       
   232 
   232 
   233     // To capture special situation: After copy, move, rename playlist folder name,
   233     // To capture special situation: After copy, move, rename playlist folder name,
   234     // record in MPX is not inlined with framework db, playlist should not be deleted
   234     // record in MPX is not inlined with framework db, playlist should not be deleted
   235     // until next session.
   235     // until next session.
   236     // This is used to keep the same behavior in mass storage and device file manager.
   236     // This is used to keep the same behavior in mass storage and device file manager.
   250         {
   250         {
   251         iDeleteError = KErrAccessDenied;
   251         iDeleteError = KErrAccessDenied;
   252         PRINT1( _L( "MM MTP <= CDeleteObject::DeleteObjectL, \"%S\" is a read-only file"), &fileName );
   252         PRINT1( _L( "MM MTP <= CDeleteObject::DeleteObjectL, \"%S\" is a read-only file"), &fileName );
   253         return;
   253         return;
   254         }
   254         }
   255     iDeleteError = iFs.Delete( fileName );
   255     // Some other component might be holding on to the file (MDS background harvesting),
   256     if ( iDeleteError != KErrNone && iDeleteError != KErrNotFound )
   256     // try again after 100 millisec, up to 10 times, before give up
   257         {
   257     TInt count = KMaxDeletionTimes;
   258         PRINT1( _L( "MM MTP <= CDeleteObject::DeleteObjectL, Delete from file system failed, err = %d" ), iDeleteError );
   258     while ( count > 0 )
   259         return;
   259         {
       
   260         iDeleteError = iFs.Delete( fileName );
       
   261         if ( iDeleteError == KErrNone || iDeleteError == KErrNotFound )
       
   262             {
       
   263             break;
       
   264             }
       
   265         else if ( ( iDeleteError == KErrInUse ) && ( count > 1 ) )
       
   266             {
       
   267             User::After( KDeletionThreshold );
       
   268             count--;
       
   269             }
       
   270         else
       
   271             {
       
   272             PRINT1( _L( "MM MTP <= CDeleteObject::DeleteObjectL, Delete from file system failed, err = %d" ), iDeleteError );
       
   273             return;
       
   274             }
   260         }
   275         }
   261 
   276 
   262     // 2. Delete object from metadata db
   277     // 2. Delete object from metadata db
   263     TRAP( iDeleteError, iDpConfig.GetWrapperL().DeleteObjectL( fileName, aObjectInfo.Uint( CMTPObjectMetaData::EFormatCode ) ));
   278     TRAP( iDeleteError, iDpConfig.GetWrapperL().DeleteObjectL( fileName, aObjectInfo.Uint( CMTPObjectMetaData::EFormatCode ) ));
   264     PRINT1( _L( "MM MTP <> CDeleteObject::DeleteObjectL, Delete from Media DB, err = %d" ), iDeleteError );
   279     PRINT1( _L( "MM MTP <> CDeleteObject::DeleteObjectL, Delete from Media DB, err = %d" ), iDeleteError );