|
1 /* |
|
2 * Copyright (c) 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: This is the declaration of the Browser Test Plugin Model. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef DIAGBROWSERPLUGINMODEL_H |
|
20 #define DIAGBROWSERPLUGINMODEL_H |
|
21 |
|
22 // System Include Files |
|
23 #include <e32base.h> // CActive |
|
24 #include <commdbconnpref.h> // TCommDbConnPref |
|
25 #include <es_sock.h> // RSocketServ, RConnection |
|
26 #include <http/rhttpsession.h> // RHTTPSession |
|
27 #include <http/rhttptransaction.h> // RHTTPTransaction |
|
28 #include <http/mhttptransactioncallback.h> // MHTTPTransactionCallback |
|
29 #include <DiagResultsDatabaseItem.h> // CDiagResultsDatabaseItem |
|
30 #include <diaglogeventeraserobserver.h> // MDiagLogEventEraserObserver |
|
31 #include <AknWaitDialog.h> |
|
32 // Forward Declarations |
|
33 class MDiagBrowserPluginModelObserver; |
|
34 class CPeriodic; |
|
35 class CDiagLogEventEraser; |
|
36 class RCmConnectionMethod; |
|
37 |
|
38 // Local Constants |
|
39 const TInt KMaxStringLength = ( 512 ); |
|
40 |
|
41 /** |
|
42 * Diagnostics Browser Test Plugin Model. |
|
43 * This class defines the model for the browser test plugin. This class is |
|
44 * used to validate end-to-end browser (HTTP) functionality. |
|
45 * |
|
46 * @lib euser.lib |
|
47 * @lib commonengine.lib |
|
48 * @lib centralrepository.lib |
|
49 * @lib cmmanager.lib |
|
50 * @lib commdb.lib |
|
51 * @lib inetprotutil.lib |
|
52 * @lib http.lib |
|
53 * @lib esock.lib |
|
54 * @lib flogger.lib |
|
55 * @lib logcli.lib |
|
56 * @lib diagframework.lib |
|
57 */ |
|
58 class CDiagBrowserPluginModel : public CActive, |
|
59 public MHTTPTransactionCallback, |
|
60 public MDiagLogEventEraserObserver, |
|
61 public MProgressDialogCallback |
|
62 { |
|
63 |
|
64 public: // New functions |
|
65 |
|
66 /** |
|
67 * Two-phased constructor. |
|
68 * |
|
69 * @param aObserver The model observer to report events to. |
|
70 * @return An instance of CDiagBrowserPluginModel. |
|
71 */ |
|
72 static CDiagBrowserPluginModel* NewL( |
|
73 MDiagBrowserPluginModelObserver& aObserver ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 ~CDiagBrowserPluginModel(); |
|
79 |
|
80 /** |
|
81 * Initiates the browser test. |
|
82 */ |
|
83 void RunBrowserTestL(); |
|
84 |
|
85 /** |
|
86 * Returns the total number of execution steps. |
|
87 * |
|
88 * @return The total number of execution steps. |
|
89 */ |
|
90 static TUint TotalSteps(); |
|
91 |
|
92 |
|
93 private: // Data types |
|
94 |
|
95 /** |
|
96 * Enumerates the states in the browser test. These are also used to |
|
97 * report test progress information. |
|
98 */ |
|
99 enum TDiagBrowserState |
|
100 { |
|
101 EDiagBrowserStateInitial = 0, |
|
102 EDiagBrowserStateConnectingBearer, |
|
103 EDiagBrowserStateConnectingServer, |
|
104 EDiagBrowserStateErasingLog, |
|
105 EDiagBrowserStateMax |
|
106 }; |
|
107 |
|
108 /** |
|
109 * Holds information about the connection methods used in the test. |
|
110 */ |
|
111 struct TBrowserConnectionMethodData |
|
112 { |
|
113 /** The access point of this connection method. */ |
|
114 TBuf< KMaxStringLength > iApn; |
|
115 |
|
116 /** The name of this connection method. */ |
|
117 TBuf< KMaxStringLength > iMethodName; |
|
118 |
|
119 /** The access point id of this connection method. */ |
|
120 TUint iApId; |
|
121 |
|
122 /** Indicates if this connection method contains valid data. */ |
|
123 TBool iIsValid; |
|
124 |
|
125 /** Indicates if this connection method was attempted. */ |
|
126 TBool iUsed; |
|
127 }; |
|
128 |
|
129 |
|
130 private: // New functions |
|
131 |
|
132 /** |
|
133 * The default constructor. |
|
134 */ |
|
135 CDiagBrowserPluginModel( MDiagBrowserPluginModelObserver& aObserver ); |
|
136 |
|
137 /** |
|
138 * Two-phased constructor. |
|
139 */ |
|
140 void ConstructL(); |
|
141 |
|
142 /** |
|
143 * Reads and stores the browser test's Central Repository Keys. |
|
144 * |
|
145 * @return ETrue if the operation succeeded, EFalse otherwise. |
|
146 */ |
|
147 TBool ReadCenRepKeysL(); |
|
148 |
|
149 /** |
|
150 * Finds the connection method that corresponds to the data supplied in the |
|
151 * argument. Updates the argument object with the connection method data. |
|
152 * |
|
153 * @param aData The connection method data to search with and update. |
|
154 */ |
|
155 void GetConnectionMethodL( TBrowserConnectionMethodData& aData ); |
|
156 |
|
157 /** |
|
158 * Checks if the connection method matches the data supplied in the |
|
159 * argument. Updates the argument object with the connection method data. |
|
160 * |
|
161 * @param aMethod The connection method to compare with. |
|
162 * @param aData The connection method data to search with and update. |
|
163 */ |
|
164 void CheckConnectionMatchL( const RCmConnectionMethod& aMethod, |
|
165 TBrowserConnectionMethodData& aData ) const; |
|
166 |
|
167 /** |
|
168 * Starts or resets the connection timeout timer. |
|
169 */ |
|
170 void StartConnectionTimerL(); |
|
171 |
|
172 /** |
|
173 * Updates the plugin's state and reports progress to the observer. |
|
174 * |
|
175 * @param aTargetState The new state to transition to. |
|
176 */ |
|
177 void SetStateL( TDiagBrowserState aTargetState ); |
|
178 |
|
179 /** |
|
180 * Callback function for handling timer events. |
|
181 * |
|
182 * @param aPtr A pointer to the instance of the browser test model. |
|
183 * @return An error code for the CPeriodic framework. |
|
184 */ |
|
185 static TInt TimerExpired( TAny* aPtr ); |
|
186 |
|
187 /** |
|
188 * Opens the network connection. May be called multiple times if a retry |
|
189 * is necessary. |
|
190 * |
|
191 * @return ETrue if the operation succeeded, EFalse otherwise. |
|
192 */ |
|
193 TBool OpenAndStartConnectionL(); |
|
194 |
|
195 /** |
|
196 * Handles ending the test by deleting the logs, if necessary, and |
|
197 * informing the observer. |
|
198 * |
|
199 * @param aResult The test result to complete with. |
|
200 */ |
|
201 void HandleTestEndL( CDiagResultsDatabaseItem::TResult aResult ); |
|
202 |
|
203 /** |
|
204 * Retries the connection on the secondary access point, if available, or |
|
205 * fails the test. |
|
206 */ |
|
207 void RetryConnectionL(); |
|
208 |
|
209 /** |
|
210 * Wait Dialog |
|
211 * |
|
212 */ |
|
213 void ShowProgressNoteL(); |
|
214 void TimerCleanUp(); |
|
215 |
|
216 private: // from MProgressDialogCallback |
|
217 |
|
218 /** |
|
219 * Called when the progress dialog is dismissed. |
|
220 * |
|
221 * @param aButtonId - indicate which button made dialog to dismiss |
|
222 */ |
|
223 virtual void DialogDismissedL( TInt aButtonId ); |
|
224 |
|
225 private: // From base class CActive |
|
226 |
|
227 /** |
|
228 * From CActive. |
|
229 * Handles active object completion events. |
|
230 */ |
|
231 virtual void RunL(); |
|
232 |
|
233 /** |
|
234 * From CActive. |
|
235 * Handles leaves in the active object's RunL function. |
|
236 */ |
|
237 virtual TInt RunError( TInt aError ); |
|
238 |
|
239 /** |
|
240 * From CActive. |
|
241 * Handle active object cancel event. |
|
242 */ |
|
243 virtual void DoCancel(); |
|
244 |
|
245 |
|
246 private: // From base class MHTTPTransactionCallback |
|
247 |
|
248 /** |
|
249 * From MHTTPTransactionCallback. |
|
250 * Called when an event occurs on an HTTP transaction. |
|
251 * |
|
252 * @param aTransaction The transaction the event occured on. |
|
253 * @param aEvent The event that occurred. |
|
254 */ |
|
255 virtual void MHFRunL( RHTTPTransaction aTransaction, |
|
256 const THTTPEvent& aEvent ); |
|
257 |
|
258 /** |
|
259 * From MHTTPTransactionCallback. |
|
260 * Called when an error occurs on an HTTP transaction. |
|
261 * |
|
262 * @param aError The error code. |
|
263 * @param aTransaction The transaction the error occured on. |
|
264 * @param aEvent The event that occurred. |
|
265 * @return An error code indicating if this error was handled. |
|
266 */ |
|
267 virtual TInt MHFRunError( TInt aError, |
|
268 RHTTPTransaction aTransaction, |
|
269 const THTTPEvent& aEvent ); |
|
270 |
|
271 |
|
272 private: // From base class MDiagLogEventEraserObserver |
|
273 |
|
274 /** |
|
275 * This function is called to check if the log event needs to be deleted. |
|
276 * |
|
277 * @param aEvent The event to check. |
|
278 * @return ETrue if the log event should be deleted, EFalse otherwise. |
|
279 */ |
|
280 virtual TBool IsEventToBeDeleted( const CLogEvent& aEvent ); |
|
281 |
|
282 /** |
|
283 * This function is called to notify that the erase operation is complete. |
|
284 * |
|
285 * @param aError Error code to indicate erase failure, or KErrNone. |
|
286 */ |
|
287 virtual void CompleteEventEraseL( TInt aError ); |
|
288 |
|
289 |
|
290 private: // Data |
|
291 |
|
292 /** The socket server session used by the test. */ |
|
293 RSocketServ iSocketServ; |
|
294 |
|
295 /** The network connection used by the test. */ |
|
296 RConnection iConnection; |
|
297 |
|
298 /** The HTTP session used by the test. */ |
|
299 RHTTPSession iHttpSession; |
|
300 |
|
301 /** The HTTP transaction used by the test. */ |
|
302 RHTTPTransaction iHttpTransaction; |
|
303 |
|
304 /** The connection preferences, used to establish the data connection. */ |
|
305 TCommDbConnPref iConnectionPrefs; |
|
306 |
|
307 /** The timeout timer. Own. */ |
|
308 CPeriodic* iTimer; |
|
309 |
|
310 /** The log eraser, used to remove the data usage from the OS log. Own. */ |
|
311 CDiagLogEventEraser* iLogEraser; |
|
312 |
|
313 /** The state of the test. */ |
|
314 TDiagBrowserState iState; |
|
315 |
|
316 /** The time testing started. Used to filter logs for deletion. */ |
|
317 TTime iStartTime; |
|
318 |
|
319 /** The primary connection method's data. */ |
|
320 TBrowserConnectionMethodData iPrimaryConnection; |
|
321 |
|
322 /** The secondary connection method's data. */ |
|
323 TBrowserConnectionMethodData iSecondaryConnection; |
|
324 |
|
325 /** The address of the proxy server to use (from CenRep). */ |
|
326 TBuf< KMaxStringLength > iProxyAddress; |
|
327 |
|
328 /** The port of the proxy server to use (from CenRep). */ |
|
329 TInt iProxyPort; |
|
330 |
|
331 /** The timeout value to use (from CenRep). */ |
|
332 TInt iTimeoutValue; |
|
333 |
|
334 /** The web page to retrieve (from CenRep). */ |
|
335 TBuf< KMaxStringLength > iUri; |
|
336 |
|
337 /** The test result to return. Used to hold the result while deleting logs |
|
338 * asynchronously. |
|
339 */ |
|
340 CDiagResultsDatabaseItem::TResult iResult; |
|
341 |
|
342 /** The model's observer, where events are reported. */ |
|
343 MDiagBrowserPluginModelObserver& iObserver; |
|
344 // Retrycount |
|
345 TInt iRetryCount,iTimerCalled; |
|
346 |
|
347 /** |
|
348 * |
|
349 * Wait Dialog |
|
350 * |
|
351 */ |
|
352 |
|
353 CAknWaitDialog* iWaitDialog; |
|
354 TBool idialogOn,idialogDismissed; |
|
355 }; |
|
356 |
|
357 #endif // DIAGBROWSERPLUGINMODEL_H |