imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp
branchRCL_3
changeset 21 6257223ede8a
parent 20 2b4b06654caa
child 22 9d4d3445ce6e
equal deleted inserted replaced
20:2b4b06654caa 21:6257223ede8a
    31 #include "thumbnailmanageruids.hrh"
    31 #include "thumbnailmanageruids.hrh"
    32 #include "thumbnailcenrep.h"
    32 #include "thumbnailcenrep.h"
    33 #include "thumbnailpanic.h"
    33 #include "thumbnailpanic.h"
    34 #include "thumbnailmanagerconstants.h"
    34 #include "thumbnailmanagerconstants.h"
    35 #include "thumbnailserver.h"
    35 #include "thumbnailserver.h"
       
    36 #include "OstTraceDefinitions.h"
       
    37 #ifdef OST_TRACE_COMPILER_IN_USE
       
    38 #include "thumbnailstoreTraces.h"
       
    39 #endif
       
    40 
    36 
    41 
    37 
    42 
    38 _LIT8( KThumbnailSqlConfig, "page_size=32768; cache_size=64;" );
    43 _LIT8( KThumbnailSqlConfig, "page_size=32768; cache_size=64;" );
    39 
    44 
    40 const TInt KStreamBufferSize = 1024 * 8;
    45 const TInt KStreamBufferSize = 1024 * 8;
    42 const TInt KMinor = 2;
    47 const TInt KMinor = 2;
    43 
    48 
    44 const TInt KStoreUnrecoverableErr = KErrCorrupt;
    49 const TInt KStoreUnrecoverableErr = KErrCorrupt;
    45 
    50 
    46 // Database path without drive letter
    51 // Database path without drive letter
    47 //Symbian^3 v4
    52 //Symbian^4 v5
    48 _LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v4.db" );
    53 _LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v5.db" );
    49 
    54 
    50 
    55 
    51 // Allow access to database only for the server process
    56 // Allow access to database only for the server process
    52 const TSecurityPolicy KThumbnailDatabaseSecurityPolicy( TSecureId(
    57 const TSecurityPolicy KThumbnailDatabaseSecurityPolicy( TSecureId(
    53     THUMBNAIL_MANAGER_SERVER_UID ));
    58     THUMBNAIL_MANAGER_SERVER_UID ));
    70 void RThumbnailTransaction::BeginL()
    75 void RThumbnailTransaction::BeginL()
    71     {    
    76     {    
    72     if (iDatabase.InTransaction())
    77     if (iDatabase.InTransaction())
    73         {
    78         {
    74         TN_DEBUG1( "RThumbnailTransaction::BeginL() - error: old transaction open!" );
    79         TN_DEBUG1( "RThumbnailTransaction::BeginL() - error: old transaction open!" );
       
    80         OstTrace0( TRACE_NORMAL, RTHUMBNAILTRANSACTION_BEGINL, "RThumbnailTransaction::BeginL - error: old transaction open!" );
    75         __ASSERT_DEBUG(( !iDatabase.InTransaction() ), ThumbnailPanic( EThumbnailSQLTransaction ));
    81         __ASSERT_DEBUG(( !iDatabase.InTransaction() ), ThumbnailPanic( EThumbnailSQLTransaction ));
    76         
    82         
    77         // old transaction already open, don't open another
    83         // old transaction already open, don't open another
    78         iState = EOldOpen;
    84         iState = EOldOpen;
    79         
    85         
    89         {
    95         {
    90         iState = EError;
    96         iState = EError;
    91 #ifdef _DEBUG
    97 #ifdef _DEBUG
    92     TPtrC errorMsg = iDatabase.LastErrorMessage();
    98     TPtrC errorMsg = iDatabase.LastErrorMessage();
    93     TN_DEBUG3( "RThumbnailTransaction::BeginL() lastError %S, ret = %d" , &errorMsg, err);
    99     TN_DEBUG3( "RThumbnailTransaction::BeginL() lastError %S, ret = %d" , &errorMsg, err);
       
   100     OstTraceExt2( TRACE_NORMAL, DUP1_RTHUMBNAILTRANSACTION_BEGINL, "RThumbnailTransaction::BeginL - lastError;errorMsg=%S;err=%d", errorMsg, err );
    94 #endif
   101 #endif
    95         User::Leave( err );
   102         User::Leave( err );
    96         }
   103         }
    97     }
   104     }
    98 
   105 
   119         TInt ret = iDatabase.Exec( KThumbnailCommitTransaction );
   126         TInt ret = iDatabase.Exec( KThumbnailCommitTransaction );
   120     
   127     
   121 #ifdef _DEBUG
   128 #ifdef _DEBUG
   122     TPtrC errorMsg = iDatabase.LastErrorMessage();
   129     TPtrC errorMsg = iDatabase.LastErrorMessage();
   123     TN_DEBUG3( "RThumbnailTransaction::CommitL() lastError %S, ret = %d" , &errorMsg, ret);
   130     TN_DEBUG3( "RThumbnailTransaction::CommitL() lastError %S, ret = %d" , &errorMsg, ret);
       
   131     OstTraceExt2( TRACE_NORMAL, DUP2_RTHUMBNAILTRANSACTION_BEGINL, "RThumbnailTransaction::BeginL - lastError;errorMsg=%S;ret=%d", errorMsg, ret );
   124 #endif  
   132 #endif  
   125     User::LeaveIfError( ret );
   133     User::LeaveIfError( ret );
   126         }
   134         }
   127     
   135     
   128     iState = EClosed;
   136     iState = EClosed;
   148             return err;
   156             return err;
   149             }
   157             }
   150         else
   158         else
   151             {
   159             {
   152             TN_DEBUG1( "RThumbnailTransaction::Rollback() - automatic rollback already done!" );
   160             TN_DEBUG1( "RThumbnailTransaction::Rollback() - automatic rollback already done!" );
       
   161             OstTrace0( TRACE_NORMAL, RTHUMBNAILTRANSACTION_ROLLBACK, "RThumbnailTransaction::Rollback - automatic rollback already done!" );
   153             }
   162             }
   154         }
   163         }
   155     
   164     
   156     iState = EClosed;
   165     iState = EClosed;
   157     
   166     
   182 // ---------------------------------------------------------------------------
   191 // ---------------------------------------------------------------------------
   183 //
   192 //
   184 CThumbnailStore::~CThumbnailStore()
   193 CThumbnailStore::~CThumbnailStore()
   185     {
   194     {
   186     TN_DEBUG2( "CThumbnailStore::~CThumbnailStore() drive: %d", iDrive );
   195     TN_DEBUG2( "CThumbnailStore::~CThumbnailStore() drive: %d", iDrive );
       
   196     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTORE_CTHUMBNAILSTORE, "CThumbnailStore::~CThumbnailStore;iDrive=%d", iDrive );
   187     
   197     
   188     if(iActivityManager)
   198     if(iActivityManager)
   189         {
   199         {
   190         delete iActivityManager;
   200         delete iActivityManager;
   191         iActivityManager = NULL;
   201         iActivityManager = NULL;
   213     
   223     
   214     CloseStatements();   
   224     CloseStatements();   
   215     iDatabase.Close();
   225     iDatabase.Close();
   216     
   226     
   217     TN_DEBUG1( "CThumbnailStore::~CThumbnailStore() - database closed" );
   227     TN_DEBUG1( "CThumbnailStore::~CThumbnailStore() - database closed" );
       
   228     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_CTHUMBNAILSTORE, "CThumbnailStore::~CThumbnailStore - database closed" );
   218     }
   229     }
   219 
   230 
   220 // ---------------------------------------------------------------------------
   231 // ---------------------------------------------------------------------------
   221 // CThumbnailStore::CThumbnailStore()
   232 // CThumbnailStore::CThumbnailStore()
   222 // C++ default constructor can NOT contain any code, that might leave.
   233 // C++ default constructor can NOT contain any code, that might leave.
   235 // ---------------------------------------------------------------------------
   246 // ---------------------------------------------------------------------------
   236 //
   247 //
   237 void CThumbnailStore::ConstructL()
   248 void CThumbnailStore::ConstructL()
   238     {
   249     {
   239     TN_DEBUG1( "CThumbnailStore::ConstructL()" );
   250     TN_DEBUG1( "CThumbnailStore::ConstructL()" );
       
   251     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_CONSTRUCTL, "CThumbnailStore::ConstructL" );
   240 
   252 
   241 #ifdef _DEBUG
   253 #ifdef _DEBUG
   242     iThumbCounter = 0;
   254     iThumbCounter = 0;
   243 #endif
   255 #endif
   244     if(!iReadOnly)
   256     if(!iReadOnly)
   255                                                 pathPtr );
   267                                                 pathPtr );
   256 
   268 
   257         CleanupStack::PopAndDestroy( databasePath );
   269         CleanupStack::PopAndDestroy( databasePath );
   258     
   270     
   259         TN_DEBUG2( "CThumbnailStore::ConstructL() drive: %d", iDrive );
   271         TN_DEBUG2( "CThumbnailStore::ConstructL() drive: %d", iDrive );
       
   272         OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_CONSTRUCTL, "CThumbnailStore::ConstructL;iDrive=%d", iDrive );
   260     
   273     
   261         OpenDatabaseL();
   274         OpenDatabaseL();
   262     
   275     
   263         // to monitor device activity
   276         // to monitor device activity
   264         iActivityManager = CTMActivityManager::NewL( this, KStoreMaintenanceIdle);
   277         iActivityManager = CTMActivityManager::NewL( this, KStoreMaintenanceIdle);
   268         iCheckFilesExist = ETrue;
   281         iCheckFilesExist = ETrue;
   269         }
   282         }
   270     else
   283     else
   271         {
   284         {
   272 	    TN_DEBUG1( "CThumbnailStore::ConstructL() - read only, dymmy mode..." );
   285 	    TN_DEBUG1( "CThumbnailStore::ConstructL() - read only, dymmy mode..." );
       
   286         OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_CONSTRUCTL, "CThumbnailStore::ConstructL - read only, dymmy mode..." );
   273         iDeleteThumbs = EFalse;
   287         iDeleteThumbs = EFalse;
   274         iCheckFilesExist = EFalse;
   288         iCheckFilesExist = EFalse;
   275         iLastCheckedRowID = -1;
   289         iLastCheckedRowID = -1;
   276         }
   290         }
   277     }
   291     }
   280 // OpenDatabaseL database file
   294 // OpenDatabaseL database file
   281 // ---------------------------------------------------------------------------
   295 // ---------------------------------------------------------------------------
   282 TInt CThumbnailStore::OpenDatabaseFileL()
   296 TInt CThumbnailStore::OpenDatabaseFileL()
   283     {
   297     {
   284     TN_DEBUG1( "CThumbnailStore::OpenDatabaseFile()" );
   298     TN_DEBUG1( "CThumbnailStore::OpenDatabaseFile()" );
       
   299     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_OPENDATABASEFILEL, "CThumbnailStore::OpenDatabaseFileL" );
   285     
   300     
   286     HBufC* databasePath = HBufC::NewLC( KMaxFileName );
   301     HBufC* databasePath = HBufC::NewLC( KMaxFileName );
   287     TPtr pathPtr = databasePath->Des();
   302     TPtr pathPtr = databasePath->Des();
   288     TChar driveChar = 0;
   303     TChar driveChar = 0;
   289     User::LeaveIfError( RFs::DriveToChar( iDrive, driveChar ));
   304     User::LeaveIfError( RFs::DriveToChar( iDrive, driveChar ));
   299 // OpenDatabaseL database
   314 // OpenDatabaseL database
   300 // ---------------------------------------------------------------------------
   315 // ---------------------------------------------------------------------------
   301 TInt CThumbnailStore::OpenDatabaseL( TBool aNewDatabase )
   316 TInt CThumbnailStore::OpenDatabaseL( TBool aNewDatabase )
   302     {
   317     {
   303     TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() drive: %d", iDrive );
   318     TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() drive: %d", iDrive );
       
   319     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTORE_OPENDATABASEL, "CThumbnailStore::OpenDatabaseL;iDrive=%d", iDrive );
   304         
   320         
   305     CloseStatements();
   321     CloseStatements();
   306     iDatabase.Close();
   322     iDatabase.Close();
   307     iUnrecoverable = ETrue;
   323     iUnrecoverable = ETrue;
   308     
   324     
   323         {
   339         {
   324         // just open old
   340         // just open old
   325         err = OpenDatabaseFileL();
   341         err = OpenDatabaseFileL();
   326         
   342         
   327         TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() -- err = %d", err);
   343         TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() -- err = %d", err);
       
   344         OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_OPENDATABASEL, "CThumbnailStore::OpenDatabaseL;err=%d", err );
   328                
   345                
   329         if ( err == KErrNone)
   346         if ( err == KErrNone)
   330             {
   347             {
   331             // db found, check version and rowids
   348             // db found, check version and rowids
   332             checkError = CheckVersion();
   349             checkError = CheckVersion();
   393 // ---------------------------------------------------------------------------
   410 // ---------------------------------------------------------------------------
   394 //
   411 //
   395 void CThumbnailStore::PrepareDbL()
   412 void CThumbnailStore::PrepareDbL()
   396     {
   413     {
   397     TN_DEBUG1( "CThumbnailStore::PrepareDbL()" );
   414     TN_DEBUG1( "CThumbnailStore::PrepareDbL()" );
       
   415     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_PREPAREDBL, "CThumbnailStore::PrepareDbL" );
   398     
   416     
   399     // add persistent tables
   417     // add persistent tables
   400     CreateTablesL();
   418     CreateTablesL();
   401       
   419       
   402     AddVersionAndImeiL();
   420     AddVersionAndImeiL();
   410 // ---------------------------------------------------------------------------
   428 // ---------------------------------------------------------------------------
   411 //
   429 //
   412 void CThumbnailStore::CreateTablesL()
   430 void CThumbnailStore::CreateTablesL()
   413     {
   431     {
   414     TN_DEBUG1( "CThumbnailStore::CreateTablesL()" );
   432     TN_DEBUG1( "CThumbnailStore::CreateTablesL()" );
       
   433     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_CREATETABLESL, "CThumbnailStore::CreateTablesL" );
   415     
   434     
   416     TInt err = KErrNone;
   435     TInt err = KErrNone;
   417     err = iDatabase.Exec( KThumbnailCreateInfoTable );
   436     err = iDatabase.Exec( KThumbnailCreateInfoTable );
   418     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTable err=%d", err );
   437     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTable err=%d", err );
       
   438     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_CREATETABLESL, "CThumbnailStore::CreateTablesL - KThumbnailCreateInfoTable;err=%d", err );
   419     User::LeaveIfError( err );
   439     User::LeaveIfError( err );
   420     
   440     
   421     err = iDatabase.Exec( KThumbnailCreateInfoDataTable );
   441     err = iDatabase.Exec( KThumbnailCreateInfoDataTable );
   422     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoDataTable err=%d", err );
   442     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoDataTable err=%d", err );
       
   443     OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_CREATETABLESL, "CThumbnailStore::CreateTablesL - KThumbnailCreateInfoDataTable;err=%d", err );
   423     User::LeaveIfError( err );
   444     User::LeaveIfError( err );
   424     
   445     
   425     err = iDatabase.Exec(KThumbnailDeletedTable);
   446     err = iDatabase.Exec(KThumbnailDeletedTable);
   426     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailDeletedTable err=%d", err );
   447     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailDeletedTable err=%d", err );
       
   448     OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_CREATETABLESL, "CThumbnailStore::CreateTablesL - KThumbnailDeletedTable;err=%d", err );
   427     User::LeaveIfError( err );
   449     User::LeaveIfError( err );
   428     
   450     
   429     err = iDatabase.Exec( KThumbnailCreateInfoTableIndex1 );
   451     err = iDatabase.Exec( KThumbnailCreateInfoTableIndex1 );
   430     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex1 err=%d", err );
   452     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex1 err=%d", err );
   431     User::LeaveIfError( err );
   453     User::LeaveIfError( err );
   432     
   454     
   433     err = iDatabase.Exec(KThumbnailVersionTable);
   455     err = iDatabase.Exec(KThumbnailVersionTable);
   434     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailVersionTable err=%d", err );
   456     TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailVersionTable err=%d", err );
       
   457     OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_CREATETABLESL, "CThumbnailStore::CreateTablesL;err=%d", err );
   435     User::LeaveIfError( err );
   458     User::LeaveIfError( err );
   436     }
   459     }
   437 
   460 
   438 // ---------------------------------------------------------------------------
   461 // ---------------------------------------------------------------------------
   439 // Create temp tables
   462 // Create temp tables
   440 // ---------------------------------------------------------------------------
   463 // ---------------------------------------------------------------------------
   441 //
   464 //
   442 void CThumbnailStore::CreateTempTablesL()
   465 void CThumbnailStore::CreateTempTablesL()
   443     {
   466     {
   444     TN_DEBUG1( "CThumbnailStore::CreateTempTablesL()" );
   467     TN_DEBUG1( "CThumbnailStore::CreateTempTablesL()" );
       
   468     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_CREATETEMPTABLESL, "CThumbnailStore::CreateTempTablesL" );
   445 
   469 
   446     TInt err = iDatabase.Exec( KThumbnailCreateTempInfoTable );
   470     TInt err = iDatabase.Exec( KThumbnailCreateTempInfoTable );
   447 
   471 
   448 #ifdef _DEBUG
   472 #ifdef _DEBUG
   449     if(err < 0)
   473     if(err < 0)
   450         {
   474         {
   451         TPtrC errorMsg = iDatabase.LastErrorMessage();
   475         TPtrC errorMsg = iDatabase.LastErrorMessage();
   452         TN_DEBUG2( "CThumbnailStore::PrepareDbL() KThumbnailCreateTempInfoTable %S" , &errorMsg);
   476         TN_DEBUG2( "CThumbnailStore::PrepareDbL() KThumbnailCreateTempInfoTable %S" , &errorMsg);
       
   477         OstTraceExt1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_CREATETEMPTABLESL, "CThumbnailStore::CreateTempTablesL - KThumbnailCreateTempInfoTable;errorMsg=%S", errorMsg );
   453         }
   478         }
   454 #endif
   479 #endif
   455     
   480     
   456     User::LeaveIfError( err );
   481     User::LeaveIfError( err );
   457 
   482 
   460 #ifdef _DEBUG
   485 #ifdef _DEBUG
   461     if(err < 0)
   486     if(err < 0)
   462         {
   487         {
   463         TPtrC errorMsg = iDatabase.LastErrorMessage();
   488         TPtrC errorMsg = iDatabase.LastErrorMessage();
   464         TN_DEBUG2( "CThumbnailStore::PrepareDbL() KThumbnailCreateTempInfoDataTable %S" , &errorMsg);
   489         TN_DEBUG2( "CThumbnailStore::PrepareDbL() KThumbnailCreateTempInfoDataTable %S" , &errorMsg);
       
   490         OstTraceExt1( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_CREATETEMPTABLESL, "CThumbnailStore::CreateTempTablesL - KThumbnailCreateTempInfoDataTable;errorMsg=%S", errorMsg );
   465         }
   491         }
   466 #endif
   492 #endif
   467     
   493     
   468     User::LeaveIfError( err );
   494     User::LeaveIfError( err );
   469     }
   495     }
   470 
   496 
   471 void CThumbnailStore::RecreateDatabaseL(const TBool aDelete)
   497 void CThumbnailStore::RecreateDatabaseL(const TBool aDelete)
   472     {
   498     {
   473     TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() drive: %d", iDrive );
   499     TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() drive: %d", iDrive );
       
   500     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL;iDrive=%d", iDrive );
   474     
   501     
   475     TVolumeInfo volumeinfo;
   502     TVolumeInfo volumeinfo;
   476     User::LeaveIfError( iFs.Volume(volumeinfo, iDrive) );
   503     User::LeaveIfError( iFs.Volume(volumeinfo, iDrive) );
   477     TUint id = volumeinfo.iUniqueID;
   504     TUint id = volumeinfo.iUniqueID;
   478     TBuf<50> mediaid;
   505     TBuf<50> mediaid;
   481     CloseStatements();
   508     CloseStatements();
   482     iDatabase.Close();
   509     iDatabase.Close();
   483     iUnrecoverable = ETrue;
   510     iUnrecoverable = ETrue;
   484     
   511     
   485     TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() database closed" );
   512     TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() database closed" );
       
   513     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL - database closed" );
   486     
   514     
   487     HBufC* databasePath = HBufC::NewLC( KMaxFileName );
   515     HBufC* databasePath = HBufC::NewLC( KMaxFileName );
   488     TPtr pathPtr = databasePath->Des();
   516     TPtr pathPtr = databasePath->Des();
   489     User::LeaveIfError( RFs::DriveToChar( iDrive, iDriveChar ));
   517     User::LeaveIfError( RFs::DriveToChar( iDrive, iDriveChar ));
   490     pathPtr.Append( iDriveChar );
   518     pathPtr.Append( iDriveChar );
   494     
   522     
   495     // delete old if necessary
   523     // delete old if necessary
   496     if(aDelete)
   524     if(aDelete)
   497         {
   525         {
   498         TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() delete database" );
   526         TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() delete database" );
       
   527         OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL - delete database" );
   499         TInt del = iDatabase.Delete(pathPtr);     
   528         TInt del = iDatabase.Delete(pathPtr);     
   500         TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() deleted database, err: %d", del );       
   529         TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() deleted database, err: %d", del );       
       
   530         OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL" );
   501         }
   531         }
   502         
   532         
   503     const TDesC8& config = KThumbnailSqlConfig;
   533     const TDesC8& config = KThumbnailSqlConfig;
   504 
   534 
   505     RSqlSecurityPolicy securityPolicy;
   535     RSqlSecurityPolicy securityPolicy;
   506     CleanupClosePushL( securityPolicy );
   536     CleanupClosePushL( securityPolicy );
   507     securityPolicy.CreateL( KThumbnailDatabaseSecurityPolicy );
   537     securityPolicy.CreateL( KThumbnailDatabaseSecurityPolicy );
   508 
   538 
   509     // create new
   539     // create new
   510     TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() create new" );
   540     TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() create new" );
       
   541     OstTrace0( TRACE_FATAL, DUP3_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL - create new" );
   511     TRAP(err, iDatabase.CreateL( pathPtr, securityPolicy, &config ));    
   542     TRAP(err, iDatabase.CreateL( pathPtr, securityPolicy, &config ));    
   512     TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- database created, err = %d", err );
   543     TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- database created, err = %d", err );
       
   544     OstTrace1( TRACE_FATAL, DUP5_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL;err=%d", err );
   513     User::LeaveIfError(err);
   545     User::LeaveIfError(err);
   514     
   546     
   515     CleanupStack::PopAndDestroy( &securityPolicy );
   547     CleanupStack::PopAndDestroy( &securityPolicy );
   516     
   548     
   517     // add tables
   549     // add tables
   518     TRAPD(prepareErr, PrepareDbL() );
   550     TRAPD(prepareErr, PrepareDbL() );
   519     
   551     
   520     TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- prepare tables, err = %d", prepareErr );
   552     TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- prepare tables, err = %d", prepareErr );
       
   553     OstTrace1( TRACE_FATAL, DUP6_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL - prepare tables;prepareErr=%d", prepareErr );
   521     
   554     
   522     TInt mediaidErr(KErrNone);
   555     TInt mediaidErr(KErrNone);
   523     
   556     
   524     // write media id file if doesn't exist
   557     // write media id file if doesn't exist
   525     if(!BaflUtils::FileExists( iFs, mediaid ))
   558     if(!BaflUtils::FileExists( iFs, mediaid ))
   527         RFile64 file;
   560         RFile64 file;
   528         mediaidErr = file.Create(iFs, mediaid, EFileShareReadersOrWriters );
   561         mediaidErr = file.Create(iFs, mediaid, EFileShareReadersOrWriters );
   529         file.Close();
   562         file.Close();
   530         
   563         
   531         TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- mediaID file created, err = %d", mediaidErr );
   564         TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- mediaID file created, err = %d", mediaidErr );
       
   565         OstTrace1( TRACE_FATAL, DUP7_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL;mediaidErr=%d", mediaidErr );
   532         }
   566         }
   533     
   567     
   534     // delete db if not fully complete
   568     // delete db if not fully complete
   535     if (prepareErr < 0 || mediaidErr < 0)
   569     if (prepareErr < 0 || mediaidErr < 0)
   536         {
   570         {
   537         CloseStatements();
   571         CloseStatements();
   538         iDatabase.Close();
   572         iDatabase.Close();
   539         TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() delete database" );
   573         TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() delete database" );
       
   574         OstTrace0( TRACE_FATAL, DUP8_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL - delete database" );
   540         TInt del = iDatabase.Delete(pathPtr);     
   575         TInt del = iDatabase.Delete(pathPtr);     
   541         TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() deleted database, err: %d", del );
   576         TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() deleted database, err: %d", del );
       
   577         OstTrace1( TRACE_FATAL, DUP9_CTHUMBNAILSTORE_RECREATEDATABASEL, "CThumbnailStore::RecreateDatabaseL - delete database;del=%d", del );
   542         }
   578         }
   543     
   579     
   544     User::LeaveIfError( prepareErr );
   580     User::LeaveIfError( prepareErr );
   545     User::LeaveIfError( mediaidErr );
   581     User::LeaveIfError( mediaidErr );
   546     
   582     
   548     }
   584     }
   549 
   585 
   550 TInt CThumbnailStore::CheckRowIDs()
   586 TInt CThumbnailStore::CheckRowIDs()
   551     {
   587     {
   552     TN_DEBUG1( "CThumbnailStore::CheckRowIDs()");
   588     TN_DEBUG1( "CThumbnailStore::CheckRowIDs()");
       
   589     OstTrace0( TRACE_FATAL, CTHUMBNAILSTORE_CHECKROWIDS, "CThumbnailStore::CheckRowIDs" );
   553     
   590     
   554     RSqlStatement stmt;
   591     RSqlStatement stmt;
   555     TInt column = 0;   
   592     TInt column = 0;   
   556     TInt rowStatus = 0;
   593     TInt rowStatus = 0;
   557     TInt64 inforows = -1;
   594     TInt64 inforows = -1;
   560     TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID );
   597     TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID );
   561     if(ret < 0)
   598     if(ret < 0)
   562         {
   599         {
   563         stmt.Close();
   600         stmt.Close();
   564         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoRowID failed %d");
   601         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetInfoRowID failed %d");
       
   602         OstTrace1( TRACE_FATAL, DUP1_CTHUMBNAILSTORE_CHECKROWIDS, "CThumbnailStore::CheckRowIDs KGetInfoRowID failed;ret=%d", ret );
   565         return KErrNotSupported;
   603         return KErrNotSupported;
   566         }
   604         }
   567     rowStatus = stmt.Next();
   605     rowStatus = stmt.Next();
   568                 
   606                 
   569     if ( rowStatus == KSqlAtRow)    
   607     if ( rowStatus == KSqlAtRow)    
   576     if(rowStatus < 0)
   614     if(rowStatus < 0)
   577         {
   615         {
   578 #ifdef _DEBUG
   616 #ifdef _DEBUG
   579         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   617         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   580         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   618         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
       
   619         OstTraceExt1( TRACE_FATAL, DUP2_CTHUMBNAILSTORE_CHECKROWIDS, "CThumbnailStore::CheckRowIDs - lastError;errorMsg2=%S", errorMsg2 );
   581 #endif
   620 #endif
   582         return KErrNotSupported;
   621         return KErrNotSupported;
   583         }
   622         }
   584               
   623               
   585     ret = stmt.Prepare( iDatabase, KGetDataRowID );
   624     ret = stmt.Prepare( iDatabase, KGetDataRowID );
   586     if(ret < 0)
   625     if(ret < 0)
   587         {
   626         {
   588         stmt.Close();
   627         stmt.Close();
   589         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetDataRowID failed");
   628         TN_DEBUG1( "CThumbnailStore::CheckRowIDs() KGetDataRowID failed");
       
   629         OstTrace0( TRACE_FATAL, DUP3_CTHUMBNAILSTORE_CHECKROWIDS, "CThumbnailStore::CheckRowIDs - KGetDataRowID failed" );
   590         return KErrNotSupported;
   630         return KErrNotSupported;
   591         }
   631         }
   592     rowStatus = stmt.Next();
   632     rowStatus = stmt.Next();
   593                        
   633                        
   594     if ( rowStatus == KSqlAtRow)    
   634     if ( rowStatus == KSqlAtRow)    
   601     if( rowStatus < 0)
   641     if( rowStatus < 0)
   602         {
   642         {
   603 #ifdef _DEBUG
   643 #ifdef _DEBUG
   604         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   644         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
   605         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
   645         TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2);
       
   646         OstTraceExt1( TRACE_FATAL, DUP4_CTHUMBNAILSTORE_CHECKROWIDS, "CThumbnailStore::CheckRowIDs - lastError;errorMsg2=%S", errorMsg2 );
   606 #endif
   647 #endif
   607         return KErrNotSupported;
   648         return KErrNotSupported;
   608         }
   649         }
   609     
   650     
   610     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - inforows %Ld", inforows );
   651     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - inforows %Ld", inforows );
       
   652     OstTraceExt1( TRACE_FATAL, DUP5_CTHUMBNAILSTORE_CHECKROWIDS, "CThumbnailStore::CheckRowIDs;inforows=%g", inforows );
   611     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datarows %Ld", datarows );
   653     TN_DEBUG2( "CThumbnailStore::CheckRowIDsL() - datarows %Ld", datarows );
       
   654     OstTraceExt1( TRACE_FATAL, DUP6_CTHUMBNAILSTORE_CHECKROWIDS, "CThumbnailStore::CheckRowIDs;datarows=%Ld", datarows );
   612             
   655             
   613     if( inforows != datarows )
   656     if( inforows != datarows )
   614         {
   657         {
   615         TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" );
   658         TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" );
   616         return KErrNotSupported;
   659         return KErrNotSupported;
   626 // -----------------------------------------------------------------------------
   669 // -----------------------------------------------------------------------------
   627 //
   670 //
   628 TInt CThumbnailStore::CheckVersion()
   671 TInt CThumbnailStore::CheckVersion()
   629     {
   672     {
   630     TN_DEBUG1( "CThumbnailStore::CheckVersion()" );
   673     TN_DEBUG1( "CThumbnailStore::CheckVersion()" );
       
   674     OstTrace0( TRACE_FATAL, CTHUMBNAILSTORE_CHECKVERSION, "CThumbnailStore::CheckVersion" );
   631     RSqlStatement stmt;
   675     RSqlStatement stmt;
   632          
   676          
   633     TInt rowStatus = 0;
   677     TInt rowStatus = 0;
   634     TInt column = 0;
   678     TInt column = 0;
   635     TInt minor = 0;
   679     TInt minor = 0;
   638     TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion );
   682     TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion );
   639     if(ret < 0 )
   683     if(ret < 0 )
   640        {  
   684        {  
   641        stmt.Close();
   685        stmt.Close();
   642        TN_DEBUG1( "CThumbnailStore::CheckVersion() unknown version" );
   686        TN_DEBUG1( "CThumbnailStore::CheckVersion() unknown version" );
       
   687        OstTrace0( TRACE_FATAL, DUP1_CTHUMBNAILSTORE_CHECKVERSION, "CThumbnailStore::CheckVersion - unknown version" );
   643        return KErrNotSupported;
   688        return KErrNotSupported;
   644        }
   689        }
   645               
   690               
   646     rowStatus = stmt.Next();
   691     rowStatus = stmt.Next();
   647     
   692     
   656     if( rowStatus < 0 )
   701     if( rowStatus < 0 )
   657         {
   702         {
   658 #ifdef _DEBUG
   703 #ifdef _DEBUG
   659          TPtrC errorMsg = iDatabase.LastErrorMessage();
   704          TPtrC errorMsg = iDatabase.LastErrorMessage();
   660         TN_DEBUG2( "RThumbnailTransaction::CheckVersion() lastError %S, ret = %d" , &errorMsg);
   705         TN_DEBUG2( "RThumbnailTransaction::CheckVersion() lastError %S, ret = %d" , &errorMsg);
       
   706         OstTrace0( TRACE_FATAL, DUP2_CTHUMBNAILSTORE_CHECKVERSION, "CThumbnailStore::CheckVersion" );
   661 #endif
   707 #endif
   662         return ret;
   708         return ret;
   663         }
   709         }
   664     
   710     
   665     if(major == KMajor && minor == KMinor )
   711     if(major == KMajor && minor == KMinor )
   667       return KErrNone;  
   713       return KErrNone;  
   668       }
   714       }
   669     else
   715     else
   670       {
   716       {
   671       TN_DEBUG1( "CThumbnailStore::CheckVersion() - wrong DB version" );
   717       TN_DEBUG1( "CThumbnailStore::CheckVersion() - wrong DB version" );
       
   718       OstTrace0( TRACE_FATAL, DUP3_CTHUMBNAILSTORE_CHECKVERSION, "CThumbnailStore::CheckVersion" );
   672       return KErrNotSupported;  
   719       return KErrNotSupported;  
   673       }
   720       }
   674     }
   721     }
   675 
   722 
   676 // -----------------------------------------------------------------------------
   723 // -----------------------------------------------------------------------------
   678 // -----------------------------------------------------------------------------
   725 // -----------------------------------------------------------------------------
   679 //
   726 //
   680 TInt CThumbnailStore::CheckImei()
   727 TInt CThumbnailStore::CheckImei()
   681     {
   728     {
   682     TN_DEBUG1( "CThumbnailStore::CheckImei()" );
   729     TN_DEBUG1( "CThumbnailStore::CheckImei()" );
       
   730     OstTrace0( TRACE_FATAL, CTHUMBNAILSTORE_CHECKIMEI, "CThumbnailStore::CheckImei" );
   683     RSqlStatement stmt;
   731     RSqlStatement stmt;
   684          
   732          
   685     TInt rowStatus = 0;
   733     TInt rowStatus = 0;
   686     TInt column = 0;
   734     TInt column = 0;
   687     TBuf<KImeiBufferSize> imei;
   735     TBuf<KImeiBufferSize> imei;
   689     TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion );
   737     TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion );
   690     if(ret < 0 )
   738     if(ret < 0 )
   691        {  
   739        {  
   692         stmt.Close();
   740         stmt.Close();
   693        TN_DEBUG1( "CThumbnailStore::CheckImei() failed" );
   741        TN_DEBUG1( "CThumbnailStore::CheckImei() failed" );
       
   742        OstTrace0( TRACE_FATAL, DUP1_CTHUMBNAILSTORE_CHECKIMEI, "CThumbnailStore::CheckImei - failed" );
   694        return KErrNotSupported;
   743        return KErrNotSupported;
   695        }
   744        }
   696               
   745               
   697     rowStatus = stmt.Next();
   746     rowStatus = stmt.Next();
   698     
   747     
   707     if( rowStatus < 0 )
   756     if( rowStatus < 0 )
   708         {
   757         {
   709 #ifdef _DEBUG
   758 #ifdef _DEBUG
   710          TPtrC errorMsg = iDatabase.LastErrorMessage();
   759          TPtrC errorMsg = iDatabase.LastErrorMessage();
   711         TN_DEBUG2( "RThumbnailTransaction::CheckImei() lastError %S, ret = %d" , &errorMsg);
   760         TN_DEBUG2( "RThumbnailTransaction::CheckImei() lastError %S, ret = %d" , &errorMsg);
       
   761         OstTraceExt1( TRACE_FATAL, DUP2_CTHUMBNAILSTORE_CHECKIMEI, "CThumbnailStore::CheckImei - lastError;errorMsg=%S", errorMsg );
   712 #endif
   762 #endif
   713         return ret;
   763         return ret;
   714         }
   764         }
   715     
   765     
   716     if( imei == iImei )
   766     if( imei == iImei )
   718       return KErrNone;  
   768       return KErrNone;  
   719       }
   769       }
   720     else
   770     else
   721       {
   771       {
   722       TN_DEBUG1( "CThumbnailStore::CheckImei() mismatch" );
   772       TN_DEBUG1( "CThumbnailStore::CheckImei() mismatch" );
       
   773       OstTrace0( TRACE_FATAL, DUP3_CTHUMBNAILSTORE_CHECKIMEI, "CThumbnailStore::CheckImei - mismatch" );
   723       return KErrNotSupported;  
   774       return KErrNotSupported;  
   724       }
   775       }
   725     }
   776     }
   726 
   777 
   727 // -----------------------------------------------------------------------------
   778 // -----------------------------------------------------------------------------
   729 // -----------------------------------------------------------------------------
   780 // -----------------------------------------------------------------------------
   730 //
   781 //
   731 TInt CThumbnailStore::CheckMediaIDL()
   782 TInt CThumbnailStore::CheckMediaIDL()
   732     {
   783     {
   733     TN_DEBUG1( "CThumbnailStore::CheckMediaIDL()" );
   784     TN_DEBUG1( "CThumbnailStore::CheckMediaIDL()" );
       
   785     OstTrace0( TRACE_FATAL, CTHUMBNAILSTORE_CHECKMEDIAIDL, "CThumbnailStore::CheckMediaIDL" );
   734     
   786     
   735     TVolumeInfo volumeinfo;
   787     TVolumeInfo volumeinfo;
   736     User::LeaveIfError( iFs.Volume(volumeinfo, iDrive) );
   788     User::LeaveIfError( iFs.Volume(volumeinfo, iDrive) );
   737     TUint id = volumeinfo.iUniqueID;
   789     TUint id = volumeinfo.iUniqueID;
   738     TBuf<50> mediaid;
   790     TBuf<50> mediaid;
   742        {
   794        {
   743        RFile64 file;
   795        RFile64 file;
   744        TInt err = file.Create(iFs, mediaid, EFileShareReadersOrWriters );
   796        TInt err = file.Create(iFs, mediaid, EFileShareReadersOrWriters );
   745        file.Close();
   797        file.Close();
   746        TN_DEBUG2( "CThumbnailStore::CheckMediaIDL() -- mediaID file created, err = %d", err );
   798        TN_DEBUG2( "CThumbnailStore::CheckMediaIDL() -- mediaID file created, err = %d", err );
       
   799        OstTrace1( TRACE_FATAL, DUP1_CTHUMBNAILSTORE_CHECKMEDIAIDL, "CThumbnailStore::CheckMediaIDL - mediaID file created;err=%d", err );
   747        
   800        
   748        return KErrNotSupported;
   801        return KErrNotSupported;
   749        } 
   802        } 
   750 
   803 
   751     return KErrNone;  
   804     return KErrNone;  
   756 // -----------------------------------------------------------------------------
   809 // -----------------------------------------------------------------------------
   757 //
   810 //
   758 void CThumbnailStore::AddVersionAndImeiL()
   811 void CThumbnailStore::AddVersionAndImeiL()
   759     {
   812     {
   760     TN_DEBUG1( "CThumbnailStore::AddVersionAndImei()" );
   813     TN_DEBUG1( "CThumbnailStore::AddVersionAndImei()" );
       
   814     OstTrace0( TRACE_FATAL, CTHUMBNAILSTORE_ADDVERSIONANDIMEIL, "CThumbnailStore::AddVersionAndImeiL" );
   761     RSqlStatement stmt;
   815     RSqlStatement stmt;
   762     CleanupClosePushL( stmt );
   816     CleanupClosePushL( stmt );
   763             
   817             
   764     TInt paramIndex = 0;
   818     TInt paramIndex = 0;
   765             
   819             
   785 // -----------------------------------------------------------------------------
   839 // -----------------------------------------------------------------------------
   786 //
   840 //
   787 void CThumbnailStore::UpdateImeiL()
   841 void CThumbnailStore::UpdateImeiL()
   788     {
   842     {
   789     TN_DEBUG1( "CThumbnailStore::UpdateImeiL()" );
   843     TN_DEBUG1( "CThumbnailStore::UpdateImeiL()" );
       
   844     OstTrace0( TRACE_FATAL, CTHUMBNAILSTORE_UPDATEIMEIL, "CThumbnailStore::UpdateImeiL" );
   790     RSqlStatement stmt;
   845     RSqlStatement stmt;
   791     CleanupClosePushL( stmt );
   846     CleanupClosePushL( stmt );
   792             
   847             
   793     User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailUpdateIMEI ) );
   848     User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailUpdateIMEI ) );
   794     
   849     
   801     if(err < 0)
   856     if(err < 0)
   802         {
   857         {
   803 #ifdef _DEBUG
   858 #ifdef _DEBUG
   804         TPtrC errorMsg = iDatabase.LastErrorMessage();
   859         TPtrC errorMsg = iDatabase.LastErrorMessage();
   805         TN_DEBUG2( "RThumbnailTransaction::UpdateImeiL() lastError %S" , &errorMsg);
   860         TN_DEBUG2( "RThumbnailTransaction::UpdateImeiL() lastError %S" , &errorMsg);
       
   861         OstTraceExt1( TRACE_FATAL, DUP1_CTHUMBNAILSTORE_UPDATEIMEIL, "CThumbnailStore::UpdateImeiL - lastError;errorMsg=%S", errorMsg );
   806 #endif
   862 #endif
   807         User::Leave(err);
   863         User::Leave(err);
   808         }
   864         }
   809     
   865     
   810     CleanupStack::PopAndDestroy( &stmt );
   866     CleanupStack::PopAndDestroy( &stmt );
   815 // ---------------------------------------------------------------------------
   871 // ---------------------------------------------------------------------------
   816 //
   872 //
   817 void CThumbnailStore::PrepareStatementsL()
   873 void CThumbnailStore::PrepareStatementsL()
   818     {
   874     {
   819     TN_DEBUG1("CThumbnailStore::PrepareStatementsL()");
   875     TN_DEBUG1("CThumbnailStore::PrepareStatementsL()");
       
   876     OstTrace0( TRACE_FATAL, CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL" );
   820     
   877     
   821     TInt err = KErrNone;  
   878     TInt err = KErrNone;  
   822 #ifdef _DEBUG
   879 #ifdef _DEBUG
   823     TFileName msg;
   880     TFileName msg;
   824 #endif
   881 #endif
   825     
   882     
   826     err = iStmt_KThumbnailSelectInfoByPath.Prepare( iDatabase, KThumbnailSelectInfoByPath );
   883     err = iStmt_KThumbnailSelectInfoByPath.Prepare( iDatabase, KThumbnailSelectInfoByPath );
   827 #ifdef _DEBUG
   884 #ifdef _DEBUG
   828     msg.Append( iDatabase.LastErrorMessage() );
   885     msg.Append( iDatabase.LastErrorMessage() );
   829     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectInfoByPath %S" , &msg );
   886     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectInfoByPath %S" , &msg );
       
   887     OstTraceExt1( TRACE_FATAL, DUP1_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSelectInfoByPath;msg=%S", msg );
   830     msg.Zero();
   888     msg.Zero();
   831 #endif
   889 #endif
   832     User::LeaveIfError( err );
   890     User::LeaveIfError( err );
   833     
   891     
   834     err = iStmt_KThumbnailSelectTempInfoByPath.Prepare( iDatabase, KThumbnailSelectTempInfoByPath );
   892     err = iStmt_KThumbnailSelectTempInfoByPath.Prepare( iDatabase, KThumbnailSelectTempInfoByPath );
   835 #ifdef _DEBUG
   893 #ifdef _DEBUG
   836     msg.Append( iDatabase.LastErrorMessage() );
   894     msg.Append( iDatabase.LastErrorMessage() );
   837     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempInfoByPath %S" , &msg );
   895     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempInfoByPath %S" , &msg );
       
   896     OstTraceExt1( TRACE_FATAL, DUP2_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSelectTempInfoByPath;msg=%S", msg );
   838     msg.Zero();
   897     msg.Zero();
   839 #endif
   898 #endif
   840     User::LeaveIfError( err );
   899     User::LeaveIfError( err );
   841 
   900 
   842     err = iStmt_KThumbnailInsertTempThumbnailInfo.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfo );
   901     err = iStmt_KThumbnailInsertTempThumbnailInfo.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfo );
   843 #ifdef _DEBUG
   902 #ifdef _DEBUG
   844     msg.Append( iDatabase.LastErrorMessage() );
   903     msg.Append( iDatabase.LastErrorMessage() );
   845     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailInsertTempThumbnailInfo %S" , &msg );
   904     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailInsertTempThumbnailInfo %S" , &msg );
       
   905     OstTraceExt1( TRACE_FATAL, DUP3_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailInsertTempThumbnailInfo ;msg=%S", msg );
   846     msg.Zero();
   906     msg.Zero();
   847 #endif
   907 #endif
   848     User::LeaveIfError( err );
   908     User::LeaveIfError( err );
   849     
   909     
   850     err = iStmt_KThumbnailInsertTempThumbnailInfoData.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfoData );
   910     err = iStmt_KThumbnailInsertTempThumbnailInfoData.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfoData );
   851 #ifdef _DEBUG
   911 #ifdef _DEBUG
   852     msg.Append( iDatabase.LastErrorMessage() );
   912     msg.Append( iDatabase.LastErrorMessage() );
   853     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailInsertTempThumbnailInfoData %S" , &msg );
   913     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailInsertTempThumbnailInfoData %S" , &msg );
       
   914     OstTraceExt1( TRACE_FATAL, DUP4_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailInsertTempThumbnailInfoData;msg=%S", msg );
   854     msg.Zero();
   915     msg.Zero();
   855 #endif
   916 #endif
   856     User::LeaveIfError( err );
   917     User::LeaveIfError( err );
   857     
   918     
   858     err = iStmt_KThumbnailSelectModifiedByPath.Prepare( iDatabase, KThumbnailSelectModifiedByPath );
   919     err = iStmt_KThumbnailSelectModifiedByPath.Prepare( iDatabase, KThumbnailSelectModifiedByPath );
   859 #ifdef _DEBUG
   920 #ifdef _DEBUG
   860     msg.Append( iDatabase.LastErrorMessage() );
   921     msg.Append( iDatabase.LastErrorMessage() );
   861     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectModifiedByPath %S" , &msg );
   922     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectModifiedByPath %S" , &msg );
       
   923     OstTraceExt1( TRACE_FATAL, DUP5_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL;msg=%S", msg );
   862     msg.Zero();
   924     msg.Zero();
   863 #endif
   925 #endif
   864     User::LeaveIfError( err );
   926     User::LeaveIfError( err );
   865     
   927     
   866     err = iStmt_KThumbnailSelectTempModifiedByPath.Prepare( iDatabase, KThumbnailSelectTempModifiedByPath );
   928     err = iStmt_KThumbnailSelectTempModifiedByPath.Prepare( iDatabase, KThumbnailSelectTempModifiedByPath );
   867 #ifdef _DEBUG
   929 #ifdef _DEBUG
   868     msg.Append( iDatabase.LastErrorMessage() );
   930     msg.Append( iDatabase.LastErrorMessage() );
   869     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempModifiedByPath %S" , &msg );
   931     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempModifiedByPath %S" , &msg );
       
   932     OstTraceExt1( TRACE_FATAL, DUP6_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSelectTempModifiedByPath;msg=%S", msg );
   870     msg.Zero();
   933     msg.Zero();
   871 #endif
   934 #endif
   872     User::LeaveIfError( err );
   935     User::LeaveIfError( err );
   873     
   936     
   874     err = iStmt_KThumbnailFindDuplicate.Prepare( iDatabase, KThumbnailFindDuplicate );
   937     err = iStmt_KThumbnailFindDuplicate.Prepare( iDatabase, KThumbnailFindDuplicate );
   875 #ifdef _DEBUG
   938 #ifdef _DEBUG
   876     msg.Append( iDatabase.LastErrorMessage() );
   939     msg.Append( iDatabase.LastErrorMessage() );
   877     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailFindDuplicate %S" , &msg );
   940     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailFindDuplicate %S" , &msg );
       
   941     OstTraceExt1( TRACE_FATAL, DUP7_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailFindDuplicate;msg=%S", msg );
   878     msg.Zero();
   942     msg.Zero();
   879 #endif
   943 #endif
   880     User::LeaveIfError( err );
   944     User::LeaveIfError( err );
   881     
   945     
   882     err = iStmt_KThumbnailTempFindDuplicate.Prepare( iDatabase, KThumbnailTempFindDuplicate );
   946     err = iStmt_KThumbnailTempFindDuplicate.Prepare( iDatabase, KThumbnailTempFindDuplicate );
   883 #ifdef _DEBUG
   947 #ifdef _DEBUG
   884     msg.Append( iDatabase.LastErrorMessage() );
   948     msg.Append( iDatabase.LastErrorMessage() );
   885     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailTempFindDuplicate %S" , &msg );
   949     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailTempFindDuplicate %S" , &msg );
       
   950     OstTraceExt1( TRACE_FATAL, DUP8_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailTempFindDuplicate;msg=%S", msg );
   886     msg.Zero();
   951     msg.Zero();
   887 #endif
   952 #endif
   888     User::LeaveIfError( err );
   953     User::LeaveIfError( err );
   889     
   954     
   890     err = iStmt_KThumbnailSqlFindDeleted.Prepare( iDatabase, KThumbnailSqlFindDeleted );
   955     err = iStmt_KThumbnailSqlFindDeleted.Prepare( iDatabase, KThumbnailSqlFindDeleted );
   891 #ifdef _DEBUG
   956 #ifdef _DEBUG
   892     msg.Append( iDatabase.LastErrorMessage() );
   957     msg.Append( iDatabase.LastErrorMessage() );
   893     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlFindDeleted %S" , &msg );
   958     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlFindDeleted %S" , &msg );
       
   959     OstTraceExt1( TRACE_FATAL, DUP9_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSqlFindDeleted;msg=%S", msg );
   894     msg.Zero();
   960     msg.Zero();
   895 #endif
   961 #endif
   896     User::LeaveIfError( err );
   962     User::LeaveIfError( err );
   897     
   963     
   898     err = iStmt_KThumbnailSelectSizeByPath.Prepare( iDatabase, KThumbnailSelectSizeByPath );
   964     err = iStmt_KThumbnailSelectSizeByPath.Prepare( iDatabase, KThumbnailSelectSizeByPath );
   899 #ifdef _DEBUG
   965 #ifdef _DEBUG
   900     msg.Append( iDatabase.LastErrorMessage() );
   966     msg.Append( iDatabase.LastErrorMessage() );
   901     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectSizeByPath %S" , &msg );
   967     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectSizeByPath %S" , &msg );
       
   968     OstTraceExt1( TRACE_FATAL, DUP10_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSelectSizeByPath;msg=%S", msg );
   902     msg.Zero();
   969     msg.Zero();
   903 #endif
   970 #endif
   904     User::LeaveIfError( err );
   971     User::LeaveIfError( err );
   905     
   972     
   906     err = iStmt_KThumbnailSelectTempSizeByPath.Prepare( iDatabase, KThumbnailSelectTempSizeByPath );
   973     err = iStmt_KThumbnailSelectTempSizeByPath.Prepare( iDatabase, KThumbnailSelectTempSizeByPath );
   907 #ifdef _DEBUG
   974 #ifdef _DEBUG
   908     msg.Append( iDatabase.LastErrorMessage() );
   975     msg.Append( iDatabase.LastErrorMessage() );
   909     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempSizeByPath %S" , &msg );
   976     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempSizeByPath %S" , &msg );
       
   977     OstTraceExt1( TRACE_FATAL, DUP11_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSelectTempSizeByPath;msg=%S", msg );
   910     msg.Zero();
   978     msg.Zero();
   911 #endif
   979 #endif
   912     User::LeaveIfError( err );
   980     User::LeaveIfError( err );
   913     
   981     
   914     err = iStmt_KThumbnailSqlSelectRowIDInfoByPath.Prepare( iDatabase, KThumbnailSqlSelectRowIDInfoByPath );
   982     err = iStmt_KThumbnailSqlSelectRowIDInfoByPath.Prepare( iDatabase, KThumbnailSqlSelectRowIDInfoByPath );
   915 #ifdef _DEBUG
   983 #ifdef _DEBUG
   916     msg.Append( iDatabase.LastErrorMessage() );
   984     msg.Append( iDatabase.LastErrorMessage() );
   917     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlSelectRowIDInfoByPath %S" , &msg );
   985     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlSelectRowIDInfoByPath %S" , &msg );
       
   986     OstTraceExt1( TRACE_FATAL, DUP12_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSqlSelectRowIDInfoByPath;msg=%S", msg );
   918     msg.Zero();
   987     msg.Zero();
   919 #endif
   988 #endif
   920     User::LeaveIfError( err );
   989     User::LeaveIfError( err );
   921     
   990     
   922     err = iStmt_KThumbnailSqlDeleteInfoByPath.Prepare( iDatabase, KThumbnailSqlDeleteInfoByPath );
   991     err = iStmt_KThumbnailSqlDeleteInfoByPath.Prepare( iDatabase, KThumbnailSqlDeleteInfoByPath );
   923 #ifdef _DEBUG
   992 #ifdef _DEBUG
   924     msg.Append( iDatabase.LastErrorMessage() );
   993     msg.Append( iDatabase.LastErrorMessage() );
   925     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoByPath %S" , &msg );
   994     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoByPath %S" , &msg );
       
   995     OstTraceExt1( TRACE_FATAL, DUP13_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSqlDeleteInfoByPath;msg=%S", msg );
   926     msg.Zero();
   996     msg.Zero();
   927 #endif
   997 #endif
   928     User::LeaveIfError( err );
   998     User::LeaveIfError( err );
   929 
   999 
   930     err = iStmt_KThumbnailSqlDeleteInfoDataByPath.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByPath );
  1000     err = iStmt_KThumbnailSqlDeleteInfoDataByPath.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByPath );
   931 #ifdef _DEBUG
  1001 #ifdef _DEBUG
   932     msg.Append( iDatabase.LastErrorMessage() );
  1002     msg.Append( iDatabase.LastErrorMessage() );
   933     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoDataByPath %S" , &msg );
  1003     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoDataByPath %S" , &msg );
       
  1004     OstTraceExt1( TRACE_FATAL, DUP14_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSqlDeleteInfoDataByPath;msg=%S", msg );
   934     msg.Zero();
  1005     msg.Zero();
   935 #endif
  1006 #endif
   936     User::LeaveIfError( err );
  1007     User::LeaveIfError( err );
   937 
  1008 
   938     err = iStmt_KTempThumbnailSqlSelectRowIDInfoByPath.Prepare( iDatabase, KTempThumbnailSqlSelectRowIDInfoByPath );
  1009     err = iStmt_KTempThumbnailSqlSelectRowIDInfoByPath.Prepare( iDatabase, KTempThumbnailSqlSelectRowIDInfoByPath );
   939 #ifdef _DEBUG
  1010 #ifdef _DEBUG
   940     msg.Append( iDatabase.LastErrorMessage() );
  1011     msg.Append( iDatabase.LastErrorMessage() );
   941     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlSelectRowIDInfoByPath %S" , &msg );
  1012     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlSelectRowIDInfoByPath %S" , &msg );
       
  1013     OstTraceExt1( TRACE_FATAL, DUP15_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KTempThumbnailSqlSelectRowIDInfoByPath;msg=%S", msg );
   942     msg.Zero();
  1014     msg.Zero();
   943 #endif
  1015 #endif
   944     User::LeaveIfError( err );
  1016     User::LeaveIfError( err );
   945 
  1017 
   946     err = iStmt_KTempThumbnailSqlDeleteInfoByPath.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoByPath );
  1018     err = iStmt_KTempThumbnailSqlDeleteInfoByPath.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoByPath );
   947 #ifdef _DEBUG
  1019 #ifdef _DEBUG
   948     msg.Append( iDatabase.LastErrorMessage() );
  1020     msg.Append( iDatabase.LastErrorMessage() );
   949     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlDeleteInfoByPath %S" , &msg );
  1021     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlDeleteInfoByPath %S" , &msg );
       
  1022     OstTraceExt1( TRACE_FATAL, DUP16_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KTempThumbnailSqlDeleteInfoByPath;msg=%S", msg );
   950     msg.Zero();
  1023     msg.Zero();
   951 #endif
  1024 #endif
   952     User::LeaveIfError( err );
  1025     User::LeaveIfError( err );
   953 
  1026 
   954     err = iStmt_KTempThumbnailSqlDeleteInfoDataByPath.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoDataByPath );
  1027     err = iStmt_KTempThumbnailSqlDeleteInfoDataByPath.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoDataByPath );
   955 #ifdef _DEBUG
  1028 #ifdef _DEBUG
   956     msg.Append( iDatabase.LastErrorMessage() );
  1029     msg.Append( iDatabase.LastErrorMessage() );
   957     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlDeleteInfoDataByPath %S" , &msg );
  1030     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlDeleteInfoDataByPath %S" , &msg );
       
  1031     OstTraceExt1( TRACE_FATAL, DUP17_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KTempThumbnailSqlDeleteInfoDataByPath;msg=%S", msg );
   958     msg.Zero();
  1032     msg.Zero();
   959 #endif
  1033 #endif
   960     User::LeaveIfError( err );
  1034     User::LeaveIfError( err );
   961 
  1035 
   962     err = iStmt_KThumbnailSqlInsertDeleted.Prepare( iDatabase, KThumbnailSqlInsertDeleted );
  1036     err = iStmt_KThumbnailSqlInsertDeleted.Prepare( iDatabase, KThumbnailSqlInsertDeleted );
   963 #ifdef _DEBUG
  1037 #ifdef _DEBUG
   964     msg.Append( iDatabase.LastErrorMessage() );
  1038     msg.Append( iDatabase.LastErrorMessage() );
   965     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlInsertDeleted %S" , &msg );
  1039     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlInsertDeleted %S" , &msg );
       
  1040     OstTraceExt1( TRACE_FATAL, DUP18_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSqlInsertDeleted;msg=%S", msg );
   966     msg.Zero();
  1041     msg.Zero();
   967 #endif
  1042 #endif
   968     User::LeaveIfError( err );
  1043     User::LeaveIfError( err );
   969     
  1044     
   970     err = iStmt_KThumbnailSqlSelectMarked.Prepare( iDatabase, KThumbnailSqlSelectMarked );
  1045     err = iStmt_KThumbnailSqlSelectMarked.Prepare( iDatabase, KThumbnailSqlSelectMarked );
   971 #ifdef _DEBUG
  1046 #ifdef _DEBUG
   972     msg.Append( iDatabase.LastErrorMessage() );
  1047     msg.Append( iDatabase.LastErrorMessage() );
   973     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlSelectMarked %S" , &msg );
  1048     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlSelectMarked %S" , &msg );
       
  1049     OstTraceExt1( TRACE_NORMAL, DUP19_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSqlSelectMarked;msg=%S", msg );
   974     msg.Zero();
  1050     msg.Zero();
   975 #endif
  1051 #endif
   976     User::LeaveIfError( err );
  1052     User::LeaveIfError( err );
   977 
  1053 
   978     err = iStmt_KThumbnailSqlDeleteInfoByRowID.Prepare( iDatabase, KThumbnailSqlDeleteInfoByRowID );
  1054     err = iStmt_KThumbnailSqlDeleteInfoByRowID.Prepare( iDatabase, KThumbnailSqlDeleteInfoByRowID );
   979 #ifdef _DEBUG
  1055 #ifdef _DEBUG
   980     msg.Append( iDatabase.LastErrorMessage() );
  1056     msg.Append( iDatabase.LastErrorMessage() );
   981     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoByRowID %S" , &msg );
  1057     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoByRowID %S" , &msg );
       
  1058     OstTraceExt1( TRACE_NORMAL, DUP20_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSqlDeleteInfoByRowID;msg=%S", msg );
   982     msg.Zero();
  1059     msg.Zero();
   983 #endif
  1060 #endif
   984     User::LeaveIfError( err );
  1061     User::LeaveIfError( err );
   985 
  1062 
   986     err = iStmt_KThumbnailSqlDeleteInfoDataByRowID.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByRowID );
  1063     err = iStmt_KThumbnailSqlDeleteInfoDataByRowID.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByRowID );
   987 #ifdef _DEBUG
  1064 #ifdef _DEBUG
   988     msg.Append( iDatabase.LastErrorMessage() );
  1065     msg.Append( iDatabase.LastErrorMessage() );
   989     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoDataByRowID %S" , &msg );
  1066     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoDataByRowID %S" , &msg );
       
  1067     OstTraceExt1( TRACE_NORMAL, DUP21_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSqlDeleteInfoDataByRowID;msg=%S", msg );
   990     msg.Zero();
  1068     msg.Zero();
   991 #endif
  1069 #endif
   992     User::LeaveIfError( err );
  1070     User::LeaveIfError( err );
   993     
  1071     
   994     err = iStmt_KThumbnailSelectAllPaths.Prepare( iDatabase, KThumbnailSelectAllPaths );
  1072     err = iStmt_KThumbnailSelectAllPaths.Prepare( iDatabase, KThumbnailSelectAllPaths );
   995 #ifdef _DEBUG
  1073 #ifdef _DEBUG
   996     msg.Append( iDatabase.LastErrorMessage() );
  1074     msg.Append( iDatabase.LastErrorMessage() );
   997     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectAllPaths %S" , &msg );
  1075     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectAllPaths %S" , &msg );
       
  1076     OstTraceExt1( TRACE_NORMAL, DUP22_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailSelectAllPaths;msg=%S", msg );
   998     msg.Zero();
  1077     msg.Zero();
   999 #endif
  1078 #endif
  1000     User::LeaveIfError( err );
  1079     User::LeaveIfError( err );
  1001     
  1080     
  1002     err = iStmt_KThumbnailRename.Prepare( iDatabase, KThumbnailRename );
  1081     err = iStmt_KThumbnailRename.Prepare( iDatabase, KThumbnailRename );
  1003 #ifdef _DEBUG
  1082 #ifdef _DEBUG
  1004     msg.Append( iDatabase.LastErrorMessage() );
  1083     msg.Append( iDatabase.LastErrorMessage() );
  1005     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailRename %S" , &msg );
  1084     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailRename %S" , &msg );
       
  1085     OstTraceExt1( TRACE_NORMAL, DUP23_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailRename;msg=%S", msg );
  1006     msg.Zero();
  1086     msg.Zero();
  1007 #endif
  1087 #endif
  1008     User::LeaveIfError( err );
  1088     User::LeaveIfError( err );
  1009     
  1089     
  1010     err = iStmt_KThumbnailTempRename.Prepare( iDatabase, KThumbnailTempRename );
  1090     err = iStmt_KThumbnailTempRename.Prepare( iDatabase, KThumbnailTempRename );
  1011 #ifdef _DEBUG
  1091 #ifdef _DEBUG
  1012     msg.Append( iDatabase.LastErrorMessage() );
  1092     msg.Append( iDatabase.LastErrorMessage() );
  1013     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailTempRename %S" , &msg );
  1093     TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailTempRename %S" , &msg );
       
  1094     OstTraceExt1( TRACE_NORMAL, DUP24_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - KThumbnailTempRename;msg=%S", msg );
  1014     msg.Zero();
  1095     msg.Zero();
  1015 #endif
  1096 #endif
  1016     User::LeaveIfError( err );
  1097     User::LeaveIfError( err );
  1017     
  1098     
  1018     TN_DEBUG1("CThumbnailStore::PrepareStatementsL() end");
  1099     TN_DEBUG1("CThumbnailStore::PrepareStatementsL() end");
       
  1100     OstTrace0( TRACE_NORMAL, DUP25_CTHUMBNAILSTORE_PREPARESTATEMENTSL, "CThumbnailStore::PrepareStatementsL - end" );
  1019     }
  1101     }
  1020 
  1102 
  1021 // ---------------------------------------------------------------------------
  1103 // ---------------------------------------------------------------------------
  1022 // CThumbnailStore::ResetStatement()
  1104 // CThumbnailStore::ResetStatement()
  1023 // ---------------------------------------------------------------------------
  1105 // ---------------------------------------------------------------------------
  1034 // ---------------------------------------------------------------------------
  1116 // ---------------------------------------------------------------------------
  1035 //
  1117 //
  1036 void CThumbnailStore::CloseStatements()
  1118 void CThumbnailStore::CloseStatements()
  1037     {
  1119     {
  1038     TN_DEBUG1("CThumbnailStore::CloseStatements()");
  1120     TN_DEBUG1("CThumbnailStore::CloseStatements()");
       
  1121     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_CLOSESTATEMENTS, "CThumbnailStore::CloseStatements" );
  1039     
  1122     
  1040     iStmt_KThumbnailSelectInfoByPath.Close();
  1123     iStmt_KThumbnailSelectInfoByPath.Close();
  1041     iStmt_KThumbnailSelectTempInfoByPath.Close();   
  1124     iStmt_KThumbnailSelectTempInfoByPath.Close();   
  1042     iStmt_KThumbnailInsertTempThumbnailInfo.Close();
  1125     iStmt_KThumbnailInsertTempThumbnailInfo.Close();
  1043     iStmt_KThumbnailInsertTempThumbnailInfoData.Close();  
  1126     iStmt_KThumbnailInsertTempThumbnailInfoData.Close();  
  1061     iStmt_KThumbnailSelectAllPaths.Close();
  1144     iStmt_KThumbnailSelectAllPaths.Close();
  1062     iStmt_KThumbnailRename.Close();
  1145     iStmt_KThumbnailRename.Close();
  1063     iStmt_KThumbnailTempRename.Close();
  1146     iStmt_KThumbnailTempRename.Close();
  1064     
  1147     
  1065     TN_DEBUG1("CThumbnailStore::CloseStatements() end");
  1148     TN_DEBUG1("CThumbnailStore::CloseStatements() end");
       
  1149     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_CLOSESTATEMENTS, "CThumbnailStore::CloseStatements - end" );
  1066     }
  1150     }
  1067 
  1151 
  1068 // ---------------------------------------------------------------------------
  1152 // ---------------------------------------------------------------------------
  1069 // CThumbnailStore::StoreThumbnailL()
  1153 // CThumbnailStore::StoreThumbnailL()
  1070 // Stores thumbnail image.
  1154 // Stores thumbnail image.
  1142     
  1226     
  1143     // try getting modification time from file
  1227     // try getting modification time from file
  1144     TTime timeStamp;
  1228     TTime timeStamp;
  1145     
  1229     
  1146     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) timeStamp aModified %Ld", aModified );
  1230     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) timeStamp aModified %Ld", aModified );
       
  1231     OstTraceExt1( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - timeStamp aModified;aModified=%Ld", aModified );
  1147         
  1232         
  1148     if( aModified )
  1233     if( aModified )
  1149         {
  1234         {
  1150         timeStamp = aModified;
  1235         timeStamp = aModified;
  1151         }
  1236         }
  1164             timeErr = iFs.Modified(path, timeStamp);
  1249             timeErr = iFs.Modified(path, timeStamp);
  1165             
  1250             
  1166             if (timeErr != KErrNone)
  1251             if (timeErr != KErrNone)
  1167                 {
  1252                 {
  1168                 TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) error getting timeStamp: %d", timeErr );
  1253                 TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) error getting timeStamp: %d", timeErr );
       
  1254                 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - error getting timeStamp;timeErr=%d", timeErr );
  1169                 }
  1255                 }
  1170             else
  1256             else
  1171                 {
  1257                 {
  1172                 TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) timeStamp       iFs %Ld", timeStamp.Int64() );
  1258                 TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) timeStamp       iFs %Ld", timeStamp.Int64() );
       
  1259                 OstTraceExt1( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - timeStamp;timeStamp.Int64()=%Ld", timeStamp.Int64() );
  1173                 }
  1260                 }
  1174             }
  1261             }
  1175         
  1262         
  1176         if (!aPath.Length() || timeErr != KErrNone)
  1263         if (!aPath.Length() || timeErr != KErrNone)
  1177             {
  1264             {
  1178             // otherwise current time
  1265             // otherwise current time
  1179             timeStamp.UniversalTime();
  1266             timeStamp.UniversalTime();
  1180             TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) timeStamp   current %Ld", timeStamp.Int64() );
  1267             TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) timeStamp   current %Ld", timeStamp.Int64() );
       
  1268             OstTraceExt1( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - timeStamp   current;timeStamp.Int64()=%Ld", timeStamp.Int64() );
  1181             }
  1269             }
  1182         }
  1270         }
  1183         
  1271         
  1184    TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) timeStamp       set %Ld", timeStamp.Int64());
  1272    TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) timeStamp       set %Ld", timeStamp.Int64());
       
  1273    OstTraceExt1( TRACE_NORMAL, DUP5_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - timeStamp       set;timeStamp.Int64()=%Ld", timeStamp.Int64() );
  1185    
  1274    
  1186     paramIndex = stmt->ParameterIndex( KThumbnailSqlParamModified );
  1275     paramIndex = stmt->ParameterIndex( KThumbnailSqlParamModified );
  1187     User::LeaveIfError( paramIndex );
  1276     User::LeaveIfError( paramIndex );
  1188     User::LeaveIfError( stmt->BindInt64( paramIndex, timeStamp.Int64() ));
  1277     User::LeaveIfError( stmt->BindInt64( paramIndex, timeStamp.Int64() ));
  1189     
  1278     
  1211     FlushCacheTable();
  1300     FlushCacheTable();
  1212 
  1301 
  1213 #ifdef _DEBUG
  1302 #ifdef _DEBUG
  1214     iThumbCounter++;
  1303     iThumbCounter++;
  1215     TN_DEBUG2( "CThumbnailStore::THUMBSTORE-COUNTER----------, Thumbs = %d", iThumbCounter );
  1304     TN_DEBUG2( "CThumbnailStore::THUMBSTORE-COUNTER----------, Thumbs = %d", iThumbCounter );
       
  1305     OstTrace1( TRACE_NORMAL, DUP6_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::THUMBSTORE-COUNTER----------, Thumbs =;iThumbCounter=%d", iThumbCounter );
  1216     
  1306     
  1217     aStop.UniversalTime();
  1307     aStop.UniversalTime();
       
  1308     TInt tookTime = aStop.MicroSecondsFrom(aStart).Int64()/1000;
  1218     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) insert to table %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
  1309     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( private ) insert to table %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
       
  1310     OstTrace1( TRACE_NORMAL, DUP7_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - insert to table;tookTime=%d", tookTime );
  1219 #endif 
  1311 #endif 
  1220     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( private ) out" );
  1312     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( private ) out" );
       
  1313     OstTrace0( TRACE_NORMAL, DUP8_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - out" );
  1221     }
  1314     }
  1222 
  1315 
  1223 
  1316 
  1224 // ---------------------------------------------------------------------------
  1317 // ---------------------------------------------------------------------------
  1225 // CThumbnailStore::StoreThumbnailL()
  1318 // CThumbnailStore::StoreThumbnailL()
  1230     aThumbnail, const TSize& aOriginalSize, TBool /*aCropped*/, const TThumbnailSize aThumbnailSize, 
  1323     aThumbnail, const TSize& aOriginalSize, TBool /*aCropped*/, const TThumbnailSize aThumbnailSize, 
  1231     const TInt64 aModified, TBool aThumbFromPath, TBool aBlackListed )
  1324     const TInt64 aModified, TBool aThumbFromPath, TBool aBlackListed )
  1232     {
  1325     {
  1233     TSize thumbSize = aThumbnail->SizeInPixels();
  1326     TSize thumbSize = aThumbnail->SizeInPixels();
  1234     TN_DEBUG4( "CThumbnailStore::StoreThumbnailL( public ) aThumbnailSize = %d, aThumbnailSize(%d,%d) IN", aThumbnailSize, thumbSize.iWidth, thumbSize.iHeight );
  1327     TN_DEBUG4( "CThumbnailStore::StoreThumbnailL( public ) aThumbnailSize = %d, aThumbnailSize(%d,%d) IN", aThumbnailSize, thumbSize.iWidth, thumbSize.iHeight );
  1235     
  1328     OstTraceExt3( TRACE_NORMAL, DUP9_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - IN;aThumbnailSize=%u;thumbSize.iWidth=%d;thumbSize.iHeight=%d", aThumbnailSize, thumbSize.iWidth, thumbSize.iHeight );    
  1236     if(iReadOnly)
  1329     if(iReadOnly)
  1237         {
  1330         {
  1238         TN_DEBUG1( "CThumbnailStore::StoreThumbnailL() read only, skip..." );
  1331         TN_DEBUG1( "CThumbnailStore::StoreThumbnailL() read only, skip..." );
  1239         return;
  1332         return;
  1240         }
  1333         }
  1246     // don't store custom/unknown sizes or zero sizes
  1339     // don't store custom/unknown sizes or zero sizes
  1247     if(aThumbnailSize == ECustomThumbnailSize || aThumbnailSize == EUnknownThumbnailSize 
  1340     if(aThumbnailSize == ECustomThumbnailSize || aThumbnailSize == EUnknownThumbnailSize 
  1248             || thumbSize.iWidth <= 0 || thumbSize.iHeight <= 0 )
  1341             || thumbSize.iWidth <= 0 || thumbSize.iHeight <= 0 )
  1249         {
  1342         {
  1250         TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) not stored");
  1343         TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) not stored");
       
  1344         OstTrace0( TRACE_NORMAL, DUP10_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - not stored" );
  1251         return;
  1345         return;
  1252         }
  1346         }
  1253     
  1347     
  1254     HBufC* path = aPath.AllocLC();
  1348     HBufC* path = aPath.AllocLC();
  1255     TPtr ptr(path->Des());
  1349     TPtr ptr(path->Des());
  1278             
  1372             
  1279             if( (aThumbnailSize == EImageFullScreenThumbnailSize || aThumbnailSize == EVideoFullScreenThumbnailSize ||
  1373             if( (aThumbnailSize == EImageFullScreenThumbnailSize || aThumbnailSize == EVideoFullScreenThumbnailSize ||
  1280                  aThumbnailSize == EAudioFullScreenThumbnailSize) && !aBlackListed )
  1374                  aThumbnailSize == EAudioFullScreenThumbnailSize) && !aBlackListed )
  1281                 {
  1375                 {
  1282                 TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - encode jpg" );
  1376                 TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - encode jpg" );
       
  1377                 OstTrace0( TRACE_NORMAL, DUP11_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - encode jpg" );
  1283             
  1378             
  1284                 HBufC8* data = NULL;
  1379                 HBufC8* data = NULL;
  1285                 CleanupStack::PushL( data );
  1380                 CleanupStack::PushL( data );
  1286                 
  1381                 
  1287                 CImageEncoder* encoder = NULL;
  1382                 CImageEncoder* encoder = NULL;
  1290 				
  1385 				
  1291                 TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::EHwImplementation, data, options ) );
  1386                 TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::EHwImplementation, data, options ) );
  1292                 if ( decErr != KErrNone )
  1387                 if ( decErr != KErrNone )
  1293                     {
  1388                     {
  1294                     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - HW CExtJpegEncoder failed %d", decErr);
  1389                     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - HW CExtJpegEncoder failed %d", decErr);
       
  1390                     OstTrace1( TRACE_NORMAL, DUP12_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - HW CExtJpegEncoder failed;decErr=%d", decErr );
  1295                 
  1391                 
  1296                     TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::ESwImplementation, data, options ) );
  1392                     TRAPD( decErr, encoder = CExtJpegEncoder::DataNewL( CExtJpegEncoder::ESwImplementation, data, options ) );
  1297                     if ( decErr != KErrNone )
  1393                     if ( decErr != KErrNone )
  1298                         {
  1394                         {
  1299                         TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - SW CExtJpegEncoder failed %d", decErr);
  1395                         TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - SW CExtJpegEncoder failed %d", decErr);
       
  1396                         OstTrace1( TRACE_NORMAL, DUP13_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - SW CExtJpegEncoder failed;decErr=%d", decErr );
  1300                     
  1397                     
  1301                         TRAPD( decErr, encoder = CImageEncoder::DataNewL( data,  KJpegMime(), options ) );
  1398                         TRAPD( decErr, encoder = CImageEncoder::DataNewL( data,  KJpegMime(), options ) );
  1302                         if ( decErr != KErrNone )
  1399                         if ( decErr != KErrNone )
  1303                             {
  1400                             {
  1304                             TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - CImageEncoder failed %d", decErr);
  1401                             TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - CImageEncoder failed %d", decErr);
       
  1402                             OstTrace1( TRACE_NORMAL, DUP14_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - CImageEncoder failed;decErr=%d", decErr );
  1305                             
  1403                             
  1306                             User::Leave(decErr);
  1404                             User::Leave(decErr);
  1307                             }
  1405                             }
  1308                         else
  1406                         else
  1309                             {
  1407                             {
  1310                             TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - CImageEncoder created" );
  1408                             TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - CImageEncoder created" );
       
  1409                             OstTrace0( TRACE_NORMAL, DUP15_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - CImageEncoder created" );
  1311                             }
  1410                             }
  1312                         }
  1411                         }
  1313                     else
  1412                     else
  1314                         {
  1413                         {
  1315                         TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - SW CExtJpegEncoder created" );
  1414                         TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - SW CExtJpegEncoder created" );
       
  1415                         OstTrace0( TRACE_NORMAL, DUP16_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - SW CExtJpegEncoder created" );
  1316                         }
  1416                         }
  1317                     }
  1417                     }
  1318                 else
  1418                 else
  1319                     {
  1419                     {
  1320                     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - HW CExtJpegEncoder created" );
  1420                     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - HW CExtJpegEncoder created" );
       
  1421                     OstTrace0( TRACE_NORMAL, DUP17_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - HW CExtJpegEncoder created" );
  1321                     }             
  1422                     }             
  1322                 
  1423                 
  1323                 CleanupStack::Pop( data );
  1424                 CleanupStack::Pop( data );
  1324                 CleanupStack::PushL( encoder );
  1425                 CleanupStack::PushL( encoder );
  1325              
  1426              
  1352                 CleanupStack::PopAndDestroy( encoder );
  1453                 CleanupStack::PopAndDestroy( encoder );
  1353                 
  1454                 
  1354                 if(request == KErrNone)
  1455                 if(request == KErrNone)
  1355                     {           
  1456                     {           
  1356                     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - encoding ok" );    
  1457                     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) - encoding ok" );    
       
  1458                     OstTrace0( TRACE_NORMAL, DUP18_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - encoding ok" );
  1357                 
  1459                 
  1358                     CleanupStack::PushL( data );
  1460                     CleanupStack::PushL( data );
  1359                     TPtr8 ptr = data->Des(); 
  1461                     TPtr8 ptr = data->Des(); 
  1360                     StoreThumbnailL( *path, ptr, aThumbnail->SizeInPixels(), 
  1462                     StoreThumbnailL( *path, ptr, aThumbnail->SizeInPixels(), 
  1361                                      aOriginalSize, EThumbnailFormatJpeg, flags, 
  1463                                      aOriginalSize, EThumbnailFormatJpeg, flags, 
  1363                     CleanupStack::Pop( data );
  1465                     CleanupStack::Pop( data );
  1364                     }
  1466                     }
  1365                 else
  1467                 else
  1366                     {
  1468                     {
  1367                     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - encoding failed: %d", request.Int() );
  1469                     TN_DEBUG2( "CThumbnailStore::StoreThumbnailL( public ) - encoding failed: %d", request.Int() );
       
  1470                     OstTrace1( TRACE_NORMAL, DUP19_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - encoding failed;request.Int()=%d", request.Int() );
  1368                     }
  1471                     }
  1369                 
  1472                 
  1370                 delete data;
  1473                 delete data;
  1371                 data = NULL;
  1474                 data = NULL;
  1372                 }
  1475                 }
  1390         }
  1493         }
  1391     
  1494     
  1392     CleanupStack::PopAndDestroy( path );
  1495     CleanupStack::PopAndDestroy( path );
  1393     
  1496     
  1394     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) out" );
  1497     TN_DEBUG1( "CThumbnailStore::StoreThumbnailL( public ) out" );
       
  1498     OstTrace0( TRACE_NORMAL, DUP20_CTHUMBNAILSTORE_STORETHUMBNAILL, "CThumbnailStore::StoreThumbnailL - out" );
  1395     }
  1499     }
  1396 
  1500 
  1397 // ---------------------------------------------------------------------------
  1501 // ---------------------------------------------------------------------------
  1398 // Finds possible existing duplicate thumbnail.
  1502 // Finds possible existing duplicate thumbnail.
  1399 // ---------------------------------------------------------------------------
  1503 // ---------------------------------------------------------------------------
  1400 //
  1504 //
  1401 TBool CThumbnailStore::FindDuplicateL( const TDesC& aPath, const TThumbnailSize& aThumbnailSize )
  1505 TBool CThumbnailStore::FindDuplicateL( const TDesC& aPath, const TThumbnailSize& aThumbnailSize )
  1402     {
  1506     {
  1403     TN_DEBUG1( "CThumbnailStore::FindDuplicateL()" );
  1507     TN_DEBUG1( "CThumbnailStore::FindDuplicateL()" );
  1404 	
  1508     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_FINDDUPLICATEL, "CThumbnailStore::FindDuplicateL" );
  1405 	if(iReadOnly)
  1509 	if(iReadOnly)
  1406 		{
  1510 		{
  1407 		TN_DEBUG1( "CThumbnailStore::FindDuplicateL() read only, skip..." );
  1511 		TN_DEBUG1( "CThumbnailStore::FindDuplicateL() read only, skip..." );
  1408 		return EFalse;
  1512 		return EFalse;
  1409 		}
  1513 		}
  1446         rowStatus = stmt->Next();
  1550         rowStatus = stmt->Next();
  1447         
  1551         
  1448         if(rowStatus == KSqlAtRow)
  1552         if(rowStatus == KSqlAtRow)
  1449             {
  1553             {
  1450             TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate in main table" );
  1554             TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate in main table" );
       
  1555             OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_FINDDUPLICATEL, "CThumbnailStore::FindDuplicateL - duplicate in main table" );
  1451             
  1556             
  1452             found = ETrue;
  1557             found = ETrue;
  1453             }
  1558             }
  1454         else
  1559         else
  1455             {
  1560             {
  1456             TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - no duplicate" );
  1561             TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - no duplicate" );
       
  1562             OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_FINDDUPLICATEL, "CThumbnailStore::FindDuplicateL - no duplicate" );
  1457             }
  1563             }
  1458         }
  1564         }
  1459     else
  1565     else
  1460         {
  1566         {
  1461         TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate in temp table" );
  1567         TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate in temp table" );
       
  1568         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_FINDDUPLICATEL, "CThumbnailStore::FindDuplicateL - duplicate in temp table" );
  1462         
  1569         
  1463         found = ETrue;
  1570         found = ETrue;
  1464         }
  1571         }
  1465     
  1572     
  1466     CleanupStack::PopAndDestroy( stmt );
  1573     CleanupStack::PopAndDestroy( stmt );
  1480         CleanupStack::PopAndDestroy( stmt );
  1587         CleanupStack::PopAndDestroy( stmt );
  1481         
  1588         
  1482         if(rowStatus == KSqlAtRow)
  1589         if(rowStatus == KSqlAtRow)
  1483             {
  1590             {
  1484             TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate marked deleted" );
  1591             TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate marked deleted" );
       
  1592             OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_FINDDUPLICATEL, "CThumbnailStore::FindDuplicateL - duplicate marked deleted" );
  1485             
  1593             
  1486             DeleteThumbnailsL(aPath, ETrue);
  1594             DeleteThumbnailsL(aPath, ETrue);
  1487             
  1595             
  1488             TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate force-deleted" );
  1596             TN_DEBUG1( "CThumbnailStore::FindDuplicateL() - duplicate force-deleted" );
       
  1597             OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILSTORE_FINDDUPLICATEL, "CThumbnailStore::FindDuplicateL - duplicate force-deleted" );
  1489             
  1598             
  1490             found = EFalse;
  1599             found = EFalse;
  1491             }
  1600             }
  1492         }
  1601         }
  1493     
  1602     
  1500 //     
  1609 //     
  1501 void CThumbnailStore::GetMissingSizesL( const TDesC& aPath, TInt aSourceType, RArray <
  1610 void CThumbnailStore::GetMissingSizesL( const TDesC& aPath, TInt aSourceType, RArray <
  1502     TThumbnailPersistentSize > & aMissingSizes, TBool aCheckGridSizeOnly )
  1611     TThumbnailPersistentSize > & aMissingSizes, TBool aCheckGridSizeOnly )
  1503     {
  1612     {
  1504     TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() aSourceType == %d", aSourceType );
  1613     TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() aSourceType == %d", aSourceType );
  1505     
  1614     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTORE_GETMISSINGSIZESL, "CThumbnailStore::GetMissingSizesL;aSourceType=%d", aSourceType );
  1506     if(iReadOnly)
  1615     if(iReadOnly)
  1507         {
  1616         {
  1508         TN_DEBUG1( "CThumbnailStore::GetMissingSizesL() read only, skip..." );
  1617         TN_DEBUG1( "CThumbnailStore::GetMissingSizesL() read only, skip..." );
  1509 		return;
  1618 		return;
  1510         }
  1619         }
  1528 				if( (iPersistentSizes[i].iSourceType == TThumbnailPersistentSize::EImage || iPersistentSizes[i].iSourceType == TThumbnailPersistentSize::EVideo )&&
  1637 				if( (iPersistentSizes[i].iSourceType == TThumbnailPersistentSize::EImage || iPersistentSizes[i].iSourceType == TThumbnailPersistentSize::EVideo )&&
  1529                      iPersistentSizes[i].iSizeType != TThumbnailPersistentSize::EGrid )
  1638                      iPersistentSizes[i].iSizeType != TThumbnailPersistentSize::EGrid )
  1530                     {
  1639                     {
  1531                     TN_DEBUG4( "CThumbnailStore::GetMissingSizesL() skip, aCheckGridSizeOnly = %d and  iPersistentSizes[%d].iSizeType == %d", 
  1640                     TN_DEBUG4( "CThumbnailStore::GetMissingSizesL() skip, aCheckGridSizeOnly = %d and  iPersistentSizes[%d].iSizeType == %d", 
  1532                             aCheckGridSizeOnly, i, iPersistentSizes[i].iSizeType );
  1641                             aCheckGridSizeOnly, i, iPersistentSizes[i].iSizeType );
       
  1642                     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_GETMISSINGSIZESL, "CThumbnailStore::GetMissingSizesL;aCheckGridSizeOnly=%u", aCheckGridSizeOnly );
  1533                     }
  1643                     }
  1534 				else
  1644 				else
  1535 				    {
  1645 				    {
  1536                     aMissingSizes.AppendL( iPersistentSizes[ i ] );
  1646                     aMissingSizes.AppendL( iPersistentSizes[ i ] );
  1537 				    }
  1647 				    }
  1544         }
  1654         }
  1545     
  1655     
  1546     TInt missingSizeCount = aMissingSizes.Count();
  1656     TInt missingSizeCount = aMissingSizes.Count();
  1547         
  1657         
  1548     TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() missingSizeCount == %d", missingSizeCount );
  1658     TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() missingSizeCount == %d", missingSizeCount );
       
  1659     OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_GETMISSINGSIZESL, "CThumbnailStore::GetMissingSizesL;missingSizeCount=%d", missingSizeCount );
  1549     
  1660     
  1550     // check temp table first
  1661     // check temp table first
  1551     RSqlStatement* stmt = NULL;
  1662     RSqlStatement* stmt = NULL;
  1552     stmt = &iStmt_KThumbnailSelectTempSizeByPath;
  1663     stmt = &iStmt_KThumbnailSelectTempSizeByPath;
  1553     CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1664     CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1571             for ( TInt i = 0; i < missingSizeCount; i++ )
  1682             for ( TInt i = 0; i < missingSizeCount; i++ )
  1572                 {
  1683                 {
  1573                 if ( aMissingSizes[ i ].iType == size )
  1684                 if ( aMissingSizes[ i ].iType == size )
  1574                     {
  1685                     {
  1575                     TN_DEBUG1( "CThumbnailStore::GetMissingSizesL() -- thumbnail found" );
  1686                     TN_DEBUG1( "CThumbnailStore::GetMissingSizesL() -- thumbnail found" );
       
  1687                     OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_GETMISSINGSIZESL, "CThumbnailStore::GetMissingSizesL - thumbnail found" );
  1576                     aMissingSizes.Remove( i );
  1688                     aMissingSizes.Remove( i );
  1577                     missingSizeCount--;
  1689                     missingSizeCount--;
  1578                     break;
  1690                     break;
  1579                     }
  1691                     }
  1580                 }
  1692                 }
  1615 //
  1727 //
  1616 void CThumbnailStore::FetchThumbnailL( const TDesC& aPath, CFbsBitmap* &
  1728 void CThumbnailStore::FetchThumbnailL( const TDesC& aPath, CFbsBitmap* &
  1617     aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aThumbnailRealSize )
  1729     aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aThumbnailRealSize )
  1618     {
  1730     {
  1619     TN_DEBUG3( "CThumbnailStore::FetchThumbnailL(%S) aThumbnailSize==%d", &aPath, aThumbnailSize );
  1731     TN_DEBUG3( "CThumbnailStore::FetchThumbnailL(%S) aThumbnailSize==%d", &aPath, aThumbnailSize );
  1620     
  1732     OstTraceExt2( TRACE_NORMAL, CTHUMBNAILSTORE_FETCHTHUMBNAILL, "CThumbnailStore::FetchThumbnailL;aPath=%S;aThumbnailSize=%u", aPath, aThumbnailSize );
  1621     if(iReadOnly)
  1733     if(iReadOnly)
  1622         {
  1734         {
  1623         TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() read only, skip..." );
  1735         TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() read only, skip..." );
  1624         User::Leave( KErrNotFound );
  1736         User::Leave( KErrNotFound );
  1625         }
  1737         }
  1634     TInt found = KErrNotFound;
  1746     TInt found = KErrNotFound;
  1635     TInt rowStatus = 0;
  1747     TInt rowStatus = 0;
  1636     TInt column = 0;
  1748     TInt column = 0;
  1637     
  1749     
  1638     TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- TEMP TABLE lookup" );
  1750     TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- TEMP TABLE lookup" );
       
  1751     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_FETCHTHUMBNAILL, "CThumbnailStore::FetchThumbnailL - TEMP TABLE lookup" );
  1639 
  1752 
  1640     RSqlStatement* stmt = NULL;
  1753     RSqlStatement* stmt = NULL;
  1641     stmt = &iStmt_KThumbnailSelectTempInfoByPath;
  1754     stmt = &iStmt_KThumbnailSelectTempInfoByPath;
  1642     CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1755     CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1643     
  1756     
  1653 
  1766 
  1654     //if not found from temp table, look from real table
  1767     //if not found from temp table, look from real table
  1655     if(rowStatus != KSqlAtRow)
  1768     if(rowStatus != KSqlAtRow)
  1656        {
  1769        {
  1657        TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- MAIN TABLE lookup" );
  1770        TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- MAIN TABLE lookup" );
       
  1771        OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_FETCHTHUMBNAILL, "CThumbnailStore::FetchThumbnailL - MAIN TABLE lookup" );
  1658       
  1772       
  1659        CleanupStack::PopAndDestroy( stmt );
  1773        CleanupStack::PopAndDestroy( stmt );
  1660        stmt = &iStmt_KThumbnailSelectInfoByPath;
  1774        stmt = &iStmt_KThumbnailSelectInfoByPath;
  1661        CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1775        CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1662     
  1776     
  1672        }
  1786        }
  1673 
  1787 
  1674     if(rowStatus == KSqlAtRow)
  1788     if(rowStatus == KSqlAtRow)
  1675        {
  1789        {
  1676         TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail found" );
  1790         TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail found" );
       
  1791         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_FETCHTHUMBNAILL, "CThumbnailStore::FetchThumbnailL - thumbnail found" );
  1677         
  1792         
  1678         // Check whether blacklisted thumbnail entry modified. 
  1793         // Check whether blacklisted thumbnail entry modified. 
  1679         // If thumbnail is marked as blacklisted and timestamp has 
  1794         // If thumbnail is marked as blacklisted and timestamp has 
  1680         // changed, delete thumbnails from tables and leave with 
  1795         // changed, delete thumbnails from tables and leave with 
  1681         // KErrNotFound to get thumbnail regenerated.
  1796         // KErrNotFound to get thumbnail regenerated.
  1729             }
  1844             }
  1730         }
  1845         }
  1731     else
  1846     else
  1732         {
  1847         {
  1733         TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail NOT found" );
  1848         TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail NOT found" );
       
  1849         OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_FETCHTHUMBNAILL, "CThumbnailStore::FetchThumbnailL - thumbnail NOT found" );
  1734         }
  1850         }
  1735         
  1851         
  1736     CleanupStack::PopAndDestroy( stmt );
  1852     CleanupStack::PopAndDestroy( stmt );
  1737     CleanupStack::PopAndDestroy( path );
  1853     CleanupStack::PopAndDestroy( path );
  1738     
  1854     
  1745 //
  1861 //
  1746 void CThumbnailStore::DeleteThumbnailsL( const TDesC& aPath, TBool aForce, 
  1862 void CThumbnailStore::DeleteThumbnailsL( const TDesC& aPath, TBool aForce, 
  1747                                          TBool aTransaction )
  1863                                          TBool aTransaction )
  1748     {
  1864     {
  1749     TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsL(%S)", &aPath );
  1865     TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsL(%S)", &aPath );
       
  1866     OstTraceExt1( TRACE_NORMAL, CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL;aPath=%S", aPath );
  1750 
  1867 
  1751     if(iReadOnly)
  1868     if(iReadOnly)
  1752         {
  1869         {
  1753         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsL() read only, skip..." );
  1870         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsL() read only, skip..." );
  1754         return;
  1871         return;
  1779         CleanupClosePushL( transaction );    
  1896         CleanupClosePushL( transaction );    
  1780         transaction.BeginL();
  1897         transaction.BeginL();
  1781         }
  1898         }
  1782         
  1899         
  1783     TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByPathL() -- TEMP TABLE lookup" );
  1900     TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByPathL() -- TEMP TABLE lookup" );
       
  1901     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL - TEMP TABLE lookup" );
  1784     
  1902     
  1785     RSqlStatement* stmt = NULL;
  1903     RSqlStatement* stmt = NULL;
  1786     RSqlStatement* stmt_info = NULL;
  1904     RSqlStatement* stmt_info = NULL;
  1787     RSqlStatement* stmt_infodata = NULL;
  1905     RSqlStatement* stmt_infodata = NULL;
  1788     
  1906     
  1817         err = stmt_infodata->Exec();
  1935         err = stmt_infodata->Exec();
  1818         stmt_infodata->Reset();
  1936         stmt_infodata->Reset();
  1819         User::LeaveIfError( err );
  1937         User::LeaveIfError( err );
  1820         
  1938         
  1821         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByPathL() -- TEMP TABLE lookup - thumbnail deleted" );
  1939         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByPathL() -- TEMP TABLE lookup - thumbnail deleted" );
       
  1940         OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL - TEMP TABLE lookup - thumbnail deleted" );
  1822        
  1941        
  1823         // fetch another row (temp table rowIDs are updated immediately)
  1942         // fetch another row (temp table rowIDs are updated immediately)
  1824         stmt->Reset();
  1943         stmt->Reset();
  1825        
  1944        
  1826         paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath );
  1945         paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath );
  1837     // if forcing instant delete
  1956     // if forcing instant delete
  1838     if (aForce)
  1957     if (aForce)
  1839         {
  1958         {
  1840         //look from real table 
  1959         //look from real table 
  1841         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup" );
  1960         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup" );
       
  1961         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL - MAIN TABLE lookup" );
  1842         
  1962         
  1843         stmt = &iStmt_KThumbnailSqlSelectRowIDInfoByPath;
  1963         stmt = &iStmt_KThumbnailSqlSelectRowIDInfoByPath;
  1844         CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1964         CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1845         stmt_info = &iStmt_KThumbnailSqlDeleteInfoByPath;
  1965         stmt_info = &iStmt_KThumbnailSqlDeleteInfoByPath;
  1846         CleanupStack::PushL(TCleanupItem(ResetStatement, stmt_info));    
  1966         CleanupStack::PushL(TCleanupItem(ResetStatement, stmt_info));    
  1871             err = stmt_infodata->Exec();
  1991             err = stmt_infodata->Exec();
  1872             stmt_infodata->Reset();
  1992             stmt_infodata->Reset();
  1873             User::LeaveIfError( err );
  1993             User::LeaveIfError( err );
  1874            
  1994            
  1875             TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup - thumbnail deleted" );
  1995             TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup - thumbnail deleted" );
       
  1996             OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL - MAIN TABLE lookup - thumbnail deleted" );
  1876             
  1997             
  1877             rowStatus = stmt->Next();
  1998             rowStatus = stmt->Next();
  1878             }
  1999             }
  1879         
  2000         
  1880         CleanupStack::PopAndDestroy( stmt_infodata );
  2001         CleanupStack::PopAndDestroy( stmt_infodata );
  1885         User::LeaveIfError( iDatabase.Exec( KThumbnailSqlDeleteFromDeleted ) );
  2006         User::LeaveIfError( iDatabase.Exec( KThumbnailSqlDeleteFromDeleted ) );
  1886         } 
  2007         } 
  1887     else
  2008     else
  1888         {
  2009         {
  1889         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup" );        
  2010         TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup" );        
       
  2011         OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL - MAIN TABLE lookup" );
  1890     
  2012     
  1891         stmt = &iStmt_KThumbnailSqlSelectRowIDInfoByPath;
  2013         stmt = &iStmt_KThumbnailSqlSelectRowIDInfoByPath;
  1892         CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  2014         CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1893 
  2015 
  1894         paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath );
  2016         paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath );
  1901         
  2023         
  1902         // there were matching rows in main table
  2024         // there were matching rows in main table
  1903         if (rowStatus == KSqlAtRow)
  2025         if (rowStatus == KSqlAtRow)
  1904             {        
  2026             {        
  1905             TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- add to Deleted" );
  2027             TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- add to Deleted" );
       
  2028             OstTrace0( TRACE_NORMAL, DUP6_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL - add to Deleted" );
  1906         
  2029         
  1907             // only add path to deleted table
  2030             // only add path to deleted table
  1908             stmt = &iStmt_KThumbnailSqlInsertDeleted;
  2031             stmt = &iStmt_KThumbnailSqlInsertDeleted;
  1909             CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  2032             CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1910             
  2033             
  1917             CleanupStack::PopAndDestroy( stmt );
  2040             CleanupStack::PopAndDestroy( stmt );
  1918             }
  2041             }
  1919         else
  2042         else
  1920             {
  2043             {
  1921             TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- no thumbs in MAIN" );
  2044             TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- no thumbs in MAIN" );
       
  2045             OstTrace0( TRACE_NORMAL, DUP7_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL - no thumbs in MAIN" );
  1922             }
  2046             }
  1923         }    
  2047         }    
  1924     
  2048     
  1925     if (aTransaction)
  2049     if (aTransaction)
  1926         {
  2050         {
  1928         CleanupStack::PopAndDestroy( &transaction );
  2052         CleanupStack::PopAndDestroy( &transaction );
  1929         }
  2053         }
  1930     
  2054     
  1931 #ifdef _DEBUG
  2055 #ifdef _DEBUG
  1932     aStop.UniversalTime();
  2056     aStop.UniversalTime();
       
  2057     TInt tookTime = (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000;
  1933     TN_DEBUG2( "CThumbnailStore::DeleteThumbnailByPathL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
  2058     TN_DEBUG2( "CThumbnailStore::DeleteThumbnailByPathL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
       
  2059     OstTrace1( TRACE_NORMAL, DUP8_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL - took;tookTime=%d", tookTime );
  1934 #endif
  2060 #endif
  1935     
  2061     
  1936     // start maintenance if rows in main table were marked
  2062     // start maintenance if rows in main table were marked
  1937     if (!aForce && count > 0)
  2063     if (!aForce && count > 0)
  1938         {
  2064         {
  1939         TN_DEBUG2( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup - %d rows marked deleted", count);
  2065         TN_DEBUG2( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup - %d rows marked deleted", count);
       
  2066         OstTrace1( TRACE_NORMAL, DUP9_CTHUMBNAILSTORE_DELETETHUMBNAILSL, "CThumbnailStore::DeleteThumbnailsL -- MAIN TABLE lookup - rows marked deleted;count=%d", count );
  1940         
  2067         
  1941         iDeleteThumbs = ETrue;
  2068         iDeleteThumbs = ETrue;
  1942         iActivityManager->Start();
  2069         iActivityManager->Start();
  1943         }
  2070         }
  1944     
  2071     
  1950 // -----------------------------------------------------------------------------
  2077 // -----------------------------------------------------------------------------
  1951 //
  2078 //
  1952 void CThumbnailStore::RenameThumbnailsL( const TDesC& aCurrentPath, const TDesC& aNewPath )
  2079 void CThumbnailStore::RenameThumbnailsL( const TDesC& aCurrentPath, const TDesC& aNewPath )
  1953     {
  2080     {
  1954     TN_DEBUG2( "CThumbnailStore::RenameThumbnailsL(%S)", &aCurrentPath );
  2081     TN_DEBUG2( "CThumbnailStore::RenameThumbnailsL(%S)", &aCurrentPath );
  1955     
  2082     OstTraceExt1( TRACE_NORMAL, CTHUMBNAILSTORE_RENAMETHUMBNAILSL, "CThumbnailStore::RenameThumbnailsL;aCurrentPath=%S", aCurrentPath );
  1956     if(iReadOnly)
  2083     if(iReadOnly)
  1957         {
  2084         {
  1958         TN_DEBUG1( "CThumbnailStore::RenameThumbnailsL() read only, skip..." );
  2085         TN_DEBUG1( "CThumbnailStore::RenameThumbnailsL() read only, skip..." );
  1959         return;
  2086         return;
  1960         }
  2087         }
  1979     RThumbnailTransaction transaction( iDatabase );
  2106     RThumbnailTransaction transaction( iDatabase );
  1980     CleanupClosePushL( transaction );    
  2107     CleanupClosePushL( transaction );    
  1981     transaction.BeginL();
  2108     transaction.BeginL();
  1982         
  2109         
  1983     TN_DEBUG1( "CThumbnailStore::RenameThumbnailsL() -- TEMP TABLE" );
  2110     TN_DEBUG1( "CThumbnailStore::RenameThumbnailsL() -- TEMP TABLE" );
       
  2111     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_RENAMETHUMBNAILSL, "CThumbnailStore::RenameThumbnailsL - TEMP TABLE" );
  1984     
  2112     
  1985     RSqlStatement* stmt = NULL;
  2113     RSqlStatement* stmt = NULL;
  1986     stmt = &iStmt_KThumbnailTempRename;
  2114     stmt = &iStmt_KThumbnailTempRename;
  1987     CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  2115     CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  1988     
  2116     
  1995     User::LeaveIfError( stmt->BindText( paramIndex, *newPath ));
  2123     User::LeaveIfError( stmt->BindText( paramIndex, *newPath ));
  1996     
  2124     
  1997     User::LeaveIfError( stmt->Exec() );
  2125     User::LeaveIfError( stmt->Exec() );
  1998     
  2126     
  1999     TN_DEBUG1( "CThumbnailStore::RenameThumbnailsL() -- MAIN TABLE" );
  2127     TN_DEBUG1( "CThumbnailStore::RenameThumbnailsL() -- MAIN TABLE" );
       
  2128     OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_RENAMETHUMBNAILSL, "CThumbnailStore::RenameThumbnailsL - MAIN TABLE" );
  2000     
  2129     
  2001     CleanupStack::PopAndDestroy( stmt );
  2130     CleanupStack::PopAndDestroy( stmt );
  2002     stmt = &iStmt_KThumbnailRename;
  2131     stmt = &iStmt_KThumbnailRename;
  2003     CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  2132     CleanupStack::PushL(TCleanupItem(ResetStatement, stmt));
  2004     
  2133     
  2023     CleanupStack::PopAndDestroy( newPath );
  2152     CleanupStack::PopAndDestroy( newPath );
  2024     CleanupStack::PopAndDestroy( path );
  2153     CleanupStack::PopAndDestroy( path );
  2025     
  2154     
  2026 #ifdef _DEBUG
  2155 #ifdef _DEBUG
  2027     aStop.UniversalTime();
  2156     aStop.UniversalTime();
       
  2157     TInt tookTime = (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000;
  2028     TN_DEBUG2( "CThumbnailStore::RenameThumbnailsL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
  2158     TN_DEBUG2( "CThumbnailStore::RenameThumbnailsL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
       
  2159     OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_RENAMETHUMBNAILSL, "CThumbnailStore::RenameThumbnailsL;tookTime=%d", tookTime );
  2029 #endif      
  2160 #endif      
  2030     }
  2161     }
  2031 
  2162 
  2032 // ---------------------------------------------------------------------------
  2163 // ---------------------------------------------------------------------------
  2033 // CThumbnailStore::PersistentSizes()
  2164 // CThumbnailStore::PersistentSizes()
  2043 // ---------------------------------------------------------------------------
  2174 // ---------------------------------------------------------------------------
  2044 //
  2175 //
  2045 void CThumbnailStore::FlushCacheTable( TBool aForce )
  2176 void CThumbnailStore::FlushCacheTable( TBool aForce )
  2046     {
  2177     {
  2047     TN_DEBUG1("CThumbnailStore::FlushCacheTable() in");
  2178     TN_DEBUG1("CThumbnailStore::FlushCacheTable() in");
       
  2179     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - in" );
  2048     
  2180     
  2049     StopAutoFlush();
  2181     StopAutoFlush();
  2050     
  2182     
  2051     if(iReadOnly)
  2183     if(iReadOnly)
  2052         {
  2184         {
  2056     
  2188     
  2057     if(iBatchItemCount <= 0 || CheckDbState() != KErrNone)
  2189     if(iBatchItemCount <= 0 || CheckDbState() != KErrNone)
  2058         {
  2190         {
  2059         // cache empty or db unusable
  2191         // cache empty or db unusable
  2060         TN_DEBUG1( "CThumbnailStore::FlushCacheTable() error ");
  2192         TN_DEBUG1( "CThumbnailStore::FlushCacheTable() error ");
       
  2193         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - error" );
  2061         return;
  2194         return;
  2062         }
  2195         }
  2063     
  2196     
  2064     // longer flush allowed if MTP sync on
  2197     // longer flush allowed if MTP sync on
  2065     TInt MPXHarvesting(0);
  2198     TInt MPXHarvesting(0);
  2066     TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
  2199     TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
  2067     if(ret != KErrNone)
  2200     if(ret != KErrNone)
  2068        {
  2201        {
  2069        TN_DEBUG2( "CThumbnailStore::FlushCacheTable() error checking MTP sync: %d", ret);
  2202        TN_DEBUG2( "CThumbnailStore::FlushCacheTable() error checking MTP sync: %d", ret);
       
  2203        OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - error checking MTP sync;ret=%d", ret );
  2070        }
  2204        }
  2071     
  2205     
  2072     //set init max flush delay
  2206     //set init max flush delay
  2073     TReal32 aMaxFlushDelay(KMaxFlushDelay);
  2207     TReal32 aMaxFlushDelay(KMaxFlushDelay);
  2074     TReal32 aPreviousFlushDelay(iPreviousFlushDelay);
  2208     TReal32 aPreviousFlushDelay(iPreviousFlushDelay);
  2076     
  2210     
  2077     if(MPXHarvesting)
  2211     if(MPXHarvesting)
  2078         {
  2212         {
  2079         //MTP or MPX harvesting active, allow longer flush -> bigger batch size
  2213         //MTP or MPX harvesting active, allow longer flush -> bigger batch size
  2080         TN_DEBUG1("CThumbnailStore::FlushCacheTable() MTP sync, longer flush..");
  2214         TN_DEBUG1("CThumbnailStore::FlushCacheTable() MTP sync, longer flush..");
       
  2215         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - MTP sync, longer flush.." );
  2081         aMaxFlushDelay = KMaxMTPFlushDelay;
  2216         aMaxFlushDelay = KMaxMTPFlushDelay;
  2082         }
  2217         }
  2083     
  2218     
  2084     //1st item in batch    
  2219     //1st item in batch    
  2085     if( iBatchItemCount == 1)
  2220     if( iBatchItemCount == 1)
  2086         {
  2221         {
  2087         TN_DEBUG2("CThumbnailStore::FlushCacheTable() calculate new batch size iPreviousFlushDelay = %d", iPreviousFlushDelay);
  2222         TN_DEBUG2("CThumbnailStore::FlushCacheTable() calculate new batch size iPreviousFlushDelay = %d", iPreviousFlushDelay);
       
  2223         OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable;iPreviousFlushDelay=%d", iPreviousFlushDelay );
  2088         //adjust batch size dynamically between min and max based on previous flush speed
  2224         //adjust batch size dynamically between min and max based on previous flush speed
  2089         if( iPreviousFlushDelay > 0 )
  2225         if( iPreviousFlushDelay > 0 )
  2090             {
  2226             {
  2091             TReal32 aNewBatchFlushItemCount = aMaxFlushDelay / aPreviousFlushDelay * aBatchFlushItemCount;
  2227             TReal32 aNewBatchFlushItemCount = aMaxFlushDelay / aPreviousFlushDelay * aBatchFlushItemCount;
  2092             iBatchFlushItemCount = (TInt)aNewBatchFlushItemCount;
  2228             iBatchFlushItemCount = (TInt)aNewBatchFlushItemCount;
  2093 
  2229 
  2094             TN_DEBUG2("CThumbnailStore::FlushCacheTable() aMaxFlushDelay %e", aMaxFlushDelay);      
  2230             TN_DEBUG2("CThumbnailStore::FlushCacheTable() aMaxFlushDelay %e", aMaxFlushDelay);      
       
  2231             OstTrace1( TRACE_NORMAL, DUP5_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable;aMaxFlushDelay=%d", aMaxFlushDelay );
  2095             TN_DEBUG2("CThumbnailStore::FlushCacheTable() aPreviousFlushDelay %e", aPreviousFlushDelay);      
  2232             TN_DEBUG2("CThumbnailStore::FlushCacheTable() aPreviousFlushDelay %e", aPreviousFlushDelay);      
       
  2233 			OstTrace1( TRACE_NORMAL, DUP6_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable;aPreviousFlushDelay=%d", aPreviousFlushDelay );
  2096 			TN_DEBUG2("CThumbnailStore::FlushCacheTable() aBatchFlushItemCount %e", aBatchFlushItemCount);      
  2234 			TN_DEBUG2("CThumbnailStore::FlushCacheTable() aBatchFlushItemCount %e", aBatchFlushItemCount);      
       
  2235             OstTrace1( TRACE_NORMAL, DUP7_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable;aBatchFlushItemCount=%d", aBatchFlushItemCount );
  2097             TN_DEBUG2("CThumbnailStore::FlushCacheTable() aNewBatchFlushItemCount %e", aNewBatchFlushItemCount);
  2236             TN_DEBUG2("CThumbnailStore::FlushCacheTable() aNewBatchFlushItemCount %e", aNewBatchFlushItemCount);
       
  2237             OstTrace1( TRACE_NORMAL, DUP8_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable;aNewBatchFlushItemCount=%d", aNewBatchFlushItemCount );
  2098             TN_DEBUG2("CThumbnailStore::FlushCacheTable() iBatchFlushItemCount %d", iBatchFlushItemCount);
  2238             TN_DEBUG2("CThumbnailStore::FlushCacheTable() iBatchFlushItemCount %d", iBatchFlushItemCount);
       
  2239             OstTrace1( TRACE_NORMAL, DUP9_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable;iBatchFlushItemCount=%d", iBatchFlushItemCount );
  2099             
  2240             
  2100             if( iBatchFlushItemCount < KMInBatchItems )
  2241             if( iBatchFlushItemCount < KMInBatchItems )
  2101                 {
  2242                 {
  2102                 iBatchFlushItemCount = KMInBatchItems;
  2243                 iBatchFlushItemCount = KMInBatchItems;
  2103                 }
  2244                 }
  2112             iBatchFlushItemCount = KMInBatchItems;
  2253             iBatchFlushItemCount = KMInBatchItems;
  2113             }
  2254             }
  2114         }
  2255         }
  2115     
  2256     
  2116     TN_DEBUG3("CThumbnailStore::FlushCacheTable() iBatchFlushItemCount = %d, iBatchItemCount = %d", iBatchFlushItemCount, iBatchItemCount);
  2257     TN_DEBUG3("CThumbnailStore::FlushCacheTable() iBatchFlushItemCount = %d, iBatchItemCount = %d", iBatchFlushItemCount, iBatchItemCount);
       
  2258     OstTrace0( TRACE_NORMAL, DUP10_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable" );
  2117     
  2259     
  2118     if( iBatchItemCount < iBatchFlushItemCount && !aForce)
  2260     if( iBatchItemCount < iBatchFlushItemCount && !aForce)
  2119        {
  2261        {
  2120        //some items in cache
  2262        //some items in cache
  2121        StartAutoFlush();
  2263        StartAutoFlush();
  2125     iStartFlush.UniversalTime();
  2267     iStartFlush.UniversalTime();
  2126     
  2268     
  2127     // Move data from temp table to main....
  2269     // Move data from temp table to main....
  2128     TInt err_begin = iDatabase.Exec( KThumbnailBeginTransaction );
  2270     TInt err_begin = iDatabase.Exec( KThumbnailBeginTransaction );
  2129     TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailBeginTransaction %d", err_begin);
  2271     TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailBeginTransaction %d", err_begin);
       
  2272     OstTrace1( TRACE_NORMAL, DUP11_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - KThumbnailBeginTransaction;err_begin=%d", err_begin );
  2130     
  2273     
  2131     TInt err_tempinfo = iDatabase.Exec( KThumbnailMoveFromTempInfoToMainTable );
  2274     TInt err_tempinfo = iDatabase.Exec( KThumbnailMoveFromTempInfoToMainTable );
  2132     TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailMoveFromTempInfoToMainTable %d", err_tempinfo);
  2275     TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailMoveFromTempInfoToMainTable %d", err_tempinfo);
       
  2276     OstTrace1( TRACE_NORMAL, DUP12_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - KThumbnailMoveFromTempInfoToMainTable;err_tempinfo=%d", err_tempinfo );
  2133     
  2277     
  2134 #ifdef _DEBUG
  2278 #ifdef _DEBUG
  2135     if(err_tempinfo < 0)
  2279     if(err_tempinfo < 0)
  2136         {
  2280         {
  2137         TPtrC errorMsg = iDatabase.LastErrorMessage();
  2281         TPtrC errorMsg = iDatabase.LastErrorMessage();
  2138         TN_DEBUG2( "CThumbnailStore::FlushCacheTable() lastError %S", &errorMsg);
  2282         TN_DEBUG2( "CThumbnailStore::FlushCacheTable() lastError %S", &errorMsg);
       
  2283         OstTraceExt1( TRACE_NORMAL, DUP13_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - lastError;errorMsg=%S", errorMsg );
  2139         }
  2284         }
  2140 #endif
  2285 #endif
  2141     
  2286     
  2142     TInt err_tempdata = iDatabase.Exec( KThumbnailMoveFromTempDataToMainTable );
  2287     TInt err_tempdata = iDatabase.Exec( KThumbnailMoveFromTempDataToMainTable );
  2143     
  2288     
  2144 #ifdef _DEBUG
  2289 #ifdef _DEBUG
  2145     if(err_tempdata < 0)
  2290     if(err_tempdata < 0)
  2146         {
  2291         {
  2147         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
  2292         TPtrC errorMsg2 = iDatabase.LastErrorMessage();
  2148         TN_DEBUG2( "CThumbnailStore::FlushCacheTable() KThumbnailMoveFromTempDataToMainTable %S", &errorMsg2);
  2293         TN_DEBUG2( "CThumbnailStore::FlushCacheTable() KThumbnailMoveFromTempDataToMainTable %S", &errorMsg2);
       
  2294         OstTraceExt1( TRACE_NORMAL, DUP14_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - KThumbnailMoveFromTempDataToMainTable;errorMsg2=%S", errorMsg2 );
  2149         }
  2295         }
  2150 #endif
  2296 #endif
  2151     
  2297     
  2152     TInt err_delinfo = iDatabase.Exec( KThumbnailDeleteFromTempInfoTable );
  2298     TInt err_delinfo = iDatabase.Exec( KThumbnailDeleteFromTempInfoTable );
  2153     TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailDeleteFromTempInfoTable %d", err_delinfo);
  2299     TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailDeleteFromTempInfoTable %d", err_delinfo);
       
  2300     OstTrace1( TRACE_NORMAL, DUP15_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - KThumbnailDeleteFromTempInfoTable;err_delinfo=%d", err_delinfo );
  2154     
  2301     
  2155     TInt err_deldata = iDatabase.Exec( KThumbnailDeleteFromTempDataTable );
  2302     TInt err_deldata = iDatabase.Exec( KThumbnailDeleteFromTempDataTable );
  2156     TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailDeleteFromTempDataTable %d", err_deldata);
  2303     TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailDeleteFromTempDataTable %d", err_deldata);
       
  2304     OstTrace1( TRACE_NORMAL, DUP16_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable;err_deldata=%d", err_deldata );
  2157    
  2305    
  2158     if( err_tempinfo < 0 || err_tempdata < 0  || err_delinfo < 0  || err_deldata < 0 )
  2306     if( err_tempinfo < 0 || err_tempdata < 0  || err_delinfo < 0  || err_deldata < 0 )
  2159         {
  2307         {
  2160         TInt err = iDatabase.Exec( KThumbnailRollbackTransaction );
  2308         TInt err = iDatabase.Exec( KThumbnailRollbackTransaction );
  2161         TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailRollbackTransaction %d", err);
  2309         TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailRollbackTransaction %d", err);
       
  2310         OstTrace1( TRACE_NORMAL, DUP17_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - KThumbnailRollbackTransaction;err=%d", err );
  2162         }
  2311         }
  2163     else
  2312     else
  2164         {
  2313         {
  2165         TInt err_commit = iDatabase.Exec( KThumbnailCommitTransaction );
  2314         TInt err_commit = iDatabase.Exec( KThumbnailCommitTransaction );
  2166         TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailCommitTransaction %d", err_commit);
  2315         TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailCommitTransaction %d", err_commit);
       
  2316         OstTrace0( TRACE_NORMAL, DUP18_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable" );
  2167         }
  2317         }
  2168     
  2318     
  2169     // db got corrupted
  2319     // db got corrupted
  2170     if(err_tempinfo == KSqlErrCorrupt || err_tempinfo == KErrCorrupt ||
  2320     if(err_tempinfo == KSqlErrCorrupt || err_tempinfo == KErrCorrupt ||
  2171        err_tempdata == KSqlErrCorrupt || err_tempdata == KErrCorrupt)
  2321        err_tempdata == KSqlErrCorrupt || err_tempdata == KErrCorrupt)
  2172         {
  2322         {
  2173         TN_DEBUG1("CThumbnailStore::FlushCacheTable() db corrupted");
  2323         TN_DEBUG1("CThumbnailStore::FlushCacheTable() db corrupted");
       
  2324         OstTrace0( TRACE_NORMAL, DUP19_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - db corrupted" );
  2174     
  2325     
  2175         // open new
  2326         // open new
  2176         TRAP_IGNORE(OpenDatabaseL(ETrue));
  2327         TRAP_IGNORE(OpenDatabaseL(ETrue));
  2177         }
  2328         }
  2178    
  2329    
  2179     iStopFlush.UniversalTime();
  2330     iStopFlush.UniversalTime();
  2180     iPreviousFlushDelay = (TInt)iStopFlush.MicroSecondsFrom(iStartFlush).Int64()/1000;
  2331     iPreviousFlushDelay = (TInt)iStopFlush.MicroSecondsFrom(iStartFlush).Int64()/1000;
  2181     
  2332     
  2182     TN_DEBUG2( "CThumbnailStore::FlushCacheTable() took %d ms", iPreviousFlushDelay);
  2333     TN_DEBUG2( "CThumbnailStore::FlushCacheTable() took %d ms", iPreviousFlushDelay);
       
  2334     OstTrace1( TRACE_NORMAL, DUP20_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - took ms ;iPreviousFlushDelay=%d", iPreviousFlushDelay );
  2183         
  2335         
  2184     //cache flushed
  2336     //cache flushed
  2185     iBatchItemCount = 0;
  2337     iBatchItemCount = 0;
  2186 
  2338 
  2187     TN_DEBUG1("CThumbnailStore::FlushCacheTable() out");
  2339     TN_DEBUG1("CThumbnailStore::FlushCacheTable() out");
       
  2340     OstTrace0( TRACE_NORMAL, DUP21_CTHUMBNAILSTORE_FLUSHCACHETABLE, "CThumbnailStore::FlushCacheTable - out" );
  2188     }
  2341     }
  2189 
  2342 
  2190 // -----------------------------------------------------------------------------
  2343 // -----------------------------------------------------------------------------
  2191 // StartAutoFlush()
  2344 // StartAutoFlush()
  2192 // -----------------------------------------------------------------------------
  2345 // -----------------------------------------------------------------------------
  2193 //
  2346 //
  2194 void CThumbnailStore::StartAutoFlush()
  2347 void CThumbnailStore::StartAutoFlush()
  2195     {
  2348     {
  2196     TN_DEBUG1( "CThumbnailStore::StartAutoFlush()" );
  2349     TN_DEBUG1( "CThumbnailStore::StartAutoFlush()" );
  2197     
  2350     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_STARTAUTOFLUSH, "CThumbnailStore::StartAutoFlush" );
  2198     if(iReadOnly)
  2351     if(iReadOnly)
  2199         {
  2352         {
  2200         TN_DEBUG1( "CThumbnailStore::StartAutoFlush() read only, skip..." );
  2353         TN_DEBUG1( "CThumbnailStore::StartAutoFlush() read only, skip..." );
  2201         return;
  2354         return;
  2202         }
  2355         }
  2213         }
  2366         }
  2214     
  2367     
  2215     if (err != KErrNone)
  2368     if (err != KErrNone)
  2216         {
  2369         {
  2217         TN_DEBUG2( "CThumbnailStore::StartAutoFlush() - Error creating timer (%d)", err );
  2370         TN_DEBUG2( "CThumbnailStore::StartAutoFlush() - Error creating timer (%d)", err );
       
  2371         OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_STARTAUTOFLUSH, "CThumbnailStore::StartAutoFlush - - Error creating timer;err=%d", err );
  2218         }
  2372         }
  2219     else
  2373     else
  2220         {
  2374         {
  2221         iAutoFlushTimer->Start( KAutoFlushTimeout * 1000000, KAutoFlushTimeout * 1000000, 
  2375         iAutoFlushTimer->Start( KAutoFlushTimeout * 1000000, KAutoFlushTimeout * 1000000, 
  2222                                 TCallBack(AutoFlushTimerCallBack, this));
  2376                                 TCallBack(AutoFlushTimerCallBack, this));
  2228 // -----------------------------------------------------------------------------
  2382 // -----------------------------------------------------------------------------
  2229 //
  2383 //
  2230 void CThumbnailStore::StopAutoFlush()
  2384 void CThumbnailStore::StopAutoFlush()
  2231     {
  2385     {
  2232     TN_DEBUG1( "CThumbnailStore::StopAutoFlush()" );
  2386     TN_DEBUG1( "CThumbnailStore::StopAutoFlush()" );
       
  2387     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_STOPAUTOFLUSH, "CThumbnailStore::StopAutoFlush" );
  2233     if( iAutoFlushTimer )
  2388     if( iAutoFlushTimer )
  2234         {
  2389         {
  2235         iAutoFlushTimer->Cancel();
  2390         iAutoFlushTimer->Cancel();
  2236         }
  2391         }
  2237     }
  2392     }
  2241 // -----------------------------------------------------------------------------
  2396 // -----------------------------------------------------------------------------
  2242 //
  2397 //
  2243 void CThumbnailStore::StartMaintenance()
  2398 void CThumbnailStore::StartMaintenance()
  2244     {
  2399     {
  2245     TN_DEBUG1( "CThumbnailStore::StartMaintenance()");
  2400     TN_DEBUG1( "CThumbnailStore::StartMaintenance()");
       
  2401     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_STARTMAINTENANCE, "CThumbnailStore::StartMaintenance" );
  2246     TInt err = KErrNone;
  2402     TInt err = KErrNone;
  2247     
  2403     
  2248     if( iMaintenanceTimer && iMaintenanceTimer->IsActive() )
  2404     if( iMaintenanceTimer && iMaintenanceTimer->IsActive() )
  2249         {
  2405         {
  2250         return;
  2406         return;
  2255         }
  2411         }
  2256     
  2412     
  2257     if (err != KErrNone && !iMaintenanceTimer)
  2413     if (err != KErrNone && !iMaintenanceTimer)
  2258         {
  2414         {
  2259         TN_DEBUG2( "CThumbnailStore::StartMaintenanceTimer() - Error creating timer (%d)", err );
  2415         TN_DEBUG2( "CThumbnailStore::StartMaintenanceTimer() - Error creating timer (%d)", err );
       
  2416         OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_STARTMAINTENANCE, "CThumbnailStore::StartMaintenance - Error creating timer ;err=%d", err );
  2260         }
  2417         }
  2261     else
  2418     else
  2262         {
  2419         {
  2263         iMaintenanceTimer->Start( KStoreMaintenancePeriodic, KStoreMaintenancePeriodic, 
  2420         iMaintenanceTimer->Start( KStoreMaintenancePeriodic, KStoreMaintenancePeriodic, 
  2264                                   TCallBack(MaintenanceTimerCallBack, this));
  2421                                   TCallBack(MaintenanceTimerCallBack, this));
  2270 // ---------------------------------------------------------------------------
  2427 // ---------------------------------------------------------------------------
  2271 //
  2428 //
  2272 TInt CThumbnailStore::AutoFlushTimerCallBack(TAny* aAny)
  2429 TInt CThumbnailStore::AutoFlushTimerCallBack(TAny* aAny)
  2273     {
  2430     {
  2274     TN_DEBUG1( "CThumbnailStore::AutoFlushTimerCallBack()");
  2431     TN_DEBUG1( "CThumbnailStore::AutoFlushTimerCallBack()");
       
  2432     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_AUTOFLUSHTIMERCALLBACK, "CThumbnailStore::AutoFlushTimerCallBack" );
  2275     CThumbnailStore* self = static_cast<CThumbnailStore*>( aAny );
  2433     CThumbnailStore* self = static_cast<CThumbnailStore*>( aAny );
  2276     
  2434     
  2277     self->FlushCacheTable(ETrue);
  2435     self->FlushCacheTable(ETrue);
  2278 
  2436 
  2279     return KErrNone; // Return value ignored by CPeriodic
  2437     return KErrNone; // Return value ignored by CPeriodic
  2293     TInt DaemonProcessing(0);
  2451     TInt DaemonProcessing(0);
  2294     TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
  2452     TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
  2295     if(ret != KErrNone || MPXHarvesting)
  2453     if(ret != KErrNone || MPXHarvesting)
  2296         {
  2454         {
  2297         TN_DEBUG3( "CThumbnailStore::MaintenanceTimerCallBack() KMPXHarvesting err == %d, MPXHarvesting == %d", ret, MPXHarvesting);
  2455         TN_DEBUG3( "CThumbnailStore::MaintenanceTimerCallBack() KMPXHarvesting err == %d, MPXHarvesting == %d", ret, MPXHarvesting);
       
  2456         OstTraceExt2( TRACE_NORMAL, CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack;ret=%d;MPXHarvesting=%d", ret, MPXHarvesting );
  2298         self->iIdle = EFalse;
  2457         self->iIdle = EFalse;
  2299         }
  2458         }
  2300     TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() KMPXHarvesting == %d", MPXHarvesting);
  2459     TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() KMPXHarvesting == %d", MPXHarvesting);
       
  2460     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack;MPXHarvesting=%d", MPXHarvesting );
  2301 
  2461 
  2302     ret = RProperty::Get(KTAGDPSNotification, KDaemonProcessing, DaemonProcessing);
  2462     ret = RProperty::Get(KTAGDPSNotification, KDaemonProcessing, DaemonProcessing);
  2303     if(ret != KErrNone || DaemonProcessing)
  2463     if(ret != KErrNone || DaemonProcessing)
  2304         {
  2464         {
  2305         TN_DEBUG3( "CThumbnailStore::MaintenanceTimerCallBack() KDaemonProcessing err == %d, DaemonProcessing == %d", ret, DaemonProcessing);
  2465         TN_DEBUG3( "CThumbnailStore::MaintenanceTimerCallBack() KDaemonProcessing err == %d, DaemonProcessing == %d", ret, DaemonProcessing);
       
  2466         OstTraceExt2( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack;ret=%d;DaemonProcessing=%d", ret, DaemonProcessing );
  2306         self->iIdle = EFalse;
  2467         self->iIdle = EFalse;
  2307         }
  2468         }
  2308     TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() DaemonProcessing == %d", DaemonProcessing);
  2469     TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() DaemonProcessing == %d", DaemonProcessing);
       
  2470     OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack;DaemonProcessing=%d", DaemonProcessing );
  2309     
  2471     
  2310     if (self->iIdle)
  2472     if (self->iIdle)
  2311         {
  2473         {
  2312         TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - maintenance, store %d", self->iDrive);
  2474         TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - maintenance, store %d", self->iDrive);
       
  2475         OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - maintenance, store;self->iDrive=%d", self->iDrive );
  2313     
  2476     
  2314         // thumbmnail deletion
  2477         // thumbmnail deletion
  2315         if (self->iDeleteThumbs)
  2478         if (self->iDeleteThumbs)
  2316             {
  2479             {
  2317             TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - cleanup");
  2480             TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - cleanup");
       
  2481             OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - cleanup" );
  2318         
  2482         
  2319             TInt deleteCount = 0;
  2483             TInt deleteCount = 0;
  2320             
  2484             
  2321             // delete marked rows from database
  2485             // delete marked rows from database
  2322             TRAPD( err, deleteCount = self->DeleteMarkedL() );
  2486             TRAPD( err, deleteCount = self->DeleteMarkedL() );
  2323             if (err != KErrNone)
  2487             if (err != KErrNone)
  2324                 {
  2488                 {
  2325                 TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - cleanup failed, err %d", err);
  2489                 TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - cleanup failed, err %d", err);
       
  2490                 OstTrace1( TRACE_NORMAL, DUP6_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - cleanup failed;err=%d", err );
  2326                 return err;
  2491                 return err;
  2327                 }
  2492                 }
  2328             
  2493             
  2329             // no more marked rows
  2494             // no more marked rows
  2330             if (deleteCount < KStoreMaintenanceDeleteLimit || deleteCount == 0)
  2495             if (deleteCount < KStoreMaintenanceDeleteLimit || deleteCount == 0)
  2331                 {
  2496                 {
  2332                 TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - cleanup finished, store %d", self->iDrive);
  2497                 TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - cleanup finished, store %d", self->iDrive);
       
  2498                 OstTrace1( TRACE_NORMAL, DUP7_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - cleanup finished, store;self->iDrive=%d", self->iDrive );
  2333                 self->iDeleteThumbs = EFalse;
  2499                 self->iDeleteThumbs = EFalse;
  2334                 }     
  2500                 }     
  2335             }
  2501             }
  2336         
  2502         
  2337         // file existence check
  2503         // file existence check
  2338         else if (self->iCheckFilesExist)
  2504         else if (self->iCheckFilesExist)
  2339             {
  2505             {
  2340             TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - file existence check");
  2506             TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - file existence check");
       
  2507             OstTrace0( TRACE_NORMAL, DUP8_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - file existence check" );
  2341         
  2508         
  2342             TBool finished = EFalse;
  2509             TBool finished = EFalse;
  2343         
  2510         
  2344             TRAPD( err, finished = self->FileExistenceCheckL() );
  2511             TRAPD( err, finished = self->FileExistenceCheckL() );
  2345             if (err != KErrNone)
  2512             if (err != KErrNone)
  2346                 {
  2513                 {
  2347                 TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - file existence check failed, err %d", err);
  2514                 TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - file existence check failed, err %d", err);
       
  2515                 OstTrace1( TRACE_NORMAL, DUP9_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - file existence check failed;err=%d", err );
  2348                 return err;
  2516                 return err;
  2349                 }
  2517                 }
  2350         
  2518         
  2351             // all files checked.
  2519             // all files checked.
  2352             if (finished)
  2520             if (finished)
  2353                 {
  2521                 {
  2354                 TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - file existence check finished, store %d", self->iDrive);
  2522                 TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - file existence check finished, store %d", self->iDrive);
       
  2523                 OstTrace1( TRACE_NORMAL, DUP10_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - file existence check finished, store;self->iDrive=%d", self->iDrive );
  2355                 self->iCheckFilesExist = EFalse;
  2524                 self->iCheckFilesExist = EFalse;
  2356                 }
  2525                 }
  2357             }
  2526             }
  2358         
  2527         
  2359         // next round
  2528         // next round
  2360         if (self->iIdle && ( self->iDeleteThumbs || self->iCheckFilesExist) )
  2529         if (self->iIdle && ( self->iDeleteThumbs || self->iCheckFilesExist) )
  2361             {
  2530             {
  2362             TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - continue maintenance");
  2531             TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - continue maintenance");
       
  2532             OstTrace0( TRACE_NORMAL, DUP11_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - continue maintenance" );
  2363             self->StartMaintenance();
  2533             self->StartMaintenance();
  2364             }  
  2534             }  
  2365         else if (!self->iDeleteThumbs && !self->iCheckFilesExist)
  2535         else if (!self->iDeleteThumbs && !self->iCheckFilesExist)
  2366             {
  2536             {
  2367             TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - no more maintenance");
  2537             TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - no more maintenance");
       
  2538             OstTrace0( TRACE_NORMAL, DUP12_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - no more maintenance" );
  2368         
  2539         
  2369             // no need to monitor activity anymore
  2540             // no need to monitor activity anymore
  2370             self->iActivityManager->Cancel();
  2541             self->iActivityManager->Cancel();
  2371             }
  2542             }
  2372         }
  2543         }
  2373     else
  2544     else
  2374         {
  2545         {
  2375         TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - device not idle");
  2546         TN_DEBUG1( "CThumbnailStore::MaintenanceTimerCallBack() - device not idle");
       
  2547         OstTrace0( TRACE_NORMAL, DUP13_CTHUMBNAILSTORE_MAINTENANCETIMERCALLBACK, "CThumbnailStore::MaintenanceTimerCallBack - device not idle" );
  2376         }
  2548         }
  2377 
  2549 
  2378     return KErrNone; // Return value ignored by CPeriodic
  2550     return KErrNone; // Return value ignored by CPeriodic
  2379     }
  2551     }
  2380 
  2552 
  2381 TBool CThumbnailStore::CheckModifiedByPathL( const TDesC& aPath, const TInt64 aModified, TBool& modifiedChanged )
  2553 TBool CThumbnailStore::CheckModifiedByPathL( const TDesC& aPath, const TInt64 aModified, TBool& modifiedChanged )
  2382     {
  2554     {
  2383     TN_DEBUG2( "CThumbnailStore::CheckModifiedByPathL() %S", &aPath);
  2555     TN_DEBUG2( "CThumbnailStore::CheckModifiedByPathL() %S", &aPath);
       
  2556     OstTraceExt1( TRACE_NORMAL, CTHUMBNAILSTORE_CHECKMODIFIEDBYPATHL, "CThumbnailStore::CheckModifiedByPathL;aPath=%S", aPath );
  2384     
  2557     
  2385     if(iReadOnly)
  2558     if(iReadOnly)
  2386     	{
  2559     	{
  2387     	TN_DEBUG1( "CThumbnailStore::CheckModifiedByPathL() read only, skip..." );
  2560     	TN_DEBUG1( "CThumbnailStore::CheckModifiedByPathL() read only, skip..." );
  2388 		modifiedChanged = EFalse;
  2561 		modifiedChanged = EFalse;
  2412     TInt rowStatus = stmt->Next();
  2585     TInt rowStatus = stmt->Next();
  2413    
  2586    
  2414     TBool checkMain = EFalse;
  2587     TBool checkMain = EFalse;
  2415    
  2588    
  2416     TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- temp" );
  2589     TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- temp" );
       
  2590     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_CHECKMODIFIEDBYPATHL, "CThumbnailStore::CheckModifiedByPathL -- temp" );
  2417    
  2591    
  2418     while(rowStatus == KSqlAtRow || !checkMain)
  2592     while(rowStatus == KSqlAtRow || !checkMain)
  2419         {
  2593         {
  2420         if(rowStatus == KSqlAtRow)
  2594         if(rowStatus == KSqlAtRow)
  2421             {
  2595             {
  2422             ret = ETrue;
  2596             ret = ETrue;
  2423             TInt64 oldModified = stmt->ColumnInt64( column );
  2597             TInt64 oldModified = stmt->ColumnInt64( column );
  2424            
  2598            
  2425             TN_DEBUG2( "CThumbnailStore::CheckModifiedL() -- timestamp old %Ld", oldModified);
  2599             TN_DEBUG2( "CThumbnailStore::CheckModifiedL() -- timestamp old %Ld", oldModified);
       
  2600             OstTraceExt1( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_CHECKMODIFIEDBYPATHL, "CThumbnailStore::CheckModifiedByPathL -- timestamp old;oldModified=%Ld", oldModified );
  2426             TN_DEBUG2( "CThumbnailStore::CheckModifiedL() -- timestamp mds %Ld", aModified);
  2601             TN_DEBUG2( "CThumbnailStore::CheckModifiedL() -- timestamp mds %Ld", aModified);
       
  2602             OstTraceExt1( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_CHECKMODIFIEDBYPATHL, "CThumbnailStore::CheckModifiedByPathL -- timestamp mds;aModified=%Ld", aModified );
  2427           
  2603           
  2428             if (oldModified < aModified)
  2604             if (oldModified < aModified)
  2429                 {
  2605                 {
  2430                 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is newer than original" );
  2606                 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is newer than original" );
       
  2607                 OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSTORE_CHECKMODIFIEDBYPATHL, "CThumbnailStore::CheckModifiedByPathL -- timestamp is newer than original" );
  2431                 modifiedChanged = ETrue;
  2608                 modifiedChanged = ETrue;
  2432                 break;
  2609                 break;
  2433                 }
  2610                 }
  2434             else if (oldModified > aModified)
  2611             else if (oldModified > aModified)
  2435                 {
  2612                 {
  2436                 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is older than original" );
  2613                 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is older than original" );
       
  2614                 OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILSTORE_CHECKMODIFIEDBYPATHL, "CThumbnailStore::CheckModifiedByPathL -- timestamp is older than original" );
  2437                 }
  2615                 }
  2438             else if (oldModified == aModified)
  2616             else if (oldModified == aModified)
  2439                 {
  2617                 {
  2440                 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is the same as original" );
  2618                 TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is the same as original" );
       
  2619                 OstTrace0( TRACE_NORMAL, DUP6_CTHUMBNAILSTORE_CHECKMODIFIEDBYPATHL, "CThumbnailStore::CheckModifiedByPathL -- timestamp is the same as original" );
  2441                 }
  2620                 }
  2442             
  2621             
  2443             rowStatus = stmt->Next();
  2622             rowStatus = stmt->Next();
  2444             }
  2623             }
  2445        
  2624        
  2446         //switch to main table if modified not found from temp
  2625         //switch to main table if modified not found from temp
  2447         if(rowStatus != KSqlAtRow && !checkMain && !modifiedChanged)
  2626         if(rowStatus != KSqlAtRow && !checkMain && !modifiedChanged)
  2448             {
  2627             {
  2449             TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- main" );
  2628             TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- main" );
       
  2629             OstTrace0( TRACE_NORMAL, DUP7_CTHUMBNAILSTORE_CHECKMODIFIEDBYPATHL, "CThumbnailStore::CheckModifiedByPathL -- main" );
  2450             //come here only once
  2630             //come here only once
  2451             checkMain = ETrue;
  2631             checkMain = ETrue;
  2452            
  2632            
  2453             CleanupStack::PopAndDestroy( stmt );
  2633             CleanupStack::PopAndDestroy( stmt );
  2454             stmt = &iStmt_KThumbnailSelectModifiedByPath;
  2634             stmt = &iStmt_KThumbnailSelectModifiedByPath;
  2483 // -----------------------------------------------------------------------------
  2663 // -----------------------------------------------------------------------------
  2484 //
  2664 //
  2485 void CThumbnailStore::PrepareBlacklistedItemsForRetryL()
  2665 void CThumbnailStore::PrepareBlacklistedItemsForRetryL()
  2486     {
  2666     {
  2487     TN_DEBUG1( "CThumbnailStore::PrepareBlacklistedItemsForRetry()" );
  2667     TN_DEBUG1( "CThumbnailStore::PrepareBlacklistedItemsForRetry()" );
       
  2668     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_PREPAREBLACKLISTEDITEMSFORRETRYL, "CThumbnailStore::PrepareBlacklistedItemsForRetryL" );
  2488     
  2669     
  2489     RSqlStatement stmt;
  2670     RSqlStatement stmt;
  2490     CleanupClosePushL( stmt );
  2671     CleanupClosePushL( stmt );
  2491 
  2672 
  2492     User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailTouchBlacklistedRows ));
  2673     User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailTouchBlacklistedRows ));
  2495     User::LeaveIfError( paramIndex );
  2676     User::LeaveIfError( paramIndex );
  2496     User::LeaveIfError( stmt.BindInt( paramIndex, KThumbnailDbFlagBlacklisted ));
  2677     User::LeaveIfError( stmt.BindInt( paramIndex, KThumbnailDbFlagBlacklisted ));
  2497     TInt err = stmt.Exec();
  2678     TInt err = stmt.Exec();
  2498    
  2679    
  2499     TN_DEBUG2( "CThumbnailStore::PrepareBlacklistedItemsForRetryL() - main table, err=%d", err );
  2680     TN_DEBUG2( "CThumbnailStore::PrepareBlacklistedItemsForRetryL() - main table, err=%d", err );
       
  2681     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_PREPAREBLACKLISTEDITEMSFORRETRYL, "CThumbnailStore::PrepareBlacklistedItemsForRetryL - main table;err=%d", err );
  2500     
  2682     
  2501     CleanupStack::PopAndDestroy( &stmt );
  2683     CleanupStack::PopAndDestroy( &stmt );
  2502     }
  2684     }
  2503 
  2685 
  2504 // -----------------------------------------------------------------------------
  2686 // -----------------------------------------------------------------------------
  2506 // -----------------------------------------------------------------------------
  2688 // -----------------------------------------------------------------------------
  2507 //
  2689 //
  2508 TInt CThumbnailStore::DeleteMarkedL()
  2690 TInt CThumbnailStore::DeleteMarkedL()
  2509     {
  2691     {
  2510     TN_DEBUG1( "CThumbnailStore::DeleteMarkedL()" );
  2692     TN_DEBUG1( "CThumbnailStore::DeleteMarkedL()" );
  2511     
  2693     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_DELETEMARKEDL, "CThumbnailStore::DeleteMarkedL" );
  2512     if(iReadOnly)
  2694     if(iReadOnly)
  2513         {
  2695         {
  2514         TN_DEBUG1( "CThumbnailStore::DeleteMarkedL() read only, skip..." );
  2696         TN_DEBUG1( "CThumbnailStore::DeleteMarkedL() read only, skip..." );
  2515         return KErrAccessDenied;
  2697         return KErrAccessDenied;
  2516         }
  2698         }
  2571        stmt_infodata->Reset();
  2753        stmt_infodata->Reset();
  2572        User::LeaveIfError( err );
  2754        User::LeaveIfError( err );
  2573        deleteCount++;
  2755        deleteCount++;
  2574        
  2756        
  2575        TN_DEBUG1( "CThumbnailStore::DeleteMarkedL() - thumbnail deleted" );
  2757        TN_DEBUG1( "CThumbnailStore::DeleteMarkedL() - thumbnail deleted" );
       
  2758        OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_DELETEMARKEDL, "CThumbnailStore::DeleteMarkedL - thumbnail deleted" );
  2576        
  2759        
  2577        rowStatus = stmt->Next();
  2760        rowStatus = stmt->Next();
  2578        }
  2761        }
  2579         
  2762         
  2580     CleanupStack::PopAndDestroy( stmt_infodata );
  2763     CleanupStack::PopAndDestroy( stmt_infodata );
  2590     transaction.CommitL();
  2773     transaction.CommitL();
  2591     CleanupStack::PopAndDestroy( &transaction );
  2774     CleanupStack::PopAndDestroy( &transaction );
  2592     
  2775     
  2593 #ifdef _DEBUG
  2776 #ifdef _DEBUG
  2594     aStop.UniversalTime();
  2777     aStop.UniversalTime();
       
  2778     TInt tookTime = (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000;
  2595     TN_DEBUG2( "CThumbnailStore::DeleteMarkedL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
  2779     TN_DEBUG2( "CThumbnailStore::DeleteMarkedL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
       
  2780     OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_DELETEMARKEDL, "CThumbnailStore::DeleteMarkedL - took ms;tookTime=%d", tookTime );
  2596 #endif
  2781 #endif
  2597     
  2782     
  2598     return deleteCount;
  2783     return deleteCount;
  2599     }
  2784     }
  2600 
  2785 
  2603 // -----------------------------------------------------------------------------
  2788 // -----------------------------------------------------------------------------
  2604 //
  2789 //
  2605 TInt CThumbnailStore::FileExistenceCheckL()
  2790 TInt CThumbnailStore::FileExistenceCheckL()
  2606     {
  2791     {
  2607     TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL()" );
  2792     TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL()" );
  2608 	
  2793     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_FILEEXISTENCECHECKL, "CThumbnailStore::FileExistenceCheckL" );
  2609     if(iReadOnly)
  2794     if(iReadOnly)
  2610 		{
  2795 		{
  2611 		TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL() read only, skip..." );
  2796 		TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL() read only, skip..." );
  2612 		return ETrue;
  2797 		return ETrue;
  2613 		}
  2798 		}
  2694     transaction.CommitL();
  2879     transaction.CommitL();
  2695     CleanupStack::PopAndDestroy( &transaction );
  2880     CleanupStack::PopAndDestroy( &transaction );
  2696     
  2881     
  2697 #ifdef _DEBUG
  2882 #ifdef _DEBUG
  2698     aStop.UniversalTime();
  2883     aStop.UniversalTime();
       
  2884     TInt tookTime = (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000;
  2699     TN_DEBUG2( "CThumbnailStore::FileExistenceCheckL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
  2885     TN_DEBUG2( "CThumbnailStore::FileExistenceCheckL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
       
  2886     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_FILEEXISTENCECHECKL, "CThumbnailStore::FileExistenceCheckL - took ms;tookTime=%d", tookTime );
  2700 #endif
  2887 #endif
  2701     
  2888     
  2702     return finished;
  2889     return finished;
  2703     }
  2890     }
  2704 
  2891 
  2734 TInt CThumbnailStore::CheckDbState()
  2921 TInt CThumbnailStore::CheckDbState()
  2735     {
  2922     {
  2736     if (iUnrecoverable && !iReadOnly)
  2923     if (iUnrecoverable && !iReadOnly)
  2737         {
  2924         {
  2738         TN_DEBUG1( "CThumbnailStore::CheckDbState() - database in unrecoverable state" );
  2925         TN_DEBUG1( "CThumbnailStore::CheckDbState() - database in unrecoverable state" );
       
  2926         OstTrace0( TRACE_NORMAL, CTHUMBNAILSTORE_CHECKDBSTATE, "CThumbnailStore::CheckDbState" );
  2739         __ASSERT_DEBUG( !iUnrecoverable, ThumbnailPanic( EThumbnailDatabaseUnrecoverable ));
  2927         __ASSERT_DEBUG( !iUnrecoverable, ThumbnailPanic( EThumbnailDatabaseUnrecoverable ));
  2740         
  2928         
  2741         return KStoreUnrecoverableErr;
  2929         return KStoreUnrecoverableErr;
  2742         }
  2930         }
  2743     else
  2931     else
  2747     }
  2935     }
  2748 
  2936 
  2749 void CThumbnailStore::HandleDiskSpaceNotificationL( TBool aDiskFull )
  2937 void CThumbnailStore::HandleDiskSpaceNotificationL( TBool aDiskFull )
  2750     {
  2938     {
  2751     TN_DEBUG2( "CThumbnailStore::HandleDiskSpaceNotificationL() aDiskFull = %d", aDiskFull );
  2939     TN_DEBUG2( "CThumbnailStore::HandleDiskSpaceNotificationL() aDiskFull = %d", aDiskFull );
       
  2940     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTORE_HANDLEDISKSPACENOTIFICATIONL, "CThumbnailStore::HandleDiskSpaceNotificationL;aDiskFull=%u", aDiskFull );
  2752     iDiskFull = aDiskFull;
  2941     iDiskFull = aDiskFull;
  2753     }
  2942     }
  2754 
  2943 
  2755 #ifdef _DEBUG
  2944 #ifdef _DEBUG
  2756 void CThumbnailStore::HandleDiskSpaceError(TInt aError )
  2945 void CThumbnailStore::HandleDiskSpaceError(TInt aError )
  2757 #else
  2946 #else
  2758 void CThumbnailStore::HandleDiskSpaceError(TInt /*aError*/ )
  2947 void CThumbnailStore::HandleDiskSpaceError(TInt /*aError*/ )
  2759 #endif
  2948 #endif
  2760     {
  2949     {
  2761     TN_DEBUG2( "CThumbnailStore::HandleDiskSpaceError() aError = %d", aError );
  2950     TN_DEBUG2( "CThumbnailStore::HandleDiskSpaceError() aError = %d", aError );
       
  2951 #ifdef _DEBUG
       
  2952     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTORE_HANDLEDISKSPACEERROR, "CThumbnailStore::HandleDiskSpaceError;aError=%d", aError );
       
  2953 #endif
  2762     }
  2954     }
  2763 
  2955 
  2764 TBool CThumbnailStore::IsDiskFull()
  2956 TBool CThumbnailStore::IsDiskFull()
  2765     {
  2957     {
  2766     if(iReadOnly)
  2958     if(iReadOnly)
  2776 // -----------------------------------------------------------------------------
  2968 // -----------------------------------------------------------------------------
  2777 //
  2969 //
  2778 void CThumbnailStore::ActivityChanged(const TBool aActive)
  2970 void CThumbnailStore::ActivityChanged(const TBool aActive)
  2779     {
  2971     {
  2780     TN_DEBUG2( "CThumbnailStore::ActivityChanged() aActive == %d", aActive);
  2972     TN_DEBUG2( "CThumbnailStore::ActivityChanged() aActive == %d", aActive);
  2781     
  2973     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTORE_ACTIVITYCHANGED, "CThumbnailStore::ActivityChanged;aActive=%u", aActive );
  2782     if( iReadOnly )
  2974     if( iReadOnly )
  2783         {
  2975         {
  2784         TN_DEBUG1( "CThumbnailStore::ActivityChanged() read only, skip..." );
  2976         TN_DEBUG1( "CThumbnailStore::ActivityChanged() read only, skip..." );
  2785         return;
  2977         return;
  2786         }
  2978         }
  2796         
  2988         
  2797         TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
  2989         TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
  2798         if(ret != KErrNone || MPXHarvesting)
  2990         if(ret != KErrNone || MPXHarvesting)
  2799             {
  2991             {
  2800             TN_DEBUG3( "CThumbnailStore::ActivityChanged() KMPXHarvesting err == %d, MPXHarvesting == %d", ret, MPXHarvesting);
  2992             TN_DEBUG3( "CThumbnailStore::ActivityChanged() KMPXHarvesting err == %d, MPXHarvesting == %d", ret, MPXHarvesting);
       
  2993             OstTraceExt2( TRACE_NORMAL, DUP1_CTHUMBNAILSTORE_ACTIVITYCHANGED, "CThumbnailStore::ActivityChanged;ret=%d;MPXHarvesting=%d", ret, MPXHarvesting );
  2801             iIdle = EFalse;
  2994             iIdle = EFalse;
  2802             return;
  2995             return;
  2803             }
  2996             }
  2804         
  2997         
  2805         ret = RProperty::Get(KTAGDPSNotification, KDaemonProcessing, DaemonProcessing);
  2998         ret = RProperty::Get(KTAGDPSNotification, KDaemonProcessing, DaemonProcessing);
  2806         if(ret != KErrNone || DaemonProcessing)
  2999         if(ret != KErrNone || DaemonProcessing)
  2807             {
  3000             {
  2808             TN_DEBUG3( "CThumbnailStore::ActivityChanged() KDaemonProcessing err == %d DaemonProcessing == %d", ret, DaemonProcessing );
  3001             TN_DEBUG3( "CThumbnailStore::ActivityChanged() KDaemonProcessing err == %d DaemonProcessing == %d", ret, DaemonProcessing );
       
  3002             OstTraceExt2( TRACE_NORMAL, DUP2_CTHUMBNAILSTORE_ACTIVITYCHANGED, "CThumbnailStore::ActivityChanged - KDaemonProcessing;ret=%d;DaemonProcessing=%d", ret, DaemonProcessing );
  2809             iIdle = EFalse;
  3003             iIdle = EFalse;
  2810             return;
  3004             return;
  2811             }
  3005             }
  2812         
  3006         
  2813         TN_DEBUG1( "CThumbnailStore::ActivityChanged() - starting maintenance");
  3007         TN_DEBUG1( "CThumbnailStore::ActivityChanged() - starting maintenance");
       
  3008         OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILSTORE_ACTIVITYCHANGED, "CThumbnailStore::ActivityChanged - starting maintenance" );
  2814         iIdle = ETrue;
  3009         iIdle = ETrue;
  2815         StartMaintenance();
  3010         StartMaintenance();
  2816         }
  3011         }
  2817     }
  3012     }
  2818 
  3013 
  2843     }
  3038     }
  2844 
  3039 
  2845 TDriveNumber CThumbnailStoreDiskSpaceNotifierAO::GetDriveNumberL( const TDesC& aFilename )
  3040 TDriveNumber CThumbnailStoreDiskSpaceNotifierAO::GetDriveNumberL( const TDesC& aFilename )
  2846     {
  3041     {
  2847     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::GetDriveNumberL()");
  3042     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::GetDriveNumberL()");
       
  3043     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTOREDISKSPACENOTIFIERAO_GETDRIVENUMBERL, "CThumbnailStoreDiskSpaceNotifierAO::GetDriveNumberL" );
  2848     TLex driveParser( aFilename );
  3044     TLex driveParser( aFilename );
  2849     
  3045     
  2850     TChar driveChar = driveParser.Get();
  3046     TChar driveChar = driveParser.Get();
  2851 
  3047 
  2852     if( 0 == driveChar || TChar( ':' ) != driveParser.Peek() )
  3048     if( 0 == driveChar || TChar( ':' ) != driveParser.Peek() )
  2853         {
  3049         {
  2854         TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::GetDriveNumberL() KErrArgument");
  3050         TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::GetDriveNumberL() KErrArgument");
       
  3051         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_GETDRIVENUMBERL, "CThumbnailStoreDiskSpaceNotifierAO::GetDriveNumberL - KErrArgument" );
  2855         User::Leave( KErrArgument );
  3052         User::Leave( KErrArgument );
  2856         }
  3053         }
  2857         
  3054         
  2858     TInt driveNumber;
  3055     TInt driveNumber;
  2859     
  3056     
  2863     }
  3060     }
  2864 
  3061 
  2865 CThumbnailStoreDiskSpaceNotifierAO::~CThumbnailStoreDiskSpaceNotifierAO()
  3062 CThumbnailStoreDiskSpaceNotifierAO::~CThumbnailStoreDiskSpaceNotifierAO()
  2866     {
  3063     {
  2867     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::~CThumbnailStoreDiskSpaceNotifierAO()");
  3064     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::~CThumbnailStoreDiskSpaceNotifierAO()");
       
  3065     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTOREDISKSPACENOTIFIERAO_CTHUMBNAILSTOREDISKSPACENOTIFIERAO, "CThumbnailStoreDiskSpaceNotifierAO::~CThumbnailStoreDiskSpaceNotifierAO" );
  2868     Cancel();
  3066     Cancel();
  2869 
  3067 
  2870     iFileServerSession.Close();
  3068     iFileServerSession.Close();
  2871     }
  3069     }
  2872 
  3070 
  2873 void CThumbnailStoreDiskSpaceNotifierAO::RunL()
  3071 void CThumbnailStoreDiskSpaceNotifierAO::RunL()
  2874     {   
  3072     {   
  2875     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL()");
  3073     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL()");
       
  3074     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNL, "CThumbnailStoreDiskSpaceNotifierAO::RunL" );
  2876     TVolumeInfo volumeInfo;
  3075     TVolumeInfo volumeInfo;
  2877 
  3076 
  2878     if ( iState == CThumbnailStoreDiskSpaceNotifierAO::ENormal )
  3077     if ( iState == CThumbnailStoreDiskSpaceNotifierAO::ENormal )
  2879         {
  3078         {
  2880         TInt status = iStatus.Int();
  3079         TInt status = iStatus.Int();
  2890                     {                  
  3089                     {                  
  2891                     // Check if free space is less than threshold level
  3090                     // Check if free space is less than threshold level
  2892                     if( volumeInfo.iFree < iThreshold )
  3091                     if( volumeInfo.iFree < iThreshold )
  2893                         {
  3092                         {
  2894                         TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() FULL");
  3093                         TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() FULL");
       
  3094                         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNL, "CThumbnailStoreDiskSpaceNotifierAO::RunL - FULL" );
  2895                         iDiskFull = ETrue;
  3095                         iDiskFull = ETrue;
  2896                         iObserver.HandleDiskSpaceNotificationL( iDiskFull );
  3096                         iObserver.HandleDiskSpaceNotificationL( iDiskFull );
  2897                         iState = EIterate;
  3097                         iState = EIterate;
  2898                         iIterationCount = 0;
  3098                         iIterationCount = 0;
  2899                         SetActive();
  3099                         SetActive();
  2902                         return;
  3102                         return;
  2903                         }
  3103                         }
  2904                     else
  3104                     else
  2905                         {
  3105                         {
  2906                         TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() NOT FULL");
  3106                         TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() NOT FULL");
       
  3107                         OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNL, "CThumbnailStoreDiskSpaceNotifierAO::RunL - NOT FULL" );
  2907                         iDiskFull = EFalse;
  3108                         iDiskFull = EFalse;
  2908                         iObserver.HandleDiskSpaceNotificationL( iDiskFull );
  3109                         iObserver.HandleDiskSpaceNotificationL( iDiskFull );
  2909                         }
  3110                         }
  2910                     }
  3111                     }
  2911                 else
  3112                 else
  2912                     {
  3113                     {
  2913                     TN_DEBUG2( "CThumbnailStoreDiskSpaceNotifierAO::RunL() error %d NOT FULL", ret);
  3114                     TN_DEBUG2( "CThumbnailStoreDiskSpaceNotifierAO::RunL() error %d NOT FULL", ret);
       
  3115                     OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNL, "CThumbnailStoreDiskSpaceNotifierAO::RunL - NOT FULL;ret=%d", ret );
  2914                     iDiskFull = EFalse;
  3116                     iDiskFull = EFalse;
  2915                     iObserver.HandleDiskSpaceNotificationL( iDiskFull );
  3117                     iObserver.HandleDiskSpaceNotificationL( iDiskFull );
  2916                     User::Leave( ret );
  3118                     User::Leave( ret );
  2917                     }
  3119                     }
  2918                 
  3120                 
  2919                 StartNotifier();
  3121                 StartNotifier();
  2920                 break;
  3122                 break;
  2921 
  3123 
  2922             case KErrArgument:
  3124             case KErrArgument:
  2923                 TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() KErrArgument");
  3125                 TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() KErrArgument");
       
  3126                 OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNL, "CThumbnailStoreDiskSpaceNotifierAO::RunL - KErrArgument" );
  2924                 User::Leave( status );
  3127                 User::Leave( status );
  2925                 break;
  3128                 break;
  2926             default:
  3129             default:
  2927                 break;
  3130                 break;
  2928             }
  3131             }
  2947                 {
  3150                 {
  2948                 User::LeaveIfError( iFileServerSession.Volume( volumeInfo, iDrive ) );
  3151                 User::LeaveIfError( iFileServerSession.Volume( volumeInfo, iDrive ) );
  2949                 if ( volumeInfo.iFree >= iThreshold )
  3152                 if ( volumeInfo.iFree >= iThreshold )
  2950                     {
  3153                     {
  2951                     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() NOT FULL");
  3154                     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() NOT FULL");
       
  3155                     OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNL, "CThumbnailStoreDiskSpaceNotifierAO::RunL - NOT FULL" );
  2952                     iDiskFull = EFalse;
  3156                     iDiskFull = EFalse;
  2953                     }
  3157                     }
  2954                 }
  3158                 }
  2955             }
  3159             }
  2956         else
  3160         else
  2957             {
  3161             {
  2958             TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() NOT FULL");
  3162             TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() NOT FULL");
       
  3163             OstTrace0( TRACE_NORMAL, DUP6_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNL, "CThumbnailStoreDiskSpaceNotifierAO::RunL - NOT FULL" );
  2959             iDiskFull = EFalse;
  3164             iDiskFull = EFalse;
  2960             }
  3165             }
  2961         iState = ENormal;
  3166         iState = ENormal;
  2962         iIterationCount = 0;
  3167         iIterationCount = 0;
  2963         StartNotifier();            
  3168         StartNotifier();            
  2964         }
  3169         }
  2965     else
  3170     else
  2966         {
  3171         {
  2967         TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() KErrGeneral");
  3172         TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() KErrGeneral");
       
  3173         OstTrace0( TRACE_NORMAL, DUP7_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNL, "CThumbnailStoreDiskSpaceNotifierAO::RunL - KErrGeneral" );
  2968         User::Leave( KErrGeneral );
  3174         User::Leave( KErrGeneral );
  2969         }
  3175         }
  2970     }
  3176     }
  2971 
  3177 
  2972 TInt CThumbnailStoreDiskSpaceNotifierAO::RunError(TInt aError)
  3178 TInt CThumbnailStoreDiskSpaceNotifierAO::RunError(TInt aError)
  2973     {
  3179     {
  2974     TN_DEBUG2( "CThumbnailStoreDiskSpaceNotifierAO::RunError() %d", aError);
  3180     TN_DEBUG2( "CThumbnailStoreDiskSpaceNotifierAO::RunError() %d", aError);
       
  3181     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTOREDISKSPACENOTIFIERAO_RUNERROR, "CThumbnailStoreDiskSpaceNotifierAO::RunError;aError=%d", aError );
  2975     
  3182     
  2976     iObserver.HandleDiskSpaceError( aError );
  3183     iObserver.HandleDiskSpaceError( aError );
  2977     
  3184     
  2978     return KErrNone;
  3185     return KErrNone;
  2979     }
  3186     }
  2980 
  3187 
  2981 void CThumbnailStoreDiskSpaceNotifierAO::DoCancel()
  3188 void CThumbnailStoreDiskSpaceNotifierAO::DoCancel()
  2982     {
  3189     {
  2983     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::DoCancel()");
  3190     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::DoCancel()");
       
  3191     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTOREDISKSPACENOTIFIERAO_DOCANCEL, "CThumbnailStoreDiskSpaceNotifierAO::DoCancel" );
  2984     
  3192     
  2985     if( IsActive() )
  3193     if( IsActive() )
  2986         {   
  3194         {   
  2987         iFileServerSession.NotifyDiskSpaceCancel();
  3195         iFileServerSession.NotifyDiskSpaceCancel();
  2988         }
  3196         }
  2992     MThumbnailStoreDiskSpaceNotifierObserver& aObserver, TInt64 aThreshold, const TDriveNumber aDrive)
  3200     MThumbnailStoreDiskSpaceNotifierObserver& aObserver, TInt64 aThreshold, const TDriveNumber aDrive)
  2993     : CActive( CActive::EPriorityStandard ), 
  3201     : CActive( CActive::EPriorityStandard ), 
  2994     iObserver( aObserver ), iThreshold( aThreshold ), iDrive( aDrive ), iState( CThumbnailStoreDiskSpaceNotifierAO::ENormal ), iDiskFull( EFalse )
  3202     iObserver( aObserver ), iThreshold( aThreshold ), iDrive( aDrive ), iState( CThumbnailStoreDiskSpaceNotifierAO::ENormal ), iDiskFull( EFalse )
  2995     {
  3203     {
  2996     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::CThumbnailStoreDiskSpaceNotifierAO()");
  3204     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::CThumbnailStoreDiskSpaceNotifierAO()");
       
  3205     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_CTHUMBNAILSTOREDISKSPACENOTIFIERAO, "CThumbnailStoreDiskSpaceNotifierAO::CThumbnailStoreDiskSpaceNotifierAO" );
  2997     CActiveScheduler::Add( this );
  3206     CActiveScheduler::Add( this );
  2998     }
  3207     }
  2999 
  3208 
  3000 void CThumbnailStoreDiskSpaceNotifierAO::ConstructL()
  3209 void CThumbnailStoreDiskSpaceNotifierAO::ConstructL()
  3001     {   
  3210     {   
  3002     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::ConstructL()");
  3211     TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::ConstructL()");
       
  3212     OstTrace0( TRACE_NORMAL, CTHUMBNAILSTOREDISKSPACENOTIFIERAO_CONSTRUCTL, "CThumbnailStoreDiskSpaceNotifierAO::ConstructL" );
  3003     TInt KMessageSlotCount = 2; // slots for NotifyDiskSpace and NotifyDiskSpaceCancel
  3213     TInt KMessageSlotCount = 2; // slots for NotifyDiskSpace and NotifyDiskSpaceCancel
  3004 
  3214 
  3005     User::LeaveIfError( iFileServerSession.Connect( KMessageSlotCount ) );
  3215     User::LeaveIfError( iFileServerSession.Connect( KMessageSlotCount ) );
  3006     
  3216     
  3007     TVolumeInfo volumeInfo;
  3217     TVolumeInfo volumeInfo;
  3010     if( !ret )
  3220     if( !ret )
  3011         {
  3221         {
  3012         if ( volumeInfo.iFree < iThreshold )
  3222         if ( volumeInfo.iFree < iThreshold )
  3013             {
  3223             {
  3014             TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::ConstructL() FULL");
  3224             TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::ConstructL() FULL");
       
  3225             OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_CONSTRUCTL, "CThumbnailStoreDiskSpaceNotifierAO::ConstructL - FULL" );
  3015             iDiskFull = ETrue;
  3226             iDiskFull = ETrue;
  3016             }
  3227             }
  3017         }
  3228         }
  3018     else
  3229     else
  3019         {
  3230         {
  3020         TN_DEBUG2( "CThumbnailStoreDiskSpaceNotifierAO::ConstructL() error %d NOT FULL", ret);
  3231         TN_DEBUG2( "CThumbnailStoreDiskSpaceNotifierAO::ConstructL() error %d NOT FULL", ret);
       
  3232         OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSTOREDISKSPACENOTIFIERAO_CONSTRUCTL, "CThumbnailStoreDiskSpaceNotifierAO::ConstructL - NOT FULL;ret=%d", ret );
  3021         iDiskFull = EFalse;
  3233         iDiskFull = EFalse;
  3022         User::Leave( ret );
  3234         User::Leave( ret );
  3023         }
  3235         }
  3024 
  3236 
  3025     iObserver.HandleDiskSpaceNotificationL( iDiskFull );
  3237     iObserver.HandleDiskSpaceNotificationL( iDiskFull );
  3028     }
  3240     }
  3029 
  3241 
  3030 void CThumbnailStoreDiskSpaceNotifierAO::StartNotifier()
  3242 void CThumbnailStoreDiskSpaceNotifierAO::StartNotifier()
  3031     {   
  3243     {   
  3032     TN_DEBUG2( "CThumbnailStoreDiskSpaceNotifierAO::StartNotifier() iDrive == %d", iDrive);
  3244     TN_DEBUG2( "CThumbnailStoreDiskSpaceNotifierAO::StartNotifier() iDrive == %d", iDrive);
       
  3245     OstTrace1( TRACE_NORMAL, CTHUMBNAILSTOREDISKSPACENOTIFIERAO_STARTNOTIFIER, "CThumbnailStoreDiskSpaceNotifierAO::StartNotifier;iDrive=%d", iDrive );
  3033     iFileServerSession.NotifyDiskSpace( iThreshold, iDrive, iStatus );
  3246     iFileServerSession.NotifyDiskSpace( iThreshold, iDrive, iStatus );
  3034     
  3247     
  3035     SetActive();
  3248     SetActive();
  3036     }
  3249     }
  3037 
  3250