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_WSFENGINE_H |
|
21 #define C_WSFENGINE_H |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <commsdattypesv1_1.h> |
|
26 #include <cmmanagerext.h> |
|
27 |
|
28 // INTERNAL INCLUDES |
|
29 #include "wsfwlanscannerobserver.h" |
|
30 #include "wsfwlanmonitorobserver.h" |
|
31 #include "wsfcommon.h" |
|
32 |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CWsfWlanScanner; |
|
36 class MWsfEngineObserver; |
|
37 class CWsfWlanBearerConnectionMonitor; |
|
38 class TWsfWlanInfo; |
|
39 class MWsfServerCloserAdapter; |
|
40 |
|
41 // CLASS DEFINITION |
|
42 /** |
|
43 * Sniffer engine class. |
|
44 * This class manages the objects responsible for connection creation, |
|
45 * closing and monitoring, communication with the WLAN engine etc. |
|
46 * |
|
47 * @since S60 5.0 |
|
48 * @lib wsfserver.exe |
|
49 */ |
|
50 NONSHARABLE_CLASS( CWsfEngine ): public CBase, |
|
51 public MWsfWlanScannerObserver, |
|
52 public MWsfWlanMonitorObserver |
|
53 { |
|
54 public: // Constructors and destructor |
|
55 /** |
|
56 * Factory function. |
|
57 * @since S60 5.0 |
|
58 * @param aServerCloser Reference to the server closer object. |
|
59 * Ownership not passed. |
|
60 * @return Server instance |
|
61 */ |
|
62 static CWsfEngine* NewL( MWsfServerCloserAdapter& aServerCloser ); |
|
63 |
|
64 /** |
|
65 * Factory function. |
|
66 * @since S60 5.0 |
|
67 * @param aServerCloser Reference to the server closer object. |
|
68 * Ownership not passed. |
|
69 * @return Server instance |
|
70 */ |
|
71 static CWsfEngine* NewLC( MWsfServerCloserAdapter& aServerCloser ); |
|
72 |
|
73 /** |
|
74 * Destructor |
|
75 */ |
|
76 ~CWsfEngine(); |
|
77 |
|
78 |
|
79 private: // Constructors |
|
80 /** |
|
81 * Constructor |
|
82 * @since S60 5.0 |
|
83 * @param aServerCloser Reference to the server closer object. |
|
84 * Ownership not passed. |
|
85 */ |
|
86 CWsfEngine( MWsfServerCloserAdapter& aServerCloser ); |
|
87 |
|
88 /** |
|
89 * Second-phase constructor. |
|
90 * @since S60 5.0 |
|
91 */ |
|
92 void ConstructL(); |
|
93 |
|
94 |
|
95 public: // New methods |
|
96 |
|
97 /** |
|
98 * Gets the result of complete wlan scan |
|
99 * @since S60 5.0 |
|
100 * @return Buffer pointer containing a serialized array of |
|
101 * wlaninfo items |
|
102 */ |
|
103 HBufC8* GetScanResults(); |
|
104 |
|
105 /** |
|
106 * Sets wlan scanning on |
|
107 * @since S60 5.0 |
|
108 */ |
|
109 void EnableScanningL(); |
|
110 |
|
111 /** |
|
112 * Sets wlan scanning off |
|
113 * @since S60 5.0 |
|
114 */ |
|
115 void DisableScanningL(); |
|
116 |
|
117 /** |
|
118 * Returns whether scanning is enabled |
|
119 * @since S60 5.0 |
|
120 * @return ETrue if scanning has been enabled, EFalse otherwise |
|
121 */ |
|
122 TBool IsScanning(); |
|
123 |
|
124 /** |
|
125 * Checks if there is an active wlan connection and returns connection |
|
126 * name (SSID) if appropriate. |
|
127 * @since S60 5.0 |
|
128 * @return The SSID of connected access point or empty descriptor |
|
129 * if not connected |
|
130 */ |
|
131 HBufC* ConnectedWlanSsidL(); |
|
132 |
|
133 /** |
|
134 * Fills the wlaninfo with the details of the active WLAN connection |
|
135 * @since S60 5.0 |
|
136 * @param aWlanInfo The wlaninfo record to be filled |
|
137 * Ownership not passed. |
|
138 * @return ETrue if success, EFalse on failure |
|
139 */ |
|
140 TBool ConnectedWlanConnectionDetailsL( TWsfWlanInfo& aWlanInfo ); |
|
141 |
|
142 /** |
|
143 * Connects to the given IAP |
|
144 * @since S60 5.0 |
|
145 * @param aIapId The IAP to connect to |
|
146 * @param aConnectOnly ETrue if Connect selected |
|
147 * @param aPersistence Persistence property of the IAP |
|
148 * @return KErrNone if successful, otherwise error code |
|
149 */ |
|
150 TInt ConnectWlanL( TUint32 aIapId, |
|
151 TBool aConnectOnly, |
|
152 TWsfIapPersistence aPersistence ); |
|
153 |
|
154 /** |
|
155 * Disconnects the active WLAN connection |
|
156 * @since S60 5.0 |
|
157 * @return ETrue on success, EFalse if there was nothing to disconnect |
|
158 */ |
|
159 TBool DisconnectWlan(); |
|
160 |
|
161 /** |
|
162 * Requests a wlan scan |
|
163 * @since S60 5.0 |
|
164 * @return ETrue if scanning is restarted |
|
165 */ |
|
166 TBool RefreshScanResults(); |
|
167 |
|
168 /** |
|
169 * Requests the server to monitor an access point |
|
170 * @since S60 5.0 |
|
171 * @param aApId Access Point to be monitored |
|
172 */ |
|
173 void MonitorAccessPointL( TUint32 aApId ); |
|
174 |
|
175 /** |
|
176 * Queries if there is an active WLAN connection. |
|
177 * @since S60 5.0 |
|
178 * @return ETrue if there is an active WLAN connection, |
|
179 * EFalse otherwise. |
|
180 */ |
|
181 TBool IsConnected(); |
|
182 |
|
183 /** |
|
184 * Aborts the currently ongoing connecting process |
|
185 * @since S60 5.0 |
|
186 */ |
|
187 void AbortConnectingL(); |
|
188 |
|
189 /** |
|
190 * Aborts the currently ongoing scanning process |
|
191 * @since S60 5.0 |
|
192 */ |
|
193 void AbortScanning(); |
|
194 |
|
195 /** |
|
196 * Sets the persistence property for the currently monitored IAP |
|
197 * @since S60 5.0 |
|
198 * @param aPersistence The value of the property |
|
199 * @return ETrue on success |
|
200 */ |
|
201 TBool SetIapPersistenceL( TWsfIapPersistence aPersistence ); |
|
202 |
|
203 /** |
|
204 * Controls the auto-disconnect timer in the server |
|
205 * for owned connections |
|
206 * @since S60 5.0 |
|
207 * @param aAdcCommand Command for the timer, |
|
208 * see TWsfAutoDisconnectCommand |
|
209 * @return ETrue if the timer has been started (also if it had been |
|
210 * started earlier), EFalse if the timer couldn't be started |
|
211 * (e.g. because there is no owned connection). |
|
212 */ |
|
213 TBool ControlDisconnectTimer( TUint aAdcCommand ); |
|
214 |
|
215 /** |
|
216 * Resets the iSuppressIapDeletion flag. |
|
217 * @since S60 5.0 |
|
218 */ |
|
219 void ResetSuppressIapDeletion (); |
|
220 |
|
221 |
|
222 public: // new methods |
|
223 |
|
224 /** |
|
225 * Adds the given observer to the notification list |
|
226 * @since S60 5.0 |
|
227 * @param aObserver The observer to add. Ownership not passed. |
|
228 */ |
|
229 void AttachL( MWsfEngineObserver* aObserver ); |
|
230 |
|
231 /** |
|
232 * Deletes the given observer from the notification list |
|
233 * @since S60 5.0 |
|
234 * @param aObserver The observer to remove. Ownership not passed. |
|
235 */ |
|
236 void Detach( MWsfEngineObserver* aObserver ); |
|
237 |
|
238 |
|
239 protected: // from MWsfWlanScannerObserver |
|
240 |
|
241 /** |
|
242 * When the scan cycle has completed this function is called to report |
|
243 * the completion. |
|
244 * @since S60 5.0 |
|
245 */ |
|
246 void WlanScanCompleteL(); |
|
247 |
|
248 /** |
|
249 * Called when the scan cycle has started |
|
250 * @since S60 5.0 |
|
251 */ |
|
252 void WlanScanStarted(); |
|
253 |
|
254 /** |
|
255 * Called when an error occured while scanning wlan data |
|
256 * @since S60 5.0 |
|
257 * @param aError System wide error code |
|
258 */ |
|
259 void NotifyError( TInt aError ); |
|
260 |
|
261 |
|
262 protected: // from MWsfWlanMonitorObserver |
|
263 |
|
264 /** |
|
265 * Called when a wlan connection is established |
|
266 * @since S60 5.0 |
|
267 * @param aConnectionName WLAN connection name (SSID) |
|
268 */ |
|
269 virtual void ConnectionEstablishedL( const TDesC& aConnectionName ); |
|
270 |
|
271 /** |
|
272 * Called when wlan connection has been lost |
|
273 * @since S60 5.0 |
|
274 */ |
|
275 virtual void ConnectionLostL(); |
|
276 |
|
277 /** |
|
278 * Called when the connection process failed for some reason |
|
279 * @since S60 5.0 |
|
280 * @param aError System wide error code |
|
281 */ |
|
282 virtual void ConnectingFailedL( TInt aError ); |
|
283 |
|
284 /** |
|
285 * Called when the connection no longer needs the IAP it was using |
|
286 * @since S60 5.0 |
|
287 */ |
|
288 virtual void ConnectedIapReleasedL(); |
|
289 |
|
290 |
|
291 private: |
|
292 |
|
293 /** |
|
294 * Tries to delete the corresponding IAP |
|
295 * @since S60 5.0 |
|
296 * @param aIapId The IAP to be deleted |
|
297 */ |
|
298 void DeleteIapL( TUint32 aIapId ); |
|
299 |
|
300 |
|
301 private: // Data |
|
302 /** |
|
303 * Reference to the server closer (not owned) |
|
304 */ |
|
305 MWsfServerCloserAdapter& iServerCloser; |
|
306 |
|
307 /** |
|
308 * WLAN scanner object (owned) |
|
309 */ |
|
310 CWsfWlanScanner* iScanner; |
|
311 |
|
312 /** |
|
313 * Handle to the commsdat database (owned) |
|
314 */ |
|
315 CommsDat::CMDBSession* iDbSession; |
|
316 |
|
317 /** |
|
318 * WLAN connection monitor object (owned) |
|
319 */ |
|
320 CWsfWlanBearerConnectionMonitor* iWlanBearerMonitor; |
|
321 |
|
322 /** |
|
323 * Reference counter for scan enabling requests |
|
324 */ |
|
325 TInt iEnableScanning; |
|
326 |
|
327 /** |
|
328 * Array of references to the observers of the engine |
|
329 * (elements not owned) |
|
330 */ |
|
331 RPointerArray<MWsfEngineObserver> iObservers; |
|
332 |
|
333 /** |
|
334 * Accesspoint to be monitored |
|
335 */ |
|
336 TUint32 iMonitoredIap; |
|
337 |
|
338 /** |
|
339 * Indicates the persistence property of monitored IAP |
|
340 */ |
|
341 TWsfIapPersistence iIapPersistence; |
|
342 |
|
343 /** |
|
344 * Indicates whether to postpone IAP deletion |
|
345 */ |
|
346 TBool iSuppressIapDeletion; |
|
347 }; |
|
348 |
|
349 #endif // C_WSFENGINE_H |
|
350 |
|
351 // End of file |
|