|
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: ?Description |
|
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 ): |
|
64 public CBase, |
|
65 public MIRHttpDataProviderObserver, |
|
66 public MIRDataProviderTimeoutNotifier |
|
67 { |
|
68 public: |
|
69 |
|
70 /** |
|
71 * CIRDataProvider::NewL(MIRDataProviderObserver& aObserver) |
|
72 * Creates instance of CIRDataProvider. |
|
73 * @param aObserver Observer for HTTP request. |
|
74 * @return CIRDataProvider* |
|
75 */ |
|
76 IMPORT_C static CIRDataProvider *NewL(MIRDataProviderObserver &aObserver); |
|
77 |
|
78 /** |
|
79 * CIRDataProvider::NewL(MIRDataProviderObserver& aObserver, |
|
80 * TDesC8& aFilePath) |
|
81 * Creates instance of CIRDataProvider. |
|
82 * @param aObserver Observer for HTTP request. |
|
83 * @return CIRDataProvider* |
|
84 */ |
|
85 IMPORT_C static CIRDataProvider *NewL( MIRDataProviderObserver &aObserver, |
|
86 const TDesC &aFilePath ); |
|
87 |
|
88 /** |
|
89 * CIRDataProvider::~CIRDataProvider() |
|
90 * Destructs an instance of CIRDataProvider. |
|
91 */ |
|
92 virtual ~CIRDataProvider(); |
|
93 |
|
94 /** |
|
95 * CIRDataProvider::IRHttpIssueRequest(TDesC8& aUri) |
|
96 * Used to issue an Http request |
|
97 * @param aRequestObject A reference of CIRHttpRequestData containing |
|
98 * HTTP request parameters |
|
99 */ |
|
100 IMPORT_C void IRHttpIssueRequestL( CIRHttpRequestData &aRequestObject ); |
|
101 |
|
102 /** |
|
103 * CIRDataProvider::IRHttpCancelRequest() |
|
104 * Used to cancel a request |
|
105 */ |
|
106 IMPORT_C void IRHttpCancelRequest(); |
|
107 |
|
108 /** |
|
109 * CIRDataProvider::ReleaseResources() |
|
110 * Used to release all the resources help by data provider |
|
111 * Called when there is a network disconnection |
|
112 */ |
|
113 IMPORT_C void ReleaseResources(); |
|
114 |
|
115 IMPORT_C CIRHttpDataProvider* GetHttpDataProvider(); |
|
116 |
|
117 void ExtractHeaderValue(const TDesC8& aHeaderData, |
|
118 const TDesC8& aHeaderName,const TDesC8& aDelimeter, |
|
119 TDes8& aHolder) const; |
|
120 |
|
121 /* |
|
122 *These are the callback functions used by CIRHttpDataProvider to |
|
123 *provide the CIRDataProvider with the data after processing the |
|
124 *HTTP request. |
|
125 */ |
|
126 /** |
|
127 * CIRDataProvider::HttpEventComplete() |
|
128 * Used to Indicate to the observer that the request event has completed |
|
129 */ |
|
130 virtual void HttpEventComplete(); |
|
131 |
|
132 /** |
|
133 * CIRDataProvider::HttpHeaderReceived( const TDesC8& aHeaderData ) |
|
134 * Used by CIRHttpDataProvider to indicate that an HTTP header is |
|
135 * received. |
|
136 * @param aHeaderData Reference to the Header Info |
|
137 */ |
|
138 virtual void HttpHeaderReceived( const TDesC8 &aHeaderData ); |
|
139 |
|
140 /** |
|
141 * CIRDataProvider::HttpDateHeaderReceived(const TDesC8 &aHeader, |
|
142 * const TTime& aTime ); |
|
143 * Used by CIRHttpDataProvider to indicate that an HTTP header is |
|
144 * received. |
|
145 * @param aHeader Reference to the Header Info |
|
146 * @param aTime Reference to the TTime object containing time to be |
|
147 * set in the header |
|
148 */ |
|
149 virtual void HttpDateHeaderReceived(const TDesC8 &aHeader, |
|
150 const TTime& aTime ); |
|
151 |
|
152 /** |
|
153 * CIRDataProvider::HttpBodyReceived( const TDesC8& aBodyData ) |
|
154 * Used by CIRHttpDataProvider to indicate that an HTTP response |
|
155 * body is received. |
|
156 * @param aHeaderData Reference to the Body data of HTTP request |
|
157 */ |
|
158 virtual void HttpBodyReceived( const TDesC8 &aBodyData ); |
|
159 |
|
160 /** |
|
161 * CIRDataProvider::HttpTransactionError(TInt aErrCode) |
|
162 * Used by CIRHttpDataProvider to indicate that a HTTP Transaction |
|
163 * error has occured. |
|
164 * @param aErrCode Error code indicating the HTTP Transaction error |
|
165 */ |
|
166 virtual void HttpTransactionError( TInt aErrCode ); |
|
167 |
|
168 /** |
|
169 * CIRDataProvider::HttpResponseCodeRecieved(TInt aResponseCode) |
|
170 * Used by CIRHttpDataProvider to indicate to the iSDS Client that a |
|
171 * 304 Not Changed response received |
|
172 * Note: Implemented in version 0.2 |
|
173 * @param aResponseCode Response code received after HTTP Transaction |
|
174 */ |
|
175 virtual void HttpResponseCodeRecieved( TInt aResponseCode ); |
|
176 |
|
177 /** |
|
178 * CIRDataProvider::TimerExpired( ) |
|
179 * Called to indicate expiry of timer |
|
180 */ |
|
181 virtual void TimerExpired(); |
|
182 |
|
183 private: |
|
184 /** |
|
185 * CIRDataProvider::CIRDataProvider(MIRDataProviderObserver& |
|
186 * aObserver):iDataProviderObserver(aObserver) |
|
187 * Default Constructor |
|
188 * @param aObserver Reference to the IRDataProvider Observer |
|
189 */ |
|
190 CIRDataProvider( MIRDataProviderObserver &aObserver ); |
|
191 /** |
|
192 * void CIRDataProvider::ConstructL() |
|
193 * 2nd Phase construction |
|
194 */ |
|
195 void ConstructL(); |
|
196 /** |
|
197 * void CIRDataProvider::ConstructL(TDesC8& aFileName) |
|
198 * 2nd Phase construction |
|
199 */ |
|
200 void ConstructL( const TDesC &aFileName ); |
|
201 /** |
|
202 * CIRDataProvider::NewLC(MIRDataProviderObserver& aObserver) |
|
203 * Creates instance of CIRDataProvider. |
|
204 * @param aObserver Observer for HTTP request. |
|
205 * @return CIRDataProvider* |
|
206 */ |
|
207 static CIRDataProvider *NewLC( MIRDataProviderObserver &aObserver ); |
|
208 /** |
|
209 * CIRDataProvider::NewLC(MIRDataProviderObserver& aObserver, |
|
210 * TDesC8& aFileName) |
|
211 * Creates instance of CIRDataProvider. |
|
212 * @param aObserver Observer for HTTP request. |
|
213 * @return CIRDataProvider* |
|
214 */ |
|
215 static CIRDataProvider *NewLC( MIRDataProviderObserver &aObserver, |
|
216 const TDesC &aFileName ); |
|
217 |
|
218 /** |
|
219 * CIRDataProvider::SetOffsetSeconds( const TTime& aTime ) |
|
220 * Stores the offset between device time and response header in settings |
|
221 * @param isds time |
|
222 */ |
|
223 void SetOffsetSeconds( const TTime& aTime ); |
|
224 |
|
225 private: |
|
226 |
|
227 /** |
|
228 * Reference of the observer object to which call backs are returned |
|
229 */ |
|
230 MIRDataProviderObserver &iDataProviderObserver; |
|
231 |
|
232 /** |
|
233 * Pointer to the HttpDataProvider object which is the actual |
|
234 * implementation of RFC 2616 |
|
235 */ |
|
236 CIRHttpDataProvider *iHttpDataProvider; |
|
237 |
|
238 /** |
|
239 * Pointer to timer object |
|
240 */ |
|
241 CIRDataProviderTimer *iDataProviderTimer; // Timeout Timer |
|
242 /** |
|
243 * File server session handle |
|
244 */ |
|
245 RFs iFsSession; // Used for creation of XML data |
|
246 /** |
|
247 * File handle to create the xml file |
|
248 */ |
|
249 RFile iFile; |
|
250 |
|
251 /** |
|
252 * Name of the Xml file to be created |
|
253 */ |
|
254 TFileName iXmlFilePath; |
|
255 |
|
256 /** |
|
257 * Pointer to Response header data |
|
258 */ |
|
259 CIRHttpResponseData* iResponseHeaders; |
|
260 |
|
261 /** |
|
262 * Used to access Settings object |
|
263 */ |
|
264 CIRSettings* iIRSettings; |
|
265 |
|
266 /** |
|
267 * Timer timeout value |
|
268 */ |
|
269 TInt iTimeOut; |
|
270 |
|
271 }; |
|
272 |
|
273 #endif // IRDATAPROVIDER_H |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |