videofeeds/vcnsuiengine/inc/vcxnsdownloadupdater.h
branchRCL_3
changeset 57 befca0ec475f
parent 0 96612d01cf9f
equal deleted inserted replaced
56:839377eedc2b 57:befca0ec475f
       
     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_CVCXNSDOWNLOADUPDATER_H
       
    22 #define C_CVCXNSDOWNLOADUPDATER_H
       
    23 
       
    24 #include <e32std.h>
       
    25 #include <e32base.h>
       
    26 #include "CIptvUtil.h"
       
    27 
       
    28 class CPeriodic;
       
    29 class CVcxNsContent;
       
    30 
       
    31 /**
       
    32  *  @lib vcxnsuiengine
       
    33  *  @since S60 5.0
       
    34  * 
       
    35  *  Observer interface for the CVcxNsDownloadUpdater class,
       
    36  *  receives notification if the object with given mpx id has 
       
    37  *  changed, and needs to be refreshed.
       
    38  */
       
    39 class MVcxNsDownloadUpdaterObserver
       
    40     {
       
    41     
       
    42 public:
       
    43 
       
    44     /**
       
    45      * Notify, that the object with given mpx id has 
       
    46      * changed, and needs to be refreshed.
       
    47      * @param aMpxId Mpx media id
       
    48      */
       
    49     virtual void UpdateVideoObject( TUint32 aMpxId ) = 0;
       
    50     
       
    51     /**
       
    52      * Notifies that resume has started from beginning.
       
    53      * @param aMpxId MPX Media Id of the video object.
       
    54      */
       
    55     virtual void ResumeStartedFromBeginningL( TUint32 aMpxId ) = 0;
       
    56     };
       
    57 
       
    58 /**
       
    59  *  @lib vcxnsuiengine
       
    60  *  @since S60 5.0
       
    61  */
       
    62 NONSHARABLE_CLASS( CVcxNsDownloadUpdater ) : public CBase
       
    63     {
       
    64 
       
    65 private:
       
    66 
       
    67     /**
       
    68      * TDownloadItem
       
    69      * Private inner class for storing polled downloads and their
       
    70      * previous statuses and progresses.
       
    71      */
       
    72     class TDownloadItem
       
    73         {
       
    74 
       
    75     public:
       
    76 
       
    77         /**
       
    78          * Content object. Must not be deleted until the remove is called
       
    79          */
       
    80         CVcxNsContent* iContent;
       
    81     
       
    82         /**
       
    83          * Old state, used for determine refresh need.
       
    84          */
       
    85         TUint32 iState;
       
    86         
       
    87         /**
       
    88          * Old progress, used for determine refresh need.
       
    89          */
       
    90         TUint32 iProgress;
       
    91 
       
    92         };
       
    93 
       
    94 public:
       
    95 
       
    96     /**
       
    97      * Two-phased constructor.
       
    98      * @param aObserver Callback observer
       
    99      */
       
   100     static CVcxNsDownloadUpdater* NewL( MVcxNsDownloadUpdaterObserver* aObserver );
       
   101     
       
   102     /**
       
   103      * Destructor.
       
   104      */
       
   105     virtual ~CVcxNsDownloadUpdater();
       
   106 
       
   107     /**
       
   108      * Adds download to the refresh list.
       
   109      * @note Content object must not be deleted until remove is called
       
   110      * @param aContent Content object
       
   111      */
       
   112     void AddDownload( CVcxNsContent* aContent );
       
   113     
       
   114     /**
       
   115      * Removes download from the refresh list.
       
   116      *
       
   117      * @param aContent Content object
       
   118      */
       
   119     void RemoveDownload( CVcxNsContent* aContent );
       
   120     
       
   121     /**
       
   122      * Removes all downloads from the refresh list.
       
   123      */
       
   124     void RemoveAllDownloads();
       
   125     
       
   126     /**
       
   127     * Periodic's callback.
       
   128     * @param aPtr Object pointer to be used with callback routine
       
   129     */
       
   130     static TInt Callback( TAny *aPtr );
       
   131     
       
   132     /**
       
   133      * Update the downloads.
       
   134      */
       
   135     void UpdateDownloadsL();
       
   136 
       
   137     /**
       
   138      * Update given download if it's status has changed.
       
   139      *  
       
   140      * @param aDownload Download item
       
   141      */
       
   142     void UpdateDownloadL( TDownloadItem& aDownload );
       
   143     
       
   144 private:
       
   145 
       
   146     /**
       
   147      * Constructor
       
   148      * @param aObserver Callback observer
       
   149      */
       
   150     CVcxNsDownloadUpdater( MVcxNsDownloadUpdaterObserver* aObserver );
       
   151 
       
   152     void ConstructL();
       
   153     
       
   154     /**
       
   155      * Find the download from the downloads list.
       
   156      * 
       
   157      * @param IN  aContent Content, to which the searched content is compared.
       
   158      * @param OUT aIndex index of found download in internal array.
       
   159      * @return Is it found.
       
   160      */
       
   161     TBool FindDownload( CVcxNsContent* aContent , TInt* aIndex );
       
   162 
       
   163 private: // data
       
   164 
       
   165     /**
       
   166      * MVcxNsDownloadUpdaterObserver
       
   167      */
       
   168     MVcxNsDownloadUpdaterObserver* iObserver;
       
   169 
       
   170     /**
       
   171      * CPeriodic. 
       
   172      * Own.
       
   173      */
       
   174     CPeriodic* iTimer;
       
   175     
       
   176     /**
       
   177      * Array of polled downloads
       
   178      * Own.
       
   179      */
       
   180     RArray<TDownloadItem> iDownloadArray;
       
   181 
       
   182     };
       
   183 
       
   184 #endif // C_CVCXNSDOWNLOADUPDATER_H