557 CMPMServerSession& aSession ) |
551 CMPMServerSession& aSession ) |
558 { |
552 { |
559 MPMLOGSTRING2( "CMPMServer::RemoveBMConnection - aConnId = 0x%x", |
553 MPMLOGSTRING2( "CMPMServer::RemoveBMConnection - aConnId = 0x%x", |
560 aConnId ) |
554 aConnId ) |
561 |
555 |
|
556 TInt count = iActiveBMConns.Count(); |
|
557 |
|
558 // Decrement by one, because count is n, |
|
559 // but indexes in array are 0 .. n-1. |
|
560 // |
|
561 count--; |
|
562 |
562 // This time we are browsing the array from the end to the beginning, |
563 // This time we are browsing the array from the end to the beginning, |
563 // because removing one element from array affects index numbering. |
564 // because removing one element from array affects index numbering. |
564 // Decrement i by one, because count is n, but indexes in array are 0 .. n-1 |
565 // |
565 for ( TInt i = iActiveBMConns.Count() - 1; i >= 0; i-- ) |
566 for ( TInt i = count; i >= 0; i-- ) |
566 { |
567 { |
567 if ( iActiveBMConns[i].iConnInfo.iConnId == aConnId ) |
568 if ( iActiveBMConns[i].iConnInfo.iConnId == aConnId ) |
568 { |
569 { |
569 |
|
570 TInt closeIapId = iActiveBMConns[i].iConnInfo.iIapId; |
|
571 if ( !closeIapId ) |
|
572 { |
|
573 TRAP_IGNORE( closeIapId = aSession.IapSelectionL()->MpmConnPref().IapId() ); |
|
574 } |
|
575 |
|
576 // If Connection Id found, remove it. |
570 // If Connection Id found, remove it. |
|
571 // |
577 iActiveBMConns.Remove( i ); |
572 iActiveBMConns.Remove( i ); |
578 |
573 |
579 // Update active connection |
574 // Update active connection |
580 if ( aSession.ChooseBestIapCalled() ) |
575 if ( aSession.ChooseBestIapCalled() ) |
581 { |
576 { |
582 UpdateActiveConnection( aSession ); |
577 UpdateActiveConnection( aSession ); |
583 } |
578 } |
584 |
579 } |
585 CheckIapForDisconnect( closeIapId ); |
580 } |
586 } |
581 |
587 } |
|
588 |
|
589 #ifdef _DEBUG |
582 #ifdef _DEBUG |
590 // Dump array of active connections to log in order to support testing. |
583 // Dump array of active connections to log in order to support testing. |
591 // |
584 // |
592 DumpActiveBMConns(); |
585 DumpActiveBMConns(); |
593 #endif // _DEBUG |
586 #endif // _DEBUG |
881 { |
876 { |
882 MPMLOGSTRING3( |
877 MPMLOGSTRING3( |
883 "CMPMServer::RemoveBMIAPConnection - aIapId = %i, aConnId = 0x%x", |
878 "CMPMServer::RemoveBMIAPConnection - aIapId = %i, aConnId = 0x%x", |
884 aIapId, aConnId ) |
879 aIapId, aConnId ) |
885 |
880 |
|
881 TActiveBMConn conn; |
|
882 conn.iConnInfo.iIapId = aIapId; |
|
883 |
886 // The IAP connection lifetime is determined by the two calls |
884 // The IAP connection lifetime is determined by the two calls |
887 // IAPConnectionStarted and IAPConnectionStopped. |
885 // IAPConnectionStarted and IAPConnectionStopped. |
|
886 // |
|
887 TInt count = iActiveBMConns.Count(); |
|
888 |
|
889 // Decrement by one, because count is n, |
|
890 // but indexes in array are 0 .. n-1. |
|
891 // |
|
892 count--; |
888 |
893 |
889 // This time we are browsing the array from the end to the beginning, |
894 // This time we are browsing the array from the end to the beginning, |
890 // because removing one element from array affects index numbering. |
895 // because removing one element from array affects index numbering. |
891 // Decrement i by one, because count is n, but indexes in array are 0 .. n-1 |
896 // |
892 for ( TInt i = iActiveBMConns.Count() - 1; i >= 0; i-- ) |
897 for ( TInt i = count; i >= 0; i-- ) |
893 { |
898 { |
894 if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId ) |
899 if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId ) |
895 { |
900 { |
896 if ( iActiveBMConns[i].iConnInfo.iSnap == 0 ) |
901 if ( iActiveBMConns[i].iConnInfo.iSnap == 0 ) |
897 { |
902 { |
2414 MPMLOGSTRING( "CMPMServer::IsConnPermQueryTimerOn: Yes." ) |
2412 MPMLOGSTRING( "CMPMServer::IsConnPermQueryTimerOn: Yes." ) |
2415 } |
2413 } |
2416 return retval; |
2414 return retval; |
2417 } |
2415 } |
2418 |
2416 |
2419 // --------------------------------------------------------------------------- |
|
2420 // CMPMServer::StartOfflineQueryTimer |
|
2421 // Starts the offline query timer. |
|
2422 // --------------------------------------------------------------------------- |
|
2423 // |
|
2424 void CMPMServer::StartOfflineQueryTimer() |
|
2425 { |
|
2426 MPMLOGSTRING( "CMPMServer::StartOfflineQueryTimer" ) |
|
2427 |
|
2428 if ( !iOfflineQueryTimer ) |
|
2429 { |
|
2430 TRAPD( err, iOfflineQueryTimer = CMPMOfflineQueryTimer::NewL( this ) ); |
|
2431 if ( err == KErrNone ) |
|
2432 { |
|
2433 iOfflineQueryTimer->StartTimer(); |
|
2434 MPMLOGSTRING( "CMPMServer::StartOfflineQueryTimer: Ok." ) |
|
2435 } |
|
2436 } |
|
2437 } |
|
2438 |
|
2439 // --------------------------------------------------------------------------- |
|
2440 // CMPMServer::ResetOfflineQueryTimer |
|
2441 // Resets the offline query timer. |
|
2442 // --------------------------------------------------------------------------- |
|
2443 // |
|
2444 void CMPMServer::ResetOfflineQueryTimer() |
|
2445 { |
|
2446 MPMLOGSTRING( "CMPMServer::ResetOfflineQueryTimer" ) |
|
2447 |
|
2448 if ( iOfflineQueryTimer ) |
|
2449 { |
|
2450 delete iOfflineQueryTimer; |
|
2451 iOfflineQueryTimer = NULL; |
|
2452 MPMLOGSTRING( "CMPMServer::ResetOfflineQueryTimer: Ok." ) |
|
2453 } |
|
2454 } |
|
2455 |
|
2456 // --------------------------------------------------------------------------- |
|
2457 // CMPMServer::IsOfflineQueryTimerOn |
|
2458 // Tells if the offline query timer is on. |
|
2459 // --------------------------------------------------------------------------- |
|
2460 // |
|
2461 TBool CMPMServer::IsOfflineQueryTimerOn() |
|
2462 { |
|
2463 MPMLOGSTRING( "CMPMServer::IsOfflineQueryTimerOn" ) |
|
2464 |
|
2465 TBool retval = EFalse; |
|
2466 if ( iOfflineQueryTimer ) |
|
2467 { |
|
2468 retval = ETrue; |
|
2469 MPMLOGSTRING( "CMPMServer::IsOfflineQueryTimerOn: Yes." ) |
|
2470 } |
|
2471 return retval; |
|
2472 } |
|
2473 |
|
2474 // --------------------------------------------------------------------------- |
|
2475 // CMPMServer::StartConnSelectionDlgTimer |
|
2476 // Starts the connection selection dialog timer. |
|
2477 // --------------------------------------------------------------------------- |
|
2478 // |
|
2479 void CMPMServer::StartConnSelectionDlgTimer() |
|
2480 { |
|
2481 MPMLOGSTRING( "CMPMServer::StartConnSelectionDlgTimer" ) |
|
2482 |
|
2483 if ( !iConnSelectionDlgTimer ) |
|
2484 { |
|
2485 TRAPD( err, iConnSelectionDlgTimer = CMPMConnSelectionDlgTimer::NewL( this ) ); |
|
2486 if ( err == KErrNone ) |
|
2487 { |
|
2488 iConnSelectionDlgTimer->StartTimer(); |
|
2489 MPMLOGSTRING( "CMPMServer::StartConnSelectionDlgTimer: Ok." ) |
|
2490 } |
|
2491 } |
|
2492 } |
|
2493 |
|
2494 // --------------------------------------------------------------------------- |
|
2495 // CMPMServer::ResetConnSelectionDlgTimer |
|
2496 // Resets the connection selection dialog timer. |
|
2497 // --------------------------------------------------------------------------- |
|
2498 // |
|
2499 void CMPMServer::ResetConnSelectionDlgTimer() |
|
2500 { |
|
2501 MPMLOGSTRING( "CMPMServer::ResetConnSelectionDlgTimer" ) |
|
2502 |
|
2503 if ( iConnSelectionDlgTimer ) |
|
2504 { |
|
2505 delete iConnSelectionDlgTimer; |
|
2506 iConnSelectionDlgTimer = NULL; |
|
2507 MPMLOGSTRING( "CMPMServer::ResetConnSelectionDlgTimer: Ok." ) |
|
2508 } |
|
2509 } |
|
2510 |
|
2511 // --------------------------------------------------------------------------- |
|
2512 // CMPMServer::IsConnSelectionDlgTimerOn |
|
2513 // Tells if the connection selection dialog timer is on. |
|
2514 // --------------------------------------------------------------------------- |
|
2515 // |
|
2516 TBool CMPMServer::IsConnSelectionDlgTimerOn() |
|
2517 { |
|
2518 MPMLOGSTRING( "CMPMServer::IsConnSelectionDlgTimerOn" ) |
|
2519 |
|
2520 TBool retval = EFalse; |
|
2521 if ( iConnSelectionDlgTimer ) |
|
2522 { |
|
2523 retval = ETrue; |
|
2524 MPMLOGSTRING( "CMPMServer::IsConnSelectionDlgTimerOn: Yes." ) |
|
2525 } |
|
2526 return retval; |
|
2527 } |
|
2528 |
|
2529 // ----------------------------------------------------------------------------- |
|
2530 // CMPMServer::CheckIapForDisconnect |
|
2531 // ----------------------------------------------------------------------------- |
|
2532 // |
|
2533 void CMPMServer::CheckIapForDisconnect( TInt aIapId ) |
|
2534 { |
|
2535 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - aIapId = 0x%x", |
|
2536 aIapId ) |
|
2537 |
|
2538 // Fix for case ou1cimx1#468999: stop sessions to cellular iap |
|
2539 // when there is only silent connections to it, and cellular usage is set |
|
2540 // to always ask |
|
2541 |
|
2542 // Check iap type and usage policy |
|
2543 TMPMBearerType bearerType( EMPMBearerTypeNone ); |
|
2544 TRAP_IGNORE( bearerType = CommsDatAccess()->GetBearerTypeL( aIapId ) ); |
|
2545 |
|
2546 TBool closeIap = ( bearerType == EMPMBearerTypePacketData |
|
2547 && DataUsageWatcher()->CellularDataUsage() == ECmCellularDataUsageConfirm ); |
|
2548 |
|
2549 // No need to put iapSessions to CleanupStack; there are no leaves |
|
2550 RPointerArray<CMPMServerSession> iapSessions; |
|
2551 if ( closeIap ) |
|
2552 { |
|
2553 // Check for non-silent sessions to iap |
|
2554 // closeIap is left true also when there are no sessions using the iap |
|
2555 for ( TInt i = 0; i < iActiveBMConns.Count(); i++ ) |
|
2556 { |
|
2557 |
|
2558 CMPMServerSession* session |
|
2559 = GetServerSession( iActiveBMConns[i].iConnInfo.iConnId ); |
|
2560 |
|
2561 TInt sessionIapId = iActiveBMConns[i].iConnInfo.iIapId; |
|
2562 if ( !sessionIapId ) |
|
2563 { |
|
2564 TRAP_IGNORE( sessionIapId = session->IapSelectionL()->MpmConnPref().IapId() ); |
|
2565 } |
|
2566 |
|
2567 if ( sessionIapId == aIapId ) |
|
2568 { |
|
2569 iapSessions.Append( session ); // Don't mind if Append fails |
|
2570 |
|
2571 TBool silent( ETrue ); |
|
2572 TRAP_IGNORE( silent = session->IapSelectionL()->MpmConnPref().NoteBehaviour() |
|
2573 & TExtendedConnPref::ENoteBehaviourConnDisableNotes ); |
|
2574 if ( !silent ) |
|
2575 { |
|
2576 // Non-silent session to iap found |
|
2577 closeIap = EFalse; |
|
2578 break; // for |
|
2579 } |
|
2580 } |
|
2581 } |
|
2582 } |
|
2583 |
|
2584 if ( closeIap ) |
|
2585 { |
|
2586 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping silent sessions to iap 0x%x", |
|
2587 aIapId ) |
|
2588 // Stop all (silent) sessions to iap |
|
2589 for ( TInt i = 0; i < iapSessions.Count(); i++) |
|
2590 { |
|
2591 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping connId 0x%x", |
|
2592 iapSessions[i]->ConnectionId()); |
|
2593 iapSessions[i]->StopConnection(); |
|
2594 } |
|
2595 } |
|
2596 |
|
2597 iapSessions.Close(); |
|
2598 |
|
2599 } |
|
2600 |
|
2601 |
|
2602 // ----------------------------------------------------------------------------- |
2417 // ----------------------------------------------------------------------------- |
2603 // TMPMBlackListConnId::Append |
2418 // TMPMBlackListConnId::Append |
2604 // ----------------------------------------------------------------------------- |
2419 // ----------------------------------------------------------------------------- |
2605 // |
2420 // |
2606 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory ) |
2421 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory ) |