232 #endif |
232 #endif |
233 } |
233 } |
234 else if ( iStatus.Int() == KThumbnailErrThumbnailNotFound && iParams.iFileName.Length() && |
234 else if ( iStatus.Int() == KThumbnailErrThumbnailNotFound && iParams.iFileName.Length() && |
235 !( iParams.iFlags& CThumbnailManager::EDoNotCreate )) |
235 !( iParams.iFlags& CThumbnailManager::EDoNotCreate )) |
236 { |
236 { |
237 TN_DEBUG1( "CThumbnaiRequestActive::RunL() - no thumbnail found - lets try with file handle" ); |
237 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - no thumbnail found - lets try with file handle %S", &iParams.iFileName ); |
238 iRequestCompleted = EFalse; |
238 iRequestCompleted = EFalse; |
239 |
239 |
240 // We tried to get thumbnail using file path, but it was not found in |
240 // 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 |
241 // the database. We need to open the file now (on the client side) and |
242 // use file handle. |
242 // use file handle. |
243 User::LeaveIfError( iFile.Open( iFs, iParams.iFileName, EFileShareReadersOrWriters )); |
243 |
|
244 TInt err = iFile.Open( iFs, iParams.iFileName, EFileShareReadersOrWriters ); |
|
245 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - file handle open err = %d", err ); |
|
246 User::LeaveIfError( err ); |
|
247 |
244 CleanupClosePushL( iFile ); |
248 CleanupClosePushL( iFile ); |
245 |
249 |
246 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - file handle opened for %S", &iParams.iFileName ); |
250 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - file handle opened for %S", &iParams.iFileName ); |
247 |
251 |
248 iSession.RequestThumbnailL( iFile, iParams.iFileName, iParamsPckg, iStatus ); |
252 iSession.RequestThumbnailL( iFile, iParams.iFileName, iParamsPckg, iStatus ); |
252 TCallBack(TimerCallBack, this)); |
256 TCallBack(TimerCallBack, this)); |
253 SetActive(); |
257 SetActive(); |
254 } |
258 } |
255 else if ( iStatus.Int()) |
259 else if ( iStatus.Int()) |
256 { |
260 { |
257 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - error (%d) occured", iStatus.Int() ); |
261 TN_DEBUG2( "CThumbnailRequestActive::RunL() - error (%d) occured", iStatus.Int() ); |
258 // An error occurred |
262 // An error occurred |
259 iError = iStatus.Int(); |
263 iError = iStatus.Int(); |
260 HandleError(); |
264 HandleError(); |
261 } |
265 } |
262 else if (iParams.iControlFlags == EThumbnailGeneratePersistentSizesOnly) |
266 //1st round thumb ready from exif (stored) |
|
267 else if (iParams.iOriginalControlFlags == EThumbnailGeneratePersistentSizesOnly && !iProcessingPreview) |
263 { |
268 { |
264 TN_DEBUG1( "CThumbnaiRequestActive::RunL()- generate persistent sizes" ); |
269 TN_DEBUG1( "CThumbnaiRequestActive::RunL()- generate persistent sizes thumbnailready" ); |
265 iBitmapHandle = iParams.iBitmapHandle; |
270 iBitmapHandle = iParams.iBitmapHandle; |
266 |
271 |
267 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId ); |
272 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId ); |
268 iObserver.ThumbnailReady( iStatus.Int(), *iCallbackThumbnail, iParams.iRequestId ); |
273 iObserver.ThumbnailReady( iStatus.Int(), *iCallbackThumbnail, iParams.iRequestId ); |
269 |
274 |
270 ReleaseServerBitmap(); |
275 ReleaseServerBitmap(); |
271 iRequestQueue->RequestComplete(this); |
276 iRequestQueue->RequestComplete(this); |
272 |
277 |
273 #ifdef _DEBUG |
278 #ifdef _DEBUG |
274 TTime stop; |
279 TTime stop; |
275 stop.UniversalTime(); |
280 stop.UniversalTime(); |
276 TN_DEBUG3( "CThumbnailRequestActive::RunL() total execution time %d, %d ms", |
281 TN_DEBUG3( "CThumbnailRequestActive::RunL() total execution time %d, %d ms", |
277 iParams.iRequestId, (TInt)stop.MicroSecondsFrom(iStartExecTime).Int64()/1000 ); |
282 iParams.iRequestId, (TInt)stop.MicroSecondsFrom(iStartExecTime).Int64()/1000 ); |
278 #endif |
283 #endif |
279 } |
284 } |
|
285 //1st round preview ready from too low quality exif/exif not found (not-stored) |
|
286 //relauch using normal decoding |
|
287 else if (iParams.iOriginalControlFlags == EThumbnailGeneratePersistentSizesOnly && iProcessingPreview) |
|
288 { |
|
289 TN_DEBUG1( "CThumbnaiRequestActive::RunL()- generate persistent sizes thumbnailpreviewready" ); |
|
290 iBitmapHandle = iParams.iBitmapHandle; |
|
291 |
|
292 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailPreviewReady %d", iParams.iRequestId ); |
|
293 iObserver.ThumbnailPreviewReady( *iCallbackThumbnail, iParams.iRequestId ); |
|
294 |
|
295 iProcessingPreview = EFalse; |
|
296 |
|
297 ReleaseServerBitmap(); |
|
298 |
|
299 //set flags so that EThumbnailGeneratePersistentSizesOnly is done aka check all missing sizes |
|
300 iParams.iQualityPreference = CThumbnailManager::EOptimizeForQuality; |
|
301 iParams.iControlFlags = EThumbnailGeneratePersistentSizesOnly; |
|
302 iRequestType = EReqUpdateThumbnails; |
|
303 |
|
304 //increase priority |
|
305 this->SetPriority(this->Priority() + 1); |
|
306 iParams.iPriority++; |
|
307 |
|
308 iSession.UpdateThumbnails( iPath, iOrientation, iModified, iParamsPckg, iStatus ); |
|
309 |
|
310 SetActive(); |
|
311 |
|
312 #ifdef _DEBUG |
|
313 TTime stop; |
|
314 stop.UniversalTime(); |
|
315 TN_DEBUG3( "CThumbnailRequestActive::RunL() total execution time %d, %d ms", |
|
316 iParams.iRequestId, (TInt)stop.MicroSecondsFrom(iStartExecTime).Int64()/1000 ); |
|
317 #endif |
|
318 } |
280 else |
319 else |
281 { |
320 { |
282 TN_DEBUG1( "CThumbnaiRequestActive::RunL() - succesful" ); |
321 TN_DEBUG1( "CThumbnailRequestActive::RunL() - succesful" ); |
283 |
322 |
284 // Success |
323 // Success |
285 iBitmapHandle = iParams.iBitmapHandle; |
324 iBitmapHandle = iParams.iBitmapHandle; |
286 CFbsBitmap* bitmap = new( ELeave )CFbsBitmap(); |
325 |
287 CleanupStack::PushL( bitmap ); |
326 if( iBitmapHandle ) |
288 User::LeaveIfError( bitmap->Duplicate( iBitmapHandle )); |
327 { |
289 CleanupStack::Pop( bitmap ); |
328 CFbsBitmap* bitmap = new( ELeave )CFbsBitmap(); |
290 |
329 CleanupStack::PushL( bitmap ); |
291 // reduce bpp value (displaymode to match reqested bits per pixel) |
330 User::LeaveIfError( bitmap->Duplicate( iBitmapHandle )); |
292 #ifdef _DEBUG |
331 CleanupStack::Pop( bitmap ); |
293 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - displaymode is %d", bitmap->DisplayMode()); |
332 |
294 #endif |
333 // reduce bpp value (displaymode to match reqested bits per pixel) |
295 |
334 #ifdef _DEBUG |
296 if( bitmap->DisplayMode() > iParams.iDisplayMode ) |
335 TN_DEBUG2( "CThumbnailRequestActive::RunL() - displaymode is %d", bitmap->DisplayMode()); |
297 { |
336 #endif |
298 bitmap->SetDisplayMode( iParams.iDisplayMode ); |
337 |
299 #ifdef _DEBUG |
338 if( bitmap->DisplayMode() > iParams.iDisplayMode ) |
300 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - displaymode is now %d", bitmap->DisplayMode()); |
339 { |
301 #endif |
340 bitmap->SetDisplayMode( iParams.iDisplayMode ); |
|
341 #ifdef _DEBUG |
|
342 TN_DEBUG2( "CThumbnailRequestActive::RunL() - displaymode is now %d", bitmap->DisplayMode()); |
|
343 #endif |
|
344 } |
|
345 |
|
346 iCallbackThumbnail->Set( bitmap, iClientData ); |
|
347 bitmap = NULL; // Owned by iCallbackThumbnail or client now |
302 } |
348 } |
303 |
|
304 iCallbackThumbnail->Set( bitmap, iClientData ); |
|
305 bitmap = NULL; // Owned by iCallbackThumbnail or client now |
|
306 |
349 |
307 if ( iProcessingPreview ) |
350 if ( iProcessingPreview ) |
308 { |
351 { |
309 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailPreviewReady %d", iParams.iRequestId ); |
352 TN_DEBUG2( "CThumbnailRequestActive::RunL() - iObserver.ThumbnailPreviewReady %d", iParams.iRequestId ); |
|
353 //increase priority of 2nd round (both, AO and request itself) |
|
354 this->SetPriority(this->Priority() + 1); |
|
355 iParams.iPriority++; |
310 iObserver.ThumbnailPreviewReady( *iCallbackThumbnail, iParams.iRequestId ); |
356 iObserver.ThumbnailPreviewReady( *iCallbackThumbnail, iParams.iRequestId ); |
311 iProcessingPreview = EFalse; |
357 iProcessingPreview = EFalse; |
312 ReleaseServerBitmap(); |
358 ReleaseServerBitmap(); |
313 Get2ndPhaseThumbnailL(); |
359 Get2ndPhaseThumbnailL(); |
314 } |
360 } |
315 else |
361 else |
316 { |
362 { |
317 TN_DEBUG2( "CThumbnaiRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId ); |
363 TN_DEBUG2( "CThumbnailRequestActive::RunL() - iObserver.ThumbnailReady %d", iParams.iRequestId ); |
318 |
364 |
319 iObserver.ThumbnailReady( iStatus.Int(), * iCallbackThumbnail, iParams.iRequestId ); |
365 iObserver.ThumbnailReady( iStatus.Int(), * iCallbackThumbnail, iParams.iRequestId ); |
320 ReleaseServerBitmap(); |
366 ReleaseServerBitmap(); |
321 |
367 |
322 iRequestQueue->RequestComplete(this); |
368 iRequestQueue->RequestComplete(this); |