imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp
changeset 30 b67379558a75
parent 25 cb86b71cae0a
child 31 d429f823a6b7
child 36 c5df59b4ae2d
--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp	Wed Jun 23 18:33:48 2010 +0300
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailgeneratetask.cpp	Tue Jul 06 14:37:18 2010 +0300
@@ -43,12 +43,13 @@
     const TSize& aSize, TDisplayMode aDisplayMode, TInt aPriority,
     RArray < TThumbnailPersistentSize >* aMissingSizes, const TDesC& aTargetUri,
     TThumbnailSize aThumbnailSize, const TInt64 aModified, 
-    const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ): 
+    const CThumbnailManager::TThumbnailQualityPreference aQualityPreference,
+    TBool aVirtualUri ): 
     CThumbnailTask( aProcessor, aPriority ), iServer( aServer ), 
     iFlags( aFlags ), iSize( aSize ), iDisplayMode( aDisplayMode ),
     iMissingSizes( aMissingSizes ), iTargetUri( aTargetUri ),
     iThumbnailSize( aThumbnailSize ), iModified(aModified),
-    iQualityPreference( aQualityPreference )
+    iQualityPreference( aQualityPreference ), iVirtualUri( aVirtualUri )
     {
     TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::CThumbnailGenerateTask()", this);
     
@@ -125,11 +126,11 @@
     aStart.UniversalTime();
 #endif
    
-    TParsePtrC parse(iFilename);
-    TPtrC ext(parse.Ext());
-    TBuf8< KMaxDataTypeLength > mimeType;                
-    if  (ext.CompareF(KNonEmbeddedArtExt)== 0) 
-        {       
+    TBuf8< KMaxDataTypeLength > mimeType;
+
+    if ( (!iVirtualUri && iFilename.Right(KExtLength).CompareF(KNonEmbeddedArtExt) == 0) ||
+         (iVirtualUri && iTargetUri.Right(KExtLength).CompareF(KContactExt) == 0) ) // tparse panics with virtual URI
+        {         
         mimeType.Copy( KImageMime );  		
         }
     else
@@ -138,8 +139,7 @@
         }
     iProvider = iServer.ResolveProviderL(mimeType);
        	
-    TN_DEBUG3( "CThumbnailGenerateTask(0x%08x) -- provider UID 0x%08x", this,
-        iProvider->Uid());
+    TN_DEBUG3( "CThumbnailGenerateTask(0x%08x) -- provider UID 0x%08x", this, iProvider->Uid());
 
     __ASSERT_DEBUG(( iProvider ), ThumbnailPanic( EThumbnailNullPointer ));
 
@@ -197,6 +197,7 @@
 void CThumbnailGenerateTask::DoCancel()
     {
     TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::DoCancel()", this );
+    
     if ( iProvider )
         {
         iProvider->CancelGetThumbnail();
@@ -328,6 +329,25 @@
     // compTask is the scale task which returns the bitmap to the client
     CThumbnailScaleTask* complTask = NULL;
 	
+    TInt err1 = KErrNone;
+    TInt err2 = KErrNone;
+    TBool isPublic = ETrue;
+    TBool isPublic2 = ETrue;
+    
+    if(iFilename != KNullDesC)
+        {
+        TRAP(err1, iServer.StoreForPathL(iFilename));
+        
+        isPublic = iServer.IsPublicPath( iFilename );
+        }           
+    if(iTargetUri != KNullDesC )
+        {
+        TRAP(err2, iServer.StoreForPathL(iTargetUri));
+        
+        isPublic2 = iServer.IsPublicPath( iTargetUri );
+        }
+    
+    // check if need to create more than one scale task
     if ( iMissingSizes )
         {
         const TInt count = iMissingSizes->Count();
@@ -359,41 +379,23 @@
             CThumbnailScaleTask* complTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename,
                 aBitmap, iOriginalSize, (*iMissingSizes)[ i ].iSize, (*iMissingSizes)[ i ].iCrop, iDisplayMode,
                 KMaxPriority, iTargetUri, (*iMissingSizes)[ i ].iType, iModified, iScaledBitmapToPool, iEXIF,
-                iRequestId);
+                iRequestId, iVirtualUri);
             CleanupStack::PushL( complTask );
             
-            TInt err1 = KErrNone;
-            TInt err2 = KErrNone;
-            
-            if(iFilename != KNullDesC)
-                {
-                TRAP(err1, iServer.StoreForPathL(iFilename));
-                }
-            
-            if(iTargetUri != KNullDesC )
-                {
-                TRAP(err2, iServer.StoreForPathL(iTargetUri));
-                }
             // if trying to access Z drive, don't try to store
             // don't want to store custom sizes
-            if( err1 == KErrAccessDenied || err2 == KErrAccessDenied ||
-                    (*iMissingSizes)[ i ].iType == ECustomThumbnailSize || 
-                    (*iMissingSizes)[ i ].iType == EUnknownThumbnailSize )
+            // don't store if from private directory
+            if( !isPublic || !isPublic2 ||
+                err1 == KErrAccessDenied || err2 == KErrAccessDenied ||
+                (*iMissingSizes)[ i ].iType == ECustomThumbnailSize || 
+                (*iMissingSizes)[ i ].iType == EUnknownThumbnailSize )
                 {
                 complTask->SetDoStore( EFalse );
                 TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::CreateScaleTasksL() - do not store", this );
                 }
             else
                 {
-                if(iFilename != KNullDesC)
-                    {
-                    complTask->SetDoStore(iServer.IsPublicPath( iFilename ));
-                    }
-                
-                if(iTargetUri != KNullDesC)
-                    {
-                    complTask->SetDoStore(iServer.IsPublicPath( iTargetUri ));
-                    }
+                complTask->SetDoStore( ETrue );
                 }
             
             iProcessor.AddTaskL( complTask );
@@ -426,22 +428,14 @@
         complTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename,
             aBitmap, iOriginalSize, iSize, iFlags& CThumbnailManager
             ::ECropToAspectRatio, iDisplayMode, KMaxPriority, iTargetUri,
-            iThumbnailSize, iModified, iScaledBitmapToPool, iEXIF, iRequestId );
+            iThumbnailSize, iModified, iScaledBitmapToPool, iEXIF, iRequestId,
+            iVirtualUri);
         CleanupStack::PushL( complTask );
         
-        TInt err1 = KErrNone;
-        TInt err2 = KErrNone;
-        if(iFilename != KNullDesC)
-            {
-            TRAP(err1, iServer.StoreForPathL(iFilename));
-            }
-        if(iTargetUri != KNullDesC)
-            {
-            TRAP(err2, iServer.StoreForPathL(iTargetUri));
-            }
         // if trying to access Z drive, don't try to store
         // don't want to store custom sizes
-        if( err1 == KErrAccessDenied || err2 == KErrAccessDenied ||
+        if( !isPublic || !isPublic2 ||
+            err1 == KErrAccessDenied || err2 == KErrAccessDenied ||
             iThumbnailSize == ECustomThumbnailSize || 
             iThumbnailSize == EUnknownThumbnailSize )
             {
@@ -450,15 +444,7 @@
             }
         else
             {
-            if(iFilename != KNullDesC)
-                {
-                complTask->SetDoStore(iServer.IsPublicPath( iFilename ));
-                }
-             
-             if(iTargetUri != KNullDesC)
-                {
-                complTask->SetDoStore(iServer.IsPublicPath( iTargetUri ));
-                }
+            complTask->SetDoStore( ETrue );
             }
         
         iProcessor.AddTaskL( complTask );
@@ -506,14 +492,14 @@
     if(iFilename != KNullDesC)
         {
         iServer.StoreForPathL( iFilename )->StoreThumbnailL( 
-            iFilename, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iModified, EFalse, ETrue );
+            iFilename, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iModified, !iVirtualUri, 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 );
+            iTargetUri, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iModified, !iVirtualUri, ETrue );
 		//remove result from fetched checker
         iServer.FetchedChecker().SetFetchResult( iTargetUri, KErrNone );
         }