imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestactive.cpp
changeset 17 ffa62e555b02
parent 15 7197e789b953
child 19 b790c5b3d11f
equal deleted inserted replaced
15:7197e789b953 17:ffa62e555b02
   161             break;
   161             break;
   162             }       
   162             }       
   163         case EReqGetThumbnailHandleLater:
   163         case EReqGetThumbnailHandleLater:
   164             {
   164             {
   165             // open file handle
   165             // open file handle
       
   166             iFile.Close();
   166             User::LeaveIfError( iFile.Open( iFs, iTargetUri, EFileShareReadersOrWriters ) );  
   167             User::LeaveIfError( iFile.Open( iFs, iTargetUri, EFileShareReadersOrWriters ) );  
   167             
   168             
   168             TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iTargetUri );
   169             TN_DEBUG2( "CThumbnailRequestActive::StartL() - file handle opened for %S", &iTargetUri );
   169             
   170             
   170             CleanupClosePushL( iFile );
   171             CleanupClosePushL( iFile );
   183             else
   184             else
   184                 {
   185                 {
   185                 iSession.DeleteThumbnails( iParams.iThumbnailId, iParamsPckg, iStatus );
   186                 iSession.DeleteThumbnails( iParams.iThumbnailId, iParamsPckg, iStatus );
   186                 }
   187                 }
   187             break;
   188             break;
   188             } 
   189             }
       
   190         case EReqRenameThumbnails:
       
   191             {
       
   192             iSession.RenameThumbnails( iParamsPckg, iStatus );
       
   193             break;
       
   194             }  
   189         default:
   195         default:
   190             {
   196             {
   191             break;
   197             break;
   192             }
   198             }
   193         }
   199         }
   217         iRequestCompleted = ETrue;
   223         iRequestCompleted = ETrue;
   218         }
   224         }
   219     
   225     
   220     iTimer->Cancel();
   226     iTimer->Cancel();
   221     
   227     
   222     if (iRequestType == EReqDeleteThumbnails || iCanceled)
   228     if (iRequestType == EReqDeleteThumbnails || iCanceled ||
   223         {
   229         iRequestType == EReqRenameThumbnails)
   224         // no action for delete or canceled request
   230         {
       
   231         TN_DEBUG1( "CThumbnailRequestActive::RunL() - rename/delete/canceled" );
       
   232     
       
   233         iFile.Close();
       
   234         iMyFileHandle.Close();
       
   235     
       
   236         // no action for delete/rename or canceled request
   225         iRequestQueue->RequestComplete(this);
   237         iRequestQueue->RequestComplete(this);
   226         
   238         
   227 #ifdef _DEBUG
   239 #ifdef _DEBUG
   228     TTime stop;
   240     TTime stop;
   229     stop.UniversalTime();
   241     stop.UniversalTime();
   237         TN_DEBUG2( "CThumbnaiRequestActive::RunL() - no thumbnail found - lets try with file handle %S", &iParams.iFileName );
   249         TN_DEBUG2( "CThumbnaiRequestActive::RunL() - no thumbnail found - lets try with file handle %S", &iParams.iFileName );
   238         iRequestCompleted = EFalse;
   250         iRequestCompleted = EFalse;
   239         
   251         
   240         // We tried to get thumbnail using file path, but it was not found in
   252         // We tried to get thumbnail using file path, but it was not found in
   241         // the database. We need to open the file now (on the client side) and
   253         // the database. We need to open the file now (on the client side) and
   242         // use file handle.
   254         // use file handle.     
   243         
   255         iFile.Close();
   244         TInt err = iFile.Open( iFs, iParams.iFileName, EFileShareReadersOrWriters );
   256         TInt err = iFile.Open( iFs, iParams.iFileName, EFileShareReadersOrWriters );
   245         TN_DEBUG2( "CThumbnaiRequestActive::RunL() - file handle open err = %d", err );
   257         TN_DEBUG2( "CThumbnaiRequestActive::RunL() - file handle open err = %d", err );
   246         User::LeaveIfError( err );
   258         User::LeaveIfError( err );
   247         
   259         
   248         CleanupClosePushL( iFile );
   260         CleanupClosePushL( iFile );
   271 	    
   283 	    
   272 	    TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId );
   284 	    TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId );
   273 	    iObserver.ThumbnailReady( iStatus.Int(), *iCallbackThumbnail, iParams.iRequestId );
   285 	    iObserver.ThumbnailReady( iStatus.Int(), *iCallbackThumbnail, iParams.iRequestId );
   274 	  
   286 	  
   275 	    ReleaseServerBitmap();
   287 	    ReleaseServerBitmap();
       
   288 	    
       
   289 	    iFile.Close();
       
   290 	    iMyFileHandle.Close();
       
   291 	    
   276 	    iRequestQueue->RequestComplete(this);
   292 	    iRequestQueue->RequestComplete(this);
   277 	    
   293 	    
   278         #ifdef _DEBUG
   294         #ifdef _DEBUG
   279             TTime stop;
   295             TTime stop;
   280             stop.UniversalTime();
   296             stop.UniversalTime();
   294         
   310         
   295         iProcessingPreview = EFalse;
   311         iProcessingPreview = EFalse;
   296       
   312       
   297         ReleaseServerBitmap();
   313         ReleaseServerBitmap();
   298         
   314         
       
   315         iFile.Close();
       
   316         
   299         //set flags so that EThumbnailGeneratePersistentSizesOnly is done aka check all missing sizes 
   317         //set flags so that EThumbnailGeneratePersistentSizesOnly is done aka check all missing sizes 
   300         iParams.iQualityPreference = CThumbnailManager::EOptimizeForQuality;
   318         iParams.iQualityPreference = CThumbnailManager::EOptimizeForQuality;
   301         iParams.iControlFlags = EThumbnailGeneratePersistentSizesOnly;
   319         iParams.iControlFlags = EThumbnailGeneratePersistentSizesOnly;
   302         iRequestType = EReqUpdateThumbnails;
   320         iRequestType = EReqUpdateThumbnails;
   303         
   321         
   348             }
   366             }
   349 
   367 
   350         if ( iProcessingPreview )
   368         if ( iProcessingPreview )
   351             {
   369             {
   352             TN_DEBUG2( "CThumbnailRequestActive::RunL() - iObserver.ThumbnailPreviewReady %d", iParams.iRequestId );
   370             TN_DEBUG2( "CThumbnailRequestActive::RunL() - iObserver.ThumbnailPreviewReady %d", iParams.iRequestId );
   353 			//increase priority of 2nd round (both, AO and request itself)
   371 			
       
   372             //increase priority of 2nd round (both, AO and request itself)
   354             this->SetPriority(this->Priority() + 1);
   373             this->SetPriority(this->Priority() + 1);
   355             iParams.iPriority++;
   374             iParams.iPriority++;
   356             iObserver.ThumbnailPreviewReady( *iCallbackThumbnail, iParams.iRequestId );
   375             iObserver.ThumbnailPreviewReady( *iCallbackThumbnail, iParams.iRequestId );
   357             iProcessingPreview = EFalse;
   376             iProcessingPreview = EFalse;
       
   377             
   358             ReleaseServerBitmap();
   378             ReleaseServerBitmap();
       
   379             
       
   380             iFile.Close();
       
   381             
   359             Get2ndPhaseThumbnailL();
   382             Get2ndPhaseThumbnailL();
   360             }
   383             }
   361         else
   384         else
   362             {
   385             {
   363             TN_DEBUG2( "CThumbnailRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId );
   386             TN_DEBUG2( "CThumbnailRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId );
   364             
   387             
   365             iObserver.ThumbnailReady( iStatus.Int(), * iCallbackThumbnail, iParams.iRequestId );
   388             iObserver.ThumbnailReady( iStatus.Int(), * iCallbackThumbnail, iParams.iRequestId );
   366             ReleaseServerBitmap();    
   389             ReleaseServerBitmap();    
       
   390             
       
   391             iFile.Close();
       
   392             iMyFileHandle.Close();
   367             
   393             
   368             iRequestQueue->RequestComplete(this);
   394             iRequestQueue->RequestComplete(this);
   369             
   395             
   370 #ifdef _DEBUG
   396 #ifdef _DEBUG
   371         TTime stop;
   397         TTime stop;
   477         
   503         
   478         iError = KErrNone;
   504         iError = KErrNone;
   479         }
   505         }
   480     
   506     
   481     ReleaseServerBitmap();
   507     ReleaseServerBitmap();
       
   508     
       
   509     iFile.Close();
       
   510     iMyFileHandle.Close();
   482     
   511     
   483     iRequestCompleted = ETrue;
   512     iRequestCompleted = ETrue;
   484     iRequestQueue->RequestComplete(this);
   513     iRequestQueue->RequestComplete(this);
   485     iRequestActive = EFalse;
   514     iRequestActive = EFalse;
   486     }
   515     }
   724     
   753     
   725     iPath = aPath;
   754     iPath = aPath;
   726     }
   755     }
   727 
   756 
   728 // ---------------------------------------------------------------------------
   757 // ---------------------------------------------------------------------------
       
   758 // CThumbnailRequestActive::RenameThumbnails()
       
   759 // Rename thumbnails.
       
   760 // ---------------------------------------------------------------------------
       
   761 //
       
   762 void CThumbnailRequestActive::RenameThumbnails( const TDesC& aCurrentPath, 
       
   763         const TDesC& aNewPath, const TInt aPriority )
       
   764     {
       
   765     iRequestType = EReqRenameThumbnails;
       
   766     
       
   767     iParams.iRequestId = iRequestId;
       
   768     iParams.iPriority = aPriority;
       
   769     iParams.iFileName = aCurrentPath;
       
   770     iParams.iTargetUri = aNewPath;
       
   771     }
       
   772 
       
   773 // ---------------------------------------------------------------------------
   729 // Request 2nd phase thumbnail
   774 // Request 2nd phase thumbnail
   730 // ---------------------------------------------------------------------------
   775 // ---------------------------------------------------------------------------
   731 //
   776 //
   732 void CThumbnailRequestActive::Get2ndPhaseThumbnailL()
   777 void CThumbnailRequestActive::Get2ndPhaseThumbnailL()
   733     {
   778     {
   796     {
   841     {
   797     TN_DEBUG1( "CThumbnailRequestActive::TimerCallBack() - request timeout");
   842     TN_DEBUG1( "CThumbnailRequestActive::TimerCallBack() - request timeout");
   798     
   843     
   799     CThumbnailRequestActive* self = static_cast<CThumbnailRequestActive*>( aAny );
   844     CThumbnailRequestActive* self = static_cast<CThumbnailRequestActive*>( aAny );
   800     
   845     
       
   846     self->iTimer->Cancel();
       
   847     
       
   848     if (self->IsActive())
       
   849         {
       
   850         // hangs without this
       
   851         TRequestStatus* statusPtr = &self->iStatus;
       
   852         User::RequestComplete( statusPtr, KErrTimedOut );
       
   853         }
       
   854     
   801     self->Cancel();
   855     self->Cancel();
   802     self->iTimer->Cancel();
       
   803     
   856     
   804     if (self->iStartError != KErrNone)
   857     if (self->iStartError != KErrNone)
   805         {
   858         {
   806         self->iError = self->iStartError;
   859         self->iError = self->iStartError;
   807         }
   860         }
   810         self->iError = KErrTimedOut;
   863         self->iError = KErrTimedOut;
   811         }
   864         }
   812     
   865     
   813     self->HandleError();
   866     self->HandleError();
   814     
   867     
       
   868     TN_DEBUG1( "CThumbnailRequestActive::TimerCallBack() - end");
       
   869     
   815     return KErrNone;
   870     return KErrNone;
   816     }
   871     }
   817 
   872 
   818 // End of file
   873 // End of file