mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cdeleteobject.cpp
branchRCL_3
changeset 67 16db3449d7ba
parent 53 e42293e811d8
equal deleted inserted replaced
63:91d5ad76f5c6 67:16db3449d7ba
    24 #include "mmmtpdpconfig.h"
    24 #include "mmmtpdpconfig.h"
    25 #include "cmmmtpdpmetadataaccesswrapper.h"
    25 #include "cmmmtpdpmetadataaccesswrapper.h"
    26 #include "mmmtpdputility.h"
    26 #include "mmmtpdputility.h"
    27 
    27 
    28 const TInt KMaxDeletionTimes = 10;
    28 const TInt KMaxDeletionTimes = 10;
    29 const TInt KMaxDeviceBusyTimes = 3;
       
    30 const TInt KDeletionThreshold = 100 * 1000; // (100 millisec)
    29 const TInt KDeletionThreshold = 100 * 1000; // (100 millisec)
    31 
    30 
    32 // -----------------------------------------------------------------------------
    31 // -----------------------------------------------------------------------------
    33 // Verification data for the DeleteObject request
    32 // Verification data for the DeleteObject request
    34 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
   293     {
   292     {
   294     TRAP_IGNORE( ProcessFinalPhaseL() );
   293     TRAP_IGNORE( ProcessFinalPhaseL() );
   295     }
   294     }
   296 
   295 
   297 // -----------------------------------------------------------------------------
   296 // -----------------------------------------------------------------------------
   298 // CDeleteObject::DoHandleCompletingPhaseL
       
   299 // Completeing phase Handler
       
   300 // -----------------------------------------------------------------------------
       
   301 //
       
   302 EXPORT_C TBool CDeleteObject::DoHandleCompletingPhaseL()
       
   303     {
       
   304     CRequestProcessor::DoHandleCompletingPhaseL();
       
   305 
       
   306     // If the response code is EMTPRespCodeDeviceBusy, don't release this object
       
   307     TBool result = !iDeviceBusy;
       
   308 
       
   309     PRINT2( _L( "MM MTP <> CDeleteObject::DoHandleCompletingPhaseL iDeleteError= %d, result = %d" ),
       
   310             iDeleteError,
       
   311             result );
       
   312 
       
   313     return result;
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CDeleteObject::ProcessFinalPhaseL
   297 // CDeleteObject::ProcessFinalPhaseL
   318 // Delete all of the associations if file deletion was successful
   298 // Delete all of the associations if file deletion was successful
   319 // Then signals that the deletion has been completed
   299 // Then signals that the deletion has been completed
   320 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   321 //
   301 //
   323     {
   303     {
   324     PRINT( _L( "MM MTP => CDeleteObject::ProcessFinalPhaseL" ) );
   304     PRINT( _L( "MM MTP => CDeleteObject::ProcessFinalPhaseL" ) );
   325 
   305 
   326     TInt num = iObjectsToDelete.Count();
   306     TInt num = iObjectsToDelete.Count();
   327     TBool isOk = iDeleteError == KErrNone || iDeleteError == KErrNotFound;
   307     TBool isOk = iDeleteError == KErrNone || iDeleteError == KErrNotFound;
   328     iDeviceBusy = EFalse;
       
   329 
   308 
   330     if ( num == 0 && isOk )
   309     if ( num == 0 && isOk )
   331         {
   310         {
   332         SendResponseL( EMTPRespCodeOK );
   311         SendResponseL( EMTPRespCodeOK );
   333         }
   312         }
   334     else if ( iIsMultiDelete && !isOk )
   313     else if ( iIsMultiDelete && !isOk )
   335         {
   314         {
   336         SendResponseL( EMTPRespCodePartialDeletion );
   315         SendResponseL( EMTPRespCodePartialDeletion );
   337         }
   316         }
   338     else if ( !iIsMultiDelete && iDeleteError == KErrAccessDenied )
   317     else if ( !iIsMultiDelete && iDeleteError == KErrAccessDenied )
   339         { 
   318         {
   340         SendResponseL( EMTPRespCodeObjectWriteProtected );
   319         SendResponseL( EMTPRespCodeObjectWriteProtected );
   341         }
   320         }
   342     else if ( iDeleteError == KErrInUse 
   321     else if ( iDeleteError == KErrInUse )
   343             && iCountDeviceBusyError < KMaxDeviceBusyTimes )
   322         {
   344         {
       
   345         iCountDeviceBusyError++;
       
   346         SendResponseL( EMTPRespCodeDeviceBusy );
   323         SendResponseL( EMTPRespCodeDeviceBusy );
   347         iDeviceBusy = ETrue;
       
   348         }
   324         }
   349     else
   325     else
   350         {
   326         {
   351         SendResponseL( EMTPRespCodeAccessDenied );
   327         SendResponseL( EMTPRespCodeAccessDenied );
   352         }
   328         }