|
1 /* |
|
2 * Copyright (c) 2006 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: Listbox array for podcast collection view container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <StringLoader.h> |
|
21 #include <gulicon.h> |
|
22 #include <AknsSkinInstance.h> |
|
23 #include <AknUtils.h> |
|
24 #include <AknsUtils.h> |
|
25 #include <AknIconUtils.h> |
|
26 #include <aknconsts.h> |
|
27 #include <AknIconArray.h> |
|
28 #include <avkon.mbg> |
|
29 #include <f32file.h> |
|
30 #include <data_caging_path_literals.hrh> |
|
31 #include <mpxmedia.h> |
|
32 #include <mpxmediacontainerdefs.h> |
|
33 #include <mpxmediageneraldefs.h> |
|
34 #include <mpxmediaarray.h> |
|
35 #include <mpxlog.h> |
|
36 #include <mpxpodcastcollectionview.mbg> |
|
37 #include <mpxpodcastdefs.h> // Podcast specific |
|
38 #include <mpxplaybackframeworkdefs.h> |
|
39 #include <mpxpodcastcollectionview.rsg> |
|
40 #include <mpxuser.h> |
|
41 #include <mpxcommonuihelper.h> |
|
42 #include "mpxcommoncontainer.hrh" |
|
43 #include "mpxpodcastcollectionview.hrh" |
|
44 #include "mpxcommonlistboxarrayobserver.h" |
|
45 #include "mpxpodcastcollectionviewlistboxarray.h" |
|
46 |
|
47 // CONSTANTS |
|
48 _LIT( KMPXCommonListboxFormatString, "%d\t%S" ); |
|
49 _LIT( KMPXTab, "\t" ); |
|
50 _LIT( KMPXPodcastCollectionViewIconFile, "mpxpodcastcollectionview.mbm" ); |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Two-phased constructor. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CMPXPodcastCollectionViewListBoxArray* CMPXPodcastCollectionViewListBoxArray::NewL() |
|
59 { |
|
60 MPX_FUNC( "CMPXPodcastCollectionViewListBoxArray::NewL" ); |
|
61 CMPXPodcastCollectionViewListBoxArray* self = |
|
62 new ( ELeave ) CMPXPodcastCollectionViewListBoxArray(); |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CMPXCommonListBoxArrayBase::CMPXCommonListBoxArrayBase |
|
71 // C++ default constructor can NOT contain any code, that |
|
72 // might leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CMPXPodcastCollectionViewListBoxArray::CMPXPodcastCollectionViewListBoxArray() : |
|
76 CMPXCommonListBoxArrayBase() |
|
77 { |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // Destructor. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CMPXPodcastCollectionViewListBoxArray::~CMPXPodcastCollectionViewListBoxArray() |
|
85 { |
|
86 MPX_FUNC( "CMPXPodcastCollectionViewListBoxArray::~CMPXPodcastCollectionViewListBoxArray" ); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // Destructor. |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CMPXPodcastCollectionViewListBoxArray::ConstructL() |
|
94 { |
|
95 MPX_FUNC( "CMPXPodcastCollectionViewListBoxArray::ConstructL" ); |
|
96 iMMCDrive = CMPXCommonUiHelper::MMCDriveNumber(); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Sets playback status |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 TInt CMPXPodcastCollectionViewListBoxArray::SetPlaybackStatusByIdL( |
|
104 TMPXItemId aId, TMPXPlaybackState aStatus ) |
|
105 { |
|
106 MPX_FUNC( "CMPXPodcastCollectionViewListBoxArray::SetPlaybackStatusById" ); |
|
107 if ( iMedia ) |
|
108 { |
|
109 ASSERT( iMedia ); |
|
110 TInt index( KErrNotFound ); |
|
111 TInt count( iMedia->Count() ); |
|
112 |
|
113 for ( TInt i = 0; i < count; i++ ) |
|
114 { |
|
115 CMPXMedia* entry( iMedia->AtL( i ) ); |
|
116 if( entry->IsSupported( KMPXMediaGeneralId ) ) |
|
117 { |
|
118 TMPXItemId id( |
|
119 entry->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
120 |
|
121 if ( id == aId ) |
|
122 { |
|
123 index = i; |
|
124 break; |
|
125 } |
|
126 |
|
127 } |
|
128 } |
|
129 |
|
130 return SetPlaybackStatusByIndex( index, aStatus ); |
|
131 } |
|
132 |
|
133 return KErrNotFound; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Gets the index for the song that's currently playing |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 TInt CMPXPodcastCollectionViewListBoxArray::GetPlaybackIndex() const |
|
141 { |
|
142 MPX_FUNC( "CMPXCollectionViewListBoxArray::GetPlaybackIndex" ); |
|
143 return iIndex; |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // Get array of indicator icon indices at the specified view index |
|
148 // Only used when using Hitchcock container. |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 RArray<TInt> CMPXPodcastCollectionViewListBoxArray::IndicatorIconIndicesL( |
|
152 TInt aIndex ) |
|
153 { |
|
154 RArray<TInt> iconIndices; |
|
155 TInt index( MapListBoxIndexToArrayIndex( aIndex ) ); |
|
156 |
|
157 CMPXMedia* entry( iMedia->AtL( index ) ); |
|
158 |
|
159 TMPXPodcastType type = EMPXPodcastNoType; |
|
160 TMPXPodcastCategory category = EMPXUnknown; |
|
161 if ( entry->IsSupported( KMPXMediaPodcastType ) ) |
|
162 { |
|
163 type = entry->ValueTObjectL<TMPXPodcastType>( KMPXMediaPodcastType ); |
|
164 } |
|
165 if ( entry->IsSupported( KMPXMediaPodcastCategoryGroup ) ) |
|
166 { |
|
167 category = entry->ValueTObjectL<TMPXPodcastCategory>( KMPXMediaPodcastCategoryGroup ); |
|
168 } |
|
169 TUint flags(0); |
|
170 if ( entry->IsSupported( KMPXMediaGeneralFlags ) ) |
|
171 { |
|
172 flags = entry->ValueTObjectL<TUint>( KMPXMediaGeneralFlags ); |
|
173 } |
|
174 |
|
175 MPX_DEBUG4( "CMPXPodcastCollectionViewListBoxArray::IndicatorIconIndicesL (%d) Type: %d, Category: %d", aIndex, type, category ); |
|
176 |
|
177 |
|
178 // playback status icon |
|
179 if ( iIndex == index ) |
|
180 { |
|
181 switch ( iPbState ) |
|
182 { |
|
183 case EPbStatePlaying: |
|
184 { |
|
185 iconIndices.Append( EMPXPodClvIconPlay ); |
|
186 break; |
|
187 } |
|
188 case EPbStatePaused: |
|
189 { |
|
190 iconIndices.Append( EMPXPodClvIconPause ); |
|
191 break; |
|
192 } |
|
193 default: |
|
194 { |
|
195 // other playback states, not handled |
|
196 break; |
|
197 } |
|
198 } |
|
199 } |
|
200 |
|
201 if ( type == EMPXPodcastItem ) |
|
202 { |
|
203 TBool checkFlag(ETrue); |
|
204 switch( category ) |
|
205 { |
|
206 case EMPXEpisode: |
|
207 { |
|
208 iconIndices.Append( EMPXPodClvIconEpisode ); |
|
209 break; |
|
210 } |
|
211 case EMPXNew: |
|
212 { |
|
213 if ( entry->IsSupported(KMPXMediaPodcastIsPlaying) && |
|
214 entry->ValueTObjectL<TBool>(KMPXMediaPodcastIsPlaying) ) |
|
215 { |
|
216 iconIndices.Append( EMPXPodClvIconPartplay ); |
|
217 } |
|
218 else if ( iIndex == aIndex && |
|
219 (iPbState == EPbStatePlaying || iPbState == EPbStatePaused) ) |
|
220 { |
|
221 entry->SetTObjectValueL<TBool>(KMPXMediaPodcastIsPlaying, ETrue); |
|
222 iconIndices.Append( EMPXPodClvIconPartplay ); |
|
223 } |
|
224 else |
|
225 { |
|
226 iconIndices.Append( EMPXPodClvIconNew ); |
|
227 } |
|
228 |
|
229 break; |
|
230 } |
|
231 case EMPXPartlyPlayed: |
|
232 { |
|
233 iconIndices.Append( EMPXPodClvIconPartplay ); |
|
234 break; |
|
235 } |
|
236 case EMPXCompletelyPlayed: |
|
237 { |
|
238 iconIndices.Append( EMPXPodClvIconCompplay ); |
|
239 break; |
|
240 } |
|
241 case EMPXPodcastFile: |
|
242 { |
|
243 checkFlag = EFalse; |
|
244 iconIndices.Append( EMPXPodClvIconFolder ); |
|
245 break; |
|
246 } |
|
247 default: |
|
248 { |
|
249 checkFlag = EFalse; |
|
250 iconIndices.Append( EMPXPodClvIconUnknowFile ); |
|
251 break; |
|
252 } |
|
253 } |
|
254 |
|
255 if ( checkFlag ) |
|
256 { |
|
257 if ( flags & KMPXMediaGeneralFlagsIsCorrupted ) |
|
258 { |
|
259 iconIndices.Append( EMPXPodClvIconCorrupt ); |
|
260 } |
|
261 else if ( flags & KMPXMediaGeneralFlagsIsInvalid ) |
|
262 { |
|
263 iconIndices.Append( EMPXPodClvIconBroken ); |
|
264 } |
|
265 else if ( flags & KMPXMediaGeneralFlagsIsDrmLicenceInvalid ) |
|
266 { |
|
267 iconIndices.Append( EMPXPodClvIconBroken ); |
|
268 } |
|
269 // else do nothing |
|
270 } |
|
271 } |
|
272 |
|
273 TInt driveNum = ( ( flags ) & ( KMPXMediaGeneralFlagsDriveInfo ) ); |
|
274 if ( driveNum == iMMCDrive ) |
|
275 { |
|
276 // The MMC icon is displayed in the first Indicator slot |
|
277 iconIndices.Append( EMPXPodClvIconMMC ); |
|
278 } |
|
279 |
|
280 return iconIndices; |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CMPXCommonListBoxArrayBase::MdcaPoint |
|
285 // indexes into a descriptor array. |
|
286 // (other items were commented in a header). |
|
287 // ----------------------------------------------------------------------------- |
|
288 // |
|
289 TPtrC CMPXPodcastCollectionViewListBoxArray::MdcaPoint( TInt aIndex ) const |
|
290 { |
|
291 TPtrC item( KNullDesC ); |
|
292 TRAP_IGNORE( item.Set( DoMdcaPointL( aIndex ) ) ); |
|
293 return item; |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CMPXCommonListBoxArrayBase::CreateIconArrayL |
|
298 // creates icon array. |
|
299 // ----------------------------------------------------------------------------- |
|
300 // |
|
301 CAknIconArray* CMPXPodcastCollectionViewListBoxArray::CreateIconArrayL() |
|
302 { |
|
303 MPX_FUNC( "CMPXPodcastCollectionViewListBoxArray::CreateIconArrayL" ); |
|
304 TParse mbmFileName; |
|
305 mbmFileName.Set( KMPXPodcastCollectionViewIconFile, |
|
306 &KDC_APP_RESOURCE_DIR, NULL ); |
|
307 TFileName iconFile( mbmFileName.FullName() ); |
|
308 User::LeaveIfError( MPXUser::CompleteWithDllPath( iconFile ) ); |
|
309 |
|
310 // Prepare icon array for listbox |
|
311 CAknIconArray* iconArray = new ( ELeave ) CAknIconArray( 21 ); // magic: array granularity |
|
312 |
|
313 // Update the enums when this list is updated |
|
314 AppendColorIconToArrayL( iconArray, |
|
315 KAknsIIDQgnIndiMarkedAdd, |
|
316 KAknsIIDQsnIconColors, |
|
317 EAknsCIQsnIconColorsCG13, |
|
318 KAvkonBitmapFile, |
|
319 EMbmAvkonQgn_indi_marked_add, |
|
320 EMbmAvkonQgn_indi_marked_add_mask); |
|
321 AppendColorIconToArrayL( iconArray, |
|
322 KAknsIIDQgnPropEmpty, |
|
323 KAknsIIDNone, |
|
324 EAknsMinorNone, |
|
325 KAvkonBitmapFile, |
|
326 EMbmAvkonQgn_prop_empty, |
|
327 EMbmAvkonQgn_prop_empty_mask); |
|
328 AppendColorIconToArrayL( iconArray, |
|
329 KAknsIIDQgnGrafMupLstPdcAdded, |
|
330 KAknsIIDNone, |
|
331 EAknsMinorNone, |
|
332 iconFile, |
|
333 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_added, |
|
334 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_added_mask ); //1 |
|
335 AppendColorIconToArrayL( iconArray, |
|
336 KAknsIIDQgnGrafMupLstPdcAuto, |
|
337 KAknsIIDNone, |
|
338 EAknsMinorNone, |
|
339 iconFile, |
|
340 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_auto, |
|
341 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_auto_mask ); //2 |
|
342 AppendColorIconToArrayL( iconArray, |
|
343 KAknsIIDQgnGrafMupLstPdcCateg, |
|
344 KAknsIIDNone, |
|
345 EAknsMinorNone, |
|
346 iconFile, |
|
347 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_categ, |
|
348 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_categ_mask ); //3 |
|
349 AppendColorIconToArrayL( iconArray, |
|
350 KAknsIIDQgnGrafMupLstPdcCompplay, |
|
351 KAknsIIDNone, |
|
352 EAknsMinorNone, |
|
353 iconFile, |
|
354 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_compplay, |
|
355 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_compplay_mask ); //4 |
|
356 AppendColorIconToArrayL( iconArray, |
|
357 KAknsIIDQgnGrafMupLstPdcDate, |
|
358 KAknsIIDNone, |
|
359 EAknsMinorNone, |
|
360 iconFile, |
|
361 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_date, |
|
362 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_date_mask ); //5 |
|
363 AppendColorIconToArrayL( iconArray, |
|
364 KAknsIIDQgnGrafMupLstPdcEpisode, |
|
365 KAknsIIDNone, |
|
366 EAknsMinorNone, |
|
367 iconFile, |
|
368 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_episode, |
|
369 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_episode_mask ); //6 |
|
370 AppendColorIconToArrayL( iconArray, |
|
371 KAknsIIDQgnGrafMupLstPdcNew, |
|
372 KAknsIIDNone, |
|
373 EAknsMinorNone, |
|
374 iconFile, |
|
375 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_new, |
|
376 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_new_mask ); //7 |
|
377 AppendColorIconToArrayL( iconArray, |
|
378 KAknsIIDQgnGrafMupLstPdcNoplay, |
|
379 KAknsIIDNone, |
|
380 EAknsMinorNone, |
|
381 iconFile, |
|
382 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_noplay, |
|
383 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_noplay_mask ); //8 |
|
384 AppendColorIconToArrayL( iconArray, |
|
385 KAknsIIDQgnGrafMupLstPdcPartplay, |
|
386 KAknsIIDNone, |
|
387 EAknsMinorNone, |
|
388 iconFile, |
|
389 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_partplay, |
|
390 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_partplay_mask ); //9 |
|
391 AppendColorIconToArrayL( iconArray, |
|
392 KAknsIIDQgnGrafMupLstPdcTitle, |
|
393 KAknsIIDNone, |
|
394 EAknsMinorNone, |
|
395 iconFile, |
|
396 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_title, |
|
397 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_pdc_title_mask ); //10 |
|
398 AppendColorIconToArrayL( iconArray, |
|
399 KAknsIIDQgnMenuFolderApps, |
|
400 KAknsIIDNone, |
|
401 EAknsMinorNone, |
|
402 iconFile, |
|
403 EMbmMpxpodcastcollectionviewQgn_menu_folder_apps, |
|
404 EMbmMpxpodcastcollectionviewQgn_menu_folder_apps_mask ); //11 |
|
405 AppendColorIconToArrayL( iconArray, |
|
406 KAknsIIDQgnPropUnknown, |
|
407 KAknsIIDNone, |
|
408 EAknsMinorNone, |
|
409 iconFile, |
|
410 EMbmMpxpodcastcollectionviewQgn_prop_unknown, |
|
411 EMbmMpxpodcastcollectionviewQgn_prop_unknown_mask ); //12 |
|
412 AppendColorIconToArrayL( iconArray, |
|
413 KAknsIIDQgnIndiMupPlay, |
|
414 KAknsIIDQsnIconColors, |
|
415 EAknsCIQsnIconColorsCG26, |
|
416 iconFile, |
|
417 EMbmMpxpodcastcollectionviewQgn_graf_mup_npv_icon_play, |
|
418 EMbmMpxpodcastcollectionviewQgn_graf_mup_npv_icon_play_mask ); //13 |
|
419 AppendColorIconToArrayL( iconArray, |
|
420 KAknsIIDQgnIndiMupPause, |
|
421 KAknsIIDQsnIconColors, |
|
422 EAknsCIQsnIconColorsCG26, |
|
423 iconFile, |
|
424 EMbmMpxpodcastcollectionviewQgn_graf_mup_npv_icon_pause, |
|
425 EMbmMpxpodcastcollectionviewQgn_graf_mup_npv_icon_pause_mask ); // 14 |
|
426 AppendColorIconToArrayL( iconArray, |
|
427 KAknsIIDQgnIndiMupForwAdd, |
|
428 KAknsIIDQsnIconColors, |
|
429 EAknsCIQsnIconColorsCG26, |
|
430 iconFile, |
|
431 EMbmMpxpodcastcollectionviewQgn_indi_mup_forw_add, |
|
432 EMbmMpxpodcastcollectionviewQgn_indi_mup_forw_add_mask ); // 15 |
|
433 AppendColorIconToArrayL( iconArray, |
|
434 KAknsIIDQgnIndiMupRewAdd, |
|
435 KAknsIIDQsnIconColors, |
|
436 EAknsCIQsnIconColorsCG26, |
|
437 iconFile, |
|
438 EMbmMpxpodcastcollectionviewQgn_indi_mup_rew_add, |
|
439 EMbmMpxpodcastcollectionviewQgn_indi_mup_rew_add_mask ); // 16 |
|
440 AppendColorIconToArrayL( iconArray, |
|
441 KAknsIIDQgnIndiMmcAdd, |
|
442 KAknsIIDQsnIconColors, |
|
443 EAknsCIQsnIconColorsCG26, |
|
444 iconFile, |
|
445 EMbmMpxpodcastcollectionviewQgn_indi_mmc_add, |
|
446 EMbmMpxpodcastcollectionviewQgn_indi_mmc_add_mask ); // 17 |
|
447 AppendColorIconToArrayL( iconArray, |
|
448 KAknsIIDQgnGrafMupLstBrokenpodc, |
|
449 KAknsIIDNone, |
|
450 EAknsMinorNone, |
|
451 iconFile, |
|
452 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_brokenpodc, |
|
453 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_brokenpodc_mask ); // 18 |
|
454 AppendColorIconToArrayL( iconArray, |
|
455 KAknsIIDQgnGrafMupLstCorruptpodc, |
|
456 KAknsIIDNone, |
|
457 EAknsMinorNone, |
|
458 iconFile, |
|
459 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_corruptpodc, |
|
460 EMbmMpxpodcastcollectionviewQgn_graf_mup_lst_corruptpodc_mask ); // 19 |
|
461 |
|
462 return iconArray; |
|
463 } |
|
464 |
|
465 // ----------------------------------------------------------------------------- |
|
466 // Appends media array to the current array |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 void CMPXPodcastCollectionViewListBoxArray::AppendMediaL( const CMPXMedia& aMedia ) |
|
470 { |
|
471 MPX_FUNC( "CMPXCollectionViewListBoxArray::AppendMediaL" ); |
|
472 CMPXCommonListBoxArrayBase::AppendMediaL( aMedia ); |
|
473 if ( iMedia ) |
|
474 { |
|
475 TInt entriesCount = iMedia->Count(); |
|
476 if ( entriesCount > 0 ) |
|
477 { |
|
478 CMPXMedia* origMedia( iMedia->AtL( entriesCount - 1 ) ); |
|
479 if ( origMedia->ValueText(KMPXMediaGeneralTitle ).Length() == 0 ) |
|
480 { |
|
481 HBufC* text = StringLoader::LoadLC( |
|
482 R_MPX_QTN_NMP_UNKNOWN_TITLE ); |
|
483 origMedia->SetTextValueL(KMPXMediaGeneralTitle, |
|
484 *text ); |
|
485 CleanupStack::PopAndDestroy( text ); |
|
486 } |
|
487 } |
|
488 } |
|
489 if ( iContainerMedia ) |
|
490 { |
|
491 if ( iContainerMedia->IsSupported(KMPXMediaGeneralTitle) ) |
|
492 { |
|
493 if ( iContainerMedia->ValueText(KMPXMediaGeneralTitle).Length() == 0 ) |
|
494 { |
|
495 HBufC* text = StringLoader::LoadLC( |
|
496 R_MPX_QTN_NMP_UNKNOWN_TITLE ); |
|
497 iContainerMedia->SetTextValueL(KMPXMediaGeneralTitle, |
|
498 *text ); |
|
499 CleanupStack::PopAndDestroy( text ); |
|
500 } |
|
501 } |
|
502 } |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // Checks if the current item is a broken link |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 TBool CMPXPodcastCollectionViewListBoxArray::IsItemBrokenLinkL( TInt aIndex ) |
|
510 { |
|
511 TBool ret( EFalse ); |
|
512 if ( iMedia ) |
|
513 { |
|
514 CMPXMedia* entry( iMedia->AtL( aIndex ) ); |
|
515 TUint flags( 0 ); |
|
516 if(entry->IsSupported(KMPXMediaGeneralFlags)) |
|
517 { |
|
518 flags = entry->ValueTObjectL<TUint>( KMPXMediaGeneralFlags ); |
|
519 } |
|
520 |
|
521 ret = ( ( flags ) & ( KMPXMediaGeneralFlagsIsInvalid ) ); |
|
522 } |
|
523 return ret; |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // Checks if the current item is corrupted |
|
528 // ----------------------------------------------------------------------------- |
|
529 // |
|
530 TBool CMPXPodcastCollectionViewListBoxArray::IsItemCorruptedL( TInt aIndex ) |
|
531 { |
|
532 TBool ret( EFalse ); |
|
533 if ( iMedia ) |
|
534 { |
|
535 CMPXMedia* entry( iMedia->AtL( aIndex ) ); |
|
536 TUint flags( 0 ); |
|
537 if(entry->IsSupported( KMPXMediaGeneralFlags)) |
|
538 { |
|
539 flags = entry->ValueTObjectL<TUint>( KMPXMediaGeneralFlags ); |
|
540 } |
|
541 ret = ( ( flags ) & ( KMPXMediaGeneralFlagsIsCorrupted ) ); |
|
542 } |
|
543 return ret; |
|
544 } |
|
545 |
|
546 // ----------------------------------------------------------------------------- |
|
547 // CMPXCommonListBoxArrayBase::DoMdcaPointL |
|
548 // indexes into a descriptor array. |
|
549 // (other items were commented in a header). |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 TPtrC CMPXPodcastCollectionViewListBoxArray::DoMdcaPointL( TInt aIndex ) const |
|
553 { |
|
554 MPX_FUNC( "CMPXPodcastCollectionViewListBoxArray::DoMdcaPointL" ); |
|
555 MPX_DEBUG3( "CMPXPodcastCollectionViewListBoxArray::DoMdcaPointL media count = %d aIndex = %d", MdcaCount(), aIndex ); |
|
556 TInt index( MapListBoxIndexToArrayIndex( aIndex ) ); |
|
557 |
|
558 CMPXMedia* entry( iMedia->AtL( index ) ); |
|
559 |
|
560 if( entry->IsSupported( KMPXMediaGeneralTitle )) |
|
561 { |
|
562 const TDesC& title = entry->ValueText(KMPXMediaGeneralTitle); |
|
563 TMPXPodcastType type = EMPXPodcastNoType; |
|
564 TMPXPodcastCategory category = EMPXUnknown; |
|
565 |
|
566 if (entry->IsSupported(KMPXMediaPodcastType)) |
|
567 { |
|
568 type = |
|
569 entry->ValueTObjectL<TMPXPodcastType>(KMPXMediaPodcastType); |
|
570 |
|
571 } |
|
572 if (entry->IsSupported(KMPXMediaPodcastCategoryGroup)) |
|
573 { |
|
574 category = |
|
575 entry->ValueTObjectL<TMPXPodcastCategory>(KMPXMediaPodcastCategoryGroup); |
|
576 } |
|
577 TUint flags(0); |
|
578 if( entry->IsSupported( KMPXMediaGeneralFlags ) ) |
|
579 { |
|
580 flags = entry->ValueTObjectL<TUint>( KMPXMediaGeneralFlags ); |
|
581 } |
|
582 |
|
583 MPX_DEBUG3( "CMPXPodcastCollectionViewListBoxArray::MdcaPoint (%d) Name: %S", aIndex, &title ); |
|
584 MPX_DEBUG4( "CMPXPodcastCollectionViewListBoxArray::MdcaPoint (%d) Type: %d, Category: %d", aIndex, type, category ); |
|
585 TInt iconID; |
|
586 if ( type == EMPXPodcastGroup ) |
|
587 { |
|
588 switch( category ) |
|
589 { |
|
590 case EMPXAll: |
|
591 { |
|
592 iconID = EMPXPodClvIconEpisode; |
|
593 break; |
|
594 } |
|
595 case EMPXRecentlyAdded: |
|
596 case EMPXNotYetPlayed: |
|
597 { |
|
598 iconID = EMPXPodClvIconAuto; |
|
599 break; |
|
600 } |
|
601 case EMPXPubDate: |
|
602 { |
|
603 iconID = EMPXPodClvIconDate; |
|
604 break; |
|
605 } |
|
606 case EMPXTitle: |
|
607 { |
|
608 iconID = EMPXPodClvIconTitle; |
|
609 break; |
|
610 } |
|
611 case EMPXPodcastFile: |
|
612 { |
|
613 iconID = EMPXPodClvIconFolder; |
|
614 break; |
|
615 } |
|
616 default: |
|
617 { |
|
618 iconID = EMPXPodClvIconUnknowFile; |
|
619 break; |
|
620 } |
|
621 } // Switch |
|
622 } |
|
623 else if ( type == EMPXPodcastItem ) |
|
624 { |
|
625 TBool checkFlag(ETrue); |
|
626 |
|
627 switch( category ) |
|
628 { |
|
629 case EMPXEpisode: |
|
630 { |
|
631 iconID = EMPXPodClvIconEpisode; |
|
632 break; |
|
633 } |
|
634 case EMPXNew: |
|
635 { |
|
636 if(entry->IsSupported(KMPXMediaPodcastIsPlaying) && |
|
637 entry->ValueTObjectL<TBool>(KMPXMediaPodcastIsPlaying)) |
|
638 { |
|
639 iconID = EMPXPodClvIconPartplay; |
|
640 } |
|
641 else if(iIndex == aIndex && |
|
642 (iPbState == EPbStatePlaying || |
|
643 iPbState == EPbStatePaused)) |
|
644 { |
|
645 entry->SetTObjectValueL<TBool> ( |
|
646 KMPXMediaPodcastIsPlaying, ETrue); |
|
647 iconID = EMPXPodClvIconPartplay; |
|
648 } |
|
649 else |
|
650 { |
|
651 iconID = EMPXPodClvIconNew; |
|
652 } |
|
653 |
|
654 break; |
|
655 } |
|
656 case EMPXPartlyPlayed: |
|
657 { |
|
658 iconID = EMPXPodClvIconPartplay; |
|
659 break; |
|
660 } |
|
661 case EMPXCompletelyPlayed: |
|
662 { |
|
663 iconID = EMPXPodClvIconCompplay; |
|
664 break; |
|
665 } |
|
666 case EMPXPodcastFile: |
|
667 { |
|
668 checkFlag = EFalse; |
|
669 iconID = EMPXPodClvIconFolder; |
|
670 break; |
|
671 } |
|
672 default: |
|
673 { |
|
674 checkFlag = EFalse; |
|
675 iconID = EMPXPodClvIconUnknowFile; |
|
676 break; |
|
677 } |
|
678 } // Switch |
|
679 |
|
680 if(checkFlag) |
|
681 { |
|
682 if ( flags & KMPXMediaGeneralFlagsIsCorrupted ) |
|
683 { |
|
684 iconID = EMPXPodClvIconCorrupt; |
|
685 } |
|
686 else if ( flags & KMPXMediaGeneralFlagsIsInvalid ) |
|
687 { |
|
688 iconID = EMPXPodClvIconBroken; |
|
689 } |
|
690 else if ( flags & KMPXMediaGeneralFlagsIsDrmLicenceInvalid ) |
|
691 { |
|
692 iconID = EMPXPodClvIconBroken; |
|
693 } |
|
694 // else do nothing |
|
695 } |
|
696 } |
|
697 else |
|
698 { |
|
699 iconID = EMPXPodClvIconUnknowFile; |
|
700 } |
|
701 |
|
702 TPtrC item; |
|
703 |
|
704 TPtr ptr = iItem->Des(); |
|
705 ptr.Zero(); |
|
706 ptr.Format( KMPXCommonListboxFormatString, iconID, &title ); |
|
707 |
|
708 // playback status icon |
|
709 if ( iIndex == index ) |
|
710 { |
|
711 if ( iPbState == EPbStatePlaying ) |
|
712 { |
|
713 ptr.Append( KMPXTab ); |
|
714 ptr.AppendNum( EMPXPodClvIconPlay ); |
|
715 } |
|
716 else if ( iPbState == EPbStatePaused ) |
|
717 { |
|
718 ptr.Append( KMPXTab ); |
|
719 ptr.AppendNum( EMPXPodClvIconPause ); |
|
720 } |
|
721 else if ( iPbState == EPbStateSeekingForward ) |
|
722 { |
|
723 ptr.Append( KMPXTab ); |
|
724 ptr.AppendNum( EMPXPodClvIconForward ); |
|
725 } |
|
726 else if ( iPbState == EPbStateSeekingBackward ) |
|
727 { |
|
728 ptr.Append( KMPXTab ); |
|
729 ptr.AppendNum( EMPXPodClvIconRewind ); |
|
730 } |
|
731 else |
|
732 { |
|
733 // Do nothing |
|
734 } |
|
735 } |
|
736 |
|
737 // mmc icon |
|
738 TInt driveNum = ( ( flags ) & ( KMPXMediaGeneralFlagsDriveInfo ) ); |
|
739 if( driveNum == iMMCDrive ) |
|
740 { |
|
741 ptr.Append( KMPXTab ); |
|
742 ptr.AppendNum( EMPXPodClvIconMMC ); |
|
743 } |
|
744 |
|
745 item.Set( *iItem ); |
|
746 return item; |
|
747 } |
|
748 else |
|
749 { |
|
750 TPtrC item( KNullDesC ); |
|
751 return item; |
|
752 } |
|
753 } |
|
754 |
|
755 // ----------------------------------------------------------------------------- |
|
756 // Append icon to array |
|
757 // ----------------------------------------------------------------------------- |
|
758 // |
|
759 void CMPXPodcastCollectionViewListBoxArray::AppendColorIconToArrayL( |
|
760 CAknIconArray* aArray, |
|
761 const TAknsItemID& aID, |
|
762 const TAknsItemID& aColorId, |
|
763 TInt aColorIndex, |
|
764 const TDesC& aMbmFile, |
|
765 TInt aBitmapId, |
|
766 TInt aMaskId ) |
|
767 { |
|
768 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
769 |
|
770 CFbsBitmap* bitmap = NULL; |
|
771 CFbsBitmap* mask = NULL; |
|
772 |
|
773 if ( aColorId == KAknsIIDNone ) |
|
774 { |
|
775 // do not use theme color, use the default color from the file |
|
776 AknsUtils::CreateIconLC( skin, aID, |
|
777 bitmap, mask, aMbmFile, aBitmapId, aMaskId ); |
|
778 } |
|
779 else |
|
780 { |
|
781 // use theme color |
|
782 AknsUtils::CreateColorIconLC( skin, aID, aColorId, aColorIndex, |
|
783 bitmap, mask, aMbmFile, aBitmapId, aMaskId, KRgbBlack ); |
|
784 } |
|
785 |
|
786 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
787 icon->SetBitmapsOwnedExternally( EFalse ); |
|
788 |
|
789 // icon now owns the bitmaps, no need to keep on cleanup stack. |
|
790 CleanupStack::Pop( 2 ); // mask, bitmap |
|
791 bitmap = NULL; |
|
792 mask = NULL; |
|
793 |
|
794 CleanupStack::PushL( icon ); |
|
795 aArray->AppendL( icon ); |
|
796 // aArray now owns the icon, no need to delete. |
|
797 CleanupStack::Pop( icon ); |
|
798 } |
|
799 |
|
800 // ----------------------------------------------------------------------------- |
|
801 // Maps list box index to array index in reorder mode |
|
802 // ----------------------------------------------------------------------------- |
|
803 // |
|
804 TInt CMPXPodcastCollectionViewListBoxArray::MapListBoxIndexToArrayIndex( |
|
805 TInt aIndex ) const |
|
806 { |
|
807 TInt index = aIndex; |
|
808 |
|
809 if ( ( iReorder ) && ( iOriginalIndex != iMovedIndex ) ) |
|
810 { |
|
811 if ( iMovedIndex > iOriginalIndex ) |
|
812 { |
|
813 // moved down |
|
814 if ( aIndex < iOriginalIndex ) |
|
815 { |
|
816 // do nothing |
|
817 } |
|
818 else if ( aIndex > iMovedIndex ) |
|
819 { |
|
820 // do nothing |
|
821 } |
|
822 else if ( aIndex < iMovedIndex ) |
|
823 { |
|
824 // between original index and moved index |
|
825 index = aIndex + 1; |
|
826 } |
|
827 else if ( aIndex == iMovedIndex ) |
|
828 { |
|
829 index = iOriginalIndex; |
|
830 } |
|
831 } |
|
832 else |
|
833 { |
|
834 // moved up |
|
835 if ( aIndex > iOriginalIndex ) |
|
836 { |
|
837 // do nothing |
|
838 } |
|
839 else if ( aIndex < iMovedIndex ) |
|
840 { |
|
841 // do nothing |
|
842 } |
|
843 else if ( aIndex > iMovedIndex ) |
|
844 { |
|
845 // between original index and moved index |
|
846 index = aIndex - 1; |
|
847 } |
|
848 else if ( aIndex == iMovedIndex ) |
|
849 { |
|
850 index = iOriginalIndex; |
|
851 } |
|
852 } |
|
853 } |
|
854 |
|
855 return index; |
|
856 } |
|
857 |
|
858 // --------------------------------------------------------------------------- |
|
859 // Sets playback status |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 TInt CMPXPodcastCollectionViewListBoxArray::SetPlaybackStatusByIndex( |
|
863 TInt aIndex, TMPXPlaybackState aStatus ) |
|
864 { |
|
865 MPX_FUNC( "CMPXPodcastCollectionViewListBoxArray::SetPlaybackStatusByIndex" ); |
|
866 TInt ret( iIndex ); |
|
867 iIndex = aIndex; |
|
868 |
|
869 // Not to display seeking icons for seeking mode |
|
870 if ( aStatus != EPbStateSeekingForward && |
|
871 aStatus != EPbStateSeekingBackward ) |
|
872 { |
|
873 iPbState = aStatus; |
|
874 } |
|
875 return ret; |
|
876 } |
|
877 |
|
878 // End of File |