|
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: RSS plugin.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CIPTVRSSPLUGIN_H |
|
21 #define CIPTVRSSPLUGIN_H |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <xml/parser.h> |
|
25 #include "MIptvTimerObserver.h" |
|
26 #include "CIptvDownloadItem.h" |
|
27 #include "CIptvEpgPluginInterface.h" |
|
28 |
|
29 class CIptvXmlContentHandler; |
|
30 class MIptvEpgVodCallback; |
|
31 class MIptvEpgLiveTvCallback; |
|
32 class CIptvEpgService; |
|
33 class CIptvRssDownload; |
|
34 class CIptvTimer; |
|
35 class CMD5; |
|
36 |
|
37 using namespace Xml; |
|
38 |
|
39 enum TDownloadStatus |
|
40 { |
|
41 EDownloadFailed = 0, |
|
42 EDownloadSucceeded, |
|
43 EDownloadNoNeed, |
|
44 EDownloadAlreadyDownloaded, |
|
45 EDownloadNeeded, |
|
46 }; |
|
47 |
|
48 /** |
|
49 * RSS plugin. |
|
50 * |
|
51 * Controls content parsing and download. |
|
52 * |
|
53 * @lib IptvRssPlugin.dll |
|
54 * @since S60 v3.1 |
|
55 */ |
|
56 class CIptvRssPlugin : public CIptvEpgPluginInterface, |
|
57 public MIptvTimerObserver |
|
58 { |
|
59 |
|
60 public: |
|
61 |
|
62 static CIptvRssPlugin* NewL(); |
|
63 |
|
64 ~CIptvRssPlugin(); |
|
65 |
|
66 /** |
|
67 * Handles download finished. |
|
68 * |
|
69 * @param aState New download state. |
|
70 * @param aError Download status. |
|
71 */ |
|
72 void DownloadFinishedL( TInt aState, TIptvDlError aError ); |
|
73 |
|
74 /** |
|
75 * Static entry point for CIdle callback. |
|
76 * |
|
77 * @param aPluginImpl Own class implementation for callback. |
|
78 * @return Continue parsing. |
|
79 */ |
|
80 static TInt ParseIdleCallback( TAny* aPluginImpl ); |
|
81 |
|
82 /** |
|
83 * Handle idle callback functionality. |
|
84 * |
|
85 * @return Continue parsing. |
|
86 */ |
|
87 TInt HandleParseIdleCallback(); |
|
88 |
|
89 /** |
|
90 * Add thumbnail to download queue. |
|
91 * |
|
92 * @param aItem Item to be added. |
|
93 */ |
|
94 void AddToDlQueueL( const CIptvDownloadItem* aItem ); |
|
95 |
|
96 /** |
|
97 * Set parsing failed. |
|
98 */ |
|
99 void SetParsingFailed(); |
|
100 |
|
101 /** |
|
102 * Download thumbnails. |
|
103 */ |
|
104 void DownloadThumbnailsL(); |
|
105 |
|
106 /** |
|
107 * Content update completed. |
|
108 */ |
|
109 void ContentUpdateCompletedL(); |
|
110 |
|
111 // From CIptvEpgPluginInterface interface |
|
112 |
|
113 /** |
|
114 * @see CIptvEpgPluginInterface |
|
115 */ |
|
116 void RunPlugin(); |
|
117 |
|
118 /** |
|
119 * Set callback pointer to MIptvEpgVodCallback. Plugin uses |
|
120 * MIptvEpgVodCallback interface to supply Epg data to system. |
|
121 * |
|
122 * @param aVodCallback Pointer to callback interface. |
|
123 */ |
|
124 void SetVodCallback( MIptvEpgVodCallback* aVodCallback ); |
|
125 |
|
126 /** |
|
127 * Set callback pointer to MIptvEpgLiveTvCallback. |
|
128 * |
|
129 * @param aLiveTvCallback Pointer to callback interface. |
|
130 */ |
|
131 void SetLiveTvCallback( MIptvEpgLiveTvCallback* aLiveTvCallback ); |
|
132 |
|
133 /** |
|
134 * Checks whether plugin is performing normal update or search operation. |
|
135 * |
|
136 * @return ETrue if plugin is performing search. |
|
137 */ |
|
138 TBool IsSearchOperation() const { return ( EIptvRssSearch == iAction ); } |
|
139 |
|
140 /** |
|
141 * @see CIptvEpgPluginInterface |
|
142 */ |
|
143 void SetServiceInformation(CIptvEpgService* aService, TBool aUseSearchAddress ); |
|
144 |
|
145 /** |
|
146 * @see CIptvEpgPluginInterface |
|
147 */ |
|
148 void SetServiceInformationL( CIptvEpgService* aService, TIptvRSSAction aAction ); |
|
149 |
|
150 /** |
|
151 * Set first update. |
|
152 * |
|
153 * @param aFirstUpdate ETrue if plugin in running first time |
|
154 * after EPG database is created. |
|
155 */ |
|
156 void SetFirstUpdate( TBool aFirstUpdate ); |
|
157 |
|
158 /** |
|
159 * Remove thumbnails not referenced during download. |
|
160 */ |
|
161 void RemoveObsoleteIconsL(); |
|
162 |
|
163 /** |
|
164 * Thumbnail has been referenced during download. |
|
165 * It is either already valid without need to be re-downloaded, or it is |
|
166 * obsolete and will be deleted prior download. |
|
167 * |
|
168 * @param aIconName Thumbnail to be removed from list. |
|
169 * @param aDelete Delete thumbnail file. |
|
170 */ |
|
171 void RemoveIconFromList( |
|
172 const HBufC* aIconName, |
|
173 TBool aDelete ); |
|
174 |
|
175 // From MIptvTimerObserver |
|
176 |
|
177 /** |
|
178 * Delayed plugin start. |
|
179 * |
|
180 * @param aTimer Not used. |
|
181 */ |
|
182 void TimerExpired( CIptvTimer* aTimer ); |
|
183 |
|
184 private: |
|
185 |
|
186 /** |
|
187 * C++ default constructor. |
|
188 */ |
|
189 CIptvRssPlugin(); |
|
190 |
|
191 /** |
|
192 * By default Symbian 2nd phase constructor is private. |
|
193 * @param |
|
194 */ |
|
195 void ConstructL(); |
|
196 |
|
197 /** |
|
198 * Delayed plugin start. |
|
199 */ |
|
200 void DoTimerExpiredL(); |
|
201 |
|
202 /** |
|
203 * Start plugin. |
|
204 */ |
|
205 void RunPluginL(); |
|
206 |
|
207 /** |
|
208 * Set plugin failed. |
|
209 * |
|
210 * @param aError Download status. |
|
211 */ |
|
212 void PluginFailedL( TIptvDlError aError ); |
|
213 |
|
214 /** |
|
215 * Set plugin succeeded. |
|
216 */ |
|
217 void PluginSucceededL(); |
|
218 |
|
219 /** |
|
220 * Parse EPG data. |
|
221 */ |
|
222 void ParseL(); |
|
223 |
|
224 /** |
|
225 * Parse EPG data. |
|
226 * |
|
227 * @param aFileName Downloaded XML file. |
|
228 */ |
|
229 void StartParsingXmlFileL( const TDesC& aFileName ); |
|
230 |
|
231 /** |
|
232 * Check is thumbnail download allowed. |
|
233 */ |
|
234 TBool ThumbnailDlAllowedL() const; |
|
235 |
|
236 /** |
|
237 * Build hashed pathname for download object. |
|
238 * Name is unique with adequate propability. |
|
239 * @param aUrl Download url for hash basis. |
|
240 * @param aPathSelection Select path according to type. |
|
241 * @param aDefaultExtension Extension for use when url doesnt have any. |
|
242 * @param aPathName Generated name |
|
243 */ |
|
244 void BuildUniqueuPathNameL( |
|
245 const TDesC& aUrl, |
|
246 const TIptvPathSelection aPathSelection, |
|
247 const TDesC& aDefaultExtension, |
|
248 const TBool aGenerateName, |
|
249 TPtr aPathName ); |
|
250 |
|
251 /** |
|
252 * Save successfully saved path to keep track of already downloaded |
|
253 * thumbnails to avoid to redownload. |
|
254 */ |
|
255 void SetAlreadyDownloadedPathL(); |
|
256 |
|
257 /** |
|
258 * Keep track of already downloaded thumbnails to avoid to redownload. |
|
259 * |
|
260 * @return Pathname of thumbnail when already downloaded, otherwise NULL. |
|
261 */ |
|
262 HBufC* GetAlreadyDownloadedPath(); |
|
263 |
|
264 /** |
|
265 * Build list of item thumbnails associated to the current service. |
|
266 */ |
|
267 void ListCurrentIconsL(); |
|
268 |
|
269 private: // Data members |
|
270 |
|
271 /** |
|
272 * XML-parser callback class. |
|
273 */ |
|
274 CIptvXmlContentHandler* iXmlContentHandler; |
|
275 |
|
276 /** |
|
277 * XML reader to be used to parse XML file. |
|
278 */ |
|
279 CParser* iParser; |
|
280 |
|
281 /** |
|
282 * Idle. |
|
283 */ |
|
284 CIdle* iParserIdle; |
|
285 |
|
286 /** |
|
287 * Download manager. |
|
288 */ |
|
289 CIptvRssDownload* iDownload; |
|
290 |
|
291 /** |
|
292 * Pointer to MIptvEpgVodCallback interface. |
|
293 */ |
|
294 MIptvEpgVodCallback* iVodCallback; |
|
295 |
|
296 /** |
|
297 * Service address. |
|
298 */ |
|
299 TBuf8<KIptvCAContentUrlLength> iServiceAddress; |
|
300 |
|
301 /** |
|
302 * File server session |
|
303 */ |
|
304 RFs iFs; |
|
305 |
|
306 /** |
|
307 * File content. |
|
308 */ |
|
309 HBufC8* iXmlFileContent; |
|
310 |
|
311 /** |
|
312 * Current parse position. |
|
313 */ |
|
314 TInt iCurrentParsePosition; |
|
315 |
|
316 /** |
|
317 * Pointer to CIptvTimer. Runs plugin after timer has expired. |
|
318 */ |
|
319 CIptvTimer* iStartTimer; |
|
320 |
|
321 /** |
|
322 * RSS temp file. |
|
323 */ |
|
324 TBuf<KIptvMaxPath> iRssPath; |
|
325 |
|
326 /** |
|
327 * Service id. |
|
328 */ |
|
329 TUint32 iServiceId; |
|
330 |
|
331 /** |
|
332 * Thumbnail download queue. |
|
333 */ |
|
334 RPointerArray<CIptvDownloadItem> iDlQueue; |
|
335 |
|
336 /** |
|
337 * Current thumbnail downloading. |
|
338 */ |
|
339 CIptvDownloadItem* iItem; |
|
340 |
|
341 /** |
|
342 * Download path. |
|
343 */ |
|
344 TBuf<KIptvMaxPath> iDownloadPath; |
|
345 |
|
346 /** |
|
347 * Download thumbnail. |
|
348 */ |
|
349 TBool iDlThumbnail; |
|
350 |
|
351 /** |
|
352 * Is thumbnail download allowed. |
|
353 */ |
|
354 TBool iThumbnailDlAllowed; |
|
355 |
|
356 /** |
|
357 * Parsing failed. |
|
358 */ |
|
359 TBool iParsingFailed; |
|
360 |
|
361 /** |
|
362 * Defines the action RSS plugin is used for. |
|
363 */ |
|
364 TIptvRSSAction iAction; |
|
365 |
|
366 /** |
|
367 * Defines if RSS plugin is used for search purposes |
|
368 */ |
|
369 TBool iIsSearchOperation; |
|
370 |
|
371 /** |
|
372 * Only one file will be downloaded without parse. |
|
373 */ |
|
374 TBool iIsGroupOperation; |
|
375 |
|
376 /** |
|
377 * MD5 message digest class. |
|
378 * Required to generate identificable thumbnail names. |
|
379 * Own. |
|
380 */ |
|
381 CMD5* iMD5Calculator; |
|
382 |
|
383 /** |
|
384 * Last update time of this service. |
|
385 */ |
|
386 TTime iLastUpdated; |
|
387 |
|
388 /** |
|
389 * List of old thumbnails. |
|
390 * When either thumbnail is replaced by a new one or found still valid, |
|
391 * It will be removed from this list. |
|
392 * At the end of downloads, list contains obsolete thumbnails, i.e. |
|
393 * those not referenced from any of the still existing items. |
|
394 * Own. |
|
395 */ |
|
396 RPointerArray<HBufC> iIconList; |
|
397 |
|
398 /** |
|
399 * List of already downloaded thumbnail URL addresses. |
|
400 * Items in this list correspond items in iPreviouslyDownloadedPaths. |
|
401 * Handling of these two list must be done parallel. |
|
402 * Own. |
|
403 */ |
|
404 RPointerArray<HBufC8> iPreviouslyDownloadedAddresses; |
|
405 |
|
406 /** |
|
407 * List of already downloaded local download paths. |
|
408 * Items in this list correspond items in iPreviouslyDownloadedAddresses. |
|
409 * Handling of these two list must be done parallel. |
|
410 * Own. |
|
411 */ |
|
412 RPointerArray<HBufC> iPreviouslyDownloadedPaths; |
|
413 |
|
414 }; |
|
415 |
|
416 #endif // CIPTVRSSPLUGIN_H |