Revision: 201004 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 16:59:11 +0300
branchRCL_3
changeset 23 f5809cfbf6d5
parent 19 ef55b168cedb
child 24 523717cdb0ad
Revision: 201004 Kit: 201019
backupandrestore/backupengine/group/connectivity_securebackupengine.iby
backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackup2.cpp
mtpdataproviders/mtpimagedp/group/bld.inf
mtpdataproviders/mtpimagedp/inc/mtpimagedputilits.h
mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp
mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp
mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageinfo.h
mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp
mtpfws/mtpfw/inc/cmtpobjectstore.h
mtpfws/mtpfw/src/cmtpconnectionmgr.cpp
mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp
mtpfws/mtpfw/src/cmtpobjectstore.cpp
--- a/backupandrestore/backupengine/group/connectivity_securebackupengine.iby	Tue Apr 27 17:30:23 2010 +0300
+++ b/backupandrestore/backupengine/group/connectivity_securebackupengine.iby	Tue May 11 16:59:11 2010 +0300
@@ -21,7 +21,7 @@
 file=ABI_DIR\BUILD_DIR\abclient.dll			System\libs\abclient.dll
 
 #ifndef SBEHEAPMAX
-#define SBEHEAPMAX  0x400000
+#define SBEHEAPMAX  0x2000000
 #endif
 
 file=ABI_DIR\BUILD_DIR\sbengine.exe			System\programs\sbengine.exe heapmax=SBEHEAPMAX
--- a/backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackup2.cpp	Tue Apr 27 17:30:23 2010 +0300
+++ b/backupandrestore/backuptest/burtestserver/TestSteps/src/t_teststepbackup2.cpp	Tue May 11 16:59:11 2010 +0300
@@ -21,6 +21,7 @@
 #include <connect/sbtypes.h>
 #include "t_teststepbackup2.h"
 #include <apgcli.h>
+#include <connect/javamanagerinterface.h>
 
 namespace bur_ts
 	{	
@@ -738,7 +739,7 @@
 		{
 		//Coverage test get large public file list
 		RPointerArray<CSBGenericDataType> transferTypes;
-		CleanupClosePushL(transferTypes);
+		CleanupResetAndDestroyPushL(transferTypes);
 		TRAP_IGNORE(GeneratePublicTransferTypesL(transferTypes));
 		RFileArray array;
 		CleanupClosePushL(array);
--- a/mtpdataproviders/mtpimagedp/group/bld.inf	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/group/bld.inf	Tue May 11 16:59:11 2010 +0300
@@ -30,9 +30,9 @@
 
 PRJ_EXPORTS
 // Note: these files are exported for testing and techview only. Not used in a device
-2001FCA2.txt /epoc32/data/z/private/10202be9/2001FCA2.txt
-2001FCA2.txt /epoc32/release/winscw/udeb/z/private/10202be9/2001FCA2.txt
-2001FCA2.txt /epoc32/release/winscw/urel/z/private/10202be9/2001FCA2.txt
+2001fca2.txt /epoc32/data/z/private/10202be9/2001fca2.txt
+2001fca2.txt /epoc32/release/winscw/udeb/z/private/10202be9/2001fca2.txt
+2001fca2.txt /epoc32/release/winscw/urel/z/private/10202be9/2001fca2.txt
 
 ../group/mtp_imagedp.iby  /epoc32/rom/include/mtp_imagedp.iby
 
--- a/mtpdataproviders/mtpimagedp/inc/mtpimagedputilits.h	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/inc/mtpimagedputilits.h	Tue May 11 16:59:11 2010 +0300
@@ -53,16 +53,6 @@
      * update object status to old
      */
     static void UpdateObjectStatusToOldL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata);
-    
-    /**
-     * query thumbnail size from metadata of object
-     */
-    static TInt GetThumbnailSize(const CMTPObjectMetaData& aMetadata);
-    
-    /**
-     * update object thumbnail size
-     */
-    static void UpdateObjectThumbnailSizeL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata, TInt aThumbnailSize);
     };
     
 #endif MTPIMAGEDPUTILITS_H
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp	Tue May 11 16:59:11 2010 +0300
@@ -238,7 +238,10 @@
                 //add Suid to deleteobjectlist
                 iDataProvider.AppendDeleteObjectsArrayL(iObjectMeta->DesC(CMTPObjectMetaData::ESuid));
                 //coverity[unterminated_case]
-            case KErrNone:
+            case KErrPathNotFound:
+                //if the file does not exist on device, remove it from objectstore
+                //coverity[fallthrough]
+            case KErrNone:            
                 //add for test
                 __FLOG(_L8("KErrNone"));                
                 //if the image object is new, we should update new picture count
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp	Tue May 11 16:59:11 2010 +0300
@@ -403,16 +403,18 @@
         aValue = KThumbFormatCode;
        break;        
     case EMTPObjectPropCodeProtectionStatus:
-        iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry);
-        if (entry.IsReadOnly())
+        {
+        TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry);        
+        if ( err == KErrNone && entry.IsReadOnly())
             {
             aValue = EMTPProtectionReadOnly;
             }
         else
             {
             aValue = EMTPProtectionNoProtection;
-            }
-        break;        
+            }        
+        }    
+        break;    
     default:
         aValue = 0;//initialization
         //ingore the failure if we can't get properties form MdS
@@ -437,55 +439,46 @@
         aValue = iObjectInfo->Uint(CMTPObjectMetaData::EParentHandle);
         break;        
        
-    case EMTPObjectPropCodeRepresentativeSampleSize: 
-        aValue = MTPImageDpUtilits::GetThumbnailSize(*iObjectInfo);
-        if (aValue == 0)
+    case EMTPObjectPropCodeRepresentativeSampleSize:
+        {
+        __FLOG_VA((_L16("Query smaple size from MdS - URI:%S"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid)));
+        ClearThumnailCache();                                
+        /**
+         * try to query thumbnail from TNM, and then store thumbnail to cache
+         */
+        TEntry fileEntry;
+        TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
+        if (err == KErrNone)
             {
-            __FLOG_VA((_L16("Query smaple size from MdS - URI:%S"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid)));
-            ClearThumnailCache();                                
+            if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate)
+                {
+                iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
+                }
+            else
+                {
+                iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
+                }
+            
             /**
-             * try to query thumbnail from TNM, and then store thumbnail to cache
+             * trap the leave to avoid return general error when PC get object property list
              */
-            TEntry fileEntry;
-            TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
+            TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
             if (err == KErrNone)
                 {
-                if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate)
-                    {
-                    iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
-                    }
-                else
-                    {
-                    iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
-                    }
-                
-                /**
-                 * trap the leave to avoid return general error when PC get object property list
-                 */
-                TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
-                if (err == KErrNone)
+                iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
+                if (iThumbnailCache.iThumbnailData != NULL)
                     {
-                    iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
-                    if (iThumbnailCache.iThumbnailData != NULL)
-                        {
-                        aValue = static_cast<TUint32>(iThumbnailCache.iThumbnailData->Size());
-                        }
-                                                
-                    if (aValue > 0)
-                        {
-                        //update metadata column
-                        MTPImageDpUtilits::UpdateObjectThumbnailSizeL(iFramework, *iObjectInfo, aValue);
-                        }
-                    else
-                        {
-                        //trigger initiator to re-query thumbnail again if the thumbnail size of response is zero
-                        aValue = KThumbCompressedSize;
-                        }
-
-                    __FLOG_VA((_L16("Cache miss:GetThumbnailSize - URI:%S, Size:%u"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid), aValue));
+                    aValue = static_cast<TUint32>(iThumbnailCache.iThumbnailData->Size());
+                    }
+                                            
+                if (aValue <= 0)
+                    {
+                    //trigger initiator to re-query thumbnail again if the thumbnail size of response is zero
+                    aValue = KThumbCompressedSize;
                     }
                 }
-            }	    
+            }
+        }
         break;       
        
     case EMTPObjectPropCodeRepresentativeSampleHeight:
@@ -618,17 +611,10 @@
                 TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
                 if (err == KErrNone)
                     {
-                    TInt size = MTPImageDpUtilits::GetThumbnailSize(*iObjectInfo);
                     iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
                     if (iThumbnailCache.iThumbnailData != NULL)
                         {
                         aValue.SetByDesL(*iThumbnailCache.iThumbnailData);
-                        if (size == 0)
-                            {
-                            //update metadata column
-                            MTPImageDpUtilits::UpdateObjectThumbnailSizeL(iFramework, *iObjectInfo, iThumbnailCache.iThumbnailData->Size());
-                            __FLOG_VA((_L16("Cache miss:GetThumbnailSize - URI:%S, Size:%u"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid), size));
-                            }
                         }                                
                     }
                 }
--- a/mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp	Tue May 11 16:59:11 2010 +0300
@@ -93,30 +93,3 @@
     aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, status);
     aFramework.ObjectMgr().ModifyObjectL(aMetadata);
     }
-
-TInt MTPImageDpUtilits::GetThumbnailSize(const CMTPObjectMetaData& aMetadata)
-    {    
-    /**
-     * query thumbnail size from EFormatSubCode column
-     */
-    return (aMetadata.Uint(CMTPObjectMetaData::EFormatSubCode) & IMAGE_OBJECT_THUMBNAIL_SIZE_BITMASK);
-    }
-
-void MTPImageDpUtilits::UpdateObjectThumbnailSizeL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata, TInt aThumbnailSize)
-    {
-    //check thumbnail size whether it is overflow
-    if (aThumbnailSize <= IMAGE_OBJECT_THUMBNAIL_SIZE_BITMASK)
-        {
-        TBool newPic = MTPImageDpUtilits::IsNewPicture(aMetadata);
-        if (newPic)
-            {
-            aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, aThumbnailSize);
-            }
-        else
-            {
-            aThumbnailSize |= IMAGE_OBJECT_STATUS_BITMASK;
-            aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, aThumbnailSize);
-            }
-        aFramework.ObjectMgr().ModifyObjectL(aMetadata);
-        }
-    }
--- a/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageinfo.h	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageinfo.h	Tue May 11 16:59:11 2010 +0300
@@ -30,6 +30,15 @@
 //forward declaration
 class CMTPTypeStorageInfo;
 
+//Default drive name used when failed to read drive name from
+//System
+_LIT(KPhoneMemory,"Phone memory");
+_LIT(KMassMemory,"Mass memory");
+_LIT(KMemoryCard,"Memory card");
+_LIT(KNoName,"No name");
+//The last resort for drive name:DriveChar + drive, eg 'A drive'
+_LIT(KDefaultName," drive");
+
 /** 
 Defines device data provider GetStorageInfo request processor
 
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp	Tue May 11 16:59:11 2010 +0300
@@ -197,10 +197,22 @@
 		case EMediaFloppy:
 		    if (iDriveInfo.iDriveAtt & KDriveAttRemovable)
 		        {
-		        storageType = EMTPStorageRemovableRAM;
+		        //E: is set as logically removable after eMMC image updated
+		        //So here we need to deal with this case to set it as FixedRam
+		        if(iDriveInfo.iDriveAtt & KDriveAttInternal)
+		            {
+		            __FLOG(_L8("removable but internal drive, set as Fixed RAM"));
+		            storageType = EMTPStorageFixedRAM;
+		            }
+		        else
+		            {
+		            __FLOG(_L8("non internal,set as removable RAM"));
+		            storageType = EMTPStorageRemovableRAM;
+		            }
 		        }
 		    else
 		        {
+		        __FLOG(_L8("Non removable, set as Fixed RAM"));
 		        storageType = EMTPStorageFixedRAM;
 		        }
 			break;
@@ -309,30 +321,68 @@
 	__FLOG(_L8("SetStorageDescriptionL - Entry"));
     TUint32 storage(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
     TInt driveNumber = iFramework.StorageMgr().DriveNumber(storage);
-	RBuf volumeName;
-	volumeName.CreateL(KMaxFileName);
-	volumeName.CleanupClosePushL();
-	RMTPDeviceDpSingletons devSingletons;
-	devSingletons.OpenL(iFramework);
-	CleanupClosePushL(devSingletons);
-	TRAPD(resError, devSingletons.ConfigMgr().GetFriendlyVolumeNameL(driveNumber, volumeName));
-	if ((KErrNone == resError) && (0 < volumeName.Length()))
-		{
-		__FLOG(_L8("Using volume name from resource file"));
-		CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(volumeName);
-		iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription, *mtpDescription);
-		CleanupStack::PopAndDestroy(mtpDescription);
-		}
-	else if (0 < iVolumeInfo.iName.Length())
-		{
-		__FLOG(_L8("Using standard volume name"));
-		CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(iVolumeInfo.iName);
-		iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription, *mtpDescription);
-	    CleanupStack::PopAndDestroy(mtpDescription);
-		}
-		
-	CleanupStack::PopAndDestroy(&devSingletons);
-	CleanupStack::PopAndDestroy(&volumeName);
+	__FLOG_1(_L8("driveNumber:%d"),driveNumber);
+	
+	CMTPTypeString* mtpDescription = CMTPTypeString::NewLC();
+	            
+	//Firstly, read name from VolumeInfo
+	if (0 < iVolumeInfo.iName.Length())
+	    {
+	        __FLOG_1(_L8("Using standard volume name:%S"),&iVolumeInfo.iName);
+	        mtpDescription->SetL(iVolumeInfo.iName);	        
+	    }
+	else //If name not set, set name according to type
+	    {
+	    TMTPTypeUint16 storageType(EMTPStorageUndefined);
+	    iStorageInfo->GetL(CMTPTypeStorageInfo::EStorageType,storageType);
+	    __FLOG_1(_L8("Set name according to storage type: %d"),storageType.Value());
+	    
+	    switch (storageType.Value())
+	        {
+	        case EMTPStorageFixedROM:
+	            if (driveNumber == EDriveC)//Phone Memory
+	                {
+	                __FLOG(_L8("drive c"));
+	                mtpDescription->SetL(KPhoneMemory);
+	                }
+	            break;
+	        case EMTPStorageRemovableROM:
+	            break;
+	        case EMTPStorageFixedRAM: // Mass Memory
+	            mtpDescription->SetL(KMassMemory);
+	            break;
+	        case EMTPStorageRemovableRAM: // Memory Card
+	            mtpDescription->SetL(KMemoryCard);
+	            break;
+	        case EMTPStorageUndefined:
+	        default:
+	            break;
+	        }
+	    
+	    //Finally, it the name still not set, use default value:
+	    //eg, 'A drive'
+	    if(mtpDescription->NumChars() == 0)
+	        {
+	        TChar driveChar;
+	        TInt err = iFramework.Fs().DriveToChar(driveNumber,driveChar);
+	        __FLOG_2(_L8("Use default name,driveNumber:%d err:%d"),driveNumber,err);
+	        if (err == KErrNone)
+	            {
+	            TBuf<sizeof(KDefaultName) + 1> driveName;
+	            driveName.Append(driveChar);
+	            driveName.Append(KDefaultName);
+	            mtpDescription->SetL(driveName);
+	            }
+	        else
+	            {
+	            mtpDescription->SetL(KNoName);
+	            }
+	        }
+	    }
+	
+	iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription,*mtpDescription);
+	CleanupStack::PopAndDestroy(mtpDescription);	
+	
 	__FLOG(_L8("SetStorageDescriptionL - Exit"));
 	}
 	
--- a/mtpfws/mtpfw/inc/cmtpobjectstore.h	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpfws/mtpfw/inc/cmtpobjectstore.h	Tue May 11 16:59:11 2010 +0300
@@ -27,7 +27,7 @@
 #include "mtpframeworkconst.h"
 #include "rmtpframework.h"
 #include "mtpdebug.h"
-
+#include "cmtpreferencemgr.h"
 class CFileStore;
 class CMTPHandleAllocator;
 class CMTPObjectMetaData;
@@ -155,6 +155,8 @@
 			}
 		void DoL(RDbTable& aTable)
 			{
+			//no need to call GetL already all it in TraverseL
+			iStore.ReferenceMgr().RemoveReferencesL(aTable.ColUint32(EObjectStoreHandleId));
 			aTable.DeleteL();
 			iStore.IncTranOpsNumL();
 			}
@@ -200,6 +202,7 @@
 	void MarkNonPersistentObjectsL(TUint aDataProviderId, TUint32 aStorageId);
 	void EstablishDBSnapshotL(TUint32 aStorageId);
 	void CleanDBSnapshotL(TBool aOnlyRoot = EFalse);
+    void RemoveUndefinedObjectsL();
 	void ObjectsEnumComplete();
 	void MarkDPLoadedL(TUint aDataProviderId, TBool aFlag);
 
@@ -364,6 +367,7 @@
 	TInt                                    iSnapshotCleanPos;
 	CSnapshotWorker*                        iSnapshotWorker;
 	mutable TFileName                       iSuidBuf;
+	TBool                                   iCleanUndefined;
 	/**
 	 FLOGGER debug trace member variable.
 	 */
--- a/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp	Tue May 11 16:59:11 2010 +0300
@@ -40,8 +40,7 @@
 CMTPConnectionMgr::~CMTPConnectionMgr()
     {
     StopTransport( iTransportUid, ETrue );
-    iConnections.ResetAndDestroy();
-    iSuspendedTransports.Reset();
+    iConnections.ResetAndDestroy();    
     iSuspendedTransports.Close();
     delete iTransportTrigger;
     __FLOG_CLOSE;
--- a/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp	Tue May 11 16:59:11 2010 +0300
@@ -372,7 +372,17 @@
 */  
 EXPORT_C TInt CMTPDataProviderController::DpId(TUint aUid)
     {
-    return iDataProviders.FindInOrder(TUid::Uid(aUid), CMTPDataProvider::LinearOrderUid);
+    TInt dpId = KErrNotFound;
+    for (TUint index=0; index < iDataProviders.Count(); index++)
+      {
+      if (iDataProviders[index]->ImplementationUid().iUid == aUid)
+        {
+        dpId = iDataProviders[index]->DataProviderId();
+        break;
+        }
+      }
+    
+    return dpId;
     }
 
 /**
--- a/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Tue Apr 27 17:30:23 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Tue May 11 16:59:11 2010 +0300
@@ -25,7 +25,6 @@
 #include <mtp/tmtptypeuint32.h>
 #include "cmtphandleallocator.h"
 #include "cmtpobjectstore.h"
-#include "cmtpreferencemgr.h"
 #include "dbutility.h"
 #include "cmtpdataprovidercontroller.h"
 #include "cmtpdataprovider.h"
@@ -54,6 +53,8 @@
 const TInt KMaxLimitCompactInEnumeration = 2048;
 const TInt KMaxLimitCompactAfterEnumeration = 1024;
 const TInt KSnapshotGranularity = 128; 
+const TInt KMaxLimitSnapshotSize = 50000;
+
 
 
 
@@ -768,7 +769,7 @@
             }
         iCachedSuidHash = 0;
         iCachedHandle = 0;
-        
+        iReferenceMgr->RemoveReferencesL(aHandle.Value());
         iBatched.DeleteL();
         __FLOG(_L8("RemoveObjectL From iBacthed"));
         IncTranOpsNumL();
@@ -787,6 +788,8 @@
 			}
 		iCachedSuidHash = 0;
 		iCachedHandle = 0;
+		//no need to call GetL already all it in LocateBySuidL
+		iReferenceMgr->RemoveReferencesL(iBatched_SuidHashID.ColUint32(EObjectStoreHandleId));
 		iBatched_SuidHashID.DeleteL();
 		IncTranOpsNumL();
 		}
@@ -837,6 +840,8 @@
 void CMTPObjectStore::CleanL()
 	{
 	__FLOG(_L8("CleanL - Entry"));
+	
+	RemoveUndefinedObjectsL();
 	Swi::RSisRegistrySession sisSession;
 	User::LeaveIfError(sisSession.Connect());
 	CleanupClosePushL(sisSession);
@@ -1375,6 +1380,39 @@
     __FLOG(_L8("CleanDBSnapshotL Exit"));
     }
 
+void CMTPObjectStore::RemoveUndefinedObjectsL()
+    {
+    __FLOG(_L8("CompactDBSnapshotL Entry"));
+    
+    if (iCleanUndefined)
+        {
+        return;
+        }
+    
+    TInt32 count = 0;
+    RDbTable temp;
+    CleanupClosePushL(temp);
+    User::LeaveIfError(temp.Open(iDatabase, KSQLHandleTableName, RDbRowSet::EUpdatable));
+    count = temp.CountL(RDbRowSet::EQuick);
+
+    __FLOG_VA((_L8("Count before deletion %d "), count));
+    CleanupStack::PopAndDestroy(&temp);
+    
+    if (count > KMaxLimitSnapshotSize)
+        {
+        // Delete all object with undefined format
+        _LIT(KSQLDeleteObjectText, "DELETE FROM HandleStore WHERE FormatCode = %u");
+        iSqlStatement.Format(KSQLDeleteObjectText, EMTPFormatCodeUndefined);
+        User::LeaveIfError(iDatabase.Execute(iSqlStatement));    
+        }
+    
+    iCleanUndefined = ETrue;
+
+    
+    __FLOG(_L8("CompactDBSnapshotL Exit"));    
+    }
+
+
 CMTPObjectStore::CEnumertingCacheItem::CEnumertingCacheItem(TUint32 aSuidHash, TUint32 aHandle, TUint32 aParent, TUint32 aFormat, TUint64 aId, TUint8 aDpID)
 	{
 	iObjSuiIdHash = aSuidHash;