videofeeds/vcnsuiengine/inc/vcxnscontentprovider.h
changeset 0 96612d01cf9f
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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_VCXNSCONTENTPROVIDER_H
       
    22 #define C_VCXNSCONTENTPROVIDER_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <mpxitemid.h>
       
    27 #include "CIptvUtil.h" 
       
    28 
       
    29 #include "vcxnscontentproviderif.h"
       
    30 #include "vcxnscontentproviderobserver.h"
       
    31 #include "vcxnscontent.h"
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class MVcxNsContentProviderObserver;
       
    35 class CVcxNsUiEngine;
       
    36 class CVcxNsContentList;
       
    37 class CIptvMediaContent;
       
    38 class CIptvVodContentContentBriefDetails;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * Class CVcxNsContentProvider handles application contents.
       
    44 *
       
    45 * @lib vcxnsuiengine.lib
       
    46 */
       
    47 class CVcxNsContentProvider : public CBase,
       
    48                               public MVcxNsContentProviderIf
       
    49     { 
       
    50 
       
    51 public:
       
    52 
       
    53     /**
       
    54      * Constructor.
       
    55      * @param aUiEngine Ui engine
       
    56      */
       
    57     static CVcxNsContentProvider* NewL( CVcxNsUiEngine& aUiEngine );
       
    58 
       
    59     virtual ~CVcxNsContentProvider();
       
    60 
       
    61     /**
       
    62      * RegisterObserver.
       
    63      * @param aObserver Observer
       
    64      */
       
    65     void RegisterObserver( MVcxNsContentProviderObserver* aObserver );
       
    66 
       
    67     /**
       
    68      * DeRegisterObserver.
       
    69      * @param aObserver Observer
       
    70      */
       
    71     void DeRegisterObserver( MVcxNsContentProviderObserver* aObserver );
       
    72 
       
    73     /**
       
    74      * Get contents with highlighted position
       
    75      * @param aHighlight On return, highlight index for content list
       
    76      * @return Array of contents.
       
    77      */
       
    78     RPointerArray<CVcxNsContent>& GetContentsL( TInt& aHighlight );
       
    79     
       
    80     /**
       
    81      * Gets contents.
       
    82      *
       
    83      * @return Vod contents
       
    84      */
       
    85     RPointerArray<CVcxNsContent>& GetContentsL();
       
    86     
       
    87     /**
       
    88      * Reset the contents with given service id.
       
    89      *
       
    90      * @param aServiceId Service id
       
    91      */
       
    92     void RemoveServiceData( TUint32 aServiceId );
       
    93 
       
    94     /**
       
    95      * Reset the contents of specified category in service.
       
    96      * Note: This is usually done only for search category when
       
    97      * search results are cleared before new search.
       
    98      *
       
    99      * @param aServiceId Service id
       
   100      * @param aCategoryId Category id
       
   101      */
       
   102     void RemoveCategoryData( TUint32 aServiceId, TUint32 aCategoryId );
       
   103     
       
   104     /**
       
   105      * Handle the back command by choosing new application state.
       
   106      * @return Was the back event consumed. If EFalse, 
       
   107      *         the back event should be handled by caller.     
       
   108      */
       
   109     TBool HandleBack();
       
   110     
       
   111     /**
       
   112      * Starts the content update.
       
   113      *
       
   114      * @return KErrNone or one of the system wide error codes.
       
   115      */
       
   116     TInt RefreshContentsL();
       
   117 
       
   118     /**
       
   119      * Starts download of given content item.
       
   120      * @param aIndex Index of the content to be downloaded
       
   121      * @return KErrNone or one of the system wide error codes.
       
   122      */
       
   123     TInt StartDownloadL( TInt aIndex );
       
   124       
       
   125     /**
       
   126      * Pause download of given content item.
       
   127      * 
       
   128      * @param aIndex Index of the content item.
       
   129      * @return KErrNone or one of the system wide error codes.
       
   130      */
       
   131     TInt PauseDownloadL( TInt aIndex );
       
   132     
       
   133     /**
       
   134      * Resume download of given content item.
       
   135      * 
       
   136      * @param aIndex Index of the content item.
       
   137      * @return KErrNone or one of the system wide error codes.
       
   138      */
       
   139     TInt ResumeDownloadL( TInt aIndex );
       
   140     
       
   141     /**
       
   142      * Resume download of given content item.
       
   143      * 
       
   144      * @param aContent Content details
       
   145      * @return KErrNone or one of the system wide error codes.
       
   146      */
       
   147     TInt ResumeDownloadL( CVcxNsContent& aContent );
       
   148     
       
   149     /**
       
   150      * Cancels downloading of given content item.
       
   151      * 
       
   152      * @param aIndex Index of the content item.
       
   153      * @return KErrNone or one of the system wide error codes.
       
   154      */
       
   155     TInt CancelDownloadL( TInt aIndex );
       
   156     
       
   157     /**
       
   158      * Search content by uri.
       
   159      * @param aUri uri of the content to be found
       
   160      * @return Content which has the given uri or NULL if not found.
       
   161      */
       
   162     CVcxNsContent* SearchContentByUri( const TDesC& aUri );
       
   163     
       
   164     /**
       
   165      * Search content by TMPXItemId.
       
   166      * @param aItemId MPX item id
       
   167      * @return Content which has the given TMPXItemId or NULL if not found.
       
   168      */
       
   169     CVcxNsContent* SearchContentByMpxId( TMPXItemId aItemId );
       
   170     
       
   171     /**
       
   172      * Search content by id.
       
   173      * @param aServiceId  Service id  
       
   174      * @param aContentId  Content id
       
   175      * @return Content which has the given service and content id.
       
   176      */
       
   177     CVcxNsContent* SearchContentById( TUint32 aServiceId, TUint32 aContentId );
       
   178     
       
   179     /**
       
   180      * Search content's index in ui model.
       
   181      * @param aContent Content item
       
   182      * @return Index of the content or KErrNotFound, if not visible.
       
   183      */
       
   184     TInt ContentIndex( CVcxNsContent* aContent );
       
   185     
       
   186     /**
       
   187      * Tell UI layer that the given single content item needs to be updated.
       
   188      * Event is forwarded to MVcxNsContentProviderObserver
       
   189      *
       
   190      * @param aContentdata Updated content data     
       
   191      */
       
   192     void UpdateContent( CVcxNsContent* aContentdata );
       
   193     
       
   194     /**
       
   195      * Fetches the icons path from epg database and 
       
   196      * updates them to current content array.
       
   197      */
       
   198     void UpdateIconsPathL();
       
   199     
       
   200     /**
       
   201      * Get the content with given id by any means.
       
   202      * @param aServiceId  Service id  
       
   203      * @param aContentId  Content id
       
   204      * @return Content which has the given service and content id.
       
   205      */
       
   206     CVcxNsContent* GetContentL( TUint32 aServiceId, TUint32 aContentId );
       
   207 
       
   208 // From MVcxNsContentProviderObserver
       
   209 
       
   210     /**
       
   211      * Content update notification.
       
   212      *
       
   213      * @param aIndex Updated item's index
       
   214      */
       
   215     void ContentUpdated( TInt aIndex );
       
   216     
       
   217     /**
       
   218      * View needs to be refreshed.
       
   219      */
       
   220     void RefreshView();
       
   221 
       
   222     /**
       
   223      * Application state needs to be updated.
       
   224      */
       
   225     void HandleAppStateChangedL();
       
   226 
       
   227     /**
       
   228      * Epg update is ongoing, show the notification.
       
   229      * When downloading and parsing the xml, both parameters are 0.
       
   230      * 
       
   231      * @param aShow If ETrue, show the note, if EFalse, hide it.
       
   232      * @param aDownloadedTbns count of downloaded thumbnails.
       
   233      * @param aTotalTbns Total count of thumbnails to be downloaded.
       
   234      */
       
   235     void ShowUpdatingNoteL( TBool aShow, TInt aDownloadedTbns, TInt aTotalTbns );
       
   236     
       
   237     /**
       
   238      * Store the last play position to epg db.
       
   239      * This is intended to be used just with streams,
       
   240      * video attributes are managed by MPX collection.
       
   241      * @param aContent Content item
       
   242      * @param aType Media content access type 
       
   243      * @param aPos Last play position to be set
       
   244      */
       
   245     void StoreLastPlayPosL( CVcxNsContent* aContent, 
       
   246                             CVcxNsContent::TVcxNsContentAccessType aType,
       
   247                             TReal32 aPos );
       
   248     
       
   249     
       
   250     /**
       
   251      * Handle error, send error information to UI.
       
   252      *
       
   253      * @param aError Error code.
       
   254      * @param aUpdate ETrue if error comes from epg update. 
       
   255      *                EFalse if error is from download.
       
   256      * @param aServiceId Service ID
       
   257      */
       
   258     void HandleErrorL( TInt aError, TBool aUpdate, TUint32 aServiceId );
       
   259     
       
   260     /**
       
   261      * Handle dl error. 
       
   262      *
       
   263      * @param aError Error code.
       
   264      * @param aContent Details of the failed video content.
       
   265      */
       
   266     void HandleDlErrorL( TIptvDlError aError, CVcxNsContent& aContent );
       
   267     
       
   268     /**
       
   269      * Checks if video has more details than just name
       
   270      * 
       
   271      * @param aSelected Index of selected item
       
   272      * @return Does the video have other details than just name
       
   273      */
       
   274      TBool HasVideoDetailsL( TInt aSelected );
       
   275         
       
   276      /**
       
   277       * Fetches full video details
       
   278       * 
       
   279       * @param aSelected Index of selected item
       
   280       * @return Content full details
       
   281       */
       
   282      CVcxNsContent* GetFullDetailsL( TInt aSelected );
       
   283      
       
   284      /**
       
   285       * Save content view highlight for currently active category. 
       
   286       * @param aHighlight Highlight index to save.
       
   287       */
       
   288      void SetContentHighlight( TInt aHighlight );
       
   289      
       
   290      /**
       
   291       * Fetches full details for the given content item.
       
   292       * 
       
   293       * @param aContent Content, which details to fetch
       
   294       */
       
   295      void FetchFullDetailsL( CVcxNsContent* aContent );
       
   296 
       
   297 private:
       
   298 
       
   299     /**
       
   300      * Constructor.
       
   301      * @param aUiEngine Ui engine
       
   302      */
       
   303     CVcxNsContentProvider( CVcxNsUiEngine& aUiEngine );
       
   304 
       
   305     /**
       
   306      * Get content list from cache.
       
   307      * @return Content list
       
   308      */
       
   309     CVcxNsContentList* GetListFromCache();
       
   310     
       
   311     /**
       
   312      * Get the Content data from DB
       
   313      * @return Content list
       
   314      */
       
   315     CVcxNsContentList* LoadEpgDataL();
       
   316     
       
   317     /**
       
   318      * Adds contents which has mds ids to mpx client's downlolad list.
       
   319      * @param aContentList Content list, which items to add to dl list
       
   320      */
       
   321     void BuildDownloadListL( RPointerArray<CVcxNsContent>& aContentList );
       
   322     
       
   323     /**
       
   324      * Adds valid content accesses from the list to the content.
       
   325      * @param aContent Content item
       
   326      * @param aContentAccessList Content access list
       
   327      */
       
   328     void AddContentAccessesL( CVcxNsContent& aContent, 
       
   329                     RPointerArray<CIptvMediaContent>& aContentAccessList );
       
   330     
       
   331     /**
       
   332      * Creates ns content item from server side videocenter content object.
       
   333      * @param aData Source content data class
       
   334      * @param aServiceId Content's service ID 
       
   335      * @return Newly constructed content item
       
   336      */
       
   337     CVcxNsContent* ConstructContentItemL( CIptvVodContentContentBriefDetails* aData,
       
   338                                           TUint32 aServiceId );
       
   339     
       
   340 // Data
       
   341     
       
   342     /**
       
   343      * Array of content event observers. Not Own.
       
   344      */
       
   345     RPointerArray<MVcxNsContentProviderObserver> iContentObservers;
       
   346     
       
   347     /**
       
   348      * UI engine.
       
   349      */
       
   350     CVcxNsUiEngine& iUiEngine;
       
   351 
       
   352     /**
       
   353      * Array of content lists.
       
   354      */
       
   355     RPointerArray<CVcxNsContentList> iContentListList;
       
   356     
       
   357     /**
       
   358      * Pointer to previously fetched content list.
       
   359      * 
       
   360      * Owned elsewhere.
       
   361      */
       
   362     CVcxNsContentList* iPreviousList;
       
   363 
       
   364     };
       
   365 
       
   366 #endif // C_VCXNSCONTENTPROVIDER_H