32 #include "mpmserversession.h" |
32 #include "mpmserversession.h" |
33 #include "mpmconnmonevents.h" |
33 #include "mpmconnmonevents.h" |
34 #include "mpmlogger.h" |
34 #include "mpmlogger.h" |
35 #include "mpmdtmwatcher.h" |
35 #include "mpmdtmwatcher.h" |
36 #include "mpmroamingwatcher.h" |
36 #include "mpmroamingwatcher.h" |
37 #include "mpmdisconnectdlg.h" |
|
38 #include "mpmconfirmdlgroaming.h" |
37 #include "mpmconfirmdlgroaming.h" |
39 #include "mpmconfirmdlgstarting.h" |
38 #include "mpmconfirmdlgstarting.h" |
40 #include "mpmdefaultconnection.h" |
|
41 #include "mpmcommsdataccess.h" |
39 #include "mpmcommsdataccess.h" |
42 #include "mpmwlanquerydialog.h" |
|
43 #include "mpmdialog.h" |
|
44 #include "mpmprivatecrkeys.h" |
40 #include "mpmprivatecrkeys.h" |
45 #include "mpmcsidwatcher.h" |
41 #include "mpmcsidwatcher.h" |
|
42 #include "mpmvpntogglewatcher.h" |
46 #include "mpmdatausagewatcher.h" |
43 #include "mpmdatausagewatcher.h" |
47 #include "mpmpropertydef.h" |
44 #include "mpmpropertydef.h" |
48 #include "mpmofflinewatcher.h" |
|
49 #include "mpmconnpermquerytimer.h" |
45 #include "mpmconnpermquerytimer.h" |
50 |
46 |
|
47 static const TUint32 KUidKmdServer = 0x1000088A; |
|
48 |
51 // ============================= LOCAL FUNCTIONS =============================== |
49 // ============================= LOCAL FUNCTIONS =============================== |
52 |
50 |
53 // ----------------------------------------------------------------------------- |
51 // ----------------------------------------------------------------------------- |
54 // PanicServer |
52 // PanicServer |
55 // Panics the server in case of programming error. |
53 // Panics the server in case of programming error. |
85 : CPolicyServer( CPolicyServer::EPriorityStandard, KMPMPolicy ), |
83 : CPolicyServer( CPolicyServer::EPriorityStandard, KMPMPolicy ), |
86 iEvents( NULL ), |
84 iEvents( NULL ), |
87 iTSYLoaded( EFalse ), |
85 iTSYLoaded( EFalse ), |
88 iPacketServLoaded( EFalse ), |
86 iPacketServLoaded( EFalse ), |
89 iDtmWatcher( NULL ), |
87 iDtmWatcher( NULL ), |
|
88 iRoamingWatcher( NULL ), |
90 iWLANScanRequired( EFalse ), |
89 iWLANScanRequired( EFalse ), |
91 iDisconnectQueue( NULL ), |
|
92 iRoamingQueue( NULL ), |
90 iRoamingQueue( NULL ), |
93 iStartingQueue( NULL ), |
91 iStartingQueue( NULL ), |
94 iWlanQueryQueue( NULL ), |
|
95 iConnectDialogQueue( NULL ), |
|
96 iDefaultConnection( NULL ), |
|
97 iConnectionCounter( 0 ), |
92 iConnectionCounter( 0 ), |
98 iOfflineMode( ECoreAppUIsNetworkConnectionAllowed ) |
93 iUserConnection( EFalse ), |
|
94 iUserConnectionInInternet( EFalse ), |
|
95 iVpnUserConnectionSessionCount( 0 ), |
|
96 iMpmCsIdWatcher( NULL ), |
|
97 iMpmVpnToggleWatcher( NULL ), |
|
98 iMpmDataUsageWatcher( NULL ), |
|
99 iCommsDatAccess( NULL ), |
|
100 iConnUiUtils( NULL ), |
|
101 iOfflineMode( ECoreAppUIsNetworkConnectionAllowed ), |
|
102 iOfflineWlanQueryResponse( EOfflineResponseUndefined ), |
|
103 iRoamingToWlanPeriodic( NULL ), |
|
104 iConnPermQueryTimer( NULL ) |
99 { |
105 { |
100 } |
106 } |
101 |
107 |
102 |
108 |
103 // ----------------------------------------------------------------------------- |
109 // ----------------------------------------------------------------------------- |
154 } |
160 } |
155 |
161 |
156 iRoamingWatcher = CMPMRoamingWatcher::NewL(iMobilePhone); |
162 iRoamingWatcher = CMPMRoamingWatcher::NewL(iMobilePhone); |
157 |
163 |
158 iCommsDatAccess = CMPMCommsDatAccess::NewL( ); |
164 iCommsDatAccess = CMPMCommsDatAccess::NewL( ); |
159 |
|
160 iDisconnectQueue = new ( ELeave ) CArrayPtrFlat<CMPMDisconnectDlg>( KGranularity ); |
|
161 iDisconnectQueue->Reset(); |
|
162 |
165 |
163 iRoamingQueue = new ( ELeave ) CArrayPtrFlat<CMPMConfirmDlgRoaming>( KGranularity ); |
166 iRoamingQueue = new ( ELeave ) CArrayPtrFlat<CMPMConfirmDlgRoaming>( KGranularity ); |
164 iRoamingQueue->Reset(); |
167 iRoamingQueue->Reset(); |
165 |
168 |
166 iStartingQueue = new ( ELeave ) CArrayPtrFlat<CMPMConfirmDlgStarting>( KGranularity ); |
169 iStartingQueue = new ( ELeave ) CArrayPtrFlat<CMPMConfirmDlgStarting>( KGranularity ); |
167 iStartingQueue->Reset(); |
170 iStartingQueue->Reset(); |
168 |
|
169 iWlanQueryQueue = new ( ELeave ) CArrayPtrFlat<CMPMWlanQueryDialog>( KGranularity ); |
|
170 iWlanQueryQueue->Reset(); |
|
171 |
|
172 iConnectDialogQueue = new ( ELeave ) CArrayPtrFlat<CMPMDialog>( KGranularity ); |
|
173 iConnectDialogQueue->Reset(); |
|
174 |
|
175 iDefaultConnection = CMPMDefaultConnection::NewL( this ); |
|
176 |
171 |
177 // Create central repository watcher and start it |
172 // Create central repository watcher and start it |
178 iMpmCsIdWatcher = CMpmCsIdWatcher::NewL(); |
173 iMpmCsIdWatcher = CMpmCsIdWatcher::NewL(); |
179 iMpmCsIdWatcher->StartL(); |
174 iMpmCsIdWatcher->StartL(); |
|
175 |
|
176 // Create VPN toggle central repository watcher and start it |
|
177 iMpmVpnToggleWatcher = CMpmVpnToggleWatcher::NewL( *this ); |
180 |
178 |
181 // Create another central repository watcher and start it |
179 // Create another central repository watcher and start it |
182 TRAPD( duwErr, iMpmDataUsageWatcher = CMpmDataUsageWatcher::NewL( this ) ); |
180 TRAPD( duwErr, iMpmDataUsageWatcher = CMpmDataUsageWatcher::NewL( this ) ); |
183 if (duwErr == KErrNone) |
181 if (duwErr == KErrNone) |
184 { |
182 { |
188 { |
186 { |
189 iMpmDataUsageWatcher = NULL; |
187 iMpmDataUsageWatcher = NULL; |
190 MPMLOGSTRING( "CMPMServer::ConstructL: CMpmDataUsageWatcher::NewL() failed!" ) |
188 MPMLOGSTRING( "CMPMServer::ConstructL: CMpmDataUsageWatcher::NewL() failed!" ) |
191 } |
189 } |
192 |
190 |
193 // Create another central repository watcher and start it |
|
194 TRAPD( owErr, iMpmOfflineWatcher = CMpmOfflineWatcher::NewL( this ) ); |
|
195 if (owErr == KErrNone) |
|
196 { |
|
197 iMpmOfflineWatcher->StartL(); |
|
198 } |
|
199 else |
|
200 { |
|
201 iMpmOfflineWatcher = NULL; |
|
202 MPMLOGSTRING( "CMPMServer::ConstructL: CMpmOfflineWatcher::NewL() failed!" ) |
|
203 } |
|
204 |
|
205 // Define P&S keys (snap & iap) for the user connection |
|
206 TInt ret = RProperty::Define( KMPMUserConnectionCategory, |
|
207 KMPMPSKeyUserConnectionSnap, |
|
208 KMPMUserConnectionSnapType, |
|
209 KMPMUserConnectionReadPolicy, |
|
210 KMPMUserConnectionWritePolicy ); |
|
211 |
|
212 if ( (ret != KErrNone) && (ret != KErrAlreadyExists) ) |
|
213 { |
|
214 User::Leave(err); |
|
215 } |
|
216 |
|
217 ret = RProperty::Define( KMPMUserConnectionCategory, |
|
218 KMPMPSKeyUserConnectionIap, |
|
219 KMPMUserConnectionIapType, |
|
220 KMPMUserConnectionReadPolicy, |
|
221 KMPMUserConnectionWritePolicy ); |
|
222 |
|
223 if ( (ret != KErrNone) && (ret != KErrAlreadyExists) ) |
|
224 { |
|
225 User::Leave(err); |
|
226 } |
|
227 |
|
228 // Set initial values for the keys |
|
229 User::LeaveIfError(RProperty::Set( KMPMUserConnectionCategory, |
|
230 KMPMPSKeyUserConnectionSnap, |
|
231 0 )); |
|
232 |
|
233 User::LeaveIfError(RProperty::Set( KMPMUserConnectionCategory, |
|
234 KMPMPSKeyUserConnectionIap, |
|
235 0 )); |
|
236 |
|
237 // Read dedicated clients from the central repository |
191 // Read dedicated clients from the central repository |
238 CRepository* repository = CRepository::NewL( KCRUidMPM ); |
192 CRepository* repository = CRepository::NewL( KCRUidMPM ); |
239 |
193 |
240 CleanupStack::PushL( repository ); |
194 CleanupStack::PushL( repository ); |
241 |
195 |
242 TUint32 baseKey = KMpmDedicatedClientBase; |
196 TUint32 baseKey = KMpmDedicatedClientBase; |
243 TInt value; |
197 TInt value; |
244 ret = KErrNone; |
198 TInt ret = KErrNone; |
245 |
199 |
246 while ( ret == KErrNone ) |
200 while ( ret == KErrNone ) |
247 { |
201 { |
248 ret = repository->Get ( baseKey, value ); |
202 ret = repository->Get ( baseKey, value ); |
249 |
203 |
255 |
209 |
256 baseKey++; |
210 baseKey++; |
257 } |
211 } |
258 |
212 |
259 CleanupStack::PopAndDestroy ( repository ); |
213 CleanupStack::PopAndDestroy ( repository ); |
260 |
|
261 // Define P&S keys for the connection dialogs |
|
262 ret = RProperty::Define( KMPMActiveConnectionCategory, |
|
263 KMPMPSKeyActiveConnectionIap, |
|
264 KMPMActiveConnectionIapType, |
|
265 KMPMActiveConnectionReadPolicy, |
|
266 KMPMActiveConnectionWritePolicy ); |
|
267 |
|
268 if ( (ret != KErrNone) && (ret != KErrAlreadyExists) ) |
|
269 { |
|
270 User::Leave(err); |
|
271 } |
|
272 |
|
273 ret = RProperty::Define( KMPMActiveConnectionCategory, |
|
274 KMPMPSKeyActiveConnectionSnap, |
|
275 KMPMActiveConnectionSnapType, |
|
276 KMPMActiveConnectionReadPolicy, |
|
277 KMPMActiveConnectionWritePolicy ); |
|
278 |
|
279 if ( (ret != KErrNone) && (ret != KErrAlreadyExists) ) |
|
280 { |
|
281 User::Leave(err); |
|
282 } |
|
283 |
|
284 ret = RProperty::Define( KMPMActiveConnectionCategory, |
|
285 KMPMPSKeyActiveConnectionBearer, |
|
286 KMPMActiveConnectionBearerType, |
|
287 KMPMActiveConnectionReadPolicy, |
|
288 KMPMActiveConnectionWritePolicy ); |
|
289 |
|
290 if ( (ret != KErrNone) && (ret != KErrAlreadyExists) ) |
|
291 { |
|
292 User::Leave(err); |
|
293 } |
|
294 |
214 |
295 PublishActiveConnection(); |
215 iConnUiUtils = CConnectionUiUtilities::NewL(); |
296 |
|
297 iRoamingToWlanPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
298 iRoamingToHotspotWlanPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
299 |
|
300 } |
216 } |
301 |
217 |
302 |
218 |
303 // ----------------------------------------------------------------------------- |
219 // ----------------------------------------------------------------------------- |
304 // CMPMServer::~CMPMServer |
220 // CMPMServer::~CMPMServer |
366 } |
259 } |
367 |
260 |
368 iMobilePhone.Close(); |
261 iMobilePhone.Close(); |
369 iTelServer.Close(); |
262 iTelServer.Close(); |
370 |
263 |
371 delete iDefaultConnection; |
|
372 |
|
373 delete iMpmCsIdWatcher; |
264 delete iMpmCsIdWatcher; |
374 |
265 |
|
266 delete iMpmVpnToggleWatcher; |
|
267 |
375 delete iMpmDataUsageWatcher; |
268 delete iMpmDataUsageWatcher; |
376 |
269 |
377 delete iMpmOfflineWatcher; |
|
378 |
|
379 iDedicatedClients.Close(); |
270 iDedicatedClients.Close(); |
380 |
271 |
381 delete iCommsDatAccess; |
272 delete iCommsDatAccess; |
382 |
273 |
|
274 delete iConnUiUtils; |
|
275 |
383 delete iConnPermQueryTimer; |
276 delete iConnPermQueryTimer; |
384 } |
277 } |
385 |
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CMPMServer::SetVpnToggleValuesL |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CMPMServer::SetVpnToggleValuesL( const TBool aVpnPreferred, |
|
284 const TUint32 /*aVpnIapId*/, |
|
285 const TUint32 /*aSnapId*/ ) |
|
286 { |
|
287 MPMLOGSTRING2("CMPMServer::SetVpnToggleValues, VPN connection preferred: %d", |
|
288 aVpnPreferred) |
|
289 if ( aVpnPreferred ) |
|
290 { |
|
291 // Stop Internet connections, except if VPN user connection |
|
292 // would not be made with current preferences when reconnecting. |
|
293 for (TInt index = 0; index < iSessions.Count(); index++) |
|
294 { |
|
295 CMPMServerSession* session = iSessions[index]; |
|
296 TUint32 iapId = GetBMIap( session->ConnectionId() ); |
|
297 TUint32 snapId = GetBMSnap( session->ConnectionId() ); |
|
298 |
|
299 if ( (session->ChooseBestIapCalled()) && |
|
300 (!session->IapSelectionL()->MpmConnPref().MandateIap()) && |
|
301 (session->AppUid() != KUidKmdServer) && |
|
302 (!session->UserConnection()) && |
|
303 iCommsDatAccess->IsInternetSnapL(iapId, snapId) ) |
|
304 { |
|
305 // Stop connection. |
|
306 MPMLOGSTRING2( "CMPMServer::SetVpnToggleValuesL: \ |
|
307 Disconnected Connection Id = 0x%x", session->ConnectionId() ) |
|
308 session->ClientErrorNotificationL(KErrForceDisconnected); |
|
309 } |
|
310 } |
|
311 } |
|
312 else |
|
313 { |
|
314 // Stop connections, which use VPN user connection. |
|
315 for (TInt index = 0; index < iSessions.Count(); index++) |
|
316 { |
|
317 CMPMServerSession* session = iSessions[index]; |
|
318 if ( session->VpnUserConnectionUsed() ) |
|
319 { |
|
320 session->SetVpnUserConnectionUsed( EFalse ); |
|
321 // Stop connection. |
|
322 MPMLOGSTRING2( "CMPMServer::SetVpnToggleValuesL: \ |
|
323 Disconnected Connection Id = 0x%x", session->ConnectionId() ) |
|
324 session->ClientErrorNotificationL(KErrForceDisconnected); |
|
325 } |
|
326 } |
|
327 ASSERT( iVpnUserConnectionSessionCount == 0 ); |
|
328 } |
|
329 } |
386 |
330 |
387 // ----------------------------------------------------------------------------- |
331 // ----------------------------------------------------------------------------- |
388 // CMPMServer::NewSessionL |
332 // CMPMServer::NewSessionL |
389 // ----------------------------------------------------------------------------- |
333 // ----------------------------------------------------------------------------- |
390 // |
334 // |
546 // ----------------------------------------------------------------------------- |
479 // ----------------------------------------------------------------------------- |
547 // CMPMServer::RemoveBMConnection |
480 // CMPMServer::RemoveBMConnection |
548 // ----------------------------------------------------------------------------- |
481 // ----------------------------------------------------------------------------- |
549 // |
482 // |
550 void CMPMServer::RemoveBMConnection( const TConnectionId aConnId, |
483 void CMPMServer::RemoveBMConnection( const TConnectionId aConnId, |
551 CMPMServerSession& aSession ) |
484 CMPMServerSession& /*aSession*/ ) |
552 { |
485 { |
553 MPMLOGSTRING2( "CMPMServer::RemoveBMConnection - aConnId = 0x%x", |
486 MPMLOGSTRING2( "CMPMServer::RemoveBMConnection - aConnId = 0x%x", |
554 aConnId ) |
487 aConnId ) |
555 |
488 |
|
489 TInt count = iActiveBMConns.Count(); |
|
490 |
|
491 // Decrement by one, because count is n, |
|
492 // but indexes in array are 0 .. n-1. |
|
493 // |
|
494 count--; |
|
495 |
556 // This time we are browsing the array from the end to the beginning, |
496 // This time we are browsing the array from the end to the beginning, |
557 // because removing one element from array affects index numbering. |
497 // because removing one element from array affects index numbering. |
558 // Decrement i by one, because count is n, but indexes in array are 0 .. n-1 |
498 // |
559 for ( TInt i = iActiveBMConns.Count() - 1; i >= 0; i-- ) |
499 for ( TInt i = count; i >= 0; i-- ) |
560 { |
500 { |
561 if ( iActiveBMConns[i].iConnInfo.iConnId == aConnId ) |
501 if ( iActiveBMConns[i].iConnInfo.iConnId == aConnId ) |
562 { |
502 { |
563 |
|
564 TInt closeIapId = iActiveBMConns[i].iConnInfo.iIapId; |
|
565 if ( !closeIapId ) |
|
566 { |
|
567 TRAP_IGNORE( closeIapId = aSession.IapSelectionL()->MpmConnPref().IapId() ); |
|
568 } |
|
569 |
|
570 // If Connection Id found, remove it. |
503 // If Connection Id found, remove it. |
|
504 // |
571 iActiveBMConns.Remove( i ); |
505 iActiveBMConns.Remove( i ); |
572 |
506 } |
573 // Update active connection |
507 } |
574 if ( aSession.ChooseBestIapCalled() ) |
508 |
575 { |
|
576 UpdateActiveConnection( aSession ); |
|
577 } |
|
578 |
|
579 CheckIapForDisconnect( closeIapId ); |
|
580 } |
|
581 } |
|
582 |
|
583 #ifdef _DEBUG |
509 #ifdef _DEBUG |
584 // Dump array of active connections to log in order to support testing. |
510 // Dump array of active connections to log in order to support testing. |
585 // |
511 // |
586 DumpActiveBMConns(); |
512 DumpActiveBMConns(); |
587 #endif // _DEBUG |
513 #endif // _DEBUG |
704 } |
632 } |
705 #endif // _DEBUG |
633 #endif // _DEBUG |
706 } |
634 } |
707 |
635 |
708 // ----------------------------------------------------------------------------- |
636 // ----------------------------------------------------------------------------- |
709 // CMPMServer::CheckUsageOfIap |
637 // CMPMServer::CheckIfStarted |
710 // ----------------------------------------------------------------------------- |
638 // ----------------------------------------------------------------------------- |
711 // |
639 // |
712 TConnectionState CMPMServer::CheckUsageOfIap( const TUint32 aIapId , |
640 TBool CMPMServer::CheckIfStarted( const TUint32 aIapId , |
713 const TConnectionId aOwnConnId ) |
641 const TConnectionId aConnId ) |
714 { |
642 { |
715 MPMLOGSTRING3( "CMPMServer::CheckUsageOfIap - aIapId = %i, aOwnConnId = 0x%x", |
643 MPMLOGSTRING3( "CMPMServer::CheckIfStarted - aIapId = %i, aConnId = 0x%x", |
716 aIapId, aOwnConnId ) |
644 aIapId, aConnId ) |
717 |
645 |
718 TConnectionState state = EIdle; |
646 TConnectionState state( EIdle ); |
|
647 TBool stopLoop( EFalse ); |
719 |
648 |
720 // Loop all connections until EStarted is found or no more connections |
649 // Loop all connections until EStarted is found or no more connections |
721 // |
650 // |
722 for ( TInt i = 0; i < iActiveBMConns.Count(); i++ ) |
651 for ( TInt i = 0; ( ( i < iActiveBMConns.Count() ) && !stopLoop ); i++ ) |
723 { |
652 { |
724 // Check if IAP Id matches; exclude matching with own connection |
653 // Check if IAP Id matches; exclude matching with own connection |
725 // |
654 // |
726 if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId && |
655 if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId && |
727 iActiveBMConns[i].iConnInfo.iConnId != aOwnConnId) |
656 iActiveBMConns[i].iConnInfo.iConnId != aConnId) |
728 { |
657 { |
729 state = iActiveBMConns[i].iConnInfo.iState; |
658 state = iActiveBMConns[i].iConnInfo.iState; |
730 |
659 |
731 // Stop looping if EStarted found |
660 // Stop looping if EStarted found |
732 // |
661 // |
733 if ( state == EStarted ) |
662 if ( state == EStarted ) |
734 { |
663 { |
735 break; // Breaks the for loop |
664 stopLoop = ETrue; |
736 } |
665 } |
737 } |
666 } |
738 } |
667 } |
739 |
668 |
740 #ifdef _DEBUG |
669 #ifdef _DEBUG |
741 switch( state ) |
670 switch( state ) |
742 { |
671 { |
743 case EStarting: |
672 case EStarting: |
744 { |
673 { |
745 MPMLOGSTRING( "CMPMServer::CheckUsageOfIap - Starting" ) |
674 MPMLOGSTRING( "CMPMServer::CheckIfStarted - Starting" ) |
746 break; |
675 break; |
747 } |
676 } |
748 case EStarted: |
677 case EStarted: |
749 { |
678 { |
750 MPMLOGSTRING( "CMPMServer::CheckUsageOfIap - Started" ) |
679 MPMLOGSTRING( "CMPMServer::CheckIfStarted - Started" ) |
751 break; |
680 break; |
752 } |
681 } |
753 case EIdle: |
682 case EIdle: |
754 { |
683 { |
755 MPMLOGSTRING( "CMPMServer::CheckUsageOfIap - Idle" ) |
684 MPMLOGSTRING( "CMPMServer::CheckIfStarted - Idle" ) |
756 break; |
685 break; |
757 } |
686 } |
758 case ERoaming: |
687 case ERoaming: |
759 { |
688 { |
760 MPMLOGSTRING( "CMPMServer::CheckUsageOfIap - Roaming" ) |
689 MPMLOGSTRING( "CMPMServer::CheckIfStarted - Roaming" ) |
761 break; |
690 break; |
762 } |
691 } |
763 default: |
692 default: |
764 { |
693 { |
765 MPMLOGSTRING( "CMPMServer::CheckUsageOfIap - Unknown" ) |
694 MPMLOGSTRING( "CMPMServer::CheckIfStarted - Unknown" ) |
766 break; |
695 break; |
767 } |
696 } |
768 } |
697 } |
769 #endif // _DEBUG |
698 #endif // _DEBUG |
770 |
699 |
771 return state; |
700 //Return true incase the matching connection is in EStarting state also because |
|
701 //sometimes when connections are started simultaneously (for same iapID) |
|
702 //the first connection may still be in EStarting state. |
|
703 // |
|
704 if ( state == EStarted || state == EStarting ) |
|
705 { |
|
706 return ETrue; |
|
707 } |
|
708 else |
|
709 { |
|
710 return EFalse; |
|
711 } |
772 } |
712 } |
773 |
713 |
774 // ----------------------------------------------------------------------------- |
714 // ----------------------------------------------------------------------------- |
775 // CMPMServer::IsWlanConnectionStartedL |
715 // CMPMServer::IsWlanConnectionStartedL |
776 // ----------------------------------------------------------------------------- |
716 // ----------------------------------------------------------------------------- |
867 // CMPMServer::RemoveBMIAPConnection |
802 // CMPMServer::RemoveBMIAPConnection |
868 // ----------------------------------------------------------------------------- |
803 // ----------------------------------------------------------------------------- |
869 // |
804 // |
870 void CMPMServer::RemoveBMIAPConnection( const TUint32 aIapId, |
805 void CMPMServer::RemoveBMIAPConnection( const TUint32 aIapId, |
871 const TConnectionId aConnId, |
806 const TConnectionId aConnId, |
872 CMPMServerSession& aSession ) |
807 CMPMServerSession& /*aSession*/ ) |
873 { |
808 { |
874 MPMLOGSTRING3( |
809 MPMLOGSTRING3( |
875 "CMPMServer::RemoveBMIAPConnection - aIapId = %i, aConnId = 0x%x", |
810 "CMPMServer::RemoveBMIAPConnection - aIapId = %i, aConnId = 0x%x", |
876 aIapId, aConnId ) |
811 aIapId, aConnId ) |
877 |
812 |
|
813 TActiveBMConn conn; |
|
814 conn.iConnInfo.iIapId = aIapId; |
|
815 |
878 // The IAP connection lifetime is determined by the two calls |
816 // The IAP connection lifetime is determined by the two calls |
879 // IAPConnectionStarted and IAPConnectionStopped. |
817 // IAPConnectionStarted and IAPConnectionStopped. |
|
818 // |
|
819 TInt count = iActiveBMConns.Count(); |
|
820 |
|
821 // Decrement by one, because count is n, |
|
822 // but indexes in array are 0 .. n-1. |
|
823 // |
|
824 count--; |
880 |
825 |
881 // This time we are browsing the array from the end to the beginning, |
826 // This time we are browsing the array from the end to the beginning, |
882 // because removing one element from array affects index numbering. |
827 // because removing one element from array affects index numbering. |
883 // Decrement i by one, because count is n, but indexes in array are 0 .. n-1 |
828 // |
884 for ( TInt i = iActiveBMConns.Count() - 1; i >= 0; i-- ) |
829 for ( TInt i = count; i >= 0; i-- ) |
885 { |
830 { |
886 if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId ) |
831 if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId ) |
887 { |
832 { |
888 if ( iActiveBMConns[i].iConnInfo.iSnap == 0 ) |
833 if ( iActiveBMConns[i].iConnInfo.iSnap == 0 ) |
889 { |
834 { |
962 const TPrefIAPNotifCaller aCaller ) |
901 const TPrefIAPNotifCaller aCaller ) |
963 { |
902 { |
964 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIapL - IAPs count: %d", |
903 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIapL - IAPs count: %d", |
965 aIapInfo.iCount) |
904 aIapInfo.iCount) |
966 TConnMonIapInfo iapInfo = aIapInfo; |
905 TConnMonIapInfo iapInfo = aIapInfo; |
967 iConnMonIapInfo = aIapInfo; |
906 |
968 #ifdef _DEBUG |
907 #ifdef _DEBUG |
969 for (TUint i = 0; i < iapInfo.Count(); i++) |
908 for (TUint i = 0; i < iapInfo.Count(); i++) |
970 { |
909 { |
971 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIap - IAP: %d", |
910 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIap - IAP: %d", |
972 iapInfo.iIap[i].iIapId) |
911 iapInfo.iIap[i].iIapId) |
973 } |
912 } |
974 #endif // _DEBUG |
913 #endif // _DEBUG |
975 |
914 |
976 // Read info for forced roaming from Commdat |
|
977 TUint32 maxOpenTransAttempts ( KMaxOpenTransAttempts ) ; |
|
978 TUint32 retryAfter ( KRetryAfter ); |
|
979 TInt err; |
|
980 // CommDat reading might fail because CommDat session could be locked by another process at the moment |
|
981 // So, we may wait/retry to read from CommDat a bit later. |
|
982 TCmUsageOfWlan usageOfWlan ( ECmUsageOfWlanKnown ); |
|
983 do |
|
984 { |
|
985 TRAP ( err, usageOfWlan = CommsDatAccess()->ForcedRoamingL() ); |
|
986 |
|
987 if( err ) |
|
988 { |
|
989 User::After( retryAfter ); |
|
990 } |
|
991 } while( err && maxOpenTransAttempts-- ); |
|
992 |
|
993 // Start possible forced roaming |
915 // Start possible forced roaming |
994 if ( !err ) |
916 TCmUsageOfWlan usageOfWlan = CommsDatAccess()->ForcedRoamingL(); |
995 { |
917 if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew ) |
996 if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew ) |
918 { |
997 { |
919 if ( IsWlanConnectionStartedL( CommsDatAccess() ) ) |
998 if ( IsWlanConnectionStartedL( CommsDatAccess() ) ) |
920 { |
|
921 iConnMonIapInfo = aIapInfo; |
|
922 |
|
923 if ( iRoamingToWlanPeriodic ) |
999 { |
924 { |
1000 iRoamingToWlanPeriodic->Cancel(); |
925 iRoamingToWlanPeriodic->Cancel(); |
1001 iRoamingToHotspotWlanPeriodic->Cancel(); |
|
1002 |
|
1003 // Start periodic object that calls StartForcedRoamingToWlanL after 10s. |
|
1004 // this handles the case when new wlan connection is |
|
1005 // started from e.g. wlan sniffer but IAP is not yet in Internet SNAP |
|
1006 iRoamingToWlanPeriodic->Start( |
|
1007 TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), |
|
1008 TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), |
|
1009 TCallBack( StartForcedRoamingToConnectedWlanL, this ) ); |
|
1010 |
|
1011 // Start periodic object that calls StartForcedRoamingToWlanL after 120s. |
|
1012 // this handles the case when new captive portal hotspot wlan |
|
1013 // connection is started. IAP will be moved to Internet SNAP after |
|
1014 // successful login only. |
|
1015 iRoamingToHotspotWlanPeriodic->Start( |
|
1016 TTimeIntervalMicroSeconds32( KRoamingToHotspotWlanUpdateInterval ), |
|
1017 TTimeIntervalMicroSeconds32( KRoamingToHotspotWlanUpdateInterval ), |
|
1018 TCallBack( StartForcedRoamingToConnectedHotspotWlanL, this ) ); |
|
1019 } |
926 } |
1020 else |
927 else |
1021 { |
928 { |
1022 StartForcedRoamingToWlanL( iapInfo ); |
929 iRoamingToWlanPeriodic = CPeriodic::NewL( |
1023 } |
930 CActive::EPriorityStandard ); |
1024 |
931 } |
1025 StartForcedRoamingFromWlanL( iapInfo ); |
932 // start periodic object that calls StartForcedRoamingToWlanL after 10s. |
1026 } |
933 // this handles the case when new wlan connection is |
1027 } |
934 // started from e.g. wlan sniffer but IAP is not yet in Internet SNAP |
1028 else |
935 iRoamingToWlanPeriodic->Start( |
1029 { |
936 TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), |
1030 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIapL - \ |
937 TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), |
1031 reading info for forced roaming fails with err %d, forced roaming fails", err ) |
938 TCallBack( StartForcedRoamingToConnectedWlanL, this ) ); |
|
939 } |
|
940 else |
|
941 { |
|
942 StartForcedRoamingToWlanL( iapInfo ); |
|
943 } |
|
944 |
|
945 StartForcedRoamingFromWlanL( iapInfo ); |
1032 } |
946 } |
1033 |
947 |
1034 MPMLOGSTRING2( |
948 MPMLOGSTRING2( |
1035 "CMPMServer::NotifyBMPrefIapL - Send notifications for %d sessions", |
949 "CMPMServer::NotifyBMPrefIapL - Send notifications for %d sessions", |
1036 iSessions.Count() ) |
950 iSessions.Count() ) |
1037 |
951 |
1038 for ( TInt i = 0; i < iSessions.Count(); i++ ) |
952 for ( TInt i = 0; i < iSessions.Count(); i++ ) |
1039 { |
953 { |
1040 iapInfo = iSessions[i]->GetAvailableIAPs( ); |
954 iapInfo = iSessions[i]->GetAvailableIAPs( ); |
1041 iSessions[i]->PrefIAPNotificationL( iapInfo, aCaller ); |
955 iSessions[i]->PrefIAPNotificationL( iapInfo, aCaller ); |
1042 } |
|
1043 |
|
1044 // If a session is displaying connection selection dialog |
|
1045 // the contents of the dialog should be updated according to the |
|
1046 // current iap availability |
|
1047 // |
|
1048 for ( TInt i( 0 ); i < iSessions.Count(); i++ ) |
|
1049 { |
|
1050 iSessions[i]->UpdateConnectionDialogL(); |
|
1051 } |
|
1052 } |
|
1053 |
|
1054 // ----------------------------------------------------------------------------- |
|
1055 // CMPMServer::UpdateSessionConnectionDlgL |
|
1056 // ----------------------------------------------------------------------------- |
|
1057 // |
|
1058 void CMPMServer::UpdateSessionConnectionDlgL() |
|
1059 { |
|
1060 MPMLOGSTRING( "CMPMServer::UpdateSessionConnectionDlgL" ) |
|
1061 |
|
1062 // If a session is displaying connection selection dialog |
|
1063 // the contents of the dialog should be updated according to the |
|
1064 // current iap availability |
|
1065 // |
|
1066 for ( TInt i( 0 ); i < iSessions.Count(); i++ ) |
|
1067 { |
|
1068 iSessions[i]->UpdateConnectionDialogL(); |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 |
|
1073 // ----------------------------------------------------------------------------- |
|
1074 // CMPMServer::HandlePendingMsgs |
|
1075 // ----------------------------------------------------------------------------- |
|
1076 // |
|
1077 void CMPMServer::HandlePendingMsgs( TUint aIapId, |
|
1078 TInt aError, |
|
1079 TInt* aErrorReturned, |
|
1080 TBMNeededAction* aNeededAction ) |
|
1081 { |
|
1082 MPMLOGSTRING3( "CMPMServer::HandlePendingMsgs aError = %d iapId = %d", |
|
1083 aError, aIapId ) |
|
1084 |
|
1085 for ( TInt i( 0 ); i < iSessions.Count(); i++ ) |
|
1086 { |
|
1087 // Read the Connection Id of the application |
|
1088 TConnectionId connId = iSessions[i]->ConnectionId(); |
|
1089 |
|
1090 // Get the current connection IapId for this connId |
|
1091 TUint32 currentIap = iSessions[i]->MyServer().GetBMIap( connId ); |
|
1092 |
|
1093 MPMLOGSTRING2( "Session IapId = %d", currentIap ); |
|
1094 |
|
1095 if ( currentIap == aIapId && !iSessions[i]->ChooseBestIapCalled() ) |
|
1096 { |
|
1097 iSessions[i]->ProcessErrorComplete( aError, |
|
1098 aErrorReturned, |
|
1099 aNeededAction ); |
|
1100 } |
|
1101 } |
956 } |
1102 } |
957 } |
1103 |
958 |
1104 |
959 |
1105 // ----------------------------------------------------------------------------- |
960 // ----------------------------------------------------------------------------- |
1620 else if ( GetBMIap( session->ConnectionId() ) == aIapId ) |
1447 else if ( GetBMIap( session->ConnectionId() ) == aIapId ) |
1621 { |
1448 { |
1622 TRAP_IGNORE( session->StopIAPNotificationL( aIapId )); |
1449 TRAP_IGNORE( session->StopIAPNotificationL( aIapId )); |
1623 } |
1450 } |
1624 } |
1451 } |
1625 } |
|
1626 |
|
1627 // ----------------------------------------------------------------------------- |
|
1628 // CMPMServer::UpdateActiveConnection |
|
1629 // ----------------------------------------------------------------------------- |
|
1630 // |
|
1631 void CMPMServer::UpdateActiveConnection( CMPMServerSession& aSession ) |
|
1632 { |
|
1633 // Update active connection |
|
1634 TInt ret = KErrNone; |
|
1635 |
|
1636 TRAP ( ret, UpdateActiveConnectionL( aSession ) ); |
|
1637 |
|
1638 if ( ret != KErrNone ) |
|
1639 { |
|
1640 iActiveBearerType = EMPMBearerTypeNone; |
|
1641 iActiveIapId = 0; |
|
1642 iActiveSnapId = 0; |
|
1643 } |
|
1644 } |
|
1645 |
|
1646 // ----------------------------------------------------------------------------- |
|
1647 // CMPMServer::UpdateActiveConnectionL |
|
1648 // ----------------------------------------------------------------------------- |
|
1649 // |
|
1650 void CMPMServer::UpdateActiveConnectionL( CMPMServerSession& aSession ) |
|
1651 { |
|
1652 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL" ) |
|
1653 |
|
1654 TBool keysUpToDate( ETrue ); |
|
1655 |
|
1656 // number of active iaps |
|
1657 TInt numberOfActive = NumberOfActiveConnections( keysUpToDate ); |
|
1658 |
|
1659 if ( numberOfActive == 0 ) |
|
1660 { |
|
1661 // If no active connections then just reset keys and publish |
|
1662 iActiveBearerType = EMPMBearerTypeNone; |
|
1663 iActiveIapId = 0; |
|
1664 iActiveSnapId = 0; |
|
1665 PublishActiveConnection(); |
|
1666 return; |
|
1667 } |
|
1668 |
|
1669 if ( keysUpToDate ) |
|
1670 { |
|
1671 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL: already up-to-date" ) |
|
1672 return; |
|
1673 } |
|
1674 |
|
1675 if ( numberOfActive > 1 ) |
|
1676 { |
|
1677 // Check if all active connections are in same snap |
|
1678 TUint32 snapId; |
|
1679 |
|
1680 if ( CommsDatAccess()->AreActiveIapsInSameSnapL( |
|
1681 iActiveBMConns, snapId, *this ) ) |
|
1682 { |
|
1683 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL: Active iaps are in one SNAP" ) |
|
1684 // Select active connection according to priority |
|
1685 CommsDatAccess()->SelectActiveConnectionL ( |
|
1686 snapId, |
|
1687 iActiveBMConns, |
|
1688 iActiveIapId, |
|
1689 iActiveSnapId, |
|
1690 iActiveBearerType, |
|
1691 aSession ); |
|
1692 |
|
1693 PublishActiveConnection(); |
|
1694 return; |
|
1695 } |
|
1696 |
|
1697 MPMLOGSTRING( "CMPMServer::UpdateActiveConnectionL: Active iaps are in different SNAPs" ) |
|
1698 } |
|
1699 |
|
1700 // Reset active connections |
|
1701 iActiveBearerType = EMPMBearerTypeNone; |
|
1702 iActiveIapId = 0; |
|
1703 iActiveSnapId = 0; |
|
1704 |
|
1705 // Active connections locating in different snaps |
|
1706 // Use priority order vpn, wlan and packet |
|
1707 for ( TInt index = 0; index < iActiveBMConns.Count(); index++ ) |
|
1708 { |
|
1709 CMPMServerSession* serverSession = GetServerSession( |
|
1710 iActiveBMConns[index].iConnInfo.iConnId ); |
|
1711 |
|
1712 // Do check only for active connections |
|
1713 if ( iActiveBMConns[index].iConnInfo.iState == EStarted && |
|
1714 serverSession->ChooseBestIapCalled() ) |
|
1715 { |
|
1716 TMPMBearerType bearerType = EMPMBearerTypeOther; |
|
1717 |
|
1718 TInt ret = iDedicatedClients.Find( iActiveBMConns[index].iConnInfo.iAppUid ); |
|
1719 if ( ret != KErrNotFound ) |
|
1720 { |
|
1721 // Skip dedicated client |
|
1722 MPMLOGSTRING2( "Skip dedicated client = %d", iActiveBMConns[index].iConnInfo.iAppUid ) |
|
1723 continue; |
|
1724 } |
|
1725 |
|
1726 bearerType = CommsDatAccess()->GetBearerTypeL( |
|
1727 iActiveBMConns[index].iConnInfo.iIapId ); |
|
1728 |
|
1729 if ( bearerType == EMPMBearerTypeOther ) |
|
1730 { |
|
1731 // Don't publish this connection |
|
1732 continue; |
|
1733 } |
|
1734 |
|
1735 // This is true if, |
|
1736 // bearer type is smaller or different than none |
|
1737 // or |
|
1738 // bearer type is same and iap is different. |
|
1739 if ( ( bearerType < iActiveBearerType ) || |
|
1740 ( iActiveBearerType == EMPMBearerTypeNone ) || |
|
1741 ( ( bearerType == iActiveBearerType) && |
|
1742 ( iActiveIapId != iActiveBMConns[index].iConnInfo.iIapId ) ) ) |
|
1743 { |
|
1744 iActiveBearerType = bearerType; |
|
1745 iActiveIapId = iActiveBMConns[index].iConnInfo.iIapId; |
|
1746 iActiveSnapId = iActiveBMConns[index].iConnInfo.iSnap; |
|
1747 } |
|
1748 } |
|
1749 } |
|
1750 PublishActiveConnection(); |
|
1751 } |
|
1752 |
|
1753 // ----------------------------------------------------------------------------- |
|
1754 // CMPMServer::MapBearerType |
|
1755 // ----------------------------------------------------------------------------- |
|
1756 // |
|
1757 TUint32 CMPMServer::MapBearerType(TMPMBearerType aBearerType) |
|
1758 { |
|
1759 MPMLOGSTRING( "CMPMServer::MapBearerType" ) |
|
1760 |
|
1761 switch ( aBearerType ) |
|
1762 { |
|
1763 case EMPMBearerTypeNone: |
|
1764 return 0; |
|
1765 |
|
1766 case EMPMBearerTypeVpn: |
|
1767 return KCommDbBearerVirtual; |
|
1768 |
|
1769 case EMPMBearerTypeWlan: |
|
1770 return KCommDbBearerWLAN; |
|
1771 |
|
1772 case EMPMBearerTypePacketData: |
|
1773 return KCommDbBearerWcdma; |
|
1774 |
|
1775 case EMPMBearerTypeOther: |
|
1776 return KCommDbBearerUnknown; |
|
1777 |
|
1778 default: |
|
1779 MPMLOGSTRING( "CMPMServer::MapBearerType: Unknown bearer type" ) |
|
1780 break; |
|
1781 } |
|
1782 |
|
1783 return KCommDbBearerUnknown; |
|
1784 } |
|
1785 |
|
1786 // ----------------------------------------------------------------------------- |
|
1787 // CMPMServer::PublishActiveConnection |
|
1788 // ----------------------------------------------------------------------------- |
|
1789 // |
|
1790 void CMPMServer::PublishActiveConnection() |
|
1791 { |
|
1792 MPMLOGSTRING( "CMPMServer::PublishActiveConnection" ) |
|
1793 |
|
1794 // update active connection keys |
|
1795 RProperty::Set( KMPMActiveConnectionCategory, |
|
1796 KMPMPSKeyActiveConnectionIap, |
|
1797 iActiveIapId ); |
|
1798 |
|
1799 RProperty::Set( KMPMActiveConnectionCategory, |
|
1800 KMPMPSKeyActiveConnectionSnap, |
|
1801 iActiveSnapId ); |
|
1802 |
|
1803 RProperty::Set( KMPMActiveConnectionCategory, |
|
1804 KMPMPSKeyActiveConnectionBearer, |
|
1805 MapBearerType( iActiveBearerType ) ); |
|
1806 |
|
1807 MPMLOGSTRING4( "CMPMServer::PublishActiveConnection: Set to: %d, %d, %d", |
|
1808 iActiveIapId, iActiveSnapId, iActiveBearerType ) |
|
1809 } |
|
1810 |
|
1811 // ----------------------------------------------------------------------------- |
|
1812 // CMPMServer::NumberOfActiveConnections |
|
1813 // Returns number of active iaps. |
|
1814 // ----------------------------------------------------------------------------- |
|
1815 // |
|
1816 TInt CMPMServer::NumberOfActiveConnections( TBool& aKeysUpToDate ) |
|
1817 { |
|
1818 MPMLOGSTRING( "CMPMServer::NumberOfActiveConnections" ) |
|
1819 |
|
1820 aKeysUpToDate = ETrue; |
|
1821 TInt count( 0 ); |
|
1822 RArray<TUint32> activeIaps; |
|
1823 |
|
1824 activeIaps.Reset(); |
|
1825 |
|
1826 for ( TInt index = 0; index < iActiveBMConns.Count(); index++ ) |
|
1827 { |
|
1828 CMPMServerSession* serverSession = GetServerSession( |
|
1829 iActiveBMConns[index].iConnInfo.iConnId ); |
|
1830 |
|
1831 if ( iActiveBMConns[index].iConnInfo.iState == EStarted && |
|
1832 serverSession->ChooseBestIapCalled() ) |
|
1833 { |
|
1834 TInt ret = activeIaps.Find( iActiveBMConns[index].iConnInfo.iIapId ); |
|
1835 |
|
1836 if ( ret == KErrNotFound ) |
|
1837 { |
|
1838 activeIaps.Append ( iActiveBMConns[index].iConnInfo.iIapId ); |
|
1839 count++; |
|
1840 } |
|
1841 |
|
1842 if ( iActiveIapId != iActiveBMConns[index].iConnInfo.iIapId ) |
|
1843 { |
|
1844 // iap that is different from current active iap was found |
|
1845 aKeysUpToDate = EFalse; |
|
1846 } |
|
1847 } |
|
1848 } |
|
1849 |
|
1850 activeIaps.Close(); |
|
1851 MPMLOGSTRING2( "CMPMServer::NumberOfActiveConnections: count = %d", count ) |
|
1852 |
|
1853 return count; |
|
1854 } |
1452 } |
1855 |
1453 |
1856 // ----------------------------------------------------------------------------- |
1454 // ----------------------------------------------------------------------------- |
1857 // CMPMServer::UserConnectionInInternet |
1455 // CMPMServer::UserConnectionInInternet |
1858 // ----------------------------------------------------------------------------- |
1456 // ----------------------------------------------------------------------------- |
1878 // ----------------------------------------------------------------------------- |
1476 // ----------------------------------------------------------------------------- |
1879 // |
1477 // |
1880 void CMPMServer::StartForcedRoamingToWlanL( const TConnMonIapInfo& aIapInfo ) |
1478 void CMPMServer::StartForcedRoamingToWlanL( const TConnMonIapInfo& aIapInfo ) |
1881 { |
1479 { |
1882 MPMLOGSTRING( "CMPMServer::StartForcedRoamingToWlan" ) |
1480 MPMLOGSTRING( "CMPMServer::StartForcedRoamingToWlan" ) |
1883 |
1481 |
|
1482 // cancel the periodic object |
|
1483 if ( iRoamingToWlanPeriodic ) |
|
1484 { |
|
1485 iRoamingToWlanPeriodic->Cancel(); |
|
1486 } |
|
1487 |
1884 // Copy all available wlan iap ids to own array |
1488 // Copy all available wlan iap ids to own array |
1885 RArray<TUint32> wlanIapIds; |
1489 RArray<TUint32> wlanIapIds; |
1886 CleanupClosePushL( wlanIapIds ); |
1490 CleanupClosePushL( wlanIapIds ); |
1887 RAvailableIAPList iapList; |
1491 RAvailableIAPList iapList; |
1888 CleanupClosePushL( iapList ); |
1492 CleanupClosePushL( iapList ); |
1889 |
1493 |
1890 for ( TUint index = 0; index < aIapInfo.iCount; index++ ) |
1494 for ( TUint index = 0; index < aIapInfo.iCount; index++ ) |
1891 { |
1495 { |
1892 TWlanIapType iapType ( ENotWlanIap ); |
1496 if ( CommsDatAccess()->CheckWlanL( aIapInfo.iIap[index].iIapId ) != ENotWlanIap ) |
1893 TRAPD (leave, iapType = CommsDatAccess()->CheckWlanL( aIapInfo.iIap[index].iIapId ) ); |
|
1894 if ( ( iapType != ENotWlanIap ) && ( leave == KErrNone ) ) |
|
1895 { |
1497 { |
1896 // Accept only wlan iaps in internet snap |
1498 // Accept only wlan iaps in internet snap |
1897 if ( iCommsDatAccess->IsInternetSnapL( aIapInfo.iIap[index].iIapId, 0 ) ) |
1499 if ( iCommsDatAccess->IsInternetSnapL( aIapInfo.iIap[index].iIapId, 0 ) ) |
1898 { |
1500 { |
1899 wlanIapIds.AppendL( aIapInfo.iIap[index].iIapId ); |
1501 wlanIapIds.AppendL( aIapInfo.iIap[index].iIapId ); |
1900 } |
1502 } |
1901 } |
1503 } |
1902 // Fill iap list to be used later to check best iap; |
1504 // Fill iap list to be used later to check best iap |
1903 if ( leave == KErrNone ) |
1505 iapList.AppendL( aIapInfo.iIap[index].iIapId ); |
1904 { |
1506 } |
1905 iapList.AppendL( aIapInfo.iIap[index].iIapId ); |
1507 |
1906 } |
|
1907 } |
|
1908 // No wlans available -> no reason to continue |
1508 // No wlans available -> no reason to continue |
1909 if ( !wlanIapIds.Count() ) |
1509 if ( !wlanIapIds.Count() ) |
1910 { |
1510 { |
1911 CleanupStack::PopAndDestroy( &iapList ); |
1511 CleanupStack::PopAndDestroy( &iapList ); |
1912 CleanupStack::PopAndDestroy( &wlanIapIds ); |
1512 CleanupStack::PopAndDestroy( &wlanIapIds ); |
1947 // CMPMServer::StartForcedRoamingToConnectedWlanL |
1547 // CMPMServer::StartForcedRoamingToConnectedWlanL |
1948 // --------------------------------------------------------------------------- |
1548 // --------------------------------------------------------------------------- |
1949 // |
1549 // |
1950 TInt CMPMServer::StartForcedRoamingToConnectedWlanL( TAny* aUpdater ) |
1550 TInt CMPMServer::StartForcedRoamingToConnectedWlanL( TAny* aUpdater ) |
1951 { |
1551 { |
1952 MPMLOGSTRING( "CMPMServer::StartForcedRoamingToConnectedWlanL" ) |
1552 MPMLOGSTRING( "CMPMServer::StartForcedRoamingToConnectedWlanL" ); |
1953 CMPMServer* self = static_cast<CMPMServer*>( aUpdater ); |
1553 static_cast<CMPMServer*>( aUpdater )->StartForcedRoamingToWlanL( |
1954 if ( self ) |
1554 static_cast<CMPMServer*>( aUpdater )->iConnMonIapInfo ); |
1955 { |
1555 // Added also execution of policy based roaming logic because |
1956 // cancel the periodic object |
1556 // connections that are in EStarting state, when WLAN signal |
1957 self->iRoamingToWlanPeriodic->Cancel(); |
1557 // gets weak, would remain in WLAN as long as signal is weak. |
1958 self->StartForcedRoamingToWlanL( self->iConnMonIapInfo ); |
1558 static_cast<CMPMServer*>( aUpdater )->StartForcedRoamingFromWlanL( |
1959 } |
1559 static_cast<CMPMServer*>( aUpdater )->iConnMonIapInfo ); |
1960 return 0; |
1560 return 0; |
1961 } |
1561 } |
1962 |
1562 |
1963 // --------------------------------------------------------------------------- |
|
1964 // CMPMServer::StartForcedRoamingToConnectedHotspotWlanL |
|
1965 // --------------------------------------------------------------------------- |
|
1966 // |
|
1967 TInt CMPMServer::StartForcedRoamingToConnectedHotspotWlanL( TAny* aUpdater ) |
|
1968 { |
|
1969 MPMLOGSTRING( "CMPMServer::StartForcedRoamingToConnectedHotspotWlanL" ) |
|
1970 CMPMServer* self = static_cast<CMPMServer*>( aUpdater ); |
|
1971 if ( self ) |
|
1972 { |
|
1973 // cancel the periodic object |
|
1974 self->iRoamingToHotspotWlanPeriodic->Cancel(); |
|
1975 self->StartForcedRoamingToWlanL( self->iConnMonIapInfo ); |
|
1976 } |
|
1977 return 0; |
|
1978 } |
|
1979 |
1563 |
1980 // ----------------------------------------------------------------------------- |
1564 // ----------------------------------------------------------------------------- |
1981 // CMPMServer::StartForcedRoamingFromWlanL |
1565 // CMPMServer::StartForcedRoamingFromWlanL |
1982 // ----------------------------------------------------------------------------- |
1566 // ----------------------------------------------------------------------------- |
1983 // |
1567 // |
2237 err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap ); |
1821 err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap ); |
2238 // Check that it's not MMS IAP. |
1822 // Check that it's not MMS IAP. |
2239 if (!(err == KErrNone && iapId == mmsIap)) |
1823 if (!(err == KErrNone && iapId == mmsIap)) |
2240 { |
1824 { |
2241 // Stop the conn / IAP. |
1825 // Stop the conn / IAP. |
2242 if ( aSilentOnly ) |
1826 StopConnections( iapId ); |
2243 { |
|
2244 CheckIapForDisconnect( iapId ); |
|
2245 } |
|
2246 else |
|
2247 { |
|
2248 StopConnections( iapId ); |
|
2249 } |
|
2250 stoppedIaps.Append( iapId ); |
1827 stoppedIaps.Append( iapId ); |
2251 } |
1828 } |
2252 } |
1829 } |
2253 } |
1830 } |
2254 } |
1831 } |
2255 stoppedIaps.Close(); |
1832 stoppedIaps.Close(); |
|
1833 } |
|
1834 |
|
1835 // ----------------------------------------------------------------------------- |
|
1836 // CMPMServer::AddVpnUserConnectionSession |
|
1837 // ----------------------------------------------------------------------------- |
|
1838 // |
|
1839 void CMPMServer::AddVpnUserConnectionSession() |
|
1840 { |
|
1841 iVpnUserConnectionSessionCount++; |
|
1842 } |
|
1843 |
|
1844 // ----------------------------------------------------------------------------- |
|
1845 // CMPMServer::RemoveVpnUserConnectionSession |
|
1846 // ----------------------------------------------------------------------------- |
|
1847 // |
|
1848 void CMPMServer::RemoveVpnUserConnectionSession() |
|
1849 { |
|
1850 ASSERT( iVpnUserConnectionSessionCount > 0 ); |
|
1851 iVpnUserConnectionSessionCount--; |
|
1852 } |
|
1853 |
|
1854 // --------------------------------------------------------------------------- |
|
1855 // CMPMServer::UseVpnUserConnection |
|
1856 // Informs if VPN user connection is used with given MPM preferences and |
|
1857 // application. |
|
1858 // --------------------------------------------------------------------------- |
|
1859 // |
|
1860 TBool CMPMServer::UseVpnUserConnection( const TMpmConnPref aMpmConnPref, |
|
1861 const TUint32 aAppUid ) const |
|
1862 { |
|
1863 if ( iMpmVpnToggleWatcher->IsVpnConnectionPreferred() && |
|
1864 !aMpmConnPref.MandateIap() && |
|
1865 aAppUid != KUidKmdServer && |
|
1866 aAppUid != iMpmCsIdWatcher->ConnectScreenId() ) |
|
1867 { |
|
1868 // VPN connection is preferred connection, connection preferences are |
|
1869 // not mandatet and client is not KMD server or Connect Screen. |
|
1870 if ( aMpmConnPref.ConnType() == TMpmConnPref::EConnTypeDefault || |
|
1871 aMpmConnPref.ConnType() == TMpmConnPref::EConnTypeImplicit ) |
|
1872 { |
|
1873 // Default or implicit connection is requested. |
|
1874 // VPN user connection is used. |
|
1875 return ETrue; |
|
1876 } |
|
1877 else |
|
1878 { |
|
1879 // Explicit connection is requested. |
|
1880 TBool internetSnap(EFalse); |
|
1881 TRAPD( err, internetSnap = iCommsDatAccess->IsInternetSnapL( aMpmConnPref.IapId(), |
|
1882 aMpmConnPref.SnapId() ) ); |
|
1883 if ( err == KErrNone && |
|
1884 internetSnap ) |
|
1885 { |
|
1886 // Connection belongs to Internet SNAP. |
|
1887 // VPN user connection is used. |
|
1888 return ETrue; |
|
1889 } |
|
1890 } |
|
1891 } |
|
1892 |
|
1893 // VPN user connection is not used. |
|
1894 return EFalse; |
|
1895 } |
|
1896 |
|
1897 // ----------------------------------------------------------------------------- |
|
1898 // CMPMServer::PrepareVpnUserConnection |
|
1899 // ----------------------------------------------------------------------------- |
|
1900 // |
|
1901 TBool CMPMServer::PrepareVpnUserConnection( TMpmConnPref& aMpmConnPref ) |
|
1902 { |
|
1903 // Get VPN IAP Id or SNAP Id, which is used for VPN user connection. |
|
1904 TUint32 vpnIapId = iMpmVpnToggleWatcher->VpnIapId(); |
|
1905 TUint32 snapId = iMpmVpnToggleWatcher->SnapId(); |
|
1906 |
|
1907 // Check first if SNAP Id is set, in which case VPN IAP Id is ignored. |
|
1908 if ( snapId != 0 ) |
|
1909 { |
|
1910 TBool intranetSnap( EFalse ); |
|
1911 TRAPD( err , intranetSnap = |
|
1912 iCommsDatAccess->IsIntranetSnapL( snapId ) ); |
|
1913 if ( (err != KErrNone) || |
|
1914 (!intranetSnap) ) |
|
1915 { |
|
1916 // SNAP is not intranet SNAP. |
|
1917 // Reset VPN toggle values and continue without using VPN user |
|
1918 // connection. |
|
1919 MPMLOGSTRING3( "CMPMServer::PrepareVpnUserConnection failed, \ |
|
1920 SNAP Id=%d, err=%d", snapId, err ); |
|
1921 |
|
1922 iMpmVpnToggleWatcher->ResetVpnToggleValues(); |
|
1923 return EFalse; |
|
1924 } |
|
1925 aMpmConnPref.SetIapId( 0 ); |
|
1926 aMpmConnPref.SetSnapId( snapId ); |
|
1927 } |
|
1928 else |
|
1929 { |
|
1930 // Validate that IAP is VPN IAP. |
|
1931 TMPMBearerType bearerType = EMPMBearerTypeNone; |
|
1932 TRAPD( err, bearerType = iCommsDatAccess->GetBearerTypeL( vpnIapId ) ); |
|
1933 if ( (err != KErrNone) || |
|
1934 (bearerType != EMPMBearerTypeVpn) ) |
|
1935 { |
|
1936 // IAP is not valid VPN IAP. |
|
1937 // Reset VPN toggle values and continue without using VPN user |
|
1938 // connection. |
|
1939 MPMLOGSTRING4( "CMPMServer::PrepareVpnUserConnection failed, \ |
|
1940 IAP Id=%d, err=%d, bearerType=%d", vpnIapId, err, bearerType ); |
|
1941 |
|
1942 iMpmVpnToggleWatcher->ResetVpnToggleValues(); |
|
1943 return EFalse; |
|
1944 } |
|
1945 aMpmConnPref.SetIapId( vpnIapId ); |
|
1946 aMpmConnPref.SetSnapId( 0 ); |
|
1947 } |
|
1948 |
|
1949 aMpmConnPref.SetConnType( TMpmConnPref::EConnTypeExplicit ); |
|
1950 |
|
1951 // VPN user connection will be activated. |
|
1952 return ETrue; |
2256 } |
1953 } |
2257 |
1954 |
2258 // --------------------------------------------------------------------------- |
1955 // --------------------------------------------------------------------------- |
2259 // CMPMServer::UpdateOfflineMode |
1956 // CMPMServer::UpdateOfflineMode |
2260 // Offline watcher listens the offline mode and calls this when it's changed. |
1957 // Offline watcher listens the offline mode and calls this when it's changed. |
2261 // --------------------------------------------------------------------------- |
1958 // --------------------------------------------------------------------------- |
2262 // |
1959 // |
2263 void CMPMServer::UpdateOfflineMode( TInt newModeValue ) |
1960 void CMPMServer::UpdateOfflineMode( TInt aNewModeValue ) |
2264 { |
1961 { |
2265 MPMLOGSTRING2( "CMPMServer::UpdateOfflineMode: Value %d", newModeValue ) |
1962 MPMLOGSTRING2( "CMPMServer::UpdateOfflineMode: Value %d", aNewModeValue ) |
2266 |
1963 |
2267 iOfflineMode = newModeValue; |
1964 iOfflineMode = aNewModeValue; |
2268 |
1965 |
2269 if ( iOfflineMode == ECoreAppUIsNetworkConnectionAllowed ) |
1966 if ( iOfflineMode == ECoreAppUIsNetworkConnectionAllowed ) |
2270 { |
1967 { |
2271 // Offline mode finished, reset the QueryResponse variable. |
1968 // Offline mode finished, reset the QueryResponse variable. |
2272 iOfflineWlanQueryResponse = EOfflineResponseUndefined; |
1969 iOfflineWlanQueryResponse = EOfflineResponseUndefined; |
2378 } |
2075 } |
2379 return retval; |
2076 return retval; |
2380 } |
2077 } |
2381 |
2078 |
2382 // ----------------------------------------------------------------------------- |
2079 // ----------------------------------------------------------------------------- |
2383 // CMPMServer::CheckIapForDisconnect |
|
2384 // ----------------------------------------------------------------------------- |
|
2385 // |
|
2386 void CMPMServer::CheckIapForDisconnect( TInt aIapId ) |
|
2387 { |
|
2388 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - aIapId = 0x%x", |
|
2389 aIapId ) |
|
2390 |
|
2391 // Fix for case ou1cimx1#468999: stop sessions to cellular iap |
|
2392 // when there is only silent connections to it, and cellular usage is set |
|
2393 // to always ask |
|
2394 |
|
2395 // Check iap type and usage policy |
|
2396 TMPMBearerType bearerType( EMPMBearerTypeNone ); |
|
2397 TRAP_IGNORE( bearerType = CommsDatAccess()->GetBearerTypeL( aIapId ) ); |
|
2398 |
|
2399 TBool closeIap = ( bearerType == EMPMBearerTypePacketData |
|
2400 && DataUsageWatcher()->CellularDataUsage() == ECmCellularDataUsageConfirm ); |
|
2401 |
|
2402 // No need to put iapSessions to CleanupStack; there are no leaves |
|
2403 RPointerArray<CMPMServerSession> iapSessions; |
|
2404 if ( closeIap ) |
|
2405 { |
|
2406 // Check for non-silent sessions to iap |
|
2407 // closeIap is left true also when there are no sessions using the iap |
|
2408 for ( TInt i = 0; i < iActiveBMConns.Count(); i++ ) |
|
2409 { |
|
2410 |
|
2411 CMPMServerSession* session |
|
2412 = GetServerSession( iActiveBMConns[i].iConnInfo.iConnId ); |
|
2413 |
|
2414 TInt sessionIapId = iActiveBMConns[i].iConnInfo.iIapId; |
|
2415 if ( !sessionIapId ) |
|
2416 { |
|
2417 TRAP_IGNORE( sessionIapId = session->IapSelectionL()->MpmConnPref().IapId() ); |
|
2418 } |
|
2419 |
|
2420 if ( sessionIapId == aIapId ) |
|
2421 { |
|
2422 iapSessions.Append( session ); // Don't mind if Append fails |
|
2423 |
|
2424 TBool silent( ETrue ); |
|
2425 TRAP_IGNORE( silent = session->IapSelectionL()->MpmConnPref().NoteBehaviour() |
|
2426 & TExtendedConnPref::ENoteBehaviourConnDisableNotes ); |
|
2427 if ( !silent ) |
|
2428 { |
|
2429 // Non-silent session to iap found |
|
2430 closeIap = EFalse; |
|
2431 break; // for |
|
2432 } |
|
2433 } |
|
2434 } |
|
2435 } |
|
2436 |
|
2437 if ( closeIap ) |
|
2438 { |
|
2439 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping silent sessions to iap 0x%x", |
|
2440 aIapId ) |
|
2441 // Stop all (silent) sessions to iap |
|
2442 for ( TInt i = 0; i < iapSessions.Count(); i++) |
|
2443 { |
|
2444 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping connId 0x%x", |
|
2445 iapSessions[i]->ConnectionId()); |
|
2446 iapSessions[i]->StopConnection(); |
|
2447 } |
|
2448 } |
|
2449 |
|
2450 iapSessions.Close(); |
|
2451 |
|
2452 } |
|
2453 |
|
2454 |
|
2455 // ----------------------------------------------------------------------------- |
|
2456 // TMPMBlackListConnId::Append |
2080 // TMPMBlackListConnId::Append |
2457 // ----------------------------------------------------------------------------- |
2081 // ----------------------------------------------------------------------------- |
2458 // |
2082 // |
2459 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory ) |
2083 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory ) |
2460 { |
2084 { |