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: Implementation class of Thumbnail Manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <akniconconfig.h> |
|
21 #include <fbs.h> |
|
22 #include <badesca.h> |
|
23 #include <centralrepository.h> |
|
24 |
|
25 #include <thumbnailmanager.h> |
|
26 |
|
27 #include "thumbnailmanagerimpl.h" |
|
28 #include "thumbnailrequestactive.h" |
|
29 #include "thumbnailprovider.h" |
|
30 #include "thumbnailsession.h" |
|
31 #include "thumbnailmanageruids.hrh" |
|
32 #include "thumbnailmanagerprivatecrkeys.h" |
|
33 #include "thumbnailpanic.h" |
|
34 |
|
35 #include "thumbnaildata.h" |
|
36 #include "OstTraceDefinitions.h" |
|
37 #ifdef OST_TRACE_COMPILER_IN_USE |
|
38 #include "thumbnailmanagerimplTraces.h" |
|
39 #endif |
|
40 |
|
41 |
|
42 const TInt KThumbnailMimeTypeListGranularity = 8; |
|
43 |
|
44 |
|
45 // ======== MEMBER FUNCTIONS ======== |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CThumbnailManagerImpl::~CThumbnailManagerImpl() |
|
49 // Destructor. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CThumbnailManagerImpl::~CThumbnailManagerImpl() |
|
53 { |
|
54 TN_DEBUG1( "CThumbnailManagerImpl::~CThumbnailManagerImpl() - start" ); |
|
55 OstTrace0( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_CTHUMBNAILMANAGERIMPL, "CThumbnailManagerImpl::~CThumbnailManagerImpl - start" ); |
|
56 |
|
57 delete iRequestQueue; |
|
58 iRequestQueue = NULL; |
|
59 |
|
60 iSession.Close(); |
|
61 iFs.Close(); |
|
62 |
|
63 // Check if we need to disconnect Fbs |
|
64 TInt sessionCount = (TInt)Dll::Tls(); |
|
65 if ( sessionCount > 0) |
|
66 { |
|
67 if( --sessionCount == 0 ) |
|
68 { |
|
69 TN_DEBUG1( "CThumbnailManagerImpl::~CThumbnailManagerImpl() - Disconnect FBS" ); |
|
70 OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILMANAGERIMPL_CTHUMBNAILMANAGERIMPL, "CThumbnailManagerImpl::~CThumbnailManagerImpl - Disconnect FBS" ); |
|
71 iFbsSession.Disconnect(); |
|
72 } |
|
73 TN_DEBUG2( "CThumbnailManagerImpl::~CThumbnailManagerImpl() - update sessionCount == %d to TLS", sessionCount ); |
|
74 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILMANAGERIMPL_CTHUMBNAILMANAGERIMPL, "CThumbnailManagerImpl::~CThumbnailManagerImpl - update sessionCount == %d to TLS", sessionCount ); |
|
75 Dll::SetTls( (TAny*)sessionCount ); |
|
76 } |
|
77 |
|
78 delete iMimeTypeList; |
|
79 iMimeTypeList = NULL; |
|
80 |
|
81 TN_DEBUG1( "CThumbnailManagerImpl::~CThumbnailManagerImpl() - end" ); |
|
82 OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILMANAGERIMPL_CTHUMBNAILMANAGERIMPL, "CThumbnailManagerImpl::~CThumbnailManagerImpl - end" ); |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CThumbnailManagerImpl::NewLC() |
|
88 // Two-phased constructor. |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 CThumbnailManagerImpl* CThumbnailManagerImpl::NewLC( MThumbnailManagerObserver& |
|
92 aObserver ) |
|
93 { |
|
94 CThumbnailManagerImpl* self = new( ELeave )CThumbnailManagerImpl( aObserver ); |
|
95 CleanupStack::PushL( self ); |
|
96 self->ConstructL(); |
|
97 return self; |
|
98 } |
|
99 |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CThumbnailManagerImpl::CThumbnailManagerImpl() |
|
103 // C++ default constructor can NOT contain any code, that might leave. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 CThumbnailManagerImpl::CThumbnailManagerImpl( MThumbnailManagerObserver& |
|
107 aObserver ): iObserver( aObserver ), iRequestObserver( NULL ), iDisplayMode( |
|
108 KThumbnailDefaultDisplayMode ), iFlags( EDefaultFlags ), iQualityPreference |
|
109 ( EOptimizeForQuality ), iRequestId( 0 ) |
|
110 { |
|
111 // No implementation required |
|
112 TN_DEBUG1( "CThumbnailManagerImpl::CThumbnailManagerImpl()" ); |
|
113 OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILMANAGERIMPL_CTHUMBNAILMANAGERIMPL, "CThumbnailManagerImpl::CThumbnailManagerImpl" ); |
|
114 } |
|
115 |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CThumbnailManagerImpl::ConstructL() |
|
119 // Symbian 2nd phase constructor can leave. |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CThumbnailManagerImpl::ConstructL() |
|
123 { |
|
124 TN_DEBUG1( "CThumbnailManagerImpl::ConstructL - start"); |
|
125 OstTrace0( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_CONSTRUCTL, "CThumbnailManagerImpl::ConstructL - start" ); |
|
126 |
|
127 User::LeaveIfError( iSession.Connect()); |
|
128 User::LeaveIfError( iFs.Connect()); |
|
129 User::LeaveIfError( iFs.ShareProtected()); |
|
130 |
|
131 if ( !RFbsSession::GetSession() ) |
|
132 { |
|
133 // We need to connect to Fbs (first user in this thread) |
|
134 // Maintain a reference count in TLS |
|
135 User::LeaveIfError( iFbsSession.Connect()); |
|
136 Dll::SetTls( (TAny*)1 ); |
|
137 TN_DEBUG2( "CThumbnailManagerImpl::ConstructL() - update sessionCount == %d to TLS", 1 ); |
|
138 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILMANAGERIMPL_CONSTRUCTL, "CThumbnailManagerImpl::ConstructL - update sessionCount == %d to TLS", 1 ); |
|
139 } |
|
140 else |
|
141 { |
|
142 TInt sessionCount = (TInt)Dll::Tls(); |
|
143 if( sessionCount++ > 0 ) |
|
144 { |
|
145 // Increase the reference count in TLS |
|
146 Dll::SetTls( (TAny*)sessionCount ); |
|
147 TN_DEBUG2( "CThumbnailManagerImpl::ConstructL() - update sessionCount == %d to TLS", sessionCount ); |
|
148 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILMANAGERIMPL_CONSTRUCTL, "CThumbnailManagerImpl::ConstructL - update sessionCount == %d to TLS", sessionCount ); |
|
149 } |
|
150 else |
|
151 { |
|
152 // Fbs connection was available in the beginning, no need to |
|
153 // increase the reference count |
|
154 TN_DEBUG1( "CThumbnailManagerImpl::ConstructL - no need to update sessionCount"); |
|
155 OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILMANAGERIMPL_CONSTRUCTL, "CThumbnailManagerImpl::ConstructL - no need to update sessionCount" ); |
|
156 } |
|
157 } |
|
158 |
|
159 // request processor |
|
160 iRequestQueue = CThumbnailRequestQueue::NewL(); |
|
161 |
|
162 TN_DEBUG1( "CThumbnailManagerImpl::ConstructL - end"); |
|
163 OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILMANAGERIMPL_CONSTRUCTL, "CThumbnailManagerImpl::ConstructL - end" ); |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CThumbnailManagerImpl::GetThumbnailL |
|
169 // Get a thumbnail for an object file. |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 TThumbnailRequestId CThumbnailManagerImpl::GetThumbnailL( |
|
173 CThumbnailObjectSource& aObjectSource, TAny* aClientData /*= NULL*/, const |
|
174 TInt aPriority, TBool aGeneratePersistentSizesOnly) |
|
175 { |
|
176 iRequestId++; |
|
177 TN_DEBUG4( "CThumbnailManagerImpl::GetThumbnailL() URI==%S, iThumbnailSize==%d, req %d", &aObjectSource.Uri(), iThumbnailSize, iRequestId ); |
|
178 OstTraceExt3( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_GETTHUMBNAILL, "CThumbnailManagerImpl::GetThumbnailL;aObjectSource.Uri()=%S;iThumbnailSize=%d;iRequestId=%d", aObjectSource.Uri(), iThumbnailSize, iRequestId ); |
|
179 |
|
180 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
181 |
|
182 TInt priority = ValidatePriority(aPriority); |
|
183 |
|
184 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
185 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, priority, iRequestQueue ); |
|
186 CleanupStack::PushL( getThumbnailActive ); |
|
187 |
|
188 if(aObjectSource.Id() > 0) |
|
189 { |
|
190 getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), |
|
191 aObjectSource.MimeType(),iFlags, iQualityPreference, iSize, iDisplayMode, |
|
192 priority, aClientData, aGeneratePersistentSizesOnly, KNullDesC, iThumbnailSize); |
|
193 } |
|
194 else if ( aObjectSource.Uri().Length()) |
|
195 { |
|
196 getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), |
|
197 aObjectSource.MimeType(), iFlags, iQualityPreference, iSize, iDisplayMode, |
|
198 priority, aClientData, aGeneratePersistentSizesOnly, KNullDesC, iThumbnailSize ); |
|
199 } |
|
200 else |
|
201 { |
|
202 getThumbnailActive->GetThumbnailL( aObjectSource.FileHandle(), aObjectSource.Id(), |
|
203 aObjectSource.MimeType(), iFlags, iQualityPreference, iSize, iDisplayMode, |
|
204 priority, aClientData, aGeneratePersistentSizesOnly, KNullDesC, iThumbnailSize ); |
|
205 } |
|
206 |
|
207 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
208 CleanupStack::Pop( getThumbnailActive ); |
|
209 |
|
210 iRequestQueue->Process(); |
|
211 |
|
212 TN_DEBUG2( "CThumbnailManagerImpl::GetThumbnailL() - request ID: %d", iRequestId ); |
|
213 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILMANAGERIMPL_GETTHUMBNAILL, "CThumbnailManagerImpl::GetThumbnailL;iRequestId=%u", iRequestId ); |
|
214 |
|
215 return iRequestId; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CThumbnailManagerImpl::GetThumbnailL |
|
220 // Get a thumbnail for an object file. |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 TThumbnailRequestId CThumbnailManagerImpl::GetThumbnailL( |
|
224 CThumbnailObjectSource& aObjectSource, TAny* aClientData /*= NULL*/, const |
|
225 TInt aPriority ) |
|
226 { |
|
227 return GetThumbnailL( aObjectSource, aClientData, aPriority, EFalse ); |
|
228 } |
|
229 |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // CThumbnailManagerImpl::GetThumbnailL |
|
233 // Get a thumbnail for an object file. |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 TThumbnailRequestId CThumbnailManagerImpl::GetThumbnailL( const TThumbnailId |
|
237 aThumbnailId, TAny* aClientData /*= NULL*/, TInt aPriority) |
|
238 { |
|
239 iRequestId++; |
|
240 TN_DEBUG4( "CThumbnailManagerImpl::GetThumbnailL() aThumbnailId==%d, iThumbnailSize==%d, req %d", aThumbnailId, iThumbnailSize, iRequestId ); |
|
241 OstTraceExt3( TRACE_NORMAL, DUP2_CTHUMBNAILMANAGERIMPL_GETTHUMBNAILL, "CThumbnailManagerImpl::GetThumbnailL;aThumbnailId=%u;iThumbnailSize=%u;iRequestId=%u", aThumbnailId, iThumbnailSize, iRequestId ); |
|
242 |
|
243 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
244 |
|
245 TInt priority = ValidatePriority(aPriority); |
|
246 |
|
247 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
248 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, priority, iRequestQueue ); |
|
249 CleanupStack::PushL( getThumbnailActive ); |
|
250 |
|
251 getThumbnailActive->GetThumbnailL( KNullDesC, aThumbnailId, KNullDesC8, |
|
252 iFlags, iQualityPreference, iSize, iDisplayMode, priority, aClientData, |
|
253 EFalse, KNullDesC, iThumbnailSize ); |
|
254 |
|
255 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
256 CleanupStack::Pop( getThumbnailActive ); |
|
257 |
|
258 iRequestQueue->Process(); |
|
259 |
|
260 TN_DEBUG2( "CThumbnailManagerImpl::GetThumbnailL() - request ID: %d", iRequestId ); |
|
261 OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILMANAGERIMPL_GETTHUMBNAILL, "CThumbnailManagerImpl::GetThumbnailL;iRequestId=%u", iRequestId ); |
|
262 |
|
263 return iRequestId; |
|
264 } |
|
265 |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // CThumbnailManagerImpl::ImportThumbnailL |
|
269 // Import an image to be used as thumbnail for an object. |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 TThumbnailRequestId CThumbnailManagerImpl::ImportThumbnailL( |
|
273 CThumbnailObjectSource& aObjectSource, const TDesC& aTargetUri, |
|
274 TAny* aClientData /*= NULL*/, const TInt aPriority) |
|
275 { |
|
276 iRequestId++; |
|
277 |
|
278 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
279 |
|
280 TInt priority = ValidatePriority(aPriority); |
|
281 |
|
282 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
283 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, priority, iRequestQueue ); |
|
284 CleanupStack::PushL( getThumbnailActive ); |
|
285 |
|
286 if ( aObjectSource.Uri().Length()) |
|
287 { |
|
288 getThumbnailActive->GetThumbnailL( aObjectSource.Uri(), aObjectSource.Id(), |
|
289 aObjectSource.MimeType(), iFlags, iQualityPreference, iSize, iDisplayMode, |
|
290 priority, aClientData, EFalse, aTargetUri, iThumbnailSize ); |
|
291 } |
|
292 else |
|
293 { |
|
294 getThumbnailActive->GetThumbnailL( aObjectSource.FileHandle(), aObjectSource.Id(), |
|
295 aObjectSource.MimeType(), iFlags, iQualityPreference, iSize, iDisplayMode, |
|
296 priority, aClientData, EFalse, aTargetUri, iThumbnailSize ); |
|
297 } |
|
298 |
|
299 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
300 CleanupStack::Pop( getThumbnailActive ); |
|
301 |
|
302 iRequestQueue->Process(); |
|
303 |
|
304 TN_DEBUG2( "CThumbnailManagerImpl::ImportThumbnailL() - request ID: %d", iRequestId ); |
|
305 OstTrace1( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_IMPORTTHUMBNAILL, "CThumbnailManagerImpl::ImportThumbnailL;iRequestId=%u", iRequestId ); |
|
306 |
|
307 return iRequestId; |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // CThumbnailManagerImpl::SetThumbnailL |
|
312 // Import an image to be used as thumbnail for an object. |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 TThumbnailRequestId CThumbnailManagerImpl::SetThumbnailL( CThumbnailObjectSource& aObjectSource, |
|
316 TAny* aClientData, TInt aPriority ) |
|
317 { |
|
318 iRequestId++; |
|
319 |
|
320 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
321 |
|
322 TInt priority = ValidatePriority(aPriority); |
|
323 |
|
324 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
325 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, priority, iRequestQueue ); |
|
326 CleanupStack::PushL( getThumbnailActive ); |
|
327 |
|
328 if (aObjectSource.Uri().Length() && |
|
329 aObjectSource.TargetUri().Length()) |
|
330 { |
|
331 // from path |
|
332 getThumbnailActive->SetThumbnailL( aObjectSource.Uri(), |
|
333 aObjectSource.MimeType(), iFlags, iQualityPreference, iSize, iDisplayMode, |
|
334 priority, aClientData, ETrue, aObjectSource.TargetUri(), iThumbnailSize, ETrue); |
|
335 } |
|
336 else if (aObjectSource.Uri().Length() && |
|
337 aObjectSource.Bitmap() != NULL) |
|
338 { |
|
339 // from bitmap |
|
340 getThumbnailActive->SetThumbnailL( aObjectSource.GetBitmapOwnership(), |
|
341 aObjectSource.Id(), KBmpMime, iFlags, iQualityPreference, iSize, iDisplayMode, |
|
342 priority, aClientData, ETrue, aObjectSource.Uri(), iThumbnailSize, ETrue); |
|
343 } |
|
344 else if (aObjectSource.Uri().Length() && |
|
345 aObjectSource.Buffer() != NULL && |
|
346 aObjectSource.MimeType() != KNullDesC8) |
|
347 { |
|
348 // from buffer |
|
349 getThumbnailActive->SetThumbnailL( aObjectSource.GetBufferOwnership(), aObjectSource.Id(), |
|
350 aObjectSource.MimeType(), iFlags, iQualityPreference, iSize, iDisplayMode, |
|
351 priority, aClientData, ETrue, aObjectSource.Uri(), iThumbnailSize, ETrue); |
|
352 } |
|
353 |
|
354 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
355 CleanupStack::Pop( getThumbnailActive ); |
|
356 |
|
357 iRequestQueue->Process(); |
|
358 |
|
359 TN_DEBUG2( "CThumbnailManagerImpl::SetThumbnailL() - request ID: %d", iRequestId ); |
|
360 OstTrace1( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_SETTHUMBNAILL, "CThumbnailManagerImpl::SetThumbnailL;iRequestId=%u", iRequestId ); |
|
361 |
|
362 return iRequestId; |
|
363 } |
|
364 |
|
365 // --------------------------------------------------------------------------- |
|
366 // CThumbnailManagerImpl::CreateThumbnails |
|
367 // Create persistent size thumbnails for an object. |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 TThumbnailRequestId CThumbnailManagerImpl::CreateThumbnails( |
|
371 CThumbnailObjectSource& aObjectSource, TInt aPriority ) |
|
372 { |
|
373 TRAPD(err, |
|
374 TN_DEBUG2( "CThumbnailManagerImpl::CreateThumbnails() aObjectSource==%S ", &aObjectSource.Uri() ); |
|
375 OstTraceExt1( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_CREATETHUMBNAILS, "CThumbnailManagerImpl::CreateThumbnails;aObjectSource.Uri()=%S", aObjectSource.Uri() ); |
|
376 iRequestId++; |
|
377 |
|
378 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
379 |
|
380 TInt priority = ValidatePriority(aPriority); |
|
381 |
|
382 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
383 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, priority, iRequestQueue ); |
|
384 |
|
385 CleanupStack::PushL( getThumbnailActive ); |
|
386 |
|
387 if (aObjectSource.Bitmap()) |
|
388 { |
|
389 // from bitmap |
|
390 getThumbnailActive->SetThumbnailL( aObjectSource.GetBitmapOwnership(), |
|
391 aObjectSource.Id(), KBmpMime, iFlags, iQualityPreference, |
|
392 iSize, iDisplayMode, priority, NULL, ETrue, |
|
393 aObjectSource.Uri(), EUnknownThumbnailSize, EFalse); |
|
394 } |
|
395 else if( !aObjectSource.Buffer() ) |
|
396 { |
|
397 getThumbnailActive->GetThumbnailL( aObjectSource.Id(), |
|
398 aObjectSource.Uri(), aObjectSource.MimeType(), iFlags, |
|
399 iQualityPreference, iSize, iDisplayMode, priority, NULL, |
|
400 ETrue, aObjectSource.Uri(), EUnknownThumbnailSize); |
|
401 } |
|
402 else |
|
403 { |
|
404 // from buffer |
|
405 getThumbnailActive->SetThumbnailL( aObjectSource.GetBufferOwnership(), |
|
406 aObjectSource.Id(), aObjectSource.MimeType(), iFlags, |
|
407 iQualityPreference, iSize, iDisplayMode, priority, NULL, |
|
408 ETrue, aObjectSource.Uri(), EUnknownThumbnailSize, EFalse); |
|
409 } |
|
410 |
|
411 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
412 |
|
413 CleanupStack::Pop( getThumbnailActive ); |
|
414 |
|
415 iRequestQueue->Process(); |
|
416 |
|
417 TN_DEBUG2( "CThumbnailManagerImpl::CreateThumbnails() - request ID: %d", iRequestId ); |
|
418 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILMANAGERIMPL_CREATETHUMBNAILS, "CThumbnailManagerImpl::CreateThumbnails;iRequestId=%u", iRequestId ); |
|
419 ); |
|
420 |
|
421 if( err != KErrNone) |
|
422 { |
|
423 return err; |
|
424 } |
|
425 |
|
426 return iRequestId; |
|
427 } |
|
428 |
|
429 |
|
430 // --------------------------------------------------------------------------- |
|
431 // CThumbnailManagerImpl::DisplayMode() |
|
432 // Get the current display mode for thumbnail bitmaps. |
|
433 // --------------------------------------------------------------------------- |
|
434 // |
|
435 TDisplayMode CThumbnailManagerImpl::DisplayMode()const |
|
436 { |
|
437 return iDisplayMode; |
|
438 } |
|
439 |
|
440 |
|
441 // --------------------------------------------------------------------------- |
|
442 // CThumbnailManagerImpl::SetDisplayModeL() |
|
443 // Set the current display mode for thumbnail bitmaps. |
|
444 // --------------------------------------------------------------------------- |
|
445 // |
|
446 void CThumbnailManagerImpl::SetDisplayModeL( const TDisplayMode aDisplayMode ) |
|
447 { |
|
448 iDisplayMode = aDisplayMode; |
|
449 } |
|
450 |
|
451 |
|
452 // --------------------------------------------------------------------------- |
|
453 // CThumbnailManagerImpl::QualityPreference() |
|
454 // Get the current quality versus performance preference. |
|
455 // --------------------------------------------------------------------------- |
|
456 // |
|
457 CThumbnailManager::TThumbnailQualityPreference CThumbnailManagerImpl |
|
458 ::QualityPreference()const |
|
459 { |
|
460 return iQualityPreference; |
|
461 } |
|
462 |
|
463 |
|
464 // --------------------------------------------------------------------------- |
|
465 // CThumbnailManagerImpl::SetQualityPreferenceL() |
|
466 // Set quality versus performance preference. |
|
467 // --------------------------------------------------------------------------- |
|
468 // |
|
469 void CThumbnailManagerImpl::SetQualityPreferenceL( const |
|
470 TThumbnailQualityPreference aQualityPreference ) |
|
471 { |
|
472 iQualityPreference = aQualityPreference; |
|
473 } |
|
474 |
|
475 |
|
476 // --------------------------------------------------------------------------- |
|
477 // CThumbnailManagerImpl::ThumbnailSize() |
|
478 // Get the current desired size for thumbnail bitmaps. |
|
479 // --------------------------------------------------------------------------- |
|
480 // |
|
481 const TSize& CThumbnailManagerImpl::ThumbnailSize()const |
|
482 { |
|
483 return iSize; |
|
484 } |
|
485 |
|
486 |
|
487 // --------------------------------------------------------------------------- |
|
488 // CThumbnailManagerImpl::SetThumbnailSizeL() |
|
489 // Set desired size for thumbnail bitmaps. |
|
490 // --------------------------------------------------------------------------- |
|
491 // |
|
492 void CThumbnailManagerImpl::SetThumbnailSizeL( const TSize& aThumbnailSize ) |
|
493 { |
|
494 iSize = aThumbnailSize; |
|
495 iThumbnailSize = ECustomThumbnailSize; |
|
496 } |
|
497 |
|
498 // --------------------------------------------------------------------------- |
|
499 // CThumbnailManagerImpl::SetThumbnailSizeL() |
|
500 // Set desired size for thumbnail bitmaps. |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 void CThumbnailManagerImpl::SetThumbnailSizeL( const TThumbnailSize aThumbnailSize ) |
|
504 { |
|
505 iThumbnailSize = aThumbnailSize; |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------------------------- |
|
509 // CThumbnailManagerImpl::Flags() |
|
510 // Get current flags for thumbnail generation. |
|
511 // --------------------------------------------------------------------------- |
|
512 // |
|
513 CThumbnailManager::TThumbnailFlags CThumbnailManagerImpl::Flags()const |
|
514 { |
|
515 return iFlags; |
|
516 } |
|
517 |
|
518 |
|
519 // --------------------------------------------------------------------------- |
|
520 // CThumbnailManagerImpl::SetFlagsL() |
|
521 // Set flags for thumbnail generation. Several flags may be enabled |
|
522 // by combining the values using bitwise or. |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 void CThumbnailManagerImpl::SetFlagsL( const TThumbnailFlags aFlags ) |
|
526 { |
|
527 iFlags = aFlags; |
|
528 } |
|
529 |
|
530 |
|
531 // --------------------------------------------------------------------------- |
|
532 // CThumbnailManagerImpl::DeleteThumbnails() |
|
533 // Delete all thumbnails for a given object. |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 void CThumbnailManagerImpl::DeleteThumbnails( CThumbnailObjectSource& |
|
537 aObjectSource ) |
|
538 { |
|
539 TRAP_IGNORE( |
|
540 iRequestId++; |
|
541 TN_DEBUG2( "CThumbnailManagerImpl::DeleteThumbnails() URI==%S ", &aObjectSource.Uri() ); |
|
542 OstTraceExt1( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_DELETETHUMBNAILS, "CThumbnailManagerImpl::DeleteThumbnails;aObjectSource.Uri()=%S", aObjectSource.Uri() ); |
|
543 |
|
544 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
545 |
|
546 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
547 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, CActive::EPriorityIdle, |
|
548 iRequestQueue ); |
|
549 |
|
550 CleanupStack::PushL( getThumbnailActive ); |
|
551 |
|
552 const TDesC& uri = aObjectSource.Uri(); |
|
553 |
|
554 if ( uri.Length()) |
|
555 { |
|
556 getThumbnailActive->DeleteThumbnails( uri, 0, CActive::EPriorityIdle ); |
|
557 } |
|
558 else |
|
559 { |
|
560 TInt err = aObjectSource.FileHandle().FullName( iFileNameBuf ); |
|
561 if ( !err ) |
|
562 { |
|
563 getThumbnailActive->DeleteThumbnails( iFileNameBuf, 0, CActive::EPriorityIdle ); |
|
564 } |
|
565 } |
|
566 |
|
567 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
568 |
|
569 CleanupStack::Pop( getThumbnailActive ); |
|
570 |
|
571 iRequestQueue->Process(); |
|
572 ); |
|
573 } |
|
574 |
|
575 |
|
576 // --------------------------------------------------------------------------- |
|
577 // CThumbnailManagerImpl::DeleteThumbnailsL() |
|
578 // Delete thumbnails by TThumbnailId. |
|
579 // --------------------------------------------------------------------------- |
|
580 // |
|
581 void CThumbnailManagerImpl::DeleteThumbnails( const TThumbnailId aItemId ) |
|
582 { |
|
583 TRAP_IGNORE( |
|
584 iRequestId++; |
|
585 TN_DEBUG2( "CThumbnailManagerImpl::DeleteThumbnails() aItemId==%d ", aItemId ); |
|
586 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILMANAGERIMPL_DELETETHUMBNAILS, "CThumbnailManagerImpl::DeleteThumbnails;aItemId=%u", aItemId ); |
|
587 |
|
588 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
589 |
|
590 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
591 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, CActive::EPriorityIdle, |
|
592 iRequestQueue ); |
|
593 |
|
594 CleanupStack::PushL( getThumbnailActive ); |
|
595 |
|
596 getThumbnailActive->DeleteThumbnails( KNullDesC, aItemId, CActive::EPriorityIdle ); |
|
597 |
|
598 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
599 |
|
600 CleanupStack::Pop( getThumbnailActive ); |
|
601 |
|
602 iRequestQueue->Process(); |
|
603 ); |
|
604 } |
|
605 |
|
606 |
|
607 // --------------------------------------------------------------------------- |
|
608 // CThumbnailManagerImpl::CancelRequest() |
|
609 // Cancel a thumbnail operation. |
|
610 // --------------------------------------------------------------------------- |
|
611 // |
|
612 TInt CThumbnailManagerImpl::CancelRequest( const TThumbnailRequestId aId ) |
|
613 { |
|
614 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
615 |
|
616 TN_DEBUG2( "CThumbnailManagerImpl::CancelRequest() - request ID: %d", aId ); |
|
617 OstTrace1( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_CANCELREQUEST, "CThumbnailManagerImpl::CancelRequest;aId=%u", aId ); |
|
618 |
|
619 return iRequestQueue->CancelRequest(aId); |
|
620 } |
|
621 |
|
622 |
|
623 // --------------------------------------------------------------------------- |
|
624 // CThumbnailManagerImpl::ChangePriority() |
|
625 // Change the priority of a queued thumbnail operation. |
|
626 // --------------------------------------------------------------------------- |
|
627 // |
|
628 TInt CThumbnailManagerImpl::ChangePriority( const TThumbnailRequestId aId, |
|
629 const TInt aNewPriority ) |
|
630 { |
|
631 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
632 |
|
633 TInt priority = ValidatePriority(aNewPriority); |
|
634 |
|
635 TN_DEBUG2( "CThumbnailManagerImpl::ChangePriority() - request ID: %d", aId ); |
|
636 OstTrace1( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_CHANGEPRIORITY, "CThumbnailManagerImpl::ChangePriority;aId=%u", aId ); |
|
637 |
|
638 return iRequestQueue->ChangePriority(aId, priority); |
|
639 } |
|
640 |
|
641 // --------------------------------------------------------------------------- |
|
642 // Get the list of supported file systems from server |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 const CDesCArray& CThumbnailManagerImpl::GetSupportedMimeTypesL() |
|
646 { |
|
647 if ( !iMimeTypeList ) |
|
648 { |
|
649 iMimeTypeList = new( ELeave )CDesCArraySeg( |
|
650 KThumbnailMimeTypeListGranularity ); |
|
651 HBufC* buf = iSession.GetMimeTypeListL(); |
|
652 CleanupStack::PushL( buf ); |
|
653 TLex lex( *buf ); |
|
654 while ( !lex.Eos()) |
|
655 { |
|
656 iMimeTypeList->AppendL( lex.NextToken()); |
|
657 } |
|
658 CleanupStack::PopAndDestroy( buf ); |
|
659 } |
|
660 return * iMimeTypeList; |
|
661 } |
|
662 |
|
663 |
|
664 // --------------------------------------------------------------------------- |
|
665 // CThumbnailManagerImpl::UpdateThumbnails() |
|
666 // Update thumbnails by given ID |
|
667 // --------------------------------------------------------------------------- |
|
668 // |
|
669 void CThumbnailManagerImpl::UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath, |
|
670 const TInt aOrientation, const TInt64 aModified, |
|
671 TInt aPriority ) |
|
672 { |
|
673 iRequestId++; |
|
674 TN_DEBUG4( "CThumbnailManagerImpl::UpdateThumbnailsL() URI==%S, aItemId==%d, req %d", &aPath, aItemId, iRequestId); |
|
675 OstTraceExt3( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_UPDATETHUMBNAILSL, "CThumbnailManagerImpl::UpdateThumbnailsL;aPath=%S;aItemId=%d;iRequestId=%d", aPath, aItemId, iRequestId ); |
|
676 |
|
677 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
678 |
|
679 TInt priority = ValidatePriority(aPriority); |
|
680 |
|
681 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
682 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, priority, iRequestQueue ); |
|
683 CleanupStack::PushL( getThumbnailActive ); |
|
684 |
|
685 getThumbnailActive->UpdateThumbnailsL( aPath, aItemId, iFlags, iQualityPreference, |
|
686 iDisplayMode, priority, aOrientation, aModified ); |
|
687 |
|
688 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
689 CleanupStack::Pop( getThumbnailActive ); |
|
690 |
|
691 iRequestQueue->Process(); |
|
692 } |
|
693 |
|
694 // --------------------------------------------------------------------------- |
|
695 // CThumbnailManagerImpl::RenameThumbnailsL() |
|
696 // Renames thumbnails by given path |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 TThumbnailRequestId CThumbnailManagerImpl::RenameThumbnailsL( const TDesC& aCurrentPath, |
|
700 const TDesC& aNewPath, TInt aPriority ) |
|
701 { |
|
702 iRequestId++; |
|
703 TN_DEBUG3( "CThumbnailManagerImpl::RenameThumbnailsL() URI==%S, req %d", &aCurrentPath, iRequestId); |
|
704 OstTraceExt1( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_RENAMETHUMBNAILSL, "CThumbnailManagerImpl::RenameThumbnailsL;aCurrentPath=%S", aCurrentPath ); |
|
705 |
|
706 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
707 |
|
708 TInt priority = ValidatePriority(aPriority); |
|
709 |
|
710 CThumbnailRequestActive* getThumbnailActive = CThumbnailRequestActive::NewL |
|
711 ( iFs, iSession, iObserver, iRequestObserver, iRequestId, priority, iRequestQueue ); |
|
712 CleanupStack::PushL( getThumbnailActive ); |
|
713 |
|
714 getThumbnailActive->RenameThumbnails( aCurrentPath, aNewPath, priority ); |
|
715 |
|
716 iRequestQueue->AddRequestL( getThumbnailActive ); |
|
717 CleanupStack::Pop( getThumbnailActive ); |
|
718 |
|
719 iRequestQueue->Process(); |
|
720 |
|
721 return iRequestId; |
|
722 } |
|
723 |
|
724 |
|
725 // --------------------------------------------------------------------------- |
|
726 // CThumbnailManagerImpl::SetRequestObserver() |
|
727 // Adds optional request observer |
|
728 // --------------------------------------------------------------------------- |
|
729 // |
|
730 void CThumbnailManagerImpl::SetRequestObserver( MThumbnailManagerRequestObserver& aObserver ) |
|
731 { |
|
732 iRequestObserver = NULL; |
|
733 iRequestObserver = &aObserver; |
|
734 } |
|
735 |
|
736 // --------------------------------------------------------------------------- |
|
737 // CThumbnailManagerImpl::RemoveRequestObserver() |
|
738 // Removes optional request observer |
|
739 // --------------------------------------------------------------------------- |
|
740 // |
|
741 void CThumbnailManagerImpl::RemoveRequestObserver() |
|
742 { |
|
743 if (iRequestObserver) |
|
744 { |
|
745 iRequestObserver = NULL; |
|
746 } |
|
747 } |
|
748 |
|
749 |
|
750 // --------------------------------------------------------------------------- |
|
751 // CThumbnailManagerImpl::ValidatePriority() |
|
752 // Check that given priority is in range of CActive::TPriority |
|
753 // --------------------------------------------------------------------------- |
|
754 // |
|
755 TInt CThumbnailManagerImpl::ValidatePriority( const TInt aPriority ) |
|
756 { |
|
757 if (aPriority < CActive::EPriorityIdle) |
|
758 { |
|
759 TN_DEBUG2( "CThumbnailManagerImpl::ValidatePriority() - priority %d too low for CActive", aPriority ); |
|
760 OstTrace1( TRACE_NORMAL, CTHUMBNAILMANAGERIMPL_VALIDATEPRIORITY, "CThumbnailManagerImpl::ValidatePriority - priority too low for CActive;aPriority=%d", aPriority ); |
|
761 return CActive::EPriorityIdle; |
|
762 } |
|
763 else if (aPriority > CActive::EPriorityHigh) |
|
764 { |
|
765 TN_DEBUG2( "CThumbnailManagerImpl::ValidatePriority() - priority %d too high for CActive", aPriority ); |
|
766 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILMANAGERIMPL_VALIDATEPRIORITY, "CThumbnailManagerImpl::ValidatePriority - priority too high for CActive;aPriority=%d", aPriority ); |
|
767 return CActive::EPriorityHigh; |
|
768 } |
|
769 else |
|
770 { |
|
771 return aPriority; |
|
772 } |
|
773 } |
|
774 |
|
775 // End of file |
|