--- a/imagehandling_plat/thumbnailmanager_api/inc/thumbnailmanager_qt.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandling_plat/thumbnailmanager_api/inc/thumbnailmanager_qt.h Fri Apr 16 15:16:16 2010 +0300
@@ -231,6 +231,24 @@
void * clientData = NULL, int priority = tnmWrapperPriorityIdle );
/**
+ * Set a thumbnail for an object file generated from pixmap delivered.
+ * thumbnailReady() signal will be emited when the operation is complete.
+ *
+ * @param source QImage from which the thumbnail will be created
+ * @param fileName file name
+ * @param clientData Pointer to arbitrary client data.
+ * This pointer is not used by the API for
+ * anything other than returning it in the
+ * ThumbnailReady callback.
+ * @param priority Priority for this operation
+ * @return Thumbnail request ID or -1 if request failed. This can be used to
+ * cancel the request or change priority.
+ *
+ */
+ IMPORT_C int setThumbnail( const QImage& source, const QString& fileName,
+ void * clientData = NULL, int priority = tnmWrapperPriorityIdle );
+
+ /**
* Delete all thumbnails for a given object. This is an asynchronous
* operation, which always returns immediately.
*
--- a/imagehandlinglib/Src/CIHLImageViewerExtJpg.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlinglib/Src/CIHLImageViewerExtJpg.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -24,7 +24,7 @@
#include "IHLImplementationIds.h"
#include <IHLInterfaceIds.h>
#include <IclExtJpegApi.h>
-#include <ImageCodecData.h>
+#include <imagecodecdata.h>
#include <MIHLViewerObserver.h>
#include "MIHLFileImageExtJpg.h"
#include <fbs.h>
--- a/imagehandlinglib/Src/CIHLScaler.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlinglib/Src/CIHLScaler.cpp Fri Apr 16 15:16:16 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())
Binary file imagehandlingutilities/thumbnailmanager/conf/thumbnailmanager.confml has changed
--- a/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h Fri Apr 16 15:16:16 2010 +0300
@@ -81,7 +81,7 @@
// minimum background generation idle time seconds
const TInt KBackgroundGenerationIdle = 60;
// minimum store maintenance idle time seconds
-const TInt KStoreMaintenanceIdle = 300; // 5 min
+const TInt KStoreMaintenanceIdle = 65; // 65 sec
// interval for store maintenance rounds
const TInt KStoreMaintenancePeriodic = 100000; //100 ms
@@ -91,7 +91,7 @@
const TInt KStoreMaintenanceExistLimit = 50;
// video decoder timeout
-const TInt KVideoDecoderTimeout = 5000000; // 5 seconds
+const TInt KVideoDecoderTimeout = 12000000; // 12 seconds
const TDisplayMode KThumbnailDefaultDisplayMode = EColor64K;
--- a/imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailpanic.h Fri Apr 16 15:16:16 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
};
/**
--- a/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp Fri Apr 16 15:16:16 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 )
{
--- a/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp Fri Apr 16 15:16:16 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 )
--- a/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoderv2.cpp Fri Apr 16 15:16:16 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 )
{
--- a/imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -113,7 +113,7 @@
// video thumbnail engine doesn't respond
if (iTimeout)
{
- iObserver->ThumbnailProviderReady( KErrNotSupported, NULL, TSize(), EFalse, EFalse);
+ iObserver->ThumbnailProviderReady( KErrCompletion, NULL, TSize(), EFalse, EFalse);
iTimeout = EFalse;
TN_DEBUG1( "CThumbnailVideoProvider::RunL() - timeout" );
--- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg Fri Apr 16 15:16:16 2010 +0300
@@ -17,7 +17,7 @@
&EN
; Header
-#{"Thumbnail Manager"},(0x102830AB), 10, 10, 3, TYPE=SA, RU
+#{"Thumbnail Manager"},(0x102830AB), 10, 10, 4, TYPE=SA, RU
; Localised Vendor name
%{"Nokia"}
--- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg Fri Apr 16 15:16:16 2010 +0300
@@ -17,7 +17,7 @@
&EN
; Header
-#{"ThumbnailManager"},(0x102830AB), 10, 10, 3, TYPE=SA
+#{"ThumbnailManager"},(0x102830AB), 10, 10, 4, TYPE=SA
; Localised Vendor name
%{"Nokia"}
Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/thumbnailmanager_stub.sis has changed
--- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg Fri Apr 16 15:16:16 2010 +0300
@@ -17,7 +17,7 @@
&EN
; Header
-#{"Thumbnail Manager Cenrep"},(0x10202BE9), 10, 10, 3, TYPE=SP
+#{"Thumbnail Manager Cenrep"},(0x10202BE9), 10, 10, 4, TYPE=SP
; Localised Vendor name
%{"Symbian Software Ltd."}
--- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/group/thumbagdaemon.mmp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/group/thumbagdaemon.mmp Fri Apr 16 15:16:16 2010 +0300
@@ -36,8 +36,8 @@
EPOCPROCESSPRIORITY background
-//MACRO MDS_URI_OBSERVER
-MACRO TWO_PHASED_TN_GENERATION
+MACRO MDS_URI_OBSERVER
+MACRO MDS_MODIFY_OBSERVER
SOURCEPATH ../src
SOURCE thumbagdaemon.cpp
--- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h Fri Apr 16 15:16:16 2010 +0300
@@ -328,6 +328,8 @@
//Previously notified amount of items in processing queues (add/modify)
TInt iPreviousItemsLeft;
TBool iPreviousDaemonProcessing;
+ //set ETrue when QueryAllItems needs to be run after placeholder query
+ TBool iDoQueryAllItems;
};
#endif // THUMBAGPROCESSOR_H
--- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp Fri Apr 16 15:16:16 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;
@@ -306,7 +310,7 @@
// -----------------------------------------------------------------------------
//
-void CThumbAGDaemon::HandleUriObjectNotification(CMdESession& aSession,
+void CThumbAGDaemon::HandleUriObjectNotification(CMdESession& /*aSession*/,
TObserverNotificationType aType,
const RArray<TItemId>& aObjectIdArray,
const RPointerArray<HBufC>& aObjectUriArray)
@@ -510,7 +514,9 @@
iMdESession->AddObjectObserverL( *this, addCondition, ENotifyAdd );
// modify observer
- //iMdESession->AddObjectObserverL( *this, modifyCondition, ENotifyModify );
+#ifdef MDS_MODIFY_OBSERVER
+ iMdESession->AddObjectObserverL( *this, modifyCondition, ENotifyModify );
+#endif
#ifdef MDS_URI_OBSERVER
// remove observer with uri
--- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -95,10 +95,10 @@
UpdatePSValues(ETrue);
if(iForegroundGenerationObserver)
- {
- delete iForegroundGenerationObserver;
- iForegroundGenerationObserver = NULL;
- }
+ {
+ delete iForegroundGenerationObserver;
+ iForegroundGenerationObserver = NULL;
+ }
RProperty::Define(KTAGDPSNotification, KMPXHarvesting, RProperty::EInt);
@@ -143,9 +143,10 @@
if (!iInit)
{
- /*
+#ifdef MDS_MODIFY_OBSERVER
iHarvesterClient.RemoveHarvesterEventObserver(*this);
- iHarvesterClient.Close();*/
+ iHarvesterClient.Close();
+#endif
}
if ( iCollectionUtility )
@@ -247,6 +248,12 @@
}
delete iQueryPlaceholders;
iQueryPlaceholders = NULL;
+
+ if(iDoQueryAllItems)
+ {
+ iDoQueryAllItems = EFalse;
+ TRAP_IGNORE(QueryAllItemsL());
+ }
}
else if(&aQuery == iQueryAllItems)
{
@@ -291,6 +298,52 @@
{
iProcessingCount = iQuery->Count();
+ if(iProcessingCount != iQueryQueue.Count())
+ {
+ TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() some result items missing");
+
+ RArray<TItemId> iQueryQueueDelta;
+
+ TInt itemIndex(KErrNotFound);
+
+ //search delta items
+ for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++)
+ {
+ TBool found(EFalse);
+ for(TInt queryResult = 0; queryResult < iQuery->Count(); queryResult++)
+ {
+ const CMdEObject* object = &iQuery->Result(queryResult);
+
+ if( iQueryQueue[queryItem] == object->Id())
+ {
+ found = ETrue;
+ break;
+ }
+ }
+
+ if(!found)
+ {
+ TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing from results item %d", iQueryQueue[queryItem] );
+ iQueryQueueDelta.Append( iQueryQueue[queryItem] );
+ }
+ }
+
+ TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing items total count %d", iQueryQueueDelta.Count());
+ //cleanup from previous queue it item is not found from MDS
+ while(iQueryQueueDelta.Count())
+ {
+ itemIndex = iLastQueue->Find(iQueryQueueDelta[0]);
+ if(itemIndex >= 0)
+ {
+ TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove items %d", iQueryQueue[0]);
+ iLastQueue->Remove( itemIndex );
+ }
+ iQueryQueueDelta.Remove(0);
+ }
+ iQueryQueueDelta.Close();
+ }
+
+ // no results, reset query
if( !iProcessingCount)
{
delete iQuery;
@@ -818,6 +871,8 @@
iPlaceholderQueue.Reset();
TRAP_IGNORE(QueryPlaceholdersL());
+ //query all items after PH query
+ iDoQueryAllItems = ETrue;
TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation 1 done" );
ActivateAO();
return;
@@ -829,9 +884,10 @@
iInit2 = EFalse;
TInt err(KErrNone);
- /*
+
+#ifdef MDS_MODIFY_OBSERVER
TN_DEBUG1( "CThumbAGProcessor::RunL() do iHarvesterClient connect");
- TInt err = iHarvesterClient.Connect();
+ err = iHarvesterClient.Connect();
TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient connect err = %d", err);
__ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err));
@@ -842,7 +898,8 @@
err = iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall | EHEObserverTypePlaceholder, KMaxTInt );
TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient observer err = %d", err);
__ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err));
- }*/
+ }
+#endif
TN_DEBUG1( "CThumbAGProcessor::RunL() MMPXCollectionUtility");
TRAP( err, iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated ));
@@ -855,8 +912,6 @@
iActivityManager->Start();
}
- TRAP_IGNORE(QueryAllItemsL());
-
TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation 2 done" );
return;
}
@@ -908,7 +963,7 @@
}
#endif
- if( /*iForceRun || */iForegroundRun )
+ if( iForceRun || iForegroundRun )
{
TN_DEBUG1( "void CThumbAGProcessor::RunL() skip idle detection!");
CancelTimeout();
@@ -931,15 +986,12 @@
TInt serveIdle(KErrNotFound);
TInt ret = RProperty::Get(KServerIdle, KIdle, serveIdle);
- if(ret == KErrNone )
+ if(ret != KErrNone || !serveIdle )
{
- if(!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");
}
@@ -1010,23 +1062,9 @@
TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady FINISH" );
iQueryReady = EFalse;
iQueryActive = EFalse;
- iModify = EFalse;
+ }
- //check if forced run needs to continue
- if (iModifyQueue.Count())
- {
- SetForceRun( ETrue );
- }
- else
- {
- SetForceRun( EFalse );
- }
- }
- //keep going if processing Remove items or if Add item fails
- else if( iModify || err )
- {
- ActivateAO();
- }
+ ActivateAO();
}
//waiting for MDS query to complete
else if( iQueryActive )
@@ -1317,6 +1355,17 @@
TRequestStatus* statusPtr = &iStatus;
User::RequestComplete( statusPtr, KErrNone );
}
+
+ //check if forced run needs to continue
+ if (iModifyQueue.Count())
+ {
+ SetForceRun( ETrue );
+ }
+ else
+ {
+ iModify = EFalse;
+ SetForceRun( EFalse );
+ }
UpdatePSValues();
}
@@ -1448,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] );
@@ -1477,10 +1541,7 @@
TN_DEBUG2( "CThumbAGProcessor::SetForceRun(%d) - end", aForceRun );
// enable forced run
- if (aForceRun)
- {
- iForceRun = aForceRun;
- }
+ iForceRun = aForceRun;
}
// ---------------------------------------------------------------------------
@@ -1550,18 +1611,18 @@
return;
}
- TN_DEBUG1( "CThumbAGProcessor::HandleCollectionMessage" );
-
TMPXMessageId generalId( *aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ) );
+
+ TN_DEBUG2( "CThumbAGProcessor::HandleCollectionMessage KMPXMessageGeneralId=%d", generalId);
//we are interestead of only general system events
if ( generalId == KMPXMessageGeneral )
{
TInt event( *aMessage->Value<TInt>( KMPXMessageGeneralEvent ) );
+ TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) );
+ TN_DEBUG3( "CThumbAGProcessor::HandleCollectionMessage KMPXMessageGeneralEvent=%d", event, op);
if ( event == TMPXCollectionMessage::EBroadcastEvent )
{
- TInt op( *aMessage->Value<TInt>( KMPXMessageGeneralType ) );
-
switch( op )
{
//when MTP sync or music collection is started then pause processing
@@ -1709,6 +1770,13 @@
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;
+ }
+
if(aDefine)
{
TN_DEBUG1( "CThumbAGProcessor::UpdatePSValues() define");
--- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailmanagerimpl.h Fri Apr 16 15:16:16 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:
--- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h Fri Apr 16 15:16:16 2010 +0300
@@ -441,6 +441,9 @@
CPeriodic* iTimer;
TInt iStartError;
+ // request already canceled by client
+ TBool iCanceled;
+
#ifdef _DEBUG
TTime iStartExecTime;
#endif
--- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanagerimpl.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailmanagerimpl.cpp Fri Apr 16 15:16:16 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
--- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp Fri Apr 16 15:16:16 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());
@@ -219,9 +219,9 @@
iTimer->Cancel();
- if (iRequestType == EReqDeleteThumbnails)
+ if (iRequestType == EReqDeleteThumbnails || iCanceled)
{
- // no action for delete
+ // no action for delete or canceled request
iRequestQueue->RequestComplete(this);
#ifdef _DEBUG
@@ -417,6 +417,7 @@
__ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId ));
+ iCanceled = ETrue;
iSession.CancelRequest( iRequestId );
ReleaseServerBitmap();
}
--- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailsession.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailsession.cpp Fri Apr 16 15:16:16 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;
}
--- a/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/bwins/thumbnailmanagerqt.def Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/bwins/thumbnailmanagerqt.def Fri Apr 16 15:16:16 2010 +0300
@@ -15,4 +15,5 @@
?changePriority@ThumbnailManager@@QAE_NHH@Z @ 14 NONAME ; bool ThumbnailManager::changePriority(int, int)
?getThumbnail@ThumbnailManager@@QAEHKPAXH@Z @ 15 NONAME ; int ThumbnailManager::getThumbnail(unsigned long, void *, int)
?mode@ThumbnailManager@@QBE?AW4ThumbnailMode@1@XZ @ 16 NONAME ; enum ThumbnailManager::ThumbnailMode ThumbnailManager::mode(void) const
+ ?setThumbnail@ThumbnailManager@@QAEHABVQImage@@ABVQString@@PAXH@Z @ 17 NONAME ; int ThumbnailManager::setThumbnail(class QImage const &, class QString const &, void *, int)
--- a/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/eabi/thumbnailmanagerqt.def Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/eabi/thumbnailmanagerqt.def Fri Apr 16 15:16:16 2010 +0300
@@ -18,4 +18,5 @@
_ZNK16ThumbnailManager13thumbnailSizeEv @ 17 NONAME
_ZNK16ThumbnailManager17qualityPreferenceEv @ 18 NONAME
_ZNK16ThumbnailManager4modeEv @ 19 NONAME
+ _ZN16ThumbnailManager12setThumbnailERK6QImageRK7QStringPvi @ 20 NONAME
--- a/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/inc/thumbnailmanager_p_qt.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/inc/thumbnailmanager_p_qt.h Fri Apr 16 15:16:16 2010 +0300
@@ -18,7 +18,7 @@
#ifndef THUMBNAILMANAGER_P_QT_H
#define THUMBNAILMANAGER_P_QT_H
-#include <qobject>
+#include <QObject>
#include <thumbnailmanager.h>
#include <thumbnailmanager_qt.h>
#include <thumbnailmanagerobserver.h>
@@ -110,6 +110,13 @@
void * clientData, int priority );
/**
+ * Set a thumbnail for an object file generated from pixmap delivered.
+ * thumbnailReady() signal will be emited when the operation is complete.
+ */
+ int setThumbnail( const QImage& source, const QString& fileName,
+ void * clientData, int priority );
+
+ /**
* Delete all thumbnails for a given object. This is an asynchronous
* operation, which always returns immediately.
*/
--- a/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/src/thumbnailmanager_p_qt.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/src/thumbnailmanager_p_qt.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -162,6 +162,42 @@
return result;
}
+int ThumbnailManagerPrivate::setThumbnail( const QImage& source, const QString& fileName,
+ void * clientData, int priority )
+{
+ int result( -1 );
+ RBuf file;
+ _LIT( mime, "image/png" );
+
+ if( !byteArray ){
+ byteArray = new QByteArray();
+ }
+ QBuffer buffer( byteArray );
+ buffer.open( QBuffer::ReadWrite );
+ QDataStream dataStream( &buffer );
+
+ dataStream << source;
+
+ int offset = ( dataStream.version() >= 5 ? 4 : 0 );
+
+ TRAP_IGNORE(
+ CleanupClosePushL( file );
+ file.CreateL( fileName.length() );
+ file.Copy( fileName.utf16(), fileName.length() );
+
+ HBufC* mimetype = HBufC::NewLC( 9 );
+ mimetype->Des() = mime();
+
+ TPtrC8* ptr = new TPtrC8( reinterpret_cast<const TUint8*>( byteArray->data() + offset ), byteArray->count() - offset );
+
+ CThumbnailObjectSource* objSrc = CThumbnailObjectSource::NewLC( ptr, *mimetype, file );
+ result = iThumbnailManager->SetThumbnailL( *objSrc, clientData, priority );
+ CleanupStack::PopAndDestroy( 3, &file );
+ );
+
+ return result;
+}
+
void ThumbnailManagerPrivate::deleteThumbnails( const QString& fileName )
{
QString symbFileName( fileName );
--- a/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/src/thumbnailmanager_qt.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/src/thumbnailmanager_qt.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -91,6 +91,12 @@
return d->setThumbnail( source, filename, clientData, priority );
}
+EXPORT_C int ThumbnailManager::setThumbnail( const QImage& source, const QString& filename,
+ void * clientData , int priority )
+{
+ return d->setThumbnail( source, filename, clientData, priority );
+}
+
EXPORT_C void ThumbnailManager::deleteThumbnails( const QString& fileName )
{
d->deleteThumbnails( fileName );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/tsrc/test_qtnmwrapper.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -0,0 +1,290 @@
+/*
+* 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:
+*
+*/
+
+#include <QtGui>
+#include <QtTest/QtTest>
+#include <QEventLoop>
+#include <QDebug>
+#include <QImage>
+#include <fbs.h>
+
+#include <thumbnaildata.h>
+
+#include <thumbnailmanager_qt.h>
+#include "thumbnailmanager_p_qt.h"
+
+class TestThumbnailManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestThumbnailManager(): QObject(), wrapper( NULL ), ipixmap( NULL ) {};
+
+public slots:
+ void thumbnailReady( QPixmap , void * , int , int );
+
+ void thumbnailReady_p( QPixmap , void * , int , int );
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void createAndDestroy();
+ void qualityPreference();
+ void thumbnailSize();
+ void thumbnailMode();
+
+ void getThumbnailByName();
+ void getThumbnailById();
+ void setThumbnail();
+ void cancelRequest();
+ void changePriority();
+ void deleteThumbnailsByName();
+ void deleteThumbnailsById();
+
+ void testThumbnailReadyError();
+ void testThumbnailReadyValid();
+
+public:
+ ThumbnailManager* wrapper;
+ QPixmap* ipixmap;
+
+ int aid;
+ int aerrorCode;
+ bool pixmapNull;
+
+};
+
+enum testDataType{
+ AllNull,
+ BitmapValid
+};
+
+class TestThumbnailData : public MThumbnailData
+{
+public:
+ TestThumbnailData( testDataType type) : bitmap(0), clientData(0)
+ {
+ switch( type ){
+ case AllNull:
+ break;
+
+ case BitmapValid:
+ bitmap = new CFbsBitmap();
+ QVERIFY( !bitmap->Create(TSize(26,15),EColor64K) );
+ QVERIFY( !bitmap->Load( _L("c:\\tnmwrapper_tsrc.mbm") ) );
+ break;
+ };
+
+ };
+
+ ~TestThumbnailData() {
+ if( bitmap )
+ delete bitmap;
+ if( clientData )
+ delete clientData;
+ };
+
+ CFbsBitmap* Bitmap() {return bitmap;};
+
+ CFbsBitmap* DetachBitmap() {return bitmap;};
+
+ TAny* ClientData(){ return clientData; };
+
+public:
+ CFbsBitmap* bitmap;
+ TAny* clientData;
+
+};
+
+
+// ======== MEMBER FUNCTIONS ========
+void TestThumbnailManager::initTestCase()
+{
+ wrapper = new ThumbnailManager();
+ connect( wrapper, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
+ this, SLOT( thumbnailReady( QPixmap , void* , int , int )));
+}
+
+void TestThumbnailManager::cleanupTestCase()
+{
+ disconnect( wrapper, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
+ this, SLOT( thumbnailReady( QPixmap , void* , int , int )));
+ delete wrapper;
+ wrapper = NULL;
+
+ if( ipixmap ){
+ delete ipixmap;
+ ipixmap = NULL;
+ }
+}
+
+
+void TestThumbnailManager::createAndDestroy()
+{
+ //empty
+}
+
+void TestThumbnailManager::qualityPreference()
+{
+ QVERIFY( wrapper->setQualityPreference( ThumbnailManager::OptimizeForQuality ) );
+ QVERIFY( wrapper->setQualityPreference( ThumbnailManager::OptimizeForPerformance ) );
+ QVERIFY( wrapper->qualityPreference() == ThumbnailManager::OptimizeForPerformance );
+}
+
+void TestThumbnailManager::thumbnailSize()
+{
+ QVERIFY( wrapper->setThumbnailSize( ThumbnailManager::ThumbnailSmall ) );
+ QVERIFY( wrapper->setThumbnailSize( ThumbnailManager::ThumbnailMedium ) );
+ QVERIFY( wrapper->setThumbnailSize( ThumbnailManager::ThumbnailLarge ) );
+ QVERIFY( wrapper->setThumbnailSize( QSize( 100, 100 ) ) );
+ QVERIFY( wrapper->thumbnailSize() == QSize( 100, 100 ) );
+}
+
+void TestThumbnailManager::thumbnailMode()
+{
+ QVERIFY( wrapper->setMode( ThumbnailManager::Default ) );
+ QVERIFY( wrapper->setMode( ThumbnailManager::AllowAnySize ) );
+ QVERIFY( wrapper->setMode( ThumbnailManager::DoNotCreate ) );
+
+ QVERIFY( wrapper->setMode( ThumbnailManager::CropToAspectRatio ) );
+ QVERIFY( wrapper->mode() == ThumbnailManager::CropToAspectRatio );
+}
+
+void TestThumbnailManager::getThumbnailByName()
+{
+ wrapper->setMode( ThumbnailManager::CropToAspectRatio );
+ wrapper->setThumbnailSize( QSize( 200, 50 ));
+ QVERIFY( wrapper->getThumbnail( "c:\\tnmwrapper_tsrc.png", NULL, -99 ) != -1 );
+ QVERIFY( wrapper->getThumbnail( "c:/tnmwrapper_tsrc.png", NULL, -99 ) != -1 );
+}
+
+void TestThumbnailManager::getThumbnailById()
+{
+ wrapper->setMode( ThumbnailManager::CropToAspectRatio );
+ wrapper->setThumbnailSize( QSize( 200, 50 ));
+ QVERIFY( wrapper->getThumbnail( 2, NULL, -99 ) != -1 );
+}
+
+void TestThumbnailManager::setThumbnail()
+{
+ ipixmap = new QPixmap();
+ ipixmap->load( "c:\\tnmwrapper.bmp" );
+ wrapper->setMode( ThumbnailManager::CropToAspectRatio );
+ wrapper->setThumbnailSize(ThumbnailManager::ThumbnailMedium);
+ QVERIFY( wrapper->setThumbnail( *ipixmap, "c:\\tnmwrapper_tsrc.png" ) != -1 );
+ ipixmap->fill();
+ QVERIFY( wrapper->setThumbnail( *ipixmap, "c:\\tnmwrapper_tsrc.png" ) != -1 );
+
+ //QI,mage
+ QImage *img = new QImage("c:\\tnmwrapper.bmp");
+ QVERIFY( wrapper->setThumbnail( *img, "c:\\tnmwrapper_tsrc.png" ) != -1 );
+ img->fill(0);
+ QVERIFY( wrapper->setThumbnail( *img, "c:\\tnmwrapper_tsrc.png" ) != -1 );
+ delete img;
+}
+
+void TestThumbnailManager::cancelRequest()
+{
+ wrapper->setMode( ThumbnailManager::CropToAspectRatio );
+ wrapper->setThumbnailSize( QSize( 200, 50 ));
+ QVERIFY( wrapper->cancelRequest( wrapper->getThumbnail( "c:\\tnmwrapper_tsrc.png", NULL, -99 ) ) );
+ QVERIFY( !wrapper->cancelRequest( 123 ) ); //test request not found
+}
+
+void TestThumbnailManager::changePriority()
+{
+ wrapper->setMode( ThumbnailManager::CropToAspectRatio );
+ wrapper->setThumbnailSize( QSize( 200, 50 ));
+ QVERIFY( wrapper->changePriority( wrapper->getThumbnail( "c:\\tnmwrapper_tsrc.png", NULL, -99 ), -80 ) );
+}
+
+void TestThumbnailManager::deleteThumbnailsByName()
+{
+ wrapper->deleteThumbnails( "c:/tnmwrapper_tsrc.png" );
+ wrapper->deleteThumbnails( "c:\\tnmwrapper_tsrc.png" );
+}
+
+void TestThumbnailManager::deleteThumbnailsById()
+{
+ wrapper->deleteThumbnails( 2 );
+}
+
+void TestThumbnailManager::thumbnailReady( QPixmap /*pixmap*/, void * /*clientData*/, int /*id*/, int /*errorCode*/ )
+{
+ //do nothing, we dont test Thumbnail Manager's functionality, we just use it
+}
+
+void TestThumbnailManager::thumbnailReady_p( QPixmap pixmap, void * /*clientData*/, int id, int errorCode )
+{
+ QVERIFY( pixmap.isNull() == pixmapNull );
+ QVERIFY( errorCode == aerrorCode );
+ QVERIFY( aid == id );
+}
+
+void TestThumbnailManager::testThumbnailReadyError()
+{
+ ThumbnailManagerPrivate* wrapper_p = new ThumbnailManagerPrivate();
+
+ QVERIFY( connect( wrapper_p, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
+ this, SLOT( thumbnailReady_p( QPixmap , void* , int , int )), Qt::DirectConnection ) );
+
+ //test bytearray not null and thumbnail error
+ TestThumbnailData tdata1(AllNull);
+ aid = 12;
+ aerrorCode = -1;
+ pixmapNull = true;
+ wrapper_p->ThumbnailReady( aerrorCode, tdata1, aid );
+
+ disconnect( wrapper_p, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
+ this, SLOT( thumbnailReady_p( QPixmap , void* , int , int )));
+ delete wrapper_p;
+}
+
+void TestThumbnailManager::testThumbnailReadyValid()
+{
+ ThumbnailManagerPrivate* wrapper_p = new ThumbnailManagerPrivate();
+
+ QVERIFY( connect( wrapper_p, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
+ this, SLOT( thumbnailReady_p( QPixmap , void* , int , int )), Qt::DirectConnection ) );
+
+ TestThumbnailData tdata3( BitmapValid );
+ aid = 10;
+ aerrorCode = 0;
+ pixmapNull = false;
+ wrapper_p->ThumbnailReady( aerrorCode, tdata3, aid );
+
+ disconnect( wrapper_p, SIGNAL(thumbnailReady( QPixmap , void* , int, int ) ),
+ this, SLOT( thumbnailReady_p( QPixmap , void* , int , int )));
+ delete wrapper_p;
+}
+
+#ifdef _LOG_TO_C_
+ int main (int argc, char* argv[])
+ {
+ QApplication app(argc, argv);
+ TestThumbnailManager tc;
+ int c = 3;
+ char* v[] = {argv[0], "-o", "c:/test.txt"};
+ return QTest::qExec(&tc, c, v);
+ }
+#else
+ QTEST_MAIN(TestThumbnailManager)
+#endif
+
+#include "test_qtnmwrapper.moc"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/tsrc/test_qtnmwrapper.pkg Fri Apr 16 15:16:16 2010 +0300
@@ -0,0 +1,32 @@
+; test_qtnmwrapper_template.pkg generated by qmake at 2010-03-02T10:38:07
+; This file is generated by qmake and should not be modified by the user
+;
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"test_qtnmwrapper"},(0xE33f73a5),1,0,0
+
+; Localised Vendor name
+%{"Vendor"}
+
+; Unique Vendor name
+:"Vendor"
+
+; Manual PKG pre-rules from PRO files
+; Default HW/platform dependencies
+[0x101F7961],0,0,0,{"S60ProductID"}
+[0x102032BE],0,0,0,{"S60ProductID"}
+[0x102752AE],0,0,0,{"S60ProductID"}
+[0x1028315F],0,0,0,{"S60ProductID"}
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/test_qtnmwrapper.exe" - "!:\sys\bin\test_qtnmwrapper.exe"
+"/epoc32/data/z/resource/apps/test_qtnmwrapper.rsc" - "!:\resource\apps\test_qtnmwrapper.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/test_qtnmwrapper_reg.rsc" - "!:\private\10003a3f\import\apps\test_qtnmwrapper_reg.rsc"
+; DEPLOYMENT
+"/sf/mw/imghandling/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/tsrc/tnmwrapper_tsrc.png" - "C:\tnmwrapper_tsrc.png"
+"/sf/mw/imghandling/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/tsrc/tnmwrapper_tsrc.mbm" - "C:\tnmwrapper_tsrc.mbm"
+
+; Manual PKG post-rules from PRO files
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/tsrc/test_qtnmwrapper.pro Fri Apr 16 15:16:16 2010 +0300
@@ -0,0 +1,50 @@
+#
+# 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:
+#
+#
+
+TEMPLATE = app
+TARGET = test_qtnmwrapper
+CONFIG += symbian_test
+
+INCLUDEPATH += .
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE \
+ /epoc32/include/mw/qt \
+ /epoc32/include/mw/qttest \
+ ../inc
+
+TARGET.CAPABILITY = ALL -TCB
+#DEFINES += _LOG_TO_C_
+
+# Input
+LIBS += -lthumbnailmanager \
+ -lfbscli \
+ -lthumbnailmanagerqt
+
+SOURCES += test_qtnmwrapper.cpp \
+ ../src/thumbnailmanager_p_qt.cpp
+
+HEADERS += ../inc/thumbnailmanager_p_qt.h
+
+CONFIG += qtestlib console
+
+icons.sources += tnmwrapper_tsrc.png
+icons.sources += tnmwrapper_tsrc.mbm
+icons.path = /
+DEPLOYMENT += icons
+#needed to make directory /shared/EUnit/logs/ so that test result can be written
+testres.sources += distribution.policy.s60
+testres.path = /shared/EUnit/logs/
+DEPLOYMENT += testres
Binary file imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/tsrc/tnmwrapper_tsrc.mbm has changed
Binary file imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/tsrc/tnmwrapper_tsrc.png has changed
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/group/thumbnailserver.mmp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/group/thumbnailserver.mmp Fri Apr 16 15:16:16 2010 +0300
@@ -90,6 +90,7 @@
DEBUGLIBRARY flogger.lib
-PAGED
BYTEPAIRCOMPRESSTARGET
EPOCPROCESSPRIORITY background
+
+UNPAGED
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildecodetask.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnaildecodetask.h Fri Apr 16 15:16:16 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
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h Fri Apr 16 15:16:16 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
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailscaletask.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailscaletask.h Fri Apr 16 15:16:16 2010 +0300
@@ -51,13 +51,15 @@
* @param aThumbnailSize Prededined size of thumbnail.
* @return New CThumbnailScaleTask object.
* @param aEXIF is origin EXIF.
+ * @param aRequestId Request ID.
*/
static CThumbnailScaleTask* NewL( CThumbnailTaskProcessor& aProcessor,
CThumbnailServer& aServer, const TDesC& aFilename, CFbsBitmap* aBitmap,
const TSize& aOriginalSize, const TSize& aTargetSize, TBool aCrop,
TDisplayMode aDisplayMode, TInt aPriority, const TDesC& aTargetUri,
const TThumbnailSize aThumbnailSize, const TInt64 aModified,
- const TBool aBitmapToPool, const TBool aEXIF);
+ const TBool aBitmapToPool, const TBool aEXIF,
+ const TThumbnailServerRequestId aRequestId);
/**
* Destructor
@@ -121,13 +123,15 @@
* @param aThumbnailSize Prededined size of thumbnail.
* @return New CThumbnailScaleTask object.
* @param aEXIF is origin EXIF.
+ * @param aRequestId Request ID.
*/
CThumbnailScaleTask( CThumbnailTaskProcessor& aProcessor, CThumbnailServer&
aServer, const TDesC& aFilename, CFbsBitmap* aBitmap, const TSize&
aOriginalSize, const TSize& aTargetSize, TBool aCrop, TDisplayMode
aDisplayMode, TInt aPriority, const TDesC& aTargetUri,
const TThumbnailSize aThumbnailSize, const TInt64 aModified,
- const TBool aBitmapToPool, const TBool aEXIF);
+ const TBool aBitmapToPool, const TBool aEXIF,
+ const TThumbnailServerRequestId aRequestId);
/**
* Symbian 2nd phase constructor can leave.
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserver.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserver.h Fri Apr 16 15:16:16 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
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserversession.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailserversession.h Fri Apr 16 15:16:16 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
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h Fri Apr 16 15:16:16 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
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h Fri Apr 16 15:16:16 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
@@ -523,9 +535,10 @@
RFs& iFs;
/**
- * Drive number
+ * Drive number & char
*/
TInt iDrive;
+ TChar iDriveChar;
/**
* Thumbnail database.
@@ -585,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
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtask.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtask.h Fri Apr 16 15:16:16 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;
};
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnaildecodetask.cpp Fri Apr 16 15:16:16 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
{
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp Fri Apr 16 15:16:16 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;
@@ -174,6 +175,8 @@
DoBlacklisting( providerErr, TSize(0,0) );
User::LeaveIfError( providerErr );
+
+ TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::StartL() end", this );
}
@@ -317,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
@@ -353,8 +356,9 @@
}
CThumbnailScaleTask* scaleTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename,
- iBitmap, iOriginalSize, (*iMissingSizes)[ i ].iSize, (*iMissingSizes)[ i ].iCrop, iDisplayMode,
- KMaxPriority, iTargetUri, (*iMissingSizes)[ i ].iType, iModified, iScaledBitmapToPool, iEXIF );
+ aBitmap, iOriginalSize, (*iMissingSizes)[ i ].iSize, (*iMissingSizes)[ i ].iCrop, iDisplayMode,
+ KMaxPriority, iTargetUri, (*iMissingSizes)[ i ].iType, iModified, iScaledBitmapToPool, iEXIF,
+ iRequestId);
CleanupStack::PushL( scaleTask );
TInt err1 = KErrNone;
@@ -388,7 +392,7 @@
if( i == 0 )
{
// compTask is now responsible for completing the RMessage
- scaleTask->SetMessageData( iRequestId, iMessage );
+ scaleTask->SetMessageData( iRequestId, iMessage, iClientThread );
ResetMessageData();
}
}
@@ -401,17 +405,17 @@
iThumbnailSize == EVideoFullScreenThumbnailSize ||
iThumbnailSize == EAudioFullScreenThumbnailSize ||
iThumbnailSize == EImageFullScreenThumbnailSize )
- {
- TInt width = iSize.iWidth;
- iSize.iWidth = iSize.iHeight;
- iSize.iHeight = width;
- }
+ {
+ TInt width = iSize.iWidth;
+ iSize.iWidth = iSize.iHeight;
+ iSize.iHeight = width;
+ }
}
complTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename,
- iBitmap, iOriginalSize, iSize, iFlags& CThumbnailManager
+ aBitmap, iOriginalSize, iSize, iFlags& CThumbnailManager
::ECropToAspectRatio, iDisplayMode, KMaxPriority, iTargetUri,
- iThumbnailSize, iModified, iScaledBitmapToPool, iEXIF );
+ iThumbnailSize, iModified, iScaledBitmapToPool, iEXIF, iRequestId );
CleanupStack::PushL( complTask );
TInt err1 = KErrNone;
@@ -443,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;
}
// ---------------------------------------------------------------------------
@@ -511,7 +516,8 @@
aError == KErrCorrupt ||
aError == KErrCompletion ||
aError == KErrUnderflow ||
- aError == KErrNotReady)
+ aError == KErrNotReady ||
+ aError == KErrGeneral )
{
if(iMissingSizes)
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailmdsquerytask.cpp Fri Apr 16 15:16:16 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 );
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -42,14 +42,14 @@
aBitmap, const TSize& aOriginalSize, const TSize& aTargetSize, TBool aCrop,
TDisplayMode aDisplayMode, TInt aPriority, const TDesC& aTargetUri,
const TThumbnailSize aThumbnailSize, const TInt64 aModified,
- TBool aBitmapToPool, const TBool aEXIF)
+ TBool aBitmapToPool, const TBool aEXIF, const TThumbnailServerRequestId aRequestId)
{
// We take ownership of aBitmap
CleanupStack::PushL( aBitmap );
CThumbnailScaleTask* self = new( ELeave )CThumbnailScaleTask( aProcessor,
aServer, aFilename, aBitmap, aOriginalSize, aTargetSize, aCrop,
aDisplayMode, aPriority, aTargetUri, aThumbnailSize, aModified,
- aBitmapToPool, aEXIF);
+ aBitmapToPool, aEXIF, aRequestId);
CleanupStack::Pop( aBitmap );
CleanupStack::PushL( self );
self->ConstructL();
@@ -68,7 +68,7 @@
const TSize& aOriginalSize, const TSize& aTargetSize, TBool aCrop,
TDisplayMode aDisplayMode, TInt aPriority, const TDesC& aTargetUri,
const TThumbnailSize aThumbnailSize, const TInt64 aModified,
- TBool aBitmapToPool, const TBool aEXIF):
+ TBool aBitmapToPool, const TBool aEXIF, const TThumbnailServerRequestId aRequestId):
CThumbnailTask( aProcessor, aPriority ), iServer( aServer ), iOwnBitmap( aBitmap ),
iOriginalSize( aOriginalSize ), iTargetSize(aTargetSize), iTargetSizeTN( aTargetSize ), iCrop( aCrop ),
iDisplayMode( aDisplayMode ), iFilename( aFilename ), iTargetUri( aTargetUri ),
@@ -76,6 +76,8 @@
iBitmapToPool(aBitmapToPool), iEXIF(aEXIF)
{
TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::CThumbnailScaleTask()", this );
+
+ iRequestId = aRequestId;
}
@@ -95,7 +97,6 @@
iBitmapInPool = ETrue;
iScaledBitmap = NULL;
- iScaledBitmapHandle = 0;
}
@@ -116,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;
}
@@ -150,6 +143,8 @@
CalculateCropRectangle();
}
+ TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - sizes calculated", this );
+
#ifdef _DEBUG
aStart.UniversalTime();
#endif
@@ -162,6 +157,8 @@
if(bitmapSize.iHeight == iTargetSize.iHeight && bitmapSize.iWidth == iTargetSize.iWidth)
{
+ TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - no need for scaling", this);
+
// copy bitmap 1:1
User::LeaveIfError( iScaledBitmap->Create( bitmapSize, iBitmap->DisplayMode() ));
CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iScaledBitmap);
@@ -172,7 +169,6 @@
gc->BitBlt(TPoint(0, 0), iBitmap);
CleanupStack::PopAndDestroy(2, device); // gc
- TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - no need for scaling", this);
TRAPD( err, StoreAndCompleteL());
Complete( err );
ResetMessageData();
@@ -180,11 +176,13 @@
else
{
TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - scaling", this);
+
User::LeaveIfError( iScaledBitmap->Create( iTargetSize, iBitmap->DisplayMode() ));
iServer.ScaleBitmapL( iStatus, * iBitmap, * iScaledBitmap, iCropRectangle );
SetActive();
- }
-
+ }
+
+ TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() end", this );
}
@@ -362,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");
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -219,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 );
@@ -251,8 +254,6 @@
//OpenStoresL();
AddUnmountObserversL();
-
- iReconnect = CPeriodic::NewL(CActive::EPriorityIdle);
}
@@ -484,7 +485,7 @@
TThumbnailBitmapRef* ptr = iBitmapPool.Find( aBitmap->Handle());
- TN_DEBUG2( "CThumbnailServer::AddBitmapToPoolL() - id = %d", aRequestId.iRequestId );
+ TN_DEBUG2( "CThumbnailServer::AddBitmapToPoolL() - req id = %d", aRequestId.iRequestId );
if ( ptr )
{
@@ -605,10 +606,10 @@
// 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(
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp Fri Apr 16 15:16:16 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();
@@ -676,16 +703,18 @@
CThumbnailScaleTask* scaleTask = CThumbnailScaleTask::NewL( Server()->Processor(),
*Server(), params.iTargetUri, bitmap, bitmapSize,
(*missingSizes)[i].iSize, (*missingSizes)[i].iCrop, params.iDisplayMode,
- KMaxPriority, KNullDesC, (*missingSizes)[i].iType, params.iModified, EFalse, EFalse );
+ KMaxPriority, KNullDesC, (*missingSizes)[i].iType, params.iModified, EFalse, EFalse,
+ reqId);
CleanupStack::PushL( scaleTask );
scaleTask->SetDoStore( ETrue );
Server()->Processor().AddTaskL( scaleTask );
CleanupStack::Pop( scaleTask );
- if( i == count-1 )
+ // completion to first task, because task processor works like stack
+ if( i == 0 )
{
// scaleTask is now responsible for completing the RMessage
- scaleTask->SetMessageData( reqId, iMessage );
+ scaleTask->SetMessageData( reqId, iMessage, iClientThread );
iMessage = RMessage2();
}
}
@@ -704,6 +733,7 @@
missingSizes = NULL;
}
+ // Scale tasks now reference the bitmap in the pool
Server()->DeleteBitmapFromPool( iBitmapHandle );
iBitmapHandle = 0;
bitmap = NULL;
@@ -788,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
@@ -896,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
@@ -918,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();
@@ -969,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 <
@@ -998,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
{
@@ -1027,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(
@@ -1042,6 +1072,8 @@
//
TInt CThumbnailServerSession::ChangePriority( const RMessage2& aMessage )
{
+ TN_DEBUG1( "CThumbnailServerSession::ChangePriority()" );
+
const TThumbnailServerRequestId requestId( this, aMessage.Int0());
const TInt newPriority = aMessage.Int1();
@@ -1127,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();
@@ -1330,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;
}
@@ -1368,6 +1389,7 @@
}
else
{
+ TN_DEBUG1( "CThumbnailServerSession::ClientThreadAlive() - message null");
return EFalse;
}
}
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp Fri Apr 16 15:16:16 2010 +0300
@@ -21,7 +21,7 @@
#include <fbs.h>
#include <imageconversion.h>
#include <e32base.h>
-#include <exifread.h>
+#include <ExifRead.h>
#include <bautils.h>
#include <IclExtJpegApi.h>
@@ -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 ========
// ---------------------------------------------------------------------------
@@ -154,7 +153,7 @@
//
CThumbnailStore::~CThumbnailStore()
{
- TN_DEBUG1( "CThumbnailStore::~CThumbnailStore()" );
+ TN_DEBUG2( "CThumbnailStore::~CThumbnailStore() drive: %d", iDrive );
if(iActivityManager)
{
@@ -179,23 +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 ):
- iFs( aFs ), iDrive( aDrive ), iBatchItemCount(0), iImei(aImei), iServer(aServer), iDiskFull(EFalse)
+CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei, CThumbnailServer* aServer ):
+ iFs( aFs ), iDrive( aDrive ), iDriveChar( 0 ), iBatchItemCount(0), iImei(aImei),
+ iServer(aServer), iDiskFull(EFalse), iUnrecoverable(ETrue)
{
// no implementation required
}
-
// ---------------------------------------------------------------------------
// CThumbnailStore::ConstructL()
// Symbian 2nd phase constructor can leave.
@@ -211,9 +211,8 @@
HBufC* databasePath = HBufC::NewLC( KMaxFileName );
TPtr pathPtr = databasePath->Des();
- TChar driveChar = 0;
- User::LeaveIfError( RFs::DriveToChar( iDrive, driveChar ));
- pathPtr.Append( driveChar );
+ User::LeaveIfError( RFs::DriveToChar( iDrive, iDriveChar ));
+ pathPtr.Append( iDriveChar );
pathPtr.Append( KThumbnailDatabaseName );
//start disk space monitor
@@ -223,13 +222,14 @@
CleanupStack::PopAndDestroy( databasePath );
+ 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;
@@ -241,6 +241,7 @@
TInt CThumbnailStore::OpenDatabaseFileL()
{
TN_DEBUG1( "CThumbnailStore::OpenDatabaseFile()" );
+
HBufC* databasePath = HBufC::NewLC( KMaxFileName );
TPtr pathPtr = databasePath->Des();
TChar driveChar = 0;
@@ -256,89 +257,97 @@
// ---------------------------------------------------------------------------
// OpenDatabaseL database
// ---------------------------------------------------------------------------
-TInt CThumbnailStore::OpenDatabaseL()
+TInt CThumbnailStore::OpenDatabaseL( TBool aNewDatabase )
{
- TN_DEBUG1( "CThumbnailStore::OpenDatabaseL()" );
+ 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();
+ if (aNewDatabase)
+ {
+ // delete existing and create new
+ CleanupClosePushL(iDatabase);
+ RecreateDatabaseL(ETrue);
+ CleanupStack::Pop(&iDatabase);
+ }
+ else
+ {
+ // 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
+ {
+ // 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;
+ }
+ }
+ }
- if ( err == KErrNotFound )
- {
- // 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)
- {
- error = CheckRowIDsL();
- }
- }
-
- TN_DEBUG3( "CThumbnailStore::ConstructL() -- error = %d, err = %d", error, err);
-
- // 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);
- }
+ // opened existing database file
+ if(!aNewDatabase)
+ {
+ // add temp tables
+ CreateTempTablesL();
+
+ //check ownership
+ imeiError = CheckImei();
- //check ownership
- error = CheckImeiL();
+ if(imeiError != KErrNone)
+ {
+ //take ownership
+ imeiError = UpdateImeiL();
+
+ //Touch blacklisted items
+ TRAP(blistError, PrepareBlacklistedItemsForRetryL() );
+ }
- 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);
- }
- }
- }
+ //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);
+ }
+ }
- PrepareDbL();
- return KErrNone;
+ PrepareStatementsL();
+
+ // database now usable
+ iUnrecoverable = EFalse;
+
+ return KErrNone;
}
// ---------------------------------------------------------------------------
@@ -348,41 +357,15 @@
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 );
-#ifdef _DEBUG
- if(err < 0)
- {
- TPtrC errorMsg = iDatabase.LastErrorMessage();
- TN_DEBUG2( "CThumbnailStore::ConstructL() KThumbnailCreateTempInfoTable %S" , &errorMsg);
- }
-#endif
- User::LeaveIfError( err );
-
- err = iDatabase.Exec( KThumbnailCreateTempInfoDataTable );
-#ifdef _DEBUG
- if(err < 0)
- {
- TPtrC errorMsg = iDatabase.LastErrorMessage();
- TN_DEBUG2( "CThumbnailStore::ConstructL() KThumbnailCreateTempInfoDataTable %S" , &errorMsg);
- }
-#endif
- User::LeaveIfError( err );
-}
+ AddVersionAndImeiL();
+
+ // add temp tables
+ CreateTempTablesL();
+ }
// ---------------------------------------------------------------------------
// Create database tables
@@ -392,80 +375,638 @@
{
TN_DEBUG1( "CThumbnailStore::CreateTablesL()" );
- TInt err = 0;
+ 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)
+ {
+ TPtrC errorMsg = iDatabase.LastErrorMessage();
+ TN_DEBUG2( "CThumbnailStore::PrepareDbL() KThumbnailCreateTempInfoTable %S" , &errorMsg);
+ }
+#endif
- err = iDatabase.Exec( KThumbnailCreateInfoTableIndex1 );
- TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex1 err=%d", err );
+ User::LeaveIfError( err );
+
+ err = iDatabase.Exec( KThumbnailCreateTempInfoDataTable );
- err = iDatabase.Exec( KThumbnailCreateDeletedTableIndex );
- TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateDeletedTableIndex err=%d", err );
+#ifdef _DEBUG
+ if(err < 0)
+ {
+ TPtrC errorMsg = iDatabase.LastErrorMessage();
+ TN_DEBUG2( "CThumbnailStore::PrepareDbL() KThumbnailCreateTempInfoDataTable %S" , &errorMsg);
+ }
+#endif
User::LeaveIfError( err );
}
void CThumbnailStore::RecreateDatabaseL(const TBool aDelete)
{
- TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL()" );
+ 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);
+
+ iDatabase.Close();
+ iUnrecoverable = ETrue;
- // delete db and create new
- iDatabase.Close();
+ TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() database closed" );
HBufC* databasePath = HBufC::NewLC( KMaxFileName );
TPtr pathPtr = databasePath->Des();
- TChar driveChar = 0;
- User::LeaveIfError( RFs::DriveToChar( iDrive, driveChar ));
- pathPtr.Append( driveChar );
+ User::LeaveIfError( RFs::DriveToChar( iDrive, iDriveChar ));
+ pathPtr.Append( iDriveChar );
pathPtr.Append( KThumbnailDatabaseName );
TInt err(KErrNone);
+ // delete old if necessary
if(aDelete)
{
- iDatabase.Delete(pathPtr);
+ TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() delete database" );
+ TInt del = iDatabase.Delete(pathPtr);
+ TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() deleted database, err: %d", del );
}
const TDesC8& config = KThumbnailSqlConfig;
RSqlSecurityPolicy securityPolicy;
CleanupClosePushL( securityPolicy );
- securityPolicy.Create( KThumbnailDatabaseSecurityPolicy );
+ securityPolicy.CreateL( KThumbnailDatabaseSecurityPolicy );
- TRAP(err, iDatabase.CreateL( pathPtr, securityPolicy, &config ));
+ // create new
+ TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() create new" );
+ 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<KImeiBufferSize> 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)
{
- TPtrC errorMsg = iDatabase.LastErrorMessage();
- TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() KThumbnailInsertTempThumbnailInfoData %S" , &errorMsg);
+#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
- TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- database created err = %d", err );
+
+ 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 );
+
+ 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 );
- CleanupStack::PopAndDestroy( databasePath );
+
+ 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 );
- RFile64 file;
- file.Create(iFs, mediaid, EFileShareReadersOrWriters );
- file.Close();
+ 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 );
- OpenDatabaseFileL();
+ 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");
}
// ---------------------------------------------------------------------------
@@ -489,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;
@@ -548,13 +1089,29 @@
}
else
{
-
+ TInt timeErr = KErrNone;
+
if (aPath.Length())
{
- iFs.Modified(aPath, timeStamp);
- TN_DEBUG2( "CThumbnailStore::StoreThumbnailL() timeStamp iFs %Ld", timeStamp.Int64() );
+ // need to add drive letter
+ TFileName path;
+ path.Append(iDriveChar);
+ path.Append(KDrv);
+ path.Append(aPath);
+
+ timeErr = iFs.Modified(path, timeStamp);
+
+ if (timeErr != KErrNone)
+ {
+ TN_DEBUG2( "CThumbnailStore::StoreThumbnailL() error getting timeStamp: %d", timeErr );
+ }
+ else
+ {
+ TN_DEBUG2( "CThumbnailStore::StoreThumbnailL() timeStamp iFs %Ld", timeStamp.Int64() );
+ }
}
- else
+
+ if (!aPath.Length() || timeErr != KErrNone)
{
// otherwise current time
timeStamp.UniversalTime();
@@ -564,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();
@@ -625,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 )
@@ -662,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 ",
@@ -682,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
{
@@ -709,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 );
}
@@ -731,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)
{
@@ -788,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)
{
@@ -811,8 +1372,7 @@
}
}
- stmt.Close();
- CleanupStack::PopAndDestroy( &stmt );
+ CleanupStack::PopAndDestroy( stmt );
return found;
}
@@ -826,6 +1386,8 @@
{
TN_DEBUG2( "CThumbnailStore::GetMissingSizesL() aSourceType == %d", aSourceType );
+ User::LeaveIfError( CheckDbState() );
+
HBufC* path = aPath.AllocLC();
TPtr ptr(path->Des());
StripDriveLetterL( ptr );
@@ -839,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 )
{
@@ -848,12 +1410,12 @@
}
else
{
- aMissingSizes.Append( iPersistentSizes[ i ] );
+ aMissingSizes.AppendL( iPersistentSizes[ i ] );
}
- }
+ }
else
{
- aMissingSizes.Append( iPersistentSizes[ i ] );
+ aMissingSizes.AppendL( iPersistentSizes[ i ] );
}
}
}
@@ -863,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;
@@ -879,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++ )
@@ -893,10 +1456,10 @@
}
}
- rowStatus = stmt.Next();
+ rowStatus = stmt->Next();
}
- stmt.Close();
- CleanupStack::PopAndDestroy( &stmt );
+
+ CleanupStack::PopAndDestroy( stmt );
// all found
if (missingSizeCount == 0)
@@ -907,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++;
@@ -930,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;
@@ -947,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;
@@ -1003,7 +1561,6 @@
if( modified )
{
// Close db to get deletion of thumbnails executed.
- stmt.Close();
CleanupStack::PopAndDestroy( &stmt );
DeleteThumbnailsL( *path );
User::Leave( KErrNotFound );
@@ -1017,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
@@ -1045,8 +1604,7 @@
TN_DEBUG1( "CThumbnailStore::FetchThumbnailL() -- thumbnail NOT found" );
}
- stmt.Close();
- CleanupStack::PopAndDestroy( &stmt );
+ CleanupStack::PopAndDestroy( stmt );
CleanupStack::PopAndDestroy( path );
User::LeaveIfError( found );
@@ -1060,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;
@@ -1083,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)
@@ -1148,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)
{
@@ -1249,9 +1802,9 @@
StopAutoFlush();
- if(iBatchItemCount <= 0)
+ if(iBatchItemCount <= 0 || CheckDbState() != KErrNone)
{
- // cache empty
+ // cache empty or db unusable
return;
}
@@ -1262,9 +1815,6 @@
return;
}
- //cache full, flush now
- iBatchItemCount = 0;
-
#ifdef _DEBUG
TTime aStart, aStop;
aStart.UniversalTime();
@@ -1285,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
@@ -1301,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);
@@ -1315,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 );
@@ -1327,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);
@@ -1336,246 +1884,6 @@
}
// -----------------------------------------------------------------------------
-// CheckVersionAndImeiL()
-// -----------------------------------------------------------------------------
-//
-TInt CThumbnailStore::CheckImeiL()
- {
- TN_DEBUG1( "CThumbnailStore::CheckImeiL()" );
- RSqlStatement stmt;
- CleanupClosePushL( stmt );
-
- TInt rowStatus = 0;
- TInt column = 0;
- TBuf<KImeiBufferSize> 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()
// -----------------------------------------------------------------------------
//
@@ -1671,6 +1979,24 @@
self->iMaintenanceTimer->Cancel();
+ TInt MPXHarvesting(0);
+ TInt DaemonProcessing(0);
+ TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
+ if(ret != KErrNone || MPXHarvesting)
+ {
+ TN_DEBUG3( "CThumbnailStore::MaintenanceTimerCallBack() KMPXHarvesting err == %d, MPXHarvesting == %d", ret, MPXHarvesting);
+ self->iIdle = EFalse;
+ }
+ TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() KMPXHarvesting == %d", MPXHarvesting);
+
+ ret = RProperty::Get(KTAGDPSNotification, KDaemonProcessing, DaemonProcessing);
+ if(ret != KErrNone || DaemonProcessing)
+ {
+ TN_DEBUG3( "CThumbnailStore::MaintenanceTimerCallBack() KDaemonProcessing err == %d, DaemonProcessing == %d", ret, DaemonProcessing);
+ self->iIdle = EFalse;
+ }
+ TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() DaemonProcessing == %d", DaemonProcessing);
+
if (self->iIdle)
{
TN_DEBUG2( "CThumbnailStore::MaintenanceTimerCallBack() - maintenance, store %d", self->iDrive);
@@ -1696,7 +2022,7 @@
}
}
- // file existance check
+ // file existence check
else if (self->iCheckFilesExist)
{
TBool finished = EFalse;
@@ -1735,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 );
@@ -1824,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;
}
// -----------------------------------------------------------------------------
@@ -1927,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;
@@ -1946,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();
@@ -2024,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;
@@ -2042,39 +2284,35 @@
TBool finished = EFalse;
- TChar dChar = 0;
- User::LeaveIfError( iFs.DriveToChar( iDrive, dChar ));
-
RThumbnailTransaction transaction( iDatabase );
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(dChar);
+ full.Append(iDriveChar);
full.Append(KDrv);
full.Append(path);
@@ -2096,7 +2334,7 @@
count++;
// get next
- rowStatus = stmt.Next();
+ rowStatus = stmt->Next();
}
if (count < KStoreMaintenanceExistLimit)
@@ -2105,8 +2343,7 @@
finished = ETrue;
}
- stmt.Close();
- CleanupStack::PopAndDestroy( &stmt );
+ CleanupStack::PopAndDestroy( stmt );
transaction.CommitL();
CleanupStack::PopAndDestroy( &transaction );
@@ -2134,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 );
@@ -2170,30 +2426,34 @@
{
TInt MPXHarvesting(0);
TInt DaemonProcessing(0);
+
TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
- if(!ret)
+ if(ret != KErrNone || MPXHarvesting)
+ {
+ TN_DEBUG3( "CThumbnailStore::ActivityChanged() KMPXHarvesting err == %d, MPXHarvesting == %d", ret, MPXHarvesting);
+ iIdle = EFalse;
return;
-
- TN_DEBUG2( "CThumbnailStore::ActivityChanged() KMPXHarvesting == %d", KMPXHarvesting);
+ }
ret = RProperty::Get(KTAGDPSNotification, KDaemonProcessing, DaemonProcessing);
-
- if(!ret)
+ if(ret != KErrNone || DaemonProcessing)
+ {
+ TN_DEBUG3( "CThumbnailStore::ActivityChanged() KDaemonProcessing err == %d DaemonProcessing == %d", ret, DaemonProcessing );
+ iIdle = EFalse;
return;
-
- TN_DEBUG2( "CThumbnailStore::ActivityChanged() DaemonProcessing == %d", DaemonProcessing);
+ }
- if(!MPXHarvesting && !DaemonProcessing)
- {
- TN_DEBUG1( "CThumbnailStore::ActivityChanged() - starting maintenance");
- iIdle = ETrue;
- StartMaintenance();
- }
+ TN_DEBUG1( "CThumbnailStore::ActivityChanged() - starting maintenance");
+ iIdle = ETrue;
+ StartMaintenance();
}
}
+
+// -----------------------------------------------------------------------------
// CThumbnailStoreDiskSpaceNotifierAO class
-
+// -----------------------------------------------------------------------------
+//
CThumbnailStoreDiskSpaceNotifierAO* CThumbnailStoreDiskSpaceNotifierAO::NewL(
MThumbnailStoreDiskSpaceNotifierObserver& aObserver, TInt64 aThreshold, const TDesC& aFilename)
{
@@ -2260,8 +2520,7 @@
ret = iFileServerSession.Volume( volumeInfo, iDrive );
if(!ret)
- {
-
+ {
// Check if free space is less than threshold level
if( volumeInfo.iFree < iThreshold )
{
@@ -2305,7 +2564,7 @@
{
const TInt KMaxIterations = 10;
- iFileServerSession.Volume( volumeInfo, iDrive );
+ User::LeaveIfError( iFileServerSession.Volume( volumeInfo, iDrive ) );
if ( volumeInfo.iFree < iThreshold )
{
iObserver.HandleDiskSpaceNotificationL( iDiskFull );
@@ -2319,7 +2578,7 @@
}
else
{
- iFileServerSession.Volume( volumeInfo, iDrive );
+ User::LeaveIfError( iFileServerSession.Volume( volumeInfo, iDrive ) );
if ( volumeInfo.iFree >= iThreshold )
{
TN_DEBUG1( "CThumbnailStoreDiskSpaceNotifierAO::RunL() NOT FULL");
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtask.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtask.cpp Fri Apr 16 15:16:16 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)
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtaskprocessor.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailtaskprocessor.cpp Fri Apr 16 15:16:16 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)
--- a/imagehandlingutilities/thumbnailmanager/tmcommon/inc/tmactivitymanager.h Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/tmcommon/inc/tmactivitymanager.h Fri Apr 16 15:16:16 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;
--- a/imagehandlingutilities/thumbnailmanager/tmcommon/src/tmactivitymanager.cpp Fri Mar 19 09:35:30 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/tmcommon/src/tmactivitymanager.cpp Fri Apr 16 15:16:16 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()
--- a/layers.sysdef.xml Fri Mar 19 09:35:30 2010 +0200
+++ b/layers.sysdef.xml Fri Apr 16 15:16:16 2010 +0300
@@ -21,6 +21,7 @@
<layer name="unit_test_layer">
<module name="imagehandling_unit_tests">
+ <unit unitID="imm.thumbnailmanagerqt_unit_test" name="thumbnailmanagerqt_unit_test" bldFile="&layer_real_source_path;/imagehandlingutilities/thumbnailmanager/thumbnailmanagerqt/tsrc" proFile="test_qtnmwrapper.pro" mrp="" />
</module>
</layer>
--- a/package_definition.xml Fri Mar 19 09:35:30 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<SystemDefinition schema="3.0.0">
- <package id="imghandling" name="Image Handling" levels="lib util if">
- <collection id="library3gp" name="3GP Library" level="lib">
- <component id="lib3gpmp4" filter="s60" name="3GP MP4 Library" deprecated="^3">
- <!-- deprecated due to duplication -->
- <unit bldFile="3gplibrary/3gpmp4lib/group"/>
- <!-- does the test need to be #included in the above? -->
- <!-- <unit bldFile="3gplibrary/3gpmp4lib/tsrc/public/basic/group"/> -->
- </component>
- </collection>
- <collection id="imagehandlinglib" name="Image Handling Library" level="lib">
- <component id="ihl" filter="s60" name="IHL">
- <unit bldFile="imagehandlinglib/group"/>
- </component>
- </collection>
- <collection id="imagehandlingutilities" name="Image Handling Utilities" level="util">
- <component id="imageinfopopup" filter="s60" name="Image Info Popup">
- <unit bldFile="imagehandlingutilities/imageinfopopup/group"/>
- </component>
- <component id="imagepreview" filter="s60" name="Image Preview">
- <unit bldFile="imagehandlingutilities/imagepreview/group"/>
- </component>
- <component id="thumbnailmanager" filter="s60" name="Thumbnail Manager">
- <unit bldFile="imagehandlingutilities/thumbnailmanager/group"/>
- </component>
- <component id="tvoutengine" filter="s60" name="TV Out Engine">
- <unit bldFile="imagehandlingutilities/tvoutengine/group"/>
- </component>
- </collection>
- <collection id="imghandling_info" name="Image Handling Info" level="if">
- <component id="imagehandling_plat" filter="s60" name="Image Handling Platform Interfaces" class="api">
- <unit bldFile="imagehandling_plat/group"/>
- <!-- <unit bldFile="imagehandling_plat/3gp_library_api/tsrc/group"/> -->
- <!-- <unit bldFile="imagehandling_plat/thumbnailmanager_api/tsrc/group"/> -->
- </component>
- <component id="imghandling_build" filter="s60" name="Image Handling Build">
- <!-- system include from this needs to be moved to each #included bld.inf -->
- <unit bldFile="group"/>
- </component>
- </collection>
- </package>
-</SystemDefinition>