|
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 IRHTTPDATAPROVIDER_H |
|
20 #define IRHTTPDATAPROVIDER_H |
|
21 |
|
22 #include <mhttptransactioncallback.h> |
|
23 #include <rhttpsession.h> |
|
24 |
|
25 #include "irdataproviderconstants.h" |
|
26 #include "irfavoritesdb.h" |
|
27 |
|
28 class CIRHttpPost; |
|
29 class CIRHttpRequestData; |
|
30 class CIRNetworkController; |
|
31 class CIRLogoDownloadEngine; |
|
32 class CIRFavoritesDb; |
|
33 class MIRHttpDataProviderObserver; |
|
34 |
|
35 /** |
|
36 * This class provides the implementation of the HTTP client |
|
37 */ |
|
38 |
|
39 NONSHARABLE_CLASS( CIRHttpDataProvider ) : public CBase, |
|
40 public MHTTPTransactionCallback |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * CIRHttpDataProvider::CIRHttpDataProvider() |
|
46 * Creates instance of CIRHttpDataProvider. |
|
47 * @param aObserver Reference to HTTP Data provider observer |
|
48 */ |
|
49 CIRHttpDataProvider( MIRHttpDataProviderObserver &aObserver ); |
|
50 |
|
51 /** |
|
52 * CIRHttpDataProvider::~CIRHttpDataProvider() |
|
53 * Destructs instance of CIRHttpDataProvider. |
|
54 */ |
|
55 virtual ~CIRHttpDataProvider(); |
|
56 |
|
57 /** |
|
58 * CIRHttpDataProvider::NewL() |
|
59 * Creates instance of CIRHttpDataProvider. |
|
60 * @param aObserver Reference to HTTP Data provider observer |
|
61 */ |
|
62 static CIRHttpDataProvider *NewL( MIRHttpDataProviderObserver &aObserver ); |
|
63 |
|
64 /** |
|
65 * CIRHttpDataProvider::NewLC() |
|
66 * Creates instance of CIRHttpDataProvider. |
|
67 * @param aObserver Reference to HTTP Data provider observer |
|
68 */ |
|
69 static CIRHttpDataProvider *NewLC( MIRHttpDataProviderObserver &aObserver ); |
|
70 |
|
71 /** |
|
72 * CIRHttpDataProvider::ConstructL() |
|
73 * 2nd phase construction |
|
74 */ |
|
75 void ConstructL(); |
|
76 |
|
77 /** |
|
78 * CIRHttpDataProvider::CancelTransactionL() |
|
79 * Cancel the issued Http transaction |
|
80 */ |
|
81 void CancelTransaction(); |
|
82 |
|
83 /** |
|
84 * CIRHttpDataProvider::GetHttpSession() |
|
85 * returns the iHttpSession |
|
86 */ |
|
87 RHTTPSession GetHttpSession(); |
|
88 |
|
89 /** |
|
90 * CIRHttpDataProvider::IssueHttpRequestL() |
|
91 * Used to issue the request. |
|
92 * @param aRequestInfo Reference to request object |
|
93 */ |
|
94 TInt IssueHttpRequestL( CIRHttpRequestData &aRequestObject ); |
|
95 |
|
96 /** |
|
97 * CIRHttpDataProvider::SetHttpContentType() |
|
98 * Set the Http content type |
|
99 * @param aContentType Specifies the Content-Type |
|
100 * @param aCharSet Specifies the Charecter set |
|
101 */ |
|
102 void SetHttpContentType( const TDesC &aContentType, const TDesC &aCharSet ); |
|
103 |
|
104 /** |
|
105 * CIRHttpDataProvider::InitializeHttpDataProviderL(); |
|
106 * Initialize the data provider component |
|
107 */ |
|
108 void InitializeHttpDataProviderL(); |
|
109 |
|
110 /** |
|
111 * CIRHttpDataProvider::ReleaseResources(); |
|
112 * Releases the resources held by data provider |
|
113 */ |
|
114 void ReleaseResources(); |
|
115 |
|
116 IMPORT_C CIRLogoDownloadEngine* GetLogoDownloadEngine(); |
|
117 |
|
118 private: |
|
119 /** |
|
120 * CIRHttpDataProvider::MHFRunL() |
|
121 * Inherited from MHTTPTransactionCallback |
|
122 * Called by framework to pass transaction events. |
|
123 * @param aTransaction HTTP Transaction object |
|
124 * @param aEvent HTTP Transaction Event |
|
125 */ |
|
126 void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent &aEvent ); |
|
127 |
|
128 /** |
|
129 * CIRHttpDataProvider::MHFRunError() |
|
130 * Inherited from MHTTPTransactionCallback |
|
131 * Called by framework to pass transaction errors |
|
132 * @param aError Error code of the HTTP Transactin |
|
133 * @return TInt Return code KErrNone if success |
|
134 */ |
|
135 TInt MHFRunError( TInt aError, RHTTPTransaction aTransaction, |
|
136 const THTTPEvent &aEvent ); |
|
137 |
|
138 /** |
|
139 * CIRHttpDataProvider::ExtractResponseHeadersL() |
|
140 * Used to Extract the response headers. |
|
141 * @param aTransaction HTTP Transaction object |
|
142 */ |
|
143 void ExtractResponseHeadersL( const RHTTPTransaction& aTransaction ); |
|
144 |
|
145 /** |
|
146 * CIRHttpDataProvider::SetHeaderL() |
|
147 * Used to set the Http header |
|
148 * @param aHeaders HTTP Headers object |
|
149 * @param aHeaderField Header field |
|
150 * @param aHeaderValue Header value |
|
151 */ |
|
152 void SetHeaderL( RHTTPHeaders aHeaders, TInt aHeaderField, |
|
153 const TDesC8 &aHeaderValue ) const; |
|
154 |
|
155 /** |
|
156 * CIRHttpDataProvider::BuildHeadersL() |
|
157 * Build the headers for the request |
|
158 * @param CIRHttpRequestData& |
|
159 */ |
|
160 void BuildHeadersL( const CIRHttpRequestData &aRequestInfo ); |
|
161 |
|
162 /** |
|
163 * CIRHttpDataProvider::ValidateStatusCode() |
|
164 * Validate the status code returned |
|
165 * @param aStatusCode Status code |
|
166 */ |
|
167 void ValidateStatusCode( TInt aStatusCode ); |
|
168 |
|
169 /** |
|
170 * CIRHttpDataProvider::CloseLogFile (); |
|
171 * Used to Close the log file LogUsage.gz externally |
|
172 * from other sources (bug-fixing) |
|
173 */ |
|
174 void CloseLogFile(); |
|
175 |
|
176 public: |
|
177 |
|
178 /** |
|
179 * iSetNonUAProfUserAgent Set when the UAProf should not be used |
|
180 * may be used for image data provider |
|
181 */ |
|
182 TBool iSetNonUAProfUserAgent; |
|
183 |
|
184 private: |
|
185 |
|
186 /** |
|
187 * Status code of the response |
|
188 */ |
|
189 TInt iStatusCode; |
|
190 |
|
191 /** |
|
192 * Indicates if the transaction is active ie. there is a pending |
|
193 * request. |
|
194 */ |
|
195 TBool iRunning; |
|
196 |
|
197 /** |
|
198 * Used to identify first request to the data provider object |
|
199 */ |
|
200 TBool iFirstTime; |
|
201 |
|
202 /** |
|
203 * HTTP session object |
|
204 */ |
|
205 RHTTPSession iHttpSession; |
|
206 |
|
207 /** |
|
208 * HTTP transaction object |
|
209 */ |
|
210 RHTTPTransaction iHttpTransaction; |
|
211 |
|
212 /** |
|
213 * HTTP Post object |
|
214 */ |
|
215 CIRHttpPost* iLogMessage; |
|
216 |
|
217 CIRFavoritesDb* iFavDb; |
|
218 |
|
219 /** |
|
220 * Network controller handle pointer |
|
221 */ |
|
222 CIRNetworkController *iIRNetworkControllerHandle; |
|
223 |
|
224 /** |
|
225 * Reference of the Http data provider Observer |
|
226 */ |
|
227 MIRHttpDataProviderObserver &iObserver; |
|
228 |
|
229 /** |
|
230 * Status text of the response |
|
231 */ |
|
232 TBuf<KMaxStatusTextLength> iStatusText; |
|
233 |
|
234 /** |
|
235 * Content type header info |
|
236 */ |
|
237 TBuf8<KDPMaxContentTypeLength> iContentType; |
|
238 |
|
239 /** |
|
240 * Character set header info |
|
241 */ |
|
242 TBuf8<KMaxCharSetLength> iCharSet; |
|
243 |
|
244 /** |
|
245 * Set to ETrue if the response code is KNotModified ( 304 ) |
|
246 */ |
|
247 TBool iNotModified; |
|
248 |
|
249 /** |
|
250 * Pointet to Logo download |
|
251 */ |
|
252 CIRLogoDownloadEngine* iLogoDownloadEngine; |
|
253 |
|
254 }; |
|
255 #endif // IRHTTPDATAPROVIDER_H |
|
256 |
|
257 |