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 |
|
20 #ifndef C_WSFMODEL_H |
|
21 #define C_WSFMODEL_H |
|
22 |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <e32base.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 { |
|
58 public: // Constructors and destructor |
|
59 |
|
60 /** |
|
61 * Factory function. |
|
62 * @since S60 5.0 |
|
63 * @param aObserver The object to notify about server events |
|
64 * @param aScreenSaverAware Whether to react to screensaver events |
|
65 * @return Model instance |
|
66 */ |
|
67 IMPORT_C static CWsfModel* NewL( MWsfStateChangeObserver& aObserver, |
|
68 const TBool aScreenSaverAware ); |
|
69 |
|
70 /** |
|
71 * Factory function. |
|
72 * @since S60 5.0 |
|
73 * @param aObserver The object to notify about server events |
|
74 * @param aScreenSaverAware Whether to react to screensaver events |
|
75 * @return Model instance |
|
76 */ |
|
77 IMPORT_C static CWsfModel* NewLC( MWsfStateChangeObserver& aObserver, |
|
78 const TBool aScreenSaverAware ); |
|
79 |
|
80 IMPORT_C ~CWsfModel(); |
|
81 |
|
82 private: // Constructors |
|
83 CWsfModel(); |
|
84 |
|
85 /** |
|
86 * Factory function. |
|
87 * @since S60 5.0 |
|
88 * @param aObserver The object to notify about server events |
|
89 * @param aScreenSaverAware Whether to react to screensaver events |
|
90 */ |
|
91 void ConstructL( MWsfStateChangeObserver& aObserver, |
|
92 const TBool aScreenSaverAware ); |
|
93 |
|
94 public: // New methods |
|
95 |
|
96 /** |
|
97 * Attach model observer |
|
98 * @since S60 5.0 |
|
99 * @param aObserver Pointer to the model observer |
|
100 */ |
|
101 IMPORT_C void SetEngineObserver( MWsfModelObserver* aObserver ); |
|
102 |
|
103 /** |
|
104 * Return the latest list of found WLANs. Ownership not passed. |
|
105 * @since S60 5.0 |
|
106 * @return Array of WLANs |
|
107 */ |
|
108 IMPORT_C CWsfWlanInfoArray* GetWlanListL(); |
|
109 |
|
110 /** |
|
111 * Asyncronous request to the server to return wlan list size |
|
112 * @since S60 5.2 |
|
113 * @param aPckg request result |
|
114 * @param aStatus The request status object used to contain |
|
115 * the completion status of the request. |
|
116 */ |
|
117 IMPORT_C void GetWlanListSize( TPckgBuf<TUint>& aPckg, |
|
118 TRequestStatus& aStatus ); |
|
119 |
|
120 /** |
|
121 * Asyncronous request to the server to return wlan list |
|
122 * @since S60 5.2 |
|
123 * @param aPckg request result |
|
124 * @param aPtr wlan list |
|
125 * @param aStatus The request status object used to contain |
|
126 * the completion status of the request. |
|
127 */ |
|
128 IMPORT_C void GetWlanList( TPckgBuf<TUint>& aPckg, TPtr8& aPtr, |
|
129 TRequestStatus& aStatus ); |
|
130 |
|
131 /** |
|
132 * Store active views UID |
|
133 * @since S60 5.0 |
|
134 * @param aActiveViewId Active view's UID |
|
135 */ |
|
136 IMPORT_C void SetActiveViewL( TInt aActiveViewId ); |
|
137 |
|
138 /** |
|
139 * Get UID of the active view |
|
140 * @since S60 5.0 |
|
141 * @return UID of active view |
|
142 */ |
|
143 IMPORT_C TUid ActiveViewL(); |
|
144 |
|
145 /** |
|
146 * Store SSID of active WLAN |
|
147 * @since S60 5.0 |
|
148 * @param aSsid WLAN's name (SSID) |
|
149 */ |
|
150 IMPORT_C void SetObservedWlanL( const TDesC8& aSsid ); |
|
151 |
|
152 /** |
|
153 * Get SSID of active WLAN |
|
154 * @since S60 5.0 |
|
155 * @return Active WLAN's name (SSID) |
|
156 */ |
|
157 IMPORT_C const TDesC8& ObservedWlan(); |
|
158 |
|
159 /** |
|
160 * Connects to the given WLAN IAP |
|
161 * @since S60 5.0 |
|
162 * @param aIapId WLAN IAP id to connect to. |
|
163 * @param aConnectOnly ETrue if Connect selected |
|
164 * @param aPersistence The value of the persistence property |
|
165 */ |
|
166 IMPORT_C int ConnectL( TUint32 aIapId, |
|
167 TBool aConnectOnly, |
|
168 TWsfIapPersistence aPersistence ); |
|
169 |
|
170 /** |
|
171 * Asyncronous request to the server to connect to the given WLAN IAP |
|
172 * @since S60 5.2 |
|
173 * @param aPckg request result |
|
174 * @param aIapId WLAN IAP id to connect to. |
|
175 * @param aConnectOnly ETrue if Connect selected |
|
176 * @param aPersistence The value of the persistence property |
|
177 * @param aStatus The request status object used to contain |
|
178 * the completion status of the request. |
|
179 */ |
|
180 IMPORT_C void ConnectL( TPckgBuf<TBool>& aPckg, TUint32 aIapId, |
|
181 TBool aConnectOnly, |
|
182 TWsfIapPersistence aPersistence, |
|
183 TRequestStatus& aStatus ); |
|
184 |
|
185 /** |
|
186 * Sets connection result |
|
187 * @since S60 5.2 |
|
188 * @param aResult connection result |
|
189 * @param aIapId WLAN IAP |
|
190 */ |
|
191 IMPORT_C void SetConnectResultL( TInt aResult, TUint aIapId ); |
|
192 |
|
193 /** |
|
194 * Disconnects WLAN |
|
195 * @since S60 5.0 |
|
196 */ |
|
197 IMPORT_C void DisconnectL(); |
|
198 |
|
199 /** |
|
200 * Asyncronous request to the server to disconnect |
|
201 * @since S60 5.2 |
|
202 * @param aPckg request result |
|
203 * @param aStatus The request status object used to contain |
|
204 * the completion status of the request. |
|
205 */ |
|
206 IMPORT_C void Disconnect( TPckgBuf<TBool>& aPckg, |
|
207 TRequestStatus& aStatus ); |
|
208 |
|
209 /** |
|
210 * Check if the engine is refreshing |
|
211 * @since S60 5.0 |
|
212 * @return ETrue if first refreshing |
|
213 */ |
|
214 IMPORT_C TBool Refreshing(); |
|
215 |
|
216 /** |
|
217 * Change refreshing state |
|
218 * @since S60 5.0 |
|
219 * @param aRefreshing Refreshing state |
|
220 */ |
|
221 IMPORT_C void SetRefreshState( TBool aRefreshing ); |
|
222 |
|
223 /** |
|
224 * Notifies server to start scanning if not scanning already |
|
225 * @since S60 5.0 |
|
226 * @return ETrue on success |
|
227 */ |
|
228 IMPORT_C TBool EnableScanL(); |
|
229 |
|
230 /** |
|
231 * Notifies server to disable scanning |
|
232 * However, scanning will continue if some other client |
|
233 * has enabled scanning. |
|
234 * @since S60 5.0 |
|
235 * @return ETrue on success |
|
236 */ |
|
237 IMPORT_C TBool DisableScanL(); |
|
238 |
|
239 /** |
|
240 * Checks if scanning is enabled in the server |
|
241 * @since S60 5.0 |
|
242 * @return EFalse if not scanning |
|
243 */ |
|
244 IMPORT_C TBool IsScanEnabledL(); |
|
245 |
|
246 /** |
|
247 * Continues browsing |
|
248 * @since S60 5.0 |
|
249 */ |
|
250 IMPORT_C void ContinueBrowsingL(); |
|
251 |
|
252 /** |
|
253 * Continues browsing (browser launched if needed) |
|
254 * @since S60 5.0 |
|
255 * @param aIapId The IAP id to use with the browser |
|
256 */ |
|
257 IMPORT_C void ContinueBrowsingL( TUint32 aIapId ); |
|
258 |
|
259 /** |
|
260 * Creates new WLAN access point based on wlaninfo passed as parameter. |
|
261 * If aExplicitDefine is ETrue, the connection method is saved to the |
|
262 * destination selected by the user, otherwise it is put into the |
|
263 * Uncategorized folder. |
|
264 * @since S60 5.0 |
|
265 * @param aWlan Reference to Wlan which is used as base |
|
266 * for new access point |
|
267 * @param aExplicitDefine Should be ETrue in case of |
|
268 * 'Define access point' |
|
269 * @return ETrue if access point creation succeeds |
|
270 */ |
|
271 IMPORT_C TBool CreateAccessPointL( TWsfWlanInfo& aWlan, |
|
272 TBool aExplicitDefine ); |
|
273 |
|
274 /** |
|
275 * Requests a rescan for available wlans |
|
276 * @since S60 5.0 |
|
277 * @return ETrue on success |
|
278 */ |
|
279 IMPORT_C TBool RefreshScanL(); |
|
280 |
|
281 /** |
|
282 * Asyncronous request to the server to make a scan |
|
283 * @since S60 5.2 |
|
284 * @param aPckg request result |
|
285 * @param aStatus The request status object used to contain |
|
286 * the completion status of the request. |
|
287 */ |
|
288 IMPORT_C void RefreshScan( TPckgBuf<TBool>& aPckg, |
|
289 TRequestStatus& aStatus ); |
|
290 |
|
291 /** |
|
292 * Closes helper application if it is launched |
|
293 * @since S60 5.2 |
|
294 * @return ETrue if helper application task was closed |
|
295 */ |
|
296 IMPORT_C TBool CloseHelperApplication(); |
|
297 |
|
298 /** |
|
299 * Launches and helper application to create an accesspoint |
|
300 * @since S60 5.2 |
|
301 * @param aWlanInfo The WlanInfo object to be passed to the helper app |
|
302 */ |
|
303 IMPORT_C void LaunchHelperApplicationL( TWsfWlanInfo& aWlanInfo ); |
|
304 |
|
305 /** |
|
306 * Cancel notify events from server |
|
307 * @since S60 5.0 |
|
308 */ |
|
309 IMPORT_C void CancelNotifyEvents(); |
|
310 |
|
311 /** |
|
312 * Request notify events from server |
|
313 * @since S60 5.0 |
|
314 * @param aObserver Instance of MWsfStateChangeObserver to handle events |
|
315 */ |
|
316 IMPORT_C void RequestNotifyEventsL( |
|
317 MWsfStateChangeObserver& aObserver ); |
|
318 |
|
319 /** |
|
320 * Queries if there is an active WLAN connection. |
|
321 * @since S60 5.0 |
|
322 * @return ETrue if there is an active WLAN connection, |
|
323 * EFalse otherwise. |
|
324 */ |
|
325 IMPORT_C TBool IsConnectedL(); |
|
326 |
|
327 /** |
|
328 * If there is an active WLAN connection, returns its WLAN info. |
|
329 * @since S60 5.0 |
|
330 * @param aWlanInfo The wlaninfo object to fill |
|
331 * @return ETrue if success, EFalse otherwise. |
|
332 */ |
|
333 IMPORT_C TBool GetConnectedWlanDetailsL( TWsfWlanInfo& aWlanInfo ); |
|
334 |
|
335 /** |
|
336 * Asyncronous request to the server to return connected network |
|
337 * @since S60 5.2 |
|
338 * @param aPckg request result |
|
339 * @param aWlanInfo The wlaninfo object to fill |
|
340 * @param aStatus The request status object used to contain |
|
341 * the completion status of the request. |
|
342 */ |
|
343 IMPORT_C void GetConnectedWlanDetails( TPckgBuf<TBool>& aPckg, |
|
344 TWsfWlanInfo& aWlanInfo, |
|
345 TRequestStatus& aStatus ); |
|
346 |
|
347 /** |
|
348 * Queries whether a connecting process is going on |
|
349 * @since S60 5.0 |
|
350 * @return ETrue if connection is in progress |
|
351 */ |
|
352 inline TBool IsConnecting() const; |
|
353 |
|
354 /** |
|
355 * Sets connecting status |
|
356 * @since S60 5.0 |
|
357 * @param aIsConnecting The new status of the connecting process |
|
358 */ |
|
359 inline void SetConnecting( TBool aIsConnecting ); |
|
360 |
|
361 /** |
|
362 * Aborts the currently ongoing connecting process |
|
363 * @since S60 5.0 |
|
364 */ |
|
365 IMPORT_C void AbortConnectingL(); |
|
366 |
|
367 /** |
|
368 * Aborts the currently ongoing scanning process |
|
369 * @since S60 5.0 |
|
370 */ |
|
371 IMPORT_C void AbortScanningL(); |
|
372 |
|
373 /** |
|
374 * Check if Iap Id is valid |
|
375 * Leaves with system wide error code if Iap ID is |
|
376 * not valid or checking fails |
|
377 * @since S60 5.2 |
|
378 * @param aIapId IAP id passed as a parameter |
|
379 */ |
|
380 IMPORT_C void CheckIsIapIdValidL( TUint aIapId ) const; |
|
381 |
|
382 public: // from MWsfBrowserLaunchAdapter |
|
383 /** |
|
384 * Launches Browser application using selected iap |
|
385 * @since S60 5.0 |
|
386 * @param aIapId IAP id passed as a parameter |
|
387 */ |
|
388 IMPORT_C void LaunchBrowserL( TUint32 aIapId ); |
|
389 |
|
390 |
|
391 public: // From MWsfBrowserLaunchObserver |
|
392 |
|
393 /** |
|
394 * Called if browser launch succeeds |
|
395 * @since S60 5.0 |
|
396 */ |
|
397 void BrowserLaunchCompleteL(); |
|
398 |
|
399 /** |
|
400 * Called if browser launch failed |
|
401 * @since S60 5.0 |
|
402 * @param aError System-wide error code |
|
403 */ |
|
404 void BrowserLaunchFailed( TInt aError ); |
|
405 |
|
406 /** |
|
407 * Called when the previously launched browser exits |
|
408 * @since S60 5.0 |
|
409 */ |
|
410 void BrowserExitL(); |
|
411 |
|
412 |
|
413 private: // from MWsfScreenSaverStateObserver |
|
414 |
|
415 /** |
|
416 * Called if the status of the screensaver has been changed |
|
417 * @since S60 5.0 |
|
418 * @param aScreenSaverActive Current status of the screensaver |
|
419 */ |
|
420 void ScreenSaverStatusChangedL( const TBool aScreenSaverActive ); |
|
421 |
|
422 |
|
423 private: // New methods |
|
424 |
|
425 /** |
|
426 * Check if there is disk space left |
|
427 * Leaves with KErrDiskFull is space is below CL |
|
428 * @since S60 5.0 |
|
429 */ |
|
430 void CheckSpaceBelowCriticalLevelL() const; |
|
431 |
|
432 /** |
|
433 * Check if access point to be created is |
|
434 * unknow and Network encryption is WAPI |
|
435 * Leaves with KErrWlanProtectedSetupSetupLocked |
|
436 * in the case of unknown WAPI AP. |
|
437 * @since S60 5.2 |
|
438 */ |
|
439 void CheckUnknownWapiL( TWsfWlanInfo& aWlan ) const; |
|
440 |
|
441 private: // Data |
|
442 /** |
|
443 * Reference to the current UI environment (not owned) |
|
444 */ |
|
445 CEikonEnv* iEikEnv; |
|
446 |
|
447 /** |
|
448 * Reference to the model observer (not owned) |
|
449 */ |
|
450 MWsfModelObserver* iObserver; |
|
451 |
|
452 /** |
|
453 * Browser launcher class. Owned. |
|
454 */ |
|
455 CWsfAppLauncher* iBrowserLauncher; |
|
456 |
|
457 /** |
|
458 * Screen saver watcher class. Owned. |
|
459 */ |
|
460 CWsfScreenSaverWatcher* iScreenSaverWatcher; |
|
461 |
|
462 /** |
|
463 * Client-side handle for server session |
|
464 */ |
|
465 RWsfSession iSession; |
|
466 |
|
467 /** |
|
468 * Array to store WLAN scan results. Owned. |
|
469 */ |
|
470 CWsfWlanInfoArray* iArray; |
|
471 |
|
472 /** |
|
473 * UID of active view |
|
474 */ |
|
475 TUid iActiveView; |
|
476 |
|
477 /** |
|
478 * Name of currently observed WLAN |
|
479 */ |
|
480 HBufC8* iObservedWlan; |
|
481 |
|
482 /** |
|
483 * Id of currently connected IAP (if applicable) |
|
484 */ |
|
485 TUint iConnectedIapId; |
|
486 |
|
487 /** |
|
488 * Refreshing status |
|
489 */ |
|
490 TBool iRefreshing; |
|
491 |
|
492 /** |
|
493 * Indicates whether connection creation has been started but not |
|
494 * finished yet. |
|
495 */ |
|
496 TBool iConnecting; |
|
497 |
|
498 }; |
|
499 |
|
500 |
|
501 #include "wsfmodel.inl" |
|
502 |
|
503 |
|
504 |
|
505 #endif // C_WSFMODEL_H |
|
506 |
|
507 // End of file |
|