|
1 /* |
|
2 * Copyright (c) 2006-2007 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 "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: Engine to fetch the logos |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef IRDATAPROVIDER_H |
|
20 #define IRDATAPROVIDER_H |
|
21 |
|
22 #include <f32file.h> |
|
23 |
|
24 #include "irdataprovidertimer.h" |
|
25 #include "irhttpdataproviderobserver.h" |
|
26 |
|
27 class CIRHttpDataProvider; |
|
28 class CIRHttpRequestData; |
|
29 class CIRHttpResponseData; |
|
30 class CIRSettings; |
|
31 class MIRDataProviderObserver; |
|
32 |
|
33 /** |
|
34 * This class provides the interface with the UI for IRDataProvider component |
|
35 * |
|
36 * @code |
|
37 * |
|
38 * // Create the data provider object. This is used for interaction with |
|
39 * // the iSDS |
|
40 * |
|
41 * CIRDataProvider* iDataProvider = CIRDataProvider::NewL(iObserver); |
|
42 * |
|
43 * // This API is used to give a request to the iSDS and the aRequestObject |
|
44 * // contains the headers to be set for the request url. The call back |
|
45 * // function as defined by MIRDataProviderObserver is called to indicate |
|
46 * // any responses. |
|
47 * |
|
48 * iDataProvider->IRHttpIssueRequestL( aRequestObject ); |
|
49 * |
|
50 * // This API is called to cancel a previously issued request. |
|
51 * // If there is no previously issued request it is ignored. |
|
52 * |
|
53 * iDataProvider->IRHttpCancelRequest(); |
|
54 * |
|
55 * // This API is called to indicate the data provider component to |
|
56 * // release the resources held by it generally called when the network |
|
57 * // connection gets disconnected. |
|
58 * |
|
59 * iDataProvider->ReleaseResources(); |
|
60 * @endcode |
|
61 */ |
|
62 |
|
63 NONSHARABLE_CLASS ( CIRDataProvider ): public CBase, |
|
64 public MIRHttpDataProviderObserver, |
|
65 public MIRDataProviderTimeoutNotifier |
|
66 { |
|
67 public: |
|
68 |
|
69 /** |
|
70 * CIRDataProvider::NewL |
|
71 * Creates instance of CIRDataProvider. |
|
72 * @param aObserver Observer for HTTP request. |
|
73 * @return CIRDataProvider* |
|
74 */ |
|
75 IMPORT_C static CIRDataProvider *NewL(MIRDataProviderObserver &aObserver); |
|
76 |
|
77 /** |
|
78 * CIRDataProvider::NewL() |
|
79 * Creates instance of CIRDataProvider. |
|
80 * @param aObserver Observer for HTTP request. |
|
81 * @return CIRDataProvider* |
|
82 */ |
|
83 IMPORT_C static CIRDataProvider *NewL( MIRDataProviderObserver &aObserver, |
|
84 const TDesC &aFilePath ); |
|
85 |
|
86 /** |
|
87 * CIRDataProvider::~CIRDataProvider() |
|
88 * Destructs an instance of CIRDataProvider. |
|
89 */ |
|
90 virtual ~CIRDataProvider(); |
|
91 |
|
92 /** |
|
93 * CIRDataProvider::IRHttpIssueRequest() |
|
94 * Used to issue an Http request |
|
95 * @param aRequestObject A reference of CIRHttpRequestData containing |
|
96 * HTTP request parameters |
|
97 */ |
|
98 IMPORT_C void IRHttpIssueRequestL( CIRHttpRequestData &aRequestObject ); |
|
99 |
|
100 /** |
|
101 * CIRDataProvider::IRHttpCancelRequest() |
|
102 * Used to cancel a request |
|
103 */ |
|
104 IMPORT_C void IRHttpCancelRequest(); |
|
105 |
|
106 /** |
|
107 * CIRDataProvider::ReleaseResources() |
|
108 * Used to release all the resources help by data provider |
|
109 * Called when there is a network disconnection |
|
110 */ |
|
111 IMPORT_C void ReleaseResources(); |
|
112 |
|
113 IMPORT_C CIRHttpDataProvider* GetHttpDataProvider(); |
|
114 |
|
115 /** |
|
116 * CIRDataProvider::ExtractHeaderValue() |
|
117 * |
|
118 * |
|
119 */ |
|
120 void ExtractHeaderValue( const TDesC8& aHeaderData, |
|
121 const TDesC8& aHeaderName, const TDesC8& aDelimeter, |
|
122 TDes8& aHolder ) const; |
|
123 |
|
124 /* |
|
125 *These are the callback functions used by CIRHttpDataProvider to |
|
126 *provide the CIRDataProvider with the data after processing the |
|
127 *HTTP request. |
|
128 */ |
|
129 /** |
|
130 * CIRDataProvider::HttpEventComplete() |
|
131 * Used to Indicate to the observer that the request event has completed |
|
132 */ |
|
133 virtual void HttpEventComplete(); |
|
134 |
|
135 /** |
|
136 * CIRDataProvider::HttpHeaderReceived() |
|
137 * Used by CIRHttpDataProvider to indicate that an HTTP header is |
|
138 * received. |
|
139 * @param aHeaderData Reference to the Header Info |
|
140 */ |
|
141 virtual void HttpHeaderReceived( const TDesC8 &aHeaderData ); |
|
142 |
|
143 /** |
|
144 * CIRDataProvider::HttpDateHeaderReceived() |
|
145 * Used by CIRHttpDataProvider to indicate that an HTTP header is |
|
146 * received. |
|
147 * @param aHeader Reference to the Header Info |
|
148 * @param aTime Reference to the TTime object containing time to be |
|
149 * set in the header |
|
150 */ |
|
151 virtual void HttpDateHeaderReceived( const TDesC8 &aHeader, |
|
152 const TTime& aTime ); |
|
153 |
|
154 /** |
|
155 * CIRDataProvider::HttpBodyReceived() |
|
156 * Used by CIRHttpDataProvider to indicate that an HTTP response |
|
157 * body is received. |
|
158 * @param aHeaderData Reference to the Body data of HTTP request |
|
159 */ |
|
160 virtual void HttpBodyReceived( const TDesC8 &aBodyData ); |
|
161 |
|
162 /** |
|
163 * CIRDataProvider::HttpTransactionError() |
|
164 * Used by CIRHttpDataProvider to indicate that a HTTP Transaction |
|
165 * error has occured. |
|
166 * @param aErrCode Error code indicating the HTTP Transaction error |
|
167 */ |
|
168 virtual void HttpTransactionError( TInt aErrCode ); |
|
169 |
|
170 /** |
|
171 * CIRDataProvider::HttpResponseCodeRecieved() |
|
172 * Used by CIRHttpDataProvider to indicate to the iSDS Client that a |
|
173 * 304 Not Changed response received |
|
174 * Note: Implemented in version 0.2 |
|
175 * @param aResponseCode Response code received after HTTP Transaction |
|
176 */ |
|
177 virtual void HttpResponseCodeRecieved( TInt aResponseCode ); |
|
178 |
|
179 /** |
|
180 * CIRDataProvider::TimerExpired( ) |
|
181 * Called to indicate expiry of timer |
|
182 */ |
|
183 virtual void TimerExpired(); |
|
184 |
|
185 private: |
|
186 |
|
187 /** |
|
188 * CIRDataProvider::CIRDataProvider() |
|
189 * Default Constructor |
|
190 * @param aObserver Reference to the IRDataProvider Observer |
|
191 */ |
|
192 CIRDataProvider( MIRDataProviderObserver &aObserver ); |
|
193 |
|
194 /** |
|
195 * void CIRDataProvider::ConstructL() |
|
196 * 2nd Phase construction |
|
197 */ |
|
198 void ConstructL(); |
|
199 |
|
200 /** |
|
201 * void CIRDataProvider::ConstructL() |
|
202 * 2nd Phase construction |
|
203 */ |
|
204 void ConstructL( const TDesC &aFileName ); |
|
205 |
|
206 /** |
|
207 * CIRDataProvider::NewLC(MIRDataProviderObserver& aObserver) |
|
208 * Creates instance of CIRDataProvider. |
|
209 * @param aObserver Observer for HTTP request. |
|
210 * @return CIRDataProvider* |
|
211 */ |
|
212 static CIRDataProvider *NewLC( MIRDataProviderObserver &aObserver ); |
|
213 |
|
214 /** |
|
215 * CIRDataProvider::NewLC() |
|
216 * Creates instance of CIRDataProvider. |
|
217 * @param aObserver Observer for HTTP request. |
|
218 * @return CIRDataProvider* |
|
219 */ |
|
220 static CIRDataProvider *NewLC( MIRDataProviderObserver &aObserver, |
|
221 const TDesC &aFileName ); |
|
222 |
|
223 /** |
|
224 * CIRDataProvider::SetOffsetSeconds() |
|
225 * Stores the offset between device time and response header in settings |
|
226 * @param isds time |
|
227 */ |
|
228 void SetOffsetSeconds( const TTime& aTime ); |
|
229 |
|
230 #ifdef REQUEST_ZIP_RESPONSE |
|
231 /** |
|
232 * CIRDataProvider::UnzipFileL() |
|
233 * Unzip the gz file to xml file |
|
234 * @param aOutputFile out put file |
|
235 */ |
|
236 void UnzipFileL( const TDesC& aOutputFile ); |
|
237 #endif |
|
238 |
|
239 private: |
|
240 |
|
241 /** |
|
242 * Reference of the observer object to which call backs are returned |
|
243 */ |
|
244 MIRDataProviderObserver &iDataProviderObserver; |
|
245 |
|
246 /** |
|
247 * Pointer to the HttpDataProvider object which is the actual |
|
248 * implementation of RFC 2616 |
|
249 */ |
|
250 CIRHttpDataProvider *iHttpDataProvider; |
|
251 |
|
252 /** |
|
253 * Pointer to timer object |
|
254 * Used for Timeout |
|
255 */ |
|
256 CIRDataProviderTimer *iDataProviderTimer; |
|
257 |
|
258 /** |
|
259 * File server session handle |
|
260 * Used for creation of XML data |
|
261 */ |
|
262 RFs iFsSession; |
|
263 |
|
264 /** |
|
265 * File handle to create the xml file |
|
266 */ |
|
267 RFile iFile; |
|
268 |
|
269 #ifdef REQUEST_ZIP_RESPONSE |
|
270 /** |
|
271 * Name of the Xml Gz file to be created |
|
272 */ |
|
273 TFileName iXmlGzFilePath; |
|
274 #endif |
|
275 |
|
276 /** |
|
277 * Name of the Xml file to be created |
|
278 */ |
|
279 TFileName iXmlFilePath; |
|
280 |
|
281 /** |
|
282 * Pointer to Response header data |
|
283 */ |
|
284 CIRHttpResponseData* iResponseHeaders; |
|
285 |
|
286 /** |
|
287 * Used to access Settings object |
|
288 */ |
|
289 CIRSettings* iIRSettings; |
|
290 |
|
291 /** |
|
292 * Timer timeout value |
|
293 */ |
|
294 TInt iTimeOut; |
|
295 }; |
|
296 |
|
297 #endif // IRDATAPROVIDER_H |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |