--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Thu Jul 15 18:59:26 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Thu Aug 19 10:13:51 2010 +0300
@@ -47,7 +47,6 @@
//Symbian^3 v4
_LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v4.db" );
-_LIT( KDrv, ":");
// Allow access to database only for the server process
const TSecurityPolicy KThumbnailDatabaseSecurityPolicy( TSecureId(
@@ -167,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 );
@@ -223,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
}
@@ -242,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;
+ }
}
// ---------------------------------------------------------------------------
@@ -548,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)
@@ -576,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)
{
@@ -627,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;
@@ -1122,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;
@@ -1273,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 ));
@@ -1320,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);
@@ -1363,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));
@@ -1412,7 +1380,7 @@
StoreThumbnailL( *path, buf->Ptr( 0 ), aThumbnail->SizeInPixels(),
aOriginalSize, EThumbnailFormatFbsBitmap, flags,
- aThumbnailSize, aModified);
+ aThumbnailSize, aModified, aThumbFromPath);
CleanupStack::PopAndDestroy( buf );
}
@@ -1433,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() );
@@ -1529,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();
@@ -1638,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();
@@ -1762,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();
@@ -1961,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();
@@ -2050,6 +2048,12 @@
StopAutoFlush();
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::FlushCacheTable() read only, skip..." );
+ return;
+ }
+
if(iBatchItemCount <= 0 || CheckDbState() != KErrNone)
{
// cache empty or db unusable
@@ -2191,6 +2195,12 @@
{
TN_DEBUG1( "CThumbnailStore::StartAutoFlush()" );
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::StartAutoFlush() read only, skip..." );
+ return;
+ }
+
TInt err = KErrNone;
if( iAutoFlushTimer )
@@ -2372,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();
@@ -2451,6 +2468,16 @@
return ret;
}
+
+// -----------------------------------------------------------------------------
+// IsReadOnly()
+// -----------------------------------------------------------------------------
+//
+TBool CThumbnailStore::IsReadOnly()
+ {
+ return iReadOnly;
+ }
+
// -----------------------------------------------------------------------------
// PrepareBlacklistedItemsForRetryL()
// -----------------------------------------------------------------------------
@@ -2481,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;
@@ -2572,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;
@@ -2670,11 +2709,21 @@
void CThumbnailStore::StripDriveLetterL( TDes& aPath )
{
TInt pos = aPath.Find(KDrv);
+ TInt pos2 = aPath.Find(KBackSlash);
// if URI contains drive letter
if ( pos == 1 )
{
- aPath.Delete(0,pos+1);
+ // normal URI
+ if ( pos2 == 2 )
+ {
+ aPath.Delete(0,pos+1);
+ }
+ // virtual URI
+ else
+ {
+ aPath.Replace(0,2,KBackSlash);
+ }
}
}
@@ -2684,7 +2733,7 @@
//
TInt CThumbnailStore::CheckDbState()
{
- if (iUnrecoverable)
+ if (iUnrecoverable && !iReadOnly)
{
TN_DEBUG1( "CThumbnailStore::CheckDbState() - database in unrecoverable state" );
__ASSERT_DEBUG( !iUnrecoverable, ThumbnailPanic( EThumbnailDatabaseUnrecoverable ));
@@ -2714,6 +2763,11 @@
TBool CThumbnailStore::IsDiskFull()
{
+ if(iReadOnly)
+ {
+ TN_DEBUG1( "CThumbnailStore::IsDiskFull() read only, skip..." );
+ return EFalse;
+ }
return iDiskFull;
}
@@ -2725,6 +2779,12 @@
{
TN_DEBUG2( "CThumbnailStore::ActivityChanged() aActive == %d", aActive);
+ if( iReadOnly )
+ {
+ TN_DEBUG1( "CThumbnailStore::ActivityChanged() read only, skip..." );
+ return;
+ }
+
if( aActive )
{
iIdle = EFalse;