23 // INCLUDE FILES |
23 // INCLUDE FILES |
24 #include <e32svr.h> |
24 #include <e32svr.h> |
25 #include <gsmerror.h> // KErrPacketDataTsyMaxPdpContextsReached |
25 #include <gsmerror.h> // KErrPacketDataTsyMaxPdpContextsReached |
26 #include <etelpckt.h> // KErrUmtsMaxNumOfContextExceededByNetwork |
26 #include <etelpckt.h> // KErrUmtsMaxNumOfContextExceededByNetwork |
27 #include <bldvariant.hrh> // For feature flags |
27 #include <bldvariant.hrh> // For feature flags |
28 #include <featmgr.h> // FeatureManager |
|
29 #include <centralrepository.h> // CRepository |
28 #include <centralrepository.h> // CRepository |
30 #include <CoreApplicationUIsSDKCRKeys.h> // KCRUidCoreApplicationUIs, |
29 #include <CoreApplicationUIsSDKCRKeys.h> // KCRUidCoreApplicationUIs, |
31 // KCoreAppUIsNetworkConnectionAllowed |
30 // KCoreAppUIsNetworkConnectionAllowed |
32 #include <es_sock.h> |
31 #include <es_sock.h> |
33 #include <commdb.h> |
32 #include <commdb.h> |
74 iMyServer( aServer ), |
73 iMyServer( aServer ), |
75 iDisconnectDlg( NULL ), |
74 iDisconnectDlg( NULL ), |
76 iConfirmDlgRoaming( NULL ), |
75 iConfirmDlgRoaming( NULL ), |
77 iStoredIapInfo(), |
76 iStoredIapInfo(), |
78 iIapSelection( NULL ), |
77 iIapSelection( NULL ), |
79 iMigrateState( EMigrateNone ) |
78 iMigrateState( EMigrateNone ), |
|
79 iDisconnectDialogShown( EFalse ) |
80 { |
80 { |
81 } |
81 } |
82 |
82 |
83 |
83 |
84 // ----------------------------------------------------------------------------- |
84 // ----------------------------------------------------------------------------- |
92 { |
92 { |
93 iMyServer.SetEvents(CMPMConnMonEvents::NewL( |
93 iMyServer.SetEvents(CMPMConnMonEvents::NewL( |
94 *const_cast<CMPMServer*>( &iMyServer ), *this )); |
94 *const_cast<CMPMServer*>( &iMyServer ), *this )); |
95 } |
95 } |
96 |
96 |
97 FeatureManager::InitializeLibL(); |
|
98 iOfflineFeatureSupported = FeatureManager::FeatureSupported( |
|
99 KFeatureIdOfflineMode ); |
|
100 |
|
101 FeatureManager::UnInitializeLib(); |
|
102 |
|
103 // Append session pointer to server |
97 // Append session pointer to server |
104 // |
98 // |
105 iMyServer.AppendSessionL( this ); |
99 iMyServer.AppendSessionL( this ); |
106 } |
100 } |
107 |
101 |
710 iMyServer.AppendBMIAPConnectionL( startedIap, startedId, *this ); |
704 iMyServer.AppendBMIAPConnectionL( startedIap, startedId, *this ); |
711 |
705 |
712 // Complete the message as soon as possible to avoid latency in BM |
706 // Complete the message as soon as possible to avoid latency in BM |
713 // |
707 // |
714 aMessage.Complete( KErrNone ); |
708 aMessage.Complete( KErrNone ); |
715 |
|
716 IapSelectionL()->ConnectionStarted(); |
|
717 } |
709 } |
718 |
710 |
719 // ----------------------------------------------------------------------------- |
711 // ----------------------------------------------------------------------------- |
720 // CMPMServerSession::HandleServerIapConnectionStopped |
712 // CMPMServerSession::HandleServerIapConnectionStopped |
721 // ----------------------------------------------------------------------------- |
713 // ----------------------------------------------------------------------------- |
850 |
842 |
851 if ( currentDataUsage == ECmCellularDataUsageConfirm ) |
843 if ( currentDataUsage == ECmCellularDataUsageConfirm ) |
852 { |
844 { |
853 MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" ) |
845 MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" ) |
854 isConfirmFirst = ETrue; |
846 isConfirmFirst = ETrue; |
|
847 |
|
848 // iDisconnectDialogShown is set when disconnect dialog is shown. |
|
849 // Before the disconnect dialog is shown, data usage confirmation |
|
850 // dialog is already shown for the new PDP context. If you choose |
|
851 // to disconnect the active PDP context then data usage dialog is |
|
852 // shown again for the new context. So, set isConfirmFirst to |
|
853 // False to avoid duplicate cellular confirm dialog |
|
854 // |
|
855 if ( iDisconnectDialogShown ) |
|
856 { |
|
857 MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False; Data \ |
|
858 confirmation dialog already shown this IAP" ) |
|
859 isConfirmFirst = EFalse; |
|
860 iDisconnectDialogShown = EFalse; |
|
861 } |
855 } |
862 } |
856 else |
863 else |
857 { |
864 { |
858 MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" ) |
865 MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" ) |
859 } |
866 } |
1417 ProcessErrorComplete( KErrNone, &error, &neededAction ); |
1424 ProcessErrorComplete( KErrNone, &error, &neededAction ); |
1418 return; |
1425 return; |
1419 } |
1426 } |
1420 |
1427 |
1421 // Show error popup if it's allowed per client request |
1428 // Show error popup if it's allowed per client request |
|
1429 // Don't show the pop up if error code is for disconnect dialog |
|
1430 // |
1422 if ( !( iIapSelection->MpmConnPref().NoteBehaviour() & |
1431 if ( !( iIapSelection->MpmConnPref().NoteBehaviour() & |
1423 TExtendedConnPref::ENoteBehaviourConnDisableNotes ) ) |
1432 TExtendedConnPref::ENoteBehaviourConnDisableNotes ) && |
|
1433 !DisconnectDlgErrorCode( error ) ) |
1424 { |
1434 { |
1425 CConnectionUiUtilities* connUiUtils = NULL; |
1435 CConnectionUiUtilities* connUiUtils = NULL; |
1426 TRAPD( popupCreateError, connUiUtils = CConnectionUiUtilities::NewL() ); |
1436 TRAPD( popupCreateError, connUiUtils = CConnectionUiUtilities::NewL() ); |
1427 if ( popupCreateError == KErrNone && connUiUtils ) |
1437 if ( popupCreateError == KErrNone && connUiUtils ) |
1428 { |
1438 { |
1497 MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\ |
1507 MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\ |
1498 - Start Disconnect dialog" ) |
1508 - Start Disconnect dialog" ) |
1499 iDisconnectDlg = CMPMDisconnectDlg::NewL( *const_cast<CMPMServerSession*>(this), |
1509 iDisconnectDlg = CMPMDisconnectDlg::NewL( *const_cast<CMPMServerSession*>(this), |
1500 error, |
1510 error, |
1501 *MyServer().DisconnectQueue() ); |
1511 *MyServer().DisconnectQueue() ); |
|
1512 iDisconnectDialogShown = ETrue; |
1502 return; |
1513 return; |
1503 } |
1514 } |
1504 else |
1515 else |
1505 { |
1516 { |
1506 MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \ |
1517 MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \ |
1858 } |
1869 } |
1859 |
1870 |
1860 // Store message for later usage. |
1871 // Store message for later usage. |
1861 iServerSortSNAPMessage = aMessage; |
1872 iServerSortSNAPMessage = aMessage; |
1862 |
1873 |
1863 TUint32 aSeconds = static_cast<TUint32>( iServerSortSNAPMessage.Int2() ); |
1874 TUint32 seconds = static_cast<TUint32>( iServerSortSNAPMessage.Int2() ); |
1864 |
1875 |
1865 // To display up to date information the WLAN scan should be done first |
1876 // To display up to date information the WLAN scan should be done first |
1866 iMyServer.Events()->ScanWLANNetworksL( this, |
1877 iMyServer.Events()->ScanWLANNetworksL( this, |
1867 ConnectionId(), |
1878 ConnectionId(), |
1868 EWlanScanCallbackSortSnap, |
1879 EWlanScanCallbackSortSnap, |
1869 aSeconds ); |
1880 seconds ); |
1870 } |
1881 } |
1871 |
1882 |
1872 // ----------------------------------------------------------------------------- |
1883 // ----------------------------------------------------------------------------- |
1873 // CMPMServerSession::CompleteServerSortSNAPL |
1884 // CMPMServerSession::CompleteServerSortSNAPL |
1874 // ----------------------------------------------------------------------------- |
1885 // ----------------------------------------------------------------------------- |
2663 iStoredIapInfo.SetStoredIapInfo( aIapInfo ); |
2674 iStoredIapInfo.SetStoredIapInfo( aIapInfo ); |
2664 return; |
2675 return; |
2665 } |
2676 } |
2666 } |
2677 } |
2667 |
2678 |
2668 TInt err(0); |
|
2669 TInt currentIap = MyServer().GetBMIap( iConnId ); |
2679 TInt currentIap = MyServer().GetBMIap( iConnId ); |
2670 MPMLOGSTRING4( "CMPMServerSession::PrefIAPNotificationL - \ |
2680 MPMLOGSTRING3( "CMPMServerSession::PrefIAPNotificationL - \ |
2671 current iap %d, last notified %d, err %d ", currentIap, iLastNotifiedIap, err ) |
2681 current iap %d, last notified %d ", currentIap, iLastNotifiedIap ) |
2672 if( err != KErrNone ) |
|
2673 { |
|
2674 MPMLOGSTRING( "CMPMServerSession::PrefIAPNotificationL: Connection is not \ |
|
2675 registered for notifications" ) |
|
2676 return; |
|
2677 } |
|
2678 |
2682 |
2679 TBool iapTypeLanOrWlan( EFalse ); |
2683 TBool iapTypeLanOrWlan( EFalse ); |
2680 RAvailableIAPList availableIAPList; |
2684 RAvailableIAPList availableIAPList; |
2681 CleanupClosePushL( availableIAPList ); |
2685 CleanupClosePushL( availableIAPList ); |
2682 TUint32 validateIapId( 0 ); |
2686 TUint32 validateIapId( 0 ); |
2729 validateIapId, |
2733 validateIapId, |
2730 retNetId, |
2734 retNetId, |
2731 iapTypeLanOrWlan, |
2735 iapTypeLanOrWlan, |
2732 *this ); |
2736 *this ); |
2733 |
2737 |
2734 if ( CheckNotifNeed( currentIap, |
2738 if ( CheckNotifNeedL( currentIap, |
2735 iLastNotifiedIap, |
2739 iLastNotifiedIap, |
2736 validateIapId ) ) |
2740 validateIapId ) ) |
2737 { |
2741 { |
2738 MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \ |
2742 MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \ |
2739 Sending pref iap notification connId: 0x%x", iConnId ) |
2743 Sending pref iap notification connId: 0x%x", iConnId ) |
2740 |
2744 |
2741 iLastNotifiedIap = validateIapId; |
2745 iLastNotifiedIap = validateIapId; |
2795 // in available IAP list. |
2799 // in available IAP list. |
2796 // If it's not, then notify error. |
2800 // If it's not, then notify error. |
2797 // |
2801 // |
2798 else |
2802 else |
2799 { |
2803 { |
2800 err = availableIAPList.Find( oldIapId ); |
2804 TInt err = availableIAPList.Find( oldIapId ); |
2801 if( err == KErrNotFound ) |
2805 if( err == KErrNotFound ) |
2802 { |
2806 { |
2803 MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \ |
2807 MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \ |
2804 SNAP 0 and IAP %d not available, notifying error", oldIapId ) |
2808 SNAP 0 and IAP %d not available, notifying error", oldIapId ) |
2805 TRAP_IGNORE( ErrorNotificationL( KErrNotFound, |
2809 TRAP_IGNORE( ErrorNotificationL( KErrNotFound, |
2970 iNotifRequested = EFalse; |
2974 iNotifRequested = EFalse; |
2971 |
2975 |
2972 // Now complete error notification to BM |
2976 // Now complete error notification to BM |
2973 MPMLOGSTRING("CMPMServerSession::ErrorNotificationL - Send error notification" ) |
2977 MPMLOGSTRING("CMPMServerSession::ErrorNotificationL - Send error notification" ) |
2974 iNotifMessage.Complete( KErrNone ); |
2978 iNotifMessage.Complete( KErrNone ); |
2975 } |
|
2976 |
|
2977 // ----------------------------------------------------------------------------- |
|
2978 // CMPMServerSession::IsPhoneOfflineL |
|
2979 // |
|
2980 // Checks if phone is in offline mode or not. |
|
2981 // Return ETrue if phone is in offline mode. |
|
2982 // Return EFalse if phone is not in offline mode. |
|
2983 // ----------------------------------------------------------------------------- |
|
2984 // |
|
2985 TBool CMPMServerSession::IsPhoneOfflineL() const |
|
2986 { |
|
2987 MPMLOGSTRING( "CMPMServerSession::IsPhoneOfflineL" ) |
|
2988 if ( iOfflineFeatureSupported ) |
|
2989 { |
|
2990 CRepository* repository = CRepository::NewLC(KCRUidCoreApplicationUIs); |
|
2991 TInt connAllowed = ECoreAppUIsNetworkConnectionAllowed; |
|
2992 repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed ); |
|
2993 CleanupStack::PopAndDestroy( repository ); |
|
2994 if ( !connAllowed ) |
|
2995 { |
|
2996 MPMLOGSTRING( |
|
2997 "CMPMServerSession::IsPhoneOfflineL Phone is in offline mode" ) |
|
2998 return ETrue; |
|
2999 } |
|
3000 } |
|
3001 MPMLOGSTRING( |
|
3002 "CMPMServerSession::IsPhoneOfflineL Phone is not in offline mode" ) |
|
3003 return EFalse; |
|
3004 } |
2979 } |
3005 |
2980 |
3006 // ----------------------------------------------------------------------------- |
2981 // ----------------------------------------------------------------------------- |
3007 // CMPMServerSession::AvailableUnblacklistedIapsL |
2982 // CMPMServerSession::AvailableUnblacklistedIapsL |
3008 // ----------------------------------------------------------------------------- |
2983 // ----------------------------------------------------------------------------- |
3157 return ETrue; |
3132 return ETrue; |
3158 } |
3133 } |
3159 } |
3134 } |
3160 |
3135 |
3161 // ----------------------------------------------------------------------------- |
3136 // ----------------------------------------------------------------------------- |
3162 // CMPMServerSession::CheckNotifNeed |
3137 // CMPMServerSession::CheckNotifNeedL |
3163 // ----------------------------------------------------------------------------- |
3138 // ----------------------------------------------------------------------------- |
3164 // |
3139 // |
3165 TBool CMPMServerSession::CheckNotifNeed( const TUint32 aCurrentIap, |
3140 TBool CMPMServerSession::CheckNotifNeedL( const TUint32 aCurrentIap, |
3166 const TUint32 aLastNotifiedIap, |
3141 const TUint32 aLastNotifiedIap, |
3167 const TUint32 aValidatedIap ) |
3142 const TUint32 aValidatedIap ) |
3168 { |
3143 { |
3169 TBool retValue( EFalse ); |
3144 TBool retValue( EFalse ); |
3170 |
3145 |
3171 // Get the state of the connection for this Connection Id |
3146 // Get the state of the connection for this Connection Id |
3172 // |
3147 // |
3181 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: current IAP is same preferred IAP, no need to send notification" ) |
3156 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: current IAP is same preferred IAP, no need to send notification" ) |
3182 retValue = EFalse; |
3157 retValue = EFalse; |
3183 } |
3158 } |
3184 else |
3159 else |
3185 { |
3160 { |
3186 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: notif needed" ) |
3161 TCmUsageOfWlan usageOfWlan = MyServer().CommsDatAccess()->ForcedRoamingL(); |
3187 retValue = ETrue; |
3162 |
|
3163 if ( usageOfWlan == ECmUsageOfWlanManual && |
|
3164 MyServer().CommsDatAccess()->CheckWlanL( aValidatedIap ) != ENotWlanIap ) |
|
3165 { |
|
3166 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: WLAN IAP, Switch to WLAN is Manual, no need to send notification" ) |
|
3167 retValue = EFalse; |
|
3168 } |
|
3169 else |
|
3170 { |
|
3171 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: notif needed" ) |
|
3172 retValue = ETrue; |
|
3173 } |
3188 } |
3174 } |
3189 } |
3175 } |
3190 else |
3176 else |
3191 { |
3177 { |
3192 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: Last notified IAP is same as preferred IAP, no need to send notification" ) |
3178 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: Last notified IAP is same as preferred IAP, no need to send notification" ) |
3577 // ----------------------------------------------------------------------------- |
3563 // ----------------------------------------------------------------------------- |
3578 // |
3564 // |
3579 TBool CMPMServerSession::ForcedRoaming() |
3565 TBool CMPMServerSession::ForcedRoaming() |
3580 { |
3566 { |
3581 TBool forcedRoaming( EFalse ); |
3567 TBool forcedRoaming( EFalse ); |
3582 if ( iIapSelection != NULL ) |
3568 if ( iIapSelection ) |
3583 { |
3569 { |
3584 forcedRoaming = iIapSelection->MpmConnPref().ForcedRoaming(); |
3570 forcedRoaming = iIapSelection->MpmConnPref().ForcedRoaming(); |
3585 } |
3571 } |
3586 return forcedRoaming; |
3572 return forcedRoaming; |
3587 } |
3573 } |
3657 // one unfiltered physical IAP still available. If it does not |
3643 // one unfiltered physical IAP still available. If it does not |
3658 // then it cannot be used to establish connection and should |
3644 // then it cannot be used to establish connection and should |
3659 // be filtered. |
3645 // be filtered. |
3660 index = 0; |
3646 index = 0; |
3661 RAvailableIAPList availableIaps; |
3647 RAvailableIAPList availableIaps; |
3662 |
3648 CleanupClosePushL( availableIaps ); |
|
3649 |
3663 for ( TUint i = 0; i < aIapInfo.iCount; i++ ) |
3650 for ( TUint i = 0; i < aIapInfo.iCount; i++ ) |
3664 { |
3651 { |
3665 availableIaps.AppendL( aIapInfo.iIap[i].iIapId ); |
3652 availableIaps.AppendL( aIapInfo.iIap[i].iIapId ); |
3666 } |
3653 } |
3667 |
3654 |