imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserversession.cpp
branchRCL_3
changeset 28 ff2fb7658ff7
parent 21 ad31f4183ddc
child 37 f759b6186ab5
equal deleted inserted replaced
24:f0aa341a25bf 28:ff2fb7658ff7
   442     
   442     
   443     aMessage.ReadL( 0, iRequestParams );
   443     aMessage.ReadL( 0, iRequestParams );
   444     const TThumbnailRequestParams& params = iRequestParams();
   444     const TThumbnailRequestParams& params = iRequestParams();
   445 
   445 
   446     RFile64 file;
   446     RFile64 file;
       
   447     CleanupClosePushL(file);
   447     User::LeaveIfError( file.AdoptFromClient( aMessage, 2, 3 ));
   448     User::LeaveIfError( file.AdoptFromClient( aMessage, 2, 3 ));
   448     
   449     
   449     ResolveMimeTypeL(&file);
   450     ResolveMimeTypeL(&file);
   450     
   451     
   451     if(params.iThumbnailSize == EFullScreenThumbnailSize ||
   452     if(params.iThumbnailSize == EFullScreenThumbnailSize ||
   459     
   460     
   460     // CreateThumbnails
   461     // CreateThumbnails
   461     if (params.iControlFlags == EThumbnailGeneratePersistentSizesOnly)
   462     if (params.iControlFlags == EThumbnailGeneratePersistentSizesOnly)
   462         {
   463         {
   463         TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - EThumbnailGeneratePersistentSizesOnly" );
   464         TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - EThumbnailGeneratePersistentSizesOnly" );
   464         CleanupClosePushL( file );
       
   465         CreateGenerateTaskFromFileHandleL( &file );
   465         CreateGenerateTaskFromFileHandleL( &file );
   466         CleanupStack::Pop( &file );         
   466         
       
   467         // ownership of the file transferred
       
   468         CleanupStack::Pop(&file);
   467         }
   469         }
   468     // single thumbnail request
   470     // single thumbnail request
   469     else
   471     else
   470         {
   472         {
   471         TRAPD( err, FetchThumbnailL());
   473         TRAPD( err, FetchThumbnailL());
   475             // If thumbnail of requested size is blacklisted, fetching is left with KErrCompletion
   477             // If thumbnail of requested size is blacklisted, fetching is left with KErrCompletion
   476             TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - thumbnail blacklisted" );
   478             TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - thumbnail blacklisted" );
   477             
   479             
   478             aMessage.Complete( err );
   480             aMessage.Complete( err );
   479             iMessage = RMessage2();
   481             iMessage = RMessage2();
       
   482             
       
   483             // close file
       
   484             CleanupStack::PopAndDestroy(&file);
   480             }
   485             }
   481         else if ( !err && iBitmap )
   486         else if ( !err && iBitmap )
   482             {
   487             {
   483             TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - found existing thumbnail - bitmap " );
   488             TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - found existing thumbnail - bitmap " );
   484 
   489 
   485             // Thumbnail already stored
   490             // Thumbnail already stored
   486             file.Close();
   491             CleanupStack::PopAndDestroy(&file);
   487             TN_DEBUG1("CThumbnailServerSession::RequestThumbByFileHandleAsyncL - file handle closed");
   492             TN_DEBUG1("CThumbnailServerSession::RequestThumbByFileHandleAsyncL - file handle closed");
   488 
   493 
   489             ProcessBitmapL();
   494             ProcessBitmapL();
   490             }
   495             }
   491         else if ( (err == KErrNotFound || err == KErrAccessDenied) && 
   496         else if ( (err == KErrNotFound || err == KErrAccessDenied) && 
   492                  !(params.iFlags& CThumbnailManager::EDoNotCreate) )
   497                  !(params.iFlags& CThumbnailManager::EDoNotCreate) )
   493             {
   498             {
   494             TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - KErrNotFound & !EDoNotCreate" );
   499             TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - KErrNotFound & !EDoNotCreate" );
   495             CreateGenerateTaskFromFileHandleL( &file);
   500             CreateGenerateTaskFromFileHandleL( &file);
       
   501             
       
   502             // ownership of the file transferred
       
   503         	CleanupStack::Pop(&file);
   496             }
   504             }
   497         else if (!err && iBuffer)
   505         else if (!err && iBuffer)
   498             {
   506             {
   499             TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - found existing thumbnail - jpeg " );
   507             TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - found existing thumbnail - jpeg " );
   500             
   508             
   509             // Decode task is now responsible for completing the message
   517             // Decode task is now responsible for completing the message
   510             iMessage = RMessage2();
   518             iMessage = RMessage2();
   511             
   519             
   512             //CThumbnailDecodeTask is responsible freeing
   520             //CThumbnailDecodeTask is responsible freeing
   513             iBuffer = NULL;
   521             iBuffer = NULL;
   514             file.Close();
   522             
       
   523             // close file
       
   524             CleanupStack::PopAndDestroy(&file);
   515             TN_DEBUG1("CThumbnailServerSession::RequestThumbByFileHandleAsyncL - file handle closed");
   525             TN_DEBUG1("CThumbnailServerSession::RequestThumbByFileHandleAsyncL - file handle closed");
   516             }
   526             }
   517         else
   527         else
   518             {
   528             {
   519             TN_DEBUG2( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - thumbnail not found, err=%d", err );
   529             TN_DEBUG2( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - thumbnail not found, err=%d", err );
   520             
   530             
   521             aMessage.Complete( ConvertSqlErrToE32Err( err ));
   531             aMessage.Complete( ConvertSqlErrToE32Err( err ));
   522             iMessage = RMessage2();
   532             iMessage = RMessage2();
       
   533             
       
   534             // close file
       
   535             CleanupStack::PopAndDestroy(&file);
   523             }     
   536             }     
   524         }
   537         }
   525     }
   538     }
   526 
   539 
   527 // -----------------------------------------------------------------------------
   540 // -----------------------------------------------------------------------------
  1096 // -----------------------------------------------------------------------------
  1109 // -----------------------------------------------------------------------------
  1097 //
  1110 //
  1098 void CThumbnailServerSession::ProcessBitmapL()
  1111 void CThumbnailServerSession::ProcessBitmapL()
  1099     {   
  1112     {   
  1100     TThumbnailRequestParams& params = iRequestParams();
  1113     TThumbnailRequestParams& params = iRequestParams();
  1101     
       
  1102     // in import case store bitmap
       
  1103     if ( params.iTargetUri != KNullDesC && params.iFileName != KNullDesC &&
       
  1104          params.iFileName.CompareF(params.iTargetUri) != 0 )
       
  1105         {
       
  1106         Server()->StoreThumbnailL( params.iTargetUri, iBitmap, iOriginalSize,
       
  1107                                    params.iFlags& CThumbnailManager::ECropToAspectRatio,
       
  1108                                    params.iThumbnailSize, params.iModified,
       
  1109                                    EFalse, EFalse);
       
  1110         }
       
  1111     
  1114     
  1112     if ( ClientThreadAlive() )
  1115     if ( ClientThreadAlive() )
  1113         {        
  1116         {        
  1114         TN_DEBUG2("CThumbnailServerSession::ProcessBitmapL(), iBitmap handle= 0x%08x", iBitmap->Handle());
  1117         TN_DEBUG2("CThumbnailServerSession::ProcessBitmapL(), iBitmap handle= 0x%08x", iBitmap->Handle());
  1115         
  1118