videocollection/hgmyvideos/inc/vcxhgmyvideosvideomodelhandler.h
changeset 0 96612d01cf9f
child 8 ce5ada96ab30
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     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:      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 CVcxHgMyVideosDownloadUpdater;
       
    37 class TVcxHgMyVideosVideoDetailsDialog;
       
    38 class CVcxHgMyVideosVideoList;
       
    39 class CHgScroller;
       
    40 class TVideoPlayerCustomMessage;
       
    41 class CMyVideosIndicator;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46  * UI level handler for video data.
       
    47  * @lib vcxhgmyvideos.lib
       
    48  */
       
    49 NONSHARABLE_CLASS(  CVcxHgMyVideosVideoModelHandler ) :
       
    50         public CBase,
       
    51         public MVcxHgMyVideosVideoModelObserver,
       
    52         public MHgScrollBufferObserver
       
    53     {
       
    54     public:
       
    55     
       
    56         /**
       
    57          * Two-phased constructor.
       
    58          * 
       
    59          * @param aVideoListImpl Video list implementation
       
    60          * @param aModel Application model
       
    61          * @param aView Application view
       
    62          * @param aScroller Hg list control   
       
    63          * @return New object.
       
    64          */
       
    65         static CVcxHgMyVideosVideoModelHandler* NewL( 
       
    66             CVcxHgMyVideosVideoListImpl& aVideoListImpl,
       
    67             CVcxHgMyVideosModel& aModel,
       
    68             CVcxHgMyVideosMainView& aView,
       
    69             CHgScroller& aScroller );
       
    70 
       
    71         /**
       
    72          * Two-phased constructor.
       
    73          * 
       
    74          * @param aVideoListImpl Video list implementation
       
    75          * @param aModel Application model
       
    76          * @param aView Application view
       
    77          * @param aScroller Hg list control   
       
    78          * @return New object. 
       
    79          */
       
    80         static CVcxHgMyVideosVideoModelHandler* NewLC( 
       
    81             CVcxHgMyVideosVideoListImpl& aVideoListImpl, 
       
    82             CVcxHgMyVideosModel& aModel,
       
    83             CVcxHgMyVideosMainView& aView,
       
    84             CHgScroller& aScroller );
       
    85 
       
    86         /**
       
    87          * Destructor.
       
    88          */
       
    89         virtual ~CVcxHgMyVideosVideoModelHandler();
       
    90     
       
    91         /**
       
    92          * Activates video model.
       
    93          */
       
    94         void DoModelActivateL();
       
    95         
       
    96         /**
       
    97          * Deactivates video model.
       
    98          */
       
    99         void DoModelDeactivate();        
       
   100 
       
   101         /**
       
   102          * Makes sure model has correct video list.
       
   103          * 
       
   104          * @param aCategoryIndex of video list in MPX collection.
       
   105          */
       
   106         void UpdateVideoListL( TInt aCategoryIndex );
       
   107         
       
   108         /**
       
   109          * Resorts current video list, called when list sort-order changes.
       
   110          */
       
   111         void ResortVideoListL();
       
   112         
       
   113         /**
       
   114          * Gets list highlight.
       
   115          * 
       
   116          * @return Highlight.
       
   117          */
       
   118         TInt Highlight();        
       
   119         
       
   120         /**
       
   121          * Gets video's download state base on video index.
       
   122          * 
       
   123          * @param aIndex Video's index on UI list.
       
   124          * @return Video's download state as TVcxMyVideosDownloadState structure.
       
   125          */
       
   126         TVcxMyVideosDownloadState VideoDownloadState( TInt aIndex );
       
   127         
       
   128         /**
       
   129          * Checks if progressive play (playback during download) is possible.
       
   130          * 
       
   131          * @param aIndex Video's index on UI list.
       
   132          * @return ETrue if progressive play is possible.
       
   133          */
       
   134         TBool IsProgressivePlayPossible( TInt aIndex );
       
   135 
       
   136         /**
       
   137          * Returns the count of videos in UI list model.
       
   138          *
       
   139          * @return Count of videos in UI list model.
       
   140          */
       
   141         TInt VideoCount();
       
   142 
       
   143         /**
       
   144          * Returns the index of currently open video list, or KErrNotFound.
       
   145          * 0=All videos, 1=Downloads, 2=...
       
   146          * 
       
   147          * @return Index of currently open video list.
       
   148          */
       
   149         TInt CurrentCategoryIndex();
       
   150 
       
   151         /**
       
   152          * Returns a list of currently marked videos.
       
   153          * 
       
   154          * @return List of currently marked video indexes.
       
   155          */
       
   156         void MarkedVideosL( RArray<TInt>& aMarkedVideos );
       
   157         
       
   158         /**
       
   159          * Returns a list of item indexes which download 
       
   160 		 * state is different than EVcxMyVideosDlStateNone. 
       
   161 		 * 
       
   162 		 * @return List of item indexes.
       
   163          */
       
   164         void OngoingDownloads( RArray<TInt>& aDownloads );
       
   165         
       
   166         /**
       
   167          * Handles mark command to video list.
       
   168          * 
       
   169          * @param aMarkCommand Mark command.
       
   170          */
       
   171         void HandleMarkCommandL( TInt aMarkCommand );
       
   172         
       
   173         /**
       
   174          * Returns last playback position of video, video identified by URI.
       
   175          * 
       
   176          * @param aContentUri URL or path to video.
       
   177          * @return Last playback position.
       
   178          */
       
   179         TInt LastPlaybackPosition( const TDesC& aContentUri );
       
   180 
       
   181         /**
       
   182          * Stores last playback position of video, video identified by URI.
       
   183          * 
       
   184          * @param aContentUri URL or path to video.
       
   185          * @param aPosition Last playback position.
       
   186          */
       
   187         void SetLastPlaybackPositionL( const TDesC& aContentUri, TInt aPosition );        
       
   188 
       
   189         /**
       
   190          * Returns video's name.
       
   191          * 
       
   192          * @param aIndex Video's index on UI list.
       
   193          * @return Video's name or empty string.
       
   194          */
       
   195         const TDesC& GetVideoName( TInt aIndex );
       
   196         
       
   197         /**
       
   198          * Returns video's URI.
       
   199          * 
       
   200          * @param aIndex Video's index on UI list.
       
   201          * @return Video's URI or empty string.
       
   202          */        
       
   203         const TDesC& GetVideoUri( TInt aIndex );
       
   204         
       
   205         /**
       
   206          * Returns video size in bytes
       
   207          * 
       
   208          * @param aIndex Video's index on UI list.
       
   209          * @return Video size in bytes or zero.
       
   210          */
       
   211         TInt64 GetVideoSize( TInt aIndex );
       
   212 
       
   213         /**
       
   214          * Deletes videos from requested indexes.
       
   215          * 
       
   216          * @param aOperationTargets Video indexes.
       
   217          */
       
   218         void DeleteVideosL( const RArray<TInt>& aOperationTargets );
       
   219 
       
   220         /**
       
   221          * Moves or copies videos from requested indexes to given target.
       
   222          * 
       
   223          * @param aOperationTargets Video indexes.
       
   224          * @param aTargetDrive Target drive.
       
   225          * @param aCopy If ETrue, copy is performed. If EFalse, move.
       
   226          */
       
   227         void MoveOrCopyVideosL( const RArray<TInt>& aOperationTargets,
       
   228                                 TInt aTargetDrive,
       
   229                                 TBool aCopy );
       
   230 
       
   231         /**
       
   232          * Play a video from requested index.
       
   233          * 
       
   234          * @param aIndex Video's index on UI list.
       
   235          */
       
   236         void PlayVideoL( TInt aIndex );
       
   237         
       
   238         /**
       
   239          * Resumes paused or failed download from requested index.
       
   240          * 
       
   241          * @param aIndex Video's index on UI list.
       
   242          */        
       
   243         void ResumeDownloadL( TInt aIndex );
       
   244 
       
   245         /**
       
   246          * Cancels a video download from requested index.
       
   247          * 
       
   248          * @param aIndex Video's index on UI list.
       
   249          */
       
   250         void CancelDownloadL( TInt aIndex );
       
   251         
       
   252         /**
       
   253          * Returns Video Player custom message of a video.
       
   254          * 
       
   255          * @param aFilteredIndex Video's index on filtered UI list.
       
   256          * @param aVideoInfo On return, Video Player custom message with video information.
       
   257          * @param aMpxId1 On return, MPX ID 1 of the video.
       
   258          */
       
   259         TInt GetVideoPlayerCustomMessage( TInt aFilteredIndex, 
       
   260                                           TVideoPlayerCustomMessage& aVideoInfo,
       
   261                                           TInt& aMpxId1 );
       
   262 
       
   263         /**
       
   264          * Returns Video Player custom message of a video.
       
   265          * 
       
   266          * @param aMpxItemId MPX Item Id of the video.
       
   267          * @param aVideoInfo On return, Video Player custom message with video information.
       
   268          */
       
   269         TInt GetVideoPlayerCustomMessage( TMPXItemId& aMpxItemId,
       
   270                                           TVideoPlayerCustomMessage& aVideoInfo );
       
   271 
       
   272         /**
       
   273          * Returns age profile of a video.
       
   274          * 
       
   275          * @param aIndex Video's index on UI list.
       
   276          * @return Age profile, or 0 if not defined.
       
   277          */
       
   278         TInt32 VideoAgeProfileL( TInt aIndex );
       
   279 
       
   280         /**
       
   281          * Returns age profile of a video.
       
   282          * 
       
   283          * @param aId TMPXItemId for the video.
       
   284          * @return Age profile, or 0 if not defined.
       
   285          */
       
   286         TInt32 VideoAgeProfileL( TMPXItemId aId );
       
   287 
       
   288         /**
       
   289          * Returns age profile of a video.
       
   290          * 
       
   291          * @param aMedia MPX media for the video.
       
   292          * @return Age profile, or 0 if not defined.
       
   293          */
       
   294         TInt32 VideoAgeProfileL( CMPXMedia* aMedia );
       
   295 
       
   296         /*
       
   297          * Tries to find MPX Item Id of unknown video.
       
   298          *
       
   299          * @param aVideoPath Path of the video.
       
   300          * @param aMpxItemId On return, MPX Item Id if found.
       
   301          * @return ETrue if video was found.
       
   302          */
       
   303         TBool FindVideoMpxIdL( const TDesC& aVideoPath, TMPXItemId& aMpxItemId );
       
   304 
       
   305         /**
       
   306          * Informative call about video being played. Method removes possible new
       
   307          * indicator from video.
       
   308          * 
       
   309          * @param aIndex Video's index on UI list.
       
   310          */
       
   311         void ClearNewVideoIndicatorL( TInt aIndex );        
       
   312 
       
   313         /**
       
   314          * Informative call about video being played. Method removes possible new
       
   315          * indicator from video.
       
   316          * 
       
   317          * @param aMpxItemId Video's MPX item Id.
       
   318          */
       
   319         void ClearNewVideoIndicatorL( TMPXItemId& aMpxItemId );
       
   320 
       
   321         /**
       
   322          * Gets data of currently highlighted video, and passes it to
       
   323          * TVcxHgMyVideosVideoDetailsDialog::ShowVideoDetailsDialogL().
       
   324          */
       
   325         void ShowVideoDetailsDialogL();
       
   326         
       
   327         /**
       
   328          * Returns video indicator.
       
   329          * 
       
   330          * @return Reference to video indicator.
       
   331          */
       
   332         CMyVideosIndicator& VideoIndicator();
       
   333         
       
   334     public: // From MVcxHgMyVideosVideoModelObserver
       
   335         
       
   336         /**
       
   337          * Called when a list of videos is available.
       
   338          * 
       
   339          * @param aVideoList List of videos
       
   340          */
       
   341         void NewVideoListL( CMPXMediaArray& aVideoList );
       
   342          
       
   343         /**
       
   344          * Called when the whole video list has been modified.
       
   345          * Normally this means that new items have been appended to list.
       
   346          */
       
   347         void VideoListModifiedL();
       
   348          
       
   349         /**
       
   350          * Called when a single video item has been modified (add/remove/modify).
       
   351          * 
       
   352          * @param aEventType Type of modification event (add/remove/modify).
       
   353          * @param aMpxItemId MPX Item Id of the modified item.
       
   354          * @param aExtraInfo Extra information for modification event.
       
   355          * @param aSimulated If ETrue, event is not originated from MPX Collection.
       
   356          */
       
   357         void VideoModifiedL( TMPXChangeEventType aEventType,
       
   358                               TMPXItemId aMpxItemId,
       
   359                               TInt32 aExtraInfo,
       
   360                               TBool aSimulated );
       
   361         
       
   362         /*
       
   363          * Called when a single video item has fetched.
       
   364          * Ownership of video is transferred.
       
   365          * 
       
   366          * @param aVideo Video item.
       
   367          */
       
   368         void VideoFetchingCompletedL( CMPXMedia* aVideo );
       
   369         
       
   370         /**
       
   371          * Called when resume has started from beginning.
       
   372          * @param aMpxId MPX ID of the video object.
       
   373          */
       
   374         void ResumeStartedFromBeginningL( TUint32 aMpxId );
       
   375 
       
   376         /**
       
   377          * Called when multiple video deletion command is completed.
       
   378          * 
       
   379          * @param aFailedCount Count of failed deletions, if any.
       
   380          * @param aFailedMpxId If above 1, MPXItemId of failed deletion.
       
   381          */
       
   382         void VideoDeletionCompletedL( TInt aFailedCount, TMPXItemId aFailedMpxId );         
       
   383          
       
   384         /**
       
   385          * Called when move or copy command is completed.
       
   386          * 
       
   387          * @param aFailedCount Count of failed moves/copies, if any.
       
   388          * @param aFailedMpxId If above 1, MPXItemId of failed move/copy.
       
   389          */
       
   390         void VideoMoveOrCopyCompletedL( TInt aFailedCount, TMPXItemId aFailedMpxId );
       
   391         
       
   392         /**
       
   393          * Called when all details for a video have been fetched.
       
   394          * 
       
   395          * @param aMedia MPX Media that contains all details.
       
   396          */
       
   397         void VideoDetailsCompletedL( const CMPXMedia& aMedia );
       
   398 		
       
   399     public: // From MHgScrollBufferObserver
       
   400         
       
   401         /**
       
   402          * Buffer position changed. 
       
   403          * The items between the aBufferStart and aBufferEnd should be released.
       
   404          * 
       
   405          * @param aBufferStart The index of the first item in buffer.
       
   406          * @param aBufferEnd The index of the last item in buffer.
       
   407          */
       
   408         void Release( TInt aReleaseStart, TInt aReleaseEnd );
       
   409     
       
   410         /**
       
   411          * Buffer position changed. 
       
   412          * The items between the aBufferStart and aBufferEnd should be loaded as soon as possible.
       
   413          * 
       
   414          * @param aBufferStart The index of the first item in buffer.
       
   415          * @param aBufferEnd The index of the last item in buffer.
       
   416          * @param aDirection The direction of request.
       
   417          */
       
   418         void Request( TInt aRequestStart, TInt aRequestEnd, THgScrollDirection aDirection );
       
   419         
       
   420     private:    
       
   421         
       
   422         /**
       
   423          * Default constructor
       
   424          *
       
   425          * @param aVideoListImpl Video list implementation
       
   426          * @param aModel Application model
       
   427          * @param aView Application view
       
   428          * @param aScroller Hg list control
       
   429          */
       
   430         CVcxHgMyVideosVideoModelHandler( 
       
   431             CVcxHgMyVideosVideoListImpl& aVideoListImpl,
       
   432             CVcxHgMyVideosModel& aModel,
       
   433             CVcxHgMyVideosMainView& aView,
       
   434             CHgScroller& aScroller );            
       
   435     
       
   436         /**
       
   437          * 2nd phase constructor.
       
   438          */
       
   439         void ConstructL( );
       
   440     
       
   441         /**
       
   442          * Replaces old video array with new one. Old array is deleted. 
       
   443          * 
       
   444          * @param aVideoList Reference to new video array.
       
   445          */
       
   446         void ReplaceVideoArrayL( CMPXMediaArray& aVideoList );
       
   447 
       
   448         /**
       
   449          * Formats the second row string for video item.
       
   450          * 
       
   451          * @param aIndex List index of video
       
   452          * @param aMedia MPX Media object (video).
       
   453          * @param aIsDownloading On return, ETrue if video is downloading.
       
   454          * @return Second row string.
       
   455          */
       
   456         HBufC* FormatVideoSecondRowLC(
       
   457                 TInt aIndex,
       
   458                 CMPXMedia& aMedia,
       
   459                 TBool& aIsDownloading );        
       
   460         
       
   461         /**
       
   462          * Formats the second row string for completed video.
       
   463          * 
       
   464          * @param aMedia MPX Media object (video).
       
   465          * @return Second row string.
       
   466          */
       
   467         HBufC* FormatVideoSecondRowCompletedLC( CMPXMedia& aMedia );
       
   468 
       
   469         /**
       
   470          * Formats the second row string for downloading video.
       
   471          * 
       
   472          * @param aIndex List index of video
       
   473          * @param aMedia MPX Media object (video).
       
   474          * @return Second row string.
       
   475          */
       
   476         HBufC* FormatVideoSecondRowDownloadingLC( TInt aIndex, CMPXMedia& aMedia );
       
   477 
       
   478         /**
       
   479          * Reads and returns download progress, makes sure that progress value
       
   480          * returned gets a value between 0% and 99%.
       
   481          * 
       
   482          * @param aMpxMedia Reference to MPX Media object.
       
   483          * @return Download progress. 
       
   484          */
       
   485         TInt DownloadProgressL( const CMPXMedia& aMpxMedia );
       
   486         
       
   487         /**
       
   488          * Updates video list item at given list index.
       
   489          * @param aListIndex Index.
       
   490          */
       
   491         void UpdateVideoListItemL( TInt aListIndex );
       
   492           
       
   493         /**
       
   494          * Deletes item from video array and UI list.
       
   495          * @param aMpxItemId MPX Item Id of the deleted item.
       
   496          */
       
   497         void DeleteItemL( TMPXItemId aMpxItemId );
       
   498         
       
   499         /**
       
   500          * List control calls this when it needs new buffer of data.
       
   501          * 
       
   502          * @param aRequestStart The index of the first item in buffer.
       
   503          * @param aRequestEnd The index of the last item in buffer.
       
   504          * @param aDirection The direction of request.
       
   505          */
       
   506         void HandleRequestL( TInt aRequestStart, 
       
   507                              TInt aRequestEnd, 
       
   508                              THgScrollDirection aDirection );
       
   509         
       
   510         /**
       
   511          * Inserts new video to video array and UI list.  
       
   512          *  
       
   513          * @param aVideo Video item. Ownership of video is transferred. 
       
   514          */ 
       
   515         void InsertVideoL( CMPXMedia* aVideo );
       
   516         
       
   517         /**
       
   518          * Compares MPX origin information to currently displayed category. 
       
   519          * 
       
   520          * @return ETrue if media belongs to category, otherwise EFalse.
       
   521          */
       
   522         TBool ValidOrigin( CMPXMedia& aMedia );
       
   523                 
       
   524         /** 
       
   525          * Saves MPX id of highlighted item. 
       
   526          */
       
   527         void SaveHighlightedItemIdL();
       
   528         
       
   529         /** 
       
   530          * Update scrollbar strip type depending on sort order
       
   531          */
       
   532         void UpdateScrollbarTypeL( const TVcxMyVideosSortingOrder& aSortingOrder );
       
   533 
       
   534     private:
       
   535         
       
   536         /**
       
   537          * Video details dialog.
       
   538          * Own.
       
   539          */
       
   540         TVcxHgMyVideosVideoDetailsDialog* iVideoDetails;
       
   541         
       
   542         /**
       
   543          * Reference to video list implementation.
       
   544          * Not own.
       
   545          */
       
   546         CVcxHgMyVideosVideoListImpl& iVideoListImpl;
       
   547         
       
   548         /**
       
   549          * Reference to application model.
       
   550          * Not own.
       
   551          */
       
   552         CVcxHgMyVideosModel& iModel;
       
   553 
       
   554         /**
       
   555          * Reference to application view.
       
   556          * Not own.
       
   557          */        
       
   558         CVcxHgMyVideosMainView& iView;
       
   559         
       
   560         /**
       
   561          * Array of videos.
       
   562          * Own.
       
   563          */
       
   564         CVcxHgMyVideosVideoList* iVideoArray;
       
   565                 
       
   566         /**
       
   567          * Class for updating video data (thumbnail, DRM status) asynchronously.
       
   568          * Own.
       
   569          */
       
   570         CVcxHgMyVideosVideoDataUpdater* iDataUpdater;
       
   571         
       
   572         /**
       
   573          * Class for polling & updating video download progress asynchrounously.
       
   574          * Own.
       
   575          */
       
   576         CVcxHgMyVideosDownloadUpdater* iDownloadUpdater; 
       
   577         
       
   578         /**
       
   579          * Hg list component.
       
   580          * Not own.
       
   581          */
       
   582         CHgScroller& iScroller;
       
   583         
       
   584         /**
       
   585          * Index of MPX collection video list currently displayed.
       
   586          */
       
   587         TInt iCurrentCategoryIndex;
       
   588 
       
   589         /**
       
   590          * Flag for indicating that highlight should restore to the position
       
   591          * where it was before model deactivating. 
       
   592          */ 
       
   593         TBool iRestoreHighlightPosition;
       
   594         
       
   595         /**
       
   596          * MPX id of highlighted item in a video list.
       
   597          */
       
   598         TMPXItemId iHighlightedItemId;
       
   599         
       
   600         /**
       
   601          * Downloading has been resumed for these MPX IDs. Needed for showing
       
   602 		 * note "Resuming download not possible, download starts from beginning".
       
   603          */
       
   604         RArray<TUint32> iResumeArray;
       
   605 
       
   606         /**
       
   607          * Video indicator gives an overlay icon for video thumbnails.
       
   608          */
       
   609         CMyVideosIndicator* iVideoIndicator;
       
   610     };
       
   611 
       
   612 #endif // VCXHGMYVIDEOSVIDEOMODELHANDLER_H