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 CWsfWlanBearerConnectionMonitor |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_WSFWLANBEARERCONNECTIONMONITOR_H |
|
21 #define C_WSFWLANBEARERCONNECTIONMONITOR_H |
|
22 |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <rconnmon.h> |
|
27 #include <es_sock.h> |
|
28 #include <cmdefconnvalues.h> |
|
29 #include <cmmanagerext.h> |
|
30 |
|
31 // INTERNAL INCLUDES |
|
32 #include "wsfwlaninfo.h" |
|
33 #include "wsfwlanconnectiondetailsprovider.h" |
|
34 |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class MWsfWlanMonitorObserver; |
|
38 class MWsfServerCloserAdapter; |
|
39 |
|
40 |
|
41 // CLASS DEFINITION |
|
42 /** |
|
43 * Class to monitor and control all WLAN bearer related events and actions |
|
44 * |
|
45 * @since S60 5.0 |
|
46 * @lib wsfserver.exe |
|
47 */ |
|
48 NONSHARABLE_CLASS( CWsfWlanBearerConnectionMonitor ): public CActive, |
|
49 public MConnectionMonitorObserver, |
|
50 public MWsfWlanConnectionDetailsProvider |
|
51 { |
|
52 private: |
|
53 /** |
|
54 * Connecting states when creating an owned connection |
|
55 */ |
|
56 enum TWsfConnectingState |
|
57 { |
|
58 /** |
|
59 * Not connected, neither requested |
|
60 */ |
|
61 ECsIdle, |
|
62 |
|
63 /** |
|
64 * Requested to connect |
|
65 */ |
|
66 ECsNotConnected, |
|
67 |
|
68 /** |
|
69 * Socket server and connection handler opened |
|
70 */ |
|
71 ECsSocketOpened, |
|
72 |
|
73 /** |
|
74 * Connection has been established |
|
75 */ |
|
76 ECsConnectionCreated, |
|
77 |
|
78 /** |
|
79 * Connection environment fully initialized |
|
80 */ |
|
81 ECsConnected |
|
82 }; |
|
83 |
|
84 |
|
85 public: // Constructors and destructor |
|
86 /** |
|
87 * Factory function. |
|
88 * @since S60 5.0 |
|
89 * @param aServerCloser Reference to the server closer object. |
|
90 * Ownership not passed. |
|
91 * @return Class instance |
|
92 */ |
|
93 static CWsfWlanBearerConnectionMonitor* NewL( |
|
94 MWsfServerCloserAdapter& aServerCloser ); |
|
95 |
|
96 /** |
|
97 * Factory function. |
|
98 * @since S60 5.0 |
|
99 * @param aServerCloser Reference to the server closer object. |
|
100 * Ownership not passed. |
|
101 * @return Class instance |
|
102 */ |
|
103 static CWsfWlanBearerConnectionMonitor* NewLC( |
|
104 MWsfServerCloserAdapter& aServerCloser ); |
|
105 |
|
106 /** |
|
107 * Destructor. |
|
108 */ |
|
109 ~CWsfWlanBearerConnectionMonitor(); |
|
110 |
|
111 private: // Constructors |
|
112 /** |
|
113 * Constructor |
|
114 * @since S60 5.0 |
|
115 * @param aServerCloser Reference to the server closer object. |
|
116 * Ownership not passed. |
|
117 */ |
|
118 CWsfWlanBearerConnectionMonitor( |
|
119 MWsfServerCloserAdapter& aServerCloser ); |
|
120 |
|
121 /** |
|
122 * Second-phase constructor. |
|
123 * @since S60 5.0 |
|
124 */ |
|
125 void ConstructL(); |
|
126 |
|
127 public: // New methods |
|
128 |
|
129 /** |
|
130 * Returns the name of the active wlan connection |
|
131 * @since S60 5.0 |
|
132 * @return Connection name or KNullDesC if not connected |
|
133 */ |
|
134 const TDesC& GetWlanBearerNameL(); |
|
135 |
|
136 /* |
|
137 * Starts monitoring WLAN events through the given observer |
|
138 * @since S60 5.0 |
|
139 * @param aObserver The object to use for monitoring. Ownership |
|
140 * not passed. |
|
141 */ |
|
142 void StartMonitoringL( MWsfWlanMonitorObserver* aObserver ); |
|
143 |
|
144 /* |
|
145 * Stops monitoring WLAN events |
|
146 * @since S60 5.0 |
|
147 */ |
|
148 void StopMonitoring(); |
|
149 |
|
150 /* |
|
151 * Connects to the given IAP |
|
152 * @since S60 5.0 |
|
153 * @return KErrNone on success, error code otherwise |
|
154 */ |
|
155 TInt ConnectBearer( TUint32 aIapId ); |
|
156 |
|
157 /* |
|
158 * Disconnects active connection |
|
159 * @since S60 5.0 |
|
160 * @return ETrue if the was something to disconnect otherwise EFalse |
|
161 */ |
|
162 TBool DisconnectBearer(); |
|
163 |
|
164 /** |
|
165 * Starts to monitor Access Point |
|
166 * @since S60 5.0 |
|
167 * @param aIapId Access point to be monitored |
|
168 */ |
|
169 void MonitorAccessPoint( TUint32 aIapId ); |
|
170 |
|
171 /** |
|
172 * Queries if there is an active WLAN connection. |
|
173 * @since S60 5.0 |
|
174 * @return ETrue if there is an active WLAN connection, |
|
175 * EFalse otherwise. |
|
176 */ |
|
177 TBool IsConnected(); |
|
178 |
|
179 /** |
|
180 * Aborts the currently ongoing connecting process |
|
181 * @since S60 5.0 |
|
182 */ |
|
183 void AbortConnecting(); |
|
184 |
|
185 /** |
|
186 * Controls the auto-disconnect timer in the server |
|
187 * for owned connections |
|
188 * @since S60 5.0 |
|
189 * @param aAdcCommand Command for the timer, |
|
190 * see TWsfAutoDisconnectCommand |
|
191 * @return ETrue if the timer has been started (also if it had been |
|
192 * started earlier), EFalse if the timer couldn't be started |
|
193 * (e.g. because there is no owned connection). |
|
194 */ |
|
195 TBool ControlDisconnectTimer( TUint aAdcCommand ); |
|
196 |
|
197 |
|
198 private: // From CActive |
|
199 /** |
|
200 * Implements cancellation of an outstanding request. |
|
201 * @since S60 5.0 |
|
202 */ |
|
203 void DoCancel(); |
|
204 |
|
205 /** |
|
206 * Handles an active object's request completion event. |
|
207 * @since S60 5.0 |
|
208 */ |
|
209 void RunL(); |
|
210 |
|
211 /** |
|
212 * Handles a leave occurring in RunL(). |
|
213 * @since S60 5.0 |
|
214 * @param aError Leave code |
|
215 * @return aError |
|
216 */ |
|
217 TInt RunError( TInt aError ); |
|
218 |
|
219 |
|
220 protected: // From MConnectionMonitorObserver |
|
221 |
|
222 /** |
|
223 * Event method is called every time an event occures. |
|
224 * @since S60 5.0 |
|
225 * @param aConnMonEvent The event information. |
|
226 */ |
|
227 void EventL( const CConnMonEventBase& aConnMonEvent ); |
|
228 |
|
229 |
|
230 public: // from MWsfWlanConnectionDetailsProvider |
|
231 |
|
232 /** |
|
233 * Fills TWsfWlanInfo with the connected wlan's properties |
|
234 * @since S60 5.0 |
|
235 * @param aWlanInfo The wlaninfo structure to be filled |
|
236 * @return ETrue if there is a connection and returned data is valid, |
|
237 * EFalse otherwise |
|
238 */ |
|
239 TBool ConnectedWlanConnectionDetailsL( TWsfWlanInfo* aWlanInfo ); |
|
240 |
|
241 |
|
242 private: // New methods |
|
243 |
|
244 /** |
|
245 * Loops through the list of current connections and searches for one |
|
246 * with wlan bearer |
|
247 * @since S60 5.0 |
|
248 */ |
|
249 void FindWlanBearerConnectedL(); |
|
250 |
|
251 /** |
|
252 * Checks connection details and retrieves WLAN connection name |
|
253 * @since S60 5.0 |
|
254 * @param aConnectionId The connection in question |
|
255 * @return ETrue on success (WLAN connection was found), |
|
256 * EFalse otherwise |
|
257 */ |
|
258 TBool CheckConnectionDetailsL( TUint aConnectionId ); |
|
259 |
|
260 /** |
|
261 * Shuts down the owned connection |
|
262 * @since S60 5.0 |
|
263 */ |
|
264 void ShutdownOwnedConnectionL(); |
|
265 |
|
266 /** |
|
267 * Cleanup function to release the shutdown mutex if shutdown leaves |
|
268 * @since S60 5.0 |
|
269 * @param aPtr Pointer for this class |
|
270 */ |
|
271 static void ReleaseShutdownMutex( TAny* aPtr ); |
|
272 |
|
273 /** |
|
274 * Callback for CPeriodic to check the client count and |
|
275 * start inactivity timer if needed. |
|
276 * @since S60 5.0 |
|
277 * @param aPtr Pointer for this class |
|
278 * @return KErrNone if successful, system-wide error code otherwise. |
|
279 */ |
|
280 static TInt CheckClientCount( TAny* aPtr ); |
|
281 |
|
282 /** |
|
283 * Function that does actual processing in checking the client count. |
|
284 * Called by CheckClientCount(). |
|
285 * @since S60 5.0 |
|
286 */ |
|
287 void CheckClientCountL(); |
|
288 |
|
289 |
|
290 private: // Data |
|
291 |
|
292 /** |
|
293 * Reference to the observer of this class (not owned) |
|
294 */ |
|
295 MWsfWlanMonitorObserver* iObserver; |
|
296 |
|
297 /** |
|
298 * Handle to the connection monitor |
|
299 */ |
|
300 RConnectionMonitor iMonitor; |
|
301 |
|
302 /** |
|
303 * Name of the currently active WLAN connection |
|
304 */ |
|
305 TBuf<KWlanMaxAccessPointNameLength> iWlanNetworkName; |
|
306 |
|
307 /** |
|
308 * Id of the currently active WLAN connection |
|
309 */ |
|
310 TInt iConnectionId; |
|
311 |
|
312 /** |
|
313 * Indicates whether connection monitoring is on |
|
314 */ |
|
315 TBool iMonitoring; |
|
316 |
|
317 /** |
|
318 * The access point to be monitored |
|
319 */ |
|
320 TUint32 iMonitoredAp; |
|
321 |
|
322 /** |
|
323 * Handle to the socket server for making a connection |
|
324 */ |
|
325 RSocketServ iSocketServ; |
|
326 |
|
327 /** |
|
328 * Handle to the owned connection |
|
329 */ |
|
330 RConnection iConnection; |
|
331 |
|
332 /** |
|
333 * Indicates whether the connection was initiated from within Sniffer |
|
334 */ |
|
335 TBool iConnectionOwned; |
|
336 |
|
337 /** |
|
338 * Default connection settings before creating an own connection |
|
339 */ |
|
340 TCmDefConnValue iOriginalDefConn; |
|
341 |
|
342 /** |
|
343 * Default connection settings after the owned connection has been |
|
344 * established |
|
345 */ |
|
346 TCmDefConnValue iCurrentDefConn; |
|
347 |
|
348 /** |
|
349 * Periodic polling for connection client count |
|
350 */ |
|
351 CPeriodic* iClientPoll; |
|
352 |
|
353 /** |
|
354 * Indicates whether timer-based auto-disconnect is enabled |
|
355 */ |
|
356 TBool iAutoDisconnect; |
|
357 |
|
358 /** |
|
359 * Count of clients using the connection |
|
360 */ |
|
361 TInt iClientCount; |
|
362 |
|
363 /** |
|
364 * Timer to measure time elapsed without activity |
|
365 */ |
|
366 TTime iInactivityStart; |
|
367 |
|
368 /** |
|
369 * Status of currently ongoing connecting process |
|
370 */ |
|
371 TWsfConnectingState iConnectingState; |
|
372 |
|
373 /** |
|
374 * IAP id to connect to. Used by the connecting active object. |
|
375 */ |
|
376 TUint32 iConnIap; |
|
377 |
|
378 /** |
|
379 * Indicates whether the connection is being aborted |
|
380 */ |
|
381 TBool iAborting; |
|
382 |
|
383 /** |
|
384 * Asserts that the shutdown process is not reentered |
|
385 */ |
|
386 TBool iShutdownMutex; |
|
387 |
|
388 /** |
|
389 * Asserts that the client counting process is not reentered |
|
390 */ |
|
391 TBool iClientCountMutex; |
|
392 |
|
393 /** |
|
394 * Handle to the CmManager |
|
395 */ |
|
396 RCmManagerExt iCmMgr; |
|
397 |
|
398 /** |
|
399 * Reference to the server closer (not owned) |
|
400 */ |
|
401 MWsfServerCloserAdapter& iServerCloser; |
|
402 |
|
403 }; |
|
404 |
|
405 |
|
406 #endif // C_WSFWLANBEARERCONNECTIONMONITOR_H |
|
407 |
|