--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Tue Jul 06 14:37:18 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Wed Aug 18 10:05:55 2010 +0300
@@ -166,9 +166,9 @@
// Two-phased constructor.
// ---------------------------------------------------------------------------
//
-CThumbnailStore* CThumbnailStore::NewL( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer )
+CThumbnailStore* CThumbnailStore::NewL( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer, const TBool aReadOnly )
{
- CThumbnailStore* self = new( ELeave )CThumbnailStore( aFs, aDrive, aImei, aServer );
+ CThumbnailStore* self = new( ELeave )CThumbnailStore( aFs, aDrive, aImei, aServer, aReadOnly );
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop( self );
@@ -222,9 +222,9 @@
// C++ default constructor can NOT contain any code, that might leave.
// ---------------------------------------------------------------------------
//
-CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer ):
- iFs( aFs ), iDrive( aDrive ), iDriveChar( 0 ), iBatchItemCount(0), iImei(aImei),
- iServer(aServer), iDiskFull(EFalse), iUnrecoverable(ETrue), iBatchFlushItemCount(KMInBatchItems)
+CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer, const TBool aReadOnly ):
+ iFs( aFs ), iDrive( aDrive ), iDriveChar( 0 ), iBatchItemCount(0), iImei(aImei), iServer(aServer), iDiskFullNotifier(NULL),
+ iDiskFull(EFalse), iActivityManager(NULL), iUnrecoverable(ETrue), iBatchFlushItemCount(KMInBatchItems), iReadOnly(aReadOnly)
{
// no implementation required
}
@@ -241,31 +241,39 @@
#ifdef _DEBUG
iThumbCounter = 0;
#endif
-
- HBufC* databasePath = HBufC::NewLC( KMaxFileName );
- TPtr pathPtr = databasePath->Des();
- User::LeaveIfError( RFs::DriveToChar( iDrive, iDriveChar ));
- pathPtr.Append( iDriveChar );
- pathPtr.Append( KThumbnailDatabaseName );
-
- //start disk space monitor
- iDiskFullNotifier = CThumbnailStoreDiskSpaceNotifierAO::NewL( *this,
- KDiskFullThreshold,
- pathPtr );
+ if(!iReadOnly)
+ {
+ HBufC* databasePath = HBufC::NewLC( KMaxFileName );
+ TPtr pathPtr = databasePath->Des();
+ User::LeaveIfError( RFs::DriveToChar( iDrive, iDriveChar ));
+ pathPtr.Append( iDriveChar );
+ pathPtr.Append( KThumbnailDatabaseName );
+
+ //start disk space monitor
+ iDiskFullNotifier = CThumbnailStoreDiskSpaceNotifierAO::NewL( *this,
+ KDiskFullThreshold,
+ pathPtr );
- CleanupStack::PopAndDestroy( databasePath );
+ CleanupStack::PopAndDestroy( databasePath );
+
+ TN_DEBUG2( "CThumbnailStore::ConstructL() drive: %d", iDrive );
- TN_DEBUG2( "CThumbnailStore::ConstructL() drive: %d", iDrive );
+ OpenDatabaseL();
- OpenDatabaseL();
+ // to monitor device activity
+ iActivityManager = CTMActivityManager::NewL( this, KStoreMaintenanceIdle);
+ iActivityManager->Start();
- // to monitor device activity
- iActivityManager = CTMActivityManager::NewL( this, KStoreMaintenanceIdle);
- iActivityManager->Start();
-
- iDeleteThumbs = ETrue;
- iCheckFilesExist = ETrue;
- iLastCheckedRowID = -1;
+ iDeleteThumbs = ETrue;
+ iCheckFilesExist = ETrue;
+ }
+ else
+ {
+ TN_DEBUG1( "CThumbnailStore::ConstructL() - read only, dymmy mode..." );
+ iDeleteThumbs = EFalse;
+ iCheckFilesExist = EFalse;
+ iLastCheckedRowID = -1;
+ }
}
// ---------------------------------------------------------------------------
@@ -547,9 +555,7 @@
TInt column = 0;
TInt rowStatus = 0;
TInt64 inforows = -1;
- TInt64 infocount = -1;
TInt64 datarows = -1;
- TInt64 datacount = -1;
TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID );
if(ret < 0)
@@ -575,32 +581,7 @@
#endif
return KErrNotSupported;
}
-
- ret = stmt.Prepare( iDatabase, KGetInfoCount );
- if(ret < 0)
- {
- stmt.Close();
- TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoCount failed %d");
- return KErrNotSupported;
- }
- rowStatus = stmt.Next();
-
- if ( rowStatus == KSqlAtRow)
- {
- infocount = stmt.ColumnInt64( column );
- }
-
- stmt.Close();
-
- if(rowStatus < 0)
- {
-#ifdef _DEBUG
- TPtrC errorMsg2 = iDatabase.LastErrorMessage();
- TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
-#endif
- return KErrNotSupported;
- }
-
+
ret = stmt.Prepare( iDatabase, KGetDataRowID );
if(ret < 0)
{
@@ -626,37 +607,10 @@
return KErrNotSupported;
}
- ret = stmt.Prepare( iDatabase, KGetInfoDataCount );
- if(ret < 0)
- {
- stmt.Close();
- TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoDataCount failed %d");
- return KErrNotSupported;
- }
- rowStatus = stmt.Next();
-
- if ( rowStatus == KSqlAtRow)
- {
- datacount = stmt.ColumnInt64( column );
- }
-
- stmt.Close();
-
- if(rowStatus < 0)
- {
-#ifdef _DEBUG
- TPtrC errorMsg2 = iDatabase.LastErrorMessage();
- TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
-#endif
- return KErrNotSupported;
- }
-
TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - inforows %Ld", inforows );
- TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - infocount %Ld", infocount );
TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datarows %Ld", datarows );
- TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datacount %Ld", datacount );
- if( inforows != datarows || datacount != infocount)
+ if( inforows != datarows )
{
TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" );
return KErrNotSupported;
@@ -1121,6 +1075,12 @@
const TThumbnailSize& aThumbnailSize, const TInt64 aModified, const TBool aThumbFromPath )
{
TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( private ) in" );
+
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::StoreThumbnailL() read only, skip..." );
+ return;
+ }
#ifdef _DEBUG
TTime aStart, aStop;
@@ -1272,6 +1232,12 @@
{
TSize thumbSize = aThumbnail->SizeInPixels();
TN_DEBUG4( "CThumbnailStore::StoreThumbnailL( public ) aThumbnailSize = %d, aThumbnailSize(%d,%d) IN", aThumbnailSize, thumbSize.iWidth, thumbSize.iHeight );
+
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::StoreThumbnailL() read only, skip..." );
+ return;
+ }
__ASSERT_DEBUG(( aThumbnail ), ThumbnailPanic( EThumbnailNullPointer ));
@@ -1319,17 +1285,20 @@
CleanupStack::PushL( data );
CImageEncoder* encoder = NULL;
- TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::EHwImplementation, data, CImageEncoder::EOptionAlwaysThread ) );
+
+ CImageEncoder::TOptions options = ( CImageEncoder::TOptions )( CImageEncoder::EOptionAlwaysThread );
+
+ TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::EHwImplementation, data, options ) );
if ( decErr != KErrNone )
{
TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - HW CExtJpegEncoder failed %d", decErr);
- TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::ESwImplementation, data, CImageEncoder::EOptionAlwaysThread ) );
+ TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::ESwImplementation, data, options ) );
if ( decErr != KErrNone )
{
TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - SW CExtJpegEncoder failed %d", decErr);
- TRAPD( decErr, encoder = CImageEncoder::DataNewL( data, KJpegMime(), CImageEncoder::EOptionAlwaysThread ) );
+ TRAPD( decErr, encoder = CImageEncoder::DataNewL( data, KJpegMime(), options ) );
if ( decErr != KErrNone )
{
TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - CImageEncoder failed %d", decErr);
@@ -1362,7 +1331,7 @@
// Set some format specific data
imageData->iSampleScheme = TJpegImageData::EColor444;
- imageData->iQualityFactor = 75;
+ imageData->iQualityFactor = 80;
// imageData - ownership passed to frameImageData after AppendImageData
User::LeaveIfError(frameImageData->AppendImageData(imageData));
@@ -1432,6 +1401,12 @@
TBool CThumbnailStore::FindDuplicateL( const TDesC& aPath, const TThumbnailSize& aThumbnailSize )
{
TN_DEBUG1( "CThumbnailStore::FindDuplicateL()" );
+
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::FindDuplicateL() read only, skip..." );
+ return EFalse;
+ }
User::LeaveIfError( CheckDbState() );
@@ -1528,6 +1503,12 @@
{
TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() aSourceType == %d", aSourceType );
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::GetMissingSizesL() read only, skip..." );
+ return;
+ }
+
User::LeaveIfError( CheckDbState() );
HBufC* path = aPath.AllocLC();
@@ -1637,6 +1618,12 @@
{
TN_DEBUG3( "CThumbnailStore::FetchThumbnailL(%S) aThumbnailSize==%d", &aPath, aThumbnailSize );
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() read only, skip..." );
+ User::Leave( KErrNotFound );
+ }
+
User::LeaveIfError( CheckDbState() );
HBufC* path = aPath.AllocLC();
@@ -1761,6 +1748,12 @@
{
TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsL(%S)", &aPath );
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsL() read only, skip..." );
+ return;
+ }
+
#ifdef _DEBUG
TTime aStart, aStop;
aStart.UniversalTime();
@@ -1960,6 +1953,12 @@
{
TN_DEBUG2( "CThumbnailStore::RenameThumbnailsL(%S)", &aCurrentPath );
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::RenameThumbnailsL() read only, skip..." );
+ return;
+ }
+
#ifdef _DEBUG
TTime aStart, aStop;
aStart.UniversalTime();
@@ -2049,6 +2048,12 @@
StopAutoFlush();
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::FlushCacheTable() read only, skip..." );
+ return;
+ }
+
if(iBatchItemCount <= 0 || CheckDbState() != KErrNone)
{
// cache empty or db unusable
@@ -2190,6 +2195,12 @@
{
TN_DEBUG1( "CThumbnailStore::StartAutoFlush()" );
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::StartAutoFlush() read only, skip..." );
+ return;
+ }
+
TInt err = KErrNone;
if( iAutoFlushTimer )
@@ -2371,6 +2382,13 @@
{
TN_DEBUG2( "CThumbnailStore::CheckModifiedByPathL() %S", &aPath);
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::CheckModifiedByPathL() read only, skip..." );
+ modifiedChanged = EFalse;
+ return ETrue;
+ }
+
User::LeaveIfError( CheckDbState() );
HBufC* path = aPath.AllocLC();
@@ -2450,6 +2468,16 @@
return ret;
}
+
+// -----------------------------------------------------------------------------
+// IsReadOnly()
+// -----------------------------------------------------------------------------
+//
+TBool CThumbnailStore::IsReadOnly()
+ {
+ return iReadOnly;
+ }
+
// -----------------------------------------------------------------------------
// PrepareBlacklistedItemsForRetryL()
// -----------------------------------------------------------------------------
@@ -2480,6 +2508,12 @@
TInt CThumbnailStore::DeleteMarkedL()
{
TN_DEBUG1( "CThumbnailStore::DeleteMarkedL()" );
+
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::DeleteMarkedL() read only, skip..." );
+ return KErrAccessDenied;
+ }
#ifdef _DEBUG
TTime aStart, aStop;
@@ -2571,6 +2605,12 @@
TInt CThumbnailStore::FileExistenceCheckL()
{
TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL()" );
+
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL() read only, skip..." );
+ return ETrue;
+ }
#ifdef _DEBUG
TTime aStart, aStop;
@@ -2693,7 +2733,7 @@
//
TInt CThumbnailStore::CheckDbState()
{
- if (iUnrecoverable)
+ if (iUnrecoverable && !iReadOnly)
{
TN_DEBUG1( "CThumbnailStore::CheckDbState() - database in unrecoverable state" );
__ASSERT_DEBUG( !iUnrecoverable, ThumbnailPanic( EThumbnailDatabaseUnrecoverable ));
@@ -2723,6 +2763,11 @@
TBool CThumbnailStore::IsDiskFull()
{
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::IsDiskFull() read only, skip..." );
+ return EFalse;
+ }
return iDiskFull;
}
@@ -2734,6 +2779,12 @@
{
TN_DEBUG2( "CThumbnailStore::ActivityChanged() aActive == %d", aActive);
+ if( iReadOnly )
+ {
+ TN_DEBUG1( "CThumbnailStore::ActivityChanged() read only, skip..." );
+ return;
+ }
+
if( aActive )
{
iIdle = EFalse;