bearermanagement/mpm/src/mpmserver.cpp
changeset 73 70ee5458c95d
parent 72 0c32cf868819
equal deleted inserted replaced
72:0c32cf868819 73:70ee5458c95d
   399 
   399 
   400     if ( index1 == KErrNotFound )
   400     if ( index1 == KErrNotFound )
   401         {
   401         {
   402         // If this connInfo is not yet there, insert it at the end of array
   402         // If this connInfo is not yet there, insert it at the end of array
   403         //
   403         //
   404         iActiveBMConns.Append( conn );
   404         TInt err = iActiveBMConns.Append( conn );
       
   405         if ( err )
       
   406             {
       
   407             MPMLOGSTRING2( "CMPMServer::AppendBMConnection - CRITICAL ERROR, append failed with %d", err )
       
   408             }
   405         }
   409         }
   406     else
   410     else
   407         {
   411         {
   408         // connInfo already active, check whether Connection Id is there
   412         // connInfo already active, check whether Connection Id is there
   409         //
   413         //
   970 
   974 
   971 // -----------------------------------------------------------------------------
   975 // -----------------------------------------------------------------------------
   972 // CMPMServer::HandleServerBlackListIap
   976 // CMPMServer::HandleServerBlackListIap
   973 // -----------------------------------------------------------------------------
   977 // -----------------------------------------------------------------------------
   974 //
   978 //
   975 TInt CMPMServer::HandleServerBlackListIap( const TConnectionId  aConnId,
   979 void CMPMServer::HandleServerBlackListIap(
   976                                            TUint32              aIapId, 
   980         const TConnectionId aConnId,
   977                                            TBlacklistCategory   aCategory )
   981         TUint32 aIapId,
   978     {
   982         TBlacklistCategory aCategory )
   979     MPMLOGSTRING3(
   983     {
   980         "CMPMServer::HandleServerBlackListIap - aConnId = 0x%x, iapId = %i",
   984     MPMLOGSTRING3( "CMPMServer::HandleServerBlackListIap - aConnId = 0x%x, iapId = %i", aConnId, aIapId )
   981         aConnId, aIapId )
   985     MPMLOGSTRING2( "CMPMServer::HandleServerBlackListIap - aCategory = %i", aCategory )
   982 
   986 
   983     MPMLOGSTRING2(
   987     BlackListIap( aConnId, aIapId, aCategory );
   984         "CMPMServer::HandleServerBlackListIap - aCategory = %i", aCategory )
   988 
   985 
   989     TUint32 presumedIap = Events()->PresumedIapId( aConnId, aIapId );
   986     BlackListIap( aConnId, aIapId, aCategory ); 
   990     if ( ( presumedIap != 0 ) && ( presumedIap != aIapId ) )
   987 
   991         {
   988     TUint32 presumedIap = Events()->PresumedIapId( aConnId, 
   992         MPMLOGSTRING2( "CMPMServer::HandleServerBlackListIap - presumedIap = %i", presumedIap )
   989                                                    aIapId );
   993         BlackListIap( aConnId, presumedIap, aCategory );
   990     if ( ( presumedIap != 0 ) && 
   994         }
   991          ( presumedIap != aIapId ) )
   995     }
   992         {
       
   993         MPMLOGSTRING2(
       
   994             "CMPMServer::HandleServerBlackListIap - presumedIap = %i",
       
   995             presumedIap )
       
   996         BlackListIap( aConnId, presumedIap, aCategory ); 
       
   997         }
       
   998 
       
   999     return KErrNone;
       
  1000     }
       
  1001 
       
  1002 
   996 
  1003 // -----------------------------------------------------------------------------
   997 // -----------------------------------------------------------------------------
  1004 // CMPMServer::BlackListIap
   998 // CMPMServer::BlackListIap
  1005 // -----------------------------------------------------------------------------
   999 // -----------------------------------------------------------------------------
  1006 //
  1000 //
  1007 TInt CMPMServer::BlackListIap( const TConnectionId  aConnId,
  1001 void CMPMServer::BlackListIap(
  1008                                TUint32              aIapId, 
  1002         const TConnectionId aConnId,
  1009                                TBlacklistCategory   aCategory )
  1003         TUint32 aIapId,
  1010     {
  1004         TBlacklistCategory aCategory )
  1011     TInt i;
  1005     {
  1012     TBool found = EFalse;
  1006     TInt index( 0 );
  1013 
  1007     TBool found( EFalse );
  1014     found = FindBlacklistedConnIndex( aConnId, i );
  1008 
       
  1009     found = FindBlacklistedConnIndex( aConnId, index );
  1015     if ( found )
  1010     if ( found )
  1016         {
  1011         {
  1017         TMPMBlackListConnId connIdInfo = iBlackListIdList[i];
  1012         TMPMBlackListConnId connIdInfo = iBlackListIdList[index];
  1018         connIdInfo.Append( aIapId, aCategory );
  1013         connIdInfo.Append( aIapId, aCategory );
  1019         iBlackListIdList.Remove( i );
  1014         // Since TMPMBlackListConnId is NOT really a T-class, Remove() then Insert() is necessary.
  1020         iBlackListIdList.Insert( connIdInfo, 0 );
  1015         iBlackListIdList.Remove( index );
       
  1016         (void) iBlackListIdList.Insert( connIdInfo, 0 ); // Errors ignored intentionally.
  1021         }
  1017         }
  1022     else
  1018     else
  1023         {
  1019         {
       
  1020         TInt err( KErrNone );
  1024         TMPMBlackListConnId connIdInfo;
  1021         TMPMBlackListConnId connIdInfo;
  1025         connIdInfo.iConnId = aConnId;
  1022         connIdInfo.iConnId = aConnId;
  1026         connIdInfo.Append( aIapId, aCategory );
  1023         connIdInfo.Append( aIapId, aCategory );
  1027         iBlackListIdList.Insert( connIdInfo, 0 );
  1024         if ( connIdInfo.Count() > 0 )
  1028         }
  1025             {
  1029 
  1026             err = iBlackListIdList.Insert( connIdInfo, 0 );
  1030     return KErrNone;
  1027             }
  1031     }
  1028         else
  1032 
  1029             {
       
  1030             err = KErrNoMemory; // Append failed.
       
  1031             }
       
  1032         if ( err )
       
  1033             {
       
  1034             MPMLOGSTRING2( "CMPMServer::BlackListIap - array insert failed, err %d", err )
       
  1035             connIdInfo.Close();
       
  1036             }
       
  1037         }
       
  1038     }
  1033 
  1039 
  1034 // -----------------------------------------------------------------------------
  1040 // -----------------------------------------------------------------------------
  1035 // CMPMServer::HandleServerUnblackListIap
  1041 // CMPMServer::HandleServerUnblackListIap
  1036 // -----------------------------------------------------------------------------
  1042 // -----------------------------------------------------------------------------
  1037 //
  1043 //
  1038 TInt CMPMServer::HandleServerUnblackListIap( 
  1044 TInt CMPMServer::HandleServerUnblackListIap(
  1039     const TConnectionId aConnId,
  1045         const TConnectionId aConnId,
  1040     TUint32             aIapId )
  1046         TUint32 aIapId )
  1041     {
  1047     {
  1042     MPMLOGSTRING3(
  1048     MPMLOGSTRING3( "CMPMServer::HandleServerUnblackListIap - aConnId = 0x%x, iapId = %i", aConnId, aIapId )
  1043         "CMPMServer::HandleServerUnblackListIap - aConnId = 0x%x, iapId = %i"
  1049 
  1044         ,aConnId, aIapId )
  1050     TInt result( KErrNone );
  1045 
  1051     TInt index( 0 );
  1046     TInt i;
       
  1047     TBool found = EFalse;
  1052     TBool found = EFalse;
  1048 
  1053 
  1049     found = FindBlacklistedConnIndex( aConnId, i );
  1054     found = FindBlacklistedConnIndex( aConnId, index );
  1050     if ( found )
  1055     if ( found )
  1051         {
  1056         {
  1052         // found blacklisted Connection Id
  1057         // Found blacklist for connection ID.
       
  1058         TMPMBlackListConnId connIdInfo = iBlackListIdList[index];
       
  1059         MPMLOGSTRING2( "CMPMServer::HandleServerUnblackListIap - connIdInfo count: %d", connIdInfo.Count() )
       
  1060 
       
  1061         if ( aIapId == 0 )
       
  1062             {
       
  1063             // ID 0 will reset blacklist for this connection ID.
       
  1064             MPMLOGSTRING( "CMPMServer::HandleServerUnblackListIap - reset Connection Id blacklisted iap list" );
       
  1065 
       
  1066             iBlackListIdList.Remove( index ); // Remove blacklist from array.
       
  1067             connIdInfo.Close();
       
  1068             result = KErrNone;
       
  1069             }
       
  1070         else
       
  1071             {
       
  1072             result = KErrNotFound;
       
  1073             for ( TInt j = 0; j < connIdInfo.Count(); j++ )
       
  1074                 {
       
  1075                 if ( connIdInfo.Iap( j ) == aIapId )
       
  1076                     {
       
  1077                     // IAP found, unblacklist it.
       
  1078                     iBlackListIdList.Remove( index ); // Remove blacklist from array.
       
  1079                     if ( connIdInfo.Count() > 1 )
       
  1080                         {
       
  1081                         connIdInfo.Remove( j );
       
  1082                         // Blacklist is not empty, insert the changed blacklist back to array.
       
  1083                         (void) iBlackListIdList.Insert( connIdInfo, 0 ); // Errors ignored intentionally.
       
  1084                         }
       
  1085                     else
       
  1086                         {
       
  1087                         connIdInfo.Close();
       
  1088                         }
       
  1089                     MPMLOGSTRING2( "CMPMServer::HandleServerUnblackListIap - removed blacklisted iap in index = %d", j )
       
  1090                     result = KErrNone;
       
  1091                     break;
       
  1092                     }
       
  1093                 }
       
  1094             }
       
  1095         }
       
  1096     else
       
  1097         {
       
  1098         MPMLOGSTRING( "CMPMServer::HandleServerUnblackListIap - not found blacklisted Connection Id" )
       
  1099         result = KErrNotFound;
       
  1100         }
       
  1101     return result;
       
  1102     }
       
  1103 
       
  1104 // -----------------------------------------------------------------------------
       
  1105 // CMPMServer::HandleServerUnblackListIap
       
  1106 // -----------------------------------------------------------------------------
       
  1107 //
       
  1108 void CMPMServer::HandleServerUnblackListIap(
       
  1109         TBlacklistCategory aCategory )
       
  1110     {
       
  1111     MPMLOGSTRING3( "CMPMServer::HandleServerUnblackListIap - aCategory = %i blacklisted Id count = %d",
       
  1112             aCategory, iBlackListIdList.Count() )
       
  1113 
       
  1114     for ( TInt i = iBlackListIdList.Count() - 1; i >= 0; i-- )
       
  1115         {
  1053         TMPMBlackListConnId connIdInfo = iBlackListIdList[i];
  1116         TMPMBlackListConnId connIdInfo = iBlackListIdList[i];
  1054         iBlackListIdList.Remove( i ); // remove from the list 
  1117         iBlackListIdList.Remove( i ); // Remove blacklist from array.
  1055         
  1118         MPMLOGSTRING3( "CMPMServer::HandleServerUnblackListIap - aConnId = 0x%x, blacklisted IapId count = %d",
  1056         MPMLOGSTRING2( "CMPMServer::HandleServerUnblackListIap - \
  1119                 connIdInfo.iConnId, connIdInfo.Count() )
  1057 connIdInfo count: %d", connIdInfo.Count() )
  1120 
  1058 
  1121         for ( TInt j = connIdInfo.Count() - 1; j >= 0; j-- )
  1059         if ( aIapId == 0 )
  1122             {
  1060             { // 0 will reset Connection Id blacklisted iap list 
  1123             if ( connIdInfo.Category( j ) == aCategory )
  1061             MPMLOGSTRING( "CMPMServer::HandleServerUnblackListIap - \
  1124                 {
  1062 reset Connection Id blacklisted iap list" )
  1125                 // Found matching category, unblacklisting IAP.
  1063 
  1126                 MPMLOGSTRING3( "CMPMServer::HandleServerUnblackListIap - removed blacklisted iap id %i in index: %d",
  1064             connIdInfo.Close();
  1127                         connIdInfo.Iap( j ), j )
  1065             return KErrNone;
  1128                 connIdInfo.Remove( j );
  1066             }
  1129                 }
  1067 
  1130             }
  1068         found = EFalse;
  1131         // If any IAPs remain in the blacklist, insert it back into the array.
  1069         for (TInt j = 0; j < connIdInfo.Count(); j++)
  1132         if ( connIdInfo.Count() > 0 )
  1070             {
  1133             {
  1071             if ( connIdInfo.Iap( j ) == aIapId )
  1134             (void) iBlackListIdList.Insert( connIdInfo, 0 ); // Errors ignored intentionally.
  1072                 {
       
  1073                 // found and remove blacklisted iap
       
  1074                 connIdInfo.Remove( j ); 
       
  1075                 MPMLOGSTRING2( "CMPMServer::HandleServerUnblackListIap - \
       
  1076 removed blacklisted iap in index = %d", j )
       
  1077                 
       
  1078                 if ( connIdInfo.Count() == 0 )
       
  1079                     {
       
  1080                     return KErrNone;
       
  1081                     }
       
  1082 
       
  1083                 // reinsert connIdInfo at the beginning to reflect activeness
       
  1084                 iBlackListIdList.Insert( connIdInfo, 0 ); 
       
  1085                 return KErrNone;
       
  1086                 }
       
  1087             }
       
  1088         // nothing found and reinsert at the beginning 
       
  1089         // connIdInfo to reflect activeness
       
  1090         iBlackListIdList.Insert( connIdInfo, 0 ); 
       
  1091         return KErrNotFound;
       
  1092         }
       
  1093     else
       
  1094         {
       
  1095         MPMLOGSTRING( "CMPMServer::HandleServerUnblackListIap - \
       
  1096 not found blacklisted Connection Id" )
       
  1097         return KErrNotFound;
       
  1098         }
       
  1099     }
       
  1100 
       
  1101 // -----------------------------------------------------------------------------
       
  1102 // CMPMServer::HandleServerUnblackListIap
       
  1103 // -----------------------------------------------------------------------------
       
  1104 //
       
  1105 void CMPMServer::HandleServerUnblackListIap( 
       
  1106     TBlacklistCategory  aCategory )
       
  1107     {
       
  1108     MPMLOGSTRING3( "CMPMServer::HandleServerUnblackListIap -\
       
  1109 aCategory = %i blacklisted Id count = %d", 
       
  1110                    aCategory, iBlackListIdList.Count() )
       
  1111 
       
  1112     for (TInt i = iBlackListIdList.Count()-1; i >= 0; i--)
       
  1113         {
       
  1114         // found blacklisted Connection Id
       
  1115         TMPMBlackListConnId connIdInfo = iBlackListIdList[i];
       
  1116         iBlackListIdList.Remove( i ); // remove from the list 
       
  1117 
       
  1118         MPMLOGSTRING3( "CMPMServer::HandleServerUnblackListIap - \
       
  1119 aConnId = 0x%x, blacklisted IapId count = %d", connIdInfo.iConnId, 
       
  1120         connIdInfo.Count() )
       
  1121         
       
  1122         for (TInt j = connIdInfo.Count()-1; j >= 0; j--)
       
  1123             {
       
  1124             if ( connIdInfo.Category( j ) == aCategory ) 
       
  1125                 {
       
  1126                 // found and remove blacklisted iap
       
  1127                 MPMLOGSTRING3( "CMPMServer::HandleServerUnblackListIap - \
       
  1128 removed blacklisted iap id %i in index: %d", connIdInfo.Iap( j ), j )
       
  1129                 connIdInfo.Remove( j ); 
       
  1130                 }
       
  1131             }
       
  1132         // If any blacklisted iaps remain reinsert at the 
       
  1133         // beginning connIdInfo to reflect activeness
       
  1134         //
       
  1135         if( connIdInfo.Count() > 0 )
       
  1136             {
       
  1137             MPMLOGSTRING( "reinsert connIdInfo to reflect activeness" )
       
  1138             iBlackListIdList.Insert( connIdInfo, 0 );             
       
  1139             }
  1135             }
  1140         }
  1136         }
  1141     }
  1137     }
  1142 
  1138 
  1143 // -----------------------------------------------------------------------------
  1139 // -----------------------------------------------------------------------------
  1144 // CMPMServer::GetBlacklistedIAP
  1140 // CMPMServer::GetBlacklistedIAP
  1145 // -----------------------------------------------------------------------------
  1141 // -----------------------------------------------------------------------------
  1146 //
  1142 //
  1147 TInt CMPMServer::GetBlacklistedIAP( TConnectionId    aConnId, 
  1143 void CMPMServer::GetBlacklistedIAP(
  1148                                     RArray<TUint32> &aBlacklistedIAP )
  1144         TConnectionId aConnId,
  1149     {
  1145         RArray<TUint32>& aBlacklistedIAP )
  1150     TInt  i;
  1146     {
  1151     TBool found = EFalse;
  1147     TInt index( 0 );
  1152 
  1148     TBool found( EFalse );
  1153     found = FindBlacklistedConnIndex( aConnId, i );
  1149 
  1154     if ( !found )
  1150     found = FindBlacklistedConnIndex( aConnId, index );
  1155         {
  1151     if ( found )
  1156         return KErrNotFound;
  1152         {
  1157         }
  1153         TMPMBlackListConnId connIdInfo = iBlackListIdList[index];
  1158 
  1154         for ( TInt j = 0; j < connIdInfo.Count(); j++ )
  1159     TMPMBlackListConnId connIdInfo = iBlackListIdList[i];
  1155             {
  1160     iBlackListIdList.Remove( i );
  1156             (void) aBlacklistedIAP.Append( connIdInfo.Iap( j ) ); // Errors ignored intentionally.
  1161     iBlackListIdList.Insert( connIdInfo, 0 );
  1157             }
  1162 
  1158         }
  1163     for (TInt j = 0; j < connIdInfo.Count(); j++)
  1159     }
  1164         {
       
  1165         aBlacklistedIAP.Append( connIdInfo.Iap( j ) );
       
  1166         }
       
  1167 
       
  1168     return KErrNone;
       
  1169     }
       
  1170 
       
  1171 
  1160 
  1172 // -----------------------------------------------------------------------------
  1161 // -----------------------------------------------------------------------------
  1173 // CMPMServer::GetBlacklistedIAP
  1162 // CMPMServer::GetBlacklistedIAP
  1174 // -----------------------------------------------------------------------------
  1163 // -----------------------------------------------------------------------------
  1175 //
  1164 //
  1176 TInt CMPMServer::GetBlacklistedIAP( RArray<TUint32> &aBlacklistedIAP )
  1165 void CMPMServer::GetBlacklistedIAP( RArray<TUint32>& aBlacklistedIAP )
  1177     {
  1166     {
  1178     // Returns all blacklisted IAPs regardless of Connection Id 
  1167     // Returns all blacklisted IAPs regardless of connection ID.
  1179     // 
       
  1180     for ( TInt i( 0 ); i < iBlackListIdList.Count(); i++ )
  1168     for ( TInt i( 0 ); i < iBlackListIdList.Count(); i++ )
  1181         {
  1169         {
  1182         for ( TInt j( 0 ); j < iBlackListIdList[i].Count(); 
  1170         for ( TInt j( 0 ); j < iBlackListIdList[i].Count(); j++ )
  1183               j++ )
  1171             {
  1184             {
  1172             // Inserts an object into the array in ascending unsigned
  1185             // Inserts an object into the array in ascending unsigned 
  1173             // key order. No duplicate entries are permitted.
  1186             // key order. No duplicate entries are permitted. 
  1174             //
  1187             // 
  1175             // The array remains unchanged following an attempt to
  1188             // The array remains unchanged following an attempt to 
       
  1189             // insert a duplicate entry.
  1176             // insert a duplicate entry.
  1190             // 
  1177             //
  1191             aBlacklistedIAP.InsertInUnsignedKeyOrder( 
  1178             (void) aBlacklistedIAP.InsertInUnsignedKeyOrder( iBlackListIdList[i].Iap( j ) ); // Errors ignored intentionally.
  1192                                     iBlackListIdList[i].Iap( j ) );
  1179             }
  1193             }
  1180         }
  1194         }
  1181     }
  1195     return KErrNone;
       
  1196     }
       
  1197 
       
  1198 
  1182 
  1199 // -----------------------------------------------------------------------------
  1183 // -----------------------------------------------------------------------------
  1200 // CMPMServer::FindId
  1184 // CMPMServer::FindId
  1201 // -----------------------------------------------------------------------------
  1185 // -----------------------------------------------------------------------------
  1202 //
  1186 //
  1203 TBool CMPMServer::FindBlacklistedConnIndex( const TConnectionId aConnId, 
  1187 TBool CMPMServer::FindBlacklistedConnIndex(
  1204                                             TInt                &aIndex )
  1188         const TConnectionId aConnId,
  1205     {
  1189         TInt& aIndex )
  1206     TInt  i;
  1190     {
  1207     TBool found = EFalse;
  1191     TBool found( EFalse );
  1208 
  1192     for ( TInt i = 0; i < iBlackListIdList.Count(); i++ )
  1209     for (i = 0;( (i < iBlackListIdList.Count()) && !found ); i++)
       
  1210         {
  1193         {
  1211         if ( iBlackListIdList[i].iConnId == aConnId )
  1194         if ( iBlackListIdList[i].iConnId == aConnId )
  1212             {
  1195             {
  1213             found = ETrue;
  1196             found = ETrue;
  1214             }
  1197             aIndex = i;
  1215         }
  1198             break;
  1216     i--; // Since i is incremented after finding the correct iConnId
  1199             }
  1217     aIndex = i;
  1200         }
  1218     return found;
  1201     return found;
  1219     }
  1202     }
  1220 
       
  1221 
  1203 
  1222 // -----------------------------------------------------------------------------
  1204 // -----------------------------------------------------------------------------
  1223 // CMPMServer::IsVoiceCallActiveL
  1205 // CMPMServer::IsVoiceCallActiveL
  1224 // 
  1206 // 
  1225 // Checks if voice call is active or not.
  1207 // Checks if voice call is active or not.
  1852 //
  1834 //
  1853 void CMPMServer::StopCellularConns( TBool aSilentOnly )
  1835 void CMPMServer::StopCellularConns( TBool aSilentOnly )
  1854     {
  1836     {
  1855     MPMLOGSTRING( "CMPMServer::StopCellularConns" )
  1837     MPMLOGSTRING( "CMPMServer::StopCellularConns" )
  1856 
  1838 
  1857     TUint32 iapId;
  1839     TUint32 iapId( 0 );
  1858 	TMPMBearerType bearerType = EMPMBearerTypeNone;
  1840 	TMPMBearerType bearerType = EMPMBearerTypeNone;
  1859 
  1841 
  1860 	// No cleanup stack used cause this function doesn't leave.
  1842 	// No cleanup stack used cause this function doesn't leave.
  1861     RArray<TUint32> stoppedIaps;
  1843     RArray<TUint32> stoppedIaps;
  1862 
  1844 
  1863     // Check through active connections
  1845     // Check through active connections.
  1864     for (TInt i = 0; i < iActiveBMConns.Count(); i++)
  1846     for ( TInt i = 0; i < iActiveBMConns.Count(); i++ )
  1865         {
  1847         {
  1866         iapId = iActiveBMConns[i].iConnInfo.iIapId;
  1848         iapId = iActiveBMConns[i].iConnInfo.iIapId;
  1867 
  1849 
  1868         // Don't stop the same IAP twice.
  1850         // Don't stop the same IAP twice. (Trying to stop same IAP many times
  1869         if (stoppedIaps.Find( iapId ) == KErrNotFound)
  1851         // is not really a problem, just slows things a bit).
       
  1852         if ( iapId != 0 && stoppedIaps.Find( iapId ) == KErrNotFound )
  1870             {
  1853             {
  1871             TRAPD( err, bearerType = CommsDatAccess()->GetBearerTypeL( iapId ) );
  1854             TRAPD( err, bearerType = CommsDatAccess()->GetBearerTypeL( iapId ) );
  1872             if (err == KErrNone &&
  1855             if ( err == KErrNone && bearerType == EMPMBearerTypePacketData )
  1873                     iapId != 0 &&
       
  1874                     bearerType == EMPMBearerTypePacketData)
       
  1875                 {
  1856                 {
  1876                 TInt mmsIap( 0 );
  1857                 TInt mmsIap( 0 );
  1877                 err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap );
  1858                 err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap );
  1878                 // Check that it's not MMS IAP.
  1859                 // Check that it's not MMS IAP.
  1879                 if (!(err == KErrNone && iapId == mmsIap))
  1860                 if ( !( err == KErrNone && iapId == mmsIap ) )
  1880                     {
  1861                     {
  1881                     // Stop the conn / IAP.
  1862                     // Stop the conn / IAP.
  1882 					if ( aSilentOnly )
  1863 					if ( aSilentOnly )
  1883                         {
  1864                         {
  1884                         CheckIapForDisconnect( iapId );
  1865                         CheckIapForDisconnect( iapId );
  1885                         }
  1866                         }
  1886                     else
  1867                     else
  1887                         {
  1868                         {
  1888                         StopConnections( iapId );
  1869                         StopConnections( iapId );
  1889                         }
  1870                         }
  1890                     stoppedIaps.Append( iapId );
  1871                     (void) stoppedIaps.Append( iapId ); // Errors ignored intentionally.
  1891                     }
  1872                     }
  1892                 }
  1873                 }
  1893             }
  1874             }
  1894         }
  1875         }
  1895     stoppedIaps.Close();
  1876     stoppedIaps.Close();
  2143 // CMPMServer::CheckIapForDisconnect
  2124 // CMPMServer::CheckIapForDisconnect
  2144 // -----------------------------------------------------------------------------
  2125 // -----------------------------------------------------------------------------
  2145 //
  2126 //
  2146 void CMPMServer::CheckIapForDisconnect( TInt aIapId )
  2127 void CMPMServer::CheckIapForDisconnect( TInt aIapId )
  2147     {
  2128     {
  2148     MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - aIapId = 0x%x", 
  2129     MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - aIapId = 0x%x", aIapId )
  2149         aIapId )
  2130 
  2150 
  2131     // Stop sessions to cellular iap when there is only silent connections to
  2151     // Fix for case ou1cimx1#468999: stop sessions to cellular iap
  2132     // it, and cellular usage is set to always ask.
  2152     // when there is only silent connections to it, and cellular usage is set
  2133 
  2153     // to always ask
       
  2154     
       
  2155     // Check iap type and usage policy
  2134     // Check iap type and usage policy
  2156     TMPMBearerType bearerType( EMPMBearerTypeNone );
  2135     TMPMBearerType bearerType( EMPMBearerTypeNone );
  2157     TRAP_IGNORE( bearerType = CommsDatAccess()->GetBearerTypeL( aIapId ) );
  2136     TRAP_IGNORE( bearerType = CommsDatAccess()->GetBearerTypeL( aIapId ) );
  2158 
  2137 
  2159     TBool closeIap = ( bearerType == EMPMBearerTypePacketData
  2138     TBool closeIap = ( bearerType == EMPMBearerTypePacketData
  2160                 && DataUsageWatcher()->CellularDataUsage() == ECmCellularDataUsageConfirm ); 
  2139                 && DataUsageWatcher()->CellularDataUsage() == ECmCellularDataUsageConfirm );
  2161     
  2140 
  2162     // No need to put iapSessions to CleanupStack; there are no leaves
  2141     // No need to put iapSessions to CleanupStack; there are no leaves
  2163     RPointerArray<CMPMServerSession> iapSessions;
  2142     RPointerArray<CMPMServerSession> iapSessions;
  2164     if ( closeIap )
  2143     if ( closeIap )
  2165         {
  2144         {
  2166         // Check for non-silent sessions to iap
  2145         // Check for non-silent sessions to iap
  2167         // closeIap is left true also when there are no sessions using the iap
  2146         // closeIap is left true also when there are no sessions using the iap
  2168         for ( TInt i = 0; i < iActiveBMConns.Count(); i++ )
  2147         for ( TInt i = 0; i < iActiveBMConns.Count(); i++ )
  2169             {
  2148             {
  2170 
       
  2171             CMPMServerSession* session
  2149             CMPMServerSession* session
  2172                 = GetServerSession( iActiveBMConns[i].iConnInfo.iConnId );
  2150                 = GetServerSession( iActiveBMConns[i].iConnInfo.iConnId );
  2173 
  2151 
  2174             TInt sessionIapId = iActiveBMConns[i].iConnInfo.iIapId;
  2152             TInt sessionIapId = iActiveBMConns[i].iConnInfo.iIapId;
  2175             if ( !sessionIapId )
  2153             if ( !sessionIapId )
  2177                 TRAP_IGNORE( sessionIapId = session->IapSelectionL()->MpmConnPref().IapId() );
  2155                 TRAP_IGNORE( sessionIapId = session->IapSelectionL()->MpmConnPref().IapId() );
  2178                 }
  2156                 }
  2179 
  2157 
  2180             if ( sessionIapId == aIapId )
  2158             if ( sessionIapId == aIapId )
  2181                 {
  2159                 {
  2182                 iapSessions.Append( session ); // Don't mind if Append fails
  2160                 (void) iapSessions.Append( session ); // Don't mind if Append fails
  2183                 
  2161 
  2184                 TBool silent( ETrue );
  2162                 TBool silent( ETrue );
  2185                 TRAP_IGNORE( silent = session->IapSelectionL()->MpmConnPref().NoteBehaviour()
  2163                 TRAP_IGNORE( silent = session->IapSelectionL()->MpmConnPref().NoteBehaviour()
  2186                                       & TExtendedConnPref::ENoteBehaviourConnDisableNotes );
  2164                                       & TExtendedConnPref::ENoteBehaviourConnDisableNotes );
  2187                 if ( !silent )
  2165                 if ( !silent )
  2188                     {
  2166                     {
  2191                     break; // for
  2169                     break; // for
  2192                     }
  2170                     }
  2193                 }
  2171                 }
  2194             }
  2172             }
  2195         }
  2173         }
  2196     
  2174 
  2197     if ( closeIap )
  2175     if ( closeIap )
  2198         {
  2176         {
  2199         MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping silent sessions to iap 0x%x", 
  2177         MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping silent sessions to iap 0x%x",
  2200             aIapId )
  2178             aIapId )
  2201         // Stop all (silent) sessions to iap
  2179         // Stop all (silent) sessions to iap
  2202         for ( TInt i = 0; i < iapSessions.Count(); i++)
  2180         for ( TInt i = 0; i < iapSessions.Count(); i++ )
  2203             {
  2181             {
  2204             MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping connId 0x%x",
  2182             MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping connId 0x%x",
  2205                     iapSessions[i]->ConnectionId());
  2183                     iapSessions[i]->ConnectionId());
  2206             iapSessions[i]->StopConnection();
  2184             iapSessions[i]->StopConnection();
  2207             }
  2185             }
  2208         }
  2186         }
  2209 
  2187 
  2210     iapSessions.Close();
  2188     iapSessions.Close();
  2211     
  2189     }
  2212     }
       
  2213 
       
  2214 
  2190 
  2215 // -----------------------------------------------------------------------------
  2191 // -----------------------------------------------------------------------------
  2216 // TMPMBlackListConnId::Append
  2192 // TMPMBlackListConnId::Append
  2217 // -----------------------------------------------------------------------------
  2193 // -----------------------------------------------------------------------------
  2218 //
  2194 //
  2219 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory )
  2195 void TMPMBlackListConnId::Append( TUint32 aIap, TBlacklistCategory aCategory )
  2220     {
  2196     {
  2221     iBlackListIap.Append( aIap );
  2197     // If first append fails, stop. If second append fails, need undo the first append.
  2222     iCategory.Append( aCategory );
  2198     TInt err = iBlackListIap.Append( aIap );
       
  2199     if ( !err )
       
  2200         {
       
  2201         err = iCategory.Append( aCategory );
       
  2202         if ( err )
       
  2203             {
       
  2204             iBlackListIap.Remove( iBlackListIap.Count() - 1 );
       
  2205             }
       
  2206         }
  2223     }
  2207     }
  2224 
  2208 
  2225 // -----------------------------------------------------------------------------
  2209 // -----------------------------------------------------------------------------
  2226 // TMPMBlackListConnId::Remove
  2210 // TMPMBlackListConnId::Remove
  2227 // -----------------------------------------------------------------------------
  2211 // -----------------------------------------------------------------------------
  2228 //
  2212 //
  2229 void TMPMBlackListConnId::Remove( TInt aIndex )
  2213 void TMPMBlackListConnId::Remove( TInt aIndex )
  2230     {
  2214     {
  2231     iBlackListIap.Remove( aIndex );
  2215     iBlackListIap.Remove( aIndex );
  2232     iCategory.Remove( aIndex );    
  2216     iCategory.Remove( aIndex );
  2233     }
  2217     }
  2234 
  2218 
  2235 // -----------------------------------------------------------------------------
  2219 // -----------------------------------------------------------------------------
  2236 // TMPMBlackListConnId::Close
  2220 // TMPMBlackListConnId::Close
  2237 // -----------------------------------------------------------------------------
  2221 // -----------------------------------------------------------------------------
  2238 //
  2222 //
  2239 void TMPMBlackListConnId::Close()
  2223 void TMPMBlackListConnId::Close()
  2240     {
  2224     {
  2241     iBlackListIap.Close();
  2225     iBlackListIap.Close();
  2242     iCategory.Close();    
  2226     iCategory.Close();
  2243     }
  2227     }
  2244 
  2228 
  2245 // -----------------------------------------------------------------------------
  2229 // -----------------------------------------------------------------------------
  2246 // TMPMBlackListConnId::Count
  2230 // TMPMBlackListConnId::Count
  2247 // -----------------------------------------------------------------------------
  2231 // -----------------------------------------------------------------------------
  2253 
  2237 
  2254 // -----------------------------------------------------------------------------
  2238 // -----------------------------------------------------------------------------
  2255 // TConnectionInfo::TConnectionInfo
  2239 // TConnectionInfo::TConnectionInfo
  2256 // -----------------------------------------------------------------------------
  2240 // -----------------------------------------------------------------------------
  2257 //
  2241 //
  2258 TConnectionInfo::TConnectionInfo() 
  2242 TConnectionInfo::TConnectionInfo()
  2259     : iConnId( 0 ),
  2243     : iConnId( 0 ),
  2260       iSnap( 0 ),
  2244       iSnap( 0 ),
  2261       iIapId( 0 ), 
  2245       iIapId( 0 ),
  2262       iState( EIdle ),
  2246       iState( EIdle ),
  2263       iAppUid( 0 )
  2247       iAppUid( 0 )
  2264     {
  2248     {
  2265     }
  2249     }
  2266 
  2250