|
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: Class for following and updating download progress.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VCXHGMYVIDEOSDOWNLOADUPDATER_H |
|
21 #define VCXHGMYVIDEOSDOWNLOADUPDATER_H |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <e32std.h> |
|
25 #include <e32base.h> |
|
26 #include "CIptvUtil.h" |
|
27 #include <mpxcollectionmessagedefs.h> |
|
28 |
|
29 class CVcxHgMyVideosVideoModelHandler; |
|
30 class CPeriodic; |
|
31 class CMPXMedia; |
|
32 class CMPXMediaArray; |
|
33 class CVcxHgMyVideosVideoList; |
|
34 |
|
35 /** |
|
36 * Follows and updates download progress. |
|
37 * |
|
38 * @lib vcxhgmyvideos.lib |
|
39 */ |
|
40 NONSHARABLE_CLASS( CVcxHgMyVideosDownloadUpdater ) : public CBase |
|
41 { |
|
42 protected: |
|
43 |
|
44 /** |
|
45 * TDownloadItem |
|
46 * Private inner class for storing polled downloads and their |
|
47 * previous statuses and progresses. |
|
48 */ |
|
49 class TDownloadItem |
|
50 { |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Mpx media object. |
|
55 * Not own. |
|
56 */ |
|
57 CMPXMedia* iMedia; |
|
58 |
|
59 /** |
|
60 * Old state, used for determine refresh need. |
|
61 */ |
|
62 TVcxMyVideosDownloadState iState; |
|
63 |
|
64 /** |
|
65 * Old progress, used for determine refresh need. |
|
66 */ |
|
67 TUint32 iProgress; |
|
68 |
|
69 /** |
|
70 * Flag for marking that progressive play possibility has been queried. |
|
71 * Status is followed only for items where query has been made before. |
|
72 */ |
|
73 TBool iProgressivePlayQueried; |
|
74 |
|
75 /** |
|
76 * Previous response to CViaPlayerFileDetails::IsPlayPossible(). |
|
77 */ |
|
78 TBool iIsPlayPossible; |
|
79 }; |
|
80 |
|
81 public: |
|
82 |
|
83 /** |
|
84 * Two-phased constructor. |
|
85 * |
|
86 * @param aParent Parent class. |
|
87 * @param aVideoArray Reference to video array. |
|
88 */ |
|
89 static CVcxHgMyVideosDownloadUpdater* NewL( |
|
90 CVcxHgMyVideosVideoModelHandler& aParent, |
|
91 CVcxHgMyVideosVideoList& aVideoArray ); |
|
92 |
|
93 /** |
|
94 * Destructor. |
|
95 */ |
|
96 virtual ~CVcxHgMyVideosDownloadUpdater(); |
|
97 |
|
98 /** |
|
99 * Sets video download updater to pause or normal mode. |
|
100 * |
|
101 * @param aPaused If ETrue, updater is paused. |
|
102 */ |
|
103 void SetPausedL( TBool aPaused ); |
|
104 |
|
105 /** |
|
106 * Removes the download from download array. |
|
107 * |
|
108 * @param aMpxItemId MPX item ID of media object. |
|
109 */ |
|
110 void RemoveDownload( TMPXItemId aMpxItemId ); |
|
111 |
|
112 /** |
|
113 * Finds the download from download array. |
|
114 * |
|
115 * @param aMedia MPX media object. |
|
116 * @return Index of array or KErrNotFound. |
|
117 */ |
|
118 TInt FindDownload( CMPXMedia* aMedia ); |
|
119 |
|
120 /** |
|
121 * Called to inform that array of videos has changed. Causes download |
|
122 * data being re-setted to make sure correct downloads are followed. |
|
123 */ |
|
124 void VideoArrayChangedL(); |
|
125 |
|
126 /** |
|
127 * Checks video data modifications and updates download array. |
|
128 * |
|
129 * @param aEventType Event type, only expects EMPXItemModified. |
|
130 * @param aMpxItemId MPX item ID of modified video. |
|
131 * @param aExtraInfo Extra information for modification event. |
|
132 */ |
|
133 void VideoModifiedL( TMPXChangeEventType aEventType, |
|
134 TMPXItemId aMpxItemId, |
|
135 TInt32 aExtraInfo ); |
|
136 |
|
137 /** |
|
138 * Checks if progressive play (playback during download) is possible |
|
139 * for given video clip. |
|
140 * |
|
141 * @param aIndex Video index on video array. |
|
142 * @return ETrue if progressive play is possible. |
|
143 */ |
|
144 TBool IsPlayPossible( TInt aIndex ); |
|
145 |
|
146 /** |
|
147 * Periodic's callback. |
|
148 */ |
|
149 static TInt Callback( TAny *aPtr ); |
|
150 |
|
151 protected: |
|
152 |
|
153 CVcxHgMyVideosDownloadUpdater( |
|
154 CVcxHgMyVideosVideoModelHandler& aParent, |
|
155 CVcxHgMyVideosVideoList& aVideoArray ); |
|
156 |
|
157 void ConstructL(); |
|
158 |
|
159 /** |
|
160 * Makes sure that timer that is following download is running, and runs |
|
161 * only when it is needed. |
|
162 */ |
|
163 void ContinueToFollowDownloads(); |
|
164 |
|
165 /** |
|
166 * Resets the list of downloads to follow based on new video array. |
|
167 */ |
|
168 void ResetDownloadsToFollowL(); |
|
169 |
|
170 /** |
|
171 * Update the downloads. |
|
172 */ |
|
173 void UpdateDownloadsL(); |
|
174 |
|
175 /** |
|
176 * Update given download if it's status has changed. |
|
177 * |
|
178 * @param aItem Download item. |
|
179 */ |
|
180 void UpdateDownloadL( TDownloadItem& aItem ); |
|
181 |
|
182 protected: // data |
|
183 |
|
184 /** |
|
185 * Parent class. |
|
186 */ |
|
187 CVcxHgMyVideosVideoModelHandler& iParent; |
|
188 |
|
189 /** |
|
190 * CPeriodic. |
|
191 * Own. |
|
192 */ |
|
193 CPeriodic* iTimer; |
|
194 |
|
195 /** |
|
196 * Reference to array of videos. |
|
197 * Not own. |
|
198 */ |
|
199 CVcxHgMyVideosVideoList& iVideoArray; |
|
200 |
|
201 /** |
|
202 * Flag for pause state of download progress follower. |
|
203 */ |
|
204 TBool iPaused; |
|
205 |
|
206 /** |
|
207 * Array of polled downloads. |
|
208 * Own. |
|
209 */ |
|
210 RArray<TDownloadItem> iDownloadArray; |
|
211 }; |
|
212 |
|
213 #endif // VCXHGMYVIDEOSDOWNLOADUPDATER_H |