metadataengine/server/src/mdsmanipulationengine.cpp
branchRCL_3
changeset 13 4a4892eec172
parent 9 82c0024438c8
child 19 b73252188534
--- a/metadataengine/server/src/mdsmanipulationengine.cpp	Tue May 11 16:36:55 2010 +0300
+++ b/metadataengine/server/src/mdsmanipulationengine.cpp	Tue May 25 13:10:05 2010 +0300
@@ -31,6 +31,7 @@
 #include "mdcserializationbuffer.h"
 #include "mdeinternalerror.h"
 #include "mdeerror.h"
+#include "mdscommoninternal.h"
 
 // for CleanupResetAndDestroyPushL
 #include <mmf/common/mmfcontrollerpluginresolver.h>
@@ -168,6 +169,7 @@
             if (err == KErrNone)
                 {
                 aResultBuffer.InsertL( id );
+                iAddedObjectsCount++;
                 }
             else
                 {
@@ -295,6 +297,28 @@
 
 	iManipulate->SetNamespace( NULL );
 	iNotifier.NotifyAddedL( aBuffer, aResultBuffer );
+	
+    if( iAddedObjectsCount > KTriggerDbMaintenanceTreasholdValue )
+	   {
+	   RMdSTransaction transaction( connection );
+	   CleanupClosePushL(transaction);
+	   const TInt beginError( transaction.Error() );
+	       
+	   if( beginError != KErrNone )
+	       {
+	       CleanupStack::PopAndDestroy( &transaction );
+	       }
+	       
+	   iManipulate->AnalyzeL();
+	    
+	   if( beginError == KErrNone )
+	       {
+	       transaction.CommitL();
+	       CleanupStack::PopAndDestroy( &transaction );
+	       }
+	       
+	   iAddedObjectsCount = 0;
+	   }
 	}
 
 // ---------------------------------------------------------------------------
@@ -605,6 +629,7 @@
 			if (err == KErrNone)
 				{
 				aResultBuffer.InsertL( id );
+				iModifiedObjectsCount++;
 				}
 			else
 				{
@@ -689,6 +714,28 @@
 	resultIds.SerializeL( aResultBuffer );
 
 	iNotifier.NotifyModifiedL( aBuffer, aResultBuffer );
+	
+    if( iModifiedObjectsCount > KTriggerDbMaintenanceTreasholdValue )
+       {
+       RMdSTransaction transaction( connection );
+       CleanupClosePushL(transaction);
+       const TInt beginError( transaction.Error() );
+           
+       if( beginError != KErrNone )
+           {
+           CleanupStack::PopAndDestroy( &transaction );
+           }
+           
+       iManipulate->AnalyzeL();
+        
+       if( beginError == KErrNone )
+           {
+           transaction.CommitL();
+           CleanupStack::PopAndDestroy( &transaction );
+           }
+           
+       iModifiedObjectsCount = 0;
+       }
     }
 
 CMdCSerializationBuffer* CMdSManipulationEngine::CheckObjectL(