videocollection/mpxmyvideoscollection/tsrc/ut_collectionplugintest/inc/vcxmyvideoscategories_stub.h
branchRCL_3
changeset 70 375929f879c2
equal deleted inserted replaced
64:3eb824b18d67 70:375929f879c2
       
     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:    Categories related functionality*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef VCXMYVIDEOSCATEGORIES_H
       
    21 #define VCXMYVIDEOSCATEGORIES_H
       
    22 
       
    23 // INCLUDES
       
    24 
       
    25 #include <vcxmyvideosdefs.h>
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CMPXMedia;
       
    29 class CVcxMyVideosCollectionPlugin;
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36 * MPX My Videos collection categories implementation.
       
    37 *
       
    38 * @lib mpxmyvideoscollectionplugin.lib
       
    39 */
       
    40 NONSHARABLE_CLASS(CVcxMyVideosCategories) : CBase
       
    41     {    
       
    42     public: // Constructors and destructor
       
    43 
       
    44         /**
       
    45         * Two-phased constructor
       
    46         * @return object constructed
       
    47         */
       
    48         static CVcxMyVideosCategories* NewL ( CVcxMyVideosCollectionPlugin& aCollection );
       
    49 
       
    50         /**
       
    51         * Destructor
       
    52         */
       
    53         virtual ~CVcxMyVideosCategories();
       
    54 
       
    55         /**
       
    56         * Creates Media container with categories.
       
    57         */
       
    58         CMPXMedia* CreateCategoryListL();
       
    59 
       
    60     public: // new methods
       
    61     
       
    62         /**
       
    63         * When CVcxMyVideosVideoCache::iCache->iVideoList is grown (appended),
       
    64         * this is called to update category attributes.
       
    65         *
       
    66         * @param aVideoList          Current video list cache.
       
    67         * @param aNewItemsStartIndex Start position of new items.
       
    68         */
       
    69         void UpdateCategoriesL( CMPXMedia& aVideoList, TInt aNewItemsStartIndex );
       
    70  
       
    71         /**
       
    72         * Called after video is added to iCollection.iCache.
       
    73         * Updates category variables accordingly.
       
    74         * Modify events to iCollection.iMessageList are added, but the list
       
    75         * is not sent.
       
    76         *
       
    77         * @param aMdsId Item which was added.
       
    78         */
       
    79         void VideoAddedL( TUint32 aMdsId );
       
    80 
       
    81 
       
    82         /**
       
    83         * Called after video is added to iCollection.iCache.
       
    84         * Updates category variables accordingly.
       
    85         * Modify events to iCollection.iMessageList are added, but the list
       
    86         * is not sent.
       
    87         *
       
    88         * @param aVideo Item which was added.
       
    89         */
       
    90         void VideoAddedL( CMPXMedia& aVideo );
       
    91 
       
    92         /**
       
    93         * Called after videos are added to iCollection.iCache.
       
    94         * Updates category variables accordingly.
       
    95         * Modify events to iCollection.iMessageList are added, but the list
       
    96         * is not sent.
       
    97         *
       
    98         * @param aIds Items which were added.
       
    99         */
       
   100         void VideosAddedL( RArray<TUint32>& aIds );
       
   101 
       
   102         /**
       
   103         * Called just _before_ video is removed from iCollection.iCache.
       
   104         * Updates category variables accordingly.
       
   105         * Modify events to iCollection.iMessageList are added, but the list
       
   106         * is not sent.
       
   107         *
       
   108         * @param aMdsId Item which is being removed.
       
   109         */
       
   110         void VideoRemovedL( TUint32 aMdsId );
       
   111 
       
   112         /**
       
   113         * Called just _before_ video is removed from iCollection.iCache.
       
   114         * Updates category variables accordingly.
       
   115         * Modify events to iCollection.iMessageList are added, but the list
       
   116         * is not sent.
       
   117         *
       
   118         * @param aVideo Item which is being removed.
       
   119         */
       
   120         void VideoRemovedL( CMPXMedia& aVideo );
       
   121 
       
   122         /**
       
   123         * Called just _before_ videos are removed from iCollection.iCache.
       
   124         * Updates category variables accordingly.
       
   125         * Modify events to iCollection.iMessageList are added, but the list
       
   126         * is not sent.
       
   127         *
       
   128         * @param aIds Items which are being removed.
       
   129         */
       
   130         void VideosRemovedL( RArray<TUint32>& aIds );
       
   131 
       
   132         /**
       
   133         * Resets video counters to 0 from categories. Does not
       
   134         * send events.
       
   135         */
       
   136         void ResetVideoCountersL();
       
   137 
       
   138         /**
       
   139         * Updates categories' New Video Name fields.
       
   140         * Sends iCollection.iMessageList if any of the categories is modified.
       
   141         */
       
   142         void UpdateCategoriesNewVideoNamesL();
       
   143         
       
   144         
       
   145         /**
       
   146         * Called when video is updated in a way it affects New Video Name (and date) in category.
       
   147         * This updates the category accordinly. This function adds modify events to
       
   148         * collections message list if category is edited. Does not flush the message list.
       
   149         *
       
   150         * @param aVideo     Video which was changed.
       
   151         * @param aModified  Set to ETrue if categories were modified.
       
   152         */
       
   153         void UpdateCategoryNewVideoNameAndDateL( CMPXMedia& aVideo, TBool& aModified );
       
   154         
       
   155         /**
       
   156         * Called when items New Video Flag is updated in iCollection.iCache.
       
   157         * This function updates video counters only, no New Video Name.
       
   158         *
       
   159         * @param aOldFlags  Items flags before update.
       
   160         * @param aNewFlags  Items flags after update.
       
   161         * @param aOrigin    Which origin is affected.
       
   162         * @param aModified  Set to ETrue if category counters were edited and events
       
   163         *                   were added to message list. This does not flush the message list.
       
   164         */
       
   165         void NewVideoFlagChangedL( TUint32 aOldFlags, TUint32 aNewFlags,
       
   166                 TUint8 aOrigin, TBool& aModified );        
       
   167 
       
   168         /**
       
   169         * Checks in which categories the video belongs to and sends modified events for them.
       
   170         *
       
   171         * @param aVideo             Video which was modified.
       
   172         * @param aFlushMessageList  If ETrue, then the collections message list is sent to clients.
       
   173         * @param aExtraInfo         Extra information about the event, this value is written to
       
   174         *                           KVcxMediaMyVideosInt32Value attribute. If aExtraInfo
       
   175         *                           is 0, nothing is written.
       
   176         */
       
   177         void GenerateCategoryModifiedEventL( CMPXMedia& aVideo, TBool aFlushMessageList,
       
   178                 TInt32 aExtraInfo = 0 );
       
   179 
       
   180         /**
       
   181         * Called when videos origin is changed in iCollection.iCache.
       
   182         * Updates category variables and sends necessarry events.
       
   183         *
       
   184         * @param aVideo       Video which is changed, flags variable is read from here.
       
   185         * @param aPrevOrigin  Previous origin.
       
   186         * @param aNewOrigin   New origin.
       
   187         */
       
   188         void OriginChangedL( CMPXMedia& aVideo, TUint8 aPrevOrigin, TUint8 aNewOrigin );
       
   189                     
       
   190     private:
       
   191         /**
       
   192         * Constructor
       
   193         */
       
   194         CVcxMyVideosCategories( CVcxMyVideosCollectionPlugin& aCollectionPlugin );
       
   195 
       
   196         /**
       
   197         * Symbian 2nd phase constructor.
       
   198         */
       
   199         void ConstructL ();
       
   200         
       
   201         /**
       
   202         * Creates CMPXMedia object with category values and appends it to
       
   203         * aCategoryArray.
       
   204         *
       
   205         * @param aTitle         Category title.
       
   206         * @param aId            Collection item ID
       
   207         * @param aCategoryArray New CMPXMedia category object is appended here. 
       
   208         */
       
   209         void AppendCategoryToArrayL( const TDesC& aTitle, TMPXItemId aId,
       
   210                 CMPXMediaArray& aCategoryArray );
       
   211                 
       
   212         /**
       
   213         * Updates video counts in categories.
       
   214         *
       
   215         * @param aCategoryArray       Category array, provided as function parameter since the
       
   216         *                             calling function already has it available.
       
   217         * @param aVideosIncrements    How many new items were added to each category.
       
   218         * @param aNewVideosIncrements How many videos with new flag were added to each category.
       
   219         */
       
   220         void UpdateVideosCountL( CMPXMediaArray& aCategoryArray,
       
   221                 RArray<TInt>& aVideosIncrements, RArray<TInt>& aNewVideosIncrements );
       
   222 
       
   223         /**
       
   224         * Increases/decreases aCountAttribute in aCategory. Adds event to
       
   225         * iCollection.iMessageList if category is modified. aEventInfo is written
       
   226         * to event's extra info. Does not flush iCollection.iMessageList.
       
   227         *
       
   228         * @param aCategory       Category being modified.
       
   229         * @param aIncrement      This is added to category's current attribute value.
       
   230         * @param aCountAttribute Attribute ID.
       
   231         * @param aEventInfo      This is written to generated event's extra info attribute.
       
   232         * 
       
   233         */
       
   234         void UpdateVideosCountL( CMPXMedia& aCategory, TInt aIncrement,
       
   235                 TMPXAttributeData aCountAttribute, TInt aEventInfo );
       
   236 
       
   237         /**
       
   238         * aVideo is added(or removed) to aCategory. Updates category variables accordingly. 
       
   239         *
       
   240         * @param aCategory      Category
       
   241         * @param aCategoryIndex Category index in iList
       
   242         * @param aAdded         ETrue if aVideo was added to iList, EFalse if being removedo.
       
   243         */
       
   244         void UpdateCategoryL( CMPXMedia& aCategory, TInt aCategoryIndex,
       
   245                 CMPXMedia& aVideo, TBool aAdded );
       
   246 
       
   247         /**
       
   248         * Adds aAddition to aAttribute in aCategory.
       
   249         *
       
   250         * @param aCategory  Category to modify.
       
   251         * @param aAddition  How much increase/decrease the attribute.
       
   252         * @param aAttribute Which attribute to modify.
       
   253         */
       
   254         void AddToTUint32AttributeL( CMPXMedia& aCategory, TInt aAddition,
       
   255                 TMPXAttributeData aAttribute );
       
   256 
       
   257         /**
       
   258         * Returns the corresponding category index in category list (=iList) for aOrigin.
       
   259         * Notice that category index is the same as categorys MPXIDs iId1 value.
       
   260         * They should be kept the same.
       
   261         *
       
   262         * @param aOrigin  Origin, see values from TVcxMyVideosOrigin, if -1 given, then
       
   263         *                 index for All category is returned.
       
   264         * @return         Index in category list (=iList)
       
   265         */
       
   266         TInt CategoryIndex( TInt aOrigin );
       
   267                 
       
   268         /**
       
   269         * Updates categorys New Video Name and Creation date fields. Sets aModified to
       
   270         * ETrue if value is changed, also adds modify event to event list,
       
   271         * but does not send it.
       
   272         *
       
   273         * @param aOrigin     Identifies the category, -1 is used for All category.
       
   274         * @param aModified   Set to ETrue if category item is modified. Otherwise
       
   275         *                    the value is not touched.
       
   276         * @param aIgnoredIds Items with these MDS ids are ignored on the update.
       
   277         *                    Usefull if items are being deleted but are still on the
       
   278         *                    video list.
       
   279         */
       
   280         void UpdateCategoryNewVideoNameAndDateL( TInt aOrigin, TBool& aModified,
       
   281                 RArray<TUint32>& aIgnoredIds );
       
   282         
       
   283         /**
       
   284         * Goes through aVideoList and checks all videos which have new video
       
   285         * flag set and returns the latest ones name. Pointer to latest video
       
   286         * object is written to aNewVideo.
       
   287         *
       
   288         * @param aVideoList  Video list
       
   289         * @param aOrigin     Can be used to filter search. Only items which have
       
   290         *                    matching origin are included to the operation.
       
   291         *                    If -1, then all items are included.
       
   292         * @param aIgnoredIds Items with these MDS ids are ignored on the update.
       
   293         *                    Usefull if items are being deleted but are still on the
       
   294         *                    video list.
       
   295         * @param aNewVideo   Pointer to media object containing the new video name is
       
   296         *                    written here. NULL is written if not found. Ownership
       
   297         *                    does not move (stays in aVideoList).
       
   298         *                   
       
   299         */
       
   300         const TDesC& CalculateNewVideoNameL( CMPXMedia& aVideoList, TInt aOrigin,
       
   301                 RArray<TUint32>& aIgnoredIds, CMPXMedia*& aNewVideo );
       
   302 
       
   303         /**
       
   304         * Video was added or is being removed in iCollection.iCache. Update
       
   305         * Categories accordingly.
       
   306         *
       
   307         * @param aMdsId Item which was added or removed.
       
   308         * @param aAdded ETrue if add operation, EFalse if remove.
       
   309         */
       
   310         void VideoAddedOrRemovedL( TUint32 aMdsId, TBool aAdded );
       
   311 
       
   312         /**
       
   313         * Video was added or is being removed in iCollection.iCache. Update
       
   314         * Categories accordingly.
       
   315         *
       
   316         * @param aVideo Item which was added or removed.
       
   317         * @param aAdded ETrue if add operation, EFalse if remove.
       
   318         */
       
   319         void VideoAddedOrRemovedL( CMPXMedia& aVideo, TBool aAdded );
       
   320 
       
   321         /**
       
   322         * Videos were added or are being removed in iCollection.iCache. Update
       
   323         * Categories accordingly.
       
   324         *
       
   325         * @param aIds Items which were added or are being removed.
       
   326         * @param aAdded ETrue if add operation, EFalse if remove.
       
   327         */
       
   328         void VideosAddedOrRemovedL( RArray<TUint32>& aIds, TBool aAdded );
       
   329 
       
   330         /**
       
   331         * Resets iModifiedCategories
       
   332         */
       
   333         void ResetModifiedCategoriesArray();
       
   334 
       
   335         /**
       
   336         * Creates events from iModifiedCategories and adds them
       
   337         * to iCollection.iMessageList. Does not send.
       
   338         */
       
   339         void AddEventsFromModifiedCategoriesArrayL();
       
   340         
       
   341     public:
       
   342     
       
   343         /**
       
   344         * Contains category list, this is kept in memory to speed things up.
       
   345         * Own.
       
   346         */
       
   347         CMPXMedia* iList;
       
   348         
       
   349         /**
       
   350         * Media array of iList, owned by iList.
       
   351         */
       
   352         CMPXMediaArray* iListArray;
       
   353     
       
   354     private:
       
   355         
       
   356         /**
       
   357         * Owner of this object.
       
   358         */
       
   359         CVcxMyVideosCollectionPlugin& iCollection;
       
   360         
       
   361         /**
       
   362         * Array containing boolean for each category, if set ETrue, then modified event
       
   363         * has been added for the category (to iCollection.iMessageList).
       
   364         */
       
   365         RArray<TBool> iModifiedCategories;
       
   366 
       
   367     public:     // Friend classes
       
   368         
       
   369         friend class CCollectionPluginTest;        
       
   370     };
       
   371 
       
   372 #endif   // VCXMYVIDEOSCATEGORIES_H
       
   373 
       
   374