1 /* |
|
2 * Copyright (c) 2007-2008 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: Class header for CWsfModel |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_WSFMODEL_H |
|
20 #define C_WSFMODEL_H |
|
21 |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <ictsclientinterface.h> |
|
26 |
|
27 // INTERNAL INCLUDES |
|
28 #include "wsfsession.h" |
|
29 #include "wsfbrowserlaunchobserver.h" |
|
30 #include "wsfscreensaverstateobserver.h" |
|
31 #include "wsfbrowserlaunchadapter.h" |
|
32 #include "wsfwlaninfo.h" |
|
33 |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CWsfAppLauncher; |
|
37 class MWsfModelObserver; |
|
38 class CWsfWlanInfoArray; |
|
39 class MWsfStateChangeObserver; |
|
40 class CEikonEnv; |
|
41 class CWsfScreenSaverWatcher; |
|
42 class CWsfAsyncOperationQueue; |
|
43 |
|
44 |
|
45 // CLASS DEFINITION |
|
46 /** |
|
47 * Class acts as an application level model and is also entry point to the |
|
48 * application engine which is implemented as server |
|
49 * |
|
50 * @lib wsfmodel.lib |
|
51 * @since S60 5.0 |
|
52 */ |
|
53 NONSHARABLE_CLASS( CWsfModel ): public CBase, |
|
54 public MWsfBrowserLaunchObserver, |
|
55 public MWsfScreenSaverStateObserver, |
|
56 public MWsfBrowserLaunchAdapter, |
|
57 public MIctsObserver |
|
58 { |
|
59 public: // Constructors and destructor |
|
60 |
|
61 /** |
|
62 * Factory function. |
|
63 * @since S60 5.0 |
|
64 * @param aObserver The object to notify about server events |
|
65 * @param aScreenSaverAware Whether to react to screensaver events |
|
66 * @return Model instance |
|
67 */ |
|
68 IMPORT_C static CWsfModel* NewL( MWsfStateChangeObserver& aObserver, |
|
69 const TBool aScreenSaverAware ); |
|
70 |
|
71 /** |
|
72 * Factory function. |
|
73 * @since S60 5.0 |
|
74 * @param aObserver The object to notify about server events |
|
75 * @param aScreenSaverAware Whether to react to screensaver events |
|
76 * @return Model instance |
|
77 */ |
|
78 IMPORT_C static CWsfModel* NewLC( MWsfStateChangeObserver& aObserver, |
|
79 const TBool aScreenSaverAware ); |
|
80 |
|
81 IMPORT_C ~CWsfModel(); |
|
82 |
|
83 private: // Constructors |
|
84 CWsfModel(); |
|
85 |
|
86 /** |
|
87 * Factory function. |
|
88 * @since S60 5.0 |
|
89 * @param aObserver The object to notify about server events |
|
90 * @param aScreenSaverAware Whether to react to screensaver events |
|
91 */ |
|
92 void ConstructL( MWsfStateChangeObserver& aObserver, |
|
93 const TBool aScreenSaverAware ); |
|
94 |
|
95 public: // New methods |
|
96 |
|
97 /** |
|
98 * Attach model observer |
|
99 * @since S60 5.0 |
|
100 * @param aObserver Pointer to the model observer |
|
101 */ |
|
102 IMPORT_C void SetEngineObserver( MWsfModelObserver* aObserver ); |
|
103 |
|
104 /** |
|
105 * Return the latest list of found WLANs. Ownership not passed. |
|
106 * @since S60 5.0 |
|
107 * @return Array of WLANs |
|
108 */ |
|
109 IMPORT_C CWsfWlanInfoArray* GetWlanListL(); |
|
110 |
|
111 /** |
|
112 * Store active views UID |
|
113 * @since S60 5.0 |
|
114 * @param aActiveViewId Active view's UID |
|
115 */ |
|
116 IMPORT_C void SetActiveViewL( TInt aActiveViewId ); |
|
117 |
|
118 /** |
|
119 * Get UID of the active view |
|
120 * @since S60 5.0 |
|
121 * @return UID of active view |
|
122 */ |
|
123 IMPORT_C TUid ActiveViewL(); |
|
124 |
|
125 /** |
|
126 * Store SSID of active WLAN |
|
127 * @since S60 5.0 |
|
128 * @param aSsid WLAN's name (SSID) |
|
129 */ |
|
130 IMPORT_C void SetObservedWlanL( const TDesC8& aSsid ); |
|
131 |
|
132 /** |
|
133 * Get SSID of active WLAN |
|
134 * @since S60 5.0 |
|
135 * @return Active WLAN's name (SSID) |
|
136 */ |
|
137 IMPORT_C const TDesC8& ObservedWlan(); |
|
138 |
|
139 /** |
|
140 * Connects to the given WLAN IAP |
|
141 * @since S60 5.0 |
|
142 * @param aIapId WLAN IAP id to connect to. |
|
143 */ |
|
144 IMPORT_C int ConnectL( TUint32 aIapId ); |
|
145 |
|
146 /** |
|
147 * Connects to the given WLAN IAP |
|
148 * @since S60 5.2 |
|
149 * @param aIapId WLAN IAP id to connect to. |
|
150 */ |
|
151 IMPORT_C int ConnectWithoutConnWaiterL( TUint32 aIapId, |
|
152 TBool aTestedAccessPoint ); |
|
153 /** |
|
154 * Starts auto-disconnect timer for connected network |
|
155 * @since S60 5.2 |
|
156 */ |
|
157 IMPORT_C void FinalizeConnectL(); |
|
158 |
|
159 /** |
|
160 * Disconnects WLAN |
|
161 * @since S60 5.0 |
|
162 */ |
|
163 IMPORT_C void DisconnectL(); |
|
164 |
|
165 /** |
|
166 * Check if the engine is refreshing |
|
167 * @since S60 5.0 |
|
168 * @return ETrue if first refreshing |
|
169 */ |
|
170 IMPORT_C TBool Refreshing(); |
|
171 |
|
172 /** |
|
173 * Change refreshing state |
|
174 * @since S60 5.0 |
|
175 * @param aRefreshing Refreshing state |
|
176 */ |
|
177 IMPORT_C void SetRefreshState( TBool aRefreshing ); |
|
178 |
|
179 /** |
|
180 * Notifies server to start scanning if not scanning already |
|
181 * @since S60 5.0 |
|
182 * @return ETrue on success |
|
183 */ |
|
184 IMPORT_C TBool EnableScanL(); |
|
185 |
|
186 /** |
|
187 * Notifies server to disable scanning |
|
188 * However, scanning will continue if some other client |
|
189 * has enabled scanning. |
|
190 * @since S60 5.0 |
|
191 * @return ETrue on success |
|
192 */ |
|
193 IMPORT_C TBool DisableScanL(); |
|
194 |
|
195 /** |
|
196 * Checks if scanning is enabled in the server |
|
197 * @since S60 5.0 |
|
198 * @return EFalse if not scanning |
|
199 */ |
|
200 IMPORT_C TBool IsScanEnabledL(); |
|
201 |
|
202 /** |
|
203 * Continues browsing |
|
204 * @since S60 5.0 |
|
205 */ |
|
206 IMPORT_C void ContinueBrowsingL(); |
|
207 |
|
208 /** |
|
209 * Continues browsing (browser launched if needed) |
|
210 * @since S60 5.0 |
|
211 * @param aIapId The IAP id to use with the browser |
|
212 */ |
|
213 IMPORT_C void ContinueBrowsingL( TUint32 aIapId ); |
|
214 |
|
215 /** |
|
216 * Creates new WLAN access point based on wlaninfo passed as parameter. |
|
217 * If aExplicitDefine is ETrue, the connection method is saved to the |
|
218 * destination selected by the user, otherwise it is put into the |
|
219 * Uncategorized folder. |
|
220 * @since S60 5.0 |
|
221 * @param aWlan Reference to Wlan which is used as base |
|
222 * for new access point |
|
223 * @param aExplicitDefine Should be ETrue in case of |
|
224 * 'Define access point' |
|
225 * @return ETrue if access point creation succeeds |
|
226 */ |
|
227 IMPORT_C TBool CreateAccessPointL( TWsfWlanInfo& aWlan, |
|
228 TBool aExplicitDefine ); |
|
229 |
|
230 /** |
|
231 * Tests the WLAN access point and offers to save it to a destination |
|
232 * @since S60 5.0 |
|
233 * @param aWlan Reference to wlaninfo to test |
|
234 * @param aKeepConnection Indicates whether to keep alive the connection. |
|
235 * @param aConnectOnly ETrue if the helper app is expected to connect |
|
236 * only, EFalse if it should also launch the browser |
|
237 * on successful connection. |
|
238 * @return KErrNone if successful, system-wide error code otherwise |
|
239 */ |
|
240 IMPORT_C TInt TestAccessPointL( TWsfWlanInfo& aWlan, |
|
241 TBool aKeepConnection, |
|
242 TBool aConnectOnly ); |
|
243 |
|
244 /** |
|
245 * Tests the connected WLAN access point |
|
246 * @since S60 5.0 |
|
247 * @param aWlan Reference to wlaninfo to test |
|
248 * @param aConnectOnly ETrue if connect only case, |
|
249 * EFalse if launch browser case after successful connection. |
|
250 * @return KErrNone if successful, system-wide error code otherwise |
|
251 */ |
|
252 IMPORT_C TInt TestConnectedAccessPointL( TWsfWlanInfo& aWlan, |
|
253 TBool aConnectOnly ); |
|
254 |
|
255 /** |
|
256 * Requests a rescan for available wlans |
|
257 * @since S60 5.0 |
|
258 * @return ETrue on success |
|
259 */ |
|
260 IMPORT_C TBool RefreshScanL(); |
|
261 |
|
262 /** |
|
263 * Launches and helper application to create an accesspoint |
|
264 * @since S60 5.0 |
|
265 * @param aWlanInfo The WlanInfo object to be passed to the helper app |
|
266 * @param aConnecting ETrue if default connection is used, EFalse otherwise. |
|
267 * @param aConnectOnly ETrue if the helper app is expected to connect |
|
268 * only, EFalse if it should also launch the browser |
|
269 * on successful connection. |
|
270 */ |
|
271 IMPORT_C void LaunchHelperApplicationL( TWsfWlanInfo& aWlanInfo, |
|
272 TBool aConnecting, |
|
273 TBool aConnectOnly ); |
|
274 |
|
275 /** |
|
276 * Cancel notify events from server |
|
277 * @since S60 5.0 |
|
278 */ |
|
279 IMPORT_C void CancelNotifyEvents(); |
|
280 |
|
281 /** |
|
282 * Request notify events from server |
|
283 * @since S60 5.0 |
|
284 * @param aObserver Instance of MWsfStateChangeObserver to handle events |
|
285 */ |
|
286 IMPORT_C void RequestNotifyEventsL( |
|
287 MWsfStateChangeObserver& aObserver ); |
|
288 |
|
289 /** |
|
290 * Queries if there is an active WLAN connection. |
|
291 * @since S60 5.0 |
|
292 * @return ETrue if there is an active WLAN connection, |
|
293 * EFalse otherwise. |
|
294 */ |
|
295 IMPORT_C TBool IsConnectedL(); |
|
296 |
|
297 /** |
|
298 * If there is an active WLAN connection, returns its WLAN info. |
|
299 * @since S60 5.0 |
|
300 * @param aWlanInfo The wlaninfo object to fill |
|
301 * @return ETrue if success, EFalse otherwise. |
|
302 */ |
|
303 IMPORT_C TBool GetConnectedWlanDetailsL( TWsfWlanInfo& aWlanInfo ); |
|
304 |
|
305 /** |
|
306 * Queries whether a connecting process is going on |
|
307 * @since S60 5.0 |
|
308 * @return ETrue if connection is in progress |
|
309 */ |
|
310 inline TBool IsConnecting() const; |
|
311 |
|
312 /** |
|
313 * Sets connecting status |
|
314 * @since S60 5.0 |
|
315 * @param aIsConnecting The new status of the connecting process |
|
316 */ |
|
317 inline void SetConnecting( TBool aIsConnecting ); |
|
318 |
|
319 /** |
|
320 * Aborts the currently ongoing connecting process |
|
321 * @since S60 5.0 |
|
322 */ |
|
323 IMPORT_C void AbortConnectingL(); |
|
324 |
|
325 /** |
|
326 * Aborts the currently ongoing scanning process |
|
327 * @since S60 5.0 |
|
328 */ |
|
329 IMPORT_C void AbortScanningL(); |
|
330 |
|
331 /** |
|
332 * Gets the ICTS test permission setting value |
|
333 * @since S60 5.0 |
|
334 * @return The ICTS setting |
|
335 */ |
|
336 IMPORT_C static TInt IctsTestPermission(); |
|
337 |
|
338 /** |
|
339 * Check if Iap Id is valid |
|
340 * Leaves with system wide error code if Iap ID is |
|
341 * not valid or checking fails |
|
342 * @since S60 5.2 |
|
343 * @param aIapId IAP id passed as a parameter |
|
344 */ |
|
345 IMPORT_C void CheckIsIapIdValidL( TUint aIapId ) const; |
|
346 |
|
347 public: // from MWsfBrowserLaunchAdapter |
|
348 /** |
|
349 * Launches Browser application using selected iap |
|
350 * @since S60 5.0 |
|
351 * @param aIapId IAP id passed as a parameter |
|
352 */ |
|
353 IMPORT_C void LaunchBrowserL( TUint32 aIapId ); |
|
354 |
|
355 |
|
356 /** |
|
357 * Cleans up the possibly temporary IAP after user cancelled |
|
358 * the browser launch |
|
359 * @since S60 5.0 |
|
360 */ |
|
361 IMPORT_C void CleanUpCancelledLaunchL(); |
|
362 |
|
363 |
|
364 public: // From MWsfBrowserLaunchObserver |
|
365 |
|
366 /** |
|
367 * Called if browser launch succeeds |
|
368 * @since S60 5.0 |
|
369 */ |
|
370 void BrowserLaunchCompleteL(); |
|
371 |
|
372 /** |
|
373 * Called if browser launch failed |
|
374 * @since S60 5.0 |
|
375 * @param aError System-wide error code |
|
376 */ |
|
377 void BrowserLaunchFailed( TInt aError ); |
|
378 |
|
379 /** |
|
380 * Called when the previously launched browser exits |
|
381 * @since S60 5.0 |
|
382 */ |
|
383 void BrowserExitL(); |
|
384 |
|
385 |
|
386 private: // from MWsfScreenSaverStateObserver |
|
387 |
|
388 /** |
|
389 * Called if the status of the screensaver has been changed |
|
390 * @since S60 5.0 |
|
391 * @param aScreenSaverActive Current status of the screensaver |
|
392 */ |
|
393 void ScreenSaverStatusChangedL( const TBool aScreenSaverActive ); |
|
394 |
|
395 |
|
396 public: // from MIctsObserver |
|
397 |
|
398 /** |
|
399 * Called by ICTS during/after connectivity test |
|
400 * @since S60 5.0 |
|
401 * @param aResult Result code of the connectivity test |
|
402 * @param aString Parameter to hold auxiliary data |
|
403 */ |
|
404 void ConnectivityObserver( TIctsTestResult aResult, const TDesC& aString ); |
|
405 |
|
406 |
|
407 private: // New methods |
|
408 |
|
409 /** |
|
410 * Starts WLAN Login application |
|
411 * @param aString Contains redirect URL |
|
412 */ |
|
413 void LaunchWlanLoginL( const TDesC& aString ); |
|
414 |
|
415 /** |
|
416 * Makes the temporary IAP created for ICT persistent, i.e. notifies |
|
417 * the server not to delete it when the connection terminates. |
|
418 * @since S60 5.0 |
|
419 * @param aPersistence The persistence property for the IAP |
|
420 */ |
|
421 void MakeIctIapPersistentL( TWsfIapPersistence aPersistence ); |
|
422 |
|
423 /** |
|
424 * Moves the IAP to internet SNAP |
|
425 * @param aIapId Id of the connection method |
|
426 */ |
|
427 void MoveToInternetSnapL( const TUint32 aIapId ); |
|
428 |
|
429 /** |
|
430 * Check if there is disk space left |
|
431 * Leaves with KErrDiskFull is space is below CL |
|
432 * @since S60 5.0 |
|
433 */ |
|
434 void CheckSpaceBelowCriticalLevelL() const; |
|
435 |
|
436 /** |
|
437 * Check if access point to be created is |
|
438 * unknow and Network encryption is WAPI |
|
439 * Leaves with KErrWlanProtectedSetupSetupLocked |
|
440 * in the case of unknown WAPI AP. |
|
441 * @since S60 5.2 |
|
442 */ |
|
443 void CheckUnknownWapiL( TWsfWlanInfo& aWlan ) const; |
|
444 |
|
445 private: // Data |
|
446 /** |
|
447 * Reference to the current UI environment (not owned) |
|
448 */ |
|
449 CEikonEnv* iEikEnv; |
|
450 |
|
451 /** |
|
452 * Reference to the model observer (not owned) |
|
453 */ |
|
454 MWsfModelObserver* iObserver; |
|
455 |
|
456 /** |
|
457 * Browser launcher class. Owned. |
|
458 */ |
|
459 CWsfAppLauncher* iBrowserLauncher; |
|
460 |
|
461 /** |
|
462 * Screen saver watcher class. Owned. |
|
463 */ |
|
464 CWsfScreenSaverWatcher* iScreenSaverWatcher; |
|
465 |
|
466 /** |
|
467 * Client-side handle for server session |
|
468 */ |
|
469 RWsfSession iSession; |
|
470 |
|
471 /** |
|
472 * Array to store WLAN scan results. Owned. |
|
473 */ |
|
474 CWsfWlanInfoArray* iArray; |
|
475 |
|
476 /** |
|
477 * UID of active view |
|
478 */ |
|
479 TUid iActiveView; |
|
480 |
|
481 /** |
|
482 * Name of currently observed WLAN |
|
483 */ |
|
484 HBufC8* iObservedWlan; |
|
485 |
|
486 /** |
|
487 * Id of currently connected IAP (if applicable) |
|
488 */ |
|
489 TUint iConnectedIapId; |
|
490 |
|
491 /** |
|
492 * Network id of currently connected IAP (if applicable) |
|
493 */ |
|
494 TUint iConnectedNetId; |
|
495 |
|
496 /** |
|
497 * Refreshing status |
|
498 */ |
|
499 TBool iRefreshing; |
|
500 |
|
501 /** |
|
502 * Persistent WlanInfo for ICT cleanup |
|
503 */ |
|
504 TWsfWlanInfo iIctWlanInfo; |
|
505 |
|
506 /** |
|
507 * Indicates whether connection creation has been started but not |
|
508 * finished yet. |
|
509 */ |
|
510 TBool iConnecting; |
|
511 |
|
512 /** |
|
513 * Waiter for ICT |
|
514 */ |
|
515 CActiveSchedulerWait iIctWait; |
|
516 |
|
517 /** |
|
518 * Indicates that connectivity test if over. |
|
519 */ |
|
520 TBool iIctEnded; |
|
521 |
|
522 /** |
|
523 * Indicates if connection will be kept when launching browser. |
|
524 */ |
|
525 TBool iKeepConnection; |
|
526 |
|
527 /** |
|
528 * Indicates if "Connect" or "Start Web browsing" is selected. |
|
529 */ |
|
530 TBool iConnectOnly; |
|
531 |
|
532 }; |
|
533 |
|
534 |
|
535 #include "wsfmodel.inl" |
|
536 |
|
537 |
|
538 |
|
539 #endif // C_WSFMODEL_H |
|
540 |
|
541 // End of file |
|