23 // INCLUDE FILES |
23 // INCLUDE FILES |
24 #include <commdb.h> |
24 #include <commdb.h> |
25 #include <etel3rdparty.h> // Voice call notification |
25 #include <etel3rdparty.h> // Voice call notification |
26 #include <mmtsy_names.h> // KMmTsyModuleName |
26 #include <mmtsy_names.h> // KMmTsyModuleName |
27 #include <centralrepository.h> |
27 #include <centralrepository.h> |
|
28 #include <es_sock_partner.h> |
28 |
29 |
29 #include "mpmserver.h" |
30 #include "mpmserver.h" |
30 #include "mpmserversession.h" |
31 #include "mpmserversession.h" |
31 #include "mpmconnmonevents.h" |
32 #include "mpmconnmonevents.h" |
32 #include "mpmlogger.h" |
33 #include "mpmlogger.h" |
39 #include "mpmcommsdataccess.h" |
40 #include "mpmcommsdataccess.h" |
40 #include "mpmwlanquerydialog.h" |
41 #include "mpmwlanquerydialog.h" |
41 #include "mpmdialog.h" |
42 #include "mpmdialog.h" |
42 #include "mpmprivatecrkeys.h" |
43 #include "mpmprivatecrkeys.h" |
43 #include "mpmcsidwatcher.h" |
44 #include "mpmcsidwatcher.h" |
|
45 #include "mpmdatausagewatcher.h" |
|
46 #include "mpmpropertydef.h" |
44 |
47 |
45 // ============================= LOCAL FUNCTIONS =============================== |
48 // ============================= LOCAL FUNCTIONS =============================== |
46 |
49 |
47 // ----------------------------------------------------------------------------- |
50 // ----------------------------------------------------------------------------- |
48 // PanicServer |
51 // PanicServer |
168 |
171 |
169 // Create central repository watcher and start it |
172 // Create central repository watcher and start it |
170 iMpmCsIdWatcher = CMpmCsIdWatcher::NewL(); |
173 iMpmCsIdWatcher = CMpmCsIdWatcher::NewL(); |
171 iMpmCsIdWatcher->StartL(); |
174 iMpmCsIdWatcher->StartL(); |
172 |
175 |
|
176 // Create another central repository watcher and start it |
|
177 // TODO: Trapped, because currently it may fatally leave in HW. |
|
178 // (Possibly because of the capability updates of data usage watcher's CR-keys.) |
|
179 TRAPD( duwErr, iMpmDataUsageWatcher = CMpmDataUsageWatcher::NewL( this ) ); |
|
180 if (duwErr == KErrNone) |
|
181 { |
|
182 iMpmDataUsageWatcher->StartL(); |
|
183 } |
|
184 else |
|
185 { |
|
186 iMpmDataUsageWatcher = NULL; |
|
187 MPMLOGSTRING( "CMPMServer::ConstructL: CMpmDataUsageWatcher::NewL() failed!" ) |
|
188 } |
|
189 |
173 // Define P&S keys (snap & iap) for the user connection |
190 // Define P&S keys (snap & iap) for the user connection |
174 TInt ret = RProperty::Define( KMPMUserConnectionCategory, |
191 TInt ret = RProperty::Define( KMPMUserConnectionCategory, |
175 KMPMPSKeyUserConnectionSnap, |
192 KMPMPSKeyUserConnectionSnap, |
176 KMPMUserConnectionSnapType, |
193 KMPMUserConnectionSnapType, |
177 KMPMUserConnectionReadPolicy, |
194 KMPMUserConnectionReadPolicy, |
953 |
972 |
954 // ----------------------------------------------------------------------------- |
973 // ----------------------------------------------------------------------------- |
955 // CMPMServer::NotifyBMPrefIapL |
974 // CMPMServer::NotifyBMPrefIapL |
956 // ----------------------------------------------------------------------------- |
975 // ----------------------------------------------------------------------------- |
957 // |
976 // |
958 void CMPMServer::NotifyBMPrefIapL( const TConnMonIapInfo& aIapInfo ) |
977 void CMPMServer::NotifyBMPrefIapL( const TConnMonIapInfo& aIapInfo, |
|
978 const TPrefIAPNotifCaller aCaller ) |
959 { |
979 { |
960 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIapL - IAPs count: %d", |
980 MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIapL - IAPs count: %d", |
961 aIapInfo.iCount) |
981 aIapInfo.iCount) |
962 TConnMonIapInfo iapInfo = aIapInfo; |
982 TConnMonIapInfo iapInfo = aIapInfo; |
963 |
983 |
982 iSessions.Count() ) |
1002 iSessions.Count() ) |
983 |
1003 |
984 for ( TInt i = 0; i < iSessions.Count(); i++ ) |
1004 for ( TInt i = 0; i < iSessions.Count(); i++ ) |
985 { |
1005 { |
986 iapInfo = iSessions[i]->GetAvailableIAPs( ); |
1006 iapInfo = iSessions[i]->GetAvailableIAPs( ); |
987 iSessions[i]->PrefIAPNotificationL( iapInfo, EConnMon ); |
1007 iSessions[i]->PrefIAPNotificationL( iapInfo, aCaller ); |
988 } |
1008 } |
989 |
1009 |
990 // If a session is displaying connection selection dialog |
1010 // If a session is displaying connection selection dialog |
991 // the contents of the dialog should be updated according to the |
1011 // the contents of the dialog should be updated according to the |
992 // current iap availability |
1012 // current iap availability |
1131 else |
1151 else |
1132 { |
1152 { |
1133 return KErrNotFound; |
1153 return KErrNotFound; |
1134 } |
1154 } |
1135 } |
1155 } |
1136 |
|
1137 |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // CMPMServer::HandleServerUnblackListIap |
|
1140 // ----------------------------------------------------------------------------- |
|
1141 // |
|
1142 TInt CMPMServer::HandleServerUnblackListIap( |
|
1143 const TConnectionId aConnId, |
|
1144 TBlacklistCategory aCategory ) |
|
1145 { |
|
1146 MPMLOGSTRING3( "CMPMServer::HandleServerUnblackListIap -\ |
|
1147 aConnId = 0x%x, aCategory = %i", aConnId, aCategory ) |
|
1148 |
|
1149 TInt i; |
|
1150 TBool found = EFalse; |
|
1151 |
|
1152 found = FindBlacklistedConnIndex( aConnId, i ); |
|
1153 if ( found ) |
|
1154 { |
|
1155 // found blacklisted Connection Id |
|
1156 TMPMBlackListConnId connIdInfo = iBlackListIdList[i]; |
|
1157 iBlackListIdList.Remove( i ); // remove from the list |
|
1158 |
|
1159 found = EFalse; |
|
1160 for (TInt j = 0; j < connIdInfo.Count(); j++) |
|
1161 { |
|
1162 if ( connIdInfo.Category( j ) == aCategory ) |
|
1163 { |
|
1164 // found and remove blacklisted iap |
|
1165 connIdInfo.Remove( j ); |
|
1166 if ( connIdInfo.Count() == 0 ) |
|
1167 { |
|
1168 return KErrNone; |
|
1169 } |
|
1170 |
|
1171 // reinsert connIdInfo at the beginning to reflect activeness |
|
1172 iBlackListIdList.Insert( connIdInfo, 0 ); |
|
1173 return KErrNone; |
|
1174 } |
|
1175 } |
|
1176 // nothing found and reinsert at the beginning |
|
1177 // connIdInfo to reflect activeness |
|
1178 iBlackListIdList.Insert( connIdInfo, 0 ); |
|
1179 return KErrNotFound; |
|
1180 } |
|
1181 else |
|
1182 { |
|
1183 return KErrNotFound; |
|
1184 } |
|
1185 } |
|
1186 |
|
1187 |
1156 |
1188 // ----------------------------------------------------------------------------- |
1157 // ----------------------------------------------------------------------------- |
1189 // CMPMServer::HandleServerUnblackListIap |
1158 // CMPMServer::HandleServerUnblackListIap |
1190 // ----------------------------------------------------------------------------- |
1159 // ----------------------------------------------------------------------------- |
1191 // |
1160 // |
1782 RArray<TUint32> wlanIapIds; |
1751 RArray<TUint32> wlanIapIds; |
1783 CleanupClosePushL( wlanIapIds ); |
1752 CleanupClosePushL( wlanIapIds ); |
1784 RAvailableIAPList iapList; |
1753 RAvailableIAPList iapList; |
1785 CleanupClosePushL( iapList ); |
1754 CleanupClosePushL( iapList ); |
1786 |
1755 |
1787 for ( TInt index = 0; index < aIapInfo.iCount; index++ ) |
1756 for ( TUint index = 0; index < aIapInfo.iCount; index++ ) |
1788 { |
1757 { |
1789 if ( CommsDatAccess()->CheckWlanL( aIapInfo.iIap[index].iIapId ) != ENotWlanIap ) |
1758 if ( CommsDatAccess()->CheckWlanL( aIapInfo.iIap[index].iIapId ) != ENotWlanIap ) |
1790 { |
1759 { |
1791 // Accept only wlan iaps in internet snap |
1760 // Accept only wlan iaps in internet snap |
1792 if ( iCommsDatAccess->IsInternetSnapL( aIapInfo.iIap[index].iIapId, 0 ) ) |
1761 if ( iCommsDatAccess->IsInternetSnapL( aIapInfo.iIap[index].iIapId, 0 ) ) |
1845 |
1814 |
1846 // Copy all available packet data iap ids to own array |
1815 // Copy all available packet data iap ids to own array |
1847 RArray<TUint32> packetDataIapIds; |
1816 RArray<TUint32> packetDataIapIds; |
1848 CleanupClosePushL( packetDataIapIds ); |
1817 CleanupClosePushL( packetDataIapIds ); |
1849 |
1818 |
1850 for ( TInt index = 0; index < aIapInfo.iCount; index++ ) |
1819 for ( TUint index = 0; index < aIapInfo.iCount; index++ ) |
1851 { |
1820 { |
1852 if ( CommsDatAccess()->GetBearerTypeL( aIapInfo.iIap[index].iIapId ) == |
1821 if ( CommsDatAccess()->GetBearerTypeL( aIapInfo.iIap[index].iIapId ) == |
1853 EMPMBearerTypePacketData ) |
1822 EMPMBearerTypePacketData ) |
1854 { |
1823 { |
1855 // Accept only packet data iaps in internet snap |
1824 // Accept only packet data iaps in internet snap |
1874 if ( iCommsDatAccess->CheckWlanL( iActiveBMConns[index].iConnInfo.iIapId ) |
1843 if ( iCommsDatAccess->CheckWlanL( iActiveBMConns[index].iConnInfo.iIapId ) |
1875 == EWlanIap ) |
1844 == EWlanIap ) |
1876 { |
1845 { |
1877 // Check if used WLAN is still available |
1846 // Check if used WLAN is still available |
1878 TBool currentWlanIapAvailable = EFalse; |
1847 TBool currentWlanIapAvailable = EFalse; |
1879 for ( TInt iapIndex = 0; iapIndex < aIapInfo.iCount; iapIndex++ ) |
1848 for ( TUint iapIndex = 0; iapIndex < aIapInfo.iCount; iapIndex++ ) |
1880 { |
1849 { |
1881 if ( aIapInfo.iIap[iapIndex].iIapId == |
1850 if ( aIapInfo.iIap[iapIndex].iIapId == |
1882 iActiveBMConns[index].iConnInfo.iIapId ) |
1851 iActiveBMConns[index].iConnInfo.iIapId ) |
1883 { |
1852 { |
1884 // Current WLAN IAP found from list of available IAPs |
1853 // Current WLAN IAP found from list of available IAPs |
2059 } |
2028 } |
2060 |
2029 |
2061 ASSERT( serverSession != NULL ); |
2030 ASSERT( serverSession != NULL ); |
2062 |
2031 |
2063 return serverSession; |
2032 return serverSession; |
|
2033 } |
|
2034 |
|
2035 // --------------------------------------------------------------------------- |
|
2036 // CMPMServer::StopCellularConns |
|
2037 // Stop all cellular connections except MMS |
|
2038 // --------------------------------------------------------------------------- |
|
2039 // |
|
2040 void CMPMServer::StopCellularConns() |
|
2041 { |
|
2042 MPMLOGSTRING( "CMPMServer::StopCellularConns" ) |
|
2043 |
|
2044 TUint32 iapId; |
|
2045 TMPMBearerType bearerType = EMPMBearerTypeNone; |
|
2046 |
|
2047 // No cleanup stack used cause this function doesn't leave. |
|
2048 RArray<TUint32> stoppedIaps; |
|
2049 |
|
2050 // Check through active connections |
|
2051 for (TInt i = 0; i < iActiveBMConns.Count(); i++) |
|
2052 { |
|
2053 iapId = iActiveBMConns[i].iConnInfo.iIapId; |
|
2054 |
|
2055 // Don't stop the same IAP twice. |
|
2056 if (stoppedIaps.Find( iapId ) == KErrNotFound) |
|
2057 { |
|
2058 TRAPD( err, bearerType = CommsDatAccess()->GetBearerTypeL( iapId ) ); |
|
2059 if (err == KErrNone && |
|
2060 iapId != 0 && |
|
2061 bearerType == EMPMBearerTypePacketData) |
|
2062 { |
|
2063 TInt mmsIap( 0 ); |
|
2064 err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap ); |
|
2065 // Check that it's not MMS IAP. |
|
2066 if (!(err == KErrNone && iapId == mmsIap)) |
|
2067 { |
|
2068 // Stop the conn / IAP. |
|
2069 StopConnections( iapId ); |
|
2070 stoppedIaps.Append( iapId ); |
|
2071 } |
|
2072 } |
|
2073 } |
|
2074 } |
|
2075 stoppedIaps.Close(); |
2064 } |
2076 } |
2065 |
2077 |
2066 // ----------------------------------------------------------------------------- |
2078 // ----------------------------------------------------------------------------- |
2067 // TMPMBlackListConnId::Append |
2079 // TMPMBlackListConnId::Append |
2068 // ----------------------------------------------------------------------------- |
2080 // ----------------------------------------------------------------------------- |