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: Implementation of CWsfEngine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // EXTERNAL INCLUDES |
|
21 #include <commsdattypesv1_1.h> |
|
22 #include <commsdat.h> |
|
23 #include <cmconnectionmethodext.h> |
|
24 #include <cmpluginwlandef.h> |
|
25 |
|
26 // CLASS HEADER |
|
27 #include "wsfengine.h" |
|
28 |
|
29 |
|
30 // INTERNAL INCLUDES |
|
31 #include "wsfwlanscanner.h" |
|
32 #include "wsfwlansettingsaccessor.h" |
|
33 #include "wsfwlanbearerconnectionmonitor.h" |
|
34 #include "wsfengineobserver.h" |
|
35 #include "wsfservercloseradapter.h" |
|
36 #include "wsfactivewaiter.h" |
|
37 |
|
38 #include "wsflogger.h" |
|
39 |
|
40 |
|
41 |
|
42 // LOCAL DEFINITIONS |
|
43 using namespace CommsDat; |
|
44 |
|
45 |
|
46 /** |
|
47 * Maximum number of retries when trying to delete a temporary IAP but |
|
48 * the connection is locking it |
|
49 */ |
|
50 static const TInt KMaxIapDeletionRetries = 10; |
|
51 |
|
52 |
|
53 /** |
|
54 * Time to wait betweed two IAP deletion retries, in microseconds |
|
55 */ |
|
56 static const TUint KDelayBetweenDeletionRetries = 500 * 1000; |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 // CONSTRUCTION AND DESTRUCTION |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CWsfEngine::NewL |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 CWsfEngine* CWsfEngine::NewL( MWsfServerCloserAdapter& aServerCloser ) |
|
69 { |
|
70 CWsfEngine* self = CWsfEngine::NewLC( aServerCloser ); |
|
71 CleanupStack::Pop( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // CWsfEngine::NewLC |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 CWsfEngine* CWsfEngine::NewLC( MWsfServerCloserAdapter& aServerCloser ) |
|
81 { |
|
82 CWsfEngine* self = new ( ELeave ) CWsfEngine( aServerCloser ); |
|
83 CleanupStack::PushL( self ); |
|
84 self->ConstructL(); |
|
85 return self; |
|
86 } |
|
87 |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CWsfEngine::~CWsfEngine |
|
91 // ---------------------------------------------------------------------------- |
|
92 // |
|
93 CWsfEngine::~CWsfEngine() |
|
94 { |
|
95 LOG_ENTERFN( "CWsfEngine::~CWsfEngine" ); |
|
96 |
|
97 delete iWlanBearerMonitor; |
|
98 delete iScanner; |
|
99 delete iDbSession; |
|
100 iObservers.Reset(); |
|
101 |
|
102 if ( iMonitoredIap && |
|
103 ( iIapPersistence == EIapExpireOnDisconnect || |
|
104 iIapPersistence == EIapNestedExpireOnDisconnect || |
|
105 iIapPersistence == EIapExpireOnBrowserExit || |
|
106 iIapPersistence == EIapExpireOnShutdown ) ) |
|
107 { |
|
108 TRAP_IGNORE( DeleteIapL( iMonitoredIap ) ); |
|
109 } |
|
110 } |
|
111 |
|
112 |
|
113 // ---------------------------------------------------------------------------- |
|
114 // CWsfEngine::CWsfEngine |
|
115 // ---------------------------------------------------------------------------- |
|
116 // |
|
117 CWsfEngine::CWsfEngine( MWsfServerCloserAdapter& aServerCloser ): |
|
118 iServerCloser( aServerCloser ), |
|
119 iEnableScanning( 0 ), |
|
120 iIapPersistence( EIapDeleted ) |
|
121 { |
|
122 } |
|
123 |
|
124 |
|
125 // ---------------------------------------------------------------------------- |
|
126 // CWsfEngine::ConstructL |
|
127 // ---------------------------------------------------------------------------- |
|
128 // |
|
129 void CWsfEngine::ConstructL() |
|
130 { |
|
131 LOG_CREATE; |
|
132 LOG_ENTERFN( "CWsfEngine::ConstructL" ); |
|
133 iDbSession = CMDBSession::NewL( CMDBSession::LatestVersion() ); |
|
134 iScanner = CWsfWlanScanner::NewL( *iDbSession ); |
|
135 |
|
136 iScanner->SetObserver( *this ); |
|
137 |
|
138 iWlanBearerMonitor = CWsfWlanBearerConnectionMonitor::NewL( iServerCloser ); |
|
139 iScanner->SetConnectionDetailProvider( *iWlanBearerMonitor ); |
|
140 |
|
141 iWlanBearerMonitor->StartMonitoringL( this ); |
|
142 |
|
143 if ( iWlanBearerMonitor->GetWlanBearerNameL() != KNullDesC() ) |
|
144 { |
|
145 HBufC* name = ConnectedWlanSsidL(); |
|
146 CleanupStack::PushL( name ); |
|
147 iScanner->ConnectionEstablishedL( *name ); |
|
148 CleanupStack::PopAndDestroy( name ); |
|
149 } |
|
150 } |
|
151 |
|
152 |
|
153 // ---------------------------------------------------------------------------- |
|
154 // CWsfEngine::AttachL |
|
155 // ---------------------------------------------------------------------------- |
|
156 // |
|
157 void CWsfEngine::AttachL( MWsfEngineObserver* aObserver ) |
|
158 { |
|
159 LOG_ENTERFN( "CWsfEngine::AttachL" ); |
|
160 |
|
161 iObservers.AppendL( aObserver ); |
|
162 } |
|
163 |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CWsfEngine::Detach |
|
167 // ---------------------------------------------------------------------------- |
|
168 // |
|
169 void CWsfEngine::Detach( MWsfEngineObserver* aObserver ) |
|
170 { |
|
171 LOG_ENTERFN( "CWsfEngine::Detach" ); |
|
172 TInt index = iObservers.Find( aObserver ); |
|
173 if ( index != KErrNotFound ) |
|
174 { |
|
175 iObservers.Remove( index ); |
|
176 } |
|
177 } |
|
178 |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CWsfEngine::GetScanResults |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 HBufC8* CWsfEngine::GetScanResults() |
|
185 { |
|
186 LOG_ENTERFN( "CWsfEngine::GetScanResults" ); |
|
187 return iScanner->ScanResults(); |
|
188 } |
|
189 |
|
190 |
|
191 // ---------------------------------------------------------------------------- |
|
192 // CWsfEngine::EnableScanningL |
|
193 // ---------------------------------------------------------------------------- |
|
194 // |
|
195 void CWsfEngine::EnableScanningL() |
|
196 { |
|
197 LOG_ENTERFN( "CWsfEngine::EnableScanningL" ); |
|
198 |
|
199 iEnableScanning++; |
|
200 LOG_WRITEF( "++iEnableScanning = %d", iEnableScanning ); |
|
201 |
|
202 if ( iEnableScanning == 1 ) |
|
203 { |
|
204 LOG_WRITE( "CWsfEngine::EnableScanningL - start scanner" ); |
|
205 if ( !iScanner->IsActive() ) |
|
206 { |
|
207 iScanner->StartScanningL(); |
|
208 } |
|
209 LOG_WRITE( "CWsfEngine::EnableScanningL start scanner done" ); |
|
210 for ( TInt i( 0 ); i< iObservers.Count(); ++i ) |
|
211 { |
|
212 (iObservers[i])->ScanEnabledL(); |
|
213 } |
|
214 } |
|
215 else |
|
216 { |
|
217 // the scanning is already active - stop and reactivate to complete the |
|
218 // new monitor in sensible time |
|
219 if ( iScanner->IsActive() ) |
|
220 { |
|
221 iScanner->StopScanning(); |
|
222 } |
|
223 iScanner->StartScanningL(); |
|
224 } |
|
225 } |
|
226 |
|
227 |
|
228 // ---------------------------------------------------------------------------- |
|
229 // CWsfEngine::IsScanning |
|
230 // ---------------------------------------------------------------------------- |
|
231 // |
|
232 TBool CWsfEngine::IsScanning() |
|
233 { |
|
234 return iEnableScanning; |
|
235 } |
|
236 |
|
237 |
|
238 // ---------------------------------------------------------------------------- |
|
239 // CWsfEngine::RefreshScanResults |
|
240 // ---------------------------------------------------------------------------- |
|
241 // |
|
242 TBool CWsfEngine::RefreshScanResults() |
|
243 { |
|
244 LOG_ENTERFN( "CWsfEngine::RefreshScanResults" ); |
|
245 return iScanner->RestartScanning(); |
|
246 } |
|
247 |
|
248 |
|
249 // ---------------------------------------------------------------------------- |
|
250 // CWsfEngine::MonitorAccessPointL |
|
251 // ---------------------------------------------------------------------------- |
|
252 // |
|
253 void CWsfEngine::MonitorAccessPointL( TUint32 aIapId ) |
|
254 { |
|
255 LOG_ENTERFN( "CWsfEngine::MonitorAccessPointL" ); |
|
256 |
|
257 iMonitoredIap = aIapId; |
|
258 |
|
259 if ( iIapPersistence == EIapExpireOnShutdown ) |
|
260 { |
|
261 // web browsing with a temporary IAP |
|
262 LOG_WRITE( "EIapExpireOnShutdown => EIapExpireOnBrowserExit" ); |
|
263 SetIapPersistenceL( EIapExpireOnBrowserExit ); |
|
264 iServerCloser.WaitForBrowserExit( ETrue ); |
|
265 |
|
266 // semaphore to keep the order of calls |
|
267 iSuppressIapDeletion = ETrue; |
|
268 } |
|
269 else if ( iIapPersistence == EIapExpireOnDisconnect ) |
|
270 { |
|
271 LOG_WRITE( "EIapExpireOnDisconnect => EIapNestedExpireOnDisconnect" ); |
|
272 SetIapPersistenceL( EIapNestedExpireOnDisconnect ); |
|
273 } |
|
274 |
|
275 |
|
276 LOG_WRITEF( "iMonitoredIap = %d", iMonitoredIap ); |
|
277 } |
|
278 |
|
279 |
|
280 // ---------------------------------------------------------------------------- |
|
281 // CWsfEngine::DisableScanningL |
|
282 // ---------------------------------------------------------------------------- |
|
283 // |
|
284 void CWsfEngine::DisableScanningL() |
|
285 { |
|
286 LOG_ENTERFN( "CWsfEngine::DisableScanningL" ); |
|
287 |
|
288 iEnableScanning--; |
|
289 LOG_WRITEF( "--iEnableScanning = %d", iEnableScanning ); |
|
290 |
|
291 if ( !iEnableScanning ) |
|
292 { |
|
293 LOG_WRITE( "CWsfEngine::DisableScanning stop scanner" ); |
|
294 |
|
295 iScanner->StopScanning(); |
|
296 LOG_WRITE( "CWsfEngine::DisableScanning stopped scanner" ); |
|
297 |
|
298 for ( TInt i( 0 ); i < iObservers.Count(); ++i ) |
|
299 { |
|
300 (iObservers[i])->ScanDisabledL(); |
|
301 } |
|
302 } |
|
303 } |
|
304 |
|
305 |
|
306 // ---------------------------------------------------------------------------- |
|
307 // CWsfEngine::ConnectedWlanSsidL |
|
308 // ---------------------------------------------------------------------------- |
|
309 // |
|
310 HBufC* CWsfEngine::ConnectedWlanSsidL() |
|
311 { |
|
312 LOG_ENTERFN( "CWsfEngine::ConnectedWlanIapNameL" ); |
|
313 return iWlanBearerMonitor->GetWlanBearerNameL().AllocL(); |
|
314 } |
|
315 |
|
316 |
|
317 // ---------------------------------------------------------------------------- |
|
318 // CWsfEngine::ConnectedWlanConnectionDetailsL |
|
319 // ---------------------------------------------------------------------------- |
|
320 // |
|
321 TBool CWsfEngine::ConnectedWlanConnectionDetailsL( TWsfWlanInfo& aWlanInfo ) |
|
322 { |
|
323 LOG_ENTERFN( "CWsfEngine::ConnectedWlanConnectionDetailsL" ); |
|
324 return iWlanBearerMonitor->ConnectedWlanConnectionDetailsL( &aWlanInfo ); |
|
325 } |
|
326 |
|
327 |
|
328 // ---------------------------------------------------------------------------- |
|
329 // CWsfEngine::WlanScanCompleteL |
|
330 // ---------------------------------------------------------------------------- |
|
331 // |
|
332 void CWsfEngine::WlanScanCompleteL() |
|
333 { |
|
334 LOG_ENTERFN( "CWsfEngine::WlanScanCompleteL" ); |
|
335 |
|
336 for ( TInt i( 0 ); i < iObservers.Count(); ++i ) |
|
337 { |
|
338 (iObservers[i])->WlanListChangedL(); |
|
339 } |
|
340 } |
|
341 |
|
342 |
|
343 // ---------------------------------------------------------------------------- |
|
344 // CWsfEngine::WlanScanStarted |
|
345 // ---------------------------------------------------------------------------- |
|
346 // |
|
347 void CWsfEngine::WlanScanStarted() |
|
348 { |
|
349 LOG_ENTERFN( "CWsfEngine::WlanScanStarted" ); |
|
350 } |
|
351 |
|
352 |
|
353 // ---------------------------------------------------------------------------- |
|
354 // CWsfEngine::NotifyError |
|
355 // ---------------------------------------------------------------------------- |
|
356 // |
|
357 void CWsfEngine::NotifyError( TInt aError ) |
|
358 { |
|
359 LOG_ENTERFN( "CWsfEngine::NotifyError" ); |
|
360 |
|
361 for ( TInt i( 0 ); i < iObservers.Count(); ++i ) |
|
362 { |
|
363 TRAP_IGNORE( (iObservers)[i]->NotifyErrorL( aError ) ); |
|
364 } |
|
365 } |
|
366 |
|
367 |
|
368 // ---------------------------------------------------------------------------- |
|
369 // CWsfEngine::ConnectionEstablishedL |
|
370 // ---------------------------------------------------------------------------- |
|
371 // |
|
372 void CWsfEngine::ConnectionEstablishedL( const TDesC& aConnectionName ) |
|
373 { |
|
374 LOG_ENTERFN( "CWsfEngine::ConnectionEstablishedL" ); |
|
375 // set the scanner to check connected accounts |
|
376 iScanner->ConnectionEstablishedL( aConnectionName ); |
|
377 |
|
378 iScanner->RestartScanning(); |
|
379 |
|
380 // notify the observers |
|
381 for ( TInt i( 0 ); i < iObservers.Count(); ++i ) |
|
382 { |
|
383 (iObservers)[i]->ConnectedL(); |
|
384 } |
|
385 } |
|
386 |
|
387 |
|
388 // ---------------------------------------------------------------------------- |
|
389 // CWsfEngine::ConnectionLostL |
|
390 // ---------------------------------------------------------------------------- |
|
391 // |
|
392 void CWsfEngine::ConnectionLostL() |
|
393 { |
|
394 LOG_ENTERFN( "CWsfEngine::ConnectionLostL" ); |
|
395 |
|
396 // check temporarity here as well since it is not guaranteed that |
|
397 // the connection was owned and ConnectedIapReleasedL was called |
|
398 if ( iSuppressIapDeletion ) |
|
399 { |
|
400 // web browsing with a temporary IAP |
|
401 LOG_WRITE( "IAP deletion suppressed" ); |
|
402 iSuppressIapDeletion = EFalse; |
|
403 } |
|
404 else if ( iMonitoredIap ) |
|
405 { |
|
406 if ( iIapPersistence == EIapExpireOnDisconnect || |
|
407 iIapPersistence == EIapExpireOnBrowserExit ) |
|
408 { |
|
409 DeleteIapL( iMonitoredIap ); |
|
410 iIapPersistence = EIapDeleted; |
|
411 iMonitoredIap = 0; |
|
412 } |
|
413 else if ( iIapPersistence == EIapNestedExpireOnDisconnect ) |
|
414 { |
|
415 iIapPersistence = EIapExpireOnBrowserExit; |
|
416 } |
|
417 } |
|
418 |
|
419 iScanner->ConnectionLostL(); |
|
420 iScanner->RestartScanning(); |
|
421 |
|
422 // notify the observers |
|
423 for ( TInt i( 0 ); i < iObservers.Count(); ++i ) |
|
424 { |
|
425 (iObservers)[i]->DisconnectedL(); |
|
426 } |
|
427 } |
|
428 |
|
429 |
|
430 // ---------------------------------------------------------------------------- |
|
431 // CWsfEngine::ConnectingFailedL |
|
432 // ---------------------------------------------------------------------------- |
|
433 // |
|
434 void CWsfEngine::ConnectingFailedL( TInt aError ) |
|
435 { |
|
436 LOG_ENTERFN( "CWsfEngine::ConnectingFailedL" ); |
|
437 |
|
438 for ( TInt i( 0 ); i < iObservers.Count(); ++i ) |
|
439 { |
|
440 (iObservers)[i]->ConnectingFailedL( aError ); |
|
441 } |
|
442 } |
|
443 |
|
444 |
|
445 // ---------------------------------------------------------------------------- |
|
446 // CWsfEngine::ConnectedIapReleasedL |
|
447 // ---------------------------------------------------------------------------- |
|
448 // |
|
449 void CWsfEngine::ConnectedIapReleasedL() |
|
450 { |
|
451 LOG_ENTERFN( "CWsfEngine::ConnectedIapReleasedL" ); |
|
452 |
|
453 // deleting temporary IAP if necessary |
|
454 if ( !iSuppressIapDeletion && iMonitoredIap ) |
|
455 { |
|
456 if ( iIapPersistence == EIapExpireOnDisconnect || |
|
457 iIapPersistence == EIapExpireOnBrowserExit ) |
|
458 { |
|
459 DeleteIapL( iMonitoredIap ); |
|
460 iIapPersistence = EIapDeleted; |
|
461 iMonitoredIap = 0; |
|
462 } |
|
463 else if ( iIapPersistence == EIapNestedExpireOnDisconnect ) |
|
464 { |
|
465 iIapPersistence = EIapExpireOnBrowserExit; |
|
466 iSuppressIapDeletion = ETrue; |
|
467 } |
|
468 } |
|
469 } |
|
470 |
|
471 |
|
472 // ---------------------------------------------------------------------------- |
|
473 // CWsfEngine::DeleteIapL |
|
474 // ---------------------------------------------------------------------------- |
|
475 // |
|
476 void CWsfEngine::DeleteIapL( TUint32 aIapId ) |
|
477 { |
|
478 LOG_ENTERFN( "CWsfEngine::DeleteIapL" ); |
|
479 |
|
480 LOG_WRITEF( "deleting temporary IAP id = %d", aIapId ); |
|
481 RCmManagerExt cmMgr; |
|
482 cmMgr.OpenLC(); |
|
483 |
|
484 RArray<TUint32> cmIds; |
|
485 CleanupClosePushL( cmIds ); |
|
486 cmMgr.ConnectionMethodL( cmIds, ETrue, ETrue, EFalse ); |
|
487 TBool foundFromUncategorized = EFalse; |
|
488 |
|
489 for ( TInt k = 0; k < cmIds.Count(); k++ ) |
|
490 { |
|
491 RCmConnectionMethodExt cm; |
|
492 TRAPD( error, cm = cmMgr.ConnectionMethodL( cmIds[k] ) ); |
|
493 if ( KErrNone == error ) |
|
494 { |
|
495 CleanupClosePushL( cm ); |
|
496 |
|
497 TUint iapId = cm.GetIntAttributeL( CMManager::ECmIapId ); |
|
498 if ( iapId == aIapId ) |
|
499 { |
|
500 LOG_WRITE( "IAP is uncategorized" ); |
|
501 foundFromUncategorized = ETrue; |
|
502 } |
|
503 CleanupStack::PopAndDestroy( &cm ); |
|
504 } |
|
505 } |
|
506 |
|
507 CleanupStack::PopAndDestroy( &cmIds ); |
|
508 |
|
509 if ( !foundFromUncategorized ) |
|
510 { |
|
511 LOG_WRITE( "Not deleting IAP since it is in SNAP" ); |
|
512 CleanupStack::PopAndDestroy( &cmMgr ); |
|
513 return; |
|
514 } |
|
515 |
|
516 RCmConnectionMethodExt ictCm = cmMgr.ConnectionMethodL( aIapId ); |
|
517 CleanupClosePushL( ictCm ); |
|
518 |
|
519 CWsfActiveWaiter* waiter = CWsfActiveWaiter::NewLC(); |
|
520 |
|
521 RTimer timer; |
|
522 timer.CreateLocal(); |
|
523 |
|
524 // trying to delete the temporary IAP |
|
525 // sometimes the RConnection is still locking the IAP when |
|
526 // we want to delete it, so we might have to try a couple of times |
|
527 TInt counter( KMaxIapDeletionRetries ); |
|
528 TInt err( KErrNone ); |
|
529 |
|
530 while ( counter ) |
|
531 { |
|
532 LOG_WRITEF( "trying to delete (#%d)", |
|
533 KMaxIapDeletionRetries - counter ); |
|
534 |
|
535 TRAP( err, ictCm.DeleteL() ); |
|
536 |
|
537 if ( !err || err == KErrNotFound ) |
|
538 { |
|
539 // if success or the IAP was not found (strange but happens), break |
|
540 break; |
|
541 } |
|
542 |
|
543 --counter; |
|
544 if ( err && counter ) |
|
545 { |
|
546 LOG_WRITEF( "deletion failed with error = %d", err ); |
|
547 LOG_WRITE( "RConnection is still locking the IAP, waiting..." ); |
|
548 |
|
549 timer.After( waiter->iStatus, TTimeIntervalMicroSeconds32( |
|
550 KDelayBetweenDeletionRetries ) ); |
|
551 waiter->WaitForRequest(); |
|
552 } |
|
553 } |
|
554 |
|
555 |
|
556 timer.Close(); |
|
557 CleanupStack::PopAndDestroy( waiter ); |
|
558 |
|
559 if ( !err ) |
|
560 { |
|
561 LOG_WRITE( "IAP deleted." ); |
|
562 } |
|
563 else |
|
564 { |
|
565 LOG_WRITE( "IAP couldn't be deleted!" ); |
|
566 } |
|
567 |
|
568 CleanupStack::PopAndDestroy( &ictCm ); |
|
569 CleanupStack::PopAndDestroy( &cmMgr ); |
|
570 } |
|
571 |
|
572 |
|
573 // ---------------------------------------------------------------------------- |
|
574 // CWsfEngine::ConnectWlanL |
|
575 // ---------------------------------------------------------------------------- |
|
576 // |
|
577 TInt CWsfEngine::ConnectWlanL( TUint32 aIapId, |
|
578 TBool aConnectOnly, |
|
579 TWsfIapPersistence aPersistence ) |
|
580 { |
|
581 LOG_ENTERFN( "CWsfEngine::ConnectWlanL" ); |
|
582 LOG_WRITEF( "iapId = %d, persistence = %d", aIapId, aPersistence ); |
|
583 |
|
584 // if we have already been monitoring an IAP (different from the |
|
585 // new one), clean that one up properly |
|
586 if ( iMonitoredIap && iIapPersistence == EIapExpireOnBrowserExit ) |
|
587 { |
|
588 // user switched back from browser to sniffer and issued connect |
|
589 if ( iMonitoredIap != aIapId ) |
|
590 { |
|
591 // selected network is different, so we must clean up the old one |
|
592 DeleteIapL( iMonitoredIap ); |
|
593 iIapPersistence = EIapDeleted; |
|
594 iMonitoredIap = 0; |
|
595 } |
|
596 else if ( iMonitoredIap == aIapId ) |
|
597 { |
|
598 // selected networks are the same |
|
599 aPersistence = EIapNestedExpireOnDisconnect; |
|
600 } |
|
601 iSuppressIapDeletion = EFalse; |
|
602 } |
|
603 |
|
604 TInt ret = iWlanBearerMonitor->ConnectBearer( aIapId, |
|
605 aConnectOnly, |
|
606 aPersistence != EIapPersistent ); |
|
607 |
|
608 if ( !ret ) |
|
609 { |
|
610 // successfully initiated connection |
|
611 LOG_WRITE( "connection init succeded" ); |
|
612 iMonitoredIap = aIapId; |
|
613 SetIapPersistenceL( aPersistence ); |
|
614 } |
|
615 |
|
616 return ret; |
|
617 } |
|
618 |
|
619 |
|
620 // ---------------------------------------------------------------------------- |
|
621 // CWsfEngine::DisconnectWlan |
|
622 // ---------------------------------------------------------------------------- |
|
623 // |
|
624 TBool CWsfEngine::DisconnectWlan() |
|
625 { |
|
626 LOG_ENTERFN( "CWsfEngine::DisconnectWlan" ); |
|
627 return iWlanBearerMonitor->DisconnectBearer(); |
|
628 } |
|
629 |
|
630 |
|
631 // ---------------------------------------------------------------------------- |
|
632 // CWsfEngine::IsConnected |
|
633 // ---------------------------------------------------------------------------- |
|
634 // |
|
635 TBool CWsfEngine::IsConnected() |
|
636 { |
|
637 return iWlanBearerMonitor->IsConnected(); |
|
638 } |
|
639 |
|
640 |
|
641 // --------------------------------------------------------------------------- |
|
642 // CWsfEngine::AbortConnectingL |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 void CWsfEngine::AbortConnectingL() |
|
646 { |
|
647 LOG_ENTERFN("CWsfEngine::AbortConnectingL"); |
|
648 |
|
649 TInt result = iWlanBearerMonitor->AbortConnecting(); |
|
650 |
|
651 LOG_WRITEF( "abort connection result = %d", result ); |
|
652 |
|
653 if ( result == KErrNone && iMonitoredIap ) |
|
654 { |
|
655 if ( iIapPersistence == EIapExpireOnDisconnect ) |
|
656 { |
|
657 LOG_WRITE( "EIapNestedExpireOnDisconnect => EIapDeleted" ); |
|
658 DeleteIapL( iMonitoredIap ); |
|
659 iIapPersistence = EIapDeleted; |
|
660 iMonitoredIap = 0; |
|
661 } |
|
662 else if ( iIapPersistence == EIapNestedExpireOnDisconnect ) |
|
663 { |
|
664 LOG_WRITE( "EIapNestedExpireOnDisconnect => " |
|
665 L"EIapExpireOnBrowserExit" ); |
|
666 iIapPersistence = EIapExpireOnBrowserExit; |
|
667 } |
|
668 } |
|
669 else if ( result != KErrNone ) |
|
670 { |
|
671 LOG_WRITE( "abort connection did not stopped connection" ); |
|
672 // Try to disconnect via normal disconnect if engine is |
|
673 // connected and and there is connection id |
|
674 DisconnectWlan(); |
|
675 } |
|
676 } |
|
677 |
|
678 |
|
679 // --------------------------------------------------------------------------- |
|
680 // CWsfEngine::AbortScanning |
|
681 // --------------------------------------------------------------------------- |
|
682 // |
|
683 void CWsfEngine::AbortScanning() |
|
684 { |
|
685 LOG_ENTERFN("CWsfEngine::AbortScanning"); |
|
686 |
|
687 iScanner->AbortScanning(); |
|
688 } |
|
689 |
|
690 |
|
691 // --------------------------------------------------------------------------- |
|
692 // CWsfEngine::SetIapPersistenceL |
|
693 // --------------------------------------------------------------------------- |
|
694 // |
|
695 TBool CWsfEngine::SetIapPersistenceL( TWsfIapPersistence aPersistence ) |
|
696 { |
|
697 LOG_ENTERFN("CWsfEngine::SetIapPersistenceL"); |
|
698 if ( aPersistence == EIapForcedExpiry ) |
|
699 { |
|
700 if ( iMonitoredIap && |
|
701 ( iIapPersistence == EIapExpireOnBrowserExit || |
|
702 iIapPersistence == EIapExpireOnShutdown ) ) |
|
703 { |
|
704 LOG_WRITE( "forced IAP expiry" ); |
|
705 DeleteIapL( iMonitoredIap ); |
|
706 iIapPersistence = EIapDeleted; |
|
707 iMonitoredIap = 0; |
|
708 } |
|
709 else if ( iIapPersistence == EIapNestedExpireOnDisconnect ) |
|
710 { |
|
711 LOG_WRITE( "reverting to EIapExpireOnDisconnect" ); |
|
712 iIapPersistence = EIapExpireOnDisconnect; |
|
713 } |
|
714 |
|
715 iServerCloser.WaitForBrowserExit( EFalse ); |
|
716 } |
|
717 else |
|
718 { |
|
719 LOG_WRITEF( "persistence = %d", aPersistence ); |
|
720 iIapPersistence = aPersistence; |
|
721 } |
|
722 |
|
723 return ( iMonitoredIap ); |
|
724 } |
|
725 |
|
726 |
|
727 // --------------------------------------------------------------------------- |
|
728 // CWsfEngine::ControlDisconnectTimer |
|
729 // --------------------------------------------------------------------------- |
|
730 // |
|
731 TBool CWsfEngine::ControlDisconnectTimer( TUint aAdcCommand ) |
|
732 { |
|
733 LOG_ENTERFN("CWsfEngine::ControlDisconnectTimer"); |
|
734 |
|
735 return iWlanBearerMonitor->ControlDisconnectTimer( aAdcCommand ); |
|
736 } |
|
737 |
|
738 // --------------------------------------------------------------------------- |
|
739 // CWsfEngine::ResetSuppressIapDeletion |
|
740 // --------------------------------------------------------------------------- |
|
741 // |
|
742 void CWsfEngine::ResetSuppressIapDeletion() |
|
743 { |
|
744 LOG_ENTERFN( "CWsfEngine::ResetSuppresIapDeletion" ); |
|
745 |
|
746 iSuppressIapDeletion = EFalse; |
|
747 } |
|
748 |
|
749 // End of file |
|