Revision: 201017 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 16:30:11 +0300
branchRCL_3
changeset 20 ffb2d5dd62e9
parent 16 85a88bc05e45
child 21 ad31f4183ddc
Revision: 201017 Kit: 201019
imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/exif.jpg
imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/exif.png
imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/mp3_png.mp3
imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/no_exif.jpg
imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/wma.wma
imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/wma_empty.wma
imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/wma_png.wma
imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h
imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp
imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp
imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.5_SA_S60.50_Euro1.sis
imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.6_SA_S60.50_Euro1.sis
imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg
imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg
imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/thumbnailmanager_stub.sis
imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg
imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h
imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp
imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h
imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp
imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestqueue.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h
imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp
imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp
Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/exif.jpg has changed
Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/exif.png has changed
Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/mp3_png.mp3 has changed
Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/no_exif.jpg has changed
Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/wma.wma has changed
Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/wma_empty.wma has changed
Binary file imagehandling_plat/thumbnailmanager_api/tsrc/data/mmc/ThumbnailManagerTest/wma_png.wma has changed
--- a/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h	Tue May 11 16:30:11 2010 +0300
@@ -55,11 +55,11 @@
 //minimum batch size
 const TUint KMInBatchItems = 3;
 //maximum batch size
-const TUint KMaxBatchItems = 18;
+const TUint KMaxBatchItems = 60;
 //Max allowed flush time
-const TUint KMaxFlushDelay = 3000; //ms
-// fixed batch size for MTP
-const TUint KMaxBatchItemsMTP = 60;
+const TUint KMaxFlushDelay = 3000; // 3 sec
+//Max allowed flush time on MTP/music collection refresh
+const TUint KMaxMTPFlushDelay = 15000; // 15 seconds
 
 //how many items daemon will query at once from MDS
 const TUint KMaxQueryItems = 100;
--- a/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp	Tue May 11 16:30:11 2010 +0300
@@ -93,6 +93,8 @@
 //
 void CThumbnailImageDecoderv3::DecodeL( const TDisplayMode aDisplayMode )
     {
+    TN_DEBUG1( "CThumbnailImageDecoderv3::DecodeL() start" );
+    
     // Create the bitmap
     if ( !iBitmap )
         {
@@ -141,11 +143,10 @@
         }
     
     iDecoder->Convert( &iStatus, * iBitmap );
-    while ( iStatus == KErrUnderflow )
-        {
-        iDecoder->ContinueConvert( &iStatus );
-        }
+
     SetActive();
+    
+    TN_DEBUG1( "CThumbnailImageDecoderv3::DecodeL() end" );
     }
 
 
--- a/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp	Tue May 11 16:30:11 2010 +0300
@@ -233,10 +233,6 @@
         }
 
     iDecoder->Convert( &iStatus, * iBitmap );
-    while ( iStatus == KErrUnderflow )
-        {
-        iDecoder->ContinueConvert( &iStatus );
-        }
     
     SetActive();
     
Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.5_SA_S60.50_Euro1.sis has changed
Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v9.20.6_SA_S60.50_Euro1.sis has changed
--- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg	Tue May 11 16:30:11 2010 +0300
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"Thumbnail Manager"},(0x102830AB), 9, 20, 5, TYPE=SA, RU
+#{"Thumbnail Manager"},(0x102830AB), 9, 20, 6, TYPE=SA, RU
 
 ; Localised Vendor name
 %{"Nokia"}
--- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg	Tue May 11 16:30:11 2010 +0300
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"ThumbnailManager"},(0x102830AB), 9, 20, 5, TYPE=SA
+#{"ThumbnailManager"},(0x102830AB), 9, 20, 6, TYPE=SA
 
 ; Localised Vendor name
 %{"Nokia"}
Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/thumbnailmanager_stub.sis has changed
--- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg	Tue May 11 16:30:11 2010 +0300
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"Thumbnail Manager Cenrep"},(0x10202BE9), 9, 20, 5, TYPE=SP
+#{"Thumbnail Manager Cenrep"},(0x10202BE9), 9, 20, 6, TYPE=SP
 
 ; Localised Vendor name
 %{"Symbian Software Ltd."}
--- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h	Tue May 11 16:30:11 2010 +0300
@@ -169,8 +169,9 @@
      * DeleteAndCancelQuery
      *
      * @since Symbian^3
+     * @param aRemoveItems restore IDs back to original queue, default = ETrue
      */
-    void DeleteAndCancelQuery();
+    void DeleteAndCancelQuery(TBool aRestoreItems);
     
 protected:
 
--- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp	Tue May 11 16:30:11 2010 +0300
@@ -295,7 +295,7 @@
         delete iQueryAllItems;
         iQueryAllItems = NULL;
         }
-    else if(&aQuery == iQuery )
+    else if(&aQuery == iQuery ) 
         {
         TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - Query completed");
         
@@ -318,7 +318,7 @@
                 
                 TInt itemIndex(KErrNotFound);
                 
-                //search delta items
+                //search delta items which were queried, but not found
                  for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++)
                      {
                      TBool found(EFalse);
@@ -369,7 +369,8 @@
             }
         else
             {
-            DeleteAndCancelQuery();
+            //Delete and cancel query, do not return items back to original queue
+            DeleteAndCancelQuery( EFalse );
             TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() Query FAILED!"); 
             }
         }
@@ -664,6 +665,7 @@
                     }
                 }
             
+		   // 9.2 specific
            if( !(imageObjectDef.Id() == aObject->Def().Id() || videoObjectDef.Id() == aObject->Def().Id()) )
                 {
                 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() 1st round and not image or video, skip");
@@ -1030,7 +1032,8 @@
         //force is coming, but executing non-forced query complete-> cancel old
         else
             {
-            DeleteAndCancelQuery();
+			//cancel query and move items back to original processing queue
+            DeleteAndCancelQuery( ETrue );
 	        ActivateAO();
             return;  
             }
@@ -1048,9 +1051,11 @@
     //waiting for MDS query to complete
     else if( iQueryActive )
         {
+		//state mismatch
         if(iForceRun && !iModify)
             {
-            DeleteAndCancelQuery();
+			//cancel query and move items back to original processing queue
+            DeleteAndCancelQuery(ETrue);
             ActivateAO();
             }
         else  
@@ -1126,7 +1131,7 @@
 // CThumbAGProcessor::DeleteAndCancelQuery()
 // ---------------------------------------------------------------------------
 //
-void CThumbAGProcessor::DeleteAndCancelQuery()
+void CThumbAGProcessor::DeleteAndCancelQuery(TBool aRestoreItems)
     {
     TN_DEBUG1( "CThumbAGProcessor::DeleteAndCancelQuery() in" );
     
@@ -1145,7 +1150,7 @@
     //move remainig IDs in query queue back to original queue
     while(iQueryQueue.Count())
         {
-        if(iLastQueue)
+        if(aRestoreItems && iLastQueue)
             {
             if(iLastQueue->FindInOrder(iQueryQueue[0], Compare) == KErrNotFound)
                 {
@@ -1794,7 +1799,7 @@
     //cancel 2nd round generarion when there is items in 1st round queues
     if(itemsLeft && i2ndRound)
         {
-        DeleteAndCancelQuery();
+        DeleteAndCancelQuery(ETrue);
         i2ndRound = EFalse;
         }
         
--- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h	Tue May 11 16:30:11 2010 +0300
@@ -279,6 +279,13 @@
      */
     void StartError( const TInt aErr );
     
+    /**
+     * Async cancel
+     *
+     * @since S60 v5.0
+     */
+    void AsyncCancel();
+    
 private:
 
     /**
--- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp	Tue May 11 16:30:11 2010 +0300
@@ -141,8 +141,27 @@
             }        
         case EReqGetThumbnailPath:
             {
-            iSession.RequestThumbnailL( iPath, iTargetUri, iParams.iThumbnailId, 
-                                        iParamsPckg, iStatus );
+            // for custom size requests file handle can be opened here already, because
+            // custom thumbnails are never stored in db  
+            if (iParams.iThumbnailSize == ECustomThumbnailSize &&
+                iParams.iOriginalControlFlags != EThumbnailGeneratePersistentSizesOnly)
+                {
+                TN_DEBUG1( "CThumbnaiRequestActive::StartL()- custom size request" );
+                  
+                iFile.Close();
+                User::LeaveIfError( iFile.Open( iFs, iPath, EFileShareReadersOrWriters ) );  
+                
+                TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iTargetUri );
+                
+                CleanupClosePushL( iFile );
+                iSession.RequestThumbnailL( iFile, iPath, iParamsPckg, iStatus );
+                CleanupStack::PopAndDestroy( &iFile );   
+                }
+            else
+                {
+                iSession.RequestThumbnailL( iPath, iTargetUri, iParams.iThumbnailId, 
+                                            iParamsPckg, iStatus );
+                }            
             break;
             }  
         case EReqSetThumbnailBuffer:
@@ -212,7 +231,7 @@
 void CThumbnailRequestActive::RunL()
     {
     TN_DEBUG2( "CThumbnailRequestActive::RunL() - request ID: %d", iParams.iRequestId );
-    
+ 
     if ( iParams.iControlFlags == EThumbnailPreviewThumbnail )
         {
         iRequestCompleted = EFalse;
@@ -450,6 +469,24 @@
 
 
 // ---------------------------------------------------------------------------
+// CThumbnailRequestActive::AsyncCancel()
+// ---------------------------------------------------------------------------
+//
+void CThumbnailRequestActive::AsyncCancel()
+    {
+    TN_DEBUG1( "CThumbnailRequestActive::AsyncCancel");
+
+    __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId ));
+    
+    iCanceled = ETrue;
+    iSession.CancelRequest( iRequestId );
+    ReleaseServerBitmap();
+
+    // AO stays active until request is complete or timeout is reached
+    }
+
+
+// ---------------------------------------------------------------------------
 // CThumbnailRequestActive::ReleaseServerBitmap()
 // Releases reserved bitmap.
 // ---------------------------------------------------------------------------
@@ -619,6 +656,7 @@
     iParams.iQualityPreference = aQualityPreference;
     iParams.iThumbnailSize = aThumbnailSize;
     iParams.iThumbnailId = aThumbnailId;
+    iParams.iFileName = aPath;
     
     iPath = aPath;
     iTargetUri = aTargetUri;
@@ -845,13 +883,6 @@
     
     self->iTimer->Cancel();
     
-    if (self->IsActive())
-        {
-        // hangs without this
-        TRequestStatus* statusPtr = &self->iStatus;
-        User::RequestComplete( statusPtr, KErrTimedOut );
-        }
-    
     self->Cancel();
     
     if (self->iStartError != KErrNone)
--- a/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestqueue.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestqueue.cpp	Tue May 11 16:30:11 2010 +0300
@@ -188,19 +188,10 @@
         CThumbnailRequestActive* request = iRequests[i];
         if ( request->RequestId() == aRequestId )
             {
-            // Cancel and remove from queue
             if (iRequests[i]->IsActive()) 
                 {
-                iRequests[i]->Cancel();
-                
-                iActiveRequests--;
-                if(iActiveRequests <= -1)
-                    {
-                    iActiveRequests = 0;
-                    }
-                
-                delete request;
-                iRequests.Remove( i );
+                // this doesn't yet actually cancel/complete the AO
+                iRequests[i]->AsyncCancel();
                 
                 TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - canceled request ID: %d", aRequestId);
                 }
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h	Tue May 11 16:30:11 2010 +0300
@@ -88,7 +88,6 @@
 
 // indexes
 _LIT8( KThumbnailCreateInfoTableIndex1, "CREATE INDEX idx1 ON ThumbnailInfo(Path, Size);");
-_LIT8( KThumbnailCreateDeletedTableIndex, "CREATE INDEX idx4 ON ThumbnailDeleted(Path);");
 
 // parameters
 _LIT( KThumbnailSqlParamData, ":Data" );
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h	Tue May 11 16:30:11 2010 +0300
@@ -646,6 +646,10 @@
      * Measure time spend in flush
      */
     TTime iStartFlush, iStopFlush;
+	/**
+     * How long previous flush took ms
+     */
+    TInt iPreviousFlushDelay;
 
 };
 // End of File
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp	Tue May 11 16:30:11 2010 +0300
@@ -28,6 +28,7 @@
 #include "thumbnailmanagerconstants.h"
 #include "thumbnaillog.h"
 #include "thumbnailpanic.h"
+#include "thumbnailfetchedchecker.h"
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -488,11 +489,15 @@
         {
         iServer.StoreForPathL( iFilename )->StoreThumbnailL( 
             iFilename, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iModified, EFalse, ETrue );
+		//remove result from fetched checker
+        iServer.FetchedChecker().SetFetchResult( iFilename, KErrNone );
         }
     else if(iTargetUri != KNullDesC)
         {
         iServer.StoreForPathL( iTargetUri )->StoreThumbnailL( 
             iTargetUri, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iModified, EFalse, ETrue );
+		//remove result from fetched checker
+        iServer.FetchedChecker().SetFetchResult( iTargetUri, KErrNone );
         }
 
     CleanupStack::PopAndDestroy( tempBitmap );
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp	Tue May 11 16:30:11 2010 +0300
@@ -538,6 +538,7 @@
         {
         TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!");
         }
+    
     if( iFetchedChecker )    
         {
         iFetchedChecker->SetFetchResult( aPath, KErrNone );
@@ -558,6 +559,12 @@
         TInt err( iFetchedChecker->LastFetchResult( aPath ) );
         if ( err == KErrNone ) // To avoid useless sql gets that fails for sure
             {
+            // custom sizes are not stored to db, skip fetching
+            if ( aThumbnailSize == ECustomThumbnailSize )
+                {
+                User::Leave( KErrNotFound );
+                }
+        
             TRAP( err, StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize) );
             if ( err != KErrNone )
                 {
@@ -568,6 +575,12 @@
         }
     else
         {
+        // custom sizes are not stored to db, skip fetching
+        if ( aThumbnailSize == ECustomThumbnailSize )
+            {
+            User::Leave( KErrNotFound );
+            }
+    
         StoreForPathL( aPath )->FetchThumbnailL( aPath, aThumbnail, aData, aThumbnailSize, aOriginalSize);
         }
     }
@@ -876,7 +889,6 @@
     CThumbnailStore** resPtr = iStores.Find( aDrive );
     CThumbnailStore* res = NULL;
 
-
     if ( resPtr )
         {
         res = * resPtr;
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp	Tue May 11 16:30:11 2010 +0300
@@ -613,7 +613,9 @@
                 User::Leave(err);
                 }
 	        
-	        if(Server()->StoreForPathL(params.iFileName)->IsDiskFull())
+	        // disk space check only for stored sizes
+	        if ( params.iThumbnailSize != ECustomThumbnailSize && 
+	             Server()->StoreForPathL(params.iFileName)->IsDiskFull() )
 	            {
 	            User::Leave( KErrDiskFull );
 	            }
@@ -736,22 +738,31 @@
             {           
             if( bitmapSize.iWidth < bitmapSize.iHeight )
                {
-               TInt height = (*missingSizes)[i].iSize.iHeight;
-               (*missingSizes)[i].iSize.iHeight = (*missingSizes)[i].iSize.iWidth;
-               (*missingSizes)[i].iSize.iWidth = height;
-               TN_DEBUG1( "CThumbnailServerSession::RequestSetThumbnailByBitmapL() - portrait");
+               TThumbnailSize size = (*missingSizes)[ i ].iType;
+        
+               if ( size == EFullScreenThumbnailSize ||
+                    size == EVideoFullScreenThumbnailSize ||
+                    size == EAudioFullScreenThumbnailSize ||
+                    size == EImageFullScreenThumbnailSize )
+                   {
+                   TInt height = (*missingSizes)[i].iSize.iHeight;
+                   (*missingSizes)[i].iSize.iHeight = (*missingSizes)[i].iSize.iWidth;
+                   (*missingSizes)[i].iSize.iWidth = height;
+                    
+                   TN_DEBUG1( "CThumbnailServerSession::RequestSetThumbnailByBitmapL() - portrait");
+                   }
                }
-            
+        
             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,
-                reqId);
+                    *Server(), params.iTargetUri, bitmap, bitmapSize,
+                    (*missingSizes)[i].iSize, (*missingSizes)[i].iCrop, params.iDisplayMode,
+                    KMaxPriority, KNullDesC, (*missingSizes)[i].iType, params.iModified, EFalse, EFalse,
+                    reqId);
             CleanupStack::PushL( scaleTask );
             scaleTask->SetDoStore( ETrue );
             Server()->Processor().AddTaskL( scaleTask );
             CleanupStack::Pop( scaleTask );
-            
+        
             // completion to first task, because task processor works like stack
             if( i == 0 )
                 {
@@ -793,7 +804,9 @@
     TN_DEBUG2( 
         "CThumbnailServerSession::CreateGenerateTaskFromFileHandleL() -- create thumbnail generation task for %S", &params.iFileName );
     
-    if(Server()->StoreForPathL(params.iFileName)->IsDiskFull())
+    // disk space check only for stored sizes
+    if ( params.iThumbnailSize != ECustomThumbnailSize && 
+         Server()->StoreForPathL(params.iFileName)->IsDiskFull() )
         {
         User::Leave( KErrDiskFull );
         }
@@ -872,6 +885,7 @@
     // Generate task is now responsible for completing the message
     iMessage = RMessage2();
     } 
+
 // -----------------------------------------------------------------------------
 // CThumbnailServerSession::CreateGenerateTaskL()
 // Create a task to generate a new thumbnail
@@ -884,7 +898,9 @@
     TN_DEBUG2( 
         "CThumbnailServerSession::CreateGenerateTaskFromBufferL() -- create thumbnail generation task for %S", &params.iTargetUri );
   
-    if(Server()->StoreForPathL(params.iTargetUri)->IsDiskFull())
+    // disk space check only for stored sizes
+    if ( params.iThumbnailSize != ECustomThumbnailSize && 
+         Server()->StoreForPathL(params.iTargetUri)->IsDiskFull() )
         {
         User::Leave( KErrDiskFull );
         }
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp	Tue Apr 27 16:57:55 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp	Tue May 11 16:30:11 2010 +0300
@@ -35,7 +35,7 @@
 #include "thumbnailserver.h"
 
 
-_LIT8( KThumbnailSqlConfig, "page_size=16384; cache_size=32;" );
+_LIT8( KThumbnailSqlConfig, "page_size=32768; cache_size=32;" );
 
 const TInt KStreamBufferSize = 1024 * 8;
 const TInt KMajor = 3;
@@ -136,13 +136,21 @@
     {
     if ( iState != EOldOpen )
         {
-        const TInt err = iDatabase.Exec( KThumbnailRollbackTransaction );
-        if ( err >= 0 )
+        // in some cases there could have been automatic rollback
+        if (iDatabase.InTransaction())
             {
-            iState = EClosed;
+            const TInt err = iDatabase.Exec( KThumbnailRollbackTransaction );
+            if ( err >= 0 )
+                {
+                iState = EClosed;
+                }
+            
+            return err;
             }
-        
-        return err;
+        else
+            {
+            TN_DEBUG1( "RThumbnailTransaction::Rollback() - automatic rollback already done!" );
+            }
         }
     
     iState = EClosed;
@@ -418,10 +426,6 @@
     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 );
@@ -1936,23 +1940,51 @@
         return;
         }
     
-    // fixed batch size if MTP sync on
+    // longer flush allowed if MTP sync on
     TInt MPXHarvesting(0);
     TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting);
     if(ret != KErrNone)
+       {
+       TN_DEBUG2( "CThumbnailStore::FlushCacheTable() error checking MTP sync: %d", ret);
+       }
+    
+    //set init max flush delay
+    TInt aMaxFlushDelay(KMaxFlushDelay);
+    
+    if(MPXHarvesting)
         {
-        TN_DEBUG2( "CThumbnailStore::FlushCacheTable() error checking MTP sync: %d", ret);
+        //MTP or MPX harvesting active, allow longer flush -> bigger batch size
+        TN_DEBUG1("CThumbnailStore::FlushCacheTable() MTP sync, longer flush..");
+        aMaxFlushDelay = KMaxMTPFlushDelay;
         }
     
-    if(MPXHarvesting && iBatchItemCount < KMaxBatchItemsMTP && !aForce)
+    //1st item in batch    
+    if( iBatchItemCount == 1)
         {
-        TN_DEBUG1("CThumbnailStore::FlushCacheTable() MTP sync, fixed batch...");
+        //adjust batch size dynamically between min and max based on previous flush speed
+        if(iPreviousFlushDelay > 0 )
+            {
+            iBatchFlushItemCount = (aMaxFlushDelay/iPreviousFlushDelay)*iBatchFlushItemCount;
+            
+            if(iBatchFlushItemCount < KMInBatchItems)
+                {
+                iBatchFlushItemCount = KMInBatchItems;
+                }
+            else if(iBatchFlushItemCount > KMaxBatchItems)
+                {
+                iBatchFlushItemCount = KMaxBatchItems;
+                }
+            }
+        else
+            {
+            //cannot calculate, init values set to min
+            iBatchFlushItemCount = KMInBatchItems;
+            }
+        }
     
-        //some items in cache
-        StartAutoFlush();
-        return;
-        }    
-    else if(!MPXHarvesting && iBatchItemCount < iBatchFlushItemCount && !aForce)
+    TN_DEBUG3("CThumbnailStore::FlushCacheTable() iBatchFlushItemCount = %d, iBatchItemCount = %d", iBatchFlushItemCount, iBatchItemCount);
+    
+    if( iBatchItemCount < iBatchFlushItemCount && !aForce)
        {
        //some items in cache
        StartAutoFlush();
@@ -2014,29 +2046,14 @@
         }
    
     iStopFlush.UniversalTime();
-    TInt aFlushDelay = (TInt)iStopFlush.MicroSecondsFrom(iStartFlush).Int64()/1000;
-    
-    TN_DEBUG2( "CThumbnailStore::FlushCacheTable() took %d ms", aFlushDelay);
+    iPreviousFlushDelay = (TInt)iStopFlush.MicroSecondsFrom(iStartFlush).Int64()/1000;
     
-    //adjust batch size dynamically between min and max based on read flush speed
-    if (!MPXHarvesting)
-        {
-        //increase batch count if there room for one more item (based on average time per item)
-        if( aFlushDelay < KMaxFlushDelay && iBatchFlushItemCount < KMaxBatchItems )
-            {
-            iBatchFlushItemCount++;
-            }
-        //decrease batch count if we exeeced max time allowed in flushing the TEMP table
-        else if(aFlushDelay > KMaxFlushDelay && iBatchFlushItemCount > KMInBatchItems )
-            {
-            iBatchFlushItemCount--;
-            }
-        }
-    
+    TN_DEBUG2( "CThumbnailStore::FlushCacheTable() took %d ms", iPreviousFlushDelay);
+        
     //cache flushed
     iBatchItemCount = 0;
 
-    TN_DEBUG2("CThumbnailStore::FlushCacheTable() out iBatchFlushItemCount = %d", iBatchFlushItemCount);
+    TN_DEBUG1("CThumbnailStore::FlushCacheTable() out");
     }
 
 // -----------------------------------------------------------------------------