|
23
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2004-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 CIPTVRSSDOWNLOAD_H
|
|
|
22 |
#define CIPTVRSSDOWNLOAD_H
|
|
|
23 |
|
|
|
24 |
#include <e32std.h>
|
|
|
25 |
#include <downloadmgrclient.h>
|
|
|
26 |
#include "CIptvUtil.h"
|
|
|
27 |
#include "MIptvTimerObserver.h"
|
|
|
28 |
|
|
|
29 |
class CIptvEpgService;
|
|
|
30 |
class CIptvRssPlugin;
|
|
|
31 |
class CIptvTimer;
|
|
|
32 |
class CIptvXmlContentHandler;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Download client.
|
|
|
36 |
*
|
|
|
37 |
* Controls feed and thumbnail download.
|
|
|
38 |
*
|
|
|
39 |
* @lib IptvRssPlugin.dll
|
|
|
40 |
* @since S60 v3.1
|
|
|
41 |
*/
|
|
|
42 |
class CIptvRssDownload : public CBase,
|
|
|
43 |
public MHttpDownloadMgrObserver,
|
|
|
44 |
public MIptvTimerObserver
|
|
|
45 |
{
|
|
|
46 |
|
|
|
47 |
public:
|
|
|
48 |
|
|
|
49 |
static CIptvRssDownload* NewL(
|
|
|
50 |
CIptvRssPlugin& aPlugin,
|
|
|
51 |
RFs& aFs,
|
|
|
52 |
CIptvXmlContentHandler& aXmlContentHandler );
|
|
|
53 |
|
|
|
54 |
~CIptvRssDownload();
|
|
|
55 |
|
|
|
56 |
public:
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Initialize plugin.
|
|
|
60 |
*/
|
|
|
61 |
void InitializeL();
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Disconnect download manager session.
|
|
|
65 |
*/
|
|
|
66 |
void Disconnect();
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* When either aETag or aLastUpdated is given, downloads only the headers
|
|
|
70 |
* from the server. If ETag or aModifiedSince do not match to the headers
|
|
|
71 |
* from the server the download is finished with
|
|
|
72 |
* TDownloadStatus::EDownloadNeeded and download will be restarted for
|
|
|
73 |
* actual content. Otherwise download is completed with
|
|
|
74 |
* TDownloadStatus::EDownloadNoNeed.
|
|
|
75 |
* When neither is given, actual download is performed.
|
|
|
76 |
*
|
|
|
77 |
* @param aUri Download Url.
|
|
|
78 |
* @param aFileName File to be downloaded
|
|
|
79 |
* @param aThumbnail Enable thumbnail image download.
|
|
|
80 |
* @param aETag Previous ETag
|
|
|
81 |
* @param aLastUpdated Previous update time
|
|
|
82 |
*/
|
|
|
83 |
void DownloadL(
|
|
|
84 |
const TDesC8& aUri,
|
|
|
85 |
const TDesC& aFileName,
|
|
|
86 |
TBool aThumbnail,
|
|
|
87 |
const TDesC& aETag = KIptvEmptyDes,
|
|
|
88 |
const TTime& aLastUpdated = TTime( 0LL ) );
|
|
|
89 |
|
|
|
90 |
/**
|
|
|
91 |
* From MHttpDownloadMgrObserver
|
|
|
92 |
*
|
|
|
93 |
* @param aDownload Handle to download.
|
|
|
94 |
* @param aEvent Download event.
|
|
|
95 |
*/
|
|
|
96 |
void HandleDMgrEventL(
|
|
|
97 |
RHttpDownload& aDownload,
|
|
|
98 |
THttpDownloadEvent aEvent );
|
|
|
99 |
|
|
|
100 |
/**
|
|
|
101 |
* Set service information.
|
|
|
102 |
*
|
|
|
103 |
* @param aService Epg service implementation.
|
|
|
104 |
*/
|
|
|
105 |
void SetServiceInformation( CIptvEpgService* aService );
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* Set failed.
|
|
|
109 |
*/
|
|
|
110 |
void SetFailed();
|
|
|
111 |
|
|
|
112 |
/**
|
|
|
113 |
* No need for current download.
|
|
|
114 |
*/
|
|
|
115 |
void SkipCurrentDownloadAsyncL();
|
|
|
116 |
|
|
|
117 |
/**
|
|
|
118 |
* Getter for ETag
|
|
|
119 |
*/
|
|
|
120 |
void GetETag( TDes& aETag ) const;
|
|
|
121 |
|
|
|
122 |
/**
|
|
|
123 |
* Getter for LastModifiedSince
|
|
|
124 |
*/
|
|
|
125 |
void GetLastModifiedSince( TTime& aLastUpdated ) const;
|
|
|
126 |
|
|
|
127 |
// From MIptvTimerObserver
|
|
|
128 |
|
|
|
129 |
/**
|
|
|
130 |
* Timer expired.
|
|
|
131 |
*
|
|
|
132 |
* @param aTimer Not used here.
|
|
|
133 |
*/
|
|
|
134 |
void TimerExpired( CIptvTimer* aTimer );
|
|
|
135 |
|
|
|
136 |
private:
|
|
|
137 |
|
|
|
138 |
CIptvRssDownload(
|
|
|
139 |
CIptvRssPlugin& aPlugin,
|
|
|
140 |
RFs& aFs,
|
|
|
141 |
CIptvXmlContentHandler& aXmlContentHandler );
|
|
|
142 |
|
|
|
143 |
void ConstructL();
|
|
|
144 |
|
|
|
145 |
/**
|
|
|
146 |
* Restart previous download.
|
|
|
147 |
*/
|
|
|
148 |
void DownloadL();
|
|
|
149 |
|
|
|
150 |
/**
|
|
|
151 |
* Set authentication information.
|
|
|
152 |
*
|
|
|
153 |
* @param aDownload Handle to download.
|
|
|
154 |
*/
|
|
|
155 |
void SetAuthenticationInformationL(
|
|
|
156 |
RHttpDownload& aDownload ) const;
|
|
|
157 |
|
|
|
158 |
/**
|
|
|
159 |
* Get download error code.
|
|
|
160 |
*
|
|
|
161 |
* @param aDownload Handle to download.
|
|
|
162 |
* @param aError Download error code
|
|
|
163 |
*/
|
|
|
164 |
void GetDownloadErrorCode(
|
|
|
165 |
RHttpDownload& aDownload,
|
|
|
166 |
TIptvDlError& aError ) const;
|
|
|
167 |
|
|
|
168 |
/**
|
|
|
169 |
* Delete current download asynchronously.
|
|
|
170 |
*/
|
|
|
171 |
void DeleteDownloadAsyncL();
|
|
|
172 |
|
|
|
173 |
/**
|
|
|
174 |
* Finish and delete current download.
|
|
|
175 |
*/
|
|
|
176 |
void DeleteCurrentDownload();
|
|
|
177 |
|
|
|
178 |
/**
|
|
|
179 |
* Change the state of the download.
|
|
|
180 |
*/
|
|
|
181 |
void ChangeState( TInt aState );
|
|
|
182 |
|
|
|
183 |
private: // Data members
|
|
|
184 |
|
|
|
185 |
/**
|
|
|
186 |
* Download progress state.
|
|
|
187 |
*/
|
|
|
188 |
enum TState
|
|
|
189 |
{
|
|
|
190 |
ENormal = 0,
|
|
|
191 |
EPause,
|
|
|
192 |
EThumbnail,
|
|
|
193 |
EWaiting,
|
|
|
194 |
EFinished,
|
|
|
195 |
ETimeout,
|
|
|
196 |
ENoDiskSpace
|
|
|
197 |
};
|
|
|
198 |
|
|
|
199 |
/**
|
|
|
200 |
* Download manager.
|
|
|
201 |
*/
|
|
|
202 |
RHttpDownloadMgr iDownloadManager;
|
|
|
203 |
|
|
|
204 |
/**
|
|
|
205 |
* Epg service implementation.
|
|
|
206 |
* Not own.
|
|
|
207 |
*/
|
|
|
208 |
CIptvEpgService* iService;
|
|
|
209 |
|
|
|
210 |
/**
|
|
|
211 |
* Pluging having started us.
|
|
|
212 |
*/
|
|
|
213 |
CIptvRssPlugin& iPlugin;
|
|
|
214 |
|
|
|
215 |
/**
|
|
|
216 |
* Service username.
|
|
|
217 |
*/
|
|
|
218 |
TBuf8<KIptvEpgServiceUserNameMaxLength> iUserName;
|
|
|
219 |
|
|
|
220 |
/**
|
|
|
221 |
* Service password.
|
|
|
222 |
*/
|
|
|
223 |
TBuf8<KIptvEpgServicePasswordMaxLength> iPassword;
|
|
|
224 |
|
|
|
225 |
/**
|
|
|
226 |
* Thumbnail image download allowed.
|
|
|
227 |
*/
|
|
|
228 |
TBool iThumbnail;
|
|
|
229 |
|
|
|
230 |
/**
|
|
|
231 |
* Identifies download.
|
|
|
232 |
*/
|
|
|
233 |
TInt32 iDownloadId;
|
|
|
234 |
|
|
|
235 |
/**
|
|
|
236 |
* DownloadId above contains valid and existing value.
|
|
|
237 |
*/
|
|
|
238 |
TBool iDownloadIdValid;
|
|
|
239 |
|
|
|
240 |
/**
|
|
|
241 |
* Pointer to CIptvTimer.
|
|
|
242 |
* Own.
|
|
|
243 |
*/
|
|
|
244 |
CIptvTimer* iTimer;
|
|
|
245 |
|
|
|
246 |
/**
|
|
|
247 |
* Set when download manager is successfully connected.
|
|
|
248 |
*/
|
|
|
249 |
TBool iConnected;
|
|
|
250 |
|
|
|
251 |
/**
|
|
|
252 |
* Download progress state.
|
|
|
253 |
*/
|
|
|
254 |
TInt iState;
|
|
|
255 |
|
|
|
256 |
/**
|
|
|
257 |
* Download expires after no progress.
|
|
|
258 |
*/
|
|
|
259 |
TInt iPauseCounter;
|
|
|
260 |
|
|
|
261 |
/**
|
|
|
262 |
* File server session.
|
|
|
263 |
*/
|
|
|
264 |
RFs& iFs;
|
|
|
265 |
|
|
|
266 |
/**
|
|
|
267 |
* XML-parser callback class.
|
|
|
268 |
* Not own.
|
|
|
269 |
*/
|
|
|
270 |
CIptvXmlContentHandler& iXmlContentHandler;
|
|
|
271 |
|
|
|
272 |
/**
|
|
|
273 |
* Pointer to CIptvTimer. Deletes download.
|
|
|
274 |
* Own.
|
|
|
275 |
*/
|
|
|
276 |
CIptvTimer* iDlDeleteTimer;
|
|
|
277 |
|
|
|
278 |
/**
|
|
|
279 |
* Download error code is stored here to keep it in memory
|
|
|
280 |
* while iDlDeleteTimer is running.
|
|
|
281 |
*/
|
|
|
282 |
TIptvDlError iDlError;
|
|
|
283 |
|
|
|
284 |
/**
|
|
|
285 |
* Download status code is stored here to keep it in memory
|
|
|
286 |
* while iDlDeleteTimer is running. See TDownloadStatus from CIptvRssPlugin.h
|
|
|
287 |
* for values.
|
|
|
288 |
*/
|
|
|
289 |
TInt iDlStatus;
|
|
|
290 |
|
|
|
291 |
/**
|
|
|
292 |
* ETag
|
|
|
293 |
*/
|
|
|
294 |
HBufC* iETag;
|
|
|
295 |
|
|
|
296 |
/**
|
|
|
297 |
* Last update of this download.
|
|
|
298 |
*/
|
|
|
299 |
TTime iLastUpdated;
|
|
|
300 |
|
|
|
301 |
/**
|
|
|
302 |
* Header info is requested and we are waiting for it.
|
|
|
303 |
*/
|
|
|
304 |
TBool iWaitingContentTypeCheck;
|
|
|
305 |
|
|
|
306 |
/**
|
|
|
307 |
* Header was not available, dont do further header check.
|
|
|
308 |
*/
|
|
|
309 |
TBool iDisableLastModifiedCheck;
|
|
|
310 |
|
|
|
311 |
/**
|
|
|
312 |
* Header successfully downloaded and actual download is needed.
|
|
|
313 |
*/
|
|
|
314 |
TBool iRestartDownload;
|
|
|
315 |
|
|
|
316 |
/**
|
|
|
317 |
* File name for dowload retained for restart.
|
|
|
318 |
* Own.
|
|
|
319 |
*/
|
|
|
320 |
HBufC* iFileName;
|
|
|
321 |
|
|
|
322 |
/**
|
|
|
323 |
* Uri for dowload retained for restart.
|
|
|
324 |
*/
|
|
|
325 |
HBufC8* iUri;
|
|
|
326 |
|
|
|
327 |
};
|
|
|
328 |
|
|
|
329 |
#endif // CIPTVRSSDOWNLOAD_H
|