videocollection/mpxmyvideoscollection/tsrc/ut_collectionplugintest/inc/vcxmyvideosalbum.h
branchRCL_3
changeset 70 375929f879c2
equal deleted inserted replaced
64:3eb824b18d67 70:375929f879c2
       
     1 /*
       
     2 * Copyright (c) 2007 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 
       
    10 * Initial Contributors:
       
    11 * Nokia Corporation - initial contribution.
       
    12 *
       
    13 * Contributors:
       
    14 *
       
    15 * Description:   Class representing album in My Videos collection.
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CVCXMYVIDEOSALBUM_H
       
    20 #define CVCXMYVIDEOSALBUM_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 
       
    26 class CMPXMedia;
       
    27 class CVcxMyVideosCollectionPlugin;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32  * Contains information about video which belongs to some album.
       
    33  * These are stored to CVcxMyVideosAlbum::iVideoList.
       
    34  */
       
    35 NONSHARABLE_CLASS(TVcxMyVideosAlbumVideo)
       
    36     {
       
    37     public:
       
    38 
       
    39         /**
       
    40          * Constructor.
       
    41          */
       
    42         TVcxMyVideosAlbumVideo();
       
    43 
       
    44         /**
       
    45         * = operator.
       
    46         */        
       
    47         TVcxMyVideosAlbumVideo& operator=( const TVcxMyVideosAlbumVideo& aVideo );
       
    48     private:
       
    49         
       
    50         /**
       
    51         * Set values.
       
    52         */
       
    53         void Set( TUint32 aMdsId, TUint32 aRelationMdsId, CMPXMedia* aVideo );
       
    54 
       
    55     public:
       
    56         TUint32    iMdsId;         //Video object ID in MDS.
       
    57         TUint32    iRelationMdsId; //Relation ID in MDS, this is used when removing items from album.
       
    58         CMPXMedia* iMedia;
       
    59     };
       
    60 
       
    61 /**
       
    62  * Contains list of videos belonging to an album. Videos can be searched, added and
       
    63  * removed. Videos are kept in sorting order by MDS ID to speed up access. Pointers
       
    64  * to media objects in collection cache are also stored to speed up access.
       
    65  * Contains also logic for keeping album media attributes up to date.
       
    66  */
       
    67 NONSHARABLE_CLASS(CVcxMyVideosAlbum) : public CBase
       
    68     {    
       
    69 public:
       
    70     // Constructors and destructor
       
    71 
       
    72     /**
       
    73      * Destructor.
       
    74      */
       
    75     ~CVcxMyVideosAlbum();
       
    76 
       
    77     /**
       
    78      * Two-phased constructor.
       
    79      */
       
    80     static CVcxMyVideosAlbum* NewL( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
       
    81 
       
    82     /**
       
    83      * Two-phased constructor.
       
    84      */
       
    85     static CVcxMyVideosAlbum* NewLC( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
       
    86 
       
    87     // new methods
       
    88     
       
    89     /**
       
    90      * Sets up this album.
       
    91      * 
       
    92      * @param aAlbum  Media class to set from.
       
    93      */
       
    94     void SetL( /*CMPXMedia& aAlbum*/ );
       
    95     
       
    96     /**
       
    97      * Sorts iVideoList by MDS ID.
       
    98      */
       
    99     void Sort();
       
   100     
       
   101     /**
       
   102      * Checks if aMdsId belongs to this album. Checking is
       
   103      * done using bisection method.
       
   104      * 
       
   105      * @param aMdsId  Id to check.
       
   106      */
       
   107     TBool BelongsToAlbum( TUint32 aMdsId );
       
   108 
       
   109     /**
       
   110      * Finds video from iVideoList. Uses bisection method, ie
       
   111      * is fast.
       
   112      * 
       
   113      * @param aMdsId  Video to find.
       
   114      * @param aVideo  If found, this is filled with data.
       
   115      * @param aIndex  Position in iVideoList where from the video
       
   116      *                was found.
       
   117      * @return        System-wide error code. If != KErrNone, then
       
   118      *                aVideo and aIndex won't contain valid data.
       
   119      */
       
   120     TInt Video( TUint32 aMdsId, TVcxMyVideosAlbumVideo& aVideo, TInt& aIndex );
       
   121 
       
   122     /**
       
   123      * Adds aVideo to this album. The id array is kept in ascending order.
       
   124      * 
       
   125      * @param aVideo  Video to add.
       
   126      */
       
   127     void AddL( TVcxMyVideosAlbumVideo aVideo );
       
   128 
       
   129     /**
       
   130      * Removes videos from this album.
       
   131      * 
       
   132      * @param aMdsIds Array containing IDs of the videos to remove.
       
   133      */
       
   134     void Remove( RArray<TUint32>& aMdsIds );
       
   135 
       
   136     /**
       
   137      * Removes aMdsId from this album.
       
   138      * 
       
   139      * @param aMdsId    ID to remove.
       
   140      * @param aCompress If ETrue, then Compress is called to iVideoList.
       
   141      *                  ETrue as default.
       
   142      */
       
   143     void Remove( TUint32 aMdsId, TBool aCompress = ETrue );
       
   144     
       
   145     /**
       
   146      * Used for keeping RArray<TVcxMyVideosAlbumVideo> in integer order by
       
   147      * TVcxMyVideosAlbumVideo::iMdsId.
       
   148      * 
       
   149      * @param aVideo1 Video to compare
       
   150      * @param aVideo2 Video to compare
       
   151      * @return -1 if aVideo1 is smaller than aVideo2, 1 if aVideo1 is larger than
       
   152      *         aVideo2.
       
   153      */
       
   154     static TInt CompareVideosByMdsId( const TVcxMyVideosAlbumVideo& aVideo1,
       
   155             const TVcxMyVideosAlbumVideo& aVideo2 );
       
   156 
       
   157     /**
       
   158      * Creates video list belonging to this album. Ownership goes to caller.
       
   159      * 
       
   160      * @return Media containing media array. Array items are videos.
       
   161      */
       
   162     CMPXMedia* CreateVideoListL();
       
   163 
       
   164     /**
       
   165      * Appends items from aFromVideoList to aToVideoList if they belong to
       
   166      * this album.
       
   167      * 
       
   168      * @param aFromVideoList     From list.
       
   169      * @param aToVideoList       To List.
       
   170      * @param aNewItemStartIndex Start index of the copy. Items in aFromVideoList before this
       
   171      *                           value are ignored.
       
   172      */
       
   173     void AppendToVideoListL( CMPXMedia& aFromVideoList,
       
   174             CMPXMedia& aToVideoList, TInt aNewItemStartIndex );
       
   175 
       
   176     /**
       
   177      * Calculates KVcxMediaMyVideosCategoryItemCount, KVcxMediaMyVideosCategoryNewItemCount,
       
   178      * KVcxMediaMyVideosCategoryNewItemName and KMPXMediaGeneralDate attributes to iMedia.
       
   179      * 
       
   180      * @return Returns ETrue if album attributes were modified, EFalse otherwise.
       
   181      */
       
   182     TBool CalculateAttributesL();
       
   183     
       
   184 private:
       
   185 
       
   186     /**
       
   187      * Constructor for performing 1st stage construction
       
   188      */
       
   189     CVcxMyVideosAlbum( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
       
   190 
       
   191     /**
       
   192      * EPOC default constructor for performing 2nd stage construction
       
   193      */
       
   194     void ConstructL();
       
   195 
       
   196 private: //data
       
   197     CVcxMyVideosCollectionPlugin& iCollection;
       
   198     
       
   199 public: //data
       
   200     
       
   201     /**
       
   202      * MDS ID of this album.
       
   203      */
       
   204     TUint32 iMdsId;
       
   205 
       
   206     /**
       
   207      * MPX media object representing this album in collection, not own.
       
   208      * The item is owned by CVcxMyVideosAlbums::iAlbumList
       
   209      */
       
   210     CMPXMedia* iMedia;
       
   211 
       
   212     /**
       
   213      * Array containing info about videos belonging to this album.
       
   214      */
       
   215     RArray<TVcxMyVideosAlbumVideo> iVideoList;
       
   216             
       
   217     };
       
   218 
       
   219 #endif // CVCXMYVIDEOSALBUM_H