|
1 /* |
|
2 * Copyright (c) 2008 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 the License "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: Class for providing video list.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <collate.h> |
|
22 #include <mpxmedia.h> |
|
23 #include <mpxmediaarray.h> |
|
24 #include <mpxmediageneraldefs.h> |
|
25 #include "vcxhgmyvideosvideolist.h" |
|
26 #include "vcxhgmyvideosvideolistitem.h" |
|
27 #include "IptvDebug.h" |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CVcxHgMyVideosVideoList::NewL() |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CVcxHgMyVideosVideoList* CVcxHgMyVideosVideoList::NewL() |
|
36 { |
|
37 CVcxHgMyVideosVideoList* self = |
|
38 CVcxHgMyVideosVideoList::NewLC(); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CVcxHgMyVideosVideoList::NewLC() |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CVcxHgMyVideosVideoList* CVcxHgMyVideosVideoList::NewLC() |
|
48 { |
|
49 CVcxHgMyVideosVideoList* self = |
|
50 new (ELeave) CVcxHgMyVideosVideoList(); |
|
51 CleanupStack::PushL( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CVcxHgMyVideosVideoList::CVcxHgMyVideosVideoList() |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CVcxHgMyVideosVideoList::CVcxHgMyVideosVideoList() |
|
60 { |
|
61 // No implementation required. |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CVcxHgMyVideosVideoList::~CVcxHgMyVideosVideoList() |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CVcxHgMyVideosVideoList::~CVcxHgMyVideosVideoList() |
|
69 { |
|
70 RemoveVideoList(); |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CVcxHgMyVideosVideoList::RemoveVideoList() |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CVcxHgMyVideosVideoList::RemoveVideoList() |
|
78 { |
|
79 iVideoList.ResetAndDestroy(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CVcxHgMyVideosVideoList::ReplaceVideoListL() |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CVcxHgMyVideosVideoList::ReplaceVideoListL( CMPXMediaArray& aVideoList ) |
|
87 { |
|
88 IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoList::ReplaceVideoListL() - Enter" ); |
|
89 |
|
90 // Removes the all videos from array. |
|
91 RemoveVideoList(); |
|
92 |
|
93 TInt count = aVideoList.Count(); |
|
94 iVideoList.ReserveL( count ); |
|
95 for ( TInt i = 0; i < count; i++ ) |
|
96 { |
|
97 CMPXMedia* media = CMPXMedia::NewL( *( aVideoList[i] ) ); |
|
98 if ( media ) |
|
99 { |
|
100 CVcxHgMyVideosVideoListItem* item = CVcxHgMyVideosVideoListItem::NewLC( media ); |
|
101 iVideoList.AppendL( item ); |
|
102 CleanupStack::Pop( item ); |
|
103 } |
|
104 } |
|
105 IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoList::ReplaceVideoListL() - Exit" ); |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CVcxHgMyVideosVideoList::VideoCount() |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 TInt CVcxHgMyVideosVideoList::VideoCount() |
|
113 { |
|
114 return iVideoList.Count(); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CVcxHgMyVideosVideoList::VideoDownloadState() |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 TVcxMyVideosDownloadState CVcxHgMyVideosVideoList::VideoDownloadState( TInt aIndex ) |
|
122 { |
|
123 TVcxMyVideosDownloadState state( EVcxMyVideosDlStateNone ); |
|
124 |
|
125 if ( aIndex >= 0 && aIndex < iVideoList.Count() ) |
|
126 { |
|
127 state = iVideoList[aIndex]->DownloadState(); |
|
128 } |
|
129 return state; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CVcxHgMyVideosVideoList::GetOngoingDownloads() |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CVcxHgMyVideosVideoList::GetOngoingDownloads( RArray<TInt>& aDownloads ) |
|
137 { |
|
138 TInt count( iVideoList.Count() ); |
|
139 for ( TInt i = 0; i < count; i++ ) |
|
140 { |
|
141 if ( iVideoList[i]->DownloadState() != EVcxMyVideosDlStateNone ) |
|
142 { |
|
143 aDownloads.Append( i ); |
|
144 } |
|
145 } |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CVcxHgMyVideosVideoList::RemoveVideo() |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 TInt CVcxHgMyVideosVideoList::RemoveVideo( TMPXItemId aMpxItemId ) |
|
153 { |
|
154 TInt index = IndexByMPXItemId( aMpxItemId ); |
|
155 |
|
156 if ( index != KErrNotFound ) |
|
157 { |
|
158 delete iVideoList[index]; |
|
159 iVideoList.Remove( index ); |
|
160 } |
|
161 return index; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CVcxHgMyVideosVideoList::MPXMedia() |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 CMPXMedia* CVcxHgMyVideosVideoList::MPXMedia( TInt aIndex ) |
|
169 { |
|
170 if ( aIndex >= 0 && aIndex < iVideoList.Count() ) |
|
171 { |
|
172 return iVideoList[aIndex]->Media(); |
|
173 } |
|
174 return NULL; |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CVcxHgMyVideosVideoList::MPXMediaByUri() |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 CMPXMedia* CVcxHgMyVideosVideoList::MPXMediaByUri( const TDesC& aUri ) |
|
182 { |
|
183 CMPXMedia* media = NULL; |
|
184 TInt count( iVideoList.Count() ); |
|
185 |
|
186 for ( TInt i = 0; i < count; i++ ) |
|
187 { |
|
188 media = iVideoList[i]->Media(); |
|
189 |
|
190 if ( media && media->IsSupported( KMPXMediaGeneralUri ) ) |
|
191 { |
|
192 if ( aUri.CompareF( media->ValueText( KMPXMediaGeneralUri ) ) == 0 ) |
|
193 { |
|
194 return media; |
|
195 } |
|
196 } |
|
197 } |
|
198 return NULL; |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CVcxHgMyVideosVideoList::MPXMediaByMPXItemId() |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 CMPXMedia* CVcxHgMyVideosVideoList::MPXMediaByMPXItemId( TMPXItemId aMpxItemId ) |
|
206 { |
|
207 CMPXMedia* media = NULL; |
|
208 TInt count( iVideoList.Count() ); |
|
209 |
|
210 for ( TInt i = 0; i < count; i++ ) |
|
211 { |
|
212 media = iVideoList[i]->Media(); |
|
213 |
|
214 if ( media && media->IsSupported( KMPXMediaGeneralId ) ) |
|
215 { |
|
216 if ( aMpxItemId == media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ) |
|
217 { |
|
218 return media; |
|
219 } |
|
220 } |
|
221 } |
|
222 return NULL; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CVcxHgMyVideosVideoList::ArrayIndexToMpxItemIdL() |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 TMPXItemId CVcxHgMyVideosVideoList::ArrayIndexToMpxItemIdL( TInt aArrayIndex ) |
|
230 { |
|
231 if ( aArrayIndex < 0 || aArrayIndex >= iVideoList.Count() ) |
|
232 { |
|
233 User::Leave( KErrArgument ); |
|
234 } |
|
235 |
|
236 return iVideoList[aArrayIndex]->Media()->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CVcxHgMyVideosVideoList::IndexByMPXItemId() |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 TInt CVcxHgMyVideosVideoList::IndexByMPXItemId( TMPXItemId aMpxItemId ) |
|
244 { |
|
245 CMPXMedia* media = NULL; |
|
246 TInt count( iVideoList.Count() ); |
|
247 |
|
248 for ( TInt i = 0; i < count; i++ ) |
|
249 { |
|
250 media = iVideoList[i]->Media(); |
|
251 |
|
252 if ( media && media->IsSupported( KMPXMediaGeneralId ) ) |
|
253 { |
|
254 if ( aMpxItemId == media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ) |
|
255 { |
|
256 return i; |
|
257 } |
|
258 } |
|
259 } |
|
260 return KErrNotFound; |
|
261 } |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // CVcxHgMyVideosVideoList::AddToCorrectPlaceL() |
|
265 // ---------------------------------------------------------------------------- |
|
266 // |
|
267 void CVcxHgMyVideosVideoList::AddToCorrectPlaceL( CMPXMedia* aVideo, |
|
268 TVcxMyVideosSortingOrder aSortingOrder ) |
|
269 { |
|
270 IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoList::AddToCorrectPlaceL() - Enter" ); |
|
271 |
|
272 if ( aVideo ) |
|
273 { |
|
274 // Ownership of aVideo is transferred. |
|
275 CVcxHgMyVideosVideoListItem* video = CVcxHgMyVideosVideoListItem::NewL( aVideo ); |
|
276 CleanupStack::PushL( video ); |
|
277 |
|
278 TLinearOrder<CVcxHgMyVideosVideoListItem> sortOrder( |
|
279 CVcxHgMyVideosVideoListItem::CompareByDate ); |
|
280 |
|
281 switch( aSortingOrder ) |
|
282 { |
|
283 case EVcxMyVideosSortingName: |
|
284 { |
|
285 sortOrder = CVcxHgMyVideosVideoListItem::CompareByName; |
|
286 } |
|
287 break; |
|
288 |
|
289 case EVcxMyVideosSortingSize: |
|
290 { |
|
291 sortOrder = CVcxHgMyVideosVideoListItem::CompareBySize; |
|
292 } |
|
293 break; |
|
294 |
|
295 case EVcxMyVideosSortingCreationDate: |
|
296 { |
|
297 sortOrder = CVcxHgMyVideosVideoListItem::CompareByDate; |
|
298 } |
|
299 break; |
|
300 |
|
301 case EVcxMyVideosSortingModified: |
|
302 case EVcxMyVideosSortingId: |
|
303 default: |
|
304 { |
|
305 CleanupStack::PopAndDestroy( video ); |
|
306 IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoList::AddToCorrectPlaceL() - LEAVE: Invalid sort order" ); |
|
307 User::Leave( KErrNotSupported ); |
|
308 } |
|
309 break; |
|
310 } |
|
311 |
|
312 // Ownership of video is transferred. |
|
313 iVideoList.InsertInOrderAllowRepeatsL( video, sortOrder ); |
|
314 |
|
315 CleanupStack::Pop( video ); |
|
316 } |
|
317 |
|
318 IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoList::AddToCorrectPlaceL() - Exit" ); |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CVcxHgMyVideosVideoList::ResortVideoListL() |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 void CVcxHgMyVideosVideoList::ResortVideoListL( const TVcxMyVideosSortingOrder& aSortingOrder ) |
|
326 { |
|
327 IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoList::ResortVideoListL() - Enter" ); |
|
328 |
|
329 TLinearOrder<CVcxHgMyVideosVideoListItem> sortOrder( |
|
330 CVcxHgMyVideosVideoListItem::CompareByDate ); |
|
331 |
|
332 switch ( aSortingOrder ) |
|
333 { |
|
334 case EVcxMyVideosSortingName: |
|
335 { |
|
336 sortOrder = CVcxHgMyVideosVideoListItem::CompareByName; |
|
337 } |
|
338 break; |
|
339 |
|
340 case EVcxMyVideosSortingSize: |
|
341 { |
|
342 sortOrder = CVcxHgMyVideosVideoListItem::CompareBySize; |
|
343 } |
|
344 break; |
|
345 |
|
346 case EVcxMyVideosSortingCreationDate: |
|
347 { |
|
348 sortOrder = CVcxHgMyVideosVideoListItem::CompareByDate; |
|
349 } |
|
350 break; |
|
351 |
|
352 case EVcxMyVideosSortingModified: |
|
353 case EVcxMyVideosSortingId: |
|
354 default: |
|
355 { |
|
356 IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoList::ResortVideoListL() - LEAVE: Invalid sort order" ); |
|
357 User::Leave( KErrNotSupported ); |
|
358 } |
|
359 break; |
|
360 } |
|
361 iVideoList.Sort( sortOrder ); |
|
362 IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoList::ResortVideoListL() - Exit" ); |
|
363 } |