mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cdeleteobject.cpp
changeset 50 762d760dcfdf
parent 35 2ee890d2f7e7
--- a/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cdeleteobject.cpp	Fri Jul 23 17:48:16 2010 -0500
+++ b/mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/cdeleteobject.cpp	Fri Aug 06 17:13:32 2010 -0500
@@ -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
         {