videocollection/hgmyvideos/inc/vcxhgmyvideoscollectionclient.h
changeset 0 96612d01cf9f
child 6 7d91903f795f
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:      Client class for My Videos MPX Collection.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef VCXHGMYVIDEOSCOLLECTIONCLIENT_H
       
    21 #define VCXHGMYVIDEOSCOLLECTIONCLIENT_H
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <coemain.h>
       
    25 #include <mpxcollectionobserver.h>
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class MMPXCollectionUtility;
       
    29 class MVcxHgMyVideosCategoryModelObserver;
       
    30 class MVcxHgMyVideosVideoModelObserver;
       
    31 class CVcxHgMyVideosDownloadClient;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36  * Client class for My Videos MPX Collection.
       
    37  *
       
    38  * @lib vcxhgmyvideos.lib
       
    39  */
       
    40 NONSHARABLE_CLASS( CVcxHgMyVideosCollectionClient ) : public CBase,
       
    41                                                       public MMPXCollectionObserver
       
    42     {
       
    43     public:
       
    44         
       
    45         enum TVcxHgMyVideosCollectionCommand
       
    46             {
       
    47             EVcxHgMyVideosCollectionCommandNone = 0,
       
    48             EVcxHgMyVideosCollectionCommandMultiDelete_Starting,
       
    49             EVcxHgMyVideosCollectionCommandMultiDelete_Started,
       
    50             EVcxHgMyVideosCollectionCommandMultiDelete_Finished,
       
    51             EVcxHgMyVideosCollectionCommandCancelDelete_Requested,
       
    52             EVcxHgMyVideosCollectionCommandCancelDelete_Completed,
       
    53             EVcxHgMyVideosCollectionCommandResort,
       
    54             EVcxHgMyVideosCollectionCommandMoveCopy_Starting,
       
    55             EVcxHgMyVideosCollectionCommandMoveCopy_Started,
       
    56             EVcxHgMyVideosCollectionCommandMoveCopy_Finished,
       
    57             EVcxHgMyVideosCollectionCommandCancelMoveCopy_Requested,
       
    58             EVcxHgMyVideosCollectionCommandCancelMoveCopy_Completed,
       
    59             EVcxHgMyVideosCollectionCommandVideoDetails_Requested
       
    60             };
       
    61         
       
    62     public: // Constructors and destructor
       
    63 
       
    64         /**
       
    65          * Two-phased constructor.
       
    66          *
       
    67          * @return New object.
       
    68          */
       
    69         static CVcxHgMyVideosCollectionClient* NewL();
       
    70 
       
    71         /**
       
    72          * Two-phased constructor.
       
    73          *
       
    74          * @return New object.
       
    75          */
       
    76         static CVcxHgMyVideosCollectionClient* NewLC();
       
    77 
       
    78         /**
       
    79          * Destructor.
       
    80          */
       
    81         virtual ~CVcxHgMyVideosCollectionClient();
       
    82 
       
    83     public:
       
    84 
       
    85         /**
       
    86          * Returns Download client.
       
    87          *
       
    88          * @return Reference to Download client.
       
    89          */
       
    90         CVcxHgMyVideosDownloadClient& DownloadClient();
       
    91         
       
    92         /**
       
    93          * Returns true if object has pending command for MPX Collection Utility.
       
    94          * 
       
    95          * @return ETrue if command is pending.
       
    96          */
       
    97         TBool HasPendingCommand();        
       
    98         
       
    99         /**
       
   100          * Called to set category data observer. Can be called with NULL to
       
   101          * reset the observer.
       
   102          * 
       
   103          * @param aCategoryModelObserver Observer.
       
   104          */
       
   105         void SetCategoryModelObserver(
       
   106                 MVcxHgMyVideosCategoryModelObserver* aCategoryModelObserver ); 
       
   107 
       
   108         /**
       
   109          * Called to set video data observer. Can be called with NULL to
       
   110          * reset the observer.
       
   111          * 
       
   112          * @param aVideoModelObserver Observer.
       
   113          */
       
   114         void SetVideoModelObserver(
       
   115                 MVcxHgMyVideosVideoModelObserver* aVideoModelObserver );
       
   116         
       
   117         /**
       
   118          * When called, starts fetching category list. Category list is returned
       
   119          * through callback interface MVcxHgMyVideosCategoryModelObserver.
       
   120          */
       
   121         void GetCategoryListL();        
       
   122         
       
   123         /**
       
   124          * When called, starts fetching video list. Video list is returned
       
   125          * through callback interface MVcxHgMyVideosVideoModelObserver.
       
   126          * 
       
   127          * @param aIndex Index of video list to fetch.
       
   128          */
       
   129         void GetVideoListL( TInt aIndex );
       
   130                 
       
   131         /**
       
   132          * Translates array index to MPX item id by reading the value from array.
       
   133          *
       
   134          * @param aArrayIndex Index in array.
       
   135          * @param aArray Array of MPX Media objects.
       
   136          * @return MPX item id
       
   137          */
       
   138         TMPXItemId ArrayIndexToMpxItemIdL( TInt aArrayIndex, CMPXMediaArray* aArray );
       
   139  
       
   140         /**
       
   141          * Deletes an array of videos.
       
   142          * 
       
   143          * @param aMediasToDelete Array of MPX Media objects to delete.
       
   144          */
       
   145         void DeleteVideosL( CMPXMediaArray* aMediasToDelete );
       
   146 
       
   147         /**
       
   148          * Cancels ongoing deletion of videos. See DeleteVideosL().
       
   149          */
       
   150         void CancelDeleteVideosL();
       
   151 
       
   152         /**
       
   153          * Moves or copies array of videos.
       
   154          * 
       
   155          * @param mediasToMoveOrCopy Array of MPX Media objects to move/copy.
       
   156          * @param aTargetDrive Target drive.
       
   157          * @param aCopy ETrue of copy operation, EFalse if move.
       
   158          */
       
   159         void MoveOrCopyVideosL( CMPXMediaArray* mediasToMoveOrCopy,
       
   160                                 TInt aTargetDrive,
       
   161                                 TBool aCopy );
       
   162         
       
   163         /**
       
   164          * Cancels ongoing move/copy operation of videos. See MoveOrCopyVideosL().
       
   165          */
       
   166         void CancelMoveOrCopyVideosL();
       
   167 
       
   168         /**
       
   169          * Play a video with given MPX item id.
       
   170          *
       
   171          * @param aMpxItemId MPX item id
       
   172          */
       
   173         void PlayVideoL( TMPXItemId aMpxItemId );
       
   174 
       
   175         /**
       
   176          * Sets attribute value to MPX Collection.
       
   177          * 
       
   178          * @param aMedia MPX Media object to change.
       
   179          * @param aAttribute MPX attribute to change.
       
   180          * @param aValue New value for attribute.
       
   181          */
       
   182         void SetAttributeL( const CMPXMedia& aMedia,
       
   183                             const TMPXAttribute& aAttribute,
       
   184                             const TUint32 aValue );
       
   185         
       
   186         void SetAttributeL( const CMPXMedia& aMedia,
       
   187                             const TMPXAttribute& aAttribute,
       
   188                             const TReal32 aValue );        
       
   189 
       
   190         /**
       
   191          * Returns MPX Media object most recently requested with method call
       
   192          * FetchMpxMediaByMpxIdL().
       
   193          * 
       
   194          * @return Latest MPX Media object or NULL.
       
   195          */
       
   196         CMPXMedia* GetLatestFetchedMpxMediaL();
       
   197         
       
   198         /**
       
   199          * Fetches MPX Media object based on MPX ID. Fetched MPX Media object
       
   200          * is returned through callback interface MVcxHgMyVideosVideoModelObserver.
       
   201          * 
       
   202          * @param aMpxId MPX ID.
       
   203          */
       
   204         void FetchMpxMediaByMpxIdL( TMPXItemId& aMpxId );
       
   205         
       
   206         /**
       
   207          * Gets all details for the selected MPX Media object.
       
   208 		 * Result will be returned in HandleCommandComplete().
       
   209          * 
       
   210          * @param aMpxId MPX ID.
       
   211          */
       
   212         void GetVideoDetailsL( TMPXItemId& aMpxId );
       
   213 
       
   214     public: // From MMPXCollectionObserver
       
   215 
       
   216         /**
       
   217          * From MMPXCollectionObserver->MMPXCollectionMediaObserver
       
   218          * Handle extended media properties
       
   219          *
       
   220          * @param aMedia media 
       
   221          * @param aError error code    
       
   222          */
       
   223         void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError );
       
   224 
       
   225         /** 
       
   226          * From MMPXCollectionUtilityObserver.
       
   227          * Handle collection message
       
   228          * NOTE: only one of HandleCollectionMessage callback can be implemented
       
   229          * 
       
   230          * @param aMessage collection message, ownership not transferred. 
       
   231          *        Please check aMsg is not NULL before using it. If aErr is not 
       
   232          *        KErrNone, plugin might still call back with more info in the aMsg.
       
   233          * @param aErr system error code.
       
   234          */
       
   235         void HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr ); 
       
   236 
       
   237         /**
       
   238          * From MMPXCollectionUtilityObserver.
       
   239          * Handles the collection entries being opened. Typically called
       
   240          * when client has Open()'d a folder
       
   241          *
       
   242          * @param aEntries collection entries opened
       
   243          * @param aIndex focused entry
       
   244          * @param aComplete ETrue no more entries. EFalse more entries
       
   245          *                  expected
       
   246          * @param aError error code   
       
   247          */
       
   248         void HandleOpenL( const CMPXMedia& aEntries,
       
   249                           TInt aIndex,
       
   250                           TBool aComplete,
       
   251                           TInt aError );
       
   252     
       
   253         /**
       
   254          * From MMPXCollectionUtilityObserver.
       
   255          * Handles the item being opened. Typically called
       
   256          * when client has Open()'d an item. Client typically responds by
       
   257          * 'playing' the item via the playlist
       
   258          *
       
   259          * @param aPlaylist collection playlist
       
   260          * @param aError error code   
       
   261          */                         
       
   262         void HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, TInt aError );
       
   263 
       
   264         /**
       
   265          * From MMPXCollectionUtilityObserver.
       
   266          * Handle completion of a asynchronous command
       
   267          *
       
   268          * @param aCommandResult result of the command, NULL if error
       
   269          * @param aError error code    
       
   270          */
       
   271         void HandleCommandComplete( CMPXCommand* aCommandResult, TInt aError );
       
   272 
       
   273     protected: // Constructors
       
   274 
       
   275         /**
       
   276          * Default C++ constructor. 
       
   277          */
       
   278         CVcxHgMyVideosCollectionClient();
       
   279 
       
   280         /**
       
   281          * Symbian 2nd phase constructor.
       
   282          */
       
   283         void ConstructL();
       
   284 
       
   285         /** 
       
   286          * Called by HandleCollectionMessage(). Handles collection messages.
       
   287          * 
       
   288          * @param aMessage collection message.
       
   289          * @param aError system error code.
       
   290          */
       
   291         void HandleCollectionMessageL( CMPXMessage* aMessage, TInt aError );
       
   292 
       
   293         /** 
       
   294          * Called by HandleCollectionMessageL(). Handles single collection message.
       
   295          * 
       
   296          * @param aMessage collection message.
       
   297          * @param aError system error code.
       
   298          */
       
   299         void HandleSingleCollectionMessageL( CMPXMessage* aMessage, TInt aError );
       
   300         
       
   301         /**
       
   302          * Returns the current level of collection.
       
   303          */
       
   304         TInt CollectionLevelL();
       
   305         
       
   306         /**
       
   307          * Handles item addition message, called by HandleSingleCollectionMessageL().
       
   308          * 
       
   309          * @param aMessage collection message.
       
   310          * @param aError system error code. 
       
   311          */
       
   312         void HandleMyVideosItemsAppendedL( CMPXMessage* aMessage, TInt aError );        
       
   313         
       
   314         /**
       
   315          * Handles item changed message, called by HandleSingleCollectionMessageL().
       
   316          * 
       
   317          * @param aMessage collection message.
       
   318          * @param aError system error code. 
       
   319          */
       
   320         void HandleMyVideosItemsChangedL( CMPXMessage* aMessage, TInt aError );        
       
   321         
       
   322         /**
       
   323          * Handles delete related messages, called by HandleSingleCollectionMessageL().
       
   324          * 
       
   325          * @param aMessage collection message.
       
   326          * @param aError system error code. 
       
   327          */
       
   328         void HandleMyVideosDeleteMessageL( CMPXMessage* aMessage, TInt aError );        
       
   329 
       
   330         /**
       
   331          * Handles move or copy related messages, called by HandleSingleCollectionMessageL().
       
   332          * 
       
   333          * @param aMessage collection message.
       
   334          * @param aError system error code. 
       
   335          */
       
   336         void HandleMyVideosMoveOrCopyMessageL( CMPXMessage* aMessage, TInt aError );        
       
   337 
       
   338         /**
       
   339          * Handles response message when MPX Media object requested.
       
   340          *
       
   341          * @param aMessage collection message.
       
   342          * @param aError system error code.
       
   343          */
       
   344         void HandleGetMediasByMpxIdRespL( CMPXMessage* aMessage, TInt aError );
       
   345         
       
   346         /**
       
   347          * Handles response message when video details requested.
       
   348          * 
       
   349          * @param aMessage collection message.
       
   350          * @param aError system error code.
       
   351          */
       
   352         void HandleGetVideoDetailsRespL( CMPXMessage* aMessage, TInt aError );
       
   353 
       
   354     protected:
       
   355         
       
   356         enum TVcxHgCollectionOpenStatus
       
   357             {
       
   358             EVcxHgCollectionNotOpen = 0,
       
   359             EVcxHgCollectionOpening,
       
   360             EVcxHgCollectionOpened            
       
   361             };
       
   362         
       
   363     protected:
       
   364 
       
   365         /**
       
   366          * Pointer to MPX Collection utility.
       
   367          * Own.
       
   368          */
       
   369         MMPXCollectionUtility* iCollectionUtility;
       
   370         
       
   371         /**
       
   372          * Pointer to Download client.
       
   373          * Own.
       
   374          */
       
   375         CVcxHgMyVideosDownloadClient* iDownloadClient;
       
   376                 
       
   377         /**
       
   378          * Pointer to observer of category model.
       
   379          * Not own.
       
   380          */
       
   381         MVcxHgMyVideosCategoryModelObserver* iCategoryModelObserver;
       
   382         
       
   383         /**
       
   384          * Pointer to observer of video model.
       
   385          * Not own.
       
   386          */
       
   387         MVcxHgMyVideosVideoModelObserver* iVideoModelObserver;
       
   388         
       
   389         /**
       
   390          * Variable for storing My Videos collection opening status.
       
   391          */
       
   392         TVcxHgCollectionOpenStatus iCollectionOpenStatus;
       
   393         
       
   394         /**
       
   395          * Variable for storing pending collection command.
       
   396          */
       
   397         TVcxHgMyVideosCollectionCommand iPendingCommand;
       
   398         
       
   399         /**
       
   400          * Variable for storing latest MPX Media object fetched separately.
       
   401          * Own.
       
   402          */
       
   403         CMPXMedia* iLatestMpxMedia;
       
   404         
       
   405 #if defined(_DEBUG) && IPTV_LOGGING_METHOD != 0
       
   406     private:
       
   407         /**
       
   408          * Debug only: Prints list of videos to debug output.
       
   409          */
       
   410         void DebugPrintVideoListL( CMPXMediaArray* aVideoArray );
       
   411 #endif // _DEBUG && IPTV_LOGGING_METHOD        
       
   412         
       
   413         /**
       
   414          * Variable for storing current MPX collection level.
       
   415          */
       
   416         TInt iCollectionLevel;
       
   417     };
       
   418 
       
   419 #endif // VCXHGMYVIDEOSCOLLECTIONCLIENT_H