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 |
494 needToInsert = ETrue; |
495 needToInsert = ETrue; |
495 } |
496 } |
496 else |
497 else |
497 { |
498 { |
498 aObject.SetUint(CMTPObjectMetaData::EHandle, handle); |
499 aObject.SetUint(CMTPObjectMetaData::EHandle, handle); |
499 needUpdateOwner = ETrue; |
500 CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC()); |
500 //while enumerating, we ignore the repeatedly INSERT operations. |
501 if(ObjectL(aObject.DesC(CMTPObjectMetaData::ESuid), *object)) |
501 //User::Leave(KErrAlreadyExists); |
502 { |
|
503 if(object->Uint(CMTPObjectMetaData::EDataProviderId) != aObject.Uint(CMTPObjectMetaData::EDataProviderId)) |
|
504 { |
|
505 needUpdateOwner = ETrue; |
|
506 } |
|
507 } |
|
508 CleanupStack::PopAndDestroy(object); |
502 } |
509 } |
503 __FLOG_VA(_L8("Not Found in Snapshot")); |
510 __FLOG_VA(_L8("Not Found in Snapshot")); |
504 } |
511 } |
505 __FLOG_VA((_L8("InsertObjectL Under enmueration, needUpdateOwner %d needToInsert %d"), needUpdateOwner, needToInsert)); |
512 __FLOG_VA((_L8("InsertObjectL Under enmueration, needUpdateOwner %d needToInsert %d"), needUpdateOwner, needToInsert)); |
506 } |
513 } |
835 Clean unloaded data provider contents from object store |
844 Clean unloaded data provider contents from object store |
836 */ |
845 */ |
837 void CMTPObjectStore::CleanL() |
846 void CMTPObjectStore::CleanL() |
838 { |
847 { |
839 __FLOG(_L8("CleanL - Entry")); |
848 __FLOG(_L8("CleanL - Entry")); |
|
849 |
|
850 RemoveUndefinedObjectsL(); |
840 Swi::RSisRegistrySession sisSession; |
851 Swi::RSisRegistrySession sisSession; |
841 User::LeaveIfError(sisSession.Connect()); |
852 User::LeaveIfError(sisSession.Connect()); |
842 CleanupClosePushL(sisSession); |
853 CleanupClosePushL(sisSession); |
843 |
854 |
844 const RArray<TUint>& loadedDPIDs = iPkgIDStore->DPIDL(); |
855 const RArray<TUint>& loadedDPIDs = iPkgIDStore->DPIDL(); |
1373 } |
1384 } |
1374 |
1385 |
1375 __FLOG(_L8("CleanDBSnapshotL Exit")); |
1386 __FLOG(_L8("CleanDBSnapshotL Exit")); |
1376 } |
1387 } |
1377 |
1388 |
|
1389 void CMTPObjectStore::RemoveUndefinedObjectsL() |
|
1390 { |
|
1391 __FLOG(_L8("CompactDBSnapshotL Entry")); |
|
1392 |
|
1393 if (iCleanUndefined) |
|
1394 { |
|
1395 return; |
|
1396 } |
|
1397 |
|
1398 TInt32 count = 0; |
|
1399 RDbTable temp; |
|
1400 CleanupClosePushL(temp); |
|
1401 User::LeaveIfError(temp.Open(iDatabase, KSQLHandleTableName, RDbRowSet::EUpdatable)); |
|
1402 count = temp.CountL(RDbRowSet::EQuick); |
|
1403 |
|
1404 __FLOG_VA((_L8("Count before deletion %d "), count)); |
|
1405 CleanupStack::PopAndDestroy(&temp); |
|
1406 |
|
1407 if (count > KMaxLimitSnapshotSize) |
|
1408 { |
|
1409 // Delete all object with undefined format |
|
1410 _LIT(KSQLDeleteObjectText, "DELETE FROM HandleStore WHERE FormatCode = %u"); |
|
1411 iSqlStatement.Format(KSQLDeleteObjectText, EMTPFormatCodeUndefined); |
|
1412 User::LeaveIfError(iDatabase.Execute(iSqlStatement)); |
|
1413 } |
|
1414 |
|
1415 iCleanUndefined = ETrue; |
|
1416 |
|
1417 |
|
1418 __FLOG(_L8("CompactDBSnapshotL Exit")); |
|
1419 } |
|
1420 |
|
1421 |
1378 CMTPObjectStore::CEnumertingCacheItem::CEnumertingCacheItem(TUint32 aSuidHash, TUint32 aHandle, TUint32 aParent, TUint32 aFormat, TUint64 aId, TUint8 aDpID) |
1422 CMTPObjectStore::CEnumertingCacheItem::CEnumertingCacheItem(TUint32 aSuidHash, TUint32 aHandle, TUint32 aParent, TUint32 aFormat, TUint64 aId, TUint8 aDpID) |
1379 { |
1423 { |
1380 iObjSuiIdHash = aSuidHash; |
1424 iObjSuiIdHash = aSuidHash; |
1381 iObjHandleId = aHandle; |
1425 iObjHandleId = aHandle; |
1382 iObjParentId = aParent; |
1426 iObjParentId = aParent; |