192 TChar driveChar = 0; |
192 TChar driveChar = 0; |
193 User::LeaveIfError( RFs::DriveToChar( iDrive, driveChar )); |
193 User::LeaveIfError( RFs::DriveToChar( iDrive, driveChar )); |
194 pathPtr.Append( driveChar ); |
194 pathPtr.Append( driveChar ); |
195 pathPtr.Append( KThumbnailDatabaseName ); |
195 pathPtr.Append( KThumbnailDatabaseName ); |
196 |
196 |
|
197 //start disk space monitor |
197 iDiskFullNotifier = CThumbnailStoreDiskSpaceNotifierAO::NewL( *this, |
198 iDiskFullNotifier = CThumbnailStoreDiskSpaceNotifierAO::NewL( *this, |
198 KDiskFullThreshold, |
199 KDiskFullThreshold, |
199 pathPtr ); |
200 pathPtr ); |
200 |
201 |
201 TVolumeInfo volumeinfo; |
202 TVolumeInfo volumeinfo; |
272 ResetThumbnailIDs(); |
273 ResetThumbnailIDs(); |
273 |
274 |
274 //take ownership |
275 //take ownership |
275 UpdateImeiL(); |
276 UpdateImeiL(); |
276 |
277 |
277 //Remove blacklist markings |
278 //Touch blacklisted items |
278 TRAP_IGNORE( RemoveDbFlagL( KThumbnailDbFlagBlacklisted ) ); |
279 TRAP_IGNORE( PrepareBlacklistedItemsForRetry( ) ); |
279 } |
280 } |
280 |
281 |
281 //check is MMC known |
282 //check is MMC known |
282 if(CheckMediaIDL() != KErrNone ) |
283 if(CheckMediaIDL() != KErrNone ) |
283 { |
284 { |
284 ResetThumbnailIDs(); |
285 ResetThumbnailIDs(); |
285 |
286 |
286 //Remove blacklist markings |
287 //Touch blacklisted items |
287 TRAP_IGNORE( RemoveDbFlagL( KThumbnailDbFlagBlacklisted ) ); |
288 TRAP_IGNORE( PrepareBlacklistedItemsForRetry() ); |
288 } |
289 } |
289 } |
290 } |
290 |
291 |
291 CleanupStack::PopAndDestroy( databasePath ); |
292 CleanupStack::PopAndDestroy( databasePath ); |
292 |
293 |
451 // |
452 // |
452 void CThumbnailStore::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* |
453 void CThumbnailStore::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* |
453 aThumbnail, const TSize& aOriginalSize, TBool /*aCropped*/, const TThumbnailSize aThumbnailSize, |
454 aThumbnail, const TSize& aOriginalSize, TBool /*aCropped*/, const TThumbnailSize aThumbnailSize, |
454 const TThumbnailId aThumbnailId, const TBool aThumbFromPath, TBool aBlackListed ) |
455 const TThumbnailId aThumbnailId, const TBool aThumbFromPath, TBool aBlackListed ) |
455 { |
456 { |
456 TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( CFbsBitmap* ) in" ); |
457 TSize thumbSize = aThumbnail->SizeInPixels(); |
|
458 TN_DEBUG5( "CThumbnailStore::StoreThumbnailL( CFbsBitmap ) aThumbnailId = %d, aThumbnailSize = %d, aThumbnailSize(%d,%d) IN", aThumbnailId, aThumbnailSize, thumbSize.iWidth, thumbSize.iHeight ); |
457 |
459 |
458 __ASSERT_DEBUG(( aThumbnail ), ThumbnailPanic( EThumbnailNullPointer )); |
460 __ASSERT_DEBUG(( aThumbnail ), ThumbnailPanic( EThumbnailNullPointer )); |
|
461 |
|
462 // don't store custom/unknown sizes or zero sizes |
|
463 if(aThumbnailSize == ECustomThumbnailSize || aThumbnailSize == EUnknownThumbnailSize |
|
464 || thumbSize.iWidth <= 0 || thumbSize.iHeight <= 0 ) |
|
465 { |
|
466 TN_DEBUG1( "CThumbnailStore::StoreThumbnailL() not stored"); |
|
467 return; |
|
468 } |
459 |
469 |
460 // check for duplicates |
470 // check for duplicates |
461 TBool exists = FindDuplicateL(aPath, aThumbnailId, aThumbnailSize); |
471 TBool exists = FindDuplicateL(aPath, aThumbnailId, aThumbnailSize); |
462 |
472 |
463 TSize thumbSize = aThumbnail->SizeInPixels(); |
|
464 for ( TInt i = iPersistentSizes.Count(); --i >= 0; ) |
473 for ( TInt i = iPersistentSizes.Count(); --i >= 0; ) |
465 { |
474 { |
466 TThumbnailPersistentSize & persistentSize = iPersistentSizes[i]; |
475 TThumbnailPersistentSize & persistentSize = iPersistentSizes[i]; |
467 |
476 |
468 // don't store duplicates or custom/unknown sizes |
477 // don't store duplicates or zero sizes |
469 if ( !exists && (aThumbnailSize != ECustomThumbnailSize && |
478 if ( !exists ) |
470 aThumbnailSize != EUnknownThumbnailSize && |
|
471 thumbSize.iWidth > 0 && thumbSize.iHeight > 0 )) |
|
472 { |
479 { |
473 TInt flags = 0; |
480 TInt flags = 0; |
474 if ( persistentSize.iCrop ) |
481 if ( persistentSize.iCrop ) |
475 { |
482 { |
476 flags |= KThumbnailDbFlagCropped; |
483 flags |= KThumbnailDbFlagCropped; |
1680 TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); |
1687 TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); |
1681 User::LeaveIfError( paramIndex ); |
1688 User::LeaveIfError( paramIndex ); |
1682 User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); |
1689 User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); |
1683 |
1690 |
1684 TInt rowStatus = stmt.Next(); |
1691 TInt rowStatus = stmt.Next(); |
1685 |
1692 |
1686 //if not found from temp table, look from real table |
1693 TBool modified = EFalse; |
1687 if(rowStatus != KSqlAtRow) |
1694 TBool checkMain = EFalse; |
1688 { |
1695 |
1689 stmt.Close(); |
1696 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- temp" ); |
1690 CleanupStack::PopAndDestroy( &stmt ); |
1697 |
1691 CleanupClosePushL( stmt ); |
1698 while(rowStatus == KSqlAtRow || !checkMain) |
1692 |
1699 { |
1693 User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectModifiedByID )); |
1700 if(rowStatus == KSqlAtRow) |
1694 |
1701 { |
1695 paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); |
1702 TInt64 oldModified = stmt.ColumnInt64( column ); |
1696 User::LeaveIfError( paramIndex ); |
1703 |
1697 User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); |
1704 if (oldModified < aModified) |
1698 |
1705 { |
1699 rowStatus = stmt.Next(); |
1706 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is newer than original" ); |
1700 } |
1707 modified = ETrue; |
1701 |
1708 break; |
1702 TBool modified = EFalse; |
1709 } |
1703 |
1710 else if (oldModified > aModified) |
1704 if(rowStatus == KSqlAtRow) |
1711 { |
1705 { |
1712 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is older than original" ); |
1706 TInt64 oldModified = stmt.ColumnInt64( column ); |
1713 break; |
1707 |
1714 } |
1708 if (oldModified < aModified) |
1715 else if (oldModified == aModified) |
1709 { |
1716 { |
1710 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is newer than original" ); |
1717 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is the same as original" ); |
1711 modified = ETrue; |
1718 } |
1712 } |
1719 } |
1713 else if (oldModified > aModified) |
1720 |
1714 { |
1721 rowStatus = stmt.Next(); |
1715 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is older than original" ); |
1722 |
1716 } |
1723 //switch to main table if modified not found from temp |
1717 else if (oldModified == aModified) |
1724 if(rowStatus != KSqlAtRow && !checkMain && !modified) |
1718 { |
1725 { |
1719 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is the same as original" ); |
1726 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- main" ); |
1720 } |
1727 //come here only once |
1721 } |
1728 checkMain = ETrue; |
|
1729 |
|
1730 stmt.Close(); |
|
1731 CleanupStack::PopAndDestroy( &stmt ); |
|
1732 CleanupClosePushL( stmt ); |
|
1733 |
|
1734 User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectModifiedByID )); |
|
1735 |
|
1736 paramIndex = stmt.ParameterIndex( KThumbnailSqlParamId ); |
|
1737 User::LeaveIfError( paramIndex ); |
|
1738 User::LeaveIfError( stmt.BindInt( paramIndex, aItemId )); |
|
1739 |
|
1740 rowStatus = stmt.Next(); |
|
1741 } |
|
1742 } |
1722 |
1743 |
1723 stmt.Close(); |
1744 stmt.Close(); |
1724 CleanupStack::PopAndDestroy( &stmt ); |
1745 CleanupStack::PopAndDestroy( &stmt ); |
1725 |
1746 |
1726 return modified; |
1747 return modified; |
2351 stmt.Close(); |
2372 stmt.Close(); |
2352 CleanupStack::PopAndDestroy( &stmt ); |
2373 CleanupStack::PopAndDestroy( &stmt ); |
2353 } |
2374 } |
2354 |
2375 |
2355 // ----------------------------------------------------------------------------- |
2376 // ----------------------------------------------------------------------------- |
2356 // RemoveDbFlagL() |
2377 // PrepareBlacklistedItemsForRetry() |
2357 // ----------------------------------------------------------------------------- |
2378 // ----------------------------------------------------------------------------- |
2358 // |
2379 // |
2359 void CThumbnailStore::RemoveDbFlagL(TThumbnailDbFlags aFlag) |
2380 void CThumbnailStore::PrepareBlacklistedItemsForRetry() |
2360 { |
2381 { |
2361 TN_DEBUG1( "CThumbnailStore::RemoveBlacklistedFlag()" ); |
2382 TN_DEBUG1( "CThumbnailStore::PrepareBlacklistedItemsForRetry()" ); |
2362 |
2383 |
2363 RSqlStatement stmt; |
2384 RSqlStatement stmt; |
2364 CleanupClosePushL( stmt ); |
2385 CleanupClosePushL( stmt ); |
2365 |
2386 |
2366 User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailRemoveBlacklistedFlag )); |
2387 User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailTouchBlacklistedRows )); |
2367 |
2388 |
2368 TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFlag ); |
2389 TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFlag ); |
2369 User::LeaveIfError( paramIndex ); |
2390 User::LeaveIfError( paramIndex ); |
2370 User::LeaveIfError( stmt.BindInt( paramIndex, aFlag )); |
2391 User::LeaveIfError( stmt.BindInt( paramIndex, KThumbnailDbFlagBlacklisted )); |
2371 |
|
2372 TInt err = stmt.Exec(); |
2392 TInt err = stmt.Exec(); |
2373 |
2393 |
2374 TN_DEBUG2( "CThumbnailStore::RemoveBlacklistedFlag() - main table, err=%d", err ); |
2394 TN_DEBUG2( "CThumbnailStore::PrepareBlacklistedItemsForRetry() - main table, err=%d", err ); |
2375 |
2395 |
2376 CleanupStack::PopAndDestroy( &stmt ); |
2396 CleanupStack::PopAndDestroy( &stmt ); |
2377 } |
2397 } |
2378 |
2398 |
2379 void CThumbnailStore::HandleDiskSpaceNotificationL( TBool aDiskFull ) |
2399 void CThumbnailStore::HandleDiskSpaceNotificationL( TBool aDiskFull ) |