479 // ----------------------------------------------------------------------------- |
479 // ----------------------------------------------------------------------------- |
480 // CMPMServer::RemoveBMConnection |
480 // CMPMServer::RemoveBMConnection |
481 // ----------------------------------------------------------------------------- |
481 // ----------------------------------------------------------------------------- |
482 // |
482 // |
483 void CMPMServer::RemoveBMConnection( const TConnectionId aConnId, |
483 void CMPMServer::RemoveBMConnection( const TConnectionId aConnId, |
484 CMPMServerSession& /*aSession*/ ) |
484 CMPMServerSession& aSession ) |
485 { |
485 { |
486 MPMLOGSTRING2( "CMPMServer::RemoveBMConnection - aConnId = 0x%x", |
486 MPMLOGSTRING2( "CMPMServer::RemoveBMConnection - aConnId = 0x%x", |
487 aConnId ) |
487 aConnId ) |
488 |
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 |
|
496 // This time we are browsing the array from the end to the beginning, |
489 // This time we are browsing the array from the end to the beginning, |
497 // because removing one element from array affects index numbering. |
490 // because removing one element from array affects index numbering. |
498 // |
491 // Decrement i by one, because count is n, but indexes in array are 0 .. n-1 |
499 for ( TInt i = count; i >= 0; i-- ) |
492 for ( TInt i = iActiveBMConns.Count() - 1; i >= 0; i-- ) |
500 { |
493 { |
501 if ( iActiveBMConns[i].iConnInfo.iConnId == aConnId ) |
494 if ( iActiveBMConns[i].iConnInfo.iConnId == aConnId ) |
502 { |
495 { |
|
496 |
|
497 TInt closeIapId = iActiveBMConns[i].iConnInfo.iIapId; |
|
498 if ( !closeIapId ) |
|
499 { |
|
500 TRAP_IGNORE( closeIapId = aSession.IapSelectionL()->MpmConnPref().IapId() ); |
|
501 } |
|
502 |
503 // If Connection Id found, remove it. |
503 // If Connection Id found, remove it. |
504 // |
504 // |
505 iActiveBMConns.Remove( i ); |
505 iActiveBMConns.Remove( i ); |
|
506 CheckIapForDisconnect( closeIapId ); |
506 } |
507 } |
507 } |
508 } |
508 |
509 |
509 #ifdef _DEBUG |
510 #ifdef _DEBUG |
510 // Dump array of active connections to log in order to support testing. |
511 // Dump array of active connections to log in order to support testing. |
810 { |
811 { |
811 MPMLOGSTRING3( |
812 MPMLOGSTRING3( |
812 "CMPMServer::RemoveBMIAPConnection - aIapId = %i, aConnId = 0x%x", |
813 "CMPMServer::RemoveBMIAPConnection - aIapId = %i, aConnId = 0x%x", |
813 aIapId, aConnId ) |
814 aIapId, aConnId ) |
814 |
815 |
815 TActiveBMConn conn; |
|
816 conn.iConnInfo.iIapId = aIapId; |
|
817 |
|
818 // The IAP connection lifetime is determined by the two calls |
816 // The IAP connection lifetime is determined by the two calls |
819 // IAPConnectionStarted and IAPConnectionStopped. |
817 // IAPConnectionStarted and IAPConnectionStopped. |
820 // |
|
821 TInt count = iActiveBMConns.Count(); |
|
822 |
|
823 // Decrement by one, because count is n, |
|
824 // but indexes in array are 0 .. n-1. |
|
825 // |
|
826 count--; |
|
827 |
818 |
828 // This time we are browsing the array from the end to the beginning, |
819 // This time we are browsing the array from the end to the beginning, |
829 // because removing one element from array affects index numbering. |
820 // because removing one element from array affects index numbering. |
830 // |
821 // Decrement i by one, because count is n, but indexes in array are 0 .. n-1 |
831 for ( TInt i = count; i >= 0; i-- ) |
822 for ( TInt i = iActiveBMConns.Count() - 1; i >= 0; i-- ) |
832 { |
823 { |
833 if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId ) |
824 if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId ) |
834 { |
825 { |
835 if ( iActiveBMConns[i].iConnInfo.iSnap == 0 ) |
826 if ( iActiveBMConns[i].iConnInfo.iSnap == 0 ) |
836 { |
827 { |
913 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIap - IAP: %d", |
904 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIap - IAP: %d", |
914 iapInfo.iIap[i].iIapId) |
905 iapInfo.iIap[i].iIapId) |
915 } |
906 } |
916 #endif // _DEBUG |
907 #endif // _DEBUG |
917 |
908 |
|
909 // Read info for forced roaming from Commdat |
|
910 TUint32 maxOpenTransAttempts ( KMaxOpenTransAttempts ) ; |
|
911 TUint32 retryAfter ( KRetryAfter ); |
|
912 TInt err; |
|
913 // CommDat reading might fail because CommDat session could be locked by another process at the moment |
|
914 // So, we may wait/retry to read from CommDat a bit later. |
|
915 TCmUsageOfWlan usageOfWlan ( ECmUsageOfWlanKnown ); |
|
916 do |
|
917 { |
|
918 TRAP ( err, usageOfWlan = CommsDatAccess()->ForcedRoamingL() ); |
|
919 |
|
920 if( err ) |
|
921 { |
|
922 User::After( retryAfter ); |
|
923 } |
|
924 } while( err && maxOpenTransAttempts-- ); |
|
925 |
918 // Start possible forced roaming |
926 // Start possible forced roaming |
919 TCmUsageOfWlan usageOfWlan = CommsDatAccess()->ForcedRoamingL(); |
927 if ( !err ) |
920 if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew ) |
928 { |
921 { |
929 if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew ) |
922 if ( IsWlanConnectionStartedL( CommsDatAccess() ) ) |
930 { |
923 { |
931 if ( IsWlanConnectionStartedL( CommsDatAccess() ) ) |
924 iConnMonIapInfo = aIapInfo; |
932 { |
|
933 iConnMonIapInfo = aIapInfo; |
925 |
934 |
926 if ( iRoamingToWlanPeriodic ) |
935 if ( iRoamingToWlanPeriodic ) |
927 { |
936 { |
928 iRoamingToWlanPeriodic->Cancel(); |
937 iRoamingToWlanPeriodic->Cancel(); |
|
938 } |
|
939 else |
|
940 { |
|
941 iRoamingToWlanPeriodic = CPeriodic::NewL( |
|
942 CActive::EPriorityStandard ); |
|
943 } |
|
944 // start periodic object that calls StartForcedRoamingToWlanL after 10s. |
|
945 // this handles the case when new wlan connection is |
|
946 // started from e.g. wlan sniffer but IAP is not yet in Internet SNAP |
|
947 iRoamingToWlanPeriodic->Start( |
|
948 TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), |
|
949 TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), |
|
950 TCallBack( StartForcedRoamingToConnectedWlanL, this ) ); |
929 } |
951 } |
930 else |
952 else |
931 { |
953 { |
932 iRoamingToWlanPeriodic = CPeriodic::NewL( |
954 StartForcedRoamingToWlanL( iapInfo ); |
933 CActive::EPriorityStandard ); |
955 } |
934 } |
956 |
935 // start periodic object that calls StartForcedRoamingToWlanL after 10s. |
957 StartForcedRoamingFromWlanL( iapInfo ); |
936 // this handles the case when new wlan connection is |
958 } |
937 // started from e.g. wlan sniffer but IAP is not yet in Internet SNAP |
959 } |
938 iRoamingToWlanPeriodic->Start( |
960 else |
939 TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), |
961 { |
940 TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), |
962 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIapL - \ |
941 TCallBack( StartForcedRoamingToConnectedWlanL, this ) ); |
963 reading info for forced roaming fails with err %d, forced roaming fails", err ) |
942 } |
|
943 else |
|
944 { |
|
945 StartForcedRoamingToWlanL( iapInfo ); |
|
946 } |
|
947 |
|
948 StartForcedRoamingFromWlanL( iapInfo ); |
|
949 } |
964 } |
950 |
965 |
951 // Send notifications for all sessions |
966 // Send notifications for all sessions |
952 SendPrefIAPNotificationL(); |
967 SendPrefIAPNotificationL(); |
953 } |
968 } |
1833 // --------------------------------------------------------------------------- |
1848 // --------------------------------------------------------------------------- |
1834 // CMPMServer::StopCellularConns |
1849 // CMPMServer::StopCellularConns |
1835 // Stop all cellular connections except MMS |
1850 // Stop all cellular connections except MMS |
1836 // --------------------------------------------------------------------------- |
1851 // --------------------------------------------------------------------------- |
1837 // |
1852 // |
1838 void CMPMServer::StopCellularConns() |
1853 void CMPMServer::StopCellularConns( TBool aSilentOnly ) |
1839 { |
1854 { |
1840 MPMLOGSTRING( "CMPMServer::StopCellularConns" ) |
1855 MPMLOGSTRING( "CMPMServer::StopCellularConns" ) |
1841 |
1856 |
1842 TUint32 iapId; |
1857 TUint32 iapId; |
1843 TMPMBearerType bearerType = EMPMBearerTypeNone; |
1858 TMPMBearerType bearerType = EMPMBearerTypeNone; |
1862 err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap ); |
1877 err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap ); |
1863 // Check that it's not MMS IAP. |
1878 // Check that it's not MMS IAP. |
1864 if (!(err == KErrNone && iapId == mmsIap)) |
1879 if (!(err == KErrNone && iapId == mmsIap)) |
1865 { |
1880 { |
1866 // Stop the conn / IAP. |
1881 // Stop the conn / IAP. |
1867 StopConnections( iapId ); |
1882 if ( aSilentOnly ) |
|
1883 { |
|
1884 CheckIapForDisconnect( iapId ); |
|
1885 } |
|
1886 else |
|
1887 { |
|
1888 StopConnections( iapId ); |
|
1889 } |
1868 stoppedIaps.Append( iapId ); |
1890 stoppedIaps.Append( iapId ); |
1869 } |
1891 } |
1870 } |
1892 } |
1871 } |
1893 } |
1872 } |
1894 } |
2116 } |
2138 } |
2117 return retval; |
2139 return retval; |
2118 } |
2140 } |
2119 |
2141 |
2120 // ----------------------------------------------------------------------------- |
2142 // ----------------------------------------------------------------------------- |
|
2143 // CMPMServer::CheckIapForDisconnect |
|
2144 // ----------------------------------------------------------------------------- |
|
2145 // |
|
2146 void CMPMServer::CheckIapForDisconnect( TInt aIapId ) |
|
2147 { |
|
2148 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - aIapId = 0x%x", |
|
2149 aIapId ) |
|
2150 |
|
2151 // Fix for case ou1cimx1#468999: stop sessions to cellular iap |
|
2152 // when there is only silent connections to it, and cellular usage is set |
|
2153 // to always ask |
|
2154 |
|
2155 // Check iap type and usage policy |
|
2156 TMPMBearerType bearerType( EMPMBearerTypeNone ); |
|
2157 TRAP_IGNORE( bearerType = CommsDatAccess()->GetBearerTypeL( aIapId ) ); |
|
2158 |
|
2159 TBool closeIap = ( bearerType == EMPMBearerTypePacketData |
|
2160 && DataUsageWatcher()->CellularDataUsage() == ECmCellularDataUsageConfirm ); |
|
2161 |
|
2162 // No need to put iapSessions to CleanupStack; there are no leaves |
|
2163 RPointerArray<CMPMServerSession> iapSessions; |
|
2164 if ( closeIap ) |
|
2165 { |
|
2166 // Check for non-silent sessions to iap |
|
2167 // closeIap is left true also when there are no sessions using the iap |
|
2168 for ( TInt i = 0; i < iActiveBMConns.Count(); i++ ) |
|
2169 { |
|
2170 |
|
2171 CMPMServerSession* session |
|
2172 = GetServerSession( iActiveBMConns[i].iConnInfo.iConnId ); |
|
2173 |
|
2174 TInt sessionIapId = iActiveBMConns[i].iConnInfo.iIapId; |
|
2175 if ( !sessionIapId ) |
|
2176 { |
|
2177 TRAP_IGNORE( sessionIapId = session->IapSelectionL()->MpmConnPref().IapId() ); |
|
2178 } |
|
2179 |
|
2180 if ( sessionIapId == aIapId ) |
|
2181 { |
|
2182 iapSessions.Append( session ); // Don't mind if Append fails |
|
2183 |
|
2184 TBool silent( ETrue ); |
|
2185 TRAP_IGNORE( silent = session->IapSelectionL()->MpmConnPref().NoteBehaviour() |
|
2186 & TExtendedConnPref::ENoteBehaviourConnDisableNotes ); |
|
2187 if ( !silent ) |
|
2188 { |
|
2189 // Non-silent session to iap found |
|
2190 closeIap = EFalse; |
|
2191 break; // for |
|
2192 } |
|
2193 } |
|
2194 } |
|
2195 } |
|
2196 |
|
2197 if ( closeIap ) |
|
2198 { |
|
2199 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping silent sessions to iap 0x%x", |
|
2200 aIapId ) |
|
2201 // Stop all (silent) sessions to iap |
|
2202 for ( TInt i = 0; i < iapSessions.Count(); i++) |
|
2203 { |
|
2204 MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping connId 0x%x", |
|
2205 iapSessions[i]->ConnectionId()); |
|
2206 iapSessions[i]->StopConnection(); |
|
2207 } |
|
2208 } |
|
2209 |
|
2210 iapSessions.Close(); |
|
2211 |
|
2212 } |
|
2213 |
|
2214 |
|
2215 // ----------------------------------------------------------------------------- |
2121 // TMPMBlackListConnId::Append |
2216 // TMPMBlackListConnId::Append |
2122 // ----------------------------------------------------------------------------- |
2217 // ----------------------------------------------------------------------------- |
2123 // |
2218 // |
2124 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory ) |
2219 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory ) |
2125 { |
2220 { |