# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1270062289 -10800 # Node ID dea39715fc05ed9d6a304a3ef6e6c6ce72b79e1c # Parent 7403edfcf0fb76a2ab6bd3b73c54087e938ea54f Revision: 201011 Kit: 201013 diff -r 7403edfcf0fb -r dea39715fc05 imagehandlinglib/Src/CIHLScaler.cpp --- a/imagehandlinglib/Src/CIHLScaler.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlinglib/Src/CIHLScaler.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -1237,7 +1237,7 @@ { // TODO: optimize bilinear scaling IHL_DEBUG("CIHLScaler::InitCodePath: slow bilinear"); - ProcessingFunc = CIHLScaler::ProcessBilinear; + ProcessingFunc = &CIHLScaler::ProcessBilinear; iScanlinesPerRound = KProcessPixelsPerStep / iProcessSize.iWidth; } else if(aSrcMode == EColor64K && aSrcMode==aDstMode && !iSrcBitmap->IsCompressedInRAM() && !iDstBitmap->IsCompressedInRAM()) diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.h --- a/imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.h Wed Mar 31 22:04:49 2010 +0300 @@ -30,8 +30,8 @@ EThumbnailNullPointer = 0, EThumbnailBadSize = 1, EThumbnailBadBitmapHandle = 2, EThumbnailBadPath = 3, EThumbnailUnknownMessage = 4, EThumbnailMessageNotCompleted = 5, EThumbnailBitmapNotReleased = 6, - EThumbnailEmptyDescriptor = 7, EThumbnailWrongId = 8, EAlreadyRunning = - 10 + EThumbnailEmptyDescriptor = 7, EThumbnailWrongId = 8, EThumbnailAlreadyRunning = + 9, EThumbnailDatabaseUnrecoverable = 10 }; /** diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp --- a/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -132,8 +132,14 @@ "EFullyScaleable not set for image - loadSize=(%d,%d) reduction=1/%d ", loadSize.iWidth, loadSize.iHeight, reductionFactor ); } - User::LeaveIfError( iBitmap->Create( loadSize, aDisplayMode )); - + TInt err = iBitmap->Create( loadSize, aDisplayMode ); + if (err != KErrNone) + { + delete iBitmap; + iBitmap = NULL; + User::Leave(err); + } + iDecoder->Convert( &iStatus, * iBitmap ); while ( iStatus == KErrUnderflow ) { diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp --- a/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -166,7 +166,6 @@ //Size in both x and y dimension must be non-zero, positive value TSize loadSize( iOriginalSize) ; - if(iOriginalSize.iHeight < iSize.iHeight || iOriginalSize.iWidth < iSize.iWidth ) { loadSize = iOriginalSize; @@ -225,7 +224,13 @@ "CThumbnailImageDecoder::DecodeL() - loadSize = (%d,%d) reduction = 1/%d ", loadSize.iWidth, loadSize.iHeight, reductionFactor ); } - User::LeaveIfError( iBitmap->Create( loadSize, aDisplayMode )); + TInt err = iBitmap->Create( loadSize, aDisplayMode ); + if (err != KErrNone) + { + delete iBitmap; + iBitmap = NULL; + User::Leave(err); + } iDecoder->Convert( &iStatus, * iBitmap ); while ( iStatus == KErrUnderflow ) diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp --- a/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -84,8 +84,14 @@ } //set displaymode from global constants - User::LeaveIfError( iBitmap->Create( iDecoder->FrameInfo().iOverallSizeInPixels, iDecoder->FrameInfo().iFrameDisplayMode) ); - + TInt err = iBitmap->Create( iDecoder->FrameInfo().iOverallSizeInPixels, iDecoder->FrameInfo().iFrameDisplayMode); + if (err != KErrNone) + { + delete iBitmap; + iBitmap = NULL; + User::Leave(err); + } + iDecoder->Convert( &iStatus, * iBitmap ); while ( iStatus == KErrUnderflow ) { diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.2_SA_S60.50_Euro1.sis Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.2_SA_S60.50_Euro1.sis has changed diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.3_SA_S60.50_Euro1.sis Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.3_SA_S60.50_Euro1.sis has changed diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.4_SA_S60.50_Euro1.sis Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.4_SA_S60.50_Euro1.sis has changed diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg --- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg Wed Mar 31 22:04:49 2010 +0300 @@ -17,7 +17,7 @@ &EN ; Header -#{"Thumbnail Manager"},(0x102830AB), 9, 20, 3, TYPE=SA, RU +#{"Thumbnail Manager"},(0x102830AB), 9, 20, 4, TYPE=SA, RU ; Localised Vendor name %{"Nokia"} diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg --- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg Wed Mar 31 22:04:49 2010 +0300 @@ -17,7 +17,7 @@ &EN ; Header -#{"ThumbnailManager"},(0x102830AB), 9, 20, 3, TYPE=SA +#{"ThumbnailManager"},(0x102830AB), 9, 20, 4, TYPE=SA ; Localised Vendor name %{"Nokia"} diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/thumbnailmanager_stub.sis Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/thumbnailmanager_stub.sis has changed diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg --- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg Wed Mar 31 22:04:49 2010 +0300 @@ -17,7 +17,7 @@ &EN ; Header -#{"Thumbnail Manager Cenrep"},(0x10202BE9), 9, 20, 3, TYPE=SP +#{"Thumbnail Manager Cenrep"},(0x10202BE9), 9, 20, 4, TYPE=SP ; Localised Vendor name %{"Symbian Software Ltd."} diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagformatobserver.h --- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagformatobserver.h Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Monitors File system for Format events -* -*/ - - -#ifndef CTHUMBAGFORMATOBSERVER_H -#define CTHUMBAGFORMATOBSERVER_H - -#include -#include "f32file.h" -#include "thumbagprocessor.h" - -/** - * File System monitor class to monitor for format events - * - * @lib thumbnailsserver.exe - * @since S60 3.0 - */ -NONSHARABLE_CLASS( CThumbAGFormatObserver ) : public CBase, - public MBackupOperationObserver - { - -public: - - /** - * Two-phase constructor - * @param aObserver observer to the monitor - */ - static CThumbAGFormatObserver* NewL( CThumbAGProcessor* aProcessor ); - - /** - * Two-phase constructor - * @param aObserver observer to the monitor - */ - static CThumbAGFormatObserver* NewLC( CThumbAGProcessor* aProcessor ); - - /** - * Destructor - */ - virtual ~CThumbAGFormatObserver(); - -public: // New functions - - /** - * Polls for the current monitor status - * If an event is happening, it will callback the observer of the event - */ - void PollStatus(); - -protected: // Base Class - - /* - * From MBackupOperationObserver - * Notifies this class of the backup event. - * MMC App will signal a start / end. - */ - void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes); - -private: - - /** - * C++ constructor - * aObserver observer to this event - */ - CThumbAGFormatObserver ( CThumbAGProcessor* aProcessor ); - - /* - * Second phased constructor - */ - void ConstructL(); - -private: // data - - CThumbAGProcessor* iProcessor; - - CBaBackupSessionWrapper* iBackupSession; - - - }; - -#endif // CTHUMBAGFORMATOBSERVER_H diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumblog.h --- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumblog.h Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* -* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Log commands -* -*/ - - -#ifndef THUMBLOG_H -#define THUMBLOG_H - -#include -#include - -#ifdef _DEBUG - -#define WLOG(a) RDebug::Print(_L(a)) -#define WLOG1(a,b) RDebug::Print(_L(a),(b)) -#define WLOG2(a,b,c) RDebug::Print(_L(a),(b),(c)) -#define WLOG3(a,b,c,d) RDebug::Print(_L(a),(b),(c),(d)) - -#define HLOG(a) RDebug::Print((a)) -#define HLOG1(a, b) RDebug::Print((a), (b)) -#define HLOG2(a, b, c) RDebug::Print((a), (b), (c)) -#define HLOG3(a, b, c, d) RDebug::Print((a), (b), (c), (d)) -#define HLOG4(a, b, c, d, e) RDebug::Print((a), (b), (c), (d), (e)) -#define HLOG5(a, b, c, d, e, f) RDebug::Print((a), (b), (c), (d), (e), (f)) - -#else - -#define WLOG(a) -#define WLOG1(a,b) -#define WLOG2(a,b,c) -#define WLOG3(a,b,c,d) - -#define HLOG(a) -#define HLOG1(a, b) -#define HLOG2(a, b, c) -#define HLOG3(a, b, c, d) -#define HLOG4(a, b, c, d, e) -#define HLOG5(a, b, c, d, e, f) - -#endif - -#endif // THUMBLOG_H diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -85,8 +85,6 @@ #endif InitializeL(); - - iReconnect = CPeriodic::NewL(CActive::EPriorityIdle); TN_DEBUG1( "CThumbAGDaemon::ConstructL() - end" ); } @@ -128,6 +126,12 @@ iProcessor = CThumbAGProcessor::NewL(); + // MDS session reconnect timer + if (!iReconnect) + { + iReconnect = CPeriodic::NewL(CActive::EPriorityIdle); + } + TN_DEBUG1( "CThumbAGDaemon::InitializeL() - connect to MDS" ); if(iMdESession) @@ -190,7 +194,7 @@ #endif //present observer - TRAP_IGNORE(iMdESession->RemoveObjectPresentObserverL( * this )); + TRAP_IGNORE( iMdESession->RemoveObjectPresentObserverL( *this ) ); delete iMdESession; iMdESession = NULL; diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagformatobserver.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagformatobserver.cpp Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: File System format monitor -* -*/ - -#include "thumbagformatobserver.h" -#include "thumbnaillog.h" - -#include -#include - - -// ======== MEMBER FUNCTIONS ======== - -CThumbAGFormatObserver::CThumbAGFormatObserver ( CThumbAGProcessor* aProcessor): - iProcessor( aProcessor ) - { - TN_DEBUG1( "CThumbAGFormatObserver::CThumbAGFormatObserver()"); - - } - - -// --------------------------------------------------------------------------- -// Second Phase Constructor -// --------------------------------------------------------------------------- -// -void CThumbAGFormatObserver::ConstructL() - { - TN_DEBUG1("CThumbAGFormatObserver::ConstructL in"); - - iBackupSession = CBaBackupSessionWrapper::NewL(); - iBackupSession->RegisterBackupOperationObserverL( *this ); - - - TN_DEBUG1("CThumbAGFormatObserver::ConstructL out"); - } - - -// --------------------------------------------------------------------------- -// Two-Phased Constructor -// --------------------------------------------------------------------------- -// -CThumbAGFormatObserver* CThumbAGFormatObserver::NewL(CThumbAGProcessor* aProcessor ) - { - CThumbAGFormatObserver* self = CThumbAGFormatObserver::NewLC( aProcessor ); - CleanupStack::Pop( self ); - return self; - } - - -// --------------------------------------------------------------------------- -// Two-Phased Constructor -// --------------------------------------------------------------------------- -// -CThumbAGFormatObserver* CThumbAGFormatObserver::NewLC( CThumbAGProcessor* aProcessor ) - { - CThumbAGFormatObserver* self = new( ELeave ) CThumbAGFormatObserver( aProcessor ); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - - -// --------------------------------------------------------------------------- -// destructor -// --------------------------------------------------------------------------- -// -CThumbAGFormatObserver::~CThumbAGFormatObserver() - { - - if( iBackupSession ) - { - iBackupSession->DeRegisterBackupOperationObserver( *this ); - } - delete iBackupSession; - } - -// --------------------------------------------------------------------------- -// Checks the current status -// --------------------------------------------------------------------------- -// -void CThumbAGFormatObserver::PollStatus() - { - - TN_DEBUG1("CThumbAGFormatObserver::PollStatus()"); - - TBool formatting = iBackupSession->IsBackupOperationRunning(); - - if( formatting ) - { - iProcessor->SetFormat(ETrue); - } - } - -// --------------------------------------------------------------------------- -// CThumbnailFormatObserver::HandleBackupOperationEventL -// Handles a format operation -// --------------------------------------------------------------------------- -// -void CThumbAGFormatObserver::HandleBackupOperationEventL( - const TBackupOperationAttributes& aBackupOperationAttributes) - { - TN_DEBUG1("CThumbAGFormatObserver::HandleBackupOperationEventL in"); - - if( aBackupOperationAttributes.iOperation == EStart ) - { - iProcessor->SetFormat(ETrue); - } - else // TOperationType::EEnd or TOperationType::EAbort - { - iProcessor->SetFormat(EFalse); - } - - TN_DEBUG1("CThumbAGObserver::HandleBackupOperationEventL out"); - } - - diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -95,10 +95,10 @@ UpdatePSValues(ETrue); if(iForegroundGenerationObserver) - { - delete iForegroundGenerationObserver; - iForegroundGenerationObserver = NULL; - } + { + delete iForegroundGenerationObserver; + iForegroundGenerationObserver = NULL; + } RProperty::Define(KTAGDPSNotification, KMPXHarvesting, RProperty::EInt); @@ -503,7 +503,7 @@ iPlaceholderQueue.Remove( itemIndex ); } - if(iAddQueue.Find( aIDArray[i]) == KErrNotFound && i2ndRoundGenerateQueue.Find( aIDArray[i])) + if(iAddQueue.Find( aIDArray[i]) == KErrNotFound && i2ndRoundGenerateQueue.Find( aIDArray[i]) == KErrNotFound ) { TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to add queue"); iAddQueue.Append( aIDArray[i]); @@ -988,10 +988,10 @@ if(ret != KErrNone || !serveIdle ) { - //start inactivity timer and retry on after callback - TN_DEBUG1( "void CThumbAGProcessor::RunL() server not idle"); - StartTimeout(); - return; + //start inactivity timer and retry on after callback + TN_DEBUG1( "void CThumbAGProcessor::RunL() server not idle"); + StartTimeout(); + return; } TN_DEBUG1( "void CThumbAGProcessor::RunL() device and server idle, process"); } @@ -1497,11 +1497,26 @@ { SetForceRun( EFalse ); } - - continue; + } + + itemIndex = iQueryQueue.Find( aIDArray[i] ); + + if(itemIndex >= 0) + { + iQueryQueue.Remove(itemIndex); + TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iQueryQueue" ); } - - /*if( aRemoveFromDelete ) + + itemIndex = iPlaceholderQueue.Find( aIDArray[i] ); + + if(itemIndex >= 0) + { + iPlaceholderQueue.Remove(itemIndex); + TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" ); + } + + /* + if( aRemoveFromDelete ) { itemIndex = iRemoveQueue.Find( aIDArray[i] ); @@ -1755,6 +1770,21 @@ daemonProcessing = ETrue; } + //disable 2nd round generarion when there is items in 1st round queues + //or 2nd queue is empty + if( !i2ndRoundGenerateQueue.Count() || itemsLeft ) + { + i2ndRound = EFalse; + } + + //adjust items left to containing also items not yet processed but removed from queue under processing + if((iLastQueue == &iModifyQueue || iLastQueue == &iAddQueue) && !i2ndRound) + { + itemsLeft +=iQueryQueue.Count(); + } + + TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() KItemsleft == %d", itemsLeft); + if(aDefine) { TN_DEBUG1( "CThumbAGProcessor::UpdatePSValues() define"); diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h Wed Mar 31 22:04:49 2010 +0300 @@ -76,8 +76,7 @@ * @return Thumbnail request ID */ TThumbnailRequestId GetThumbnailL( CThumbnailObjectSource& aObjectSource, - TAny* aClientData = NULL, const TInt aPriority = CActive::EPriorityIdle - ); + TAny* aClientData = NULL, const TInt aPriority = CActive::EPriorityIdle ); /** * Get a thumbnail for an object file. If a thumbnail already exists, it @@ -101,7 +100,7 @@ * @return Thumbnail request ID */ TThumbnailRequestId GetThumbnailL( CThumbnailObjectSource& aObjectSource, - TAny* aClientData, const TInt aPriority, TBool aGeneratePersistentSizesOnly); + TAny* aClientData, const TInt aPriority, TBool aGeneratePersistentSizesOnly ); /** * Get a persistent thumbnail for an object file. If a thumbnail already @@ -179,7 +178,7 @@ */ TThumbnailRequestId SetThumbnailL( CThumbnailObjectSource& source, TAny* aClientData = NULL, - TInt aPriority = CActive::EPriorityIdle); + TInt aPriority = CActive::EPriorityIdle ); /** * Get the current display mode for thumbnail bitmaps. @@ -307,8 +306,7 @@ * @return Symbian OS error code or KErrNone if change was * successful. */ - TInt ChangePriority( const TThumbnailRequestId aId, const TInt aNewPriority - ); + TInt ChangePriority( const TThumbnailRequestId aId, const TInt aNewPriority ); /** * Get a list of supported file formats for object files. @@ -357,6 +355,15 @@ * @since S60 v5.0 */ void ConstructL(); + + /** + * Check that given priority is in range of CActive::TPriority + * + * @since S60 v5.0 + * @param aPriority Priority + * @return Valid priority. + */ + TInt ValidatePriority( const TInt aPriority ); private: diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h Wed Mar 31 22:04:49 2010 +0300 @@ -441,6 +441,9 @@ CPeriodic* iTimer; TInt iStartError; + // request already canceled by client + TBool iCanceled; + #ifdef _DEBUG TTime iStartExecTime; #endif diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanagerimpl.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanagerimpl.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanagerimpl.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -109,28 +109,28 @@ User::LeaveIfError( iFs.ShareProtected()); if ( !RFbsSession::GetSession() ) + { + // We need to connect to Fbs (first user in this thread) + // Maintain a reference count in TLS + User::LeaveIfError( iFbsSession.Connect()); + Dll::SetTls( (TAny*)1 ); + TN_DEBUG2( "CThumbnailManagerImpl::ConstructL() - update sessionCount == %d to TLS", 1 ); + } + else + { + TInt sessionCount = (TInt)Dll::Tls(); + if( sessionCount++ > 0 ) { - // We need to connect to Fbs (first user in this thread) - // Maintain a reference count in TLS - User::LeaveIfError( iFbsSession.Connect()); - Dll::SetTls( (TAny*)1 ); - TN_DEBUG2( "CThumbnailManagerImpl::ConstructL() - update sessionCount == %d to TLS", 1 ); - } + // Increase the reference count in TLS + Dll::SetTls( (TAny*)sessionCount ); + TN_DEBUG2( "CThumbnailManagerImpl::ConstructL() - update sessionCount == %d to TLS", sessionCount ); + } else { - TInt sessionCount = (TInt)Dll::Tls(); - if( sessionCount++ > 0 ) - { - // Increase the reference count in TLS - Dll::SetTls( (TAny*)sessionCount ); - TN_DEBUG2( "CThumbnailManagerImpl::ConstructL() - update sessionCount == %d to TLS", sessionCount ); - } - else - { - // Fbs connection was available in the beginning, no need to - // increase the reference count - } + // Fbs connection was available in the beginning, no need to + // increase the reference count } + } // request processor iRequestQueue = CThumbnailRequestQueue::NewL(); @@ -151,26 +151,28 @@ __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + TInt priority = ValidatePriority(aPriority); + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL - ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + ( iFs, iSession, iObserver, iRequestId, priority, iRequestQueue ); CleanupStack::PushL( getThumbnailActive ); if(aObjectSource.Id() > 0) { getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), iFlags, - iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, aGeneratePersistentSizesOnly, + iQualityPreference, iSize, iDisplayMode, priority, aClientData, aGeneratePersistentSizesOnly, KNullDesC, iThumbnailSize); } else if ( aObjectSource.Uri().Length()) { getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), iFlags, - iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, aGeneratePersistentSizesOnly, + iQualityPreference, iSize, iDisplayMode, priority, aClientData, aGeneratePersistentSizesOnly, KNullDesC, iThumbnailSize ); } else { getThumbnailActive->GetThumbnailL( aObjectSource.FileHandle(), aObjectSource.Id(), iFlags, - iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, aGeneratePersistentSizesOnly, + iQualityPreference, iSize, iDisplayMode, priority, aClientData, aGeneratePersistentSizesOnly, KNullDesC, iThumbnailSize ); } @@ -210,12 +212,14 @@ __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + TInt priority = ValidatePriority(aPriority); + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL - ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + ( iFs, iSession, iObserver, iRequestId, priority, iRequestQueue ); CleanupStack::PushL( getThumbnailActive ); getThumbnailActive->GetThumbnailL( KNullDesC, aThumbnailId, iFlags, - iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, + iQualityPreference, iSize, iDisplayMode, priority, aClientData, EFalse, KNullDesC, iThumbnailSize ); iRequestQueue->AddRequestL( getThumbnailActive ); @@ -242,20 +246,22 @@ __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + TInt priority = ValidatePriority(aPriority); + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL - ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + ( iFs, iSession, iObserver, iRequestId, priority, iRequestQueue ); CleanupStack::PushL( getThumbnailActive ); if ( aObjectSource.Uri().Length()) { getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), iFlags, - iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, + iQualityPreference, iSize, iDisplayMode, priority, aClientData, EFalse, aTargetUri, iThumbnailSize ); } else { getThumbnailActive->GetThumbnailL( aObjectSource.FileHandle(), aObjectSource.Id(), - iFlags, iQualityPreference, iSize, iDisplayMode, aPriority, aClientData, + iFlags, iQualityPreference, iSize, iDisplayMode, priority, aClientData, EFalse, aTargetUri, iThumbnailSize ); } @@ -281,8 +287,10 @@ __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + TInt priority = ValidatePriority(aPriority); + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL - ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + ( iFs, iSession, iObserver, iRequestId, priority, iRequestQueue ); CleanupStack::PushL( getThumbnailActive ); if ( aObjectSource.Uri().Length() && @@ -291,7 +299,7 @@ { getThumbnailActive->SetThumbnailL( aObjectSource.GetBufferOwnership(), aObjectSource.Id(), aObjectSource.MimeType(), iFlags, iQualityPreference, iSize, iDisplayMode, - aPriority, aClientData, EFalse, aObjectSource.Uri(), iThumbnailSize); + priority, aClientData, EFalse, aObjectSource.Uri(), iThumbnailSize); } iRequestQueue->AddRequestL( getThumbnailActive ); @@ -318,8 +326,10 @@ __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + TInt priority = ValidatePriority(aPriority); + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL - ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + ( iFs, iSession, iObserver, iRequestId, priority, iRequestQueue ); CleanupStack::PushL( getThumbnailActive ); @@ -328,14 +338,14 @@ // from bitmap getThumbnailActive->SetThumbnailL( aObjectSource.GetBitmapOwnership(), aObjectSource.Id(), KBmpMime, iFlags, iQualityPreference, - iSize, iDisplayMode, aPriority, NULL, ETrue, + iSize, iDisplayMode, priority, NULL, ETrue, aObjectSource.Uri(), EUnknownThumbnailSize); } else if( !aObjectSource.Buffer() ) { getThumbnailActive->GetThumbnailL( aObjectSource.Id(), aObjectSource.Uri(), iFlags, iQualityPreference, iSize, - iDisplayMode, aPriority, NULL, ETrue, aObjectSource.Uri(), + iDisplayMode, priority, NULL, ETrue, aObjectSource.Uri(), EUnknownThumbnailSize); } else @@ -343,7 +353,7 @@ // from buffer getThumbnailActive->SetThumbnailL( aObjectSource.GetBufferOwnership(), aObjectSource.Id(), aObjectSource.MimeType(), iFlags, - iQualityPreference, iSize, iDisplayMode, aPriority, NULL, + iQualityPreference, iSize, iDisplayMode, priority, NULL, ETrue, aObjectSource.Uri(), EUnknownThumbnailSize); } @@ -563,9 +573,11 @@ { __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + TInt priority = ValidatePriority(aNewPriority); + TN_DEBUG2( "CThumbnailManagerImpl::ChangePriority() - request ID: %d", aId ); - return iRequestQueue->ChangePriority(aId, aNewPriority); + return iRequestQueue->ChangePriority(aId, priority); } // --------------------------------------------------------------------------- @@ -605,12 +617,14 @@ __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + TInt priority = ValidatePriority(aPriority); + CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL - ( iFs, iSession, iObserver, iRequestId, aPriority, iRequestQueue ); + ( iFs, iSession, iObserver, iRequestId, priority, iRequestQueue ); CleanupStack::PushL( getThumbnailActive ); getThumbnailActive->UpdateThumbnailsL( aPath, aItemId, iFlags, iQualityPreference, - iDisplayMode, aPriority, aOrientation, aModified ); + iDisplayMode, priority, aOrientation, aModified ); iRequestQueue->AddRequestL( getThumbnailActive ); CleanupStack::Pop( getThumbnailActive ); @@ -618,4 +632,27 @@ iRequestQueue->Process(); } +// --------------------------------------------------------------------------- +// CThumbnailManagerImpl::ValidatePriority() +// Check that given priority is in range of CActive::TPriority +// --------------------------------------------------------------------------- +// +TInt CThumbnailManagerImpl::ValidatePriority( const TInt aPriority ) + { + if (aPriority < CActive::EPriorityIdle) + { + TN_DEBUG2( "CThumbnailManagerImpl::ValidatePriority() - priority %d too low for CActive", aPriority ); + return CActive::EPriorityIdle; + } + else if (aPriority > CActive::EPriorityHigh) + { + TN_DEBUG2( "CThumbnailManagerImpl::ValidatePriority() - priority %d too high for CActive", aPriority ); + return CActive::EPriorityHigh; + } + else + { + return aPriority; + } + } + // End of file diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -86,7 +86,7 @@ TThumbnailRequestId aId, TInt aPriority, CThumbnailRequestQueue* aQueue ): CActive( aPriority ), iSession( aThumbnailSession ), iParamsPckg( iParams ), iObserver( aObserver ), iFs( aFs ), iBitmapHandle( 0 ), iRequestId( aId ), - iRequestQueue( aQueue ) + iRequestQueue( aQueue ), iCanceled( EFalse ) { CActiveScheduler::Add( this ); TN_DEBUG2( "CThumbnaiRequestActive::CThumbnailRequestActive() AO's priority = %d", Priority()); @@ -163,6 +163,7 @@ case EReqGetThumbnailHandleLater: { // open file handle + iFile.Close(); User::LeaveIfError( iFile.Open( iFs, iTargetUri, EFileShareReadersOrWriters ) ); TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iTargetUri ); @@ -219,9 +220,12 @@ iTimer->Cancel(); - if (iRequestType == EReqDeleteThumbnails) + if (iRequestType == EReqDeleteThumbnails || iCanceled) { - // no action for delete + iFile.Close(); + iMyFileHandle.Close(); + + // no action for delete or canceled request iRequestQueue->RequestComplete(this); #ifdef _DEBUG @@ -239,8 +243,8 @@ // We tried to get thumbnail using file path, but it was not found in // the database. We need to open the file now (on the client side) and - // use file handle. - + // use file handle. + iFile.Close(); TInt err = iFile.Open( iFs, iParams.iFileName, EFileShareReadersOrWriters ); TN_DEBUG2( "CThumbnaiRequestActive::RunL() - file handle open err = %d", err ); User::LeaveIfError( err ); @@ -273,6 +277,10 @@ iObserver.ThumbnailReady( iStatus.Int(), *iCallbackThumbnail, iParams.iRequestId ); ReleaseServerBitmap(); + + iFile.Close(); + iMyFileHandle.Close(); + iRequestQueue->RequestComplete(this); #ifdef _DEBUG @@ -296,6 +304,8 @@ ReleaseServerBitmap(); + iFile.Close(); + //set flags so that EThumbnailGeneratePersistentSizesOnly is done aka check all missing sizes iParams.iQualityPreference = CThumbnailManager::EOptimizeForQuality; iParams.iControlFlags = EThumbnailGeneratePersistentSizesOnly; @@ -350,12 +360,17 @@ if ( iProcessingPreview ) { TN_DEBUG2( "CThumbnailRequestActive::RunL() - iObserver.ThumbnailPreviewReady %d", iParams.iRequestId ); - //increase priority of 2nd round (both, AO and request itself) + + //increase priority of 2nd round (both, AO and request itself) this->SetPriority(this->Priority() + 1); iParams.iPriority++; iObserver.ThumbnailPreviewReady( *iCallbackThumbnail, iParams.iRequestId ); iProcessingPreview = EFalse; + ReleaseServerBitmap(); + + iFile.Close(); + Get2ndPhaseThumbnailL(); } else @@ -365,6 +380,9 @@ iObserver.ThumbnailReady( iStatus.Int(), * iCallbackThumbnail, iParams.iRequestId ); ReleaseServerBitmap(); + iFile.Close(); + iMyFileHandle.Close(); + iRequestQueue->RequestComplete(this); #ifdef _DEBUG @@ -417,6 +435,7 @@ __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); + iCanceled = ETrue; iSession.CancelRequest( iRequestId ); ReleaseServerBitmap(); } @@ -479,6 +498,9 @@ ReleaseServerBitmap(); + iFile.Close(); + iMyFileHandle.Close(); + iRequestCompleted = ETrue; iRequestQueue->RequestComplete(this); iRequestActive = EFalse; diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailsession.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailsession.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailsession.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -238,6 +238,8 @@ TInt err = Send( EReleaseBitmap, TIpcArgs( aBitmapHandle )); while ( err == KErrServerBusy ) { + TN_DEBUG1( "RThumbnailSession::ReleaseBitmap() - server slots full"); + err = Send( EReleaseBitmap, TIpcArgs( aBitmapHandle )); } } @@ -249,10 +251,12 @@ // TInt RThumbnailSession::CancelRequest( TThumbnailRequestId aRequestId ) { - TInt err = SendReceive( ECancelRequest, TIpcArgs( aRequestId )); + TInt err = Send( ECancelRequest, TIpcArgs( aRequestId )); while ( err == KErrServerBusy ) { - err = SendReceive( ECancelRequest, TIpcArgs( aRequestId )); + TN_DEBUG1( "RThumbnailSession::CancelRequest() - server slots full"); + + err = Send( ECancelRequest, TIpcArgs( aRequestId )); } return err; } @@ -265,10 +269,12 @@ TInt RThumbnailSession::ChangePriority( TThumbnailRequestId aRequestId, TInt aNewPriority ) { - TInt err = SendReceive( EChangePriority, TIpcArgs( aRequestId, aNewPriority )); + TInt err = Send( EChangePriority, TIpcArgs( aRequestId, aNewPriority )); while ( err == KErrServerBusy ) { - err = SendReceive( EChangePriority, TIpcArgs( aRequestId, aNewPriority )); + TN_DEBUG1( "RThumbnailSession::ChangePriority() - server slots full"); + + err = Send( EChangePriority, TIpcArgs( aRequestId, aNewPriority )); } return err; } diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildecodetask.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildecodetask.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildecodetask.h Wed Mar 31 22:04:49 2010 +0300 @@ -115,11 +115,6 @@ * Not own. */ CThumbnailProvider* iProvider; - - /** - * If set, scaled bitmap must be released from pool. - */ - TInt iBitmapHandle; /** * Temporary buffer for client/server parameters diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailformatobserver.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailformatobserver.h Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Monitors File system for Format events -* -*/ - - -#ifndef CTHUMBNAILFORMATOBSERVER_H -#define CTHUMBNAILFORMATOBSERVER_H - -#include -#include "f32file.h" -#include "thumbnailserver.h" - -/** - * File System monitor class to monitor for format events - * - * @lib thumbnailsserver.exe - * @since S60 3.0 - */ -NONSHARABLE_CLASS( CThumbnailFormatObserver ) : public CBase, - public MBackupOperationObserver - { - -public: - - /** - * Two-phase constructor - * @param aObserver observer to the monitor - */ - static CThumbnailFormatObserver* NewL( CThumbnailServer* aServer ); - - /** - * Two-phase constructor - * @param aObserver observer to the monitor - */ - static CThumbnailFormatObserver* NewLC( CThumbnailServer* aServer ); - - /** - * Destructor - */ - virtual ~CThumbnailFormatObserver(); - -public: // New functions - - /** - * Polls for the current monitor status - * If an event is happening, it will callback the observer of the event - */ - void PollStatus(); - -protected: // Base Class - - /* - * From MBackupOperationObserver - * Notifies this class of the backup event. - * MMC App will signal a start / end. - */ - void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes); - -private: - - /** - * C++ constructor - * aObserver observer to this event - */ - CThumbnailFormatObserver ( CThumbnailServer* aServer ); - - /* - * Second phased constructor - */ - void ConstructL(); - -private: // data - - CThumbnailServer* iServer; - - CBaBackupSessionWrapper* iBackupSession; - - - }; - -#endif // CTHUMBNAILFORMATOBSERVER_H diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h Wed Mar 31 22:04:49 2010 +0300 @@ -212,14 +212,6 @@ TSize iOriginalSize; /** - * Refers to a bitmap in the bitmap pool owned by server. Must be deleted - * using CThumbnailServer::DeleteBitmapFromPool() to make reference - * counting work. - * Not own. - */ - CFbsBitmap* iBitmap; - - /** * Thumbnail provider implementation. * Not own. */ @@ -239,6 +231,8 @@ * Target rect rotated (portrait image) */ TBool iPortrait; + + TInt iBitmapHandle; }; #endif // THUMBNAILGENERATETASK_H diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserver.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserver.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserver.h Wed Mar 31 22:04:49 2010 +0300 @@ -213,7 +213,7 @@ * @param aFile File to be recognized. * @return MIME-type */ - TDataType ResolveMimeTypeL( RFile& aFile ); + TDataType ResolveMimeTypeL( RFile64& aFile ); /** * Removes bitmap from bitmap pool. Reference count is decremented diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserversession.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserversession.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserversession.h Wed Mar 31 22:04:49 2010 +0300 @@ -257,9 +257,8 @@ * Checks if client thread is still alive and RMessage2 handle valid. * * @since S60 v5.0 - * @param aMessage Message. */ - TBool ClientThreadAlive(RMessage2& aMessage); + TBool ClientThreadAlive(); private: // data @@ -295,6 +294,9 @@ TDesC8* iBuffer; TInt iBitmapHandle; + + // client thread from RMessage2 + RThread iClientThread; }; #endif // THUMBNAILSERVERSESSION_H diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h Wed Mar 31 22:04:49 2010 +0300 @@ -19,7 +19,7 @@ #ifndef THUMBNAILSQL_H #define THUMBNAILSQL_H -//main table +// main table _LIT8( KThumbnailCreateInfoTable, "CREATE TABLE ThumbnailInfo (" // Assosiacted object in file system "Path TEXT COLLATE NOCASE," @@ -54,7 +54,7 @@ // If Thumbnail is stored in SQL then Data is NOT NULL "Data BLOB);"); -//temp table is identical to actual main table except it's not persistent +// temp table is identical to actual main table except it's not persistent _LIT8( KThumbnailCreateTempInfoTable, "CREATE TEMP TABLE TempThumbnailInfo (" "Path TEXT COLLATE NOCASE," "TNId INTEGER," @@ -75,7 +75,7 @@ // If Thumbnail is stored in SQL then Data is NOT NULL "Data BLOB);"); -//version table +// version table _LIT8( KThumbnailVersionTable, "CREATE TABLE ThumbnailVersion (" "Major INTEGER," "Minor INTEGER," @@ -86,60 +86,11 @@ // Assosiacted object in file system "Path TEXT UNIQUE COLLATE NOCASE);"); -//Create index for speedup DB searches +// indexes _LIT8( KThumbnailCreateInfoTableIndex1, "CREATE INDEX idx1 ON ThumbnailInfo(Path, Size);"); _LIT8( KThumbnailCreateDeletedTableIndex, "CREATE INDEX idx4 ON ThumbnailDeleted(Path);"); -_LIT8( KThumbnailMoveFromTempInfoToMainTable, "INSERT INTO ThumbnailInfo SELECT * FROM TempThumbnailInfo;"); -_LIT8( KThumbnailMoveFromTempDataToMainTable, "INSERT INTO ThumbnailInfoData SELECT * FROM TempThumbnailInfoData;"); - -_LIT8( KThumbnailDeleteFromTempInfoTable, "DELETE FROM TempThumbnailInfo;"); -_LIT8( KThumbnailDeleteFromTempDataTable, "DELETE FROM TempThumbnailInfoData;"); - -_LIT8( KThumbnailCreateSettingsTable, "CREATE TABLE ThumbnailSettings (" - "Version INTEGER);" ); - -_LIT8( KThumbnailDropInfoTable, "DROP TABLE ThumbnailInfo;" ); -_LIT8( KThumbnailDropTempInfoTable, "DROP TABLE TempThumbnailInfo;" ); - -_LIT8( KThumbnailDropSettingsTable, "DROP TABLE ThumbnailSettings;" ); - -_LIT8( KThumbnailBeginTransaction, "BEGIN TRANSACTION;" ); -_LIT8( KThumbnailCommitTransaction, "COMMIT;" ); -_LIT8( KThumbnailRollbackTransaction, "ROLLBACK;" ); - -_LIT8( KThumbnailInsertThumbnailInfoByPathAndId, "INSERT INTO TempThumbnailInfo " - "(Path,Size,Format,Width,Height,OrigWidth,OrigHeight,Flags,Orientation,ThumbFromPath,Modified) ""VALUES " - "(:Path,:Size,:Format,:Width,:Height,:OrigWidth,:OrigHeight,:Flags,:Orient,:ThumbFromPath,:Modified);" ); - -_LIT8( KThumbnailInsertTempThumbnailInfoData, "INSERT INTO TempThumbnailInfoData (Data) VALUES (:Data);" ); - -_LIT8( KThumbnailSelectSizeByPath, "SELECT Size FROM ThumbnailInfo " - "WHERE NOT EXISTS (SELECT Path FROM ThumbnailDeleted " - "WHERE ThumbnailInfo.Path = ThumbnailDeleted.Path) " - "AND Path = :Path ORDER BY Size DESC;" ); - -_LIT8( KThumbnailSelectTempSizeByPath, "SELECT Size FROM TempThumbnailInfo WHERE Path = :Path ORDER BY Size DESC;" ); - -//query by Path -_LIT8( KThumbnailSelectInfoByPath, "SELECT ThumbnailInfo.Format, ThumbnailInfoData.Data, ThumbnailInfo.Width, ThumbnailInfo.Height, ThumbnailInfo.Flags " - "FROM ThumbnailInfo " - "JOIN ThumbnailInfoData " - "ON ThumbnailInfo.RowID = ThumbnailInfoData.RowID " - "WHERE NOT EXISTS (SELECT Path FROM ThumbnailDeleted " - "WHERE ThumbnailInfo.Path = ThumbnailDeleted.Path) " - "AND ThumbnailInfo.Path = :Path AND ThumbnailInfo.Size = :Size;"); - -_LIT8( KThumbnailSelectTempInfoByPath, "SELECT TempThumbnailInfo.Format, TempThumbnailInfoData.Data, TempThumbnailInfo.Width, TempThumbnailInfo.Height, TempThumbnailInfo.Flags " - "FROM TempThumbnailInfo " - "JOIN TempThumbnailInfoData " - "ON TempThumbnailInfo.RowID = TempThumbnailInfoData.RowID " - "WHERE TempThumbnailInfo.Path = :Path AND TempThumbnailInfo.Size = :Size;"); - - -_LIT8( KThumbnailSelectSettings, "SELECT Version FROM ThumbnailSettings;" ); - - +// parameters _LIT( KThumbnailSqlParamData, ":Data" ); _LIT( KThumbnailSqlParamFlags, ":Flags" ); _LIT( KThumbnailSqlParamPath, ":Path" ); @@ -163,7 +114,68 @@ _LIT( KThumbnailSqlParamFlag, ":Flag" ); _LIT( KThumbnailSqlParamLimit, ":Limit" ); -//Delete by path +// transaction +_LIT8( KThumbnailBeginTransaction, "BEGIN TRANSACTION;" ); +_LIT8( KThumbnailCommitTransaction, "COMMIT;" ); +_LIT8( KThumbnailRollbackTransaction, "ROLLBACK;" ); + +// version +_LIT8( KThumbnailInsertToVersion, "INSERT INTO ThumbnailVersion (IMEI, Minor, Major) VALUES (:IMEI, :Minor,:Major);" ); +_LIT8( KThumbnailSelectFromVersion, "SELECT * FROM ThumbnailVersion LIMIT 1" ); + +// IMEI +_LIT8( KThumbnailUpdateIMEI, "UPDATE ThumbnailVersion SET IMEI = :IMEI" ); + +// rowIDs +_LIT8 ( KGetInfoRowID, "SELECT MAX (ThumbnailInfo.rowID) FROM ThumbnailInfo" ); +_LIT8 ( KGetDataRowID, "SELECT MAX (ThumbnailInfoData.rowID) FROM ThumbnailInfoData" ); + +// flush +_LIT8( KThumbnailMoveFromTempInfoToMainTable, "INSERT INTO ThumbnailInfo SELECT * FROM TempThumbnailInfo;"); +_LIT8( KThumbnailMoveFromTempDataToMainTable, "INSERT INTO ThumbnailInfoData SELECT * FROM TempThumbnailInfoData;"); +_LIT8( KThumbnailDeleteFromTempInfoTable, "DELETE FROM TempThumbnailInfo;"); +_LIT8( KThumbnailDeleteFromTempDataTable, "DELETE FROM TempThumbnailInfoData;"); + +// store thumb +_LIT8( KThumbnailInsertTempThumbnailInfo, "INSERT INTO TempThumbnailInfo " + "(Path,Size,Format,Width,Height,OrigWidth,OrigHeight,Flags,Orientation,ThumbFromPath,Modified) " + "VALUES " + "(:Path,:Size,:Format,:Width,:Height,:OrigWidth,:OrigHeight,:Flags,:Orient,:ThumbFromPath,:Modified);" ); + +_LIT8( KThumbnailInsertTempThumbnailInfoData, "INSERT INTO TempThumbnailInfoData (Data) VALUES (:Data);" ); + +// duplicate check +_LIT8 ( KThumbnailTempFindDuplicate, "SELECT Path FROM TempThumbnailInfo WHERE Path = :Path AND Size = :Size;" ); +_LIT8 ( KThumbnailFindDuplicate, "SELECT Path FROM ThumbnailInfo WHERE Path = :Path AND Size = :Size;" ); + +// select size +_LIT8( KThumbnailSelectSizeByPath, "SELECT Size FROM ThumbnailInfo " + "WHERE NOT EXISTS (SELECT Path FROM ThumbnailDeleted " + "WHERE ThumbnailInfo.Path = ThumbnailDeleted.Path) " + "AND Path = :Path ORDER BY Size DESC;" ); + +_LIT8( KThumbnailSelectTempSizeByPath, "SELECT Size FROM TempThumbnailInfo WHERE Path = :Path ORDER BY Size DESC;" ); + +// select timestamp +_LIT8( KThumbnailSelectModifiedByPath, "SELECT Modified FROM ThumbnailInfo WHERE Path = :Path" ); +_LIT8( KThumbnailSelectTempModifiedByPath, "SELECT Modified FROM TempThumbnailInfo WHERE Path = :Path"); + +// select thumb +_LIT8( KThumbnailSelectInfoByPath, "SELECT ThumbnailInfo.Format, ThumbnailInfoData.Data, ThumbnailInfo.Width, ThumbnailInfo.Height, ThumbnailInfo.Flags " + "FROM ThumbnailInfo " + "JOIN ThumbnailInfoData " + "ON ThumbnailInfo.RowID = ThumbnailInfoData.RowID " + "WHERE NOT EXISTS (SELECT Path FROM ThumbnailDeleted " + "WHERE ThumbnailInfo.Path = ThumbnailDeleted.Path) " + "AND ThumbnailInfo.Path = :Path AND ThumbnailInfo.Size = :Size;"); + +_LIT8( KThumbnailSelectTempInfoByPath, "SELECT TempThumbnailInfo.Format, TempThumbnailInfoData.Data, TempThumbnailInfo.Width, TempThumbnailInfo.Height, TempThumbnailInfo.Flags " + "FROM TempThumbnailInfo " + "JOIN TempThumbnailInfoData " + "ON TempThumbnailInfo.RowID = TempThumbnailInfoData.RowID " + "WHERE TempThumbnailInfo.Path = :Path AND TempThumbnailInfo.Size = :Size;"); + +// delete thumb _LIT8( KThumbnailSqlSelectRowIDInfoByPath, "SELECT ThumbnailInfo.RowID FROM ThumbnailInfo WHERE Path = :Path;" ); _LIT8( KThumbnailSqlDeleteInfoByPath, "DELETE FROM ThumbnailInfo WHERE ThumbnailInfo.RowID = :RowID;" ); _LIT8( KThumbnailSqlDeleteInfoDataByPath, "DELETE FROM ThumbnailInfoData WHERE ThumbnailInfoData.RowID = :RowID;" ); @@ -171,46 +183,23 @@ _LIT8( KTempThumbnailSqlDeleteInfoByPath, "DELETE FROM TempThumbnailInfo WHERE TempThumbnailInfo.RowID = :RowID;" ); _LIT8( KTempThumbnailSqlDeleteInfoDataByPath, "DELETE FROM TempThumbnailInfoData WHERE TempThumbnailInfoData.RowID = :RowID;" ); - -// insert to deleted +// mark deleted _LIT8( KThumbnailSqlInsertDeleted, "INSERT INTO ThumbnailDeleted (Path) VALUES (:Path);" ); -_LIT8 ( KThumbnailSqlFindDeleted, "SELECT * FROM ThumbnailDeleted WHERE Path = :Path;" ); +_LIT8( KThumbnailSqlFindDeleted, "SELECT * FROM ThumbnailDeleted WHERE Path = :Path;" ); // delete marked _LIT8( KThumbnailSqlSelectMarked, "SELECT ThumbnailInfo.RowID FROM ThumbnailInfo " "WHERE EXISTS (SELECT Path FROM ThumbnailDeleted " "WHERE ThumbnailInfo.Path = ThumbnailDeleted.Path) LIMIT :Limit;" ); + _LIT8( KThumbnailSqlDeleteInfoByRowID, "DELETE FROM ThumbnailInfo WHERE ThumbnailInfo.RowID = :RowID;" ); _LIT8( KThumbnailSqlDeleteInfoDataByRowID, "DELETE FROM ThumbnailInfoData WHERE ThumbnailInfoData.RowID = :RowID;" ); + _LIT8( KThumbnailSqlDeleteFromDeleted, "DELETE FROM ThumbnailDeleted " "WHERE NOT EXISTS (SELECT Path FROM ThumbnailInfo " "WHERE ThumbnailDeleted.Path = ThumbnailInfo.Path);" ); - -//version commands -_LIT8( KThumbnailInsertToVersion, "INSERT INTO ThumbnailVersion (IMEI, Minor, Major) VALUES (:IMEI, :Minor,:Major);" ); -_LIT8( KThumbnailSelectFromVersion, "SELECT * FROM ThumbnailVersion LIMIT 1" ); - -//reset IDs -_LIT8( KTempThumbnailResetIDs, "UPDATE TempThumbnailInfo SET TNId = NULL WHERE TNId NOT NULL" ); -_LIT8( KThumbnailResetIDs, "UPDATE ThumbnailInfo SET TNId = NULL WHERE TNId NOT NULL" ); - -//update IMEI -_LIT8( KThumbnailUpdateIMEI, "UPDATE ThumbnailVersion SET IMEI = :IMEI" ); - -//query Modification timestamp by path -_LIT8( KThumbnailSelectModifiedByPath, "SELECT Modified FROM ThumbnailInfo WHERE Path = :Path" ); -_LIT8( KThumbnailSelectTempModifiedByPath, "SELECT Modified FROM TempThumbnailInfo WHERE Path = :Path"); - -// query possible duplicates -_LIT8 ( KTempFindDuplicate, "SELECT Path FROM TempThumbnailInfo WHERE Path = :Path AND Size = :Size;" ); -_LIT8 ( KFindDuplicate, "SELECT Path FROM ThumbnailInfo WHERE Path = :Path AND Size = :Size;" ); - -// check rowIDs -_LIT8 ( KGetInfoRowID, "SELECT MAX (ThumbnailInfo.rowID) FROM ThumbnailInfo" ); -_LIT8 ( KGetDataRowID, "SELECT MAX (ThumbnailInfoData.rowID) FROM ThumbnailInfoData" ); - -//remove KThumbnailDbFlagBlacklisted flag +// reset blacklisted _LIT8( KThumbnailTouchBlacklistedRows, "UPDATE ThumbnailInfo SET Modified = 0 WHERE Flags & :Flag" ); // existence check diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h Wed Mar 31 22:04:49 2010 +0300 @@ -297,14 +297,14 @@ * * @since S60 v5.0 */ - TInt CheckImeiL(); + TInt CheckImei(); /** * Check version of db * * @since S60 v5.0 */ - TInt CheckVersionL(); + TInt CheckVersion(); /** * Check mediaid of store @@ -321,13 +321,6 @@ void AddVersionAndImeiL(); /** - * Reset TNID column - * - * @since S60 v5.0 - */ - TInt ResetThumbnailIDs(); - - /** * Update IMEI to db * * @since S60 v5.0 @@ -340,7 +333,7 @@ * @since S60 v5.0 */ - TInt CheckRowIDsL(); + TInt CheckRowIDs(); /** * Check is disk full @@ -388,8 +381,9 @@ * Open database * * @since S60 v5.0 + * @param aNewDatabase Delete existing before creating new */ - TInt OpenDatabaseL(); + TInt OpenDatabaseL( TBool aNewDatabase = EFalse); /** * Open database @@ -404,15 +398,26 @@ * @since S60 v5.0 */ void CreateTablesL(); + void CreateTempTablesL(); /** * Delete and create database * * @since S60 v5.0 + * @param aDelete Delete old db */ - void RecreateDatabaseL( const TBool aDelete); + void RecreateDatabaseL( const TBool aDelete ); /** + * Prepare, reset & close statements + * + * @since S60 v5.0 + */ + void PrepareStatementsL(); + static void ResetStatement( TAny* aStmt ); + void CloseStatements(); + + /** * Stores thumbnail image. * * @since S60 v5.0 @@ -499,6 +504,13 @@ TBool FileExistenceCheckL(); /** + * Checks if thumbnail database is usable + * + * @return KErrNone, if no problems + */ + TInt CheckDbState(); + + /** * Strips drive letter from URI. * * @since S60 v5.0 @@ -586,6 +598,34 @@ // check if thumb source files still exist TBool iCheckFilesExist; TInt64 iLastCheckedRowID; + + // store is in a state in which db can't be used + TBool iUnrecoverable; + + // prepared statements + RSqlStatement iStmt_KThumbnailSelectInfoByPath; + RSqlStatement iStmt_KThumbnailSelectTempInfoByPath; + RSqlStatement iStmt_KThumbnailInsertTempThumbnailInfo; + RSqlStatement iStmt_KThumbnailInsertTempThumbnailInfoData; + RSqlStatement iStmt_KThumbnailSelectModifiedByPath; + RSqlStatement iStmt_KThumbnailSelectTempModifiedByPath; + RSqlStatement iStmt_KThumbnailFindDuplicate; + RSqlStatement iStmt_KThumbnailTempFindDuplicate; + RSqlStatement iStmt_KThumbnailSqlFindDeleted; + RSqlStatement iStmt_KThumbnailSelectSizeByPath; + RSqlStatement iStmt_KThumbnailSelectTempSizeByPath; + RSqlStatement iStmt_KThumbnailSqlSelectRowIDInfoByPath; + RSqlStatement iStmt_KThumbnailSqlDeleteInfoByPath; + RSqlStatement iStmt_KThumbnailSqlDeleteInfoDataByPath; + RSqlStatement iStmt_KTempThumbnailSqlSelectRowIDInfoByPath; + RSqlStatement iStmt_KTempThumbnailSqlDeleteInfoByPath; + RSqlStatement iStmt_KTempThumbnailSqlDeleteInfoDataByPath; + RSqlStatement iStmt_KThumbnailSqlInsertDeleted; + RSqlStatement iStmt_KThumbnailSqlSelectMarked; + RSqlStatement iStmt_KThumbnailSqlDeleteInfoByRowID; + RSqlStatement iStmt_KThumbnailSqlDeleteInfoDataByRowID; + RSqlStatement iStmt_KThumbnailSelectAllPaths; + }; // End of File diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtask.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtask.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtask.h Wed Mar 31 22:04:49 2010 +0300 @@ -99,9 +99,10 @@ * @since S60 v5.0 * @param aRequestId Request ID. * @param aMessage Message. + * @param aClientThread Client thread. */ virtual void SetMessageData( const TThumbnailServerRequestId& aRequestId, - const RMessage2& aMessage ); + const RMessage2& aMessage, const RThread& aClientThread ); /** * SetMessageData if message is not needed to complete @@ -184,7 +185,12 @@ * @since S60 v5.0 * @param aGetThread Need to get thread first. */ - TBool ClientThreadAlive(const TBool aGetThread = ETrue); + TBool ClientThreadAlive(const TBool aGetThread = EFalse); + + inline RMessage2& GetMessageData() + { + return iMessage; + } protected: // data @@ -214,6 +220,7 @@ */ RMessage2 iMessage; + // client thread from RMessage2 RThread iClientThread; }; diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/tmshutdownobserver.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/tmshutdownobserver.h Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* -* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: TM Shutdown Observer - * -*/ - - -#ifndef TMSHUTDOWNOBSERVER_H -#define TMSHUTDOWNOBSERVER_H - -#include -#include -#include - - -/** - * Observer interface for signaling the need for shutdown - */ -class MTMShutdownObserver - { -public: - - virtual void ShutdownNotification() = 0; - }; - -/** - * Active object for observing P&S keys - * - * @since S60 v5.0 - */ -class CTMShutdownObserver: public CActive - { -public: - - /** - * Two-phased constructor. - * - * @since S60 v5.0 - * @return Instance of CTMShutdownObserver. - */ - static CTMShutdownObserver* NewL( MTMShutdownObserver& aObserver, const TUid& aKeyCategory, - const TInt aPropertyKey, TBool aDefineKey); - - /** - * Destructor - * - * @since S60 v5.0 - */ - virtual ~CTMShutdownObserver(); - -protected: - - /** - * Handles an active object's request completion event. - * - * @since S60 v5.0 - */ - void RunL(); - - /** - * Implements cancellation of an outstanding request. - * - * @since S60 v5.0 - */ - void DoCancel(); - -private: - - /** - * C++ default constructor - * - * @since S60 v5.0 - * @return Instance of CTMShutdownObserver. - */ - CTMShutdownObserver( MTMShutdownObserver& aObserver, const TUid& aKeyCategory, - const TInt iPropertyKey, TBool aDefineKey); - - /** - * Symbian 2nd phase constructor can leave. - * - * @since S60 v5.0 - */ - void ConstructL(); - -private: - - // not own - MTMShutdownObserver& iObserver; - - const TUid& iKeyCategory; - RProperty iProperty; - TInt iPropertyKey; - - TBool iDefineKey; -}; - -#endif // TMSHUTDOWNOBSERVER_H diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/tnmgetimei.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/tnmgetimei.h Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Helper class to get IMEI number. -* -*/ - -#ifndef _TNMGETIMEI_H_ -#define _TNMGETIMEI_H_ - -#include -#include - -#include "thumbnailmanagerconstants.h" - -class CTnmgetimei: public CActive - { - private: - CTelephony *iTelephony; - CTelephony::TPhoneIdV1 iV1; - TBuf iImei; - CActiveSchedulerWait iAsw; - public: - virtual ~CTnmgetimei(); - static CTnmgetimei* NewL(); - static CTnmgetimei* NewLC(); - TBuf GetIMEI(); - - void DoCancel(); - - void RunL(); - - private: - CTnmgetimei(): CActive(EPriorityStandard), iTelephony(NULL) - {} - void ConstructL(); - - }; - -#endif //_TNMGETIMEI_H_ - diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -143,28 +143,32 @@ if ( ClientThreadAlive() ) { - TRAP_IGNORE(iServer.AddBitmapToPoolL( iRequestId.iSession, aBitmap, iRequestId )); - const TSize bitmapSize = aBitmap->SizeInPixels(); - iBitmapHandle = aBitmap->Handle(); - aBitmap = NULL; - - // Complete message and pass bitmap handle to client + // pass bitmap handle to client TThumbnailRequestParams& params = iParamsBuf(); TInt ret = iMessage.Read( 0, iParamsBuf ); if(ret == KErrNone ) { - params.iBitmapHandle = iBitmapHandle; + params.iBitmapHandle = aBitmap->Handle(); ret = iMessage.Write( 0, iParamsBuf ); } - Complete( ret ); - ResetMessageData(); - - // Successfully completed the message. The client will send - // EReleaseBitmap message later to delete the bitmap from pool. - // CThumbnailScaleTask is no longer responsible for that. - iBitmapHandle = 0; + // add bitmap to pool + TRAPD(err, iServer.AddBitmapToPoolL( iRequestId.iSession, aBitmap, iRequestId ) ); + if (err != KErrNone) + { + Complete( err ); + delete aBitmap; + aBitmap = NULL; + } + else + { + aBitmap = NULL; // Server owns the bitmap now + + // Complete message + Complete( ret ); + ResetMessageData(); + } } else { diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailformatobserver.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailformatobserver.cpp Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: File System format monitor -* -*/ - -#include "thumbnailformatobserver.h" -#include "thumbnaillog.h" - -#include -#include - - -// ======== MEMBER FUNCTIONS ======== - -CThumbnailFormatObserver::CThumbnailFormatObserver ( CThumbnailServer* aServer): - iServer( aServer ) - { - TN_DEBUG1( "CThumbnailFormatObserver::CThumbnailFormatObserver()"); - - } - - -// --------------------------------------------------------------------------- -// Second Phase Constructor -// --------------------------------------------------------------------------- -// -void CThumbnailFormatObserver::ConstructL() - { - TN_DEBUG1("CThumbnailFormatObserver::ConstructL in"); - - iBackupSession = CBaBackupSessionWrapper::NewL(); - iBackupSession->RegisterBackupOperationObserverL( *this ); - - - TN_DEBUG1("CThumbnailFormatObserver::ConstructL out"); - } - - -// --------------------------------------------------------------------------- -// Two-Phased Constructor -// --------------------------------------------------------------------------- -// -CThumbnailFormatObserver* CThumbnailFormatObserver::NewL(CThumbnailServer* aServer ) - { - CThumbnailFormatObserver* self = CThumbnailFormatObserver::NewLC( aServer ); - CleanupStack::Pop( self ); - return self; - } - - -// --------------------------------------------------------------------------- -// Two-Phased Constructor -// --------------------------------------------------------------------------- -// -CThumbnailFormatObserver* CThumbnailFormatObserver::NewLC( CThumbnailServer* aServer ) - { - CThumbnailFormatObserver* self = new( ELeave ) CThumbnailFormatObserver( aServer ); - CleanupStack::PushL( self ); - self->ConstructL(); - return self; - } - - -// --------------------------------------------------------------------------- -// destructor -// --------------------------------------------------------------------------- -// -CThumbnailFormatObserver::~CThumbnailFormatObserver() - { - - if( iBackupSession ) - { - iBackupSession->DeRegisterBackupOperationObserver( *this ); - } - delete iBackupSession; - } - -// --------------------------------------------------------------------------- -// Checks the current status -// --------------------------------------------------------------------------- -// -void CThumbnailFormatObserver::PollStatus() - { - - TN_DEBUG1("CThumbnailFormatObserver::PollStatus()"); - - TBool aFormatting = iBackupSession->IsBackupOperationRunning(); - - if( aFormatting ) - { - TRAP_IGNORE(iServer->CloseRemovableDrivesL()); - } - } - -// --------------------------------------------------------------------------- -// CThumbnailFormatObserver::HandleBackupOperationEventL -// Handles a format operation -// --------------------------------------------------------------------------- -// -void CThumbnailFormatObserver::HandleBackupOperationEventL( - const TBackupOperationAttributes& aBackupOperationAttributes) - { - TN_DEBUG1("CThumbnailFormatObserver::HandleBackupOperationEventL in"); - - if( aBackupOperationAttributes.iOperation == EStart ) - { - TRAP_IGNORE(iServer->CloseRemovableDrivesL()); - } - else // TOperationType::EEnd or TOperationType::EAbort - { - TRAP_IGNORE(iServer->OpenRemovableDrivesL()); - } - - TN_DEBUG1("CThumbnailFormatObserver::HandleBackupOperationEventL out"); - } diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -71,6 +71,7 @@ // scaled bitmaps to pool by default iScaledBitmapToPool = ETrue; + iBitmapHandle = 0; } @@ -94,10 +95,10 @@ delete iMissingSizes; } - if ( iBitmap ) + if ( iBitmapHandle ) { - iServer.DeleteBitmapFromPool( iBitmap->Handle()); - iBitmap = NULL; + iServer.DeleteBitmapFromPool( iBitmapHandle ); + iBitmapHandle = 0; } iProvider = NULL; @@ -319,8 +320,8 @@ CleanupStack::PushL( aBitmap ); iServer.AddBitmapToPoolL( iRequestId.iSession, aBitmap, iRequestId ); - // Keep pointer so we can delete bitmap from pool - iBitmap = aBitmap; + // Keep handle so we can delete bitmap from pool + iBitmapHandle = aBitmap->Handle(); CleanupStack::Pop( aBitmap ); // compTask is the scale task which returns the bitmap to the client @@ -355,7 +356,7 @@ } CThumbnailScaleTask* scaleTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename, - iBitmap, iOriginalSize, (*iMissingSizes)[ i ].iSize, (*iMissingSizes)[ i ].iCrop, iDisplayMode, + aBitmap, iOriginalSize, (*iMissingSizes)[ i ].iSize, (*iMissingSizes)[ i ].iCrop, iDisplayMode, KMaxPriority, iTargetUri, (*iMissingSizes)[ i ].iType, iModified, iScaledBitmapToPool, iEXIF, iRequestId); CleanupStack::PushL( scaleTask ); @@ -391,7 +392,7 @@ if( i == 0 ) { // compTask is now responsible for completing the RMessage - scaleTask->SetMessageData( iRequestId, iMessage ); + scaleTask->SetMessageData( iRequestId, iMessage, iClientThread ); ResetMessageData(); } } @@ -412,7 +413,7 @@ } complTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename, - iBitmap, iOriginalSize, iSize, iFlags& CThumbnailManager + aBitmap, iOriginalSize, iSize, iFlags& CThumbnailManager ::ECropToAspectRatio, iDisplayMode, KMaxPriority, iTargetUri, iThumbnailSize, iModified, iScaledBitmapToPool, iEXIF, iRequestId ); CleanupStack::PushL( complTask ); @@ -446,13 +447,14 @@ // compTask is now responsible for completing the RMessage and // returning the bitmap to the client - complTask->SetMessageData( iRequestId, iMessage ); + complTask->SetMessageData( iRequestId, iMessage, iClientThread ); ResetMessageData(); } // Scale tasks now reference the bitmap in the pool - iServer.DeleteBitmapFromPool( iBitmap->Handle()); - iBitmap = NULL; + iServer.DeleteBitmapFromPool( iBitmapHandle ); + iBitmapHandle = 0; + aBitmap = NULL; } // --------------------------------------------------------------------------- diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -101,7 +101,7 @@ else { TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - Don't ever come here!" ); - if (ClientThreadAlive(EFalse)) + if (ClientThreadAlive()) { Complete( KErrNotFound ); ResetMessageData(); @@ -114,7 +114,7 @@ TN_DEBUG1( "CThumbnailMDSQueryTask::HandleQueryCompleted() - No results." ); if(!iDelete) { - if (ClientThreadAlive(EFalse)) + if (ClientThreadAlive()) { Complete( KErrNotFound ); ResetMessageData(); @@ -133,18 +133,18 @@ TN_DEBUG2( "CThumbnailMDSQueryTask(0x%08x)::StartL()", this ); CThumbnailTask::StartL(); - - // get client thread - TInt err = iMessage.Client( iClientThread ); - if (err != KErrNone) + + if (iMessage.Handle()) { - TN_DEBUG2( "CThumbnailTask(0x%08x)::ClientThreadAlive() - client thread not found", this); - + // start query + iQuery->FindL(); + } + else + { + // no point to continue + Complete( KErrCancel ); ResetMessageData(); } - - // start query - iQuery->FindL(); } @@ -198,7 +198,7 @@ // void CThumbnailMDSQueryTask::ReturnPath(const TDesC& aUri) { - if ( ClientThreadAlive(EFalse) ) + if ( ClientThreadAlive() ) { // add path to message TInt ret = iMessage.Read( 0, iRequestParams ); diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -97,7 +97,6 @@ iBitmapInPool = ETrue; iScaledBitmap = NULL; - iScaledBitmapHandle = 0; } @@ -118,14 +117,6 @@ iServer.DeleteBitmapFromPool( iBitmap->Handle()); } - if ( iScaledBitmapHandle ) - { - TN_DEBUG1("CThumbnailScaleTask()::~CThumbnailScaleTask() delete scaled bitmap from pool"); - - // Scaled bitmap is owned by server, decrease reference count - iServer.DeleteBitmapFromPool( iScaledBitmapHandle ); - } - // Scaled bitmap is owned by us, delete now delete iScaledBitmap; } @@ -369,46 +360,38 @@ if ( ClientThreadAlive() ) { - TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap handle to params"); - TThumbnailRequestParams& params = iParamsBuf(); iMessage.ReadL( 0, iParamsBuf ); // if need to add scaled bitmap to pool if (iBitmapToPool) { - TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap to pool"); + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap handle to params"); params.iBitmapHandle = iScaledBitmap->Handle(); - - iServer.AddBitmapToPoolL( iRequestId.iSession, iScaledBitmap, iRequestId ); - iScaledBitmapHandle = params.iBitmapHandle; } if( params.iQualityPreference == CThumbnailManager::EOptimizeForQualityWithPreview && iEXIF && !iDoStore) { + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() EThumbnailPreviewThumbnail"); + // this is upscaled preview image params.iControlFlags = EThumbnailPreviewThumbnail; - TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() EThumbnailPreviewThumbnail"); } - - // Server owns the bitmap now. If the code below leaves, we will - // release the bitmap reference in destructor using iScaledBitmapHandle. - if (iBitmapToPool) - { - iScaledBitmap = NULL; - } TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() write params to message"); // pass bitmap handle to client iMessage.WriteL( 0, iParamsBuf ); - // Successfully completed the message. The client will send - // EReleaseBitmap message later to delete the bitmap from pool. - // CThumbnailScaleTask is no longer responsible for that. - iScaledBitmapHandle = 0; + if (iBitmapToPool) + { + TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() scaled bitmap to pool"); + + iServer.AddBitmapToPoolL( iRequestId.iSession, iScaledBitmap, iRequestId ); + iScaledBitmap = NULL; // Server owns the bitmap now + } } TN_DEBUG1("CThumbnailScaleTask()::StoreAndCompleteL() - end"); diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -36,7 +36,6 @@ #include "thumbnailcenrep.h" #include "thumbnailmemorycardobserver.h" #include "tmgetimei.h" -//#include "thumbnailfetchedchecker.h" _LIT8( KThumbnailMimeWildCard, "*" ); @@ -220,6 +219,9 @@ iShutdownObserver = CTMShutdownObserver::NewL( *this, KTMPSNotification, KShutdown, ETrue ); iShutdown = EFalse; + // MDS session reconnect timer + iReconnect = CPeriodic::NewL(CActive::EPriorityIdle); + // connect to MDS iMdESession = CMdESession::NewL( *this ); @@ -252,10 +254,6 @@ //OpenStoresL(); AddUnmountObserversL(); - - iReconnect = CPeriodic::NewL(CActive::EPriorityIdle); - - //iFetchedChecker = CThumbnailFetchedChecker::NewL(); } @@ -269,7 +267,6 @@ iShutdown = ETrue; - //delete iFetchedChecker; delete iShutdownObserver; delete iProcessor; @@ -539,10 +536,6 @@ { TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!"); } - /*if( iFetchedChecker ) - { - iFetchedChecker->SetFetchResult( aPath, KErrNone ); - }*/ } @@ -554,17 +547,8 @@ aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aOriginalSize ) { TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aPath=%S aThumbnailSize=%d)", &aPath, aThumbnailSize ); + StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize); -/* TInt err( iFetchedChecker->LastFetchResult( aPath ) ); - if ( err == KErrNone ) // To avoid useless sql gets that fails for sure - { - TRAP( err, StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize) ); - if ( err != KErrNone ) - { - iFetchedChecker->SetFetchResult( aPath, err ); - } - } - User::LeaveIfError( err );*/ } @@ -616,21 +600,16 @@ TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath); StoreForPathL( aPath )->DeleteThumbnailsL( aPath ); - /* - if( iFetchedChecker ) - { - iFetchedChecker->SetFetchResult( aPath, KErrNone ); - }*/ } // ----------------------------------------------------------------------------- // CThumbnailServer::ResolveMimeTypeL() // ----------------------------------------------------------------------------- // -TDataType CThumbnailServer::ResolveMimeTypeL( RFile& aFile ) +TDataType CThumbnailServer::ResolveMimeTypeL( RFile64& aFile ) { TN_DEBUG1( "CThumbnailStore::ResolveMimeTypeL()"); - RFile tmp = aFile; + RFile64 tmp = aFile; // check if DRM ContentAccess::CData* data = ContentAccess::CData::NewLC( diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -42,6 +42,8 @@ CThumbnailServerSession::CThumbnailServerSession(): CSession2() { iBitmapHandle = 0; + iBitmap = NULL; + iBuffer = NULL; } @@ -160,15 +162,33 @@ // void CThumbnailServerSession::ServiceL( const RMessage2& aMessage ) { - __ASSERT_DEBUG( !iMessage.Handle(), ThumbnailPanic( - EThumbnailMessageNotCompleted )); + TN_DEBUG1( "CThumbnailServerSession::ServiceL() - begin" ); + + __ASSERT_DEBUG( !iMessage.Handle(), ThumbnailPanic(EThumbnailMessageNotCompleted)); if ( iMessage.Handle()) { iMessage.Complete( KErrUnknown ); iMessage = RMessage2(); } + iMessage = aMessage; + if ( iMessage.Handle()) + { + // get client thread + TInt err = iMessage.Client( iClientThread ); + if (err != KErrNone) + { + TN_DEBUG1( "CThumbnailServerSession::ServiceL() - client thread not found"); + + iMessage = RMessage2(); + } + } + else + { + TN_DEBUG1( "CThumbnailServerSession::ServiceL() - message null"); + } + // clean up possible trash if (iBitmapHandle) { @@ -183,20 +203,23 @@ TInt ret = KErrNone; - TRAPD( err, - { - ret = DispatchMessageL( aMessage ); - } - ); + TRAPD( err, ret = DispatchMessageL( aMessage ) ); + + // if message was not completed, or Leave occurred if ( iMessage.Handle()) { - iMessage.Complete( ConvertSqlErrToE32Err( err != KErrNone ? err : ret )); + if ( ClientThreadAlive() ) + { + iMessage.Complete( ConvertSqlErrToE32Err( err != KErrNone ? err : ret )); + } + iMessage = RMessage2(); } - else - { - return; - } + + // close thread handle + iClientThread.Close(); + + TN_DEBUG1( "CThumbnailServerSession::ServiceL() - end" ); } @@ -344,7 +367,7 @@ CleanupStack::PushL( task ); task->QueryPathByIdL(params.iThumbnailId, EFalse); - task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage, iClientThread ); Server()->QueueTaskL( task ); CleanupStack::Pop( task ); // owned by processor now @@ -441,7 +464,7 @@ ->Processor(), * Server(), iBuffer, params.iPriority, params.iDisplayMode ); CleanupStack::PushL( task ); - task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage, iClientThread ); Server()->QueueTaskL( task ); CleanupStack::Pop( task ); // owned by processor now @@ -518,7 +541,7 @@ ->Processor(), * Server(), iBuffer, params.iPriority, params.iDisplayMode ); CleanupStack::PushL( task ); - task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), iMessage, iClientThread ); Server()->QueueTaskL( task ); CleanupStack::Pop( task ); // owned by processor now @@ -626,7 +649,11 @@ CFbsBitmap* bitmap = new( ELeave )CFbsBitmap(); CleanupStack::PushL( bitmap ); User::LeaveIfError( bitmap->Duplicate( bitmapHandle ) ); + + // use pool to prevent bitmap leak + // this bitmap is shared to several scale tasks, one of which can Leave Server()->AddBitmapToPoolL( reqId.iSession, bitmap, reqId ); + CleanupStack::Pop( bitmap ); iBitmapHandle = bitmap->Handle(); @@ -687,7 +714,7 @@ if( i == 0 ) { // scaleTask is now responsible for completing the RMessage - scaleTask->SetMessageData( reqId, iMessage ); + scaleTask->SetMessageData( reqId, iMessage, iClientThread ); iMessage = RMessage2(); } } @@ -706,6 +733,7 @@ missingSizes = NULL; } + // Scale tasks now reference the bitmap in the pool Server()->DeleteBitmapFromPool( iBitmapHandle ); iBitmapHandle = 0; bitmap = NULL; @@ -790,8 +818,7 @@ CleanupStack::Pop( aFile ); CleanupStack::PushL( task ); - task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), - iMessage ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ),iMessage, iClientThread ); Server()->QueueTaskL( task ); CleanupStack::Pop( task ); // owned by processor now @@ -898,8 +925,7 @@ } CleanupStack::PushL( task ); - task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ), - iMessage ); + task->SetMessageData( TThumbnailServerRequestId( this, params.iRequestId ),iMessage, iClientThread ); Server()->QueueTaskL( task ); CleanupStack::Pop( task ); // owned by processor now @@ -920,9 +946,12 @@ { TN_DEBUG1("CThumbnailServerSession::FetchThumbnailL()"); __ASSERT_DEBUG( !iBitmap, ThumbnailPanic( EThumbnailBitmapNotReleased )); + __ASSERT_DEBUG( !iBuffer, ThumbnailPanic( EThumbnailBitmapNotReleased )); delete iBitmap; iBitmap = NULL; + delete iBuffer; + iBuffer = NULL; TThumbnailRequestParams& params = iRequestParams(); @@ -971,22 +1000,12 @@ EFalse, EFalse); } - if ( ClientThreadAlive(iMessage) ) + if ( ClientThreadAlive() ) { - // No need to scale, return iBitmap directly + TN_DEBUG2("CThumbnailServerSession::ProcessBitmapL(), iBitmap handle= 0x%08x", iBitmap->Handle()); - TThumbnailServerRequestId &reqId = (TThumbnailServerRequestId&)params.iRequestId; - // No need to scale, return iBitmap directly - Server()->AddBitmapToPoolL( this, iBitmap, reqId ); - - CFbsBitmap* bitmap = iBitmap; - - TN_DEBUG2("CThumbnailServerSession::ProcessBitmapL(), iBitmap handle= 0x%08x", bitmap->Handle()); - - iBitmap = NULL; // owned by server now - - params.iBitmapHandle = bitmap->Handle(); - const TSize bitmapSize = bitmap->SizeInPixels(); + params.iBitmapHandle = iBitmap->Handle(); + const TSize bitmapSize = iBitmap->SizeInPixels(); if ( params.iQualityPreference == CThumbnailManager ::EOptimizeForQualityWithPreview && bitmapSize.iWidth < @@ -1000,8 +1019,15 @@ iMessage.WriteL( 0, iRequestParams ); + TN_DEBUG1("CThumbnailServerSession()::ProcessBitmapL() bitmap to pool"); + + TThumbnailServerRequestId &reqId = (TThumbnailServerRequestId&)params.iRequestId; + Server()->AddBitmapToPoolL( this, iBitmap, reqId ); + iMessage.Complete( KErrNone ); iMessage = RMessage2(); + + iBitmap = NULL; // owned by server now } else { @@ -1029,6 +1055,8 @@ // TInt CThumbnailServerSession::CancelRequest( const RMessage2& aMessage ) { + TN_DEBUG1( "CThumbnailServerSession::CancelRequest()" ); + const TThumbnailServerRequestId requestId( this, aMessage.Int0()); const TInt err = Server()->DequeTask( requestId ); TN_DEBUG4( @@ -1044,6 +1072,8 @@ // TInt CThumbnailServerSession::ChangePriority( const RMessage2& aMessage ) { + TN_DEBUG1( "CThumbnailServerSession::ChangePriority()" ); + const TThumbnailServerRequestId requestId( this, aMessage.Int0()); const TInt newPriority = aMessage.Int1(); @@ -1129,6 +1159,8 @@ // void CThumbnailServerSession::GetMimeTypeListL( const RMessage2& aMessage ) { + TN_DEBUG1( "CThumbnailServerSession::GetMimeTypeListL()" ); + TInt len = aMessage.GetDesMaxLengthL( 0 ); HBufC* buf = HBufC::NewLC( len ); TPtr ptr = buf->Des(); @@ -1332,33 +1364,20 @@ // Checks if client thread is still alive and RMessage2 handle valid. // --------------------------------------------------------------------------- // -TBool CThumbnailServerSession::ClientThreadAlive(RMessage2& aMessage) +TBool CThumbnailServerSession::ClientThreadAlive() { - if ( aMessage.Handle()) - { - RThread clientThread; + TN_DEBUG1( "CThumbnailServerSession::ClientThreadAlive()"); - // get client thread - TInt err = aMessage.Client( clientThread ); - if (err != KErrNone) - { - TN_DEBUG1( "CThumbnailServerSession::ClientThreadAlive() - client thread not found"); - - aMessage = RMessage2(); - - return EFalse; - } - + if ( iMessage.Handle()) + { // check if client thread alive - TExitType exitType = clientThread.ExitType(); - - clientThread.Close(); + TExitType exitType = iClientThread.ExitType(); if( exitType != EExitPending ) { TN_DEBUG1( "CThumbnailServerSession::ClientThreadAlive() - client thread died"); - aMessage = RMessage2(); + iMessage = RMessage2(); return EFalse; } @@ -1370,6 +1389,7 @@ } else { + TN_DEBUG1( "CThumbnailServerSession::ClientThreadAlive() - message null"); return EFalse; } } diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -41,6 +41,8 @@ const TInt KMajor = 3; const TInt KMinor = 2; +const TInt KStoreUnrecoverableErr = KErrCorrupt; + // Database path without drive letter _LIT( KThumbnailDatabaseName, ":[102830AB]thumbnail_v3.db" ); @@ -61,7 +63,6 @@ // No implementation required } - // --------------------------------------------------------------------------- // RThumbnailTransaction::BeginL() // --------------------------------------------------------------------------- @@ -84,7 +85,6 @@ } } - // --------------------------------------------------------------------------- // RThumbnailTransaction::Close() // --------------------------------------------------------------------------- @@ -97,7 +97,6 @@ } } - // --------------------------------------------------------------------------- // RThumbnailTransaction::CommitL() // --------------------------------------------------------------------------- @@ -115,7 +114,6 @@ iState = EClosed; } - // --------------------------------------------------------------------------- // RThumbnailTransaction::Rollback() // --------------------------------------------------------------------------- @@ -130,6 +128,7 @@ return err; } + // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------------------------- @@ -179,24 +178,24 @@ iAutoFlushTimer = NULL; } + CloseStatements(); iDatabase.Close(); + TN_DEBUG1( "CThumbnailStore::~CThumbnailStore() - database closed" ); } - // --------------------------------------------------------------------------- // CThumbnailStore::CThumbnailStore() // C++ default constructor can NOT contain any code, that might leave. // --------------------------------------------------------------------------- // -CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer ): +CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer ): iFs( aFs ), iDrive( aDrive ), iDriveChar( 0 ), iBatchItemCount(0), iImei(aImei), - iServer(aServer), iDiskFull(EFalse) + iServer(aServer), iDiskFull(EFalse), iUnrecoverable(ETrue) { // no implementation required } - // --------------------------------------------------------------------------- // CThumbnailStore::ConstructL() // Symbian 2nd phase constructor can leave. @@ -226,12 +225,11 @@ TN_DEBUG2( "CThumbnailStore::ConstructL() drive: %d", iDrive ); OpenDatabaseL(); - + // to monitor device activity iActivityManager = CTMActivityManager::NewL( this, KStoreMaintenanceIdle); iActivityManager->Start(); - // once in every mount iDeleteThumbs = ETrue; iCheckFilesExist = ETrue; iLastCheckedRowID = -1; @@ -259,91 +257,97 @@ // --------------------------------------------------------------------------- // OpenDatabaseL database // --------------------------------------------------------------------------- -TInt CThumbnailStore::OpenDatabaseL() +TInt CThumbnailStore::OpenDatabaseL( TBool aNewDatabase ) { TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() drive: %d", iDrive ); iDatabase.Close(); + iUnrecoverable = ETrue; - TBool newDatabase(EFalse); - TInt error = KErrNone; + TInt checkError = KErrNone; + TInt blistError = KErrNone; + TInt blistError2 = KErrNone; + TInt imeiError = KErrNone; + TInt err = KErrNone; - TInt err = OpenDatabaseFileL(); - - TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() -- err = %d", err); - - if ( err == KErrNotFound ) + if (aNewDatabase) + { + // delete existing and create new + CleanupClosePushL(iDatabase); + RecreateDatabaseL(ETrue); + CleanupStack::Pop(&iDatabase); + } + else { - // db not found, create new - RecreateDatabaseL( EFalse); - newDatabase = ETrue; - err = KErrNone; - } - else if ( err == KErrNone) - { - // db found, check version and rowids - error = CheckVersionL(); - if(error == KErrNone) + // just open old + err = OpenDatabaseFileL(); + + TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() -- err = %d", err); + + if ( err == KErrNone) + { + // db found, check version and rowids + checkError = CheckVersion(); + if(checkError == KErrNone) + { + checkError = CheckRowIDs(); + } + } + else { - error = CheckRowIDsL(); - } + // if db file not found, wrong version, corrupted database or other error opening db + if ( checkError == KErrNotSupported || err != KErrNone ) + { + CleanupClosePushL(iDatabase); + RecreateDatabaseL(ETrue); + CleanupStack::Pop(&iDatabase); + + aNewDatabase = ETrue; + } + } + } + + // opened existing database file + if(!aNewDatabase) + { + // add temp tables + CreateTempTablesL(); + + //check ownership + imeiError = CheckImei(); + + if(imeiError != KErrNone) + { + //take ownership + imeiError = UpdateImeiL(); + + //Touch blacklisted items + TRAP(blistError, PrepareBlacklistedItemsForRetryL() ); + } + + //check if MMC is known + if(CheckMediaIDL() != KErrNone) + { + //Touch blacklisted items + TRAP(blistError2, PrepareBlacklistedItemsForRetryL() ); + } + + if(imeiError == KSqlErrCorrupt || imeiError == KErrCorrupt || + blistError == KSqlErrCorrupt || blistError == KErrCorrupt || + blistError2 == KSqlErrCorrupt || blistError2 == KErrCorrupt ) + { + CleanupClosePushL(iDatabase); + RecreateDatabaseL(ETrue); + CleanupStack::Pop(&iDatabase); + } } - TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() -- error = %d", error); - - // if wrong version, corrupted database or other error opening db - if ( error == KErrNotSupported || (err != KErrNone && err != KErrNotFound) ) - { - RecreateDatabaseL( ETrue); - } - else if(!newDatabase) - { - if(ResetThumbnailIDs() == KSqlErrCorrupt) - { - RecreateDatabaseL( ETrue); - } - - //check ownership - error = CheckImeiL(); - - if(error != KErrNone) - { - if(error == KSqlErrCorrupt) - { - RecreateDatabaseL( ETrue); - } - //take ownership - error = UpdateImeiL(); - - if(error == KSqlErrCorrupt) - { - RecreateDatabaseL( ETrue); - } - - //Touch blacklisted items - TRAP(error, PrepareBlacklistedItemsForRetryL( ) ); - - if(error == KSqlErrCorrupt) - { - RecreateDatabaseL( ETrue); - } - } - - //check is MMC known - if(CheckMediaIDL() != KErrNone ) - { - //Touch blacklisted items - TRAP(error, PrepareBlacklistedItemsForRetryL() ); - - if(error == KSqlErrCorrupt) - { - RecreateDatabaseL( ETrue); - } - } - } - - PrepareDbL(); - return KErrNone; + PrepareStatementsL(); + + // database now usable + iUnrecoverable = EFalse; + + return KErrNone; } // --------------------------------------------------------------------------- @@ -353,22 +357,59 @@ void CThumbnailStore::PrepareDbL() { TN_DEBUG1( "CThumbnailStore::PrepareDbL()" ); - TInt err(KErrNone); - // add tables - TRAPD(tableError, CreateTablesL() ); + // add persistent tables + CreateTablesL(); - if(!tableError) - { - TRAPD(err, AddVersionAndImeiL()); - if (err == KSqlErrCorrupt) - { - RecreateDatabaseL( ETrue); - } - User::LeaveIfError(err); - } - - err = iDatabase.Exec( KThumbnailCreateTempInfoTable ); + AddVersionAndImeiL(); + + // add temp tables + CreateTempTablesL(); + } + +// --------------------------------------------------------------------------- +// Create database tables +// --------------------------------------------------------------------------- +// +void CThumbnailStore::CreateTablesL() + { + TN_DEBUG1( "CThumbnailStore::CreateTablesL()" ); + + TInt err = KErrNone; + err = iDatabase.Exec( KThumbnailCreateInfoTable ); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTable err=%d", err ); + User::LeaveIfError( err ); + + err = iDatabase.Exec( KThumbnailCreateInfoDataTable ); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoDataTable err=%d", err ); + User::LeaveIfError( err ); + + err = iDatabase.Exec(KThumbnailDeletedTable); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailDeletedTable err=%d", err ); + User::LeaveIfError( err ); + + err = iDatabase.Exec( KThumbnailCreateInfoTableIndex1 ); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex1 err=%d", err ); + User::LeaveIfError( err ); + + err = iDatabase.Exec( KThumbnailCreateDeletedTableIndex ); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateDeletedTableIndex err=%d", err ); + User::LeaveIfError( err ); + + err = iDatabase.Exec(KThumbnailVersionTable); + TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailVersionTable err=%d", err ); + User::LeaveIfError( err ); + } + +// --------------------------------------------------------------------------- +// Create temp tables +// --------------------------------------------------------------------------- +// +void CThumbnailStore::CreateTempTablesL() + { + TN_DEBUG1( "CThumbnailStore::CreateTempTablesL()" ); + + TInt err = iDatabase.Exec( KThumbnailCreateTempInfoTable ); #ifdef _DEBUG if(err < 0) @@ -391,35 +432,6 @@ #endif User::LeaveIfError( err ); -} - -// --------------------------------------------------------------------------- -// Create database tables -// --------------------------------------------------------------------------- -// -void CThumbnailStore::CreateTablesL() - { - TN_DEBUG1( "CThumbnailStore::CreateTablesL()" ); - - TInt err = 0; - err = iDatabase.Exec( KThumbnailCreateInfoTable ); - TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTable err=%d", err ); - err = iDatabase.Exec( KThumbnailCreateInfoDataTable ); - TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoDataTable err=%d", err ); - - err = iDatabase.Exec(KThumbnailDeletedTable); - TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailDeletedTable err=%d", err ); - - err = iDatabase.Exec(KThumbnailVersionTable); - TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailVersionTable err=%d", err ); - - err = iDatabase.Exec( KThumbnailCreateInfoTableIndex1 ); - TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex1 err=%d", err ); - - err = iDatabase.Exec( KThumbnailCreateDeletedTableIndex ); - TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateDeletedTableIndex err=%d", err ); - - User::LeaveIfError( err ); } void CThumbnailStore::RecreateDatabaseL(const TBool aDelete) @@ -427,13 +439,13 @@ TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() drive: %d", iDrive ); TVolumeInfo volumeinfo; - iFs.Volume(volumeinfo, iDrive); + User::LeaveIfError( iFs.Volume(volumeinfo, iDrive) ); TUint id = volumeinfo.iUniqueID; TBuf<50> mediaid; mediaid.Num(id); - - // delete db and create new + iDatabase.Close(); + iUnrecoverable = ETrue; TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() database closed" ); @@ -445,11 +457,12 @@ TInt err(KErrNone); + // delete old if necessary if(aDelete) { TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() delete database" ); - TInt del = iDatabase.Delete(pathPtr); - TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() deleted database, err: %d", del ); + TInt del = iDatabase.Delete(pathPtr); + TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() deleted database, err: %d", del ); } const TDesC8& config = KThumbnailSqlConfig; @@ -458,21 +471,542 @@ CleanupClosePushL( securityPolicy ); securityPolicy.CreateL( KThumbnailDatabaseSecurityPolicy ); + // create new TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() create new" ); - - TRAP(err, iDatabase.CreateL( pathPtr, securityPolicy, &config )); - - TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- database created err = %d", err ); + TRAP(err, iDatabase.CreateL( pathPtr, securityPolicy, &config )); + TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- database created, err = %d", err ); + User::LeaveIfError(err); CleanupStack::PopAndDestroy( &securityPolicy ); + + // add tables + TRAPD(prepareErr, PrepareDbL() ); + + TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- prepare tables, err = %d", prepareErr ); + + TInt mediaidErr(KErrNone); + + // write media id file if doesn't exist + if(!BaflUtils::FileExists( iFs, mediaid )) + { + RFile64 file; + mediaidErr = file.Create(iFs, mediaid, EFileShareReadersOrWriters ); + file.Close(); + + TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- mediaID file created, err = %d", mediaidErr ); + } + + // delete db if not fully complete + if (prepareErr < 0 || mediaidErr < 0) + { + iDatabase.Close(); + TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() delete database" ); + TInt del = iDatabase.Delete(pathPtr); + TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() deleted database, err: %d", del ); + } + + User::LeaveIfError( prepareErr ); + User::LeaveIfError( mediaidErr ); + CleanupStack::PopAndDestroy( databasePath ); + } + +TInt CThumbnailStore::CheckRowIDs() + { + TN_DEBUG1( "CThumbnailStore::CheckRowIDs()"); + + RSqlStatement stmt; + TInt column = 0; + TInt rowStatus = 0; + TInt64 inforows = -1; + TInt64 datarows = -1; + + TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID ); + if(ret < 0) + { + stmt.Close(); + TN_DEBUG1( "CThumbnailStore::CheckRowIDs() failed 1 %d"); + return KErrNotSupported; + } + rowStatus = stmt.Next(); + + if ( rowStatus == KSqlAtRow) + { + inforows = stmt.ColumnInt64( column ); + } + + stmt.Close(); + + if(ret < 0) + { +#ifdef _DEBUG + TPtrC errorMsg2 = iDatabase.LastErrorMessage(); + TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2); +#endif + return ret; + } + + ret = stmt.Prepare( iDatabase, KGetDataRowID ); + if(ret < 0) + { + stmt.Close(); + TN_DEBUG1( "CThumbnailStore::CheckRowIDs() failed 2"); + return KErrNotSupported; + } + rowStatus = stmt.Next(); + + if ( rowStatus == KSqlAtRow) + { + datarows = stmt.ColumnInt64( column ); + } + + stmt.Close(); + + if(ret < 0) + { +#ifdef _DEBUG + TPtrC errorMsg2 = iDatabase.LastErrorMessage(); + TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2); +#endif + return ret; + } + + if( inforows != datarows) + { + TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" ); + return KErrNotSupported; + } + else + { + return KErrNone; + } + } + +// ----------------------------------------------------------------------------- +// CheckVersion() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailStore::CheckVersion() + { + TN_DEBUG1( "CThumbnailStore::CheckVersion()" ); + RSqlStatement stmt; + + TInt rowStatus = 0; + TInt column = 0; + TInt minor = 0; + TInt major = 0; + + TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion ); + if(ret < 0 ) + { + stmt.Close(); + TN_DEBUG1( "CThumbnailStore::CheckVersion() unknown version" ); + return KErrNotSupported; + } + + rowStatus = stmt.Next(); + + if ( rowStatus == KSqlAtRow) + { + major = stmt.ColumnInt( column++); + minor = stmt.ColumnInt( column++); + } + + stmt.Close(); + + if(ret < 0 ) + { +#ifdef _DEBUG + TPtrC errorMsg = iDatabase.LastErrorMessage(); + TN_DEBUG2( "RThumbnailTransaction::CheckVersion() lastError %S, ret = %d" , &errorMsg); +#endif + return ret; + } + + if(major == KMajor && minor == KMinor ) + { + return KErrNone; + } + else + { + TN_DEBUG1( "CThumbnailStore::CheckVersion() - wrong DB version" ); + return KErrNotSupported; + } + } + +// ----------------------------------------------------------------------------- +// CheckImei() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailStore::CheckImei() + { + TN_DEBUG1( "CThumbnailStore::CheckImei()" ); + RSqlStatement stmt; + + TInt rowStatus = 0; + TInt column = 0; + TBuf imei; + + TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion ); + if(ret < 0 ) + { + stmt.Close(); + TN_DEBUG1( "CThumbnailStore::CheckImei() failed" ); + return KErrNotSupported; + } + + rowStatus = stmt.Next(); + + if ( rowStatus == KSqlAtRow) + { + column = 2; // imei column + stmt.ColumnText( column, imei); + } + + stmt.Close(); + + if(ret < 0 ) + { +#ifdef _DEBUG + TPtrC errorMsg = iDatabase.LastErrorMessage(); + TN_DEBUG2( "RThumbnailTransaction::CheckImei() lastError %S, ret = %d" , &errorMsg); +#endif + return ret; + } + + if( imei == iImei ) + { + return KErrNone; + } + else + { + TN_DEBUG1( "CThumbnailStore::CheckImei() mismatch" ); + return KErrNotSupported; + } + } + +// ----------------------------------------------------------------------------- +// CheckMediaID() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailStore::CheckMediaIDL() + { + TN_DEBUG1( "CThumbnailStore::CheckMediaIDL()" ); + + TVolumeInfo volumeinfo; + User::LeaveIfError( iFs.Volume(volumeinfo, iDrive) ); + TUint id = volumeinfo.iUniqueID; + TBuf<50> mediaid; + mediaid.Num(id); + + if(!BaflUtils::FileExists( iFs, mediaid )) + { + RFile64 file; + TInt err = file.Create(iFs, mediaid, EFileShareReadersOrWriters ); + file.Close(); + TN_DEBUG2( "CThumbnailStore::CheckMediaIDL() -- mediaID file created, err = %d", err ); + + return KErrNotSupported; + } + + return KErrNone; + } + +// ---------------------------------------------------------------------------- +// AddVersionAndImeiL() +// ----------------------------------------------------------------------------- +// +void CThumbnailStore::AddVersionAndImeiL() + { + TN_DEBUG1( "CThumbnailStore::AddVersionAndImei()" ); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt paramIndex = 0; + + User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailInsertToVersion )); + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamImei ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, iImei )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamMinor ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, KMinor )); + + paramIndex = stmt.ParameterIndex( KThumbnailSqlParamMajor ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindInt( paramIndex, KMajor )); + + User::LeaveIfError( stmt.Exec()); + CleanupStack::PopAndDestroy( &stmt ); + } + +// ----------------------------------------------------------------------------- +// UpdateImeiL() +// ----------------------------------------------------------------------------- +// +TInt CThumbnailStore::UpdateImeiL() + { + TN_DEBUG1( "CThumbnailStore::UpdateImeiL()" ); + RSqlStatement stmt; + CleanupClosePushL( stmt ); + + TInt ret = stmt.Prepare( iDatabase, KThumbnailUpdateIMEI ); + + TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamImei ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt.BindText( paramIndex, iImei )); + + TInt err = stmt.Exec(); + + if(err < 0) + { +#ifdef _DEBUG + TPtrC errorMsg2 = iDatabase.LastErrorMessage(); + TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2); +#endif + return ret; + } + + CleanupStack::PopAndDestroy( &stmt ); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CThumbnailStore::PrepareStatementsL() +// --------------------------------------------------------------------------- +// +void CThumbnailStore::PrepareStatementsL() + { + TN_DEBUG1("CThumbnailStore::PrepareStatementsL()"); + + TInt err = KErrNone; +#ifdef _DEBUG + TFileName msg; +#endif + + err = iStmt_KThumbnailSelectInfoByPath.Prepare( iDatabase, KThumbnailSelectInfoByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectInfoByPath %S" , &msg ); + msg.Zero(); +#endif User::LeaveIfError( err ); - RFile64 file; - file.Create(iFs, mediaid, EFileShareReadersOrWriters ); - file.Close(); + err = iStmt_KThumbnailSelectTempInfoByPath.Prepare( iDatabase, KThumbnailSelectTempInfoByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempInfoByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailInsertTempThumbnailInfo.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfo ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailInsertTempThumbnailInfo %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailInsertTempThumbnailInfoData.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfoData ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailInsertTempThumbnailInfoData %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSelectModifiedByPath.Prepare( iDatabase, KThumbnailSelectModifiedByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectModifiedByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSelectTempModifiedByPath.Prepare( iDatabase, KThumbnailSelectTempModifiedByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempModifiedByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailFindDuplicate.Prepare( iDatabase, KThumbnailFindDuplicate ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailFindDuplicate %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailTempFindDuplicate.Prepare( iDatabase, KThumbnailTempFindDuplicate ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailTempFindDuplicate %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSqlFindDeleted.Prepare( iDatabase, KThumbnailSqlFindDeleted ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlFindDeleted %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSelectSizeByPath.Prepare( iDatabase, KThumbnailSelectSizeByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectSizeByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSelectTempSizeByPath.Prepare( iDatabase, KThumbnailSelectTempSizeByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectTempSizeByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSqlSelectRowIDInfoByPath.Prepare( iDatabase, KThumbnailSqlSelectRowIDInfoByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlSelectRowIDInfoByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); - OpenDatabaseFileL(); + err = iStmt_KThumbnailSqlDeleteInfoByPath.Prepare( iDatabase, KThumbnailSqlDeleteInfoByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSqlDeleteInfoDataByPath.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoDataByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KTempThumbnailSqlSelectRowIDInfoByPath.Prepare( iDatabase, KTempThumbnailSqlSelectRowIDInfoByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlSelectRowIDInfoByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KTempThumbnailSqlDeleteInfoByPath.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlDeleteInfoByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KTempThumbnailSqlDeleteInfoDataByPath.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoDataByPath ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KTempThumbnailSqlDeleteInfoDataByPath %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSqlInsertDeleted.Prepare( iDatabase, KThumbnailSqlInsertDeleted ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlInsertDeleted %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSqlSelectMarked.Prepare( iDatabase, KThumbnailSqlSelectMarked ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlSelectMarked %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSqlDeleteInfoByRowID.Prepare( iDatabase, KThumbnailSqlDeleteInfoByRowID ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoByRowID %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSqlDeleteInfoDataByRowID.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByRowID ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSqlDeleteInfoDataByRowID %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + err = iStmt_KThumbnailSelectAllPaths.Prepare( iDatabase, KThumbnailSelectAllPaths ); +#ifdef _DEBUG + msg.Append( iDatabase.LastErrorMessage() ); + TN_DEBUG2( "CThumbnailStore::PrepareStatementsL() KThumbnailSelectAllPaths %S" , &msg ); + msg.Zero(); +#endif + User::LeaveIfError( err ); + + TN_DEBUG1("CThumbnailStore::PrepareStatementsL() end"); + } + +// --------------------------------------------------------------------------- +// CThumbnailStore::ResetStatement() +// --------------------------------------------------------------------------- +// +void CThumbnailStore::ResetStatement( TAny* aStmt ) + { + // called by CleanupStack::PopAndDestroy() + // just reset so that there's no need to prepare again + ((RSqlStatement*)aStmt)->Reset(); + } + +// --------------------------------------------------------------------------- +// CThumbnailStore::CloseStatements() +// --------------------------------------------------------------------------- +// +void CThumbnailStore::CloseStatements() + { + TN_DEBUG1("CThumbnailStore::CloseStatements()"); + + iStmt_KThumbnailSelectInfoByPath.Close(); + iStmt_KThumbnailSelectTempInfoByPath.Close(); + iStmt_KThumbnailInsertTempThumbnailInfo.Close(); + iStmt_KThumbnailInsertTempThumbnailInfoData.Close(); + iStmt_KThumbnailSelectModifiedByPath.Close(); + iStmt_KThumbnailSelectTempModifiedByPath.Close(); + iStmt_KThumbnailFindDuplicate.Close(); + iStmt_KThumbnailTempFindDuplicate.Close(); + iStmt_KThumbnailSqlFindDeleted.Close(); + iStmt_KThumbnailSelectSizeByPath.Close(); + iStmt_KThumbnailSelectTempSizeByPath.Close(); + iStmt_KThumbnailSqlSelectRowIDInfoByPath.Close(); + iStmt_KThumbnailSqlDeleteInfoByPath.Close(); + iStmt_KThumbnailSqlDeleteInfoDataByPath.Close(); + iStmt_KTempThumbnailSqlSelectRowIDInfoByPath.Close(); + iStmt_KTempThumbnailSqlDeleteInfoByPath.Close(); + iStmt_KTempThumbnailSqlDeleteInfoDataByPath.Close(); + iStmt_KThumbnailSqlInsertDeleted.Close(); + iStmt_KThumbnailSqlSelectMarked.Close(); + iStmt_KThumbnailSqlDeleteInfoByRowID.Close(); + iStmt_KThumbnailSqlDeleteInfoDataByRowID.Close(); + iStmt_KThumbnailSelectAllPaths.Close(); + + TN_DEBUG1("CThumbnailStore::CloseStatements() end"); } // --------------------------------------------------------------------------- @@ -496,53 +1030,53 @@ CleanupClosePushL( transaction ); transaction.BeginL(); - RSqlStatement stmt; - CleanupClosePushL( stmt ); - // Insert into ThumbnailInfo - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailInsertThumbnailInfoByPathAndId )); - - TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + // Insert into TempThumbnailInfo + RSqlStatement* stmt = NULL; + stmt = &iStmt_KThumbnailInsertTempThumbnailInfo; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); + + TInt paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + User::LeaveIfError( stmt->BindText( paramIndex, aPath )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamWidth ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamWidth ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aSize.iWidth )); + User::LeaveIfError( stmt->BindInt( paramIndex, aSize.iWidth )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamHeight ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamHeight ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aSize.iHeight )); + User::LeaveIfError( stmt->BindInt( paramIndex, aSize.iHeight )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOriginalWidth ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamOriginalWidth ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aOriginalSize.iWidth )); + User::LeaveIfError( stmt->BindInt( paramIndex, aOriginalSize.iWidth )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOriginalHeight ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamOriginalHeight ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aOriginalSize.iHeight )); + User::LeaveIfError( stmt->BindInt( paramIndex, aOriginalSize.iHeight )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFormat ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamFormat ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aFormat )); + User::LeaveIfError( stmt->BindInt( paramIndex, aFormat )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamFlags ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamFlags ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aFlags )); + User::LeaveIfError( stmt->BindInt( paramIndex, aFlags )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamSize ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + User::LeaveIfError( stmt->BindInt( paramIndex, aThumbnailSize )); // orientation temporarily to 0 - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamOrientation ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamOrientation ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, 0 )); + User::LeaveIfError( stmt->BindInt( paramIndex, 0 )); // thumb from associated path TInt fromPath = aThumbFromPath; - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamThumbFromPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamThumbFromPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, fromPath )); + User::LeaveIfError( stmt->BindInt( paramIndex, fromPath )); // try getting modification time from file TTime timeStamp; @@ -587,33 +1121,24 @@ TN_DEBUG2( "CThumbnailStore::StoreThumbnailL() timeStamp set %Ld", timeStamp.Int64()); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamModified ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamModified ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt64( paramIndex, timeStamp.Int64() )); + User::LeaveIfError( stmt->BindInt64( paramIndex, timeStamp.Int64() )); - User::LeaveIfError( stmt.Exec()); - CleanupStack::PopAndDestroy( &stmt ); + User::LeaveIfError( stmt->Exec()); + CleanupStack::PopAndDestroy( stmt ); - RSqlStatement stmtData; - CleanupClosePushL( stmtData ); - // Insert into ThumbnailInfoData - TInt err = stmtData.Prepare( iDatabase, KThumbnailInsertTempThumbnailInfoData ); - -#ifdef _DEBUG - if(err < 0) - { - TPtrC errorMsg = iDatabase.LastErrorMessage(); - TN_DEBUG2( "CThumbnailStore::StoreThumbnailL() KThumbnailInsertTempThumbnailInfoData %S" , &errorMsg); - } -#endif - User::LeaveIfError( err ); + // Insert into TempThumbnailInfoData + RSqlStatement* stmtData = NULL; + stmtData = &iStmt_KThumbnailInsertTempThumbnailInfoData; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmtData)); - paramIndex = stmtData.ParameterIndex( KThumbnailSqlParamData ); + paramIndex = stmtData->ParameterIndex( KThumbnailSqlParamData ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmtData.BindBinary( paramIndex, aData )); + User::LeaveIfError( stmtData->BindBinary( paramIndex, aData )); - User::LeaveIfError( stmtData.Exec()); - CleanupStack::PopAndDestroy( &stmtData ); + User::LeaveIfError( stmtData->Exec()); + CleanupStack::PopAndDestroy( stmtData ); // Commit transaction transaction.CommitL(); @@ -648,6 +1173,8 @@ __ASSERT_DEBUG(( aThumbnail ), ThumbnailPanic( EThumbnailNullPointer )); + User::LeaveIfError( CheckDbState() ); + // don't store custom/unknown sizes or zero sizes if(aThumbnailSize == ECustomThumbnailSize || aThumbnailSize == EUnknownThumbnailSize || thumbSize.iWidth <= 0 || thumbSize.iHeight <= 0 ) @@ -685,17 +1212,26 @@ aThumbnailSize == EAudioFullScreenThumbnailSize) && !aBlackListed ) { HBufC8* data = NULL; - CImageEncoder* iEncoder = CImageEncoder::DataNewL( data, KJpegMime(), CImageEncoder::EOptionAlwaysThread ); + CleanupStack::PushL( data ); + + CImageEncoder* encoder = CImageEncoder::DataNewL( data, KJpegMime(), CImageEncoder::EOptionAlwaysThread ); + CleanupStack::Pop( data ); + CleanupStack::PushL( encoder ); + + CFrameImageData* frameImageData = CFrameImageData::NewL(); + CleanupStack::PushL( frameImageData ); + TJpegImageData* imageData = new (ELeave) TJpegImageData(); - + CleanupStack::PushL( imageData ); + // Set some format specific data imageData->iSampleScheme = TJpegImageData::EColor444; - imageData->iQualityFactor = 75; //? - - CFrameImageData* iFrameImageData = CFrameImageData::NewL(); - - // frameData - ownership passed to iFrameImageData after AppendImageData - User::LeaveIfError(iFrameImageData->AppendImageData(imageData)); + imageData->iQualityFactor = 75; + + // imageData - ownership passed to frameImageData after AppendImageData + User::LeaveIfError(frameImageData->AppendImageData(imageData)); + CleanupStack::Pop( imageData ); + #ifdef _DEBUG TN_DEBUG4( "CThumbnailStore::StoreThumbnailL() size %d x %d displaymode %d ", @@ -705,23 +1241,24 @@ #endif TRequestStatus request; - iEncoder->Convert( &request, *aThumbnail, iFrameImageData); + encoder->Convert( &request, *aThumbnail, frameImageData); User::WaitForRequest( request); - - if(request== KErrNone) - { - TPtr8 ptr = data->Des(); - StoreThumbnailL( *path, ptr, aThumbnail->SizeInPixels(), aOriginalSize, - EThumbnailFormatJpeg, flags, aThumbnailSize, aModified, aThumbFromPath ); - } - - delete iFrameImageData; - iFrameImageData = NULL; + + CleanupStack::PopAndDestroy( frameImageData ); + CleanupStack::PopAndDestroy( encoder ); - delete iEncoder; - iEncoder = NULL; + if(request == KErrNone) + { + CleanupStack::PushL( data ); + TPtr8 ptr = data->Des(); + StoreThumbnailL( *path, ptr, aThumbnail->SizeInPixels(), + aOriginalSize, EThumbnailFormatJpeg, flags, + aThumbnailSize, aModified, aThumbFromPath ); + CleanupStack::Pop( data ); + } + delete data; - data = NULL; + data = NULL; } else { @@ -732,7 +1269,8 @@ aThumbnail->ExternalizeL( stream ); StoreThumbnailL( *path, buf->Ptr( 0 ), aThumbnail->SizeInPixels(), - aOriginalSize, EThumbnailFormatFbsBitmap, flags, aThumbnailSize, aModified); + aOriginalSize, EThumbnailFormatFbsBitmap, flags, + aThumbnailSize, aModified); CleanupStack::PopAndDestroy( buf ); } @@ -754,41 +1292,42 @@ { TN_DEBUG1( "CThumbnailStore::FindDuplicateL()" ); + User::LeaveIfError( CheckDbState() ); + TInt rowStatus = 0; TInt paramIndex = 0; TInt found = EFalse; - RSqlStatement stmt; - CleanupClosePushL( stmt ); + RSqlStatement* stmt = NULL; + stmt = &iStmt_KThumbnailTempFindDuplicate; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - User::LeaveIfError( stmt.Prepare( iDatabase, KTempFindDuplicate )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + User::LeaveIfError( stmt->BindText( paramIndex, aPath )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamSize ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + User::LeaveIfError( stmt->BindInt( paramIndex, aThumbnailSize )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); //if not found from temp table, look from real table if(rowStatus != KSqlAtRow) { - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - CleanupClosePushL( stmt ); + CleanupStack::PopAndDestroy( stmt ); + stmt = &iStmt_KThumbnailFindDuplicate; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - User::LeaveIfError( stmt.Prepare( iDatabase, KFindDuplicate )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + User::LeaveIfError( stmt->BindText( paramIndex, aPath )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamSize ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + User::LeaveIfError( stmt->BindInt( paramIndex, aThumbnailSize )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); if(rowStatus == KSqlAtRow) { @@ -811,16 +1350,15 @@ // check if duplicate in Deleted if (found) { - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - CleanupClosePushL( stmt ); + CleanupStack::PopAndDestroy( stmt ); + stmt = &iStmt_KThumbnailSqlFindDeleted; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSqlFindDeleted )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, aPath )); + User::LeaveIfError( stmt->BindText( paramIndex, aPath )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); if(rowStatus == KSqlAtRow) { @@ -834,8 +1372,7 @@ } } - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); + CleanupStack::PopAndDestroy( stmt ); return found; } @@ -849,6 +1386,8 @@ { TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() aSourceType == %d", aSourceType ); + User::LeaveIfError( CheckDbState() ); + HBufC* path = aPath.AllocLC(); TPtr ptr(path->Des()); StripDriveLetterL( ptr ); @@ -862,7 +1401,7 @@ { //if generating only grid size for image or video, other sizes are not missing if( aCheckGridSizeOnly ) - { + { if( (iPersistentSizes[i].iSourceType == TThumbnailPersistentSize::EImage || iPersistentSizes[i].iSourceType == TThumbnailPersistentSize::EVideo )&& iPersistentSizes[i].iSizeType != TThumbnailPersistentSize::EGrid ) { @@ -871,12 +1410,12 @@ } else { - aMissingSizes.Append( iPersistentSizes[ i ] ); + aMissingSizes.AppendL( iPersistentSizes[ i ] ); } - } + } else { - aMissingSizes.Append( iPersistentSizes[ i ] ); + aMissingSizes.AppendL( iPersistentSizes[ i ] ); } } } @@ -886,14 +1425,15 @@ TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() missingSizeCount == %d", missingSizeCount ); // check temp table first - RSqlStatement stmt; - CleanupClosePushL( stmt ); - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempSizeByPath )); - TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + RSqlStatement* stmt = NULL; + stmt = &iStmt_KThumbnailSelectTempSizeByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); + + TInt paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - TInt rowStatus = stmt.Next(); + TInt rowStatus = stmt->Next(); TInt round = 1; TInt size = 0; @@ -902,7 +1442,7 @@ { while ( rowStatus == KSqlAtRow && missingSizeCount > 0 ) { - size = stmt.ColumnInt( 0 ); + size = stmt->ColumnInt( 0 ); missingSizeCount = aMissingSizes.Count(); for ( TInt i = 0; i < missingSizeCount; i++ ) @@ -916,10 +1456,10 @@ } } - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); } - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); + + CleanupStack::PopAndDestroy( stmt ); // all found if (missingSizeCount == 0) @@ -930,12 +1470,13 @@ else if (round == 1) { // change to real table - CleanupClosePushL( stmt ); - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectSizeByPath )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + stmt = &iStmt_KThumbnailSelectSizeByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); + + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); - rowStatus = stmt.Next(); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); + rowStatus = stmt->Next(); } round++; @@ -953,16 +1494,13 @@ aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aThumbnailRealSize ) { TN_DEBUG3( "CThumbnailStore::FetchThumbnailL(%S) aThumbnailSize==%d", &aPath, aThumbnailSize ); - delete aThumbnail; - aThumbnail = NULL; + + User::LeaveIfError( CheckDbState() ); HBufC* path = aPath.AllocLC(); TPtr ptr(path->Des()); StripDriveLetterL( ptr ); - RSqlStatement stmt; - CleanupClosePushL( stmt ); - TInt paramIndex = 0; TInt found = KErrNotFound; TInt rowStatus = 0; @@ -970,55 +1508,52 @@ TBool inTempTable = ETrue; TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- TEMP TABLE lookup" ); - TInt err = stmt.Prepare( iDatabase, KThumbnailSelectTempInfoByPath ); -#ifdef _DEBUG - TPtrC errorMsg = iDatabase.LastErrorMessage(); - TN_DEBUG2( "CThumbnailStore::FetchThumbnailL() KThumbnailSelectTempInfoByPath %S" , &errorMsg); -#endif - User::LeaveIfError( err ); + RSqlStatement* stmt = NULL; + stmt = &iStmt_KThumbnailSelectTempInfoByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamSize ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + User::LeaveIfError( stmt->BindInt( paramIndex, aThumbnailSize )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); //if not found from temp table, look from real table if(rowStatus != KSqlAtRow) { TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- MAIN TABLE lookup" ); inTempTable = EFalse; - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - CleanupClosePushL( stmt ); - - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectInfoByPath )); + + CleanupStack::PopAndDestroy( stmt ); + stmt = &iStmt_KThumbnailSelectInfoByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamSize ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamSize ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, aThumbnailSize )); + User::LeaveIfError( stmt->BindInt( paramIndex, aThumbnailSize )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); } if(rowStatus == KSqlAtRow) { TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail found" ); + // Check whether blacklisted thumbnail entry modified. // If thumbnail is marked as blacklisted and timestamp has // changed, delete thumbnails from tables and leave with // KErrNotFound to get thumbnail regenerated. column = 4; - TInt flags = stmt.ColumnInt( column ); + TInt flags = stmt->ColumnInt( column ); if( flags & KThumbnailDbFlagBlacklisted && (*path).Length() ) { TBool modified = EFalse; @@ -1026,7 +1561,6 @@ if( modified ) { // Close db to get deletion of thumbnails executed. - stmt.Close(); CleanupStack::PopAndDestroy( &stmt ); DeleteThumbnailsL( *path ); User::Leave( KErrNotFound ); @@ -1040,27 +1574,29 @@ { found = KErrNone; column = 0; - TInt format = stmt.ColumnInt( column++ ); + TInt format = stmt->ColumnInt( column++ ); if(format == 1 /*TThumbnailFormat::EThumbnailFormatJpeg */ ) - { - TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); - HBufC8* data = ptr.AllocL() ; - aThumbnail = NULL; - aData = data; - - } else { - - TPtrC8 ptr = stmt.ColumnBinaryL( column++ ); - RDesReadStream stream( ptr ); - aThumbnail = new( ELeave )CFbsBitmap(); - aThumbnail->InternalizeL( stream ); - aData = NULL; - } + { + TPtrC8 ptr = stmt->ColumnBinaryL( column++ ); + HBufC8* data = ptr.AllocL() ; + aThumbnail = NULL; + aData = data; + } + else + { + TPtrC8 ptr = stmt->ColumnBinaryL( column++ ); + RDesReadStream stream( ptr ); + aThumbnail = new( ELeave )CFbsBitmap(); + CleanupStack::PushL( aThumbnail ); + aThumbnail->InternalizeL( stream ); + CleanupStack::Pop( aThumbnail ); + aData = NULL; + } //fetch real size of TN column = 2; - aThumbnailRealSize.iWidth = stmt.ColumnInt( column++ ); - aThumbnailRealSize.iHeight = stmt.ColumnInt( column ); + aThumbnailRealSize.iWidth = stmt->ColumnInt( column++ ); + aThumbnailRealSize.iHeight = stmt->ColumnInt( column ); } } else @@ -1068,8 +1604,7 @@ TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail NOT found" ); } - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); + CleanupStack::PopAndDestroy( stmt ); CleanupStack::PopAndDestroy( path ); User::LeaveIfError( found ); @@ -1083,10 +1618,14 @@ TBool aTransaction ) { TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsL(%S)", &aPath ); + #ifdef _DEBUG TTime aStart, aStop; aStart.UniversalTime(); #endif + + User::LeaveIfError( CheckDbState() ); + TInt paramIndex = 0; TInt paramIndex1 = 0; TInt paramIndex2 = 0; @@ -1106,64 +1645,59 @@ transaction.BeginL(); } - RSqlStatement stmt; - RSqlStatement stmt_info; - RSqlStatement stmt_infodata; - - CleanupClosePushL( stmt ); - CleanupClosePushL( stmt_info ); - CleanupClosePushL( stmt_infodata ); - TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByPathL() -- TEMP TABLE lookup" ); - User::LeaveIfError( stmt.Prepare( iDatabase, KTempThumbnailSqlSelectRowIDInfoByPath) ); - User::LeaveIfError( stmt_info.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoByPath) ); - User::LeaveIfError( stmt_infodata.Prepare( iDatabase, KTempThumbnailSqlDeleteInfoDataByPath) ); + RSqlStatement* stmt = NULL; + RSqlStatement* stmt_info = NULL; + RSqlStatement* stmt_infodata = NULL; - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + stmt = &iStmt_KTempThumbnailSqlSelectRowIDInfoByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); + stmt_info = &iStmt_KTempThumbnailSqlDeleteInfoByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt_info)); + stmt_infodata = &iStmt_KTempThumbnailSqlDeleteInfoDataByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt_infodata)); + + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); while(rowStatus == KSqlAtRow) { - rowid = stmt.ColumnInt64( column ); - paramIndex1 = stmt_info.ParameterIndex( KThumbnailSqlParamRowID ); + rowid = stmt->ColumnInt64( column ); + paramIndex1 = stmt_info->ParameterIndex( KThumbnailSqlParamRowID ); User::LeaveIfError( paramIndex1 ); - User::LeaveIfError( stmt_info.BindInt64( paramIndex1, rowid )); + User::LeaveIfError( stmt_info->BindInt64( paramIndex1, rowid )); - TInt err = stmt_info.Exec(); - stmt_info.Reset(); + TInt err = stmt_info->Exec(); + stmt_info->Reset(); User::LeaveIfError( err ); - paramIndex2 = stmt_infodata.ParameterIndex( KThumbnailSqlParamRowID ); + paramIndex2 = stmt_infodata->ParameterIndex( KThumbnailSqlParamRowID ); User::LeaveIfError( paramIndex2 ); - User::LeaveIfError( stmt_infodata.BindInt64( paramIndex2, rowid )); + User::LeaveIfError( stmt_infodata->BindInt64( paramIndex2, rowid )); - err = stmt_infodata.Exec(); - stmt_infodata.Reset(); + err = stmt_infodata->Exec(); + stmt_infodata->Reset(); User::LeaveIfError( err ); TN_DEBUG1( "CThumbnailStore::DeleteThumbnailsByPathL() -- TEMP TABLE lookup - thumbnail deleted" ); // fetch another row (temp table rowIDs are updated immediately) - stmt.Reset(); + stmt->Reset(); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); } - stmt_infodata.Close(); - stmt_info.Close(); - stmt.Close(); - - CleanupStack::PopAndDestroy( &stmt_infodata ); - CleanupStack::PopAndDestroy( &stmt_info ); - CleanupStack::PopAndDestroy( &stmt ); + CleanupStack::PopAndDestroy( stmt ); + CleanupStack::PopAndDestroy( stmt_info ); + CleanupStack::PopAndDestroy( stmt_infodata ); // if forcing instant delete if (aForce) @@ -1171,64 +1705,60 @@ //look from real table TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup" ); - CleanupClosePushL( stmt ); - CleanupClosePushL( stmt_info ); - CleanupClosePushL( stmt_infodata ); - - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSqlSelectRowIDInfoByPath )); - User::LeaveIfError( stmt_info.Prepare( iDatabase, KThumbnailSqlDeleteInfoByPath) ); - User::LeaveIfError( stmt_infodata.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByPath) ); + stmt = &iStmt_KThumbnailSqlSelectRowIDInfoByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); + stmt_info = &iStmt_KThumbnailSqlDeleteInfoByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt_info)); + stmt_infodata = &iStmt_KThumbnailSqlDeleteInfoDataByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt_infodata)); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); while(rowStatus == KSqlAtRow) { - rowid = stmt.ColumnInt64( column ); - paramIndex1 = stmt_info.ParameterIndex( KThumbnailSqlParamRowID ); + rowid = stmt->ColumnInt64( column ); + paramIndex1 = stmt_info->ParameterIndex( KThumbnailSqlParamRowID ); User::LeaveIfError( paramIndex1 ); - User::LeaveIfError( stmt_info.BindInt64( paramIndex1, rowid )); + User::LeaveIfError( stmt_info->BindInt64( paramIndex1, rowid )); - TInt err = stmt_info.Exec(); - stmt_info.Reset(); + TInt err = stmt_info->Exec(); + stmt_info->Reset(); User::LeaveIfError( err ); - paramIndex2 = stmt_infodata.ParameterIndex( KThumbnailSqlParamRowID ); + paramIndex2 = stmt_infodata->ParameterIndex( KThumbnailSqlParamRowID ); User::LeaveIfError( paramIndex2 ); - User::LeaveIfError( stmt_infodata.BindInt64( paramIndex2, rowid )); + User::LeaveIfError( stmt_infodata->BindInt64( paramIndex2, rowid )); - err = stmt_infodata.Exec(); - stmt_infodata.Reset(); + err = stmt_infodata->Exec(); + stmt_infodata->Reset(); User::LeaveIfError( err ); TN_DEBUG1( "CThumbnailStore::DeleteThumbnailByPathL() -- MAIN TABLE lookup - thumbnail deleted" ); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); } - stmt_infodata.Close(); - stmt_info.Close(); - CleanupStack::PopAndDestroy( &stmt_infodata ); - CleanupStack::PopAndDestroy( &stmt_info ); + CleanupStack::PopAndDestroy( stmt_infodata ); + CleanupStack::PopAndDestroy( stmt_info ); } else { // only add path to deleted table - CleanupClosePushL( stmt ); - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSqlInsertDeleted ) ); + stmt = &iStmt_KThumbnailSqlInsertDeleted; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - count = stmt.Exec(); + count = stmt->Exec(); } - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); + CleanupStack::PopAndDestroy( stmt ); if (aTransaction) { @@ -1272,9 +1802,9 @@ StopAutoFlush(); - if(iBatchItemCount <= 0) + if(iBatchItemCount <= 0 || CheckDbState() != KErrNone) { - // cache empty + // cache empty or db unusable return; } @@ -1285,9 +1815,6 @@ return; } - //cache full, flush now - iBatchItemCount = 0; - #ifdef _DEBUG TTime aStart, aStop; aStart.UniversalTime(); @@ -1308,13 +1835,6 @@ } #endif - if(err_tempinfo == KSqlErrCorrupt || err_tempinfo == KErrCorrupt ) - { - TRAP_IGNORE(RecreateDatabaseL(ETrue)); - TRAP_IGNORE(OpenDatabaseL()); - return; - } - TInt err_tempdata = iDatabase.Exec( KThumbnailMoveFromTempDataToMainTable ); #ifdef _DEBUG @@ -1324,13 +1844,6 @@ TN_DEBUG2( "CThumbnailStore::FlushCacheTable() KThumbnailMoveFromTempDataToMainTable %S", &errorMsg2); } #endif - if(err_tempdata == KSqlErrCorrupt || err_tempdata == KErrCorrupt ) - { - TRAP_IGNORE(RecreateDatabaseL(ETrue)); - TRAP_IGNORE(OpenDatabaseL()); - return; - } - TInt err_delinfo = iDatabase.Exec( KThumbnailDeleteFromTempInfoTable ); TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailDeleteFromTempInfoTable %d", err_delinfo); @@ -1338,7 +1851,6 @@ TInt err_deldata = iDatabase.Exec( KThumbnailDeleteFromTempDataTable ); TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailDeleteFromTempDataTable %d", err_deldata); - if( err_tempinfo < 0 || err_tempdata < 0 || err_delinfo < 0 || err_deldata < 0 ) { TInt err = iDatabase.Exec( KThumbnailRollbackTransaction ); @@ -1350,6 +1862,19 @@ TN_DEBUG2("CThumbnailStore::FlushCacheTable() KThumbnailCommitTransaction %d", err_commit); } + // db got corrupted + if(err_tempinfo == KSqlErrCorrupt || err_tempinfo == KErrCorrupt || + err_tempdata == KSqlErrCorrupt || err_tempdata == KErrCorrupt) + { + TN_DEBUG1("CThumbnailStore::FlushCacheTable() db corrupted"); + + // open new + TRAP_IGNORE(OpenDatabaseL(ETrue)); + } + + //cache flushed + iBatchItemCount = 0; + #ifdef _DEBUG aStop.UniversalTime(); TN_DEBUG2( "CThumbnailStore::FlushCacheTable() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); @@ -1359,246 +1884,6 @@ } // ----------------------------------------------------------------------------- -// CheckVersionAndImeiL() -// ----------------------------------------------------------------------------- -// -TInt CThumbnailStore::CheckImeiL() - { - TN_DEBUG1( "CThumbnailStore::CheckImeiL()" ); - RSqlStatement stmt; - CleanupClosePushL( stmt ); - - TInt rowStatus = 0; - TInt column = 0; - TBuf imei; - - TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion ); - if(ret < 0 ) - { - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - - TN_DEBUG1( "CThumbnailStore::CheckImeiL() failed" ); - return KErrNotSupported; - } - - rowStatus = stmt.Next(); - - if ( rowStatus == KSqlAtRow) - { - column=2; - stmt.ColumnText( column++, imei); - } - - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - - if(ret < 0 ) - { -#ifdef _DEBUG - TPtrC errorMsg = iDatabase.LastErrorMessage(); - TN_DEBUG2( "RThumbnailTransaction::CheckImeiL() lastError %S, ret = %d" , &errorMsg); -#endif - return ret; - } - - if( imei == iImei ) - { - return KErrNone; - } - else - { - TN_DEBUG1( "CThumbnailStore::CheckImeiL() mismatch" ); - return KErrNotSupported; - } - } - -// ----------------------------------------------------------------------------- -// CheckVersionAndImeiL() -// ----------------------------------------------------------------------------- -// -TInt CThumbnailStore::CheckVersionL() - { - TN_DEBUG1( "CThumbnailStore::CheckVersionL()" ); - RSqlStatement stmt; - CleanupClosePushL( stmt ); - - TInt rowStatus = 0; - TInt column = 0; - TInt minor = 0; - TInt major = 0; - - - TInt ret = stmt.Prepare( iDatabase, KThumbnailSelectFromVersion ); - if(ret < 0 ) - { - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - TN_DEBUG1( "CThumbnailStore::CheckVersionL() unknown version" ); - return KErrNotSupported; - } - - rowStatus = stmt.Next(); - - if ( rowStatus == KSqlAtRow) - { - major = stmt.ColumnInt( column++); - minor = stmt.ColumnInt( column++); - } - - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - - if(ret < 0 ) - { -#ifdef _DEBUG - TPtrC errorMsg = iDatabase.LastErrorMessage(); - TN_DEBUG2( "RThumbnailTransaction::CheckVersionL() lastError %S, ret = %d" , &errorMsg); -#endif - return ret; - } - - if(major == KMajor && minor == KMinor ) - { - return KErrNone; - } - else - { - TN_DEBUG1( "CThumbnailStore::CheckVersionL() - wrong DB version" ); - return KErrNotSupported; - } - } - - -// ----------------------------------------------------------------------------- -// CheckVersionAndImeiL() -// ----------------------------------------------------------------------------- -// -TInt CThumbnailStore::CheckMediaIDL() - { - - TN_DEBUG1( "CThumbnailStore::CheckMediaIDL()" ); - TInt err = 0; - - TVolumeInfo volumeinfo; - err = iFs.Volume(volumeinfo, iDrive); - TUint id = volumeinfo.iUniqueID; - TBuf<50> mediaid; - mediaid.Num(id); - - RFile64 file; - err = file.Open(iFs, mediaid, EFileShareReadersOrWriters); - if(err) - { - file.Create(iFs, mediaid, EFileShareReadersOrWriters ); - file.Close(); - return KErrNotSupported; - } - file.Close(); - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// AddVersionAndImeiL() -// ----------------------------------------------------------------------------- -// -void CThumbnailStore::AddVersionAndImeiL() - { - - TN_DEBUG1( "CThumbnailStore::AddVersionAndImei()" ); - RSqlStatement stmt; - CleanupClosePushL( stmt ); - - TInt paramIndex = 0; - - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailInsertToVersion )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamImei ); - User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, iImei )); - - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamMinor ); - User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, KMinor )); - - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamMajor ); - User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, KMajor )); - - User::LeaveIfError( stmt.Exec()); - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - - } - -// ----------------------------------------------------------------------------- -// ResetThumbnailIDs() -// ----------------------------------------------------------------------------- -// -TInt CThumbnailStore::ResetThumbnailIDs() - { - TN_DEBUG1( "CThumbnailStore::ResetThumbnailIDs()" ); - - TInt err = iDatabase.Exec( KTempThumbnailResetIDs ); - TN_DEBUG2( "CThumbnailStore::ResetThumbnailIDs() KThumbnailResetIDs - temp table, err=%d", err ); - - if(err < 0) - { -#ifdef _DEBUG - TPtrC errorMsg = iDatabase.LastErrorMessage(); - TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg); -#endif - return err; - } - - err = iDatabase.Exec( KThumbnailResetIDs ); - TN_DEBUG2( "CThumbnailStore::ResetThumbnailIDs() KThumbnailResetIDs - main table, err=%d", err ); - - if(err < 0) - { -#ifdef _DEBUG - TPtrC errorMsg2 = iDatabase.LastErrorMessage(); - TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2); -#endif - return err; - } - return KErrNone; - } - - -// ----------------------------------------------------------------------------- -// UpdateImeiL() -// ----------------------------------------------------------------------------- -// -TInt CThumbnailStore::UpdateImeiL() - { - TN_DEBUG1( "CThumbnailStore::UpdateImeiL()" ); - RSqlStatement stmt; - CleanupClosePushL( stmt ); - - - TInt ret = stmt.Prepare( iDatabase, KThumbnailUpdateIMEI ); - - TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamImei ); - User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, iImei )); - - TInt err = stmt.Exec(); - - if(err < 0) - { -#ifdef _DEBUG - TPtrC errorMsg2 = iDatabase.LastErrorMessage(); - TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2); -#endif - return ret; - } - - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - return KErrNone; - } - -// ----------------------------------------------------------------------------- // StartAutoFlush() // ----------------------------------------------------------------------------- // @@ -1737,7 +2022,7 @@ } } - // file existance check + // file existence check else if (self->iCheckFilesExist) { TBool finished = EFalse; @@ -1776,87 +2061,12 @@ return KErrNone; // Return value ignored by CPeriodic } -TInt CThumbnailStore::CheckRowIDsL() - { - TN_DEBUG1( "CThumbnailStore::CheckRowIDs()"); - - RSqlStatement stmt; - CleanupClosePushL( stmt ); - TInt column = 0; - TInt rowStatus = 0; - TInt64 inforows = 0; - TInt64 datarows = 0; - - TInt ret = stmt.Prepare( iDatabase, KGetInfoRowID ); - if(ret < 0) - { - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - TN_DEBUG1( "CThumbnailStore::CheckRowIDs() failed 1 %d"); - return KErrNotSupported; - } - rowStatus = stmt.Next(); - - if ( rowStatus == KSqlAtRow) - { - inforows = stmt.ColumnInt64( column ); - } - - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - - if(ret < 0) - { -#ifdef _DEBUG - TPtrC errorMsg2 = iDatabase.LastErrorMessage(); - TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2); -#endif - return ret; - } - - CleanupClosePushL( stmt ); - ret = stmt.Prepare( iDatabase, KGetDataRowID ); - if(ret < 0) - { - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - TN_DEBUG1( "CThumbnailStore::CheckRowIDs() failed 2"); - return KErrNotSupported; - } - rowStatus = stmt.Next(); - - if ( rowStatus == KSqlAtRow) - { - datarows = stmt.ColumnInt64( column ); - } - - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - - if(ret < 0) - { -#ifdef _DEBUG - TPtrC errorMsg2 = iDatabase.LastErrorMessage(); - TN_DEBUG2( "RThumbnailTransaction::ResetThumbnailIDs() lastError %S, ret = %d" , &errorMsg2); -#endif - return ret; - } - - if( inforows != datarows) - { - TN_DEBUG1( "CThumbnailStore::CheckRowIDsL() - tables out of sync" ); - return KErrNotSupported; - } - else - { - return KErrNone; - } - } - TBool CThumbnailStore::CheckModifiedByPathL( const TDesC& aPath, const TInt64 aModified, TBool& modifiedChanged ) { TN_DEBUG2( "CThumbnailStore::CheckModifiedByPathL() %S", &aPath); + User::LeaveIfError( CheckDbState() ); + HBufC* path = aPath.AllocLC(); TPtr ptr(path->Des()); StripDriveLetterL( ptr ); @@ -1865,78 +2075,73 @@ modifiedChanged = EFalse; - TInt column = 0; + TInt column = 0; + + RSqlStatement* stmt = NULL; + stmt = &iStmt_KThumbnailSelectTempModifiedByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - RSqlStatement stmt; - CleanupClosePushL( stmt ); - - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectTempModifiedByPath )); - - TInt paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); - User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + TInt paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - TInt rowStatus = stmt.Next(); + TInt rowStatus = stmt->Next(); - TBool checkMain = EFalse; + TBool checkMain = EFalse; - TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- temp" ); + TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- temp" ); - while(rowStatus == KSqlAtRow || !checkMain) - { - if(rowStatus == KSqlAtRow) - { - ret = ETrue; - TInt64 oldModified = stmt.ColumnInt64( column ); + while(rowStatus == KSqlAtRow || !checkMain) + { + if(rowStatus == KSqlAtRow) + { + ret = ETrue; + TInt64 oldModified = stmt->ColumnInt64( column ); - TN_DEBUG2( "CThumbnailStore::CheckModifiedL() -- timestamp old %Ld", oldModified); - TN_DEBUG2( "CThumbnailStore::CheckModifiedL() -- timestamp mds %Ld", aModified); + TN_DEBUG2( "CThumbnailStore::CheckModifiedL() -- timestamp old %Ld", oldModified); + TN_DEBUG2( "CThumbnailStore::CheckModifiedL() -- timestamp mds %Ld", aModified); - if (oldModified < aModified) - { - TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is newer than original" ); - modifiedChanged = ETrue; - break; - } - else if (oldModified > aModified) - { - TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is older than original" ); - } - else if (oldModified == aModified) - { - TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is the same as original" ); - } - } + if (oldModified < aModified) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is newer than original" ); + modifiedChanged = ETrue; + break; + } + else if (oldModified > aModified) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is older than original" ); + } + else if (oldModified == aModified) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- timestamp is the same as original" ); + } + } - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); - //switch to main table if modified not found from temp - if(rowStatus != KSqlAtRow && !checkMain && !modifiedChanged) - { - TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- main" ); - //come here only once - checkMain = ETrue; + //switch to main table if modified not found from temp + if(rowStatus != KSqlAtRow && !checkMain && !modifiedChanged) + { + TN_DEBUG1( "CThumbnailStore::CheckModifiedL() -- main" ); + //come here only once + checkMain = ETrue; - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); - CleanupClosePushL( stmt ); - - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectModifiedByPath )); + CleanupStack::PopAndDestroy( stmt ); + stmt = &iStmt_KThumbnailSelectModifiedByPath; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamPath ); - User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindText( paramIndex, *path )); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamPath ); + User::LeaveIfError( paramIndex ); + User::LeaveIfError( stmt->BindText( paramIndex, *path )); - rowStatus = stmt.Next(); - } - } + rowStatus = stmt->Next(); + } + } - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); + CleanupStack::PopAndDestroy( stmt ); + CleanupStack::PopAndDestroy( path ); - CleanupStack::PopAndDestroy( path ); - - return ret; + return ret; } // ----------------------------------------------------------------------------- @@ -1968,12 +2173,14 @@ // TInt CThumbnailStore::DeleteMarkedL() { + TN_DEBUG1( "CThumbnailStore::DeleteMarkedL()" ); + #ifdef _DEBUG TTime aStart, aStop; aStart.UniversalTime(); #endif - TN_DEBUG1( "CThumbnailStore::DeleteMarkedL()" ); + User::LeaveIfError( CheckDbState() ); TInt paramIndex = 0; TInt paramIndex1 = 0; @@ -1987,65 +2194,57 @@ CleanupClosePushL( transaction ); transaction.BeginL(); - RSqlStatement stmt; - RSqlStatement stmt_info; - RSqlStatement stmt_infodata; - CleanupClosePushL( stmt ); + RSqlStatement* stmt = NULL; + RSqlStatement* stmt_info = NULL; + RSqlStatement* stmt_infodata = NULL; + + stmt = &iStmt_KThumbnailSqlSelectMarked; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); + stmt_info = &iStmt_KThumbnailSqlDeleteInfoByRowID; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt_info)); + stmt_infodata = &iStmt_KThumbnailSqlDeleteInfoDataByRowID; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt_infodata)); // select marked rows - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSqlSelectMarked )); - - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamLimit ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamLimit ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, KStoreMaintenanceDeleteLimit )); + User::LeaveIfError( stmt->BindInt( paramIndex, KStoreMaintenanceDeleteLimit )); - rowStatus = stmt.Next(); - - CleanupClosePushL( stmt_info ); - User::LeaveIfError( stmt_info.Prepare( iDatabase, KThumbnailSqlDeleteInfoByRowID) ); - CleanupClosePushL( stmt_infodata ); - User::LeaveIfError( stmt_infodata.Prepare( iDatabase, KThumbnailSqlDeleteInfoDataByRowID) ); + rowStatus = stmt->Next(); while(rowStatus == KSqlAtRow) { - rowid = stmt.ColumnInt64( column ); - paramIndex1 = stmt_info.ParameterIndex( KThumbnailSqlParamRowID ); + rowid = stmt->ColumnInt64( column ); + paramIndex1 = stmt_info->ParameterIndex( KThumbnailSqlParamRowID ); User::LeaveIfError( paramIndex1 ); - User::LeaveIfError( stmt_info.BindInt64( paramIndex1, rowid )); + User::LeaveIfError( stmt_info->BindInt64( paramIndex1, rowid )); - TInt err = stmt_info.Exec(); - stmt_info.Reset(); + TInt err = stmt_info->Exec(); + stmt_info->Reset(); User::LeaveIfError( err ); - paramIndex2 = stmt_infodata.ParameterIndex( KThumbnailSqlParamRowID ); + paramIndex2 = stmt_infodata->ParameterIndex( KThumbnailSqlParamRowID ); User::LeaveIfError( paramIndex2 ); - User::LeaveIfError( stmt_infodata.BindInt64( paramIndex2, rowid )); + User::LeaveIfError( stmt_infodata->BindInt64( paramIndex2, rowid )); - err = stmt_infodata.Exec(); - stmt_infodata.Reset(); + err = stmt_infodata->Exec(); + stmt_infodata->Reset(); User::LeaveIfError( err ); deleteCount++; TN_DEBUG1( "CThumbnailStore::DeleteMarkedL() - thumbnail deleted" ); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); } - stmt_infodata.Close(); - stmt_info.Close(); - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt_infodata ); - CleanupStack::PopAndDestroy( &stmt_info ); - CleanupStack::PopAndDestroy( &stmt ); + CleanupStack::PopAndDestroy( stmt_infodata ); + CleanupStack::PopAndDestroy( stmt_info ); + CleanupStack::PopAndDestroy( stmt ); // remove successfully deleted paths from Deleted table if (deleteCount > 0) { - CleanupClosePushL( stmt ); User::LeaveIfError( iDatabase.Exec( KThumbnailSqlDeleteFromDeleted ) ); - - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); } transaction.CommitL(); @@ -2065,12 +2264,14 @@ // TInt CThumbnailStore::FileExistenceCheckL() { + TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL()" ); + #ifdef _DEBUG TTime aStart, aStop; aStart.UniversalTime(); #endif - TN_DEBUG1( "CThumbnailStore::FileExistenceCheckL()" ); + User::LeaveIfError( CheckDbState() ); TInt paramIndex = 0; TInt rowStatus = 0; @@ -2087,29 +2288,28 @@ CleanupClosePushL( transaction ); transaction.BeginL(); - RSqlStatement stmt; - CleanupClosePushL( stmt ); + // get rows + RSqlStatement* stmt = NULL; + stmt = &iStmt_KThumbnailSelectAllPaths; + CleanupStack::PushL(TCleanupItem(ResetStatement, stmt)); - // get rows - User::LeaveIfError( stmt.Prepare( iDatabase, KThumbnailSelectAllPaths )); - - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamRowID ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamRowID ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt64( paramIndex, iLastCheckedRowID )); + User::LeaveIfError( stmt->BindInt64( paramIndex, iLastCheckedRowID )); - paramIndex = stmt.ParameterIndex( KThumbnailSqlParamLimit ); + paramIndex = stmt->ParameterIndex( KThumbnailSqlParamLimit ); User::LeaveIfError( paramIndex ); - User::LeaveIfError( stmt.BindInt( paramIndex, KStoreMaintenanceExistLimit )); + User::LeaveIfError( stmt->BindInt( paramIndex, KStoreMaintenanceExistLimit )); - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); while(rowStatus == KSqlAtRow) { column = 0; path.Zero(); - rowid = stmt.ColumnInt64( column++ ); - stmt.ColumnText( column, path ); + rowid = stmt->ColumnInt64( column++ ); + stmt->ColumnText( column, path ); full.Zero(); full.Append(iDriveChar); @@ -2134,7 +2334,7 @@ count++; // get next - rowStatus = stmt.Next(); + rowStatus = stmt->Next(); } if (count < KStoreMaintenanceExistLimit) @@ -2143,8 +2343,7 @@ finished = ETrue; } - stmt.Close(); - CleanupStack::PopAndDestroy( &stmt ); + CleanupStack::PopAndDestroy( stmt ); transaction.CommitL(); CleanupStack::PopAndDestroy( &transaction ); @@ -2172,6 +2371,25 @@ } } +// ----------------------------------------------------------------------------- +// CheckDbState +// ----------------------------------------------------------------------------- +// +TInt CThumbnailStore::CheckDbState() + { + if (iUnrecoverable) + { + TN_DEBUG1( "CThumbnailStore::CheckDbState() - database in unrecoverable state" ); + __ASSERT_DEBUG( !iUnrecoverable, ThumbnailPanic( EThumbnailDatabaseUnrecoverable )); + + return KStoreUnrecoverableErr; + } + else + { + return KErrNone; + } + } + void CThumbnailStore::HandleDiskSpaceNotificationL( TBool aDiskFull ) { TN_DEBUG2( "CThumbnailStore::HandleDiskSpaceNotificationL() aDiskFull = %d", aDiskFull ); @@ -2231,8 +2449,11 @@ } } + +// ----------------------------------------------------------------------------- // CThumbnailStoreDiskSpaceNotifierAO class - +// ----------------------------------------------------------------------------- +// CThumbnailStoreDiskSpaceNotifierAO* CThumbnailStoreDiskSpaceNotifierAO::NewL( MThumbnailStoreDiskSpaceNotifierObserver& aObserver, TInt64 aThreshold, const TDesC& aFilename) { @@ -2299,8 +2520,7 @@ ret = iFileServerSession.Volume( volumeInfo, iDrive ); if(!ret) - { - + { // Check if free space is less than threshold level if( volumeInfo.iFree < iThreshold ) { @@ -2344,7 +2564,7 @@ { const TInt KMaxIterations = 10; - iFileServerSession.Volume( volumeInfo, iDrive ); + User::LeaveIfError( iFileServerSession.Volume( volumeInfo, iDrive ) ); if ( volumeInfo.iFree < iThreshold ) { iObserver.HandleDiskSpaceNotificationL( iDiskFull ); @@ -2358,7 +2578,7 @@ } else { - iFileServerSession.Volume( volumeInfo, iDrive ); + User::LeaveIfError( iFileServerSession.Volume( volumeInfo, iDrive ) ); if ( volumeInfo.iFree >= iThreshold ) { TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() NOT FULL"); diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtask.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtask.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtask.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -85,7 +85,7 @@ void CThumbnailTask::StartL() { TN_DEBUG3( "CThumbnailTask(0x%08x)::StartL() iState == %d ", this, iState ); - __ASSERT_DEBUG(( iState != ERunning ), ThumbnailPanic( EAlreadyRunning )); + __ASSERT_DEBUG(( iState != ERunning ), ThumbnailPanic( EThumbnailAlreadyRunning )); iState = ERunning; } @@ -174,10 +174,20 @@ // --------------------------------------------------------------------------- // void CThumbnailTask::SetMessageData( const TThumbnailServerRequestId& - aRequestId, const RMessage2& aMessage ) + aRequestId, const RMessage2& aMessage, const RThread& aClientThread ) { iMessage = aMessage; iRequestId = aRequestId; + + if ( iMessage.Handle()) + { + // copy client thread handle + iClientThread.Duplicate(aClientThread); + } + else + { + TN_DEBUG2( "CThumbnailTask(0x%08x)::ClientThreadAlive() - message null", this); + } } // --------------------------------------------------------------------------- @@ -222,7 +232,11 @@ { if ( iMessage.Handle()) { - iMessage.Complete( KErrCancel ); + if ( ClientThreadAlive() ) + { + iMessage.Complete( KErrCancel ); + } + ResetMessageData(); } } @@ -234,6 +248,8 @@ // TBool CThumbnailTask::ClientThreadAlive(const TBool aGetThread) { + TN_DEBUG1( "CThumbnailTask::ClientThreadAlive()"); + if ( iMessage.Handle()) { if (aGetThread) diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtaskprocessor.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtaskprocessor.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtaskprocessor.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -221,7 +221,6 @@ TThumbnailRequestId id = task->RequestId().iRequestId; // Task is already running, canceled first - task->ResetMessageData(); task->Cancel(); delete task; iTasks.Remove( i ); @@ -273,7 +272,6 @@ TThumbnailRequestId id = task->RequestId().iRequestId; // Task is already running, canceled first - task->ResetMessageData(); task->Cancel(); delete task; iTasks.Remove( i ); @@ -325,6 +323,7 @@ iActiveTask = NULL; TInt priority( KMinTInt ); TInt taskPriority; + TBool processingDaemonTasksOnly(ETrue); #ifdef _DEBUG TN_DEBUG2( "CThumbnailTaskProcessor::TASKPROCESSOR-COUNTER---------- in, Tasks = %d", iTasks.Count() ); @@ -351,6 +350,15 @@ iActiveTask = task; } } + + if ( processingDaemonTasksOnly && task->GetMessageData().Handle()) + { + if(task->GetMessageData().Identity() != KDaemonUid ) + { + TN_DEBUG1( "CThumbnailTaskProcessor::RunL() processingDaemonTasksOnly = EFalse" ); + processingDaemonTasksOnly = EFalse; + } + } } } @@ -364,7 +372,7 @@ #endif //update PS value for Daemon - if( iTasks.Count() > 0 && iIdle) + if( iTasks.Count() > 0 && iIdle && !processingDaemonTasksOnly) { //set not idle if(iTimerActive) diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/tmshutdownobserver.cpp --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/tmshutdownobserver.cpp Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -/* -* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Processor -* -*/ - - -#include - -#include "tmshutdownobserver.h" -#include "thumbnailmanagerconstants.h" - -// --------------------------------------------------------------------------- -// CTMShutdownObserver::NewL() -// --------------------------------------------------------------------------- -// -CTMShutdownObserver* CTMShutdownObserver::NewL( MTMShutdownObserver& aObserver, - const TUid& aKeyCategory, - const TInt aPropertyKey, - TBool aDefineKey) - { - CTMShutdownObserver* self = new( ELeave )CTMShutdownObserver( aObserver, - aKeyCategory, - aPropertyKey, - aDefineKey); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// CTMShutdownObserver::CTMShutdownObserver() -// --------------------------------------------------------------------------- -// -CTMShutdownObserver::CTMShutdownObserver( MTMShutdownObserver& aObserver, - const TUid& aKeyCategory, - const TInt aPropertyKey, - TBool aDefineKey) - : CActive( CActive::EPriorityStandard ), iObserver( aObserver ), - iKeyCategory( aKeyCategory ), iPropertyKey(aPropertyKey), iDefineKey( aDefineKey ) - { - CActiveScheduler::Add( this ); - } - -// --------------------------------------------------------------------------- -// CTMShutdownObserver::ConstructL() -// --------------------------------------------------------------------------- -// -void CTMShutdownObserver::ConstructL() - { - // define P&S property types - if (iDefineKey) - { - RProperty::Define(iKeyCategory,iPropertyKey, - RProperty::EInt,KAllowAllPolicy,KPowerMgmtPolicy); - } - - // attach to the property - TInt err = iProperty.Attach(iKeyCategory,iPropertyKey,EOwnerThread); - User::LeaveIfError(err); - - // wait for the previously attached property to be updated - iProperty.Subscribe(iStatus); - SetActive(); - } - -// --------------------------------------------------------------------------- -// CTMShutdownObserver::~CTMShutdownObserver() -// --------------------------------------------------------------------------- -// -CTMShutdownObserver::~CTMShutdownObserver() - { - Cancel(); - iProperty.Close(); - } - -// --------------------------------------------------------------------------- -// CTMShutdownObserver::RunL() -// --------------------------------------------------------------------------- -// -void CTMShutdownObserver::RunL() - { - // resubscribe before processing new value to prevent missing updates - iProperty.Subscribe(iStatus); - SetActive(); - - // retrieve the value - TInt value = 0; - iProperty.Get(value); - - // observer callback - if (value) - { - iObserver.ShutdownNotification(); - } - } - -// --------------------------------------------------------------------------- -// CTMShutdownObserver::DoCancel() -// --------------------------------------------------------------------------- -// -void CTMShutdownObserver::DoCancel() - { - iProperty.Cancel(); - } - -// End of file diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/thumbnailserver/src/tnmgetimei.cc --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/tnmgetimei.cc Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Helper class to get IMEI number. -* -*/ - - -#include "tnmgetimei.h" -#include "thumbnailmanagerconstants.h" - -CTnmgetimei* CTnmgetimei::NewL() - { - CTnmgetimei *self = CTnmgetimei::NewLC(); - CleanupStack::Pop(); - return self; - } - -CTnmgetimei* CTnmgetimei::NewLC() - { - CTnmgetimei *self = new (ELeave) CTnmgetimei(); - CleanupStack::PushL(self); - self->ConstructL(); - return self; - } - -void CTnmgetimei::ConstructL() - { - iTelephony = CTelephony::NewL(); - CActiveScheduler::Add(this); - } - -CTnmgetimei::~CTnmgetimei() - { - Cancel(); - - delete iTelephony; - } - -TBuf CTnmgetimei::GetIMEI() - { - - CTelephony::TPhoneIdV1Pckg phoneIdPckg( iV1 ); - - iTelephony->GetPhoneId( iStatus, phoneIdPckg ); - SetActive(); - iAsw.Start(); - Deque(); - return iImei; - - } - -void CTnmgetimei::DoCancel() - { - iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel); - } - -void CTnmgetimei::RunL() - { - if(iStatus == KErrNone) - { - iImei = iV1.iSerialNumber; - } - iAsw.AsyncStop(); - } diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/tmcommon/inc/tmactivitymanager.h --- a/imagehandlingutilities/thumbnailmanager/tmcommon/inc/tmactivitymanager.h Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/tmcommon/inc/tmactivitymanager.h Wed Mar 31 22:04:49 2010 +0300 @@ -21,6 +21,10 @@ #ifndef TMACTIVITYMANAGER_H #define TMACTIVITYMANAGER_H +//5.0 and 9.2 behaves totally different way, +//! uncomment on 5.0 ! +#define MONITOR_LIGHTS + class MTMActivityManagerObserver @@ -30,8 +34,10 @@ }; -class CTMActivityManager : public CActive, - public MHWRMLightObserver +class CTMActivityManager : public CActive +#ifdef MONITOR_LIGHTS + ,public MHWRMLightObserver +#endif { public: @@ -67,8 +73,10 @@ void ConstructL(); void NotifyObserver(); +#ifdef MONITOR_LIGHTS private: //From MHWRMLightObserver void LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus); +#endif protected: enum TWatch { ENone = 0, EWaitingForInactivity, EWaitingForActivity }; @@ -79,11 +87,12 @@ MTMActivityManagerObserver* iObserver; ///The observer of activity status TInt iTimeout; ///Current inactivity period +#ifdef MONITOR_LIGHTS //Backlight control CHWRMLight* iLight; //backlight status TBool iLights; - +#endif //previous status TInt iPreviousStatus; TBool iFirstRound; diff -r 7403edfcf0fb -r dea39715fc05 imagehandlingutilities/thumbnailmanager/tmcommon/src/tmactivitymanager.cpp --- a/imagehandlingutilities/thumbnailmanager/tmcommon/src/tmactivitymanager.cpp Mon Mar 15 12:41:55 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/tmcommon/src/tmactivitymanager.cpp Wed Mar 31 22:04:49 2010 +0300 @@ -50,8 +50,10 @@ CTMActivityManager::~CTMActivityManager() { TN_DEBUG1( "CTMActivityManager::~CTMActivityManager()"); +#ifdef MONITOR_LIGHTS delete iLight; iLight = NULL; +#endif Cancel(); iTimer.Close(); } @@ -84,8 +86,10 @@ void CTMActivityManager::Reset() { TN_DEBUG1( "CTMActivityManager::Reset()"); +#ifdef MONITOR_LIGHTS delete iLight; iLight = NULL; +#endif Cancel(); Start(); } @@ -110,10 +114,12 @@ iFirstRound = ETrue; +#ifdef MONITOR_LIGHTS if(!iLight) { TRAP_IGNORE(iLight = CHWRMLight::NewL(this)); } +#endif if( !IsActive() ) { @@ -213,12 +219,20 @@ // TBool CTMActivityManager::IsInactive() { +#ifdef MONITOR_LIGHTS #ifdef _DEBUG TN_DEBUG3( "CTMActivityManager::IsInactive()= %d, iLights = %d", User::InactivityTime().Int(), iLights); #endif +#else +TN_DEBUG2( "CTMActivityManager::IsInactive()= %d", User::InactivityTime().Int()); +#endif //if lights are off or inactivity timer is less that target the device is not idle - if( User::InactivityTime() >= TTimeIntervalSeconds(iTimeout) || !iLights ) + if( User::InactivityTime() >= TTimeIntervalSeconds(iTimeout) +#ifdef MONITOR_LIGHTS + || !iLights +#endif + ) { TN_DEBUG1( "CTMActivityManager::IsInactive() ETrue"); return ETrue; @@ -227,27 +241,32 @@ return EFalse; } +#ifdef MONITOR_LIGHTS // ----------------------------------------------------------------------------- // LightStatusChanged() // ----------------------------------------------------------------------------- // -void CTMActivityManager::LightStatusChanged(TInt /*aTarget*/, CHWRMLight::TLightStatus aStatus) +void CTMActivityManager::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus) { - TN_DEBUG2( "CTMActivityManager::LightStatusChanged() aStatus == %d", aStatus); + TN_DEBUG3( "CTMActivityManager::LightStatusChanged() aTarget = %d, aStatus == %d", aTarget, aStatus); - if( aStatus == CHWRMLight::ELightOff) + if(aTarget & CHWRMLight::EPrimaryDisplay) { - TN_DEBUG1( "CTMActivityManager::LightStatusChanged() -- OFF"); - iLights = EFalse; - } - else - { - TN_DEBUG1( "CTMActivityManager::LightStatusChanged() -- ON"); - iLights = ETrue; - } + if( aStatus == CHWRMLight::ELightOff ) + { + TN_DEBUG1( "CTMActivityManager::LightStatusChanged() -- OFF"); + iLights = EFalse; + } + else + { + TN_DEBUG1( "CTMActivityManager::LightStatusChanged() -- ON"); + iLights = ETrue; + } NotifyObserver(); + } } +#endif // ----------------------------------------------------------------------------- // NotifyObserver() diff -r 7403edfcf0fb -r dea39715fc05 package_definition.xml --- a/package_definition.xml Mon Mar 15 12:41:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -