|
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 : Grid view Observers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 // Ganes Headers |
|
22 #include <ganes/HgItem.h> |
|
23 #include <ganes/HgGrid.h> //Hg Grid Widget |
|
24 //#include <hg/hgcontextutility.h> |
|
25 #include <gulicon.h> |
|
26 |
|
27 //Gallery Headers |
|
28 #include <glxtracer.h> // For Tracer |
|
29 #include <glxlog.h> // For Glx Logging |
|
30 #include <glxuiutility.h> // For UiUtility instance |
|
31 #include <glxicons.mbg> // For Corrupted and not created icons |
|
32 #include <glxerrormanager.h> // For CGlxErrormanager |
|
33 #include <glxuistd.h> |
|
34 #include <mglxmedialist.h> // CGlxMedialist |
|
35 #include <glxthumbnailattributeinfo.h> // KGlxMediaIdThumbnail |
|
36 #include <glxdrmutility.h> // DRM utility class to provide DRM-related functionality |
|
37 #include <mpxmediadrmdefs.h> // KMPXMediaDrmProtected |
|
38 #include <glxcollectionplugindownloads.hrh> |
|
39 #include <glxgridviewdata.rsg> // Gridview resource |
|
40 |
|
41 // Framework |
|
42 #include <data_caging_path_literals.hrh> |
|
43 #include <StringLoader.h> |
|
44 |
|
45 #include <bldvariant.hrh> // For feature constants |
|
46 #include <featmgr.h> // Feature Manager |
|
47 #include <caf/caferr.h> |
|
48 #include <AknUtils.h> |
|
49 |
|
50 #include "glxgridviewmlobserver.h" |
|
51 |
|
52 const TInt KRecreateGridSize(100); //minimum no of items added to trigger recreate grid |
|
53 // ======== MEMBER FUNCTIONS ======== |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Two-phased constructor. |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CGlxGridViewMLObserver* CGlxGridViewMLObserver::NewL( |
|
60 MGlxMediaList& aMediaList, CHgGrid* aHgGrid) |
|
61 { |
|
62 TRACER("CGlxGridViewMLObserver::NewLC()"); |
|
63 CGlxGridViewMLObserver* self = |
|
64 new (ELeave) CGlxGridViewMLObserver(aMediaList, aHgGrid); |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop(self); |
|
68 return self; |
|
69 } |
|
70 // --------------------------------------------------------------------------- |
|
71 // C++ default constructor can NOT contain any code, that |
|
72 // might leave. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CGlxGridViewMLObserver::CGlxGridViewMLObserver(MGlxMediaList& aMediaList, |
|
76 CHgGrid* aHgGrid ) : iMediaList(aMediaList), iHgGrid(aHgGrid) |
|
77 { |
|
78 TRACER("CGlxGridViewMLObserver::CGlxGridViewMLObserver"); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Symbian 2nd phase constructor can leave. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CGlxGridViewMLObserver::ConstructL() |
|
86 { |
|
87 TRACER("CGlxGridViewMLObserver::ConstructL"); |
|
88 iMediaList.AddMediaListObserverL(this); |
|
89 // For DRm Utility |
|
90 iDRMUtility = CGlxDRMUtility::InstanceL(); |
|
91 |
|
92 CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
|
93 iGridIconSize = uiUtility->GetGridIconSize(); |
|
94 //Get the HgContextUtility instance |
|
95 // iContextUtility = uiUtility->ContextUtility(); |
|
96 iItemsPerPage = uiUtility->VisibleItemsInPageGranularityL(); |
|
97 uiUtility->Close() ; |
|
98 |
|
99 iDownloadsPlugin = EFalse; |
|
100 |
|
101 CMPXCollectionPath* path = iMediaList.PathLC( NGlxListDefs::EPathParent ); |
|
102 if (path->Id() == KGlxCollectionPluginDownloadsImplementationUid) |
|
103 { |
|
104 iDownloadsPlugin = ETrue; |
|
105 } |
|
106 CleanupStack::PopAndDestroy(path); |
|
107 |
|
108 iQualityTnAttrib = TMPXAttribute (KGlxMediaIdThumbnail, |
|
109 GlxFullThumbnailAttributeId( ETrue, iGridIconSize.iWidth, |
|
110 iGridIconSize.iHeight ) ); |
|
111 |
|
112 iSpeedTnAttrib = TMPXAttribute (KGlxMediaIdThumbnail, |
|
113 GlxFullThumbnailAttributeId( EFalse, iGridIconSize.iWidth, |
|
114 iGridIconSize.iHeight ) ); |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // Destructor |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CGlxGridViewMLObserver::~CGlxGridViewMLObserver() |
|
122 { |
|
123 TRACER("CGlxGridViewMLObserver::~CGlxGridViewMLObserver"); |
|
124 iMediaList.RemoveMediaListObserver( this ); |
|
125 if (iDRMUtility) |
|
126 { |
|
127 iDRMUtility->Close(); |
|
128 } |
|
129 iModifiedIndexes.Reset(); |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------------- |
|
133 // HandleItemAddedL |
|
134 // ---------------------------------------------------------------------------- |
|
135 // |
|
136 void CGlxGridViewMLObserver::HandleItemAddedL( TInt aStartIndex, TInt aEndIndex, |
|
137 MGlxMediaList* aList ) |
|
138 { |
|
139 TRACER("CGlxGridViewMLObserver::HandleItemAddedL()"); |
|
140 GLX_DEBUG3("CGlxGridViewMLObserver::HandleItemAddedL() aStartIndex(%d)," |
|
141 " aEndIndex(%d)", aStartIndex, aEndIndex); |
|
142 |
|
143 if (iHgGrid) |
|
144 { |
|
145 if ((aEndIndex - aStartIndex) >= KRecreateGridSize) |
|
146 { |
|
147 iHgGrid->ResizeL(aList->Count()); |
|
148 } |
|
149 else |
|
150 { |
|
151 for (TInt i = aStartIndex; i<= aEndIndex; i++) |
|
152 { |
|
153 iHgGrid->InsertItem(CHgItem::NewL(), i); |
|
154 } |
|
155 } |
|
156 } |
|
157 // Setting the initial focus for all grid views except downloads, |
|
158 // for downloads it is already set. |
|
159 TInt focusIndex = aList->FocusIndex(); |
|
160 iHgGrid->SetSelectedIndex(focusIndex); |
|
161 |
|
162 // if the Medialist has any item, set the First index context to Hg Context Utility |
|
163 // TGlxMedia item = aList->Item( focusIndex ); |
|
164 // iContextUtility->PublishPhotoContextL(item.Uri()); |
|
165 } |
|
166 |
|
167 // ---------------------------------------------------------------------------- |
|
168 // HandleItemRemoved |
|
169 // ---------------------------------------------------------------------------- |
|
170 // |
|
171 void CGlxGridViewMLObserver::HandleItemRemovedL( TInt aStartIndex, |
|
172 TInt aEndIndex, MGlxMediaList* aList ) |
|
173 { |
|
174 TRACER("CGlxGridViewMLObserver::HandleItemRemovedL()"); |
|
175 if (iHgGrid) |
|
176 { |
|
177 TInt mediaCount = aList->Count(); |
|
178 |
|
179 for (TInt i = aEndIndex; i>= aStartIndex; i--) |
|
180 { |
|
181 iHgGrid->RemoveItem(i); |
|
182 } |
|
183 |
|
184 // If the last item is also deleted, this refreshes the view |
|
185 if (mediaCount <=0) |
|
186 { |
|
187 if(iMediaList.VisibleWindowIndex() > iMediaList.Count()) |
|
188 { |
|
189 iMediaList.SetVisibleWindowIndexL(0); |
|
190 } |
|
191 //This is done since the Hg doesnot refresh the screen |
|
192 //when we remove all the items from the grid |
|
193 iHgGrid->DrawDeferred(); |
|
194 iHgGrid->Reset(); |
|
195 return; |
|
196 } |
|
197 else if (iMediaList.VisibleWindowIndex() > iMediaList.Count()) |
|
198 { |
|
199 iMediaList.SetVisibleWindowIndexL(iMediaList.Count()-1); |
|
200 } |
|
201 iHgGrid->RefreshScreen(iHgGrid->FirstIndexOnScreen()); |
|
202 } |
|
203 } |
|
204 |
|
205 // ---------------------------------------------------------------------------- |
|
206 // HandleAttributesAvailableL |
|
207 // ---------------------------------------------------------------------------- |
|
208 // |
|
209 void CGlxGridViewMLObserver::HandleAttributesAvailableL( TInt aItemIndex, |
|
210 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* /*aList*/ ) |
|
211 { |
|
212 TRACER("CGlxGridViewMLObserver::HandleAttributesAvailableL()"); |
|
213 GLX_LOG_INFO1("CGlxGridViewMLObserver::HandleAttributesAvailableL " |
|
214 "aItemIndex(%d)", aItemIndex); |
|
215 if (!iHgGrid) |
|
216 { |
|
217 return; |
|
218 } |
|
219 |
|
220 TInt mediaCount = iMediaList.Count(); |
|
221 const TGlxMedia& item = iMediaList.Item( aItemIndex ); |
|
222 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
223 |
|
224 if (KErrNotFound != aAttributes.Find( iQualityTnAttrib, match ) || |
|
225 KErrNotFound != aAttributes.Find( iSpeedTnAttrib, match )) |
|
226 { |
|
227 TFileName resFile(KDC_APP_BITMAP_DIR); |
|
228 resFile.Append(KGlxIconsFilename); |
|
229 TSize setSize = CHgGrid::PreferredImageSize(); |
|
230 TIconInfo icon; |
|
231 |
|
232 const CGlxThumbnailAttribute* qualityTn = item.ThumbnailAttribute( |
|
233 iQualityTnAttrib ); |
|
234 |
|
235 const CGlxThumbnailAttribute* speedTn = item.ThumbnailAttribute( |
|
236 iSpeedTnAttrib ); |
|
237 |
|
238 TInt tnError = GlxErrorManager::HasAttributeErrorL( |
|
239 item.Properties(), KGlxMediaIdThumbnail ); |
|
240 |
|
241 if (qualityTn) |
|
242 { |
|
243 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
244 bitmap->Duplicate( qualityTn->iBitmap->Handle()); |
|
245 AknIconUtils::SetSize(bitmap, setSize); |
|
246 iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap)); |
|
247 GLX_LOG_INFO1("### CGlxGridViewMLObserver::HandleAttributesAvailableL" |
|
248 " qualityTn-Index is %d",aItemIndex); |
|
249 } |
|
250 else if (speedTn) |
|
251 { |
|
252 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
253 bitmap->Duplicate( speedTn->iBitmap->Handle()); |
|
254 AknIconUtils::SetSize(bitmap, setSize); |
|
255 iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap)); |
|
256 GLX_LOG_INFO1("### CGlxGridViewMLObserver::HandleAttributesAvailableL" |
|
257 " speedTn-Index is %d",aItemIndex); |
|
258 } |
|
259 else if (item.GetIconInfo(icon)) |
|
260 { |
|
261 CFbsBitmap* bitmap = AknIconUtils::CreateIconL(icon.bmpfile, icon.bitmapId); |
|
262 AknIconUtils::SetSize(bitmap, setSize ); |
|
263 iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap)); |
|
264 GLX_LOG_INFO1("### CGlxGridViewMLObserver::HandleAttributesAvailableL " |
|
265 "GetIconInfo-Index is %d",aItemIndex); |
|
266 } |
|
267 else if ( KErrNone != tnError && KErrNotSupported != tnError && |
|
268 KErrArgument != tnError ) |
|
269 { |
|
270 CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile, |
|
271 EMbmGlxiconsQgn_prop_image_corrupted); |
|
272 AknIconUtils::SetSize(bitmap, setSize); |
|
273 iHgGrid->ItemL(aItemIndex).SetIcon(CGulIcon::NewL(bitmap)); |
|
274 } |
|
275 } |
|
276 |
|
277 //Now Update the items with the DRM/video icon and date/time |
|
278 UpdateItemsL(aItemIndex,aAttributes); |
|
279 |
|
280 //Now refresh the screen based on the attributes available index |
|
281 RefreshScreen(aItemIndex,aAttributes); |
|
282 } |
|
283 |
|
284 // ---------------------------------------------------------------------------- |
|
285 // HandleFocusChangedL |
|
286 // ---------------------------------------------------------------------------- |
|
287 // |
|
288 void CGlxGridViewMLObserver::HandleFocusChangedL( NGlxListDefs:: |
|
289 TFocusChangeType /*aType*/, TInt aNewIndex, TInt /*aOldIndex*/, |
|
290 MGlxMediaList* /*aList*/ ) |
|
291 { |
|
292 TRACER("CGlxGridViewMLObserver::HandleFocusChangedL()"); |
|
293 iHgGrid->SetSelectedIndex(aNewIndex); |
|
294 iHgGrid->RefreshScreen(aNewIndex); |
|
295 /* if (aList->Count()) |
|
296 { |
|
297 // This us to set the context to HG Teleport |
|
298 TGlxMedia item = iMediaList.Item( aNewIndex ); |
|
299 iContextUtility->PublishPhotoContextL(item.Uri()); |
|
300 }*/ |
|
301 } |
|
302 |
|
303 // ---------------------------------------------------------------------------- |
|
304 // HandleItemSelected |
|
305 // ---------------------------------------------------------------------------- |
|
306 // |
|
307 void CGlxGridViewMLObserver::HandleItemSelectedL(TInt /*aIndex*/, |
|
308 TBool /*aSelected*/, MGlxMediaList* /*aList*/ ) |
|
309 { |
|
310 TRACER("CGlxGridViewMLObserver::HandleItemSelectedL"); |
|
311 } |
|
312 |
|
313 // ---------------------------------------------------------------------------- |
|
314 // HandleMessageL |
|
315 // ---------------------------------------------------------------------------- |
|
316 // |
|
317 void CGlxGridViewMLObserver::HandleMessageL( const CMPXMessage& /*aMessage*/, |
|
318 MGlxMediaList* /*aList*/ ) |
|
319 { |
|
320 TRACER("CGlxGridViewMLObserver::HandleMessageL()"); |
|
321 } |
|
322 |
|
323 // ---------------------------------------------------------------------------- |
|
324 // HandleError |
|
325 // ---------------------------------------------------------------------------- |
|
326 // |
|
327 void CGlxGridViewMLObserver::HandleError( TInt /*aError*/ ) |
|
328 { |
|
329 TRACER("CGlxGridViewMLObserver::HandleError()"); |
|
330 TRAP_IGNORE(HandleErrorL()); |
|
331 } |
|
332 |
|
333 // ---------------------------------------------------------------------------- |
|
334 // HandleErrorL |
|
335 // ---------------------------------------------------------------------------- |
|
336 // |
|
337 void CGlxGridViewMLObserver::HandleErrorL() |
|
338 { |
|
339 TRACER("CGlxGridViewMLObserver::HandleErrorL()"); |
|
340 for ( TInt i = 0; i < iMediaList.Count(); i++ ) |
|
341 { |
|
342 const TGlxMedia& item = iMediaList.Item( i ); |
|
343 TInt thumbnailError = GlxErrorManager::HasAttributeErrorL( |
|
344 item.Properties(), KGlxMediaIdThumbnail ); |
|
345 |
|
346 if( thumbnailError== KErrCANoRights) |
|
347 { |
|
348 /*fix for EABI-7RKHDG |
|
349 * this is a safe code added to show default |
|
350 * TNM returns -17452 in case SD DRM files |
|
351 */ |
|
352 TFileName resFile(KDC_APP_BITMAP_DIR); |
|
353 resFile.Append(KGlxIconsFilename); |
|
354 CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile, |
|
355 EMbmGlxiconsQgn_prop_image_notcreated); |
|
356 AknIconUtils::SetSize(bitmap, CHgGrid::PreferredImageSize()); |
|
357 iHgGrid->ItemL(i).SetIcon(CGulIcon::NewL(bitmap), |
|
358 CHgItem::EHgItemFlagsDrmRightsExpired); |
|
359 } |
|
360 else if (thumbnailError) |
|
361 { |
|
362 TFileName resFile(KDC_APP_BITMAP_DIR); |
|
363 resFile.Append(KGlxIconsFilename); |
|
364 |
|
365 CFbsBitmap* bitmap = AknIconUtils::CreateIconL(resFile, |
|
366 EMbmGlxiconsQgn_prop_image_corrupted); |
|
367 |
|
368 //@ Fix for EABI-7RJA8C, Changes for HG grid for corrupted icon. |
|
369 AknIconUtils::SetSize(bitmap, CHgGrid::PreferredImageSize() ); |
|
370 |
|
371 iHgGrid->ItemL(i).SetIcon(CGulIcon::NewL(bitmap), |
|
372 CHgItem::EHgItemFlagsNone); |
|
373 } |
|
374 } |
|
375 iHgGrid->RefreshScreen(iHgGrid->FirstIndexOnScreen()); |
|
376 } |
|
377 // ---------------------------------------------------------------------------- |
|
378 // HandleCommandCompleteL |
|
379 // ---------------------------------------------------------------------------- |
|
380 // |
|
381 void CGlxGridViewMLObserver::HandleCommandCompleteL( CMPXCommand* /*aCommandResult*/, |
|
382 TInt /*aError*/, MGlxMediaList* /*aList*/ ) |
|
383 { |
|
384 TRACER("CGlxGridViewMLObserver::HandleCommandCompleteL()"); |
|
385 } |
|
386 |
|
387 // ---------------------------------------------------------------------------- |
|
388 // HandleMediaL |
|
389 // ---------------------------------------------------------------------------- |
|
390 // |
|
391 void CGlxGridViewMLObserver::HandleMediaL( TInt /*aListIndex*/, MGlxMediaList* /*aList*/ ) |
|
392 { |
|
393 TRACER("CGlxGridViewMLObserver::HandleMediaL()"); |
|
394 } |
|
395 |
|
396 // ---------------------------------------------------------------------------- |
|
397 // HandlePopulatedL |
|
398 // ---------------------------------------------------------------------------- |
|
399 // |
|
400 void CGlxGridViewMLObserver::HandlePopulatedL( MGlxMediaList* /*aList*/ ) |
|
401 { |
|
402 TRACER("CGlxGridViewMLObserver::HandlePopulatedL()"); |
|
403 if (iHgGrid) |
|
404 { |
|
405 // Setting the Empty Text |
|
406 HBufC* emptyText = |
|
407 StringLoader::LoadLC(R_GRID_EMPTY_VIEW_TEXT); |
|
408 iHgGrid->SetEmptyTextL(*emptyText); |
|
409 CleanupStack::PopAndDestroy(emptyText); |
|
410 GLX_DEBUG2("GridMLObserver::HandlePopulatedL() iMediaList.Count()=%d", |
|
411 iMediaList.Count()); |
|
412 |
|
413 |
|
414 if (iMediaList.Count() <= 0) |
|
415 { |
|
416 GLX_DEBUG1("GridMLObserver::HandlePopulatedL() - SetEmptyTextL()"); |
|
417 iHgGrid->DrawNow(); |
|
418 } |
|
419 } |
|
420 } |
|
421 |
|
422 // ---------------------------------------------------------------------------- |
|
423 // HandleItemModifiedL |
|
424 // ---------------------------------------------------------------------------- |
|
425 // |
|
426 void CGlxGridViewMLObserver::HandleItemModifiedL(const RArray<TInt>& aItemIndexes, |
|
427 MGlxMediaList* /*aList*/) |
|
428 { |
|
429 TRACER("CGlxGridViewMLObserver::HandleItemModifiedL()"); |
|
430 for(TInt index = 0;index<aItemIndexes.Count();index++) |
|
431 { |
|
432 TInt modifiedIndex = aItemIndexes[index]; |
|
433 iModifiedIndexes.AppendL(modifiedIndex); |
|
434 } |
|
435 } |
|
436 |
|
437 // ---------------------------------------------------------------------------- |
|
438 // HasRelevantThumbnailAttribute |
|
439 // ---------------------------------------------------------------------------- |
|
440 // |
|
441 TBool CGlxGridViewMLObserver::HasRelevantThumbnail(TInt aIndex) |
|
442 { |
|
443 TRACER("CGlxGridViewMLObserver::HasRelevantThumbnail()"); |
|
444 const TGlxMedia& item = iMediaList.Item( aIndex ); |
|
445 const CGlxThumbnailAttribute* qualityTn = item.ThumbnailAttribute( |
|
446 iQualityTnAttrib ); |
|
447 const CGlxThumbnailAttribute* speedTn = item.ThumbnailAttribute( |
|
448 iSpeedTnAttrib ); |
|
449 if ( qualityTn || speedTn ) |
|
450 { |
|
451 GLX_DEBUG1("GridMLObserver::HasRelevantThumbnail() - TN avail"); |
|
452 return ETrue; |
|
453 } |
|
454 return EFalse; |
|
455 } |
|
456 |
|
457 |
|
458 // ---------------------------------------------------------------------------- |
|
459 // RefreshScreen |
|
460 // ---------------------------------------------------------------------------- |
|
461 // |
|
462 void CGlxGridViewMLObserver::RefreshScreen(TInt aItemIndex, |
|
463 const RArray<TMPXAttribute>& aAttributes) |
|
464 { |
|
465 TInt mediaCount = iMediaList.Count(); |
|
466 TInt firstIndex = iHgGrid->FirstIndexOnScreen(); |
|
467 firstIndex = (firstIndex<0 ? 0 : firstIndex); |
|
468 TInt lastOnScreen = firstIndex + iHgGrid->ItemsOnScreen() - 1; |
|
469 lastOnScreen = (lastOnScreen >mediaCount-1? mediaCount-1:lastOnScreen); |
|
470 if (mediaCount < iItemsPerPage || aItemIndex == firstIndex) |
|
471 { |
|
472 if (aItemIndex == firstIndex && HasRelevantThumbnail(firstIndex)) |
|
473 { |
|
474 GLX_DEBUG2("## GridMLObserver::HandleAttributesAvailableL()" |
|
475 " RefreshScreen - firstIndex(%d)", firstIndex); |
|
476 iHgGrid->RefreshScreen(firstIndex); |
|
477 } |
|
478 } |
|
479 else if (aItemIndex > firstIndex && aItemIndex <= lastOnScreen) |
|
480 { |
|
481 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
482 if (KErrNotFound != aAttributes.Find(iQualityTnAttrib, match) || |
|
483 KErrNotFound != aAttributes.Find(iSpeedTnAttrib, match) ) |
|
484 { |
|
485 if ( HasRelevantThumbnail(firstIndex) ) |
|
486 { |
|
487 if ( HasRelevantThumbnail(lastOnScreen) ) |
|
488 { |
|
489 GLX_DEBUG2("GridMLObserver::HandleAttributesAvailableL()" |
|
490 " RefreshScreen - aItemIndex(%d)", aItemIndex); |
|
491 iHgGrid->RefreshScreen(aItemIndex); |
|
492 } |
|
493 else if (aItemIndex == lastOnScreen) |
|
494 { |
|
495 GLX_DEBUG2("GridMLObserver::HandleAttributesAvailableL()" |
|
496 " RefreshScreen - lastOnScreen(%d)", lastOnScreen); |
|
497 iHgGrid->RefreshScreen(lastOnScreen); |
|
498 } |
|
499 } |
|
500 } |
|
501 } |
|
502 if (iModifiedIndexes.Count() > 0) |
|
503 { |
|
504 for(TInt index = 0;index<iModifiedIndexes.Count();index++) |
|
505 { |
|
506 if (iModifiedIndexes[index] == aItemIndex && |
|
507 HasRelevantThumbnail(aItemIndex)) |
|
508 { |
|
509 GLX_DEBUG2("GridMLObserver::HandleAttributesAvailableL()" |
|
510 " RefreshScreen - modified index(%d)", aItemIndex); |
|
511 iHgGrid->RefreshScreen(aItemIndex); |
|
512 iModifiedIndexes.Remove(index); |
|
513 iModifiedIndexes.Compress(); |
|
514 } |
|
515 } |
|
516 } |
|
517 } |
|
518 |
|
519 |
|
520 // ---------------------------------------------------------------------------- |
|
521 // UpdateItemsL |
|
522 // ---------------------------------------------------------------------------- |
|
523 // |
|
524 void CGlxGridViewMLObserver::UpdateItemsL (TInt aItemIndex, |
|
525 const RArray<TMPXAttribute>& aAttributes) |
|
526 { |
|
527 TInt mediaCount = iMediaList.Count(); |
|
528 const TGlxMedia& item = iMediaList.Item( aItemIndex ); |
|
529 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
530 |
|
531 if (aAttributes.Find(KMPXMediaDrmProtected, match) != KErrNotFound) |
|
532 { |
|
533 if (item.IsDrmProtected()) |
|
534 { |
|
535 const TDesC& uri = item.Uri(); |
|
536 if( uri.Length() > 0) |
|
537 { |
|
538 if(iDRMUtility->IsForwardLockedL(uri)) |
|
539 { |
|
540 /* |
|
541 * fix for EABI-7RKHDG |
|
542 * to show the invalid DRM icon |
|
543 */ |
|
544 TMPXGeneralCategory cat = item.Category(); |
|
545 TBool checkViewRights = (cat==EMPXImage); |
|
546 |
|
547 if(iDRMUtility->CheckOpenRightsL(uri, checkViewRights)) |
|
548 { |
|
549 iHgGrid->ItemL(aItemIndex).SetFlags( |
|
550 CHgItem::EHgItemFlagsDrmRightsValid); |
|
551 } |
|
552 else |
|
553 { |
|
554 iHgGrid->ItemL(aItemIndex).SetFlags( |
|
555 CHgItem::EHgItemFlagsDrmRightsExpired); |
|
556 } |
|
557 } |
|
558 else |
|
559 { |
|
560 TMPXGeneralCategory cat = item.Category(); |
|
561 TBool checkViewRights = (cat==EMPXImage); |
|
562 |
|
563 if(iDRMUtility->CheckOpenRightsL(uri, checkViewRights)) |
|
564 { |
|
565 iHgGrid->ItemL(aItemIndex).SetFlags( |
|
566 CHgItem::EHgItemFlagsDrmRightsValid); |
|
567 } |
|
568 else |
|
569 { |
|
570 iHgGrid->ItemL(aItemIndex).SetFlags( |
|
571 CHgItem::EHgItemFlagsDrmRightsExpired); |
|
572 } |
|
573 } |
|
574 } |
|
575 } |
|
576 } |
|
577 |
|
578 if (aAttributes.Find(KMPXMediaGeneralDate, match) != KErrNotFound) |
|
579 { |
|
580 TTime time(0); |
|
581 if (item.GetDate(time)) |
|
582 { |
|
583 iHgGrid->ItemL(aItemIndex).SetTime(time); |
|
584 } |
|
585 |
|
586 // Sets up TLS, must be done before FeatureManager is used. |
|
587 FeatureManager::InitializeLibL(); |
|
588 |
|
589 if (FeatureManager::FeatureSupported(KFeatureIdSeamlessLinks)) |
|
590 { |
|
591 if (iDownloadsPlugin && mediaCount > iHgGrid->ItemsOnScreen() |
|
592 && aItemIndex == 2) |
|
593 { |
|
594 if (iMediaList.Item(0).IsStatic()) |
|
595 { |
|
596 iHgGrid->ItemL(0).SetTime(time); // Image Downloads link Icon |
|
597 } |
|
598 if (iMediaList.Item(1).IsStatic()) |
|
599 { |
|
600 iHgGrid->ItemL(1).SetTime(time); // Video Downloads link Icon |
|
601 } |
|
602 } |
|
603 } |
|
604 |
|
605 // Frees the TLS. Must be done after FeatureManager is used. |
|
606 FeatureManager::UnInitializeLib(); |
|
607 } |
|
608 |
|
609 if (aAttributes.Find(KMPXMediaGeneralCategory, match) != KErrNotFound) |
|
610 { |
|
611 if (item.Category() == EMPXVideo) |
|
612 { |
|
613 iHgGrid->ItemL(aItemIndex).SetFlags(CHgItem::EHgItemFlagsVideo); |
|
614 } |
|
615 } |
|
616 } |
|
617 |
|
618 |