|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Fetch context to retrieve thumbnails |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include <mpxmediadrmdefs.h> |
|
23 #include <glxresolutionutility.h> |
|
24 #include <glxdrmutility.h> |
|
25 #include <glxthumbnailattributeinfo.h> |
|
26 #include <mpxmediacollectiondetaildefs.h> // for KMPXMediaColDetailSpaceId |
|
27 #include <glxtracer.h> |
|
28 #include <glxlog.h> |
|
29 |
|
30 #include "glxattributecontext.h" |
|
31 #include "glxthumbnailcontext.h" |
|
32 #include "glxmedialist.h" |
|
33 #include "glxerrormanager.h" |
|
34 #include "glxthumbnailutility.h" |
|
35 #include "mglxcache.h" |
|
36 #include "glxlistutils.h" |
|
37 |
|
38 /** |
|
39 * Scoring for thumbnail provision order |
|
40 * Having no thumbnail is the most important, so it gets the highest bit |
|
41 * Proximity to focus is the final (lowest priority) criteria) |
|
42 */ |
|
43 const TUint KTNScoreNoThumbnail = 0x80000000; |
|
44 // bits 0 to 24 are reserved for distance from focus (excessive, but free...) |
|
45 const TUint KTNScoreMaxForDistanceFromFocus = 0x00FFFFFF; |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // Constructor |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CGlxThumbnailContext* CGlxThumbnailContext::NewL(MGlxMediaListIterator* |
|
53 aIterator) |
|
54 { |
|
55 TRACER( "CGlxThumbnailContext::NewL"); |
|
56 |
|
57 CGlxThumbnailContext* self = new(ELeave)CGlxThumbnailContext(aIterator); |
|
58 CleanupStack::PushL(self); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop(self); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // Constructor |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C CGlxThumbnailContext::CGlxThumbnailContext(MGlxMediaListIterator* aIterator) : |
|
69 iIterator(aIterator) |
|
70 { |
|
71 TRACER( "CGlxThumbnailContext::CGlxThumbnailContext"); |
|
72 |
|
73 __ASSERT_DEBUG(aIterator, Panic(EGlxPanicNullPointer)); |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // ConstructL (2nd phase construction) |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 void CGlxThumbnailContext::ConstructL() |
|
81 { |
|
82 TRACER( "CGlxThumbnailContext::ConstructL"); |
|
83 |
|
84 iCache = MGlxCache::InstanceL(); |
|
85 iResolutionUtility = CGlxResolutionUtility::InstanceL(); |
|
86 iResolutionUtility->AddObserverL( *this ); |
|
87 |
|
88 iDrmUtility = CGlxDRMUtility::InstanceL(); |
|
89 |
|
90 // create attribute context for DRM attributes |
|
91 iDrmFetchContext = new (ELeave) CGlxAttributeContext(iIterator); |
|
92 iDrmFetchContext->AddAttributeL(KMPXMediaDrmProtected); |
|
93 #ifdef RD_MDS_2_5 |
|
94 iDrmFetchContext->AddAttributeL(KGlxMediaGeneralDRMRightsValid); |
|
95 #endif |
|
96 iDrmFetchContext->AddAttributeL(KMPXMediaGeneralCategory); |
|
97 iDrmFetchContext->AddAttributeL(KMPXMediaGeneralUri); |
|
98 iDrmFetchContext->AddAttributeL(KMPXMediaGeneralSize); |
|
99 iDrmFetchContext->AddAttributeL(KGlxMediaGeneralLastModifiedDate); |
|
100 // add size attribute |
|
101 iDrmFetchContext->AddAttributeL(KGlxMediaGeneralDimensions); |
|
102 // add to speed up details retrieval |
|
103 iDrmFetchContext->AddAttributeL(KMPXMediaGeneralTitle); |
|
104 iDrmFetchContext->AddAttributeL(KMPXMediaGeneralDate); |
|
105 iDrmFetchContext->AddAttributeL(KMPXMediaGeneralDrive); |
|
106 iDrmFetchContext->AddAttributeL(KGlxMediaGeneralFramecount); |
|
107 //Need to implement IdSpaceId() functionality. |
|
108 iDrmFetchContext->AddAttributeL(KMPXMediaColDetailSpaceId); |
|
109 // Attributes required to launch Options |
|
110 iDrmFetchContext->AddAttributeL(KMPXMediaGeneralMimeType); |
|
111 iDrmFetchContext->AddAttributeL(KGlxMediaGeneralLocation); |
|
112 iDrmFetchContext->AddAttributeL(KGlxMediaGeneralSystemItem); |
|
113 iDrmFetchContext->AddAttributeL(KGlxMediaGeneralSlideshowableContent); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // Destructor |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C CGlxThumbnailContext::~CGlxThumbnailContext() |
|
121 { |
|
122 TRACER( "CGlxThumbnailContext::~CGlxThumbnailContext"); |
|
123 |
|
124 delete iDrmFetchContext; |
|
125 |
|
126 if ( iDrmUtility ) |
|
127 { |
|
128 iDrmUtility->Close(); |
|
129 } |
|
130 |
|
131 iSpecs.Close(); |
|
132 |
|
133 if ( iResolutionUtility ) |
|
134 { |
|
135 iResolutionUtility->RemoveObserver( *this ); |
|
136 iResolutionUtility->Close(); |
|
137 } |
|
138 |
|
139 if ( iCache ) |
|
140 { |
|
141 iCache->Close(); |
|
142 } |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // Adds a new fetch specification for an item |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 EXPORT_C void CGlxThumbnailContext::AddSpecForItemL( |
|
150 TInt aWidth, TInt aHeight, TInt aFocusOffset ) |
|
151 { |
|
152 TRACER( "CGlxThumbnailContext::AddSpecForItemL"); |
|
153 |
|
154 TReal32 width( aWidth ); |
|
155 TReal32 height( aHeight ); |
|
156 |
|
157 TAssignedFetchSpec spec; |
|
158 spec.iPossWidth = iResolutionUtility->PixelsToPoss( width ); |
|
159 spec.iPossHeight = iResolutionUtility->PixelsToPoss( height ); |
|
160 spec.iFocusOffset = aFocusOffset; |
|
161 |
|
162 // Has this focus index has already been added? |
|
163 #ifdef _DEBUG |
|
164 TIdentityRelation<TAssignedFetchSpec> match (&TAssignedFetchSpec::Match); |
|
165 #endif |
|
166 __ASSERT_DEBUG(iSpecs.Find(spec, match) == KErrNotFound, Panic(EGlxPanicAlreadyAdded)); |
|
167 |
|
168 iSpecs.AppendL(spec); |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // Sets the default fetch specification |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 EXPORT_C void CGlxThumbnailContext::SetDefaultSpec(TInt aWidth, TInt aHeight) |
|
176 { |
|
177 TRACER( "CGlxThumbnailContext::SetDefaultSpec"); |
|
178 |
|
179 iDefaultSpecSize = TSize(aWidth, aHeight); |
|
180 |
|
181 TReal32 width( aWidth ); |
|
182 TReal32 height( aHeight ); |
|
183 |
|
184 iDefaultSpec.iPossWidth = iResolutionUtility->PixelsToPoss( width ); |
|
185 iDefaultSpec.iPossHeight = iResolutionUtility->PixelsToPoss( height ); |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // SetHighQualityOnly |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C void CGlxThumbnailContext::SetHighQualityOnly( |
|
193 TBool aHighQualityOnly ) |
|
194 { |
|
195 TRACER( "CGlxThumbnailContext::SetHighQualityOnly"); |
|
196 |
|
197 iHighQualityOnly = aHighQualityOnly; |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // Get all attributes required for the item (whether the are fetched or not) |
|
202 // From MGlxFetchContext |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CGlxThumbnailContext::AllAttributesL(const MGlxMediaList* aList, TInt aListIndex, |
|
206 RArray<TMPXAttribute>& aAttributes) const |
|
207 { |
|
208 TRACER( "CGlxThumbnailContext::AllAttributesL"); |
|
209 |
|
210 if (!iIterator) |
|
211 { |
|
212 return; |
|
213 } |
|
214 |
|
215 // add attributes from owned attribute context |
|
216 iDrmFetchContext->AllAttributesL(aList,aListIndex, aAttributes); |
|
217 |
|
218 // No requests outside range |
|
219 iIterator->SetToFirst(aList); |
|
220 if (!iIterator->InRange(aListIndex)) |
|
221 { |
|
222 return; |
|
223 } |
|
224 TBool drmValid = EFalse; |
|
225 TSize size = iDefaultSpecSize; |
|
226 const TGlxMedia& item( aList->Item( aListIndex ) ); |
|
227 if( item.GetDrmProtected(drmValid) && drmValid) |
|
228 { |
|
229 drmValid = CheckDRMStatusL( aListIndex, aList, size ); |
|
230 } |
|
231 |
|
232 TLinearOrder<TMPXAttribute> orderer (&CGlxMediaList::AttributeOrder); |
|
233 // Always want high quality thumbnail |
|
234 TMPXAttribute attr( KGlxMediaIdThumbnail, |
|
235 GlxFullThumbnailAttributeId( ETrue, size.iWidth, size.iHeight ) ); |
|
236 aAttributes.InsertInOrderAllowRepeatsL( attr , orderer); |
|
237 |
|
238 // If don't have high quality thumbnail, find closest available thumbnail |
|
239 |
|
240 const CGlxMedia* properties = item.Properties(); |
|
241 if ( properties && !properties->IsSupported( attr ) ) |
|
242 { |
|
243 TMPXAttribute attr2; |
|
244 |
|
245 if ( item.GetClosestThumbnail( attr2, size, drmValid ) ) |
|
246 { |
|
247 aAttributes.InsertInOrderAllowRepeatsL( attr2 , orderer ); |
|
248 } |
|
249 } |
|
250 |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // Get attributes request for the item |
|
255 // From MGlxFetchContext |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 TInt CGlxThumbnailContext::AttributeRequestL(const MGlxMediaList* aList, |
|
259 RArray<TInt>& aItemIndices, RArray<TMPXAttribute>& aAttributes, |
|
260 CMPXAttributeSpecs*& aDetailedSpecs) const |
|
261 { |
|
262 TRACER( "CGlxThumbnailContext::AttributeRequestL"); |
|
263 |
|
264 // Fetch the visible items attribs & thumbnail first. |
|
265 TInt error = KErrNone; |
|
266 TInt listIndex = SelectItemL(aList, error); |
|
267 if ((listIndex >= 0 && aList->Item(listIndex).Uri().Length() == 0) || |
|
268 aList->Count() <= GlxListUtils::VisibleItemsGranularityL()) |
|
269 { |
|
270 TInt reqCount = iDrmFetchContext->AttributeRequestL(aList, |
|
271 aItemIndices, aAttributes, aDetailedSpecs); |
|
272 |
|
273 // if owned context requires DRM atributes need to request those 1st |
|
274 if ( reqCount != 0 ) |
|
275 { |
|
276 GLX_DEBUG2("CGlxThumbnailContext::AttributeRequestL() reqCount=%d", reqCount); |
|
277 return reqCount; |
|
278 } |
|
279 } |
|
280 |
|
281 // Select an item to process |
|
282 error = KErrNone; |
|
283 listIndex = SelectItemL(aList, error); |
|
284 if (KErrNotFound != listIndex) |
|
285 { |
|
286 GLX_DEBUG2("CGlxThumbnailContext::AttributeRequestL() listIndex=%d", listIndex); |
|
287 const TGlxMedia& item = aList->Item( listIndex ); |
|
288 TSize size = iDefaultSpecSize; |
|
289 |
|
290 TBool drmValid = EFalse; |
|
291 if( item.GetDrmProtected(drmValid) && drmValid) |
|
292 { |
|
293 CheckDRMStatusL( listIndex, aList, size ); |
|
294 } |
|
295 |
|
296 // Request high quality thumbnail if already have any thumbnail |
|
297 TBool quality = iHighQualityOnly |
|
298 || HasFullThumbnail( aList->Item( listIndex ) ); |
|
299 |
|
300 GLX_DEBUG2("CGlxThumbnailContext::AttributeRequestL() quality=%d", quality); |
|
301 TMPXAttribute attr( KGlxMediaIdThumbnail, |
|
302 GlxFullThumbnailAttributeId( |
|
303 quality, size.iWidth, size.iHeight ) ); |
|
304 |
|
305 aAttributes.AppendL(attr); |
|
306 |
|
307 aItemIndices.AppendL(listIndex); |
|
308 |
|
309 // Allocate CMPXAttributeSpecs |
|
310 CMPXAttributeSpecs* attributeSpecs = CMPXAttributeSpecs::NewL(); |
|
311 CleanupStack::PushL(attributeSpecs); |
|
312 |
|
313 attributeSpecs->SetTObjectValueL( |
|
314 TMPXAttribute( KGlxMediaIdThumbnail, |
|
315 KGlxAttribSpecThumbnailSize ), size ); |
|
316 |
|
317 attributeSpecs->SetTObjectValueL( |
|
318 TMPXAttribute( KGlxMediaIdThumbnail, |
|
319 KGlxAttribSpecThumbnailQualityOverSpeed ), quality ); |
|
320 |
|
321 |
|
322 aDetailedSpecs = attributeSpecs; |
|
323 |
|
324 // Pop from stack |
|
325 CleanupStack::Pop(attributeSpecs); |
|
326 } |
|
327 else |
|
328 { |
|
329 // If an error was found, return KErrGeneral |
|
330 if (error != KErrNone) |
|
331 { |
|
332 return KErrGeneral; |
|
333 } |
|
334 } |
|
335 |
|
336 return aItemIndices.Count(); |
|
337 } |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // Number of current requests |
|
341 // From MGlxFetchContext |
|
342 // ----------------------------------------------------------------------------- |
|
343 TInt CGlxThumbnailContext::RequestCountL(const MGlxMediaList* aList) const |
|
344 { |
|
345 TRACER( "CGlxThumbnailContext::RequestCountL"); |
|
346 |
|
347 RArray<TInt> itemIndices; |
|
348 CleanupClosePushL(itemIndices); |
|
349 |
|
350 RArray<TMPXAttribute> attributes; |
|
351 CleanupClosePushL(attributes); |
|
352 |
|
353 CMPXAttributeSpecs* attrSpecs = NULL; |
|
354 |
|
355 TInt requestCount = AttributeRequestL(aList, itemIndices, attributes, attrSpecs); |
|
356 |
|
357 delete attrSpecs; |
|
358 |
|
359 CleanupStack::PopAndDestroy(&attributes); |
|
360 CleanupStack::PopAndDestroy(&itemIndices); |
|
361 |
|
362 return requestCount; |
|
363 } |
|
364 |
|
365 // ----------------------------------------------------------------------------- |
|
366 // HandleResolutionChanged |
|
367 // ----------------------------------------------------------------------------- |
|
368 // |
|
369 void CGlxThumbnailContext::HandleResolutionChangedL() |
|
370 { |
|
371 TRACER( "CGlxThumbnailContext::HandleResolutionChanged"); |
|
372 |
|
373 // Ask cache manager to refresh, to fetch thumbnails in new size |
|
374 iCache->RefreshL(); |
|
375 } |
|
376 |
|
377 // ----------------------------------------------------------------------------- |
|
378 // SelectItemL |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 TInt CGlxThumbnailContext::SelectItemL(const MGlxMediaList* aList, TInt& aError) const |
|
382 { |
|
383 TRACER( "CGlxThumbnailContext::SelectItemL"); |
|
384 |
|
385 // Order of priorities when selecting the item: (highest priority rule first) |
|
386 // Items with no thumbnail before items with thumbnail |
|
387 // Items closer to the focus before |
|
388 |
|
389 TInt count = aList->Count(); |
|
390 if (0 == count || !iIterator) |
|
391 { |
|
392 return KErrNotFound; |
|
393 } |
|
394 |
|
395 // Iterate through range from iterator in search of the highest scoring thumbnail |
|
396 TUint bestScore = 0; |
|
397 TInt bestIndex = KErrNotFound; |
|
398 iIterator->SetToFirst(aList); |
|
399 TInt distanceFromFirst = 0; |
|
400 TInt i; |
|
401 while (KErrNotFound != (i = (*iIterator)++)) |
|
402 { |
|
403 // Calculate the score for this item |
|
404 TUint score = GetThumbnailScoreL(i, aList, distanceFromFirst, aError); |
|
405 __ASSERT_DEBUG(score != bestScore || score == 0, Panic(EGlxPanicLogicError)); // For safety, cannot allow two items with the same score |
|
406 if (score > bestScore) |
|
407 { |
|
408 bestScore = score; |
|
409 bestIndex = i; |
|
410 } |
|
411 |
|
412 distanceFromFirst++; |
|
413 } |
|
414 |
|
415 return bestIndex; |
|
416 } |
|
417 |
|
418 // ----------------------------------------------------------------------------- |
|
419 // GetThumbnailScoreL |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 TUint CGlxThumbnailContext::GetThumbnailScoreL(TInt aListIndex, const MGlxMediaList* aList, |
|
423 TInt aDistance, TInt& aError) const |
|
424 { |
|
425 TRACER( "CGlxThumbnailContext::GetThumbnailScoreL"); |
|
426 |
|
427 const TGlxMedia& item = aList->Item(aListIndex); |
|
428 const CGlxMedia* properties = item.Properties(); |
|
429 |
|
430 // Check for the static item in the list. |
|
431 // defualt icons needs to be displayed for static items. |
|
432 if(item.IsStatic()) |
|
433 { |
|
434 return 0; |
|
435 } |
|
436 |
|
437 TBool thumbnail = HasFullThumbnail( item ); |
|
438 TUint score = 0; |
|
439 |
|
440 if ( properties ) |
|
441 { |
|
442 TSize size = iDefaultSpecSize; |
|
443 |
|
444 TBool drmValid = EFalse; |
|
445 if( item.GetDrmProtected(drmValid) && drmValid) |
|
446 { |
|
447 CheckDRMStatusL( aListIndex, aList, size ); |
|
448 } |
|
449 |
|
450 // Want high quality thumbnail if already have any thumbnail |
|
451 TBool quality = iHighQualityOnly || thumbnail; |
|
452 TMPXAttribute attr( KGlxMediaIdThumbnail, |
|
453 GlxFullThumbnailAttributeId( |
|
454 quality, size.iWidth, size.iHeight ) ); |
|
455 |
|
456 // Items that are "perfect" are skipped |
|
457 if ( quality && properties->IsSupported( attr ) ) |
|
458 { |
|
459 return 0; |
|
460 } |
|
461 |
|
462 // Items for which fetching thumbnail failed are skipped |
|
463 TInt error = GlxErrorManager::HasAttributeErrorL( properties, attr ); |
|
464 if ( error != KErrNone ) |
|
465 { |
|
466 aError = error; |
|
467 return 0; |
|
468 } |
|
469 } |
|
470 |
|
471 // Score on not having any thumbnail |
|
472 if ( !thumbnail ) |
|
473 { |
|
474 score |= KTNScoreNoThumbnail; |
|
475 } |
|
476 |
|
477 // Score on proximity to focus |
|
478 score |= KTNScoreMaxForDistanceFromFocus - aDistance; // More distance, less points |
|
479 |
|
480 __ASSERT_DEBUG(score != 0, Panic(EGlxPanicLogicError)); |
|
481 |
|
482 return score; |
|
483 } |
|
484 |
|
485 // ----------------------------------------------------------------------------- |
|
486 // SpecForIndex |
|
487 // ----------------------------------------------------------------------------- |
|
488 // |
|
489 const CGlxThumbnailContext::TFetchSpec& CGlxThumbnailContext::SpecForIndex( |
|
490 TInt aListIndex, const MGlxMediaList* aList) const |
|
491 { |
|
492 TRACER( "CGlxThumbnailContext::SpecForIndex"); |
|
493 |
|
494 __ASSERT_DEBUG(aList, Panic(EGlxPanicNullPointer)); |
|
495 |
|
496 TInt count = aList->Count(); |
|
497 TInt offset = Abs(aListIndex - aList->FocusIndex()); |
|
498 |
|
499 if ( offset > count / 2 ) |
|
500 { |
|
501 offset = count - offset; |
|
502 } |
|
503 |
|
504 // Use specific context if one exists |
|
505 TAssignedFetchSpec spec; |
|
506 spec.iFocusOffset = offset; |
|
507 TInt index = iSpecs.Find(spec, TAssignedFetchSpec::Match); |
|
508 if ( KErrNotFound != index ) |
|
509 { |
|
510 return iSpecs[index]; |
|
511 } |
|
512 |
|
513 return iDefaultSpec; |
|
514 } |
|
515 |
|
516 // --------------------------------------------------------------------------- |
|
517 // SizeFromSpec |
|
518 // --------------------------------------------------------------------------- |
|
519 // |
|
520 TSize CGlxThumbnailContext::SizeFromSpec( const TFetchSpec& aSpec ) const |
|
521 { |
|
522 TRACER( "CGlxThumbnailContext::SizeFromSpec"); |
|
523 |
|
524 TReal32 width = iResolutionUtility->PossToPixels( aSpec.iPossWidth ); |
|
525 TReal32 height = iResolutionUtility->PossToPixels( aSpec.iPossHeight ); |
|
526 |
|
527 // Round to the nearest integers |
|
528 return TSize( width + 0.5F, height + 0.5F ); |
|
529 } |
|
530 |
|
531 // ----------------------------------------------------------------------------- |
|
532 // Compares two specs by focus offset. |
|
533 // ----------------------------------------------------------------------------- |
|
534 // |
|
535 TBool CGlxThumbnailContext::TAssignedFetchSpec::Match( |
|
536 const TAssignedFetchSpec& aSpec1, const TAssignedFetchSpec& aSpec2 ) |
|
537 { |
|
538 TRACER( "CGlxThumbnailContext::TAssignedFetchSpec::Match"); |
|
539 |
|
540 return aSpec1.iFocusOffset == aSpec2.iFocusOffset; |
|
541 } |
|
542 |
|
543 // ----------------------------------------------------------------------------- |
|
544 // HasFullThumbnail |
|
545 // ----------------------------------------------------------------------------- |
|
546 // |
|
547 TBool CGlxThumbnailContext::HasFullThumbnail( const TGlxMedia& aItem ) const |
|
548 { |
|
549 TRACER( "CGlxThumbnailContext::HasFullThumbnail"); |
|
550 |
|
551 const CGlxMedia* properties = aItem.Properties(); |
|
552 |
|
553 if ( properties ) |
|
554 { |
|
555 TInt count = properties->Count(); |
|
556 for ( TInt i = 0; i < count; i++ ) |
|
557 { |
|
558 if ( GlxThumbnailUtility::IsFullThumbnail( |
|
559 properties->Attribute( i ) ) ) |
|
560 { |
|
561 return ETrue; |
|
562 } |
|
563 } |
|
564 } |
|
565 |
|
566 return EFalse; |
|
567 } |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // Check DRM status of specified item |
|
571 // ----------------------------------------------------------------------------- |
|
572 // |
|
573 TBool CGlxThumbnailContext::CheckDRMStatusL( TInt aListIndex, |
|
574 const MGlxMediaList* aList, TSize& aSize ) const |
|
575 { |
|
576 TRACER( "CGlxThumbnailContext::CheckDRMStatusL"); |
|
577 |
|
578 const TGlxMedia& item = aList->Item( aListIndex ); |
|
579 TBool valid = EFalse; |
|
580 |
|
581 aSize = SizeFromSpec( SpecForIndex( aListIndex, aList ) ); |
|
582 |
|
583 TGlxMediaGeneralRightsValidity isValid = EGlxDrmRightsValidityUnknown; |
|
584 item.GetDrmValidity(isValid); |
|
585 if ( EGlxDrmRightsValidityUnknown == isValid ) |
|
586 { |
|
587 // check rights |
|
588 TMPXGeneralCategory cat = item.Category(); |
|
589 const TDesC& uri = item.Uri(); |
|
590 if ( uri.Length() && cat != EMPXNoCategory ) |
|
591 { |
|
592 valid = iDrmUtility->CheckOpenRightsL( uri, ( cat == EMPXImage ) ); |
|
593 CGlxMedia* properties = const_cast<CGlxMedia*>(item.Properties()); |
|
594 if( valid ) |
|
595 { |
|
596 |
|
597 isValid = EGlxDrmRightsValid; |
|
598 } |
|
599 else |
|
600 { |
|
601 |
|
602 isValid = EGlxDrmRightsInvalid; |
|
603 } |
|
604 properties->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, isValid); |
|
605 } |
|
606 } |
|
607 else if ( EGlxDrmRightsValid == isValid ) |
|
608 { |
|
609 valid = ETrue; |
|
610 } |
|
611 if ( !valid ) |
|
612 { |
|
613 // modify spec to request 'small' thumbnail |
|
614 TSize size; |
|
615 // ignore success/failure return - accept default |
|
616 item.GetDimensions(size); |
|
617 |
|
618 TSize thumbnailSize = iDrmUtility->DRMThumbnailSize( size ); |
|
619 |
|
620 // only update spec if either dimension of required DRM thumbnail |
|
621 // is smaller than correspnding spec dimension (so don't request |
|
622 // a new thumbnail if existing one if of appropriate size ) |
|
623 if( thumbnailSize.iWidth < aSize.iWidth |
|
624 || thumbnailSize.iHeight < aSize.iHeight ) |
|
625 { |
|
626 aSize = thumbnailSize; |
|
627 } |
|
628 } |
|
629 return valid; |
|
630 } |
|
631 |
|
632 // ----------------------------------------------------------------------------- |
|
633 // ----------------------------------------------------------------------------- |
|
634 // CGlxDefaultThumbnailContext |
|
635 // ----------------------------------------------------------------------------- |
|
636 // ----------------------------------------------------------------------------- |
|
637 // |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // NewL |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 EXPORT_C CGlxDefaultThumbnailContext* CGlxDefaultThumbnailContext::NewL() |
|
644 { |
|
645 TRACER( "CGlxDefaultThumbnailContext::NewL"); |
|
646 |
|
647 CGlxDefaultThumbnailContext* obj = new (ELeave) CGlxDefaultThumbnailContext(); |
|
648 CleanupStack::PushL(obj); |
|
649 obj->ConstructL(); |
|
650 CleanupStack::Pop(obj); |
|
651 return obj; |
|
652 } |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // Constructor |
|
656 // Sets the iterator of base class to be TGlxFromFocusOutwardIterator |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 CGlxDefaultThumbnailContext::CGlxDefaultThumbnailContext() : |
|
660 CGlxThumbnailContext(&iFromFocusIterator) |
|
661 { |
|
662 TRACER( "CGlxDefaultThumbnailContext::CGlxDefaultThumbnailContext"); |
|
663 |
|
664 } |
|
665 |
|
666 // ----------------------------------------------------------------------------- |
|
667 // Destructor |
|
668 // ----------------------------------------------------------------------------- |
|
669 // |
|
670 EXPORT_C CGlxDefaultThumbnailContext::~CGlxDefaultThumbnailContext() |
|
671 { |
|
672 TRACER( "CGlxDefaultThumbnailContext::~CGlxDefaultThumbnailContext"); |
|
673 |
|
674 } |
|
675 |
|
676 // ---------------------------------------------------------------------------- |
|
677 // Set range offsets |
|
678 // ---------------------------------------------------------------------------- |
|
679 // |
|
680 EXPORT_C void CGlxDefaultThumbnailContext::SetRangeOffsets(TInt aFrontOffset, TInt aRearOffset) |
|
681 { |
|
682 TRACER( "CGlxDefaultThumbnailContext::SetRangeOffsets"); |
|
683 |
|
684 iFromFocusIterator.SetRangeOffsets(aFrontOffset, aRearOffset); |
|
685 } |