|
1 /* |
|
2 * Copyright (c) 2006 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: Http download handler for epg plugin* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 #ifndef __CLIVETVDOWNLOAD_H |
|
20 #define __CLIVETVDOWNLOAD_H |
|
21 |
|
22 // User includes |
|
23 #include <e32std.h> |
|
24 #include <DownloadMgrClient.h> |
|
25 #include "MIptvDownloadObserver.h" |
|
26 #include "MIptvLiveUITimerObserver.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class MIptvDownloadObserver; |
|
30 class CIptvEpgService; |
|
31 class CIptvLiveUIObjectTimer; |
|
32 |
|
33 /** |
|
34 * Class to provide download functionality for i.e. epg plugins to download |
|
35 * content files over http. Download observer is used to report progress of |
|
36 * of the downloads to the user of this class. |
|
37 */ |
|
38 class CIptvDownload : public CBase, |
|
39 public MHttpDownloadMgrObserver, |
|
40 public MIptvLiveUITimerObserver |
|
41 { |
|
42 public: |
|
43 /** |
|
44 * Symbian two phase constructor |
|
45 * @param None |
|
46 * @return Pointer to newly created CLiveTvHttpDownload object |
|
47 */ |
|
48 IMPORT_C static CIptvDownload* NewL( MIptvDownloadObserver* aObserver ); |
|
49 |
|
50 /** |
|
51 * Destructor |
|
52 */ |
|
53 ~CIptvDownload(); |
|
54 |
|
55 public: // Implemented methods from inherited M-classes |
|
56 |
|
57 /** |
|
58 * From MHttpDownloadMgrObserver. Observer function to receive |
|
59 * notification events about sessions and sub-sessions of Download |
|
60 * Manager. |
|
61 * @param aDownload Download resource handle which event occured in |
|
62 * @param aEvent Occured download event. Contains following |
|
63 * two values: |
|
64 * THttpDownloadState |
|
65 * THttpProgressState |
|
66 * @return None |
|
67 */ |
|
68 void HandleDMgrEventL(RHttpDownload& aDownload, THttpDownloadEvent aEvent); |
|
69 |
|
70 /** |
|
71 * From MIptvLiveUITimerObserver. Timer fired successfully. |
|
72 */ |
|
73 void TimerFires(); |
|
74 |
|
75 /** |
|
76 * From MIptvLiveUITimerObserver. Error occured in the timer. |
|
77 * @param aError KErrNone if timer fired ok, KErrCancel, the timer was |
|
78 * cancelled; KErrAbort, the timer was aborted because the system time |
|
79 * changed; KErrUnderflow, the requested completion time is in the past; |
|
80 * KErrOverFlow, the requested completion time is too far in the future. |
|
81 */ |
|
82 void TimerError( const TInt aError ); |
|
83 |
|
84 public: // new public methods |
|
85 |
|
86 /** |
|
87 * Setter for service data to be used to retrieve username and password |
|
88 * to establish the download. |
|
89 * @param aService Object containing data for download object to |
|
90 * initialize download. This method needs to be |
|
91 * called before callind DownloadL. |
|
92 * @return None |
|
93 */ |
|
94 IMPORT_C void SetService( CIptvEpgService* aService ); |
|
95 |
|
96 /** |
|
97 * Function to be used to start http download. |
|
98 * @param aUid Appuid of the application which is connecting in |
|
99 * download manager. This valua can be retrieved from |
|
100 * CIptvEpgService object |
|
101 * @param aUri Uri where download is done from |
|
102 * @param aIapId Internet accesspoint's id to be used |
|
103 * @param aFileName Name of the file where retrieved data is put (this |
|
104 * also requires the path) |
|
105 * @param aETag Descriptor containing the previous ETag value. This |
|
106 * value is used to check if there has been an update |
|
107 * for the data on the server side when we receive content |
|
108 * type and ETag value in response header. |
|
109 * @param aModifiedSince String representing the modified since value of last |
|
110 * download. This value is used to compare with last modified |
|
111 * value from http header after receiving content type. |
|
112 * @return None |
|
113 */ |
|
114 IMPORT_C void DownloadL( TUid aUid, |
|
115 const TDesC8& aUri, |
|
116 TUint32 aIapId, |
|
117 const TDesC& aFileName, |
|
118 const TDesC& aETag = KNullDesC(), |
|
119 const TDesC& aModifiedSince = KNullDesC() ); |
|
120 |
|
121 private: // new private methods |
|
122 |
|
123 /** |
|
124 * Default constructor |
|
125 */ |
|
126 CIptvDownload( MIptvDownloadObserver* aObserver ); |
|
127 |
|
128 /** |
|
129 * Symbian second phase constructor |
|
130 * @param None |
|
131 * @return None |
|
132 */ |
|
133 void ConstructL(); |
|
134 |
|
135 /** |
|
136 * Method to map download error to one of the enumerations defined |
|
137 * in TIptvDlError. |
|
138 * @param aDownload Object containing data for the download object |
|
139 * that faced an error situation |
|
140 * @param aError On return contains mapped error enumeration |
|
141 * and if no match found, EIptvDlGeneral is returned |
|
142 */ |
|
143 void ResolveDownloadErrorCode( RHttpDownload& aDownload, |
|
144 TIptvDlError& aError ) const; |
|
145 |
|
146 |
|
147 /** |
|
148 * Initializes the download meaning takes connection to download |
|
149 * manager and sets used IAP from iService. This method is called |
|
150 * from SetService. |
|
151 * @param None |
|
152 * @return None |
|
153 */ |
|
154 void InitializeDownloadL(); |
|
155 |
|
156 /** |
|
157 * Delete current download asynchronously. |
|
158 */ |
|
159 void DeleteDownloadAsyncL(); |
|
160 |
|
161 /** |
|
162 * Create download. |
|
163 */ |
|
164 void CreateDownloadL( const TDesC8& aUri, TBool aNoContentTypeCheck ); |
|
165 |
|
166 /** |
|
167 * Leaving handler for TimerError(). |
|
168 * |
|
169 * @param aError KErrNone if timer fired ok, KErrCancel, the timer was |
|
170 * cancelled; KErrAbort, the timer was aborted because the system time |
|
171 * changed; KErrUnderflow, the requested completion time is in the past; |
|
172 * KErrOverFlow, the requested completion time is too far in the future. |
|
173 */ |
|
174 void HandleTimerErrorL( const TInt aError ); |
|
175 |
|
176 private: // instance variables |
|
177 |
|
178 /** |
|
179 * Handle to download manager to be used to retrieve data over http |
|
180 */ |
|
181 RHttpDownloadMgr iDownloadManager; |
|
182 |
|
183 /** |
|
184 * Pointer to download observer interface. This interface is used to |
|
185 * signalize the caller about the progress of the download. |
|
186 */ |
|
187 MIptvDownloadObserver* iObserver; |
|
188 |
|
189 /** |
|
190 * Service containing specified data for the current download. |
|
191 */ |
|
192 CIptvEpgService* iService; |
|
193 |
|
194 /** |
|
195 * ETrue if download manager is connected, EFalse otherwise. |
|
196 */ |
|
197 TBool iConnected; |
|
198 |
|
199 TBuf<100> iDownloadETag; |
|
200 |
|
201 TBuf<100> iDownloadLastModified; |
|
202 |
|
203 /** |
|
204 * Url for the download. |
|
205 */ |
|
206 TBuf8<KIptvUrlMaxLength> iUrl; |
|
207 |
|
208 /** |
|
209 * File name for the download. |
|
210 */ |
|
211 TBuf<KIptvUrlMaxLength> iFileName; |
|
212 |
|
213 /** |
|
214 * Timer for asynchronous operations like deleting the download. |
|
215 */ |
|
216 CIptvLiveUIObjectTimer* iTimer; |
|
217 |
|
218 /** |
|
219 * Flag to identify if async download deletion is ongoing. |
|
220 */ |
|
221 TBool iDeleteDownloadTimerRunning; |
|
222 |
|
223 /** |
|
224 * Identifies download. |
|
225 */ |
|
226 TInt32 iDownloadId; |
|
227 |
|
228 /** |
|
229 * Error to be sent to observer. |
|
230 */ |
|
231 TInt iDlError; |
|
232 |
|
233 /** |
|
234 * After getting last-modified info we restart the download. |
|
235 */ |
|
236 TBool iRestartDownloadAfterDeletion; |
|
237 }; |
|
238 |
|
239 #endif // __CLIVETVDOWNLOAD_H |