|
1 /* |
|
2 * Copyright (c) 2008-2010 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: UI level handler for video data.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VCXHGMYVIDEOSVIDEOMODELHANDLER_H |
|
21 #define VCXHGMYVIDEOSVIDEOMODELHANDLER_H |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "vcxmyvideosdefs.h" |
|
25 #include "vcxhgmyvideosvideomodelobserver.h" |
|
26 |
|
27 #include <e32cmn.h> |
|
28 #include <ganes/HgScrollBufferObserverIface.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CVcxHgMyVideosVideoListImpl; |
|
32 class CVcxHgMyVideosModel; |
|
33 class CVcxHgMyVideosMainView; |
|
34 class CMPXMedia; |
|
35 class CVcxHgMyVideosVideoDataUpdater; |
|
36 class CVcxHgMyVideosVideoDetailsDialog; |
|
37 class CVcxHgMyVideosVideoList; |
|
38 class CHgScroller; |
|
39 class CMyVideosIndicator; |
|
40 class CRepository; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * UI level handler for video data. |
|
46 * @lib vcxhgmyvideos.lib |
|
47 */ |
|
48 NONSHARABLE_CLASS( CVcxHgMyVideosVideoModelHandler ) : |
|
49 public CBase, |
|
50 public MVcxHgMyVideosVideoModelObserver, |
|
51 public MHgScrollBufferObserver |
|
52 { |
|
53 public: |
|
54 |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * |
|
58 * @param aVideoListImpl Video list implementation |
|
59 * @param aModel Application model |
|
60 * @param aView Application view |
|
61 * @param aScroller Hg list control |
|
62 * @return New object. |
|
63 */ |
|
64 static CVcxHgMyVideosVideoModelHandler* NewL( |
|
65 CVcxHgMyVideosVideoListImpl& aVideoListImpl, |
|
66 CVcxHgMyVideosModel& aModel, |
|
67 CVcxHgMyVideosMainView& aView, |
|
68 CHgScroller& aScroller ); |
|
69 |
|
70 /** |
|
71 * Two-phased constructor. |
|
72 * |
|
73 * @param aVideoListImpl Video list implementation |
|
74 * @param aModel Application model |
|
75 * @param aView Application view |
|
76 * @param aScroller Hg list control |
|
77 * @return New object. |
|
78 */ |
|
79 static CVcxHgMyVideosVideoModelHandler* NewLC( |
|
80 CVcxHgMyVideosVideoListImpl& aVideoListImpl, |
|
81 CVcxHgMyVideosModel& aModel, |
|
82 CVcxHgMyVideosMainView& aView, |
|
83 CHgScroller& aScroller ); |
|
84 |
|
85 /** |
|
86 * Destructor. |
|
87 */ |
|
88 virtual ~CVcxHgMyVideosVideoModelHandler(); |
|
89 |
|
90 /** |
|
91 * Activates video model. |
|
92 */ |
|
93 void DoModelActivateL(); |
|
94 |
|
95 /** |
|
96 * Deactivates video model. |
|
97 */ |
|
98 void DoModelDeactivate(); |
|
99 |
|
100 /** |
|
101 * Makes sure model has correct video list. |
|
102 * |
|
103 * @param aCategoryIndex of video list in MPX collection. |
|
104 */ |
|
105 void UpdateVideoListL( TInt aCategoryIndex ); |
|
106 |
|
107 /** |
|
108 * Resorts current video list, called when list sort-order changes. |
|
109 */ |
|
110 void ResortVideoListL(); |
|
111 |
|
112 /** |
|
113 * Gets list highlight. |
|
114 * |
|
115 * @return Highlight. |
|
116 */ |
|
117 TInt Highlight(); |
|
118 |
|
119 /** |
|
120 * Returns the count of videos in UI list model. |
|
121 * |
|
122 * @return Count of videos in UI list model. |
|
123 */ |
|
124 TInt VideoCount(); |
|
125 |
|
126 /** |
|
127 * Returns the index of currently open video list, or KErrNotFound. |
|
128 * 0=All videos, 1=Downloads, 2=... |
|
129 * |
|
130 * @return Index of currently open video list. |
|
131 */ |
|
132 TInt CurrentCategoryIndex(); |
|
133 |
|
134 /** |
|
135 * Returns a list of currently marked videos. |
|
136 * |
|
137 * @return List of currently marked video indexes. |
|
138 */ |
|
139 void MarkedVideosL( RArray<TInt>& aMarkedVideos ); |
|
140 |
|
141 /** |
|
142 * Handles mark command to video list. |
|
143 * |
|
144 * @param aMarkCommand Mark command. |
|
145 */ |
|
146 void HandleMarkCommandL( TInt aMarkCommand ); |
|
147 |
|
148 /** |
|
149 * Returns video's name. |
|
150 * |
|
151 * @param aId Video's unique id. |
|
152 * @return Video's name or empty string. |
|
153 */ |
|
154 const TDesC& GetVideoName( TInt aId ); |
|
155 |
|
156 /** |
|
157 * Returns video's URI. |
|
158 * |
|
159 * @param aIndex Video's index on UI list. |
|
160 * @return Video's URI or empty string. |
|
161 */ |
|
162 const TDesC& GetVideoUri( TInt aIndex ); |
|
163 |
|
164 /** |
|
165 * Returns video's unique mpx id. |
|
166 * |
|
167 * @param aIndex Video's index on UI list. |
|
168 * @return Video's id or KErrNotFound. |
|
169 */ |
|
170 TInt GetVideoId( TInt aIndex ); |
|
171 |
|
172 /** |
|
173 * Returns video size in bytes |
|
174 * |
|
175 * @param aIndex Video's index on UI list. |
|
176 * @return Video size in bytes or zero. |
|
177 */ |
|
178 TInt64 GetVideoSize( TInt aIndex ); |
|
179 |
|
180 /** |
|
181 * Deletes videos with requested ids. |
|
182 * |
|
183 * @param aOperationTargets Videos' mpx ids. |
|
184 */ |
|
185 void DeleteVideosL( const RArray<TInt>& aOperationTargets ); |
|
186 |
|
187 /** |
|
188 * Moves or copies videos with requested ids to given target. |
|
189 * |
|
190 * @param aOperationTargets Videos' mpx ids. |
|
191 * @param aTargetDrive Target drive. |
|
192 * @param aCopy If ETrue, copy is performed. If EFalse, move. |
|
193 */ |
|
194 void MoveOrCopyVideosL( const RArray<TInt>& aOperationTargets, |
|
195 TInt aTargetDrive, |
|
196 TBool aCopy ); |
|
197 |
|
198 /** |
|
199 * Play a video from requested index. |
|
200 * |
|
201 * @param aIndex Video's index on UI list. |
|
202 */ |
|
203 void PlayVideoL( TInt aIndex ); |
|
204 |
|
205 /** |
|
206 * Returns age profile of a video. |
|
207 * |
|
208 * @param aIndex Video's index on UI list. |
|
209 * @return Age profile, or 0 if not defined. |
|
210 */ |
|
211 TInt32 VideoAgeProfileL( TInt aIndex ); |
|
212 |
|
213 /** |
|
214 * Returns age profile of a video. |
|
215 * |
|
216 * @param aId TMPXItemId for the video. |
|
217 * @return Age profile, or 0 if not defined. |
|
218 */ |
|
219 TInt32 VideoAgeProfileL( TMPXItemId aId ); |
|
220 |
|
221 /** |
|
222 * Returns age profile of a video. |
|
223 * |
|
224 * @param aMedia MPX media for the video. |
|
225 * @return Age profile, or 0 if not defined. |
|
226 */ |
|
227 TInt32 VideoAgeProfileL( CMPXMedia* aMedia ); |
|
228 |
|
229 /* |
|
230 * Tries to find MPX Item Id of unknown video. |
|
231 * |
|
232 * @param aVideoPath Path of the video. |
|
233 * @param aMpxItemId On return, MPX Item Id if found. |
|
234 * @return ETrue if video was found. |
|
235 */ |
|
236 TBool FindVideoMpxIdL( const TDesC& aVideoPath, TMPXItemId& aMpxItemId ); |
|
237 |
|
238 /** |
|
239 * Gets data of currently highlighted video, and passes it to |
|
240 * TVcxHgMyVideosVideoDetailsDialog::ShowVideoDetailsDialogL(). |
|
241 */ |
|
242 void ShowVideoDetailsDialogL(); |
|
243 |
|
244 /** |
|
245 * Returns video indicator. |
|
246 * |
|
247 * @return Reference to video indicator. |
|
248 */ |
|
249 CMyVideosIndicator& VideoIndicator(); |
|
250 |
|
251 public: // From MVcxHgMyVideosVideoModelObserver |
|
252 |
|
253 /** |
|
254 * Called when a list of videos is available. |
|
255 * |
|
256 * @param aVideoList List of videos |
|
257 */ |
|
258 void NewVideoListL( CMPXMediaArray& aVideoList ); |
|
259 |
|
260 /** |
|
261 * Called when the whole video list has been modified. |
|
262 * Normally this means that new items have been appended to list. |
|
263 */ |
|
264 void VideoListModifiedL(); |
|
265 |
|
266 /** |
|
267 * Called when a single video item has been modified (add/remove/modify). |
|
268 * |
|
269 * @param aEventType Type of modification event (add/remove/modify). |
|
270 * @param aMpxItemId MPX Item Id of the modified item. |
|
271 * @param aExtraInfo Extra information for modification event. |
|
272 * @param aSimulated If ETrue, event is not originated from MPX Collection. |
|
273 */ |
|
274 void VideoModifiedL( TMPXChangeEventType aEventType, |
|
275 TMPXItemId aMpxItemId, |
|
276 TInt32 aExtraInfo, |
|
277 TBool aSimulated ); |
|
278 |
|
279 /* |
|
280 * Called when a single video item has fetched. |
|
281 * Ownership of video is transferred. |
|
282 * |
|
283 * @param aVideo Video item. |
|
284 */ |
|
285 void VideoFetchingCompletedL( CMPXMedia* aVideo ); |
|
286 |
|
287 /** |
|
288 * Called when multiple video deletion command is completed. |
|
289 * |
|
290 * @param aFailedCount Count of failed deletions, if any. |
|
291 * @param aFailedMpxId If above 1, MPXItemId of failed deletion. |
|
292 */ |
|
293 void VideoDeletionCompletedL( TInt aFailedCount, TMPXItemId aFailedMpxId ); |
|
294 |
|
295 /** |
|
296 * Called when move or copy command is completed. |
|
297 * |
|
298 * @param aFailedCount Count of failed moves/copies, if any. |
|
299 * @param aFailedMpxId If above 1, MPXItemId of failed move/copy. |
|
300 */ |
|
301 void VideoMoveOrCopyCompletedL( TInt aFailedCount, TMPXItemId aFailedMpxId ); |
|
302 |
|
303 /** |
|
304 * Called when all details for a video have been fetched. |
|
305 * |
|
306 * @param aMedia MPX Media that contains all details. |
|
307 */ |
|
308 void VideoDetailsCompletedL( const CMPXMedia& aMedia ); |
|
309 |
|
310 public: // From MHgScrollBufferObserver |
|
311 |
|
312 /** |
|
313 * Buffer position changed. |
|
314 * The items between the aBufferStart and aBufferEnd should be released. |
|
315 * |
|
316 * @param aBufferStart The index of the first item in buffer. |
|
317 * @param aBufferEnd The index of the last item in buffer. |
|
318 */ |
|
319 void Release( TInt aReleaseStart, TInt aReleaseEnd ); |
|
320 |
|
321 /** |
|
322 * Buffer position changed. |
|
323 * The items between the aBufferStart and aBufferEnd should be loaded as soon as possible. |
|
324 * |
|
325 * @param aBufferStart The index of the first item in buffer. |
|
326 * @param aBufferEnd The index of the last item in buffer. |
|
327 * @param aDirection The direction of request. |
|
328 */ |
|
329 void Request( TInt aRequestStart, TInt aRequestEnd, THgScrollDirection aDirection ); |
|
330 |
|
331 private: |
|
332 |
|
333 /** |
|
334 * Default constructor |
|
335 * |
|
336 * @param aVideoListImpl Video list implementation |
|
337 * @param aModel Application model |
|
338 * @param aView Application view |
|
339 * @param aScroller Hg list control |
|
340 */ |
|
341 CVcxHgMyVideosVideoModelHandler( |
|
342 CVcxHgMyVideosVideoListImpl& aVideoListImpl, |
|
343 CVcxHgMyVideosModel& aModel, |
|
344 CVcxHgMyVideosMainView& aView, |
|
345 CHgScroller& aScroller ); |
|
346 |
|
347 /** |
|
348 * 2nd phase constructor. |
|
349 */ |
|
350 void ConstructL( ); |
|
351 |
|
352 /** |
|
353 * Replaces old video array with new one. Old array is deleted. |
|
354 * |
|
355 * @param aVideoList Reference to new video array. |
|
356 */ |
|
357 void ReplaceVideoArrayL( CMPXMediaArray& aVideoList ); |
|
358 |
|
359 /** |
|
360 * Formats the second row string for video item. |
|
361 * |
|
362 * @param aMedia MPX Media object (video). |
|
363 * @return Second row string. |
|
364 */ |
|
365 HBufC* FormatVideoSecondRowLC( CMPXMedia& aMedia ); |
|
366 |
|
367 /** |
|
368 * Updates video list item at given list index. |
|
369 * @param aListIndex Index. |
|
370 */ |
|
371 void UpdateVideoListItemL( TInt aListIndex ); |
|
372 |
|
373 /** |
|
374 * Deletes item from video array and UI list. |
|
375 * @param aMpxItemId MPX Item Id of the deleted item. |
|
376 */ |
|
377 void DeleteItemL( TMPXItemId aMpxItemId ); |
|
378 |
|
379 /** |
|
380 * List control calls this when it needs new buffer of data. |
|
381 * |
|
382 * @param aRequestStart The index of the first item in buffer. |
|
383 * @param aRequestEnd The index of the last item in buffer. |
|
384 * @param aDirection The direction of request. |
|
385 */ |
|
386 void HandleRequestL( TInt aRequestStart, |
|
387 TInt aRequestEnd, |
|
388 THgScrollDirection aDirection ); |
|
389 |
|
390 /** |
|
391 * Inserts new video to video array and UI list. |
|
392 * |
|
393 * @param aVideo Video item. Ownership of video is transferred. |
|
394 */ |
|
395 void InsertVideoL( CMPXMedia* aVideo ); |
|
396 |
|
397 /** |
|
398 * Compares MPX origin information to currently displayed category. |
|
399 * |
|
400 * @return ETrue if media belongs to category, otherwise EFalse. |
|
401 */ |
|
402 TBool ValidOrigin( CMPXMedia& aMedia ); |
|
403 |
|
404 /** |
|
405 * Saves MPX id of first (topmost) visible item. |
|
406 */ |
|
407 void SaveFirstListItemIdL(); |
|
408 |
|
409 /** |
|
410 * Update scrollbar strip type depending on sort order |
|
411 */ |
|
412 void UpdateScrollbarTypeL( const TVcxMyVideosSortingOrder& aSortingOrder ); |
|
413 |
|
414 /** |
|
415 * Resets scroller items for refetch only |
|
416 */ |
|
417 void ResetScrollerItemsL(); |
|
418 |
|
419 /** |
|
420 * Resets scroller buffer and items for refetch |
|
421 * This is fastest way to reset scroller when item count is unchanged |
|
422 */ |
|
423 void ResetScrollerBufferAndItemsL(); |
|
424 |
|
425 /** |
|
426 * Resizes scroller with refetch |
|
427 * This is faster way to reset scroller than CHgScroller::Reset() and |
|
428 * CHgScroller::ResizeL() calls combined |
|
429 * @param aNewItemCount New item count |
|
430 */ |
|
431 void ResizeScrollerL( TInt aNewItemCount ); |
|
432 |
|
433 /** |
|
434 * Sets video as last watched. |
|
435 * |
|
436 * @param aMedia Media that will be last watched. |
|
437 */ |
|
438 void SetVideoLastWatchedL( CMPXMedia& aMedia ); |
|
439 |
|
440 /** |
|
441 * Clears new video tag from the file. |
|
442 * |
|
443 * @param aMedia Media from which new video tag will be cleared. |
|
444 */ |
|
445 void ClearNewVideoFlagL( CMPXMedia& aMedia ); |
|
446 |
|
447 /** |
|
448 * Saves the marked MPXMedia items to iMarkedMediaList. This is called before |
|
449 * re-sorting the videos list if marking mode is enabled to preserve the |
|
450 * marking status of marked items. |
|
451 */ |
|
452 void SaveMarkingsL(); |
|
453 |
|
454 /** |
|
455 * Restores the marking status of the MPXMedia items from iMarkedMediaList. |
|
456 * This is called after re-sorting the list if marking mode is enabled to |
|
457 * restore the marking status of the marked items. |
|
458 * This method resets iMarkedMediaList before returning. |
|
459 */ |
|
460 void RestoreMarkingsL(); |
|
461 |
|
462 private: |
|
463 |
|
464 /** |
|
465 * Video details dialog. |
|
466 * Own. |
|
467 */ |
|
468 CVcxHgMyVideosVideoDetailsDialog* iVideoDetails; |
|
469 |
|
470 /** |
|
471 * Reference to video list implementation. |
|
472 * Not own. |
|
473 */ |
|
474 CVcxHgMyVideosVideoListImpl& iVideoListImpl; |
|
475 |
|
476 /** |
|
477 * Reference to application model. |
|
478 * Not own. |
|
479 */ |
|
480 CVcxHgMyVideosModel& iModel; |
|
481 |
|
482 /** |
|
483 * Reference to application view. |
|
484 * Not own. |
|
485 */ |
|
486 CVcxHgMyVideosMainView& iView; |
|
487 |
|
488 /** |
|
489 * Array of videos. |
|
490 * Own. |
|
491 */ |
|
492 CVcxHgMyVideosVideoList* iVideoArray; |
|
493 |
|
494 /** |
|
495 * Class for updating video data (thumbnail, DRM status) asynchronously. |
|
496 * Own. |
|
497 */ |
|
498 CVcxHgMyVideosVideoDataUpdater* iDataUpdater; |
|
499 |
|
500 /** |
|
501 * Hg list component. |
|
502 * Not own. |
|
503 */ |
|
504 CHgScroller& iScroller; |
|
505 |
|
506 /** |
|
507 * Index of MPX collection video list currently displayed. |
|
508 */ |
|
509 TInt iCurrentCategoryIndex; |
|
510 |
|
511 /** |
|
512 * Flag for indicating that list should restore to the position |
|
513 * where it was before model deactivating. |
|
514 */ |
|
515 TBool iRestoreListPosition; |
|
516 |
|
517 /** |
|
518 * MPX id of first (topmost) visible item in a video list. |
|
519 */ |
|
520 TMPXItemId iFirstListItemId; |
|
521 |
|
522 /** |
|
523 * Video indicator gives an overlay icon for video thumbnails. |
|
524 */ |
|
525 CMyVideosIndicator* iVideoIndicator; |
|
526 |
|
527 /** |
|
528 * Array of marked MPXMedia items to temporarily hold a list of marked items in video list. |
|
529 * The array is temporarily filled with pointers to marked media items prior to re-sorting |
|
530 * the video list and is cleared after sorting. |
|
531 */ |
|
532 RPointerArray<CMPXMedia> iMarkedMediaList; |
|
533 |
|
534 /** |
|
535 * Cenrep session. |
|
536 */ |
|
537 CRepository* iRepository; |
|
538 |
|
539 }; |
|
540 |
|
541 #endif // VCXHGMYVIDEOSVIDEOMODELHANDLER_H |