mtpfws/mtpfw/src/cmtpobjectstore.cpp
branchRCL_3
changeset 23 f5809cfbf6d5
parent 16 3673b591050c
child 24 523717cdb0ad
equal deleted inserted replaced
19:ef55b168cedb 23:f5809cfbf6d5
    23 #include <mtp/mtpobjectmgrquerytypes.h>
    23 #include <mtp/mtpobjectmgrquerytypes.h>
    24 #include <mtp/mtpprotocolconstants.h>
    24 #include <mtp/mtpprotocolconstants.h>
    25 #include <mtp/tmtptypeuint32.h>
    25 #include <mtp/tmtptypeuint32.h>
    26 #include "cmtphandleallocator.h"
    26 #include "cmtphandleallocator.h"
    27 #include "cmtpobjectstore.h"
    27 #include "cmtpobjectstore.h"
    28 #include "cmtpreferencemgr.h"
       
    29 #include "dbutility.h"
    28 #include "dbutility.h"
    30 #include "cmtpdataprovidercontroller.h"
    29 #include "cmtpdataprovidercontroller.h"
    31 #include "cmtpdataprovider.h"
    30 #include "cmtpdataprovider.h"
    32 #include "cmtpdpidstore.h"
    31 #include "cmtpdpidstore.h"
    33 #include "cmtppkgidstore.h"
    32 #include "cmtppkgidstore.h"
    52 const TInt KMaxLimitCommitInEnumeration = 1024;
    51 const TInt KMaxLimitCommitInEnumeration = 1024;
    53 const TInt KMaxLimitCommitAfterEnumeration = 256;
    52 const TInt KMaxLimitCommitAfterEnumeration = 256;
    54 const TInt KMaxLimitCompactInEnumeration = 2048;
    53 const TInt KMaxLimitCompactInEnumeration = 2048;
    55 const TInt KMaxLimitCompactAfterEnumeration = 1024;
    54 const TInt KMaxLimitCompactAfterEnumeration = 1024;
    56 const TInt KSnapshotGranularity = 128; 
    55 const TInt KSnapshotGranularity = 128; 
       
    56 const TInt KMaxLimitSnapshotSize = 50000;
       
    57 
    57 
    58 
    58 
    59 
    59 
    60 
    60 
    61 
    61 
    62 
   766             
   767             
   767             iMtpDeltaDataMgr->UpdateDeltaDataTableL(iBatched.ColInt64(EObjectStorePOUID), CMtpDeltaDataMgr::EDeleted);
   768             iMtpDeltaDataMgr->UpdateDeltaDataTableL(iBatched.ColInt64(EObjectStorePOUID), CMtpDeltaDataMgr::EDeleted);
   768             }
   769             }
   769         iCachedSuidHash = 0;
   770         iCachedSuidHash = 0;
   770         iCachedHandle = 0;
   771         iCachedHandle = 0;
   771         
   772         iReferenceMgr->RemoveReferencesL(aHandle.Value());
   772         iBatched.DeleteL();
   773         iBatched.DeleteL();
   773         __FLOG(_L8("RemoveObjectL From iBacthed"));
   774         __FLOG(_L8("RemoveObjectL From iBacthed"));
   774         IncTranOpsNumL();
   775         IncTranOpsNumL();
   775         }
   776         }
   776     __FLOG(_L8("RemoveObjectL Exit"));
   777     __FLOG(_L8("RemoveObjectL Exit"));
   785 			{
   786 			{
   786 			iMtpDeltaDataMgr->UpdateDeltaDataTableL(iBatched_SuidHashID.ColInt64(EObjectStorePOUID), CMtpDeltaDataMgr::EDeleted);
   787 			iMtpDeltaDataMgr->UpdateDeltaDataTableL(iBatched_SuidHashID.ColInt64(EObjectStorePOUID), CMtpDeltaDataMgr::EDeleted);
   787 			}
   788 			}
   788 		iCachedSuidHash = 0;
   789 		iCachedSuidHash = 0;
   789 		iCachedHandle = 0;
   790 		iCachedHandle = 0;
       
   791 		//no need to call GetL already all it in LocateBySuidL
       
   792 		iReferenceMgr->RemoveReferencesL(iBatched_SuidHashID.ColUint32(EObjectStoreHandleId));
   790 		iBatched_SuidHashID.DeleteL();
   793 		iBatched_SuidHashID.DeleteL();
   791 		IncTranOpsNumL();
   794 		IncTranOpsNumL();
   792 		}
   795 		}
   793 	}
   796 	}
   794 
   797 
   835  Clean unloaded data provider contents from object store
   838  Clean unloaded data provider contents from object store
   836  */
   839  */
   837 void CMTPObjectStore::CleanL()
   840 void CMTPObjectStore::CleanL()
   838 	{
   841 	{
   839 	__FLOG(_L8("CleanL - Entry"));
   842 	__FLOG(_L8("CleanL - Entry"));
       
   843 	
       
   844 	RemoveUndefinedObjectsL();
   840 	Swi::RSisRegistrySession sisSession;
   845 	Swi::RSisRegistrySession sisSession;
   841 	User::LeaveIfError(sisSession.Connect());
   846 	User::LeaveIfError(sisSession.Connect());
   842 	CleanupClosePushL(sisSession);
   847 	CleanupClosePushL(sisSession);
   843 
   848 
   844 	const RArray<TUint>& loadedDPIDs = iPkgIDStore->DPIDL();
   849 	const RArray<TUint>& loadedDPIDs = iPkgIDStore->DPIDL();
  1373         }
  1378         }
  1374     
  1379     
  1375     __FLOG(_L8("CleanDBSnapshotL Exit"));
  1380     __FLOG(_L8("CleanDBSnapshotL Exit"));
  1376     }
  1381     }
  1377 
  1382 
       
  1383 void CMTPObjectStore::RemoveUndefinedObjectsL()
       
  1384     {
       
  1385     __FLOG(_L8("CompactDBSnapshotL Entry"));
       
  1386     
       
  1387     if (iCleanUndefined)
       
  1388         {
       
  1389         return;
       
  1390         }
       
  1391     
       
  1392     TInt32 count = 0;
       
  1393     RDbTable temp;
       
  1394     CleanupClosePushL(temp);
       
  1395     User::LeaveIfError(temp.Open(iDatabase, KSQLHandleTableName, RDbRowSet::EUpdatable));
       
  1396     count = temp.CountL(RDbRowSet::EQuick);
       
  1397 
       
  1398     __FLOG_VA((_L8("Count before deletion %d "), count));
       
  1399     CleanupStack::PopAndDestroy(&temp);
       
  1400     
       
  1401     if (count > KMaxLimitSnapshotSize)
       
  1402         {
       
  1403         // Delete all object with undefined format
       
  1404         _LIT(KSQLDeleteObjectText, "DELETE FROM HandleStore WHERE FormatCode = %u");
       
  1405         iSqlStatement.Format(KSQLDeleteObjectText, EMTPFormatCodeUndefined);
       
  1406         User::LeaveIfError(iDatabase.Execute(iSqlStatement));    
       
  1407         }
       
  1408     
       
  1409     iCleanUndefined = ETrue;
       
  1410 
       
  1411     
       
  1412     __FLOG(_L8("CompactDBSnapshotL Exit"));    
       
  1413     }
       
  1414 
       
  1415 
  1378 CMTPObjectStore::CEnumertingCacheItem::CEnumertingCacheItem(TUint32 aSuidHash, TUint32 aHandle, TUint32 aParent, TUint32 aFormat, TUint64 aId, TUint8 aDpID)
  1416 CMTPObjectStore::CEnumertingCacheItem::CEnumertingCacheItem(TUint32 aSuidHash, TUint32 aHandle, TUint32 aParent, TUint32 aFormat, TUint64 aId, TUint8 aDpID)
  1379 	{
  1417 	{
  1380 	iObjSuiIdHash = aSuidHash;
  1418 	iObjSuiIdHash = aSuidHash;
  1381 	iObjHandleId = aHandle;
  1419 	iObjHandleId = aHandle;
  1382 	iObjParentId = aParent;
  1420 	iObjParentId = aParent;