bearermanagement/mpm/src/mpmserversession.cpp
changeset 20 9c97ad6591ae
parent 18 fcbbe021d614
child 23 7ec726f93df1
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
    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>
    37 #include <cmgenconnsettings.h>
    36 #include <cmgenconnsettings.h>
    38 
    37 
    39 #include "mpmcommsdataccess.h"
    38 #include "mpmcommsdataccess.h"
    40 #include "mpmserversession.h"
    39 #include "mpmserversession.h"
    41 #include "mpmconnmonevents.h"
    40 #include "mpmconnmonevents.h"
    42 #include "mpmdialog.h"
       
    43 #include "mpmdisconnectdlg.h"
    41 #include "mpmdisconnectdlg.h"
    44 #include "mpmconfirmdlgstarting.h"
    42 #include "mpmconfirmdlgstarting.h"
    45 #include "mpmconfirmdlgroaming.h"
    43 #include "mpmconfirmdlgroaming.h"
    46 #include "mpmlogger.h"
    44 #include "mpmlogger.h"
    47 #include "mpmpropertydef.h"
    45 #include "mpmpropertydef.h"
    74       iMyServer( aServer ),
    72       iMyServer( aServer ),
    75       iDisconnectDlg( NULL ),
    73       iDisconnectDlg( NULL ),
    76       iConfirmDlgRoaming( NULL ),
    74       iConfirmDlgRoaming( NULL ),
    77       iStoredIapInfo(),
    75       iStoredIapInfo(),
    78       iIapSelection( NULL ),
    76       iIapSelection( NULL ),
    79       iMigrateState( EMigrateNone )
    77       iMigrateState( EMigrateNone ),
       
    78       iDisconnectDialogShown( EFalse )
    80     {
    79     {
    81     }
    80     }
    82 
    81 
    83 
    82 
    84 // -----------------------------------------------------------------------------
    83 // -----------------------------------------------------------------------------
    92         {
    91         {
    93         iMyServer.SetEvents(CMPMConnMonEvents::NewL(
    92         iMyServer.SetEvents(CMPMConnMonEvents::NewL(
    94             *const_cast<CMPMServer*>( &iMyServer ), *this ));
    93             *const_cast<CMPMServer*>( &iMyServer ), *this ));
    95         }
    94         }
    96 
    95 
    97     FeatureManager::InitializeLibL();
       
    98     iOfflineFeatureSupported = FeatureManager::FeatureSupported( 
       
    99                                    KFeatureIdOfflineMode );
       
   100  
       
   101      FeatureManager::UnInitializeLib();
       
   102                                        
       
   103     // Append session pointer to server
    96     // Append session pointer to server
   104     // 
    97     // 
   105     iMyServer.AppendSessionL( this );
    98     iMyServer.AppendSessionL( this );
   106     }
    99     }
   107 
   100 
   122 
   115 
   123     if (UserConnection())
   116     if (UserConnection())
   124         {
   117         {
   125         iMyServer.ClearUserConnection();
   118         iMyServer.ClearUserConnection();
   126         ClearUserConnection();
   119         ClearUserConnection();
   127         
       
   128         // Set PS keys to zero
       
   129         RProperty::Set( KMPMUserConnectionCategory,
       
   130                         KMPMPSKeyUserConnectionSnap,
       
   131                         0 );
       
   132         
       
   133         RProperty::Set( KMPMUserConnectionCategory,
       
   134                         KMPMPSKeyUserConnectionIap,
       
   135                         0 );
       
   136         
   120         
   137         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
   121         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
   138 User connection deactivated" )
   122 User connection deactivated" )
   139         }   
   123         }   
   140 
   124 
   141     // Clean up the blacklist table 
   125     // Clean up the blacklist table 
   142     iMyServer.HandleServerUnblackListIap( iConnId, 0 );
   126     iMyServer.HandleServerUnblackListIap( iConnId, 0 );
   143 
   127 
   144     // Make sure the connection is removed from server's information array.
   128     // Make sure the connection is removed from server's information array.
   145     iMyServer.RemoveBMConnection( iConnId, *this );
   129     iMyServer.RemoveBMConnection( iConnId, *this );
       
   130     
       
   131     // Cancel discreet popup
       
   132     iMyServer.ConnUiUtils()->CancelConnectingViaDiscreetPopup();
   146     }
   133     }
   147 
   134 
   148 
   135 
   149 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   150 // CMPMServerSession::ServiceL
   137 // CMPMServerSession::ServiceL
   422         // an error note and complete with the error code.
   409         // an error note and complete with the error code.
   423         //
   410         //
   424         if ( ! ( mpmConnPref.NoteBehaviour() &
   411         if ( ! ( mpmConnPref.NoteBehaviour() &
   425             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
   412             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
   426             {
   413             {
   427             CConnectionUiUtilities* connUiUtils = NULL;
   414             iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( error );
   428         
       
   429             TRAP_IGNORE( connUiUtils = CConnectionUiUtilities::NewL() );
       
   430             
       
   431             if ( connUiUtils )
       
   432                 {
       
   433                 connUiUtils->ConnectionErrorDiscreetPopup( error );
       
   434                 delete connUiUtils;
       
   435                 connUiUtils = NULL;
       
   436                 }
       
   437             }    	
   415             }    	
   438         	
   416         	
   439         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL - Error \
   417         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL - Error \
   440 while extracting TCommDbConnPref from TConnPref" )
   418 while extracting TCommDbConnPref from TConnPref" )
   441         aMessage.Complete( error );
   419         aMessage.Complete( error );
   446     // that it can be used to avoid DisconnectDialog popping up when 
   424     // that it can be used to avoid DisconnectDialog popping up when 
   447     // AlwaysOnline connection is being established.
   425     // AlwaysOnline connection is being established.
   448     // 
   426     // 
   449     iAppUid = aMessage.Int2();
   427     iAppUid = aMessage.Int2();
   450 
   428 
   451     MPMLOGSTRING2( "CMPMServerSession::HandleServerChooseIapL: \
       
   452 Client UID = 0x%x", iAppUid )
       
   453 
       
   454     if ( !iIapSelection )
   429     if ( !iIapSelection )
   455         {
   430         {
   456         iIapSelection = CMPMIapSelection::NewL( iMyServer.CommsDatAccess(),
   431         iIapSelection = CMPMIapSelection::NewL( iMyServer.CommsDatAccess(),
   457                                                 this ); 
   432                                                 this,
       
   433                                                 iMyServer.ConnUiUtils() ); 
   458         }
   434         }
   459     
   435     
   460     MPMLOGSTRING3( "CMPMServerSession::HandleServerChooseIapL - iap %d \
   436     MPMLOGSTRING3( "CMPMServerSession::HandleServerChooseIapL - iap %d \
   461 connType %d", mpmConnPref.IapId(), mpmConnPref.ConnType() )
   437 connType %d", mpmConnPref.IapId(), mpmConnPref.ConnType() )
   462 
   438 
       
   439     if (!( mpmConnPref.NoteBehaviour() &
       
   440             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
       
   441         {
       
   442         iMyServer.ConnUiUtils()->ConnectingViaDiscreetPopup();
       
   443         }
       
   444     
   463     iIapSelection->ChooseIapL( mpmConnPref );
   445     iIapSelection->ChooseIapL( mpmConnPref );
   464 
   446 
   465     if ( iAppUid == iMyServer.CsIdWatcher()->ConnectScreenId() )
   447     if ( iAppUid == iMyServer.CsIdWatcher()->ConnectScreenId() )
   466         {
   448         {
   467         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL -\
   449         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL -\
   469         
   451         
   470         // This is user connection
   452         // This is user connection
   471         iMyServer.SetUserConnection();
   453         iMyServer.SetUserConnection();
   472         SetUserConnection();
   454         SetUserConnection();
   473         iMyServer.SetUserConnPref( mpmConnPref );
   455         iMyServer.SetUserConnPref( mpmConnPref );
   474         
       
   475         // Set PS keys according to user connection
       
   476         // Do not check return values. Can do nothing in case of failing.
       
   477         RProperty::Set( KMPMUserConnectionCategory,
       
   478                         KMPMPSKeyUserConnectionSnap,
       
   479                         mpmConnPref.SnapId() );
       
   480         
       
   481         RProperty::Set( KMPMUserConnectionCategory,
       
   482                         KMPMPSKeyUserConnectionIap,
       
   483                         mpmConnPref.IapId() );
       
   484         }
   456         }
   485     }
   457     }
   486 
   458 
   487 
   459 
   488 // -----------------------------------------------------------------------------
   460 // -----------------------------------------------------------------------------
   711 
   683 
   712     // Complete the message as soon as possible to avoid latency in BM
   684     // Complete the message as soon as possible to avoid latency in BM
   713     // 
   685     // 
   714     aMessage.Complete( KErrNone );
   686     aMessage.Complete( KErrNone );
   715     
   687     
   716     IapSelectionL()->ConnectionStarted();
   688     iMyServer.ConnUiUtils()->CancelConnectingViaDiscreetPopup();
   717     }
   689     }
   718 
   690 
   719 
   691 
   720 // -----------------------------------------------------------------------------
   692 // -----------------------------------------------------------------------------
   721 // CMPMServerSession::HandleServerIapConnectionStopped
   693 // CMPMServerSession::HandleServerIapConnectionStopped
   757 
   729 
   758     if (UserConnection())
   730     if (UserConnection())
   759         {
   731         {
   760         iMyServer.ClearUserConnection();
   732         iMyServer.ClearUserConnection();
   761         ClearUserConnection();
   733         ClearUserConnection();
   762         
       
   763         // Set PS keys to zero
       
   764         RProperty::Set( KMPMUserConnectionCategory,
       
   765                         KMPMPSKeyUserConnectionSnap,
       
   766                         0 );
       
   767         
       
   768         RProperty::Set( KMPMUserConnectionCategory,
       
   769                         KMPMPSKeyUserConnectionIap,
       
   770                         0 );
       
   771         
   734         
   772         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
   735         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
   773 User connection deactivated" )
   736 User connection deactivated" )
   774         }   
   737         }   
   775 
   738 
   821                    iConnId )
   784                    iConnId )
   822 
   785 
   823     // check whether a started connection exists which already 
   786     // check whether a started connection exists which already 
   824     // uses this IAP. If so, it won't need to be confirmed again
   787     // uses this IAP. If so, it won't need to be confirmed again
   825     // 
   788     // 
   826     if( iMyServer.CheckIfStarted( aIapId ) )
   789     if( iMyServer.CheckIfStarted( aIapId, iConnId ) )
   827         {
   790         {
   828         MPMLOGSTRING(
   791         MPMLOGSTRING(
   829         "CMPMServerSession::IsConfirmFirstL - IAP already started, \
   792         "CMPMServerSession::IsConfirmFirstL - IAP already started, \
   830 confirm not necesary - False" )
   793 confirm not necesary - False" )
   831         return EFalse;
   794         return EFalse;
   851 
   814 
   852     if ( currentDataUsage == ECmCellularDataUsageConfirm )
   815     if ( currentDataUsage == ECmCellularDataUsageConfirm )
   853         {
   816         {
   854         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" )
   817         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" )
   855         isConfirmFirst = ETrue;
   818         isConfirmFirst = ETrue;
       
   819         
       
   820         // iDisconnectDialogShown is set when disconnect dialog is shown.
       
   821         // Before the disconnect dialog is shown, data usage confirmation
       
   822         // dialog is already shown for the new PDP context. If you choose
       
   823         // to disconnect the active PDP context then data usage dialog is
       
   824         // shown again for the new context. So, set isConfirmFirst to
       
   825         // False to avoid duplicate cellular confirm dialog
       
   826         //
       
   827         if ( iDisconnectDialogShown )
       
   828             {
       
   829             MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL  - False; Data \
       
   830 confirmation dialog already shown for this IAP" )
       
   831             isConfirmFirst = EFalse;
       
   832             iDisconnectDialogShown = EFalse;
       
   833             }
   856         }
   834         }
   857     else 
   835     else 
   858         {
   836         {
   859         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" )
   837         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" )
   860         }
   838         }
  1418         ProcessErrorComplete( KErrNone, &error, &neededAction );
  1396         ProcessErrorComplete( KErrNone, &error, &neededAction );
  1419         return;
  1397         return;
  1420         }
  1398         }
  1421 
  1399 
  1422     // Show error popup if it's allowed per client request
  1400     // Show error popup if it's allowed per client request
       
  1401     // Don't show the pop up if error code is for disconnect dialog
       
  1402     //
  1423     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
  1403     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
  1424             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
  1404             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) &&
  1425         {
  1405          !DisconnectDlgErrorCode( error ) )
  1426         CConnectionUiUtilities* connUiUtils = NULL;
  1406         {
  1427         TRAPD( popupCreateError, connUiUtils = CConnectionUiUtilities::NewL() );
  1407         // Note: Below function shows the discreet popup only if the error code
  1428         if ( popupCreateError == KErrNone && connUiUtils )
  1408         // belongs to the set of errors that are shown to the user.
  1429             {
  1409         // Otherwise the popup is not shown.
  1430             // Note: Below function shows the discreet popup only if the error code
  1410         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( error );
  1431             // belongs to the set of errors that are shown to the user.
       
  1432             // Otherwise the popup is not shown.
       
  1433             connUiUtils->ConnectionErrorDiscreetPopup( error );
       
  1434             delete connUiUtils;
       
  1435             connUiUtils = NULL;
       
  1436             }
       
  1437         }
  1411         }
  1438 
  1412 
  1439     // Read the Connection Id of the application
  1413     // Read the Connection Id of the application
  1440     // 
  1414     // 
  1441     TConnectionId connId = iProcessErrorMessage.Int1();
  1415     TConnectionId connId = iProcessErrorMessage.Int1();
  1498             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
  1472             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
  1499  - Start Disconnect dialog" )
  1473  - Start Disconnect dialog" )
  1500             iDisconnectDlg = CMPMDisconnectDlg::NewL( *const_cast<CMPMServerSession*>(this),
  1474             iDisconnectDlg = CMPMDisconnectDlg::NewL( *const_cast<CMPMServerSession*>(this),
  1501                                                       error,
  1475                                                       error,
  1502                                                       *MyServer().DisconnectQueue() );
  1476                                                       *MyServer().DisconnectQueue() );
       
  1477             iDisconnectDialogShown = ETrue;
  1503             return;
  1478             return;
  1504             }
  1479             }
  1505         else
  1480         else
  1506             {
  1481             {
  1507             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
  1482             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
  1652                     iMyServer.HandleServerBlackListIap( connId, 
  1627                     iMyServer.HandleServerBlackListIap( connId, 
  1653                                                         presumedIap, 
  1628                                                         presumedIap, 
  1654                                                         ETemporary );
  1629                                                         ETemporary );
  1655                     }
  1630                     }
  1656 
  1631 
  1657                 // current iap is either WLAN or EasyWlan
  1632                 // current iap is WLAN
  1658                 // 
  1633                 // 
  1659                 if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
  1634                 if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
  1660                       iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
  1635                       iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
  1661                     {
  1636                     {
  1662                     // perform WLAN scan 
  1637                     // perform WLAN scan 
  1859         }
  1834         }
  1860     
  1835     
  1861         // Store message for later usage.
  1836         // Store message for later usage.
  1862     iServerSortSNAPMessage = aMessage;
  1837     iServerSortSNAPMessage = aMessage;
  1863 
  1838 
  1864     TUint32 aSeconds = static_cast<TUint32>( iServerSortSNAPMessage.Int2() );
  1839     TUint32 seconds = static_cast<TUint32>( iServerSortSNAPMessage.Int2() );
  1865     
  1840     
  1866     // To display up to date information the WLAN scan should be done first
  1841     // To display up to date information the WLAN scan should be done first
  1867     iMyServer.Events()->ScanWLANNetworksL( this, 
  1842     iMyServer.Events()->ScanWLANNetworksL( this, 
  1868                                            ConnectionId(), 
  1843                                            ConnectionId(), 
  1869                                            EWlanScanCallbackSortSnap, 
  1844                                            EWlanScanCallbackSortSnap, 
  1870                                            aSeconds );
  1845                                            seconds );
  1871     }
  1846     }
  1872     
  1847     
  1873 // -----------------------------------------------------------------------------
  1848 // -----------------------------------------------------------------------------
  1874 // CMPMServerSession::CompleteServerSortSNAPL
  1849 // CMPMServerSession::CompleteServerSortSNAPL
  1875 // -----------------------------------------------------------------------------
  1850 // -----------------------------------------------------------------------------
  2227     MPMLOGSTRING(
  2202     MPMLOGSTRING(
  2228             "CMPMServerSession::SortSnapL: Sorting completed" )
  2203             "CMPMServerSession::SortSnapL: Sorting completed" )
  2229     }
  2204     }
  2230 
  2205 
  2231 // -----------------------------------------------------------------------------
  2206 // -----------------------------------------------------------------------------
  2232 // CMPMServerSession::UpdateConnectionDialog
       
  2233 // -----------------------------------------------------------------------------
       
  2234 //
       
  2235 void CMPMServerSession::UpdateConnectionDialogL()
       
  2236     {
       
  2237     if( iIapSelection )
       
  2238         {
       
  2239         iIapSelection->UpdateConnectionDialogL();
       
  2240         }
       
  2241     }
       
  2242 
       
  2243 // -----------------------------------------------------------------------------
       
  2244 // CMPMServerSession::CompleteCarrierRejected
  2207 // CMPMServerSession::CompleteCarrierRejected
  2245 // -----------------------------------------------------------------------------
  2208 // -----------------------------------------------------------------------------
  2246 //
  2209 //
  2247 void CMPMServerSession::CompleteCarrierRejected()
  2210 void CMPMServerSession::CompleteCarrierRejected()
  2248     {
  2211     {
  2328             error = KErrArgument;
  2291             error = KErrArgument;
  2329             }
  2292             }
  2330         }
  2293         }
  2331 
  2294 
  2332     ResolveConnType( aMpmConnPref );
  2295     ResolveConnType( aMpmConnPref );
       
  2296 
       
  2297     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2298 BearerSet = %d", aMpmConnPref.BearerSet());
       
  2299     
       
  2300     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2301 ConnSelectionDialog = %d", aMpmConnPref.ConnSelectionDialog());
       
  2302     
       
  2303     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2304 ConnType = %d", aMpmConnPref.ConnType());
       
  2305     
       
  2306     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2307 DisconnectDialog = %d", aMpmConnPref.DisconnectDialog());
       
  2308     
       
  2309     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2310 ForcedRoaming = %d", aMpmConnPref.ForcedRoaming() );
       
  2311     
       
  2312     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2313 IapId = %d", aMpmConnPref.IapId());
       
  2314     
       
  2315     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2316 MandateIap = %d", aMpmConnPref.MandateIap());
       
  2317     
       
  2318     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2319 NetId = %d", aMpmConnPref.NetId());
       
  2320     
       
  2321     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2322 NoteBehaviour = %d", aMpmConnPref.NoteBehaviour());
       
  2323     
       
  2324     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2325 SnapId = %d", aMpmConnPref.SnapId());
       
  2326     
       
  2327     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2328 SnapPurpose = %d", aMpmConnPref.SnapPurpose());
  2333 
  2329 
  2334     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
  2330     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
  2335 Error code in the end: %d", error )
  2331 Error code in the end: %d", error )
  2336     return error;
  2332     return error;
  2337     }
  2333     }
  2664             iStoredIapInfo.SetStoredIapInfo( aIapInfo );
  2660             iStoredIapInfo.SetStoredIapInfo( aIapInfo );
  2665             return;
  2661             return;
  2666             }
  2662             }
  2667         }
  2663         }
  2668 
  2664 
  2669     TInt err(0);
       
  2670     TInt currentIap = MyServer().GetBMIap( iConnId );
  2665     TInt currentIap = MyServer().GetBMIap( iConnId );
  2671     MPMLOGSTRING4( "CMPMServerSession::PrefIAPNotificationL - \
  2666     MPMLOGSTRING3( "CMPMServerSession::PrefIAPNotificationL - \
  2672 current iap %d, last notified %d, err %d ", currentIap, iLastNotifiedIap, err )
  2667 current iap %d, last notified %d ", currentIap, iLastNotifiedIap )
  2673     if( err != KErrNone )
       
  2674         {
       
  2675         MPMLOGSTRING( "CMPMServerSession::PrefIAPNotificationL: Connection is not \
       
  2676 registered for notifications" )
       
  2677         return;
       
  2678         }
       
  2679         
  2668         
  2680     TBool iapTypeLanOrWlan( EFalse );
  2669     TBool iapTypeLanOrWlan( EFalse );
  2681     RAvailableIAPList  availableIAPList;
  2670     RAvailableIAPList  availableIAPList;
  2682     CleanupClosePushL( availableIAPList );
  2671     CleanupClosePushL( availableIAPList );
  2683     TUint32 validateIapId( 0 );
  2672     TUint32 validateIapId( 0 );
  2730                                        validateIapId, 
  2719                                        validateIapId, 
  2731                                        retNetId, 
  2720                                        retNetId, 
  2732                                        iapTypeLanOrWlan,
  2721                                        iapTypeLanOrWlan,
  2733                                        *this );
  2722                                        *this );
  2734         
  2723         
  2735         if ( CheckNotifNeed( currentIap,
  2724         if ( CheckNotifNeedL( currentIap,
  2736                              iLastNotifiedIap,
  2725                               iLastNotifiedIap,
  2737                              validateIapId ) )
  2726                               validateIapId ) )
  2738             {
  2727             {
  2739             MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \
  2728             MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \
  2740 Sending pref iap notification connId: 0x%x", iConnId )
  2729 Sending pref iap notification connId: 0x%x", iConnId )
  2741 
  2730 
  2742             iLastNotifiedIap = validateIapId; 
  2731             iLastNotifiedIap = validateIapId; 
  2796         // in available IAP list.
  2785         // in available IAP list.
  2797         // If it's not, then notify error.
  2786         // If it's not, then notify error.
  2798         // 
  2787         // 
  2799     else 
  2788     else 
  2800         {
  2789         {
  2801         err = availableIAPList.Find( oldIapId );
  2790         TInt err = availableIAPList.Find( oldIapId );
  2802         if( err == KErrNotFound )
  2791         if( err == KErrNotFound )
  2803             {
  2792             {
  2804             MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \
  2793             MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \
  2805 SNAP 0 and IAP %d not available, notifying error", oldIapId )
  2794 SNAP 0 and IAP %d not available, notifying error", oldIapId )
  2806             TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
  2795             TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
  2834     
  2823     
  2835     // Show the connecting discreet popup to the user when migrating to another iap
  2824     // Show the connecting discreet popup to the user when migrating to another iap
  2836     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
  2825     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
  2837             TExtendedConnPref::ENoteBehaviourConnDisableNotes) )
  2826             TExtendedConnPref::ENoteBehaviourConnDisableNotes) )
  2838         {
  2827         {
  2839         TBool connectionAlreadyActive = iMyServer.CheckIfStarted( aIapId );
  2828         TBool connectionAlreadyActive = iMyServer.CheckIfStarted( aIapId, iConnId );
  2840         CConnectionUiUtilities* connUiUtils = NULL;
  2829         
  2841         TRAPD( popupError,
  2830         iMyServer.ConnUiUtils()->ConnectingViaDiscreetPopup( aIapId,
  2842                connUiUtils = CConnectionUiUtilities::NewL();
  2831                                                   connectionAlreadyActive );
  2843                connUiUtils->ConnectingViaDiscreetPopup(
       
  2844                    aIapId,
       
  2845                    connectionAlreadyActive );
       
  2846                delete connUiUtils; );
       
  2847         if ( popupError && connUiUtils )
       
  2848             {
       
  2849             delete connUiUtils;
       
  2850             }
       
  2851         }
  2832         }
  2852 
  2833 
  2853     TMpmNotificationStartIAP notifInfo;
  2834     TMpmNotificationStartIAP notifInfo;
  2854     notifInfo.iMPMNotificationType = EMPMStartIAPNotification;
  2835     notifInfo.iMPMNotificationType = EMPMStartIAPNotification;
  2855     notifInfo.iInfo.iIap = aIapId;
  2836     notifInfo.iInfo.iIap = aIapId;
  2969     iNotifRequested = EFalse;
  2950     iNotifRequested = EFalse;
  2970 
  2951 
  2971     // Now complete error notification to BM
  2952     // Now complete error notification to BM
  2972     MPMLOGSTRING("CMPMServerSession::ErrorNotificationL - Send error notification" )
  2953     MPMLOGSTRING("CMPMServerSession::ErrorNotificationL - Send error notification" )
  2973     iNotifMessage.Complete( KErrNone );
  2954     iNotifMessage.Complete( KErrNone );
  2974     }
       
  2975 
       
  2976 // -----------------------------------------------------------------------------
       
  2977 // CMPMServerSession::IsPhoneOfflineL
       
  2978 // 
       
  2979 // Checks if phone is in offline mode or not.
       
  2980 // Return ETrue if phone is in offline mode.
       
  2981 // Return EFalse if phone is not in offline mode.
       
  2982 // -----------------------------------------------------------------------------
       
  2983 //
       
  2984 TBool CMPMServerSession::IsPhoneOfflineL() const
       
  2985     {
       
  2986     MPMLOGSTRING( "CMPMServerSession::IsPhoneOfflineL" )
       
  2987     if ( iOfflineFeatureSupported )
       
  2988         {
       
  2989         CRepository* repository = CRepository::NewLC(KCRUidCoreApplicationUIs);
       
  2990         TInt connAllowed = ECoreAppUIsNetworkConnectionAllowed;
       
  2991         repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
       
  2992         CleanupStack::PopAndDestroy( repository ); 
       
  2993         if ( !connAllowed )
       
  2994             {
       
  2995             MPMLOGSTRING(
       
  2996                 "CMPMServerSession::IsPhoneOfflineL Phone is in offline mode" )
       
  2997             return ETrue;
       
  2998             }
       
  2999         }
       
  3000     MPMLOGSTRING(
       
  3001         "CMPMServerSession::IsPhoneOfflineL Phone is not in offline mode" )
       
  3002     return EFalse;
       
  3003     }
  2955     }
  3004 
  2956 
  3005 // -----------------------------------------------------------------------------
  2957 // -----------------------------------------------------------------------------
  3006 // CMPMServerSession::AvailableUnblacklistedIapsL
  2958 // CMPMServerSession::AvailableUnblacklistedIapsL
  3007 // -----------------------------------------------------------------------------
  2959 // -----------------------------------------------------------------------------
  3076                 // Check if any of the unavailable WLAN IAPs have 
  3028                 // Check if any of the unavailable WLAN IAPs have 
  3077                 // the same SSID as the active WLAN connection.
  3029                 // the same SSID as the active WLAN connection.
  3078                 //
  3030                 //
  3079                 TBool usesSame( EFalse ); 
  3031                 TBool usesSame( EFalse ); 
  3080 
  3032 
  3081                 if ( !iMyServer.CommsDatAccess()->CheckEasyWLanL( unavailableIAPs[i] ) )
  3033                 TRAP_IGNORE( iMyServer.CommsDatAccess()->MatchSSIDL( ssid, 
       
  3034                                                                      unavailableIAPs[i], 
       
  3035                                                                      usesSame,
       
  3036                                                                      *this ) )
       
  3037                                                               
       
  3038                 if ( usesSame )
  3082                     {
  3039                     {
  3083                     TRAP_IGNORE( iMyServer.CommsDatAccess()->MatchSSIDL( ssid, 
  3040                     // Append unavailable IAP to list of available IAPs
  3084                                                               unavailableIAPs[i], 
  3041                     // if it uses same SSID as active WLAN connection.
  3085                                                               usesSame,
  3042                     // 
  3086                                                               *this ) )
  3043                     MPMLOGSTRING2(
  3087                                                               
  3044                         "CMPMServerSession::AvailableUnblacklistedIapsL:\
  3088                     if ( usesSame )
       
  3089                         {
       
  3090                         // Append unavailable IAP to list of available IAPs
       
  3091                         // if it uses same SSID as active WLAN connection.
       
  3092                         // 
       
  3093                         MPMLOGSTRING2(
       
  3094                             "CMPMServerSession::AvailableUnblacklistedIapsL:\
       
  3095  Append unavailable IapId = %i", unavailableIAPs[i] )
  3045  Append unavailable IapId = %i", unavailableIAPs[i] )
  3096                         aAvailableIAPs.AppendL( unavailableIAPs[i] );
  3046                     aAvailableIAPs.AppendL( unavailableIAPs[i] );
  3097                         }
       
  3098                     }
  3047                     }
  3099                 }
  3048                 }
  3100             }
  3049             }
  3101         CleanupStack::PopAndDestroy( &unavailableIAPs );
  3050         CleanupStack::PopAndDestroy( &unavailableIAPs );
  3102         }
  3051         }
  3156         return ETrue;
  3105         return ETrue;
  3157         }
  3106         }
  3158     }
  3107     }
  3159 
  3108 
  3160 // -----------------------------------------------------------------------------
  3109 // -----------------------------------------------------------------------------
  3161 // CMPMServerSession::CheckNotifNeed
  3110 // CMPMServerSession::CheckNotifNeedL
  3162 // -----------------------------------------------------------------------------
  3111 // -----------------------------------------------------------------------------
  3163 //
  3112 //
  3164 TBool CMPMServerSession::CheckNotifNeed( const TUint32       aCurrentIap,
  3113 TBool CMPMServerSession::CheckNotifNeedL( const TUint32       aCurrentIap,
  3165                                          const TUint32       aLastNotifiedIap,
  3114                                           const TUint32       aLastNotifiedIap,
  3166                                          const TUint32       aValidatedIap )
  3115                                           const TUint32       aValidatedIap )
  3167     {
  3116     {
  3168     TBool retValue( EFalse );
  3117     TBool retValue( EFalse );
  3169 
  3118 
  3170     // Get the state of the connection for this Connection Id
  3119     // Get the state of the connection for this Connection Id
  3171     // 
  3120     // 
  3180             MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: current IAP is same preferred IAP, no need to send notification" )
  3129             MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: current IAP is same preferred IAP, no need to send notification" )
  3181             retValue = EFalse;
  3130             retValue = EFalse;
  3182             }
  3131             }
  3183         else
  3132         else
  3184             {
  3133             {
  3185             MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: notif needed" )
  3134             TCmUsageOfWlan usageOfWlan = MyServer().CommsDatAccess()->ForcedRoamingL();
  3186             retValue = ETrue;
  3135             
       
  3136             if ( usageOfWlan == ECmUsageOfWlanManual &&
       
  3137                  MyServer().CommsDatAccess()->CheckWlanL( aValidatedIap ) != ENotWlanIap  )
       
  3138                 {
       
  3139                 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: WLAN IAP, Switch to WLAN is Manual, no need to send notification" )
       
  3140                 retValue = EFalse;
       
  3141                 }
       
  3142             else
       
  3143                 {
       
  3144                 MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: notif needed" )
       
  3145                 retValue = ETrue;             
       
  3146                 }
  3187             }
  3147             }
  3188        }
  3148        }
  3189     else
  3149     else
  3190         {
  3150         {
  3191         MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: Last notified IAP is same as preferred IAP, no need to send notification" )
  3151         MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: Last notified IAP is same as preferred IAP, no need to send notification" )
  3299     TInt                aError,
  3259     TInt                aError,
  3300     const TMpmConnPref* aPolicyPref )
  3260     const TMpmConnPref* aPolicyPref )
  3301     {
  3261     {
  3302     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete aError = %d", aError )
  3262     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete aError = %d", aError )
  3303 
  3263 
  3304     // Show error popup if it's allowed per client request
       
  3305     if ( ChooseBestIapCalled() && (!( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3306             TExtendedConnPref::ENoteBehaviourConnDisableNotes ))
       
  3307             && ( aError != KErrNone ) )
       
  3308         {
       
  3309         CConnectionUiUtilities* connUiUtils = NULL;
       
  3310         TRAPD( error, connUiUtils = CConnectionUiUtilities::NewL() );
       
  3311         if ( error == KErrNone && connUiUtils )
       
  3312             {
       
  3313             // Note: Below function shows the discreet popup only if the error code
       
  3314             // belongs to the set of errors that are shown to the user.
       
  3315             // Otherwise the popup is not shown.
       
  3316             connUiUtils->ConnectionErrorDiscreetPopup( aError );
       
  3317             delete connUiUtils;
       
  3318             connUiUtils = NULL;
       
  3319             }
       
  3320         }
       
  3321     
  3264     
  3322     // Try to write back arguments and complete message.
  3265     // Try to write back arguments and complete message.
  3323     // 
  3266     // 
  3324     if ( !iChooseIapMessage.IsNull() )
  3267     if ( !iChooseIapMessage.IsNull() )
  3325         {
  3268         {
  3371                 }
  3314                 }
  3372             }
  3315             }
  3373         MPMLOGSTRING( "CMPMServerSession::ChooseIapComplete Message completed" )
  3316         MPMLOGSTRING( "CMPMServerSession::ChooseIapComplete Message completed" )
  3374         iChooseIapMessage.Complete( aError );
  3317         iChooseIapMessage.Complete( aError );
  3375         }
  3318         }
       
  3319 
       
  3320     // Show error popup if it's allowed per client request
       
  3321     if ( ChooseBestIapCalled() && (!( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3322             TExtendedConnPref::ENoteBehaviourConnDisableNotes ))
       
  3323             && ( aError != KErrNone ) )
       
  3324         {
       
  3325         // Note: Below function shows the discreet popup only if the error code
       
  3326         // belongs to the set of errors that are shown to the user.
       
  3327         // Otherwise the popup is not shown.
       
  3328         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( aError );
       
  3329         }
       
  3330     else
       
  3331         {
       
  3332         if (!( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3333             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
       
  3334             {
       
  3335             TBool connectionAlreadyActive =
       
  3336                 MyServer().CheckIfStarted( aPolicyPref->IapId(), iConnId );
       
  3337 
       
  3338             iMyServer.ConnUiUtils()->ConnectingViaDiscreetPopup( aPolicyPref->IapId(),
       
  3339                                                       connectionAlreadyActive );
       
  3340             }            
       
  3341         }
  3376     }
  3342     }
  3377 
  3343 
  3378 
  3344 
  3379 // -----------------------------------------------------------------------------
  3345 // -----------------------------------------------------------------------------
  3380 // CMPMServerSession::ProcessErrorComplete
  3346 // CMPMServerSession::ProcessErrorComplete
  3576 // -----------------------------------------------------------------------------
  3542 // -----------------------------------------------------------------------------
  3577 //
  3543 //
  3578 TBool CMPMServerSession::ForcedRoaming()
  3544 TBool CMPMServerSession::ForcedRoaming()
  3579     {
  3545     {
  3580     TBool forcedRoaming( EFalse );
  3546     TBool forcedRoaming( EFalse );
  3581     if ( iIapSelection != NULL )
  3547     if ( iIapSelection )
  3582         {
  3548         {
  3583         forcedRoaming = iIapSelection->MpmConnPref().ForcedRoaming();
  3549         forcedRoaming = iIapSelection->MpmConnPref().ForcedRoaming();
  3584         }
  3550         }
  3585     return forcedRoaming;
  3551     return forcedRoaming;
  3586     }
  3552     }
  3656         // one unfiltered physical IAP still available. If it does not
  3622         // one unfiltered physical IAP still available. If it does not
  3657         // then it cannot be used to establish connection and should 
  3623         // then it cannot be used to establish connection and should 
  3658         // be filtered.
  3624         // be filtered.
  3659         index = 0;
  3625         index = 0;
  3660         RAvailableIAPList availableIaps; 
  3626         RAvailableIAPList availableIaps; 
  3661             
  3627         CleanupClosePushL( availableIaps );
       
  3628 		
  3662         for ( TUint i = 0; i < aIapInfo.iCount; i++ )
  3629         for ( TUint i = 0; i < aIapInfo.iCount; i++ )
  3663             {
  3630             {
  3664             availableIaps.AppendL( aIapInfo.iIap[i].iIapId );
  3631             availableIaps.AppendL( aIapInfo.iIap[i].iIapId );
  3665             }
  3632             }
  3666         
  3633         
  3701                     }
  3668                     }
  3702                 
  3669                 
  3703                 aIapInfo.iCount--;                               
  3670                 aIapInfo.iCount--;                               
  3704                 }
  3671                 }
  3705             index++;
  3672             index++;
  3706             }        
  3673             }
       
  3674         CleanupStack::PopAndDestroy( &availableIaps );
  3707         }
  3675         }
  3708     }
  3676     }
  3709 
  3677 
  3710 // -----------------------------------------------------------------------------
  3678 // -----------------------------------------------------------------------------
  3711 // CMPMServerSession::GetAvailableIAPs()
  3679 // CMPMServerSession::GetAvailableIAPs()