1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Task for generating new thumbnails |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <fbs.h> |
|
21 |
|
22 #include <thumbnailmanager.h> |
|
23 #include "thumbnailgeneratetask.h" |
|
24 #include "thumbnailscaletask.h" |
|
25 #include "thumbnailprovider.h" |
|
26 #include "thumbnailserver.h" |
|
27 #include "thumbnailtaskprocessor.h" |
|
28 #include "thumbnailmanagerconstants.h" |
|
29 #include "thumbnaillog.h" |
|
30 #include "thumbnailpanic.h" |
|
31 #include "thumbnailfetchedchecker.h" |
|
32 #include "OstTraceDefinitions.h" |
|
33 #ifdef OST_TRACE_COMPILER_IN_USE |
|
34 #include "thumbnailgeneratetaskTraces.h" |
|
35 #endif |
|
36 |
|
37 |
|
38 // ======== MEMBER FUNCTIONS ======== |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CThumbnailGenerateTask::CThumbnailGenerateTask() |
|
42 // C++ default constructor can NOT contain any code, that might leave. |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CThumbnailGenerateTask::CThumbnailGenerateTask( CThumbnailTaskProcessor& |
|
46 aProcessor, CThumbnailServer& aServer, RFile64* aFile, TDesC8* aBuffer, |
|
47 const TDataType* aMimeType, CThumbnailManager::TThumbnailFlags aFlags, |
|
48 const TSize& aSize, TDisplayMode aDisplayMode, TInt aPriority, |
|
49 RArray < TThumbnailPersistentSize >* aMissingSizes, const TDesC& aTargetUri, |
|
50 TThumbnailSize aThumbnailSize, const TInt64 aModified, |
|
51 const CThumbnailManager::TThumbnailQualityPreference aQualityPreference, |
|
52 TBool aVirtualUri ): |
|
53 CThumbnailTask( aProcessor, aPriority ), iServer( aServer ), |
|
54 iFlags( aFlags ), iSize( aSize ), iDisplayMode( aDisplayMode ), |
|
55 iMissingSizes( aMissingSizes ), iTargetUri( aTargetUri ), |
|
56 iThumbnailSize( aThumbnailSize ), iModified(aModified), |
|
57 iQualityPreference( aQualityPreference ), iVirtualUri( aVirtualUri ) |
|
58 { |
|
59 TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::CThumbnailGenerateTask()", this); |
|
60 OstTrace1( TRACE_NORMAL, CTHUMBNAILGENERATETASK_CTHUMBNAILGENERATETASK, "CThumbnailGenerateTask::CThumbnailGenerateTask;this=%o", this ); |
|
61 |
|
62 if ( !aBuffer && aFile) |
|
63 { |
|
64 iFile = *aFile; |
|
65 iFile.FullName( iFilename ); |
|
66 } |
|
67 else if( aBuffer ) |
|
68 { |
|
69 iBuffer = aBuffer; |
|
70 } |
|
71 if ( aMimeType ) |
|
72 { |
|
73 iMimeType = *aMimeType; |
|
74 } |
|
75 else |
|
76 { |
|
77 iMimeType = TDataType(KNullDesC8); |
|
78 } |
|
79 |
|
80 // scaled bitmaps to pool by default |
|
81 iScaledBitmapToPool = ETrue; |
|
82 iBitmapHandle = 0; |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CThumbnailGenerateTask::~CThumbnailGenerateTask() |
|
88 // Destructor. |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 CThumbnailGenerateTask::~CThumbnailGenerateTask() |
|
92 { |
|
93 TN_DEBUG2("CThumbnailGenerateTask(0x%08x)::~CThumbnailGenerateTask()", this); |
|
94 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILGENERATETASK_CTHUMBNAILGENERATETASK, "CThumbnailGenerateTask::~CThumbnailGenerateTask;this=%o", this ); |
|
95 |
|
96 if ( iProvider ) |
|
97 { |
|
98 iProvider->CancelGetThumbnail(); |
|
99 } |
|
100 |
|
101 if ( iMissingSizes ) |
|
102 { |
|
103 iMissingSizes->Reset(); |
|
104 delete iMissingSizes; |
|
105 iMissingSizes = NULL; |
|
106 } |
|
107 |
|
108 if ( iBitmapHandle ) |
|
109 { |
|
110 iServer.DeleteBitmapFromPool( iBitmapHandle ); |
|
111 iBitmapHandle = 0; |
|
112 } |
|
113 |
|
114 iProvider = NULL; |
|
115 delete iBuffer; |
|
116 iBuffer = NULL; |
|
117 |
|
118 iFile.Close(); |
|
119 TN_DEBUG1("CThumbnailGenerateTask::~CThumbnailGenerateTask() - file handle closed"); |
|
120 OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILGENERATETASK_CTHUMBNAILGENERATETASK, "CThumbnailGenerateTask::~CThumbnailGenerateTask - file handle closed" ); |
|
121 } |
|
122 |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CThumbnailGenerateTask::StartL() |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CThumbnailGenerateTask::StartL() |
|
129 { |
|
130 TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::StartL()", this ); |
|
131 OstTrace1( TRACE_NORMAL, CTHUMBNAILGENERATETASK_STARTL, "CThumbnailGenerateTask::StartL;this=%o", this ); |
|
132 |
|
133 CThumbnailTask::StartL(); |
|
134 |
|
135 #ifdef _DEBUG |
|
136 aStart.UniversalTime(); |
|
137 #endif |
|
138 |
|
139 TBuf8< KMaxDataTypeLength > mimeType; |
|
140 |
|
141 if ( (!iVirtualUri && iFilename.Right(KExtLength).CompareF(KNonEmbeddedArtExt) == 0) || |
|
142 (iVirtualUri && iTargetUri.Right(KExtLength).CompareF(KContactExt) == 0) ) // tparse panics with virtual URI |
|
143 { |
|
144 mimeType.Copy( KImageMime ); |
|
145 } |
|
146 else |
|
147 { |
|
148 mimeType = iMimeType.Des8(); |
|
149 } |
|
150 iProvider = iServer.ResolveProviderL(mimeType); |
|
151 |
|
152 TN_DEBUG3( "CThumbnailGenerateTask(0x%08x) -- provider UID 0x%08x", this, iProvider->Uid()); |
|
153 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILGENERATETASK_STARTL, "CThumbnailGenerateTask::StartL;this=%o", this ); |
|
154 |
|
155 __ASSERT_DEBUG(( iProvider ), ThumbnailPanic( EThumbnailNullPointer )); |
|
156 |
|
157 iProvider->CancelGetThumbnail(); |
|
158 iProvider->Reset(); |
|
159 iProvider->SetObserver( *this ); |
|
160 |
|
161 TSize effectiveTargetSize; |
|
162 TSize croppedTargetSize; |
|
163 |
|
164 CalculateTargetSizesL( effectiveTargetSize, croppedTargetSize ); |
|
165 |
|
166 iProvider->SetTargetSize( effectiveTargetSize ); |
|
167 |
|
168 if(effectiveTargetSize == TSize()) |
|
169 { |
|
170 iProvider->SetTargetSize( croppedTargetSize ); |
|
171 } |
|
172 |
|
173 TInt providerErr; |
|
174 |
|
175 if ( !iBuffer ) |
|
176 { |
|
177 TRAP(providerErr, iProvider->GetThumbnailL( iServer.Fs(), iFile, iMimeType, iFlags, |
|
178 iDisplayMode, iQualityPreference ) ); |
|
179 } |
|
180 else |
|
181 { |
|
182 TRAP( providerErr, iProvider->GetThumbnailL( iServer.Fs(), iBuffer, iMimeType, iFlags, |
|
183 iDisplayMode, iQualityPreference )); |
|
184 } |
|
185 |
|
186 DoBlacklisting( providerErr, TSize(0,0) ); |
|
187 |
|
188 User::LeaveIfError( providerErr ); |
|
189 |
|
190 TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::StartL() end", this ); |
|
191 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILGENERATETASK_STARTL, "CThumbnailGenerateTask::StartL -end;this=%o", this ); |
|
192 } |
|
193 |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // CThumbnailGenerateTask::RunL() |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 void CThumbnailGenerateTask::RunL() |
|
200 { |
|
201 // No implementation required |
|
202 } |
|
203 |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CThumbnailGenerateTask::DoCancel() |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CThumbnailGenerateTask::DoCancel() |
|
210 { |
|
211 TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::DoCancel()", this ); |
|
212 OstTrace1( TRACE_NORMAL, CTHUMBNAILGENERATETASK_DOCANCEL, "CThumbnailGenerateTask::DoCancel;this=%o", this ); |
|
213 |
|
214 if ( iProvider ) |
|
215 { |
|
216 iProvider->CancelGetThumbnail(); |
|
217 } |
|
218 } |
|
219 |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // Calculate the largest non-cropped size and largest cropped size and |
|
223 // let the provider plug-in know the values |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 void CThumbnailGenerateTask::CalculateTargetSizesL( TSize& aEffectiveTargetSize, |
|
227 TSize& aCroppedTargetSize ) |
|
228 { |
|
229 if ( iThumbnailSize == ECustomThumbnailSize ) |
|
230 { |
|
231 if ( iFlags& CThumbnailManager::ECropToAspectRatio ) |
|
232 { |
|
233 aCroppedTargetSize = iSize; |
|
234 } |
|
235 else |
|
236 { |
|
237 aEffectiveTargetSize = iSize; |
|
238 } |
|
239 } |
|
240 |
|
241 if ( iThumbnailSize != ECustomThumbnailSize ) |
|
242 { |
|
243 RArray < TThumbnailPersistentSize > sizes = iServer.PersistentSizesL(); |
|
244 const TInt count = sizes.Count(); |
|
245 for ( TInt i = 0; i < count; i++ ) |
|
246 { |
|
247 TThumbnailPersistentSize size( sizes[i] ); |
|
248 |
|
249 iSize = size.iSize; |
|
250 if ( size.iCrop ) |
|
251 { |
|
252 aCroppedTargetSize.iWidth = Max( aCroppedTargetSize.iWidth, |
|
253 size.iSize.iWidth ); |
|
254 aCroppedTargetSize.iHeight = Max( aCroppedTargetSize.iHeight, |
|
255 size.iSize.iHeight ); |
|
256 |
|
257 if(iBuffer) |
|
258 { |
|
259 iFlags = ( CThumbnailManager::TThumbnailFlags ) (iFlags | CThumbnailManager::ECropToAspectRatio); |
|
260 aEffectiveTargetSize = aCroppedTargetSize; |
|
261 } |
|
262 } |
|
263 else |
|
264 { |
|
265 aEffectiveTargetSize.iWidth = Max( aEffectiveTargetSize.iWidth, |
|
266 size.iSize.iWidth ); |
|
267 aEffectiveTargetSize.iHeight = Max( aEffectiveTargetSize.iHeight, |
|
268 size.iSize.iHeight ); |
|
269 } |
|
270 |
|
271 if(size.iType == iThumbnailSize) |
|
272 { |
|
273 break; |
|
274 } |
|
275 } |
|
276 } |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // Thumbnail provider observer callback to notify the server when |
|
281 // thumbnail has been generated. |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 void CThumbnailGenerateTask::ThumbnailProviderReady( const TInt aError, |
|
285 CFbsBitmap* aBitmap, const TSize& aOriginalSize, const TBool aEXIF, const TBool aPortrait ) |
|
286 { |
|
287 TN_DEBUG4( |
|
288 "CThumbnailGenerateTask(0x%08x)::ThumbnailProviderReady(aError=%d, aBitmap=0x%08x)", this, aError, aBitmap ); |
|
289 OstTrace1( TRACE_NORMAL, CTHUMBNAILGENERATETASK_THUMBNAILPROVIDERREADY, "CThumbnailGenerateTask::ThumbnailProviderReady;this=%o", this ); |
|
290 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILGENERATETASK_THUMBNAILPROVIDERREADY, "CThumbnailGenerateTask::ThumbnailProviderReady;aError=%d", aError ); |
|
291 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILGENERATETASK_THUMBNAILPROVIDERREADY, "CThumbnailGenerateTask::ThumbnailProviderReady;aBitmap=%o", aBitmap ); |
|
292 |
|
293 #ifdef _DEBUG |
|
294 aStop.UniversalTime(); |
|
295 TN_DEBUG2( "CThumbnailGenerateTask::ThumbnailProviderReady() generate took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000); |
|
296 #endif |
|
297 |
|
298 iPortrait = aPortrait; |
|
299 iEXIF = aEXIF; |
|
300 iOriginalSize = aOriginalSize; |
|
301 |
|
302 if ( aError ) |
|
303 { |
|
304 delete aBitmap; |
|
305 aBitmap = NULL; |
|
306 |
|
307 DoBlacklisting( aError, aOriginalSize ); |
|
308 |
|
309 Complete( aError ); |
|
310 } |
|
311 else |
|
312 { |
|
313 // CreateScaleTasksL will take ownership of bitmap |
|
314 |
|
315 #ifdef _DEBUG |
|
316 TN_DEBUG2( "CThumbnailGenerateTask::ThumbnailProviderReady() - displaymode is %d", aBitmap->DisplayMode()); |
|
317 OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILGENERATETASK_THUMBNAILPROVIDERREADY, "CThumbnailGenerateTask::ThumbnailProviderReady;aBitmap->DisplayMode()=%u", aBitmap->DisplayMode() ); |
|
318 #endif |
|
319 |
|
320 TRAPD( err, CreateScaleTasksL( aBitmap )); |
|
321 aBitmap = NULL; |
|
322 // If CreateScaleTasksL left, we are responsible for completing |
|
323 // the RMessage. If there was no leave, then this call will not |
|
324 // complete actual the message, just the mark the task as completed. |
|
325 Complete( err ); |
|
326 } |
|
327 } |
|
328 |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // Create tasks to scale the thumbnail to each persistent thumbnail size |
|
332 // and also to the size the client requested |
|
333 // --------------------------------------------------------------------------- |
|
334 // |
|
335 void CThumbnailGenerateTask::CreateScaleTasksL( CFbsBitmap* aBitmap ) |
|
336 { |
|
337 __ASSERT_DEBUG(( aBitmap ), ThumbnailPanic( EThumbnailNullPointer )); |
|
338 |
|
339 CleanupStack::PushL( aBitmap ); |
|
340 iServer.AddBitmapToPoolL( iRequestId.iSession, aBitmap, iRequestId ); |
|
341 |
|
342 // Keep handle so we can delete bitmap from pool |
|
343 iBitmapHandle = aBitmap->Handle(); |
|
344 CleanupStack::Pop( aBitmap ); |
|
345 |
|
346 // compTask is the scale task which returns the bitmap to the client |
|
347 CThumbnailScaleTask* complTask = NULL; |
|
348 |
|
349 TInt err1 = KErrNone; |
|
350 TInt err2 = KErrNone; |
|
351 TBool isPublic = ETrue; |
|
352 TBool isPublic2 = ETrue; |
|
353 |
|
354 if(iFilename != KNullDesC) |
|
355 { |
|
356 TRAP(err1, iServer.StoreForPathL(iFilename)); |
|
357 |
|
358 isPublic = iServer.IsPublicPath( iFilename ); |
|
359 } |
|
360 if(iTargetUri != KNullDesC ) |
|
361 { |
|
362 TRAP(err2, iServer.StoreForPathL(iTargetUri)); |
|
363 |
|
364 isPublic2 = iServer.IsPublicPath( iTargetUri ); |
|
365 } |
|
366 |
|
367 // check if need to create more than one scale task |
|
368 if ( iMissingSizes ) |
|
369 { |
|
370 const TInt count = iMissingSizes->Count(); |
|
371 |
|
372 // scale small thumbs first, because fullscreen encoding takes longer |
|
373 for ( TInt i( count-1 ); i >= 0; i-- ) |
|
374 { |
|
375 TThumbnailSize size = (*iMissingSizes)[ i ].iType; |
|
376 #ifdef _DEBUG |
|
377 TN_DEBUG3( "CThumbnailGenerateTask(0x%08x)::CreateScaleTasksL() *iMissingSizes)[ i ].iType == %d", this, size ); |
|
378 OstTrace1( TRACE_NORMAL, CTHUMBNAILGENERATETASK_CREATESCALETASKSL, "CThumbnailGenerateTask::CreateScaleTasksL;this=%o", this ); |
|
379 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILGENERATETASK_CREATESCALETASKSL, "CThumbnailGenerateTask::CreateScaleTasksL;size=%d", size ); |
|
380 #endif |
|
381 |
|
382 if ( iPortrait ) |
|
383 { |
|
384 if ( size == EFullScreenThumbnailSize || |
|
385 size == EVideoFullScreenThumbnailSize || |
|
386 size == EAudioFullScreenThumbnailSize || |
|
387 size == EImageFullScreenThumbnailSize || |
|
388 size == EContactFullScreenThumbnailSize ) |
|
389 { |
|
390 TInt mis_width = (*iMissingSizes)[ i ].iSize.iWidth; |
|
391 TN_DEBUG2( "*iMissingSizes)[ i ].iWidth == %d", (*iMissingSizes)[ i ].iSize.iWidth ); |
|
392 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILGENERATETASK_CREATESCALETASKSL, "CThumbnailGenerateTask::CreateScaleTasksL;width=%d", mis_width ); |
|
393 |
|
394 TInt mis_height = (*iMissingSizes)[ i ].iSize.iHeight; |
|
395 TN_DEBUG2( "*iMissingSizes)[ i ].iHeight == %d", (*iMissingSizes)[ i ].iSize.iHeight ); |
|
396 OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILGENERATETASK_CREATESCALETASKSL, "CThumbnailGenerateTask::CreateScaleTasksL;mis_height=%d", mis_height ); |
|
397 TInt width = (*iMissingSizes)[ i ].iSize.iWidth; |
|
398 (*iMissingSizes)[ i ].iSize.iWidth = (*iMissingSizes)[ i ].iSize.iHeight; |
|
399 (*iMissingSizes)[ i ].iSize.iHeight = width; |
|
400 TN_DEBUG2( "*iMissingSizes)[ i ].iWidth == %d", (*iMissingSizes)[ i ].iSize.iWidth ); |
|
401 OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILGENERATETASK_CREATESCALETASKSL, "CThumbnailGenerateTask::CreateScaleTasksL;width=%d", width ); |
|
402 mis_height = (*iMissingSizes)[ i ].iSize.iHeight; |
|
403 TN_DEBUG2( "*iMissingSizes)[ i ].iHeight == %d", (*iMissingSizes)[ i ].iSize.iHeight ); |
|
404 OstTrace1( TRACE_NORMAL, DUP5_CTHUMBNAILGENERATETASK_CREATESCALETASKSL, "CThumbnailGenerateTask::CreateScaleTasksL;mis_height=%d", mis_height ); |
|
405 } |
|
406 } |
|
407 |
|
408 CThumbnailScaleTask* complTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename, |
|
409 aBitmap, iOriginalSize, (*iMissingSizes)[ i ].iSize, (*iMissingSizes)[ i ].iCrop, iDisplayMode, |
|
410 KMaxPriority, iTargetUri, (*iMissingSizes)[ i ].iType, iModified, iScaledBitmapToPool, iEXIF, |
|
411 iRequestId, iVirtualUri); |
|
412 CleanupStack::PushL( complTask ); |
|
413 |
|
414 // if trying to access Z drive, don't try to store |
|
415 // don't want to store custom sizes |
|
416 // don't store if from private directory |
|
417 if( !isPublic || !isPublic2 || |
|
418 err1 == KErrAccessDenied || err2 == KErrAccessDenied || |
|
419 (*iMissingSizes)[ i ].iType == ECustomThumbnailSize || |
|
420 (*iMissingSizes)[ i ].iType == EUnknownThumbnailSize ) |
|
421 { |
|
422 complTask->SetDoStore( EFalse ); |
|
423 TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::CreateScaleTasksL() - do not store", this ); |
|
424 OstTrace1( TRACE_NORMAL, DUP6_CTHUMBNAILGENERATETASK_CREATESCALETASKSL, "CThumbnailGenerateTask::CreateScaleTasksL - do not store;this=%o", this ); |
|
425 } |
|
426 else |
|
427 { |
|
428 complTask->SetDoStore( ETrue ); |
|
429 } |
|
430 |
|
431 iProcessor.AddTaskL( complTask ); |
|
432 CleanupStack::Pop( complTask ); |
|
433 |
|
434 // completion to first task, because task processor works like stack |
|
435 if( i == 0 ) |
|
436 { |
|
437 // compTask is now responsible for completing the RMessage |
|
438 complTask->SetMessageData( iRequestId, iMessage, iClientThread ); |
|
439 ResetMessageData(); |
|
440 } |
|
441 } |
|
442 } |
|
443 else |
|
444 { |
|
445 if( iPortrait ) |
|
446 { |
|
447 if ( iThumbnailSize == EFullScreenThumbnailSize || |
|
448 iThumbnailSize == EVideoFullScreenThumbnailSize || |
|
449 iThumbnailSize == EAudioFullScreenThumbnailSize || |
|
450 iThumbnailSize == EImageFullScreenThumbnailSize || |
|
451 iThumbnailSize == EContactFullScreenThumbnailSize) |
|
452 { |
|
453 TInt width = iSize.iWidth; |
|
454 iSize.iWidth = iSize.iHeight; |
|
455 iSize.iHeight = width; |
|
456 } |
|
457 } |
|
458 |
|
459 complTask = CThumbnailScaleTask::NewL( iProcessor, iServer, iFilename, |
|
460 aBitmap, iOriginalSize, iSize, iFlags& CThumbnailManager |
|
461 ::ECropToAspectRatio, iDisplayMode, KMaxPriority, iTargetUri, |
|
462 iThumbnailSize, iModified, iScaledBitmapToPool, iEXIF, iRequestId, |
|
463 iVirtualUri); |
|
464 CleanupStack::PushL( complTask ); |
|
465 |
|
466 // if trying to access Z drive, don't try to store |
|
467 // don't want to store custom sizes |
|
468 if( !isPublic || !isPublic2 || |
|
469 err1 == KErrAccessDenied || err2 == KErrAccessDenied || |
|
470 iThumbnailSize == ECustomThumbnailSize || |
|
471 iThumbnailSize == EUnknownThumbnailSize ) |
|
472 { |
|
473 complTask->SetDoStore( EFalse ); |
|
474 TN_DEBUG2( "CThumbnailGenerateTask(0x%08x)::CreateScaleTasksL() - do not store", this ); |
|
475 OstTrace1( TRACE_NORMAL, DUP7_CTHUMBNAILGENERATETASK_CREATESCALETASKSL, "CThumbnailGenerateTask::CreateScaleTasksL - do not store;this=%o", this ); |
|
476 } |
|
477 else |
|
478 { |
|
479 complTask->SetDoStore( ETrue ); |
|
480 } |
|
481 |
|
482 iProcessor.AddTaskL( complTask ); |
|
483 CleanupStack::Pop( complTask ); |
|
484 |
|
485 // compTask is now responsible for completing the RMessage and |
|
486 // returning the bitmap to the client |
|
487 complTask->SetMessageData( iRequestId, iMessage, iClientThread ); |
|
488 ResetMessageData(); |
|
489 } |
|
490 |
|
491 // Scale tasks now reference the bitmap in the pool |
|
492 iServer.DeleteBitmapFromPool( iBitmapHandle ); |
|
493 iBitmapHandle = 0; |
|
494 aBitmap = NULL; |
|
495 } |
|
496 |
|
497 // --------------------------------------------------------------------------- |
|
498 // Defines if scaled bitmaps need to be added to pool |
|
499 // --------------------------------------------------------------------------- |
|
500 // |
|
501 void CThumbnailGenerateTask::ScaledBitmapToPool( TBool aBool ) |
|
502 { |
|
503 iScaledBitmapToPool = aBool; |
|
504 } |
|
505 |
|
506 // --------------------------------------------------------------------------- |
|
507 // Stores a blacklisted thumbnail |
|
508 // --------------------------------------------------------------------------- |
|
509 // |
|
510 void CThumbnailGenerateTask::CreateBlackListedL( const TSize& aOriginalSize ) |
|
511 { |
|
512 TN_DEBUG1( "CThumbnailGenerateTask::CreateBlackListedL()"); |
|
513 OstTrace0( TRACE_NORMAL, CTHUMBNAILGENERATETASK_CREATEBLACKLISTEDL, "CThumbnailGenerateTask::CreateBlackListedL" ); |
|
514 CFbsBitmap* tempBitmap = 0; |
|
515 tempBitmap = new (ELeave) CFbsBitmap(); |
|
516 CleanupStack::PushL( tempBitmap ); |
|
517 TSize tempSize( 1, 1 ); |
|
518 User::LeaveIfError( tempBitmap->Create( tempSize, iDisplayMode ) ); |
|
519 |
|
520 // Instead of creating a blacklisted entry of requested size (iThumbnailSize) in thumbnail db, |
|
521 // consider blacklisting all sizes (hence the changes are needed in thumbnail fetching logic too). |
|
522 // However, decoding of source to thumnail could succeed in other sizes, which makes blacklisting |
|
523 // of requested size only meaningful. |
|
524 |
|
525 if(iFilename != KNullDesC) |
|
526 { |
|
527 iServer.StoreForPathL( iFilename )->StoreThumbnailL( |
|
528 iFilename, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iModified, !iVirtualUri, ETrue ); |
|
529 //remove result from fetched checker |
|
530 iServer.FetchedChecker().SetFetchResult( iFilename, iThumbnailSize, KErrNone ); |
|
531 } |
|
532 else if(iTargetUri != KNullDesC) |
|
533 { |
|
534 iServer.StoreForPathL( iTargetUri )->StoreThumbnailL( |
|
535 iTargetUri, tempBitmap, aOriginalSize, EFalse, iThumbnailSize, iModified, !iVirtualUri, ETrue ); |
|
536 //remove result from fetched checker |
|
537 iServer.FetchedChecker().SetFetchResult( iTargetUri, iThumbnailSize, KErrNone ); |
|
538 } |
|
539 |
|
540 CleanupStack::PopAndDestroy( tempBitmap ); |
|
541 } |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // Checks is blacklisting needed |
|
545 // --------------------------------------------------------------------------- |
|
546 // |
|
547 void CThumbnailGenerateTask::DoBlacklisting( const TInt aError, const TSize& aOriginalSize ) |
|
548 { |
|
549 TN_DEBUG1( "CThumbnailGenerateTask::DoBlacklisting()"); |
|
550 OstTrace0( TRACE_NORMAL, CTHUMBNAILGENERATETASK_DOBLACKLISTING, "CThumbnailGenerateTask::DoBlacklisting" ); |
|
551 // Create a temporary bitmap of size 1 for storing blacklisted thumbnail |
|
552 // Because no actual bitmap data is generated, there is no reason to |
|
553 // add bitmap to server bitmap pool. Completion of client request with |
|
554 // error code just results in applications showing their default bitmap. |
|
555 if( aError != KErrNone && (iFilename != KNullDesC || iTargetUri != KNullDesC )) |
|
556 { |
|
557 if (aError == KErrNotFound || |
|
558 aError == KErrNotSupported || |
|
559 aError == KErrCorrupt || |
|
560 aError == KErrCompletion || |
|
561 aError == KErrUnderflow || |
|
562 aError == KErrNotReady || |
|
563 aError == KErrGeneral ) |
|
564 { |
|
565 |
|
566 if(iMissingSizes) |
|
567 { |
|
568 TN_DEBUG2( "CThumbnailGenerateTask::DoBlacklisting() - blacklist missing sizes count = %d", iMissingSizes->Count() ); |
|
569 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILGENERATETASK_DOBLACKLISTING, "CThumbnailGenerateTask::DoBlacklisting - blacklist missing sizes count;iMissingSizes->Count()=%d", iMissingSizes->Count() ); |
|
570 |
|
571 for ( TInt i( 0 ); i < iMissingSizes->Count(); i++ ) |
|
572 { |
|
573 iThumbnailSize = (*iMissingSizes)[ i ].iType; |
|
574 TRAPD( err, CreateBlackListedL( aOriginalSize ) ); |
|
575 if (err != KErrNone) |
|
576 { |
|
577 TN_DEBUG3( "CThumbnailGenerateTask::DoBlacklisting() - blacklisting missing size %d failed with code %d", iThumbnailSize, err ); |
|
578 OstTraceExt2( TRACE_NORMAL, DUP2_CTHUMBNAILGENERATETASK_DOBLACKLISTING, "CThumbnailGenerateTask::DoBlacklisting - - blacklisting missing size failed with error;iThumbnailSize=%u;err=%d", iThumbnailSize, err ); |
|
579 } |
|
580 } |
|
581 return; |
|
582 } |
|
583 else |
|
584 { |
|
585 TN_DEBUG1( "CThumbnailGenerateTask::DoBlacklisting() - blacklist single size" ); |
|
586 OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILGENERATETASK_DOBLACKLISTING, "CThumbnailGenerateTask::DoBlacklisting - blacklist single size" ); |
|
587 TRAPD( err, CreateBlackListedL( aOriginalSize ) ); |
|
588 if (err != KErrNone) |
|
589 { |
|
590 TN_DEBUG2( "CThumbnailGenerateTask::DoBlacklisting() - blacklisting failed with code %d", err ); |
|
591 OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILGENERATETASK_DOBLACKLISTING, "CThumbnailGenerateTask::DoBlacklisting - blacklisting failed with code;err=%d", err ); |
|
592 } |
|
593 return; |
|
594 } |
|
595 } |
|
596 TN_DEBUG1( "CThumbnailGenerateTask::DoBlacklisting() - not blacklisted " ); |
|
597 OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILGENERATETASK_DOBLACKLISTING, "CThumbnailGenerateTask::DoBlacklisting - not blacklisted" ); |
|
598 } |
|
599 } |
|
600 |
|
601 |
|