mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cdeleteobject.cpp
branchRCL_3
changeset 53 e42293e811d8
parent 34 e257e2b6459d
child 67 16db3449d7ba
--- a/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cdeleteobject.cpp	Thu Jul 15 19:11:42 2010 +0300
+++ b/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cdeleteobject.cpp	Thu Aug 19 10:24:28 2010 +0300
@@ -26,6 +26,7 @@
 #include "mmmtpdputility.h"
 
 const TInt KMaxDeletionTimes = 10;
+const TInt KMaxDeviceBusyTimes = 3;
 const TInt KDeletionThreshold = 100 * 1000; // (100 millisec)
 
 // -----------------------------------------------------------------------------
@@ -294,6 +295,25 @@
     }
 
 // -----------------------------------------------------------------------------
+// CDeleteObject::DoHandleCompletingPhaseL
+// Completeing phase Handler
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDeleteObject::DoHandleCompletingPhaseL()
+    {
+    CRequestProcessor::DoHandleCompletingPhaseL();
+
+    // If the response code is EMTPRespCodeDeviceBusy, don't release this object
+    TBool result = !iDeviceBusy;
+
+    PRINT2( _L( "MM MTP <> CDeleteObject::DoHandleCompletingPhaseL iDeleteError= %d, result = %d" ),
+            iDeleteError,
+            result );
+
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
 // CDeleteObject::ProcessFinalPhaseL
 // Delete all of the associations if file deletion was successful
 // Then signals that the deletion has been completed
@@ -305,6 +325,7 @@
 
     TInt num = iObjectsToDelete.Count();
     TBool isOk = iDeleteError == KErrNone || iDeleteError == KErrNotFound;
+    iDeviceBusy = EFalse;
 
     if ( num == 0 && isOk )
         {
@@ -315,12 +336,15 @@
         SendResponseL( EMTPRespCodePartialDeletion );
         }
     else if ( !iIsMultiDelete && iDeleteError == KErrAccessDenied )
-        {
+        { 
         SendResponseL( EMTPRespCodeObjectWriteProtected );
         }
-    else if ( iDeleteError == KErrInUse )
+    else if ( iDeleteError == KErrInUse 
+            && iCountDeviceBusyError < KMaxDeviceBusyTimes )
         {
+        iCountDeviceBusyError++;
         SendResponseL( EMTPRespCodeDeviceBusy );
+        iDeviceBusy = ETrue;
         }
     else
         {