Revision: 201009 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 15 Mar 2010 12:41:55 +0200
branchRCL_3
changeset 8 7403edfcf0fb
parent 7 2eb74cf6572e
child 9 dea39715fc05
Revision: 201009 Kit: 201010
imagehandlingutilities/thumbnailmanager/conf/thumbnailmanager.confml
imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h
imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp
imagehandlingutilities/thumbnailmanager/thumbagdaemon/group/thumbagdaemon.mmp
imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h
imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp
imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/group/thumbnailserver.mmp
imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailscaletask.h
imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp
Binary file imagehandlingutilities/thumbnailmanager/conf/thumbnailmanager.confml has changed
--- a/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h	Mon Mar 15 12:41:55 2010 +0200
@@ -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/plugins/video/src/thumbnailvideoprovider.cpp	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp	Mon Mar 15 12:41:55 2010 +0200
@@ -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/thumbagdaemon/group/thumbagdaemon.mmp	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/group/thumbagdaemon.mmp	Mon Mar 15 12:41:55 2010 +0200
@@ -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 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h	Mon Mar 15 12:41:55 2010 +0200
@@ -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 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagdaemon.cpp	Mon Mar 15 12:41:55 2010 +0200
@@ -306,7 +306,7 @@
 // -----------------------------------------------------------------------------
 //
 
-void CThumbAGDaemon::HandleUriObjectNotification(CMdESession& aSession, 
+void CThumbAGDaemon::HandleUriObjectNotification(CMdESession& /*aSession*/, 
         TObserverNotificationType aType,
         const RArray<TItemId>& aObjectIdArray,
         const RPointerArray<HBufC>& aObjectUriArray)
@@ -510,7 +510,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 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp	Mon Mar 15 12:41:55 2010 +0200
@@ -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;
-                    }
                 }
             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();
     }
@@ -1477,10 +1526,7 @@
     TN_DEBUG2( "CThumbAGProcessor::SetForceRun(%d) - end", aForceRun ); 
 
     // enable forced run
-    if (aForceRun)
-        {
-        iForceRun = aForceRun;
-        }
+    iForceRun = aForceRun;
     }
 
 // ---------------------------------------------------------------------------
@@ -1550,18 +1596,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
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/group/thumbnailserver.mmp	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/group/thumbnailserver.mmp	Mon Mar 15 12:41:55 2010 +0200
@@ -90,6 +90,7 @@
 
 DEBUGLIBRARY            flogger.lib
 
-PAGED
 BYTEPAIRCOMPRESSTARGET
 EPOCPROCESSPRIORITY background
+
+UNPAGED
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailscaletask.h	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailscaletask.h	Mon Mar 15 12:41:55 2010 +0200
@@ -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/thumbnailstore.h	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h	Mon Mar 15 12:41:55 2010 +0200
@@ -523,9 +523,10 @@
     RFs& iFs;
 
     /**
-     * Drive number
+     * Drive number & char
      */
     TInt iDrive;
+    TChar iDriveChar;
 
     /**
      * Thumbnail database.
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp	Mon Mar 15 12:41:55 2010 +0200
@@ -174,6 +174,8 @@
     DoBlacklisting( providerErr, TSize(0,0) );
     
     User::LeaveIfError( providerErr );
+    
+    TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::StartL() end", this );
     }
 
 
@@ -354,7 +356,8 @@
             
             CThumbnailScaleTask* scaleTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename,
                 iBitmap, iOriginalSize, (*iMissingSizes)[ i ].iSize, (*iMissingSizes)[ i ].iCrop, iDisplayMode,
-                KMaxPriority, iTargetUri, (*iMissingSizes)[ i ].iType, iModified, iScaledBitmapToPool, iEXIF );
+                KMaxPriority, iTargetUri, (*iMissingSizes)[ i ].iType, iModified, iScaledBitmapToPool, iEXIF,
+                iRequestId);
             CleanupStack::PushL( scaleTask );
             
             TInt err1 = KErrNone;
@@ -401,17 +404,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
             ::ECropToAspectRatio, iDisplayMode, KMaxPriority, iTargetUri,
-            iThumbnailSize, iModified, iScaledBitmapToPool, iEXIF );
+            iThumbnailSize, iModified, iScaledBitmapToPool, iEXIF, iRequestId );
         CleanupStack::PushL( complTask );
         
         TInt err1 = KErrNone;
@@ -511,7 +514,8 @@
             aError == KErrCorrupt ||
             aError == KErrCompletion ||
             aError == KErrUnderflow ||
-            aError == KErrNotReady)
+            aError == KErrNotReady || 
+            aError == KErrGeneral )
             {
         
         if(iMissingSizes)
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailscaletask.cpp	Mon Mar 15 12:41:55 2010 +0200
@@ -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;
     }
 
 
@@ -150,6 +152,8 @@
         CalculateCropRectangle();
         }
     
+    TN_DEBUG2( "CThumbnailScaleTask(0x%08x)::StartL() - sizes calculated", this );
+    
 #ifdef _DEBUG
     aStart.UniversalTime();
 #endif
@@ -162,6 +166,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 +178,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 +185,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 );
     }
 
 
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp	Mon Mar 15 12:41:55 2010 +0200
@@ -36,6 +36,7 @@
 #include "thumbnailcenrep.h"
 #include "thumbnailmemorycardobserver.h"
 #include "tmgetimei.h"
+//#include "thumbnailfetchedchecker.h"
 
 
 _LIT8( KThumbnailMimeWildCard, "*" );
@@ -253,6 +254,8 @@
     AddUnmountObserversL();
     
     iReconnect = CPeriodic::NewL(CActive::EPriorityIdle);
+	
+    //iFetchedChecker = CThumbnailFetchedChecker::NewL();
     }
 
 
@@ -266,6 +269,7 @@
 
     iShutdown = ETrue;
     
+    //delete iFetchedChecker;
     delete iShutdownObserver;
     delete iProcessor;
     
@@ -484,7 +488,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 )
         {
@@ -535,6 +539,10 @@
         {
         TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!");
         }
+	/*if( iFetchedChecker )
+		{	
+    	iFetchedChecker->SetFetchResult( aPath, KErrNone );
+		}*/
     }
 
 
@@ -546,8 +554,17 @@
     aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aOriginalSize )
     {
     TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aPath=%S aThumbnailSize=%d)", &aPath, aThumbnailSize );
-
     StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize);
+/*    TInt err( iFetchedChecker->LastFetchResult( aPath ) );
+    if ( err == KErrNone ) // To avoid useless sql gets that fails for sure
+        {
+        TRAP( err, StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize) );
+        if ( err != KErrNone )
+            {
+            iFetchedChecker->SetFetchResult( aPath, err );
+            }
+        }
+    User::LeaveIfError( err );*/
     }
 
 
@@ -599,6 +616,11 @@
     TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath);
     
     StoreForPathL( aPath )->DeleteThumbnailsL( aPath );
+	/*
+	if( iFetchedChecker )
+		{
+    	iFetchedChecker->SetFetchResult( aPath, KErrNone );
+		}*/
     }
 
 // -----------------------------------------------------------------------------
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp	Mon Mar 15 12:41:55 2010 +0200
@@ -676,13 +676,15 @@
             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 );
@@ -1349,6 +1351,9 @@
     
         // check if client thread alive
         TExitType exitType = clientThread.ExitType();
+        
+        clientThread.Close();
+        
         if( exitType != EExitPending )
             {
             TN_DEBUG1( "CThumbnailServerSession::ClientThreadAlive() - client thread died");
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp	Fri Mar 12 15:43:57 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp	Mon Mar 15 12:41:55 2010 +0200
@@ -154,7 +154,7 @@
 //
 CThumbnailStore::~CThumbnailStore()
     {
-    TN_DEBUG1( "CThumbnailStore::~CThumbnailStore()" );
+    TN_DEBUG2( "CThumbnailStore::~CThumbnailStore() drive: %d", iDrive );
     
     if(iActivityManager)
         {
@@ -190,7 +190,8 @@
 // ---------------------------------------------------------------------------
 //
 CThumbnailStore::CThumbnailStore( RFs& aFs, TInt aDrive, TDesC& aImei,  CThumbnailServer* aServer ): 
-    iFs( aFs ), iDrive( aDrive ), iBatchItemCount(0), iImei(aImei), iServer(aServer), iDiskFull(EFalse)
+    iFs( aFs ), iDrive( aDrive ), iDriveChar( 0 ), iBatchItemCount(0), iImei(aImei), 
+    iServer(aServer), iDiskFull(EFalse)
     {
     // no implementation required
     }
@@ -211,9 +212,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,6 +223,8 @@
 
     CleanupStack::PopAndDestroy( databasePath );
     
+    TN_DEBUG2( "CThumbnailStore::ConstructL() drive: %d", iDrive );
+    
     OpenDatabaseL();
              
     // to monitor device activity
@@ -241,6 +243,7 @@
 TInt CThumbnailStore::OpenDatabaseFileL()
     {
     TN_DEBUG1( "CThumbnailStore::OpenDatabaseFile()" );
+    
     HBufC* databasePath = HBufC::NewLC( KMaxFileName );
     TPtr pathPtr = databasePath->Des();
     TChar driveChar = 0;
@@ -258,7 +261,7 @@
 // ---------------------------------------------------------------------------
 TInt CThumbnailStore::OpenDatabaseL()
     {
-    TN_DEBUG1( "CThumbnailStore::OpenDatabaseL()" );
+    TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() drive: %d", iDrive );
         
     iDatabase.Close();
     
@@ -267,24 +270,26 @@
     
     TInt err = OpenDatabaseFileL();
    
-   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_DEBUG2( "CThumbnailStore::OpenDatabaseL() -- err = %d", err);
+    
+    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);
+   TN_DEBUG2( "CThumbnailStore::OpenDatabaseL() -- error = %d", error);
    
    // if wrong version, corrupted database or other error opening db
    if ( error == KErrNotSupported || (err != KErrNone && err != KErrNotFound) )
@@ -354,34 +359,38 @@
     TRAPD(tableError, CreateTablesL() );
       
     if(!tableError)
-      {
-      TRAPD(err, AddVersionAndImeiL());
-      if (err == KSqlErrCorrupt)
-          {
-          RecreateDatabaseL( ETrue);
-          }
-      User::LeaveIfError(err);
-      }
+        {
+        TRAPD(err, AddVersionAndImeiL());
+        if (err == KSqlErrCorrupt)
+            {
+            RecreateDatabaseL( ETrue);
+            }
+        User::LeaveIfError(err);
+        }
           
-      err = iDatabase.Exec( KThumbnailCreateTempInfoTable );
+    err = iDatabase.Exec( KThumbnailCreateTempInfoTable );
+
 #ifdef _DEBUG
-  if(err < 0)
-      {
-       TPtrC errorMsg = iDatabase.LastErrorMessage();
-       TN_DEBUG2( "CThumbnailStore::ConstructL() KThumbnailCreateTempInfoTable %S" , &errorMsg);
-      }
+    if(err < 0)
+        {
+        TPtrC errorMsg = iDatabase.LastErrorMessage();
+        TN_DEBUG2( "CThumbnailStore::PrepareDbL() KThumbnailCreateTempInfoTable %S" , &errorMsg);
+        }
 #endif
+    
     User::LeaveIfError( err );
 
-  err = iDatabase.Exec( KThumbnailCreateTempInfoDataTable );
+    err = iDatabase.Exec( KThumbnailCreateTempInfoDataTable );
+
 #ifdef _DEBUG
-  if(err < 0)
-      {
-       TPtrC errorMsg = iDatabase.LastErrorMessage();
-       TN_DEBUG2( "CThumbnailStore::ConstructL() KThumbnailCreateTempInfoDataTable %S" , &errorMsg);
-      }
+    if(err < 0)
+        {
+        TPtrC errorMsg = iDatabase.LastErrorMessage();
+        TN_DEBUG2( "CThumbnailStore::PrepareDbL() KThumbnailCreateTempInfoDataTable %S" , &errorMsg);
+        }
 #endif
-       User::LeaveIfError( err );
+    
+    User::LeaveIfError( err );
 }
 
 // ---------------------------------------------------------------------------
@@ -415,7 +424,7 @@
 
 void CThumbnailStore::RecreateDatabaseL(const TBool aDelete)
     {
-    TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL()" );
+    TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() drive: %d", iDrive );
     
     TVolumeInfo volumeinfo;
     iFs.Volume(volumeinfo, iDrive);
@@ -426,40 +435,38 @@
     // 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);
     
     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 );
 
+    TN_DEBUG1( "CThumbnailStore::RecreateDatabaseL() create new" );
+    
     TRAP(err, iDatabase.CreateL( pathPtr, securityPolicy, &config ));
-    CleanupStack::PopAndDestroy( &securityPolicy );
     
-        
-#ifdef _DEBUG
-    if(err < 0)
-        {
-        TPtrC errorMsg = iDatabase.LastErrorMessage();
-        TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() KThumbnailInsertTempThumbnailInfoData %S" , &errorMsg);
-        }
-#endif
     TN_DEBUG2( "CThumbnailStore::RecreateDatabaseL() -- database created err = %d", err );
+    
+    CleanupStack::PopAndDestroy( &securityPolicy );
+    CleanupStack::PopAndDestroy( databasePath );
     User::LeaveIfError( err );
-    CleanupStack::PopAndDestroy( databasePath );
     
     RFile64 file;
     file.Create(iFs, mediaid, EFileShareReadersOrWriters );
@@ -548,13 +555,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();
@@ -1671,6 +1694,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);
@@ -2042,9 +2083,6 @@
     
     TBool finished = EFalse;
     
-    TChar dChar = 0;
-    User::LeaveIfError( iFs.DriveToChar( iDrive, dChar ));
-    
     RThumbnailTransaction transaction( iDatabase );
     CleanupClosePushL( transaction );    
     transaction.BeginL();
@@ -2074,7 +2112,7 @@
         stmt.ColumnText( column, path );
     
         full.Zero();
-        full.Append(dChar);
+        full.Append(iDriveChar);
         full.Append(KDrv);
         full.Append(path);
         
@@ -2170,25 +2208,26 @@
         {
         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();
         }
     }