243 aMessage.ReadL( 0, iRequestParams ); |
243 aMessage.ReadL( 0, iRequestParams ); |
244 const TThumbnailRequestParams& params = iRequestParams(); |
244 const TThumbnailRequestParams& params = iRequestParams(); |
245 |
245 |
246 TBool finished = Server()->UpdateThumbnailsL( params.iThumbnailId, params.iFileName, params.iOrientation, params.iModified ); |
246 TBool finished = Server()->UpdateThumbnailsL( params.iThumbnailId, params.iFileName, params.iOrientation, params.iModified ); |
247 |
247 |
|
248 RArray < TThumbnailPersistentSize >* missingSizes = NULL; |
|
249 |
248 if (finished) |
250 if (finished) |
249 { |
251 { |
250 TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - finished" ); |
252 // source type |
251 |
253 TDataType mimeType; |
252 aMessage.Complete( KErrNone ); |
254 TInt sourceType = 0; |
253 } |
255 TInt err = Server()->MimeTypeFromFileExt( params.iFileName, mimeType ); |
254 else |
256 TBool missingIDs(EFalse); |
255 { |
257 |
256 TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - need to recreate thumbs" ); |
258 // get missing sizes |
|
259 if ( err == KErrNone && ( params.iControlFlags & EThumbnailGeneratePersistentSizesOnly ) != 0 ) |
|
260 { |
|
261 sourceType = Server()->SourceTypeFromMimeType( mimeType ); |
|
262 |
|
263 missingSizes = new (ELeave) RArray < TThumbnailPersistentSize >; |
|
264 CleanupClosePushL( *missingSizes ); |
|
265 |
|
266 Server()->GetMissingSizesAndIDsL( params.iFileName, sourceType, *missingSizes, missingIDs); |
|
267 |
|
268 if ( missingSizes->Count() == 0) |
|
269 { |
|
270 // all thumbs already exist |
|
271 CleanupStack::PopAndDestroy( missingSizes ); |
|
272 delete missingSizes; |
|
273 missingSizes = NULL; |
|
274 } |
|
275 } |
|
276 |
|
277 if(!missingSizes) |
|
278 { |
|
279 TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - finished" ); |
|
280 aMessage.Complete( KErrNone ); |
|
281 } |
|
282 else |
|
283 { |
|
284 TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - some sizes missing..." ); |
|
285 } |
|
286 } |
|
287 |
|
288 if(missingSizes || !finished) |
|
289 { |
|
290 TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - need to create (some) thumbs" ); |
|
291 |
|
292 if(missingSizes) |
|
293 { |
|
294 CleanupStack::PopAndDestroy( missingSizes ); |
|
295 delete missingSizes; |
|
296 missingSizes = NULL; |
|
297 } |
257 |
298 |
258 if(Server()->StoreForPathL(params.iFileName)->IsDiskFull()) |
299 if(Server()->StoreForPathL(params.iFileName)->IsDiskFull()) |
259 { |
300 { |
260 User::Leave( KErrDiskFull ); |
301 User::Leave( KErrDiskFull ); |
261 } |
302 } |
262 |
303 |
263 // need to create new thumbs |
304 // need to create new thumbs |
264 aMessage.Complete( KThumbnailErrThumbnailNotFound ); |
305 aMessage.Complete( KThumbnailErrThumbnailNotFound ); |
|
306 } |
|
307 else |
|
308 { |
|
309 TN_DEBUG1( "CThumbnailServerSession::UpdateThumbnailsL() - finished" ); |
265 } |
310 } |
266 |
311 |
267 iMessage = RMessage2(); |
312 iMessage = RMessage2(); |
268 } |
313 } |
269 |
314 |
399 // single thumbnail request |
444 // single thumbnail request |
400 else |
445 else |
401 { |
446 { |
402 TRAPD( err, FetchThumbnailL()); |
447 TRAPD( err, FetchThumbnailL()); |
403 |
448 |
404 if ( !err && iBitmap ) |
449 if( err == KErrCompletion ) |
|
450 { |
|
451 // If thumbnail of requested size is blacklisted, fetching is left with KErrCompletion |
|
452 TN_DEBUG1( |
|
453 "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - thumbnail blacklisted" ); |
|
454 aMessage.Complete( err ); |
|
455 iMessage = RMessage2(); |
|
456 } |
|
457 else if ( !err && iBitmap ) |
405 { |
458 { |
406 TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - found existing thumbnail - bitmap " ); |
459 TN_DEBUG1( "CThumbnailServerSession::RequestThumbByFileHandleAsyncL() - found existing thumbnail - bitmap " ); |
407 |
460 |
408 // Thumbnail already stored |
461 // Thumbnail already stored |
409 file.Close(); |
462 file.Close(); |
625 |
678 |
626 // get bitmap |
679 // get bitmap |
627 CFbsBitmap* bitmap = new( ELeave )CFbsBitmap(); |
680 CFbsBitmap* bitmap = new( ELeave )CFbsBitmap(); |
628 CleanupStack::PushL( bitmap ); |
681 CleanupStack::PushL( bitmap ); |
629 User::LeaveIfError( bitmap->Duplicate( bitmapHandle ) ); |
682 User::LeaveIfError( bitmap->Duplicate( bitmapHandle ) ); |
630 Server()->AddBitmapToPoolL( reqId.iSession, bitmap ); |
683 Server()->AddBitmapToPoolL( reqId.iSession, bitmap, reqId ); |
631 CleanupStack::Pop( bitmap ); |
684 CleanupStack::Pop( bitmap ); |
632 iBitmapHandle = bitmap->Handle(); |
685 iBitmapHandle = bitmap->Handle(); |
633 |
686 |
634 RArray < TThumbnailPersistentSize >* missingSizes = NULL; |
687 RArray < TThumbnailPersistentSize >* missingSizes = NULL; |
635 |
688 |
1004 void CThumbnailServerSession::ProcessBitmapL() |
1057 void CThumbnailServerSession::ProcessBitmapL() |
1005 { |
1058 { |
1006 TThumbnailRequestParams& params = iRequestParams(); |
1059 TThumbnailRequestParams& params = iRequestParams(); |
1007 |
1060 |
1008 // in import case store bitmap |
1061 // in import case store bitmap |
1009 if (params.iTargetUri != KNullDesC) |
1062 if ( params.iTargetUri != KNullDesC && params.iFileName != KNullDesC && |
|
1063 params.iFileName.CompareF(params.iTargetUri) != 0 ) |
1010 { |
1064 { |
1011 Server()->StoreThumbnailL( params.iTargetUri, iBitmap, iOriginalSize, |
1065 Server()->StoreThumbnailL( params.iTargetUri, iBitmap, iOriginalSize, |
1012 params.iFlags& CThumbnailManager::ECropToAspectRatio, params.iThumbnailSize, params.iThumbnailId ); |
1066 params.iFlags& CThumbnailManager::ECropToAspectRatio, |
1013 } |
1067 params.iThumbnailSize, params.iThumbnailId, |
1014 |
1068 EFalse, EFalse); |
1015 // No need to scale, return iBitmap directly |
1069 } |
1016 Server()->AddBitmapToPoolL( this, iBitmap ); |
1070 |
1017 CFbsBitmap* bitmap = iBitmap; |
1071 if ( ClientThreadAlive(iMessage) ) |
1018 iBitmap = NULL; // owned by server now |
1072 { |
1019 |
1073 // No need to scale, return iBitmap directly |
1020 params.iBitmapHandle = bitmap->Handle(); |
1074 |
1021 const TSize bitmapSize = bitmap->SizeInPixels(); |
1075 TThumbnailServerRequestId &reqId = (TThumbnailServerRequestId&)params.iRequestId; |
1022 |
1076 // No need to scale, return iBitmap directly |
1023 if ( params.iQualityPreference == CThumbnailManager |
1077 Server()->AddBitmapToPoolL( this, iBitmap, reqId ); |
1024 ::EOptimizeForQualityWithPreview && bitmapSize.iWidth < |
1078 |
1025 params.iSize.iWidth && bitmapSize.iHeight < params.iSize.iHeight && |
1079 CFbsBitmap* bitmap = iBitmap; |
1026 bitmapSize.iWidth < iOriginalSize.iWidth && bitmapSize.iHeight < |
1080 |
1027 iOriginalSize.iHeight ) |
1081 TN_DEBUG2("CThumbnailServerSession::ProcessBitmapL(), iBitmap handle= 0x%08x", bitmap->Handle()); |
1028 { |
1082 |
1029 // This is a non-scaled preview bitmap |
1083 iBitmap = NULL; // owned by server now |
1030 params.iControlFlags = EThumbnailPreviewThumbnail; |
1084 |
1031 } |
1085 params.iBitmapHandle = bitmap->Handle(); |
1032 |
1086 const TSize bitmapSize = bitmap->SizeInPixels(); |
1033 if ( iMessage.Handle() ) |
1087 |
1034 { |
1088 if ( params.iQualityPreference == CThumbnailManager |
|
1089 ::EOptimizeForQualityWithPreview && bitmapSize.iWidth < |
|
1090 params.iSize.iWidth && bitmapSize.iHeight < params.iSize.iHeight && |
|
1091 bitmapSize.iWidth < iOriginalSize.iWidth && bitmapSize.iHeight < |
|
1092 iOriginalSize.iHeight ) |
|
1093 { |
|
1094 // This is a non-scaled preview bitmap |
|
1095 params.iControlFlags = EThumbnailPreviewThumbnail; |
|
1096 } |
|
1097 |
1035 iMessage.WriteL( 0, iRequestParams ); |
1098 iMessage.WriteL( 0, iRequestParams ); |
|
1099 |
1036 iMessage.Complete( KErrNone ); |
1100 iMessage.Complete( KErrNone ); |
1037 iMessage = RMessage2(); |
1101 iMessage = RMessage2(); |
1038 } |
1102 } |
|
1103 else |
|
1104 { |
|
1105 delete iBitmap; |
|
1106 iBitmap = NULL; |
|
1107 } |
1039 } |
1108 } |
1040 |
1109 |
1041 // ----------------------------------------------------------------------------- |
1110 // ----------------------------------------------------------------------------- |
1042 // CThumbnailServerSession::ReleaseBitmap() |
1111 // CThumbnailServerSession::ReleaseBitmap() |
1043 // Release bitmap from bitmap pool |
1112 // Release bitmap from bitmap pool |
1344 } |
1413 } |
1345 } |
1414 } |
1346 return e32Err; |
1415 return e32Err; |
1347 } |
1416 } |
1348 |
1417 |
|
1418 // --------------------------------------------------------------------------- |
|
1419 // CThumbnailServerSession::ClientThreadAlive() |
|
1420 // Checks if client thread is still alive and RMessage2 handle valid. |
|
1421 // --------------------------------------------------------------------------- |
|
1422 // |
|
1423 TBool CThumbnailServerSession::ClientThreadAlive(RMessage2& aMessage) |
|
1424 { |
|
1425 if ( aMessage.Handle()) |
|
1426 { |
|
1427 RThread clientThread; |
|
1428 |
|
1429 // get client thread |
|
1430 TInt err = aMessage.Client( clientThread ); |
|
1431 if (err != KErrNone) |
|
1432 { |
|
1433 TN_DEBUG1( "CThumbnailServerSession::ClientThreadAlive() - client thread not found"); |
|
1434 |
|
1435 aMessage = RMessage2(); |
|
1436 |
|
1437 return EFalse; |
|
1438 } |
|
1439 |
|
1440 // check if client thread alive |
|
1441 TExitType exitType = clientThread.ExitType(); |
|
1442 if( exitType != EExitPending ) |
|
1443 { |
|
1444 TN_DEBUG1( "CThumbnailServerSession::ClientThreadAlive() - client thread died"); |
|
1445 |
|
1446 aMessage = RMessage2(); |
|
1447 |
|
1448 return EFalse; |
|
1449 } |
|
1450 else |
|
1451 { |
|
1452 // all OK |
|
1453 return ETrue; |
|
1454 } |
|
1455 } |
|
1456 else |
|
1457 { |
|
1458 return EFalse; |
|
1459 } |
|
1460 } |
|
1461 |
1349 // End of file |
1462 // End of file |