imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp
branchRCL_3
changeset 38 2b4b06654caa
parent 37 f759b6186ab5
child 40 6257223ede8a
equal deleted inserted replaced
37:f759b6186ab5 38:2b4b06654caa
    45 
    45 
    46 // Database path without drive letter
    46 // Database path without drive letter
    47 //Symbian^3 v4
    47 //Symbian^3 v4
    48 _LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v4.db" );
    48 _LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v4.db" );
    49 
    49 
    50 _LIT( KDrv, ":");
       
    51 
    50 
    52 // Allow access to database only for the server process
    51 // Allow access to database only for the server process
    53 const TSecurityPolicy KThumbnailDatabaseSecurityPolicy( TSecureId(
    52 const TSecurityPolicy KThumbnailDatabaseSecurityPolicy( TSecureId(
    54     THUMBNAIL_MANAGER_SERVER_UID ));
    53     THUMBNAIL_MANAGER_SERVER_UID ));
    55 
    54 
   165 // ---------------------------------------------------------------------------
   164 // ---------------------------------------------------------------------------
   166 // CThumbnailStore::NewL()
   165 // CThumbnailStore::NewL()
   167 // Two-phased constructor.
   166 // Two-phased constructor.
   168 // ---------------------------------------------------------------------------
   167 // ---------------------------------------------------------------------------
   169 //
   168 //
   170 CThumbnailStore* CThumbnailStore::NewL( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer )
   169 CThumbnailStore* CThumbnailStore::NewL( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer, const TBool aReadOnly )
   171     {
   170     {
   172     CThumbnailStore* self = new( ELeave )CThumbnailStore( aFs, aDrive, aImei, aServer );
   171     CThumbnailStore* self = new( ELeave )CThumbnailStore( aFs, aDrive, aImei, aServer, aReadOnly );
   173     CleanupStack::PushL( self );
   172     CleanupStack::PushL( self );
   174     self->ConstructL();
   173     self->ConstructL();
   175     CleanupStack::Pop( self );
   174     CleanupStack::Pop( self );
   176     return self;
   175     return self;
   177     }
   176     }
   221 // ---------------------------------------------------------------------------
   220 // ---------------------------------------------------------------------------
   222 // CThumbnailStore::CThumbnailStore()
   221 // CThumbnailStore::CThumbnailStore()
   223 // C++ default constructor can NOT contain any code, that might leave.
   222 // C++ default constructor can NOT contain any code, that might leave.
   224 // ---------------------------------------------------------------------------
   223 // ---------------------------------------------------------------------------
   225 //
   224 //
   226 CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer ): 
   225 CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer, const TBool aReadOnly ): 
   227     iFs( aFs ), iDrive( aDrive ), iDriveChar( 0 ), iBatchItemCount(0), iImei(aImei), 
   226     iFs( aFs ), iDrive( aDrive ), iDriveChar( 0 ), iBatchItemCount(0), iImei(aImei), iServer(aServer), iDiskFullNotifier(NULL), 
   228     iServer(aServer), iDiskFull(EFalse), iUnrecoverable(ETrue), iBatchFlushItemCount(KMInBatchItems)
   227     iDiskFull(EFalse), iActivityManager(NULL), iUnrecoverable(ETrue), iBatchFlushItemCount(KMInBatchItems), iReadOnly(aReadOnly)
   229     {
   228     {
   230     // no implementation required
   229     // no implementation required
   231     }
   230     }
   232 
   231 
   233 // ---------------------------------------------------------------------------
   232 // ---------------------------------------------------------------------------
   240     TN_DEBUG1( "CThumbnailStore::ConstructL()" );
   239     TN_DEBUG1( "CThumbnailStore::ConstructL()" );
   241 
   240 
   242 #ifdef _DEBUG
   241 #ifdef _DEBUG
   243     iThumbCounter = 0;
   242     iThumbCounter = 0;
   244 #endif
   243 #endif
   245     
   244     if(!iReadOnly)
   246     HBufC* databasePath = HBufC::NewLC( KMaxFileName );
   245         {
   247     TPtr pathPtr = databasePath->Des();
   246         HBufC* databasePath = HBufC::NewLC( KMaxFileName );
   248     User::LeaveIfError( RFs::DriveToChar( iDrive, iDriveChar ));
   247         TPtr pathPtr = databasePath->Des();
   249     pathPtr.Append( iDriveChar );
   248         User::LeaveIfError( RFs::DriveToChar( iDrive, iDriveChar ));
   250     pathPtr.Append( KThumbnailDatabaseName );
   249         pathPtr.Append( iDriveChar );
   251     
   250         pathPtr.Append( KThumbnailDatabaseName );
   252 	//start disk space monitor
   251         
   253     iDiskFullNotifier = CThumbnailStoreDiskSpaceNotifierAO::NewL( *this, 
   252         //start disk space monitor
   254                                             KDiskFullThreshold,
   253         iDiskFullNotifier = CThumbnailStoreDiskSpaceNotifierAO::NewL( *this, 
   255                                             pathPtr );
   254                                                 KDiskFullThreshold,
   256 
   255                                                 pathPtr );
   257     CleanupStack::PopAndDestroy( databasePath );
   256 
   258     
   257         CleanupStack::PopAndDestroy( databasePath );
   259     TN_DEBUG2( "CThumbnailStore::ConstructL() drive: %d", iDrive );
   258     
   260     
   259         TN_DEBUG2( "CThumbnailStore::ConstructL() drive: %d", iDrive );
   261     OpenDatabaseL();
   260     
   262     
   261         OpenDatabaseL();
   263     // to monitor device activity
   262     
   264     iActivityManager = CTMActivityManager::NewL( this, KStoreMaintenanceIdle);
   263         // to monitor device activity
   265     iActivityManager->Start();
   264         iActivityManager = CTMActivityManager::NewL( this, KStoreMaintenanceIdle);
   266     
   265         iActivityManager->Start();
   267     iDeleteThumbs = ETrue;
   266     
   268     iCheckFilesExist = ETrue;
   267         iDeleteThumbs = ETrue;
   269     iLastCheckedRowID = -1;
   268         iCheckFilesExist = ETrue;
       
   269         }
       
   270     else
       
   271         {
       
   272 	    TN_DEBUG1( "CThumbnailStore::ConstructL() - read only, dymmy mode..." );
       
   273         iDeleteThumbs = EFalse;
       
   274         iCheckFilesExist = EFalse;
       
   275         iLastCheckedRowID = -1;
       
   276         }
   270     }
   277     }
   271 
   278 
   272 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   273 // OpenDatabaseL database file
   280 // OpenDatabaseL database file
   274 // ---------------------------------------------------------------------------
   281 // ---------------------------------------------------------------------------
   546     
   553     
   547     RSqlStatement stmt;
   554     RSqlStatement stmt;
   548     TInt column = 0;   
   555     TInt column = 0;   
   549     TInt rowStatus = 0;
   556     TInt rowStatus = 0;
   550     TInt64 inforows = -1;
   557     TInt64 inforows = -1;
   551     TInt64 infocount = -1;
       
   552     TInt64 datarows = -1;
   558     TInt64 datarows = -1;
   553     TInt64 datacount = -1;
       
   554     
   559     
   555     TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID );
   560     TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID );
   556     if(ret < 0)
   561     if(ret < 0)
   557         {
   562         {
   558         stmt.Close();
   563         stmt.Close();
   574         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   579         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   575         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   580         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   576 #endif
   581 #endif
   577         return KErrNotSupported;
   582         return KErrNotSupported;
   578         }
   583         }
   579     
   584               
   580     ret = stmt.Prepare( iDatabase, KGetInfoCount );
       
   581     if(ret < 0)
       
   582         {
       
   583         stmt.Close();
       
   584         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoCount failed %d");
       
   585         return KErrNotSupported;
       
   586         }
       
   587     rowStatus = stmt.Next();
       
   588                 
       
   589     if ( rowStatus == KSqlAtRow)    
       
   590         {        
       
   591         infocount = stmt.ColumnInt64( column );  
       
   592         }
       
   593                 
       
   594     stmt.Close();
       
   595     
       
   596     if(rowStatus < 0)
       
   597         {
       
   598 #ifdef _DEBUG
       
   599         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
       
   600         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
       
   601 #endif
       
   602         return KErrNotSupported;
       
   603         }
       
   604             
       
   605     ret = stmt.Prepare( iDatabase, KGetDataRowID );
   585     ret = stmt.Prepare( iDatabase, KGetDataRowID );
   606     if(ret < 0)
   586     if(ret < 0)
   607         {
   587         {
   608         stmt.Close();
   588         stmt.Close();
   609         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetDataRowID failed");
   589         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetDataRowID failed");
   625         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   605         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   626 #endif
   606 #endif
   627         return KErrNotSupported;
   607         return KErrNotSupported;
   628         }
   608         }
   629     
   609     
   630     ret = stmt.Prepare( iDatabase, KGetInfoDataCount );
       
   631     if(ret < 0)
       
   632         {
       
   633         stmt.Close();
       
   634         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoDataCount failed %d");
       
   635         return KErrNotSupported;
       
   636         }
       
   637     rowStatus = stmt.Next();
       
   638                 
       
   639     if ( rowStatus == KSqlAtRow)    
       
   640         {        
       
   641         datacount = stmt.ColumnInt64( column );  
       
   642         }
       
   643                 
       
   644     stmt.Close();
       
   645     
       
   646     if(rowStatus < 0)
       
   647         {
       
   648 #ifdef _DEBUG
       
   649         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
       
   650         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
       
   651 #endif
       
   652         return KErrNotSupported;
       
   653         }
       
   654     
       
   655     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - inforows %Ld", inforows );
   610     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - inforows %Ld", inforows );
   656     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - infocount %Ld", infocount );
       
   657     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datarows %Ld", datarows );
   611     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datarows %Ld", datarows );
   658     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datacount %Ld", datacount );
   612             
   659             
   613     if( inforows != datarows )
   660     if( inforows != datarows || datacount != infocount)
       
   661         {
   614         {
   662         TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" );
   615         TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" );
   663         return KErrNotSupported;
   616         return KErrNotSupported;
   664         }  
   617         }  
   665     else
   618     else
  1120 void CThumbnailStore::StoreThumbnailL( const TDesC& aPath, const TDes8& aData,
  1073 void CThumbnailStore::StoreThumbnailL( const TDesC& aPath, const TDes8& aData,
  1121     const TSize& aSize, const TSize& aOriginalSize, const TThumbnailFormat& aFormat, TInt aFlags, 
  1074     const TSize& aSize, const TSize& aOriginalSize, const TThumbnailFormat& aFormat, TInt aFlags, 
  1122 	const TThumbnailSize& aThumbnailSize, const TInt64 aModified, const TBool aThumbFromPath )
  1075 	const TThumbnailSize& aThumbnailSize, const TInt64 aModified, const TBool aThumbFromPath )
  1123     {
  1076     {
  1124     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( private ) in" );
  1077     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( private ) in" );
       
  1078     
       
  1079     if(iReadOnly)
       
  1080         {
       
  1081         TN_DEBUG1( "CThumbnailStore::StoreThumbnailL() read only, skip..." );
       
  1082         return;
       
  1083         }
  1125 
  1084 
  1126 #ifdef _DEBUG
  1085 #ifdef _DEBUG
  1127     TTime aStart, aStop;
  1086     TTime aStart, aStop;
  1128     aStart.UniversalTime();
  1087     aStart.UniversalTime();
  1129 #endif
  1088 #endif
  1271     aThumbnail, const TSize& aOriginalSize, TBool /*aCropped*/, const TThumbnailSize aThumbnailSize, 
  1230     aThumbnail, const TSize& aOriginalSize, TBool /*aCropped*/, const TThumbnailSize aThumbnailSize, 
  1272     const TInt64 aModified, TBool aThumbFromPath, TBool aBlackListed )
  1231     const TInt64 aModified, TBool aThumbFromPath, TBool aBlackListed )
  1273     {
  1232     {
  1274     TSize thumbSize = aThumbnail->SizeInPixels();
  1233     TSize thumbSize = aThumbnail->SizeInPixels();
  1275     TN_DEBUG4( "CThumbnailStore::StoreThumbnailL( public ) aThumbnailSize = %d, aThumbnailSize(%d,%d) IN", aThumbnailSize, thumbSize.iWidth, thumbSize.iHeight );
  1234     TN_DEBUG4( "CThumbnailStore::StoreThumbnailL( public ) aThumbnailSize = %d, aThumbnailSize(%d,%d) IN", aThumbnailSize, thumbSize.iWidth, thumbSize.iHeight );
       
  1235     
       
  1236     if(iReadOnly)
       
  1237         {
       
  1238         TN_DEBUG1( "CThumbnailStore::StoreThumbnailL() read only, skip..." );
       
  1239         return;
       
  1240         }
  1276 
  1241 
  1277     __ASSERT_DEBUG(( aThumbnail ), ThumbnailPanic( EThumbnailNullPointer ));
  1242     __ASSERT_DEBUG(( aThumbnail ), ThumbnailPanic( EThumbnailNullPointer ));
  1278     
  1243     
  1279     User::LeaveIfError( CheckDbState() );
  1244     User::LeaveIfError( CheckDbState() );
  1280     
  1245     
  1318             
  1283             
  1319                 HBufC8* data = NULL;
  1284                 HBufC8* data = NULL;
  1320                 CleanupStack::PushL( data );
  1285                 CleanupStack::PushL( data );
  1321                 
  1286                 
  1322                 CImageEncoder* encoder = NULL;
  1287                 CImageEncoder* encoder = NULL;
  1323                 TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::EHwImplementation, data, CImageEncoder::EOptionAlwaysThread ) );
  1288 				
       
  1289 				CImageEncoder::TOptions options = ( CImageEncoder::TOptions )( CImageEncoder::EOptionAlwaysThread );
       
  1290 				
       
  1291                 TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::EHwImplementation, data, options ) );
  1324                 if ( decErr != KErrNone )
  1292                 if ( decErr != KErrNone )
  1325                     {
  1293                     {
  1326                     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - HW CExtJpegEncoder failed %d", decErr);
  1294                     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - HW CExtJpegEncoder failed %d", decErr);
  1327                 
  1295                 
  1328                     TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::ESwImplementation, data, CImageEncoder::EOptionAlwaysThread ) );
  1296                     TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::ESwImplementation, data, options ) );
  1329                     if ( decErr != KErrNone )
  1297                     if ( decErr != KErrNone )
  1330                         {
  1298                         {
  1331                         TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - SW CExtJpegEncoder failed %d", decErr);
  1299                         TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - SW CExtJpegEncoder failed %d", decErr);
  1332                     
  1300                     
  1333                         TRAPD( decErr, encoder = CImageEncoder::DataNewL( data,  KJpegMime(), CImageEncoder::EOptionAlwaysThread ) );
  1301                         TRAPD( decErr, encoder = CImageEncoder::DataNewL( data,  KJpegMime(), options ) );
  1334                         if ( decErr != KErrNone )
  1302                         if ( decErr != KErrNone )
  1335                             {
  1303                             {
  1336                             TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - CImageEncoder failed %d", decErr);
  1304                             TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - CImageEncoder failed %d", decErr);
  1337                             
  1305                             
  1338                             User::Leave(decErr);
  1306                             User::Leave(decErr);
  1361                 TJpegImageData* imageData = new (ELeave) TJpegImageData();
  1329                 TJpegImageData* imageData = new (ELeave) TJpegImageData();
  1362                 CleanupStack::PushL( imageData );
  1330                 CleanupStack::PushL( imageData );
  1363                 
  1331                 
  1364                 // Set some format specific data
  1332                 // Set some format specific data
  1365                 imageData->iSampleScheme = TJpegImageData::EColor444;
  1333                 imageData->iSampleScheme = TJpegImageData::EColor444;
  1366                 imageData->iQualityFactor = 75;
  1334                 imageData->iQualityFactor = 80;
  1367                 
  1335                 
  1368                 // imageData - ownership passed to frameImageData after AppendImageData
  1336                 // imageData - ownership passed to frameImageData after AppendImageData
  1369                 User::LeaveIfError(frameImageData->AppendImageData(imageData));
  1337                 User::LeaveIfError(frameImageData->AppendImageData(imageData));
  1370                 CleanupStack::Pop( imageData );
  1338                 CleanupStack::Pop( imageData );
  1371                 
  1339                 
  1410                 stream.Open( *buf );
  1378                 stream.Open( *buf );
  1411                 aThumbnail->ExternalizeL( stream );
  1379                 aThumbnail->ExternalizeL( stream );
  1412             
  1380             
  1413                 StoreThumbnailL( *path, buf->Ptr( 0 ), aThumbnail->SizeInPixels(),
  1381                 StoreThumbnailL( *path, buf->Ptr( 0 ), aThumbnail->SizeInPixels(),
  1414                                  aOriginalSize, EThumbnailFormatFbsBitmap, flags, 
  1382                                  aOriginalSize, EThumbnailFormatFbsBitmap, flags, 
  1415                                  aThumbnailSize, aModified);
  1383                                  aThumbnailSize, aModified, aThumbFromPath);
  1416   
  1384   
  1417                 CleanupStack::PopAndDestroy( buf );
  1385                 CleanupStack::PopAndDestroy( buf );
  1418                 }
  1386                 }
  1419             
  1387             
  1420             break;
  1388             break;
  1431 // ---------------------------------------------------------------------------
  1399 // ---------------------------------------------------------------------------
  1432 //
  1400 //
  1433 TBool CThumbnailStore::FindDuplicateL( const TDesC& aPath, const TThumbnailSize& aThumbnailSize )
  1401 TBool CThumbnailStore::FindDuplicateL( const TDesC& aPath, const TThumbnailSize& aThumbnailSize )
  1434     {
  1402     {
  1435     TN_DEBUG1( "CThumbnailStore::FindDuplicateL()" );
  1403     TN_DEBUG1( "CThumbnailStore::FindDuplicateL()" );
       
  1404 	
       
  1405 	if(iReadOnly)
       
  1406 		{
       
  1407 		TN_DEBUG1( "CThumbnailStore::FindDuplicateL() read only, skip..." );
       
  1408 		return EFalse;
       
  1409 		}
  1436     
  1410     
  1437     User::LeaveIfError( CheckDbState() );
  1411     User::LeaveIfError( CheckDbState() );
  1438     
  1412     
  1439     TInt rowStatus = 0;
  1413     TInt rowStatus = 0;
  1440     TInt paramIndex = 0;
  1414     TInt paramIndex = 0;
  1526 //     
  1500 //     
  1527 void CThumbnailStore::GetMissingSizesL( const TDesC& aPath, TInt aSourceType, RArray <
  1501 void CThumbnailStore::GetMissingSizesL( const TDesC& aPath, TInt aSourceType, RArray <
  1528     TThumbnailPersistentSize > & aMissingSizes, TBool aCheckGridSizeOnly )
  1502     TThumbnailPersistentSize > & aMissingSizes, TBool aCheckGridSizeOnly )
  1529     {
  1503     {
  1530     TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() aSourceType == %d", aSourceType );
  1504     TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() aSourceType == %d", aSourceType );
       
  1505     
       
  1506     if(iReadOnly)
       
  1507         {
       
  1508         TN_DEBUG1( "CThumbnailStore::GetMissingSizesL() read only, skip..." );
       
  1509 		return;
       
  1510         }
  1531     
  1511     
  1532     User::LeaveIfError( CheckDbState() );
  1512     User::LeaveIfError( CheckDbState() );
  1533     
  1513     
  1534     HBufC* path = aPath.AllocLC();
  1514     HBufC* path = aPath.AllocLC();
  1535     TPtr ptr(path->Des());
  1515     TPtr ptr(path->Des());
  1635 //
  1615 //
  1636 void CThumbnailStore::FetchThumbnailL( const TDesC& aPath, CFbsBitmap* &
  1616 void CThumbnailStore::FetchThumbnailL( const TDesC& aPath, CFbsBitmap* &
  1637     aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aThumbnailRealSize )
  1617     aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aThumbnailRealSize )
  1638     {
  1618     {
  1639     TN_DEBUG3( "CThumbnailStore::FetchThumbnailL(%S) aThumbnailSize==%d", &aPath, aThumbnailSize );
  1619     TN_DEBUG3( "CThumbnailStore::FetchThumbnailL(%S) aThumbnailSize==%d", &aPath, aThumbnailSize );
       
  1620     
       
  1621     if(iReadOnly)
       
  1622         {
       
  1623         TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() read only, skip..." );
       
  1624         User::Leave( KErrNotFound );
       
  1625         }
  1640     
  1626     
  1641     User::LeaveIfError( CheckDbState() );
  1627     User::LeaveIfError( CheckDbState() );
  1642     
  1628     
  1643     HBufC* path = aPath.AllocLC();
  1629     HBufC* path = aPath.AllocLC();
  1644     TPtr ptr(path->Des());
  1630     TPtr ptr(path->Des());
  1760 void CThumbnailStore::DeleteThumbnailsL( const TDesC& aPath, TBool aForce, 
  1746 void CThumbnailStore::DeleteThumbnailsL( const TDesC& aPath, TBool aForce, 
  1761                                          TBool aTransaction )
  1747                                          TBool aTransaction )
  1762     {
  1748     {
  1763     TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsL(%S)", &aPath );
  1749     TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsL(%S)", &aPath );
  1764 
  1750 
       
  1751     if(iReadOnly)
       
  1752         {
       
  1753         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsL() read only, skip..." );
       
  1754         return;
       
  1755         }
       
  1756     
  1765 #ifdef _DEBUG
  1757 #ifdef _DEBUG
  1766     TTime aStart, aStop;
  1758     TTime aStart, aStop;
  1767     aStart.UniversalTime();
  1759     aStart.UniversalTime();
  1768 #endif
  1760 #endif
  1769     
  1761     
  1959 //
  1951 //
  1960 void CThumbnailStore::RenameThumbnailsL( const TDesC& aCurrentPath, const TDesC& aNewPath )
  1952 void CThumbnailStore::RenameThumbnailsL( const TDesC& aCurrentPath, const TDesC& aNewPath )
  1961     {
  1953     {
  1962     TN_DEBUG2( "CThumbnailStore::RenameThumbnailsL(%S)", &aCurrentPath );
  1954     TN_DEBUG2( "CThumbnailStore::RenameThumbnailsL(%S)", &aCurrentPath );
  1963     
  1955     
       
  1956     if(iReadOnly)
       
  1957         {
       
  1958         TN_DEBUG1( "CThumbnailStore::RenameThumbnailsL() read only, skip..." );
       
  1959         return;
       
  1960         }
       
  1961     
  1964 #ifdef _DEBUG
  1962 #ifdef _DEBUG
  1965     TTime aStart, aStop;
  1963     TTime aStart, aStop;
  1966     aStart.UniversalTime();
  1964     aStart.UniversalTime();
  1967 #endif
  1965 #endif
  1968     
  1966     
  2047 void CThumbnailStore::FlushCacheTable( TBool aForce )
  2045 void CThumbnailStore::FlushCacheTable( TBool aForce )
  2048     {
  2046     {
  2049     TN_DEBUG1("CThumbnailStore::FlushCacheTable() in");
  2047     TN_DEBUG1("CThumbnailStore::FlushCacheTable() in");
  2050     
  2048     
  2051     StopAutoFlush();
  2049     StopAutoFlush();
       
  2050     
       
  2051     if(iReadOnly)
       
  2052         {
       
  2053         TN_DEBUG1( "CThumbnailStore::FlushCacheTable() read only, skip..." );
       
  2054         return;
       
  2055         }
  2052     
  2056     
  2053     if(iBatchItemCount <= 0 || CheckDbState() != KErrNone)
  2057     if(iBatchItemCount <= 0 || CheckDbState() != KErrNone)
  2054         {
  2058         {
  2055         // cache empty or db unusable
  2059         // cache empty or db unusable
  2056         TN_DEBUG1( "CThumbnailStore::FlushCacheTable() error ");
  2060         TN_DEBUG1( "CThumbnailStore::FlushCacheTable() error ");
  2189 //
  2193 //
  2190 void CThumbnailStore::StartAutoFlush()
  2194 void CThumbnailStore::StartAutoFlush()
  2191     {
  2195     {
  2192     TN_DEBUG1( "CThumbnailStore::StartAutoFlush()" );
  2196     TN_DEBUG1( "CThumbnailStore::StartAutoFlush()" );
  2193     
  2197     
       
  2198     if(iReadOnly)
       
  2199         {
       
  2200         TN_DEBUG1( "CThumbnailStore::StartAutoFlush() read only, skip..." );
       
  2201         return;
       
  2202         }
       
  2203     
  2194     TInt err = KErrNone;
  2204     TInt err = KErrNone;
  2195     
  2205     
  2196     if( iAutoFlushTimer )
  2206     if( iAutoFlushTimer )
  2197         {
  2207         {
  2198         iAutoFlushTimer->Cancel();
  2208         iAutoFlushTimer->Cancel();
  2370 
  2380 
  2371 TBool CThumbnailStore::CheckModifiedByPathL( const TDesC& aPath, const TInt64 aModified, TBool& modifiedChanged )
  2381 TBool CThumbnailStore::CheckModifiedByPathL( const TDesC& aPath, const TInt64 aModified, TBool& modifiedChanged )
  2372     {
  2382     {
  2373     TN_DEBUG2( "CThumbnailStore::CheckModifiedByPathL() %S", &aPath);
  2383     TN_DEBUG2( "CThumbnailStore::CheckModifiedByPathL() %S", &aPath);
  2374     
  2384     
       
  2385     if(iReadOnly)
       
  2386     	{
       
  2387     	TN_DEBUG1( "CThumbnailStore::CheckModifiedByPathL() read only, skip..." );
       
  2388 		modifiedChanged = EFalse;
       
  2389     	return ETrue;
       
  2390     	}
       
  2391 	
  2375     User::LeaveIfError( CheckDbState() );
  2392     User::LeaveIfError( CheckDbState() );
  2376     
  2393     
  2377     HBufC* path = aPath.AllocLC();
  2394     HBufC* path = aPath.AllocLC();
  2378     TPtr ptr(path->Des());
  2395     TPtr ptr(path->Des());
  2379     StripDriveLetterL( ptr );
  2396     StripDriveLetterL( ptr );
  2449     CleanupStack::PopAndDestroy( path );
  2466     CleanupStack::PopAndDestroy( path );
  2450    
  2467    
  2451     return ret;
  2468     return ret;
  2452 }
  2469 }
  2453 	
  2470 	
       
  2471 
       
  2472 // -----------------------------------------------------------------------------
       
  2473 // IsReadOnly()
       
  2474 // -----------------------------------------------------------------------------
       
  2475 //
       
  2476 TBool CThumbnailStore::IsReadOnly()
       
  2477     {
       
  2478     return iReadOnly;
       
  2479     }
       
  2480 
  2454 // -----------------------------------------------------------------------------
  2481 // -----------------------------------------------------------------------------
  2455 // PrepareBlacklistedItemsForRetryL()
  2482 // PrepareBlacklistedItemsForRetryL()
  2456 // -----------------------------------------------------------------------------
  2483 // -----------------------------------------------------------------------------
  2457 //
  2484 //
  2458 void CThumbnailStore::PrepareBlacklistedItemsForRetryL()
  2485 void CThumbnailStore::PrepareBlacklistedItemsForRetryL()
  2479 // -----------------------------------------------------------------------------
  2506 // -----------------------------------------------------------------------------
  2480 //
  2507 //
  2481 TInt CThumbnailStore::DeleteMarkedL()
  2508 TInt CThumbnailStore::DeleteMarkedL()
  2482     {
  2509     {
  2483     TN_DEBUG1( "CThumbnailStore::DeleteMarkedL()" );
  2510     TN_DEBUG1( "CThumbnailStore::DeleteMarkedL()" );
       
  2511     
       
  2512     if(iReadOnly)
       
  2513         {
       
  2514         TN_DEBUG1( "CThumbnailStore::DeleteMarkedL() read only, skip..." );
       
  2515         return KErrAccessDenied;
       
  2516         }
  2484    
  2517    
  2485 #ifdef _DEBUG
  2518 #ifdef _DEBUG
  2486     TTime aStart, aStop;
  2519     TTime aStart, aStop;
  2487     aStart.UniversalTime();
  2520     aStart.UniversalTime();
  2488 #endif
  2521 #endif
  2570 // -----------------------------------------------------------------------------
  2603 // -----------------------------------------------------------------------------
  2571 //
  2604 //
  2572 TInt CThumbnailStore::FileExistenceCheckL()
  2605 TInt CThumbnailStore::FileExistenceCheckL()
  2573     {
  2606     {
  2574     TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL()" );
  2607     TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL()" );
       
  2608 	
       
  2609     if(iReadOnly)
       
  2610 		{
       
  2611 		TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL() read only, skip..." );
       
  2612 		return ETrue;
       
  2613 		}
  2575     
  2614     
  2576 #ifdef _DEBUG
  2615 #ifdef _DEBUG
  2577     TTime aStart, aStop;
  2616     TTime aStart, aStop;
  2578     aStart.UniversalTime();
  2617     aStart.UniversalTime();
  2579 #endif
  2618 #endif
  2668 // -----------------------------------------------------------------------------
  2707 // -----------------------------------------------------------------------------
  2669 //
  2708 //
  2670 void CThumbnailStore::StripDriveLetterL( TDes& aPath )
  2709 void CThumbnailStore::StripDriveLetterL( TDes& aPath )
  2671     {
  2710     {
  2672     TInt pos = aPath.Find(KDrv);
  2711     TInt pos = aPath.Find(KDrv);
       
  2712     TInt pos2 = aPath.Find(KBackSlash);
  2673     
  2713     
  2674     // if URI contains drive letter
  2714     // if URI contains drive letter
  2675     if ( pos == 1 )
  2715     if ( pos == 1 )
  2676         {
  2716         {
  2677         aPath.Delete(0,pos+1);
  2717         // normal URI
       
  2718         if ( pos2 == 2 )
       
  2719             {
       
  2720             aPath.Delete(0,pos+1);
       
  2721             }
       
  2722         // virtual URI
       
  2723         else
       
  2724             {
       
  2725             aPath.Replace(0,2,KBackSlash);
       
  2726             }
  2678         }
  2727         }
  2679     }
  2728     }
  2680 
  2729 
  2681 // -----------------------------------------------------------------------------
  2730 // -----------------------------------------------------------------------------
  2682 // CheckDbState
  2731 // CheckDbState
  2683 // -----------------------------------------------------------------------------
  2732 // -----------------------------------------------------------------------------
  2684 //
  2733 //
  2685 TInt CThumbnailStore::CheckDbState()
  2734 TInt CThumbnailStore::CheckDbState()
  2686     {
  2735     {
  2687     if (iUnrecoverable)
  2736     if (iUnrecoverable && !iReadOnly)
  2688         {
  2737         {
  2689         TN_DEBUG1( "CThumbnailStore::CheckDbState() - database in unrecoverable state" );
  2738         TN_DEBUG1( "CThumbnailStore::CheckDbState() - database in unrecoverable state" );
  2690         __ASSERT_DEBUG( !iUnrecoverable, ThumbnailPanic( EThumbnailDatabaseUnrecoverable ));
  2739         __ASSERT_DEBUG( !iUnrecoverable, ThumbnailPanic( EThumbnailDatabaseUnrecoverable ));
  2691         
  2740         
  2692         return KStoreUnrecoverableErr;
  2741         return KStoreUnrecoverableErr;
  2712     TN_DEBUG2( "CThumbnailStore::HandleDiskSpaceError() aError = %d", aError );
  2761     TN_DEBUG2( "CThumbnailStore::HandleDiskSpaceError() aError = %d", aError );
  2713     }
  2762     }
  2714 
  2763 
  2715 TBool CThumbnailStore::IsDiskFull()
  2764 TBool CThumbnailStore::IsDiskFull()
  2716     {
  2765     {
       
  2766     if(iReadOnly)
       
  2767         {
       
  2768         TN_DEBUG1( "CThumbnailStore::IsDiskFull() read only, skip..." );
       
  2769         return EFalse;
       
  2770         }
  2717     return iDiskFull;
  2771     return iDiskFull;
  2718     }
  2772     }
  2719 
  2773 
  2720 // -----------------------------------------------------------------------------
  2774 // -----------------------------------------------------------------------------
  2721 // ActivityDetected()
  2775 // ActivityDetected()
  2722 // -----------------------------------------------------------------------------
  2776 // -----------------------------------------------------------------------------
  2723 //
  2777 //
  2724 void CThumbnailStore::ActivityChanged(const TBool aActive)
  2778 void CThumbnailStore::ActivityChanged(const TBool aActive)
  2725     {
  2779     {
  2726     TN_DEBUG2( "CThumbnailStore::ActivityChanged() aActive == %d", aActive);
  2780     TN_DEBUG2( "CThumbnailStore::ActivityChanged() aActive == %d", aActive);
       
  2781     
       
  2782     if( iReadOnly )
       
  2783         {
       
  2784         TN_DEBUG1( "CThumbnailStore::ActivityChanged() read only, skip..." );
       
  2785         return;
       
  2786         }
  2727     
  2787     
  2728     if( aActive )
  2788     if( aActive )
  2729         {
  2789         {
  2730         iIdle = EFalse;
  2790         iIdle = EFalse;
  2731         }
  2791         }