|
1 /* |
|
2 * Copyright (c) 2005-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 "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: Header file CMiniBrowser class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MINI_BROWSER_H |
|
20 #define MINI_BROWSER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <http/mhttptransactioncallback.h> |
|
24 #include <http/mhttpdatasupplier.h> |
|
25 #include <http/rhttpsession.h> |
|
26 #include <http/rhttptransaction.h> |
|
27 |
|
28 |
|
29 #include "MiniBrowserObserver.h" |
|
30 #include "HttpProvStates.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CNHeadWrapperParser; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * CMiniBrowser class |
|
39 * |
|
40 * @since 3.1? |
|
41 */ |
|
42 class CMiniBrowser : |
|
43 public CBase, |
|
44 public MHTTPTransactionCallback, |
|
45 public MHTTPDataSupplier |
|
46 { |
|
47 public: |
|
48 enum TContentType |
|
49 { |
|
50 EContentTypeUnknown = 0, |
|
51 EContentTypeTextPlain, |
|
52 EContentTypeNokiaHeadWrapper |
|
53 }; |
|
54 /** |
|
55 Standard Symbian 2 phase constructor. The returned object is left |
|
56 to the CleanupStack. |
|
57 @param aObserver Listens for events/errors |
|
58 @param aSocketServ RSocketServ. Note! This must be opened until |
|
59 the CMiniBrowser object has been destroyed. |
|
60 @param aSocketServ RSocketServ. Note! This must be opened and |
|
61 started until the CMiniBrowser object has been destroyed. |
|
62 */ |
|
63 static CMiniBrowser* NewLC( MMiniBrowserObserver& aObserver, |
|
64 RSocketServ& aSocketServ, RConnection& aConnection ); |
|
65 |
|
66 /** |
|
67 Standard Symbian 2 phase constructor. |
|
68 @param aObserver Listens for events/errors |
|
69 @param aSocketServ RSocketServ. Note! This must be opened until |
|
70 the CMiniBrowser object has been destroyed. |
|
71 @param aSocketServ RSocketServ. Note! This must be opened and |
|
72 started until the CMiniBrowser object has been destroyed. |
|
73 */ |
|
74 static CMiniBrowser* NewL( MMiniBrowserObserver& aObserver, RSocketServ& |
|
75 aSocketServ, RConnection& aConnection ); |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 */ |
|
80 virtual ~CMiniBrowser(); |
|
81 |
|
82 /** |
|
83 Make a HTTP GET request to the url defined. |
|
84 Use this override if the AP used does not have proxy defined. |
|
85 @param aUri |
|
86 @param aProxyAddress Proxy server address. |
|
87 @param aProxyPort Port to be used for proxy server |
|
88 */ |
|
89 void HttpGetL( const TDesC& aUri ); |
|
90 |
|
91 /** |
|
92 Make a HTTP GET request to the url defined. |
|
93 Use this override if the AP used has a proxy defined. |
|
94 @param aUri |
|
95 @param aProxyAddress Proxy server address. |
|
96 @param aProxyPort Port to be used for proxy server |
|
97 */ |
|
98 void HttpGetL( const TDesC& aUri, const TDesC& aProxyAddress, |
|
99 const TUint aProxyPort ); |
|
100 |
|
101 /** |
|
102 Returns the report URL that was in the previously received HeadWrapper document. |
|
103 Leaves with KErrNotFound if there was no valid report url or no HeadWrapper document |
|
104 has been received. |
|
105 @return Report Url. Left to CleanupStack. |
|
106 */ |
|
107 HBufC* GetReportUrlLC(); |
|
108 |
|
109 private: |
|
110 CMiniBrowser( MMiniBrowserObserver& aObserver ); |
|
111 void ConstructL( RSocketServ& aSocketServ, RConnection& aConnection ); |
|
112 |
|
113 /** |
|
114 Called from HttpGetL. |
|
115 @see HttpGetL |
|
116 */ |
|
117 void CMiniBrowser::DoHttpGetL( |
|
118 const TDesC& aUri, |
|
119 const TBool aUseProxy, |
|
120 const TDesC& aProxyAddress, |
|
121 const TUint aProxyPort ); |
|
122 |
|
123 |
|
124 public: // from MHTTPTransactionCallback |
|
125 |
|
126 /*! |
|
127 Called when the filter's registration conditions are satisfied |
|
128 for events that occur on a transaction. Note that this function |
|
129 is not allowed to leave if called with certain events |
|
130 */ |
|
131 void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent &aEvent ); |
|
132 /*! |
|
133 Called when RunL leaves from a transaction event. This works |
|
134 in the same way as CActve::RunError; return KErrNone if you |
|
135 have handled the error. If you don't completely handle the |
|
136 error, a panic will occur. |
|
137 */ |
|
138 TInt MHFRunError( TInt aError, RHTTPTransaction aTransaction, |
|
139 const THTTPEvent& aEvent ); |
|
140 |
|
141 public: // from MHTTPDataSupplier |
|
142 |
|
143 /*! |
|
144 Obtain a data part from the supplier. The data is guaranteed to |
|
145 survive until a call is made to ReleaseData(). |
|
146 */ |
|
147 TBool GetNextDataPart( TPtrC8 &aDataPart ); |
|
148 |
|
149 /*! |
|
150 Release the current data part being held at the data supplier. |
|
151 This call indicates to the supplier that the part is no longer |
|
152 needed, and another one can be supplied, if appropriate. |
|
153 */ |
|
154 void ReleaseData(); |
|
155 |
|
156 /*! |
|
157 Obtain the overall size of the data being supplied, if known to |
|
158 the supplier. Where a body of data is supplied in several parts |
|
159 this size will be the sum of all the part sizes. If the size is |
|
160 not known, KErrNotFound is returned; in this case the client must |
|
161 use the return code of GetNextDataPart to find out when the data |
|
162 is complete. |
|
163 */ |
|
164 TInt OverallDataSize(); |
|
165 |
|
166 /*! |
|
167 Reset the data supplier. This indicates to the data supplier that |
|
168 it should return to the first part of the data. This could be used |
|
169 in a situation where the data consumer has encountered an error and |
|
170 needs the data to be supplied afresh. Even if the last part has |
|
171 been supplied (i.e. GetNextDataPart has returned ETrue), the data |
|
172 supplier should reset to the first part. |
|
173 |
|
174 If the supplier cannot reset it should return an error code; |
|
175 otherwise it should return KErrNone, where the reset will be |
|
176 assumed to have succeeded |
|
177 */ |
|
178 TInt Reset(); |
|
179 |
|
180 private: |
|
181 /* |
|
182 @return TInt KErrNone in case everything was Ok. |
|
183 */ |
|
184 static TInt TimeOutCallBack( TAny* aMiniBrowser); |
|
185 /* |
|
186 Called by TimeOutCallBack |
|
187 */ |
|
188 void DoTimeOutCallBackL(); |
|
189 |
|
190 /*! |
|
191 Appends aData to iResponseData. If aData does not fit in, iResponseData |
|
192 is reallocated. |
|
193 */ |
|
194 void AppendResponseDataL( const TDesC8& aData ); |
|
195 |
|
196 /*! |
|
197 Deletes and allocates an empty buffer for iResponseData and iReportUrl. |
|
198 This is called from DoHttpGetL to prevent using same response data and |
|
199 report url twice. |
|
200 */ |
|
201 void ResetResponseDataL(); |
|
202 |
|
203 /** |
|
204 Currently not supported |
|
205 Shows the response text (from iResponseData) in a dialog. |
|
206 */ |
|
207 // void ShowMessageDialogL( const TDesC8& aMessage ); |
|
208 |
|
209 /** |
|
210 Parses received data and saves provisioned settings if the data is a |
|
211 HeadWrapper document. |
|
212 */ |
|
213 void ParseAndSaveProvisionedSettingsL(); |
|
214 |
|
215 /** |
|
216 Saves provisioned settings. |
|
217 */ |
|
218 void SaveProvisionedSettingsL( const TDesC8& aContent ); |
|
219 |
|
220 /*! |
|
221 Get special user agent string for ServiceHelp silent mode. |
|
222 */ |
|
223 HBufC8* GetUserAgentStringL(); |
|
224 |
|
225 /*! |
|
226 Get report Url from CNHeadWrapperParser and store it into iReportUrl |
|
227 buffer for later reference. |
|
228 */ |
|
229 void GetReportUrlL( const CNHeadWrapperParser& aNHwrParser ); |
|
230 |
|
231 private: |
|
232 /*! Time-out timer */ |
|
233 CPeriodic* iPeriodic; |
|
234 /*! Observer is notified when transaction was successful or failed */ |
|
235 MMiniBrowserObserver& iObserver; |
|
236 /*! Internet access point id */ |
|
237 TInt iIapId; |
|
238 /*! buffer for URI */ |
|
239 HBufC8* iUri; |
|
240 /*! buffer for received data */ |
|
241 HBufC8* iResponseData; |
|
242 /*! buffer for report/next url parameter of received HeadWrapper document */ |
|
243 HBufC8* iReportUrl; |
|
244 /*! The content type header value of the received data */ |
|
245 TContentType iContentType; |
|
246 /*! Http session */ |
|
247 RHTTPSession iSession; |
|
248 /*! String pool for http session */ |
|
249 RStringPool iSessionStringPool; |
|
250 /*! Http transaction*/ |
|
251 RHTTPTransaction iTransaction; |
|
252 /*! The status of last provisioning, default is EStatusUnknown */ |
|
253 THttpProvStates::TProvisioningStatus iProvisioningStatus; |
|
254 }; |
|
255 |
|
256 #endif // MINI_BROWSER_H |
|
257 |
|
258 // End of File |