syncmlfw/dm/settings/src/DMProfileContentHandler.cpp
branchRCL_3
changeset 62 19bba8228ff0
parent 61 b183ec05bd8c
child 76 3cdbd92ee07b
--- a/syncmlfw/dm/settings/src/DMProfileContentHandler.cpp	Tue Aug 31 16:04:06 2010 +0300
+++ b/syncmlfw/dm/settings/src/DMProfileContentHandler.cpp	Wed Sep 01 12:27:42 2010 +0100
@@ -22,8 +22,10 @@
 #include <commdb.h>
 #include <nsmldebug.h>
 #include <featmgr.h>
+#include <centralrepository.h>
 #include "DMprofileContentHandler.h"
 #include "nsmldmsettings.h"
+#include "DevManInternalCRKeys.h"
 
 
 #define DES_AS_8_BIT(str) (TPtrC8((TText8*)((str).Ptr()), (str).Size()))
@@ -178,7 +180,8 @@
 	RemoveRSCEntryL();
 	TInt iapId = 0;
 	
-	for ( TInt i = 0; i < iProfileArray->Count(); i++ )
+	TInt count = iProfileArray->Count();
+	for ( TInt i = 0; i < count; i++ )
 	{
 		if(iProfileArray->At(i)->iAccessPoint)
 		{
@@ -210,6 +213,19 @@
 		CleanupStack::PopAndDestroy(); // profile
 							
 	}
+  CRepository* centrep = NULL;
+  TRAPD( err, centrep = CRepository::NewL(KCRUidDeviceManagementInternalKeys));  
+  if (err==KErrNone ) 
+  {
+  	TInt num(-1);
+  	TInt err = centrep->Get( KMaxFactoryDMProfileId , num );
+  	if( num >= 0 )
+  		err = centrep->Set( KMaxFactoryDMProfileId , (count + num ) );
+  	else
+  		err = centrep->Set( KMaxFactoryDMProfileId , count - 1);	
+    delete centrep;
+    centrep = NULL;
+	}
 	_DBG_FILE("CDMProfileContentHandler::SaveProfilesL(): end");
 }
 // -----------------------------------------------------------------------------