Revision: 201017
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 14 May 2010 16:10:12 +0300
changeset 19 b790c5b3d11f
parent 17 ffa62e555b02
child 22 a67f74060682
child 23 64215a1a17ce
Revision: 201017 Kit: 201019
imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h
imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailaudioprovider.cpp
imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp
imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp
imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimageprovider.cpp
imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp
imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v10.10.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
--- a/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/inc/thumbnailmanagerconstants.h	Fri May 14 16:10:12 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;
@@ -109,7 +109,7 @@
 
 //default displaymode (bpp - bits per pixel) for TNs in DB
 //this makes possible to provide all colour depths up to 16M aka 24 -bit full colour
-const TDisplayMode KStoreDisplayMode = EColor16M;
+const TDisplayMode KStoreDisplayMode = EColor16MAP;
 
 //required amount of memory to keep bitmaps on RAM in bits
 const TInt KMemoryNeed = 5000000;
--- a/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailaudioprovider.cpp	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailaudioprovider.cpp	Fri May 14 16:10:12 2010 +0300
@@ -115,6 +115,11 @@
     iFlags = aFlags;
 	//set default mode displaymode from global constants
     iDisplayMode = KStoreDisplayMode;
+	
+//TODO currently only ARM platforms supports MAP mode
+#if !(defined(__CC_ARM) || defined(__ARMCC__))
+    iDisplayMode = EColor16M;
+#endif		
     
     iImageDecoderv3->CreateL( data, *iObserver, iFlags, iMimeType, iTargetSize );
     iOriginalSize = iImageDecoderv3->OriginalSize();
--- a/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/plugins/audio/src/thumbnailimagedecoderv3.cpp	Fri May 14 16:10:12 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimagedecoder.cpp	Fri May 14 16:10:12 2010 +0300
@@ -233,10 +233,6 @@
         }
 
     iDecoder->Convert( &iStatus, * iBitmap );
-    while ( iStatus == KErrUnderflow )
-        {
-        iDecoder->ContinueConvert( &iStatus );
-        }
     
     SetActive();
     
--- a/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimageprovider.cpp	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/plugins/image/src/thumbnailimageprovider.cpp	Fri May 14 16:10:12 2010 +0300
@@ -94,6 +94,16 @@
 	//set default mode displaymode from global constants
     iDisplayMode = KStoreDisplayMode;
     
+    if ( KJpegMime() != iMimeType.Des8() ) 
+        {
+        iDisplayMode = EColor16M;
+        }
+		
+//TODO currently only ARM platforms supports MAP mode
+#if !(defined(__CC_ARM) || defined(__ARMCC__))
+    iDisplayMode = EColor16M;
+#endif	
+	
     iImageDecoder->CreateL( aFile, *iObserver, iQualityPreference, iMimeType, iTargetSize );
     iOriginalSize = iImageDecoder->OriginalSize();
     iImageDecoder->DecodeL( iDisplayMode, iFlags );
@@ -122,7 +132,16 @@
     iQualityPreference = aQualityPreference;
 	//set default mode displaymode from global constants
     iDisplayMode = KStoreDisplayMode;
-    
+    if ( KJpegMime() != iMimeType.Des8() ) 
+        {
+        iDisplayMode = EColor16M;
+        }
+
+//TODO currently only ARM platforms supports MAP mode
+#if !(defined(__CC_ARM) || defined(__ARMCC__))
+    iDisplayMode = EColor16M;
+#endif	
+		
     iImageDecoder->CreateL( aBuffer, *iObserver, iQualityPreference, iMimeType, iTargetSize );
     iOriginalSize = iImageDecoder->OriginalSize();
     iImageDecoder->DecodeL( iDisplayMode, iFlags );
--- a/imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/plugins/video/src/thumbnailvideoprovider.cpp	Fri May 14 16:10:12 2010 +0300
@@ -134,6 +134,11 @@
     iFlags = aFlags;
 	//set default mode displaymode from global constants
     iDisplayMode = KStoreDisplayMode;
+	
+//TODO currently only ARM platforms supports MAP mode
+#if !(defined(__CC_ARM) || defined(__ARMCC__))
+    iDisplayMode = EColor16M;
+#endif	
 
     TFileName filename;
     User::LeaveIfError( aFile.FullName( filename ));
Binary file imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/ThumbnailManager_0x102830AB_v10.10.6_SA_S60.50_Euro1.sis has changed
--- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/package.pkg	Fri May 14 16:10:12 2010 +0300
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"Thumbnail Manager"},(0x102830AB), 10, 10, 5, TYPE=SA, RU
+#{"Thumbnail Manager"},(0x102830AB), 10, 10, 6, TYPE=SA, RU
 
 ; Localised Vendor name
 %{"Nokia"}
--- a/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanager/stub.pkg	Fri May 14 16:10:12 2010 +0300
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"ThumbnailManager"},(0x102830AB), 10, 10, 5, TYPE=SA
+#{"ThumbnailManager"},(0x102830AB), 10, 10, 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/sis/thumbnailmanagercenrep/package.pkg	Fri May 14 16:10:12 2010 +0300
@@ -17,7 +17,7 @@
 &EN
 
 ; Header
-#{"Thumbnail Manager Cenrep"},(0x10202BE9), 10, 10, 5, TYPE=SP
+#{"Thumbnail Manager Cenrep"},(0x10202BE9), 10, 10, 6, TYPE=SP
 
 ; Localised Vendor name
 %{"Symbian Software Ltd."}
--- a/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/inc/thumbagprocessor.h	Fri May 14 16:10:12 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbagdaemon/src/thumbagprocessor.cpp	Fri May 14 16:10:12 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 @@
                     }
                 }
             
+		   // 10.1 specific
            if( imageObjectDef.Id() != aObject->Def().Id()  )
                 {
                 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() 1st round not image");
@@ -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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/inc/thumbnailrequestactive.h	Fri May 14 16:10:12 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp	Fri May 14 16:10:12 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestqueue.cpp	Fri May 14 16:10:12 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailsql.h	Fri May 14 16:10:12 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h	Fri May 14 16:10:12 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp	Fri May 14 16:10:12 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	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp	Fri May 14 16:10:12 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);
         }
     }
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp	Fri May 14 16:10:12 2010 +0300
@@ -736,22 +736,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 )
                 {
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp	Mon May 03 12:48:51 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailstore.cpp	Fri May 14 16:10:12 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");
     }
 
 // -----------------------------------------------------------------------------