bearermanagement/mpm/src/mpmserversession.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 65 14754bf06654
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
     1 /*
     2 * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    36 #include <cmgenconnsettings.h>
    36 #include <cmgenconnsettings.h>
    37 
    37 
    38 #include "mpmcommsdataccess.h"
    38 #include "mpmcommsdataccess.h"
    39 #include "mpmserversession.h"
    39 #include "mpmserversession.h"
    40 #include "mpmconnmonevents.h"
    40 #include "mpmconnmonevents.h"
       
    41 #include "mpmdialog.h"
       
    42 #include "mpmdisconnectdlg.h"
    41 #include "mpmconfirmdlgstarting.h"
    43 #include "mpmconfirmdlgstarting.h"
    42 #include "mpmconfirmdlgroaming.h"
    44 #include "mpmconfirmdlgroaming.h"
    43 #include "mpmlogger.h"
    45 #include "mpmlogger.h"
    44 #include "mpmpropertydef.h"
    46 #include "mpmpropertydef.h"
       
    47 #include "mpmdefaultconnection.h"
    45 #include "mpmiapselection.h"
    48 #include "mpmiapselection.h"
    46 #include "mpmcsidwatcher.h"
    49 #include "mpmcsidwatcher.h"
    47 
    50 
    48 // ============================ MEMBER FUNCTIONS ===============================
    51 // ============================ MEMBER FUNCTIONS ===============================
    49 
    52 
    66 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
    67 //
    70 //
    68 CMPMServerSession::CMPMServerSession(CMPMServer& aServer)
    71 CMPMServerSession::CMPMServerSession(CMPMServer& aServer)
    69     : CSession2(), 
    72     : CSession2(), 
    70       iMyServer( aServer ),
    73       iMyServer( aServer ),
       
    74       iDisconnectDlg( NULL ),
    71       iConfirmDlgRoaming( NULL ),
    75       iConfirmDlgRoaming( NULL ),
    72       iConnId( 0 ),
       
    73       iNotifRequested( EFalse ),
       
    74       iPreferredIAPRequested( EFalse ),
       
    75       iOfflineFeatureSupported( EFalse ),
       
    76       iEasyWlanIap( 0 ),
       
    77       iAppUid( 0 ),
       
    78       iStoredIapInfo(),
    76       iStoredIapInfo(),
    79       iIapSelection( NULL ),
    77       iIapSelection( NULL ),
    80       iMigrateState( EMigrateNone ),
    78       iMigrateState( EMigrateNone ),
    81       iLastNotifiedIap( 0 ),
    79       iDisconnectDialogShown( EFalse ),
    82       iMigrateIap( 0 ),
       
    83       iUserConnection( 0 ),
       
    84       iVpnUserConnectionUsed( EFalse ),
       
    85       iErrorDiscreetPopupShown( EFalse )
    80       iErrorDiscreetPopupShown( EFalse )
    86     {
    81     {
    87     }
    82     }
    88 
    83 
    89 
    84 
    94 void CMPMServerSession::ConstructL()
    89 void CMPMServerSession::ConstructL()
    95     {
    90     {
    96     MPMLOGSTRING( "CMPMServerSession::ConstructL" )
    91     MPMLOGSTRING( "CMPMServerSession::ConstructL" )
    97     if ( !iMyServer.Events() )
    92     if ( !iMyServer.Events() )
    98         {
    93         {
    99         iMyServer.SetEvents(CMPMConnMonEvents::NewL(
    94         iMyServer.SetEvents( CMPMConnMonEvents::NewL(
   100             *const_cast<CMPMServer*>( &iMyServer ) ) );
    95             *const_cast<CMPMServer*>( &iMyServer ) ) );
   101         }
    96         }
   102 
    97 
   103     // Append session pointer to server
    98     // Append session pointer to server
   104     // 
    99     // 
   110 // CMPMServerSession::~CMPMServerSession
   105 // CMPMServerSession::~CMPMServerSession
   111 // -----------------------------------------------------------------------------
   106 // -----------------------------------------------------------------------------
   112 //
   107 //
   113 CMPMServerSession::~CMPMServerSession()
   108 CMPMServerSession::~CMPMServerSession()
   114     {
   109     {
   115     delete iConfirmDlgRoaming;
   110 
   116     delete iIapSelection;
       
   117 
   111 
   118     // Remove serverside objects for notification session.
   112     // Remove serverside objects for notification session.
   119     // 
   113     // 
   120     iMyServer.RemoveSession( this );
   114     iMyServer.RemoveSession( this );
   121 
   115 
   122     if (VpnUserConnectionUsed())
   116     if (UserConnection())
   123         {
       
   124         SetVpnUserConnectionUsed( EFalse );
       
   125     
       
   126     MPMLOGSTRING( "CMPMServerSession::~CMPMServerSession -\
       
   127  VPN user connection usage ended" )    
       
   128         }
       
   129     else if (UserConnection())
       
   130         {
   117         {
   131         iMyServer.ClearUserConnection();
   118         iMyServer.ClearUserConnection();
   132         ClearUserConnection();
   119         ClearUserConnection();
   133         
   120         
   134         MPMLOGSTRING( "CMPMServerSession::~CMPMServerSession -\
   121         // Set PS keys to zero
       
   122         RProperty::Set( KMPMUserConnectionCategory,
       
   123                         KMPMPSKeyUserConnectionSnap,
       
   124                         0 );
       
   125         
       
   126         RProperty::Set( KMPMUserConnectionCategory,
       
   127                         KMPMPSKeyUserConnectionIap,
       
   128                         0 );
       
   129         
       
   130         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
   135 User connection deactivated" )
   131 User connection deactivated" )
   136         }   
   132         }   
   137 
   133 
   138     // Clean up the blacklist table 
   134     // Clean up the blacklist table 
   139     iMyServer.HandleServerUnblackListIap( iConnId, 0 );
   135     iMyServer.HandleServerUnblackListIap( iConnId, 0 );
   140 
   136     
   141     // Make sure the connection is removed from server's information array.
   137     // Make sure the connection is removed from server's information array.
   142     iMyServer.RemoveBMConnection( iConnId, *this );
   138     iMyServer.RemoveBMConnection( iConnId, *this );
   143     
   139 
   144     // Cancel discreet popup
   140     delete iDisconnectDlg;
   145     iMyServer.ConnUiUtils()->CancelConnectingViaDiscreetPopup();
   141     delete iConfirmDlgRoaming;
       
   142     delete iIapSelection;
       
   143 
   146     }
   144     }
   147 
   145 
   148 
   146 
   149 // -----------------------------------------------------------------------------
   147 // -----------------------------------------------------------------------------
   150 // CMPMServerSession::ServiceL
   148 // CMPMServerSession::ServiceL
   422         // an error note and complete with the error code.
   420         // an error note and complete with the error code.
   423         //
   421         //
   424         if ( ! ( mpmConnPref.NoteBehaviour() &
   422         if ( ! ( mpmConnPref.NoteBehaviour() &
   425             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
   423             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
   426             {
   424             {
   427             iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( error );
   425             CConnectionUiUtilities* connUiUtils = NULL;
       
   426         
       
   427             TRAP_IGNORE( connUiUtils = CConnectionUiUtilities::NewL() );
       
   428             
       
   429             if ( connUiUtils )
       
   430                 {
       
   431                 connUiUtils->ConnectionErrorDiscreetPopup( error );
       
   432                 delete connUiUtils;
       
   433                 connUiUtils = NULL;
       
   434                 }
   428             }    	
   435             }    	
   429         	
   436         	
   430         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL - Error \
   437         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL - Error \
   431 while extracting TCommDbConnPref from TConnPref" )
   438 while extracting TCommDbConnPref from TConnPref" )
   432         aMessage.Complete( error );
   439         aMessage.Complete( error );
   433         return;
   440         return;
   434         }
   441         }
   435 
   442 
   436     // Store the Uid of the application to the member variable so 
   443     // Store the Uid of the application to the member variable so 
   437     // that it can be used when AlwaysOnline connection is being established.
   444     // that it can be used to avoid DisconnectDialog popping up when 
       
   445     // AlwaysOnline connection is being established.
   438     // 
   446     // 
   439     iAppUid = aMessage.Int2();
   447     iAppUid = aMessage.Int2();
   440 
   448 
       
   449     MPMLOGSTRING2( "CMPMServerSession::HandleServerChooseIapL: \
       
   450 Client UID = 0x%x", iAppUid )
       
   451 
   441     if ( !iIapSelection )
   452     if ( !iIapSelection )
   442         {
   453         {
   443         iIapSelection = CMPMIapSelection::NewL( iMyServer.CommsDatAccess(),
   454         iIapSelection = CMPMIapSelection::NewL( iMyServer.CommsDatAccess(),
   444                                                 this,
   455                                                 this ); 
   445                                                 iMyServer.ConnUiUtils() ); 
       
   446         }
   456         }
   447     
   457     
   448     MPMLOGSTRING3( "CMPMServerSession::HandleServerChooseIapL - iap %d \
   458     MPMLOGSTRING3( "CMPMServerSession::HandleServerChooseIapL - iap %d \
   449 connType %d", mpmConnPref.IapId(), mpmConnPref.ConnType() )
   459 connType %d", mpmConnPref.IapId(), mpmConnPref.ConnType() )
   450 
   460 
   451 
       
   452     if ( iMyServer.UseVpnUserConnection(mpmConnPref,
       
   453                                         AppUid()) )
       
   454         {
       
   455         // VPN user connection needs to be used.
       
   456         TBool prepareOk = iMyServer.PrepareVpnUserConnection( mpmConnPref );
       
   457         if ( prepareOk )
       
   458             {
       
   459             SetVpnUserConnectionUsed( ETrue );
       
   460             MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL -\
       
   461  VPN user connection used" )                    
       
   462             }
       
   463         }
       
   464             
       
   465     iIapSelection->ChooseIapL( mpmConnPref );
   461     iIapSelection->ChooseIapL( mpmConnPref );
   466 
   462 
   467     if ( iAppUid == iMyServer.CsIdWatcher()->ConnectScreenId() )
   463     if ( iAppUid == iMyServer.CsIdWatcher()->ConnectScreenId() )
   468         {
   464         {
   469         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL -\
   465         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL -\
   471         
   467         
   472         // This is user connection
   468         // This is user connection
   473         iMyServer.SetUserConnection();
   469         iMyServer.SetUserConnection();
   474         SetUserConnection();
   470         SetUserConnection();
   475         iMyServer.SetUserConnPref( mpmConnPref );
   471         iMyServer.SetUserConnPref( mpmConnPref );
       
   472         
       
   473         // Set PS keys according to user connection
       
   474         // Do not check return values. Can do nothing in case of failing.
       
   475         RProperty::Set( KMPMUserConnectionCategory,
       
   476                         KMPMPSKeyUserConnectionSnap,
       
   477                         mpmConnPref.SnapId() );
       
   478         
       
   479         RProperty::Set( KMPMUserConnectionCategory,
       
   480                         KMPMPSKeyUserConnectionIap,
       
   481                         mpmConnPref.IapId() );
   476         }
   482         }
   477     }
   483     }
   478 
   484 
   479 
   485 
   480 // -----------------------------------------------------------------------------
   486 // -----------------------------------------------------------------------------
   527 
   533 
   528             // Cancel WLAN scan request if one exists
   534             // Cancel WLAN scan request if one exists
   529             //
   535             //
   530             TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ) )
   536             TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ) )
   531 
   537 
       
   538             if ( iDisconnectDlg )
       
   539                 {
       
   540                 MPMLOGSTRING( "CMPMServerSession::HandleServerCancelRequest: \
       
   541 removing dconn dlg" )
       
   542                 delete iDisconnectDlg;
       
   543                 iDisconnectDlg = NULL;
       
   544                 }
   532             return;
   545             return;
   533             }
   546             }
   534         case EMPMWaitNotification:
   547         case EMPMWaitNotification:
   535             {
   548             {
   536             if ( iNotifRequested )
   549             if ( iNotifRequested )
   545             if ( !iServerSortSNAPMessage.IsNull() )
   558             if ( !iServerSortSNAPMessage.IsNull() )
   546                 {
   559                 {
   547                 // TODO Change CancelScanL to non-leaving.
   560                 // TODO Change CancelScanL to non-leaving.
   548                 // Otherwise, nothing clever can be done here.
   561                 // Otherwise, nothing clever can be done here.
   549                 // And OOM may risk MPM stability.
   562                 // And OOM may risk MPM stability.
   550                 TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ))
   563                 TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ) )
   551                 iServerSortSNAPMessage.Complete( KErrCancel );
   564                 iServerSortSNAPMessage.Complete( KErrCancel );
   552                 }
   565                 }
   553             break;
   566             break;
   554             }
   567             }
   555         default:
   568         default:
   695     iMyServer.AppendBMIAPConnectionL( startedIap, startedId, *this );
   708     iMyServer.AppendBMIAPConnectionL( startedIap, startedId, *this );
   696 
   709 
   697     // Complete the message as soon as possible to avoid latency in BM
   710     // Complete the message as soon as possible to avoid latency in BM
   698     // 
   711     // 
   699     aMessage.Complete( KErrNone );
   712     aMessage.Complete( KErrNone );
   700     
   713     }
   701     iMyServer.ConnUiUtils()->CancelConnectingViaDiscreetPopup();
       
   702     }
       
   703 
       
   704 
   714 
   705 // -----------------------------------------------------------------------------
   715 // -----------------------------------------------------------------------------
   706 // CMPMServerSession::HandleServerIapConnectionStopped
   716 // CMPMServerSession::HandleServerIapConnectionStopped
   707 // -----------------------------------------------------------------------------
   717 // -----------------------------------------------------------------------------
   708 //
   718 //
   738     {
   748     {
   739     // Read the Connection Id of the application
   749     // Read the Connection Id of the application
   740     //
   750     //
   741     TConnectionId endId = aMessage.Int0();
   751     TConnectionId endId = aMessage.Int0();
   742 
   752 
   743     if (VpnUserConnectionUsed())
   753     if (UserConnection())
   744         {
       
   745         SetVpnUserConnectionUsed( EFalse );
       
   746 
       
   747         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
       
   748  VPN user connection usage ended" )    
       
   749         }
       
   750     else if (UserConnection())
       
   751         {
   754         {
   752         iMyServer.ClearUserConnection();
   755         iMyServer.ClearUserConnection();
   753         ClearUserConnection();
   756         ClearUserConnection();
       
   757         
       
   758         // Set PS keys to zero
       
   759         RProperty::Set( KMPMUserConnectionCategory,
       
   760                         KMPMPSKeyUserConnectionSnap,
       
   761                         0 );
       
   762         
       
   763         RProperty::Set( KMPMUserConnectionCategory,
       
   764                         KMPMPSKeyUserConnectionIap,
       
   765                         0 );
   754         
   766         
   755         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
   767         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
   756 User connection deactivated" )
   768 User connection deactivated" )
   757         }   
   769         }   
   758 
   770 
   803                    aIapId,
   815                    aIapId,
   804                    iConnId )
   816                    iConnId )
   805 
   817 
   806     // check whether a started connection exists which already 
   818     // check whether a started connection exists which already 
   807     // uses this IAP. If so, it won't need to be confirmed again
   819     // uses this IAP. If so, it won't need to be confirmed again
   808     // 
   820     //
   809     if( iMyServer.CheckIfStarted( aIapId, iConnId ) )
   821     if ( iMyServer.CheckUsageOfIap( aIapId, iConnId ) == EStarted )
   810         {
   822         {
   811         MPMLOGSTRING(
   823         MPMLOGSTRING(
   812         "CMPMServerSession::IsConfirmFirstL - IAP already started, \
   824         "CMPMServerSession::IsConfirmFirstL - IAP already started, \
   813 confirm not necesary - False" )
   825 confirm not necesary - False" )
   814         return EFalse;
   826         return EFalse;
   834 
   846 
   835     if ( currentDataUsage == ECmCellularDataUsageConfirm )
   847     if ( currentDataUsage == ECmCellularDataUsageConfirm )
   836         {
   848         {
   837         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" )
   849         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" )
   838         isConfirmFirst = ETrue;
   850         isConfirmFirst = ETrue;
       
   851 
       
   852         // iDisconnectDialogShown is set when disconnect dialog is shown.
       
   853         // Before the disconnect dialog is shown, data usage confirmation
       
   854         // dialog is already shown for the new PDP context. If you choose
       
   855         // to disconnect the active PDP context then data usage dialog is
       
   856         // shown again for the new context. So, set isConfirmFirst to
       
   857         // False to avoid duplicate cellular confirm dialog
       
   858         //
       
   859         if ( iDisconnectDialogShown )
       
   860             {
       
   861             MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL  - False; Data \
       
   862 confirmation dialog already shown this IAP" )
       
   863             isConfirmFirst = EFalse;
       
   864             iDisconnectDialogShown = EFalse;
       
   865             }
   839         }
   866         }
   840     else 
   867     else 
   841         {
   868         {
   842         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" )
   869         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" )
   843         }
   870         }
   914         if ( MyServer().CommsDatAccess()->CheckWlanL( iMigrateIap ) == ENotWlanIap )
   941         if ( MyServer().CommsDatAccess()->CheckWlanL( iMigrateIap ) == ENotWlanIap )
   915             {
   942             {
   916             // Check that connection preferences don't deny queries, and
   943             // Check that connection preferences don't deny queries, and
   917             // enough time has elapsed from the last query cancelled by the user.
   944             // enough time has elapsed from the last query cancelled by the user.
   918             if ( !( iIapSelection->MpmConnPref().NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
   945             if ( !( iIapSelection->MpmConnPref().NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
   919                  !MyServer().IsConnPermQueryTimerOn() )
   946                     !MyServer().IsConnPermQueryTimerOn() )
   920                 {
   947                 {
   921                 if ( MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
   948                 if ( MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
   922                     {
   949                     {
   923                     //International roaming
   950                     //International roaming
   924                     iConfirmDlgRoaming = CMPMConfirmDlgRoaming::NewL( 
   951                     iConfirmDlgRoaming = CMPMConfirmDlgRoaming::NewL( 
   975 	    MPMLOGSTRING2( "CMPMServerSession<0x%x>::MigrateCallbackL: State user confirmation",
  1002 	    MPMLOGSTRING2( "CMPMServerSession<0x%x>::MigrateCallbackL: State user confirmation",
   976 	                   iConnId )
  1003 	                   iConnId )
   977 	    if( aError == KErrNone )
  1004 	    if( aError == KErrNone )
   978 	        {
  1005 	        {
   979 	        iMigrateState = EMigrateOfflineConfirmation;
  1006 	        iMigrateState = EMigrateOfflineConfirmation;
       
  1007     	    if( IapSelectionL()->StartWlanQueryIfNeededL( iMigrateIap, ETrue ) )
       
  1008 	            {
       
  1009 	            return;
       
  1010                 }
   980 	        }
  1011 	        }
   981 	    }
  1012 	    }
   982 	else if( iMigrateState == EMigrateOfflineConfirmation )
  1013 	else if( iMigrateState == EMigrateOfflineConfirmation )
   983 	    {
  1014 	    {
   984 	    MPMLOGSTRING3( "CMPMServerSession<0x%x>::MigrateCallbackL: State offline confirmation error: %d", 
  1015 	    MPMLOGSTRING3( "CMPMServerSession<0x%x>::MigrateCallbackL: State offline confirmation error: %d", 
  1394         {
  1425         {
  1395         iMyServer.PanicClient( KErrBadDescriptor );
  1426         iMyServer.PanicClient( KErrBadDescriptor );
  1396         return;
  1427         return;
  1397         }
  1428         }
  1398 
  1429 
  1399     if ( !ChooseBestIapCalled() )
       
  1400         {
       
  1401         MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
       
  1402 Warning: ChooseBestIap has not been called yet" )
       
  1403         TBMNeededAction neededAction( EPropagateError );
       
  1404         ProcessErrorComplete( KErrNone, &error, &neededAction );
       
  1405         return;
       
  1406         }
       
  1407     
       
  1408     // Read the Connection Id of the application
  1430     // Read the Connection Id of the application
  1409     // 
  1431     // 
  1410     TConnectionId connId = iProcessErrorMessage.Int1();
  1432     TConnectionId connId = iProcessErrorMessage.Int1();
  1411 
  1433     
  1412     MPMLOGSTRING3( "CMPMServerSession::HandleServerProcessErrorL\
  1434     MPMLOGSTRING3( "CMPMServerSession::HandleServerProcessErrorL \
  1413  - error code = %i, Connection Id = 0x%x", error, connId )
  1435 - error code = %i, Connection Id = 0x%x", error, connId )
       
  1436 
       
  1437     if ( !ChooseBestIapCalled() )
       
  1438         {
       
  1439         MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
       
  1440 ChooseBestIap has not been called yet" )
       
  1441 
       
  1442         // If it is not disconnect dialog error then complete message. 
       
  1443         // If it is then leave message pending and it will be completed when 
       
  1444         // disconnect dialog completes in other session.
       
  1445         if ( !DisconnectDlgErrorCode( error ) )
       
  1446             {
       
  1447             TBMNeededAction neededAction( EPropagateError );
       
  1448             ProcessErrorComplete( KErrNone, &error, &neededAction );
       
  1449             }
       
  1450         else
       
  1451             {
       
  1452             MPMLOGSTRING( "Disconnect dlg error - leave msg pending" );
       
  1453             }
       
  1454         return;
       
  1455         }
       
  1456 
       
  1457     // Show error popup if it's allowed per client request
       
  1458     // Don't show the pop up if error code is for disconnect dialog
       
  1459     //
       
  1460     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  1461             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) &&
       
  1462          !DisconnectDlgErrorCode( error ) )
       
  1463         {
       
  1464         CConnectionUiUtilities* connUiUtils = NULL;
       
  1465         TRAPD( popupCreateError, connUiUtils = CConnectionUiUtilities::NewL() );
       
  1466         if ( popupCreateError == KErrNone && connUiUtils )
       
  1467             {
       
  1468             // Note: Below function shows the discreet popup only if the error code
       
  1469             // belongs to the set of errors that are shown to the user.
       
  1470             // Otherwise the popup is not shown.
       
  1471             connUiUtils->ConnectionErrorDiscreetPopup( error );
       
  1472             delete connUiUtils;
       
  1473             connUiUtils = NULL;
       
  1474             
       
  1475             // Error discreet popup has been shown. This is needed so that we
       
  1476             // dont show it again for SNAP.
       
  1477             iErrorDiscreetPopupShown = ETrue;
       
  1478             }
       
  1479         }
  1414 
  1480 
  1415     // Get the current connection IapId for this connId 
  1481     // Get the current connection IapId for this connId 
  1416     //
  1482     //
  1417     TUint32 currentIap = iMyServer.GetBMIap( connId );
  1483     TUint32 currentIap = iMyServer.GetBMIap( connId );
  1418 
  1484 
  1419     // Get the current connection SNAP for this Connection Id
  1485     // Get the current connection SNAP for this Connection Id
  1420     //
  1486     //
  1421     TUint32 snapId = iMyServer.GetBMSnap( connId );
  1487     TUint32 snapId = iMyServer.GetBMSnap( connId );
  1422 
       
  1423     // The popup is shown if the connection is not silent and the
       
  1424     // error is something else than a disconnect dialog error code.
       
  1425     // The popup is also shown if the connection is silent and the
       
  1426     // error is a disconnect dlg error, a background application 
       
  1427     // is not in question, a MMS IAP is not
       
  1428     // in question, and a started connection does not exist.
       
  1429     TBool silent = iIapSelection->MpmConnPref().NoteBehaviour() &
       
  1430                 TExtendedConnPref::ENoteBehaviourConnDisableNotes;
       
  1431     if ( !silent && ( !DisconnectDlgErrorCode( error ) ||
       
  1432             ( !IsBackgroundApplication( iAppUid ) &&
       
  1433             !IsMMSIap( currentIap ) && 
       
  1434             iMyServer.StartedConnectionExists() != KErrNotFound ) ) )
       
  1435         {
       
  1436         // Note: Below function shows the discreet popup only if the error code
       
  1437         // belongs to the set of errors that are shown to the user.
       
  1438         // Otherwise the popup is not shown.
       
  1439         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( error );
       
  1440         
       
  1441         // Error discreet popup has been shown. This is needed so that we
       
  1442         // dont show it again for SNAP.
       
  1443         iErrorDiscreetPopupShown = ETrue;
       
  1444         }  
       
  1445 
  1488 
  1446     TConnMonIapInfo availableIAPs;
  1489     TConnMonIapInfo availableIAPs;
  1447     availableIAPs = GetAvailableIAPs();
  1490     availableIAPs = GetAvailableIAPs();
  1448 
  1491 
  1449     RemoveUnavailableIap( availableIAPs, currentIap );
  1492     RemoveUnavailableIap( availableIAPs, currentIap );
  1452 
  1495 
  1453     // Get the state of the connection for this Iap Id.
  1496     // Get the state of the connection for this Iap Id.
  1454     // 
  1497     // 
  1455     TConnectionState state;
  1498     TConnectionState state;
  1456     iMyServer.GetConnectionState( connId, state );
  1499     iMyServer.GetConnectionState( connId, state );
  1457     MPMLOGSTRING2(
       
  1458         "CMPMServerSession::HandleServerProcessErrorL - state %d", state )
       
  1459 
  1500 
  1460     // We need to blacklist the presumed IAP too
  1501     // We need to blacklist the presumed IAP too
  1461     // 
  1502     // 
  1462     TUint32 presumedIap = MyServer().Events()->PresumedIapId( connId, 
  1503     TUint32 presumedIap = MyServer().Events()->PresumedIapId( connId, 
  1463                                                               currentIap );
  1504                                                               currentIap );
  1464 
  1505 
  1465     // Reset connection info.
  1506     // Reset connection info.
  1466     // 
  1507     // 
  1467     iMyServer.Events()->ResetIapConnInfo( currentIap );
  1508     iMyServer.Events()->ResetIapConnInfo( currentIap );
  1468 
  1509 
       
  1510     // Check if IAP is reported by MMS
       
  1511     //
       
  1512     TBool isMMSIap = IsMMSIap( currentIap );
       
  1513     if ( isMMSIap )
       
  1514         {
       
  1515         MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
       
  1516         - DisconnectDialog is not started because of MMS reported IAP" )
       
  1517         }
       
  1518 
  1469     TInt* returnError( NULL );
  1519     TInt* returnError( NULL );
  1470     switch ( state )
  1520     if ( ( state == EStarting ) || ( state == ERoaming ) )
  1471         {
  1521         {
  1472         case EStarting: 
  1522         // Process error according to the fact that the connection 
  1473             if ( ( snapId == 0 ) || ( error == KErrCancel ) )
  1523         // has not yet been started.
  1474                 {
  1524         // 
  1475                 neededAction = EPropagateError;
  1525         if ( DisconnectDlgErrorCode( error ) &&
  1476 
  1526              !IsBackgroundApplication( iAppUid ) &&
  1477                 MPMLOGSTRING(
  1527              !isMMSIap && 
  1478                     "CMPMServerSession::HandleServerProcessErrorL - \
  1528              iIapSelection->MpmConnPref().DisconnectDialog() &&
  1479                 Tell BM to end the client connection with appropriate error code" )
  1529              iMyServer.StartedConnectionExists() != KErrNotFound )
  1480                 }
  1530             {
  1481             else
  1531             // Start the Disconnect dialog
  1482                 {
  1532             // 
  1483                 neededAction = EDoReselection;
  1533             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
  1484 
  1534  - Start Disconnect dialog" )
  1485                 MPMLOGSTRING(
  1535             iDisconnectDlg = CMPMDisconnectDlg::NewL( *const_cast<CMPMServerSession*>(this),
  1486                     "CMPMServerSession::HandleServerProcessErrorL - \
  1536                                                       error,
  1487                 Tell BM to ignore error and do reselection" )
  1537                                                       *MyServer().DisconnectQueue() );
       
  1538             iDisconnectDialogShown = ETrue;
       
  1539             return;
       
  1540             }
       
  1541         else
       
  1542             {
       
  1543             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
       
  1544 Error not handled with disconnect dialog" )
       
  1545 
       
  1546             if ( state == EStarting ) 
       
  1547                 {
       
  1548                 if ( ( snapId == 0 ) || ( error == KErrCancel ) )
       
  1549                     {
       
  1550                     neededAction = EPropagateError;
       
  1551 
       
  1552                     MPMLOGSTRING(
       
  1553                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1554 Tell BM to end the client connection with appropriate error code" )
       
  1555                     }
       
  1556                 else
       
  1557                     {
       
  1558                     neededAction = EDoReselection;
       
  1559 
       
  1560                     MPMLOGSTRING(
       
  1561                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1562 Tell BM to ignore error and do reselection" )
       
  1563 
       
  1564                     iMyServer.HandleServerBlackListIap( connId, 
       
  1565                                                         currentIap, 
       
  1566                                                         ETemporary );
       
  1567                     if ( ( presumedIap != 0 ) && 
       
  1568                          ( presumedIap != currentIap ) )
       
  1569                         {
       
  1570                         iMyServer.HandleServerBlackListIap( connId, 
       
  1571                                                             presumedIap, 
       
  1572                                                             ETemporary );
       
  1573                         }
       
  1574                     }
       
  1575                 }
       
  1576             else if ( state == ERoaming ) 
       
  1577                 {
       
  1578                 // ERoaming means commsfw stack is moving to new IAP and failed.
       
  1579                 // Hence, MPM should mark to current iap as zero. 
       
  1580                 //
       
  1581                 iMyServer.ResetBMConnection( iConnId, currentIap, *this );
       
  1582                 
       
  1583                 // Notification will be sent with latest 
       
  1584                 // availability info
       
  1585                 //
       
  1586                 iStoredIapInfo.ResetStoredIapInfo();
       
  1587 
       
  1588                 neededAction = EIgnoreError;
  1488 
  1589 
  1489                 iMyServer.HandleServerBlackListIap( connId, 
  1590                 iMyServer.HandleServerBlackListIap( connId, 
  1490                                                     currentIap, 
  1591                                                     currentIap, 
  1491                                                     ETemporary );
  1592                                                     ETemporary );
  1492                 if ( ( presumedIap != 0 ) && 
  1593                 if ( ( presumedIap != 0 ) && 
  1493                     ( presumedIap != currentIap ) )
  1594                      ( presumedIap != currentIap ) )
  1494                     {
  1595                     {
  1495                     iMyServer.HandleServerBlackListIap( connId, 
  1596                     iMyServer.HandleServerBlackListIap( connId, 
  1496                                                         presumedIap, 
  1597                                                         presumedIap, 
  1497                                                         ETemporary );
  1598                                                         ETemporary );
  1498                     }
  1599                     }
  1499                 }
  1600                 TRAP( error, PrefIAPNotificationL( availableIAPs, 
       
  1601                                                    EBearerMan ) );
       
  1602                 if ( error == KErrNotFound )
       
  1603                     {
       
  1604                     neededAction = EPropagateError;
       
  1605 
       
  1606                     returnError = &error;
       
  1607 
       
  1608                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound, 
       
  1609                                                      EMPMMobilityErrorNotification ) );
       
  1610                     MPMLOGSTRING(
       
  1611                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1612 Tell BM to end the client connection with appropriate error code" )
       
  1613                     }
       
  1614                 else
       
  1615                     {
       
  1616                     MPMLOGSTRING(
       
  1617                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1618 Tell BM to ignore error and let MPM notify application about preferred IAP" )
       
  1619                     }
       
  1620                 }
       
  1621             else
       
  1622                 {
       
  1623                 MPMLOGSTRING2(
       
  1624                     "CMPMServerSession::HandleServerProcessErrorL - \
       
  1625 Unknown state %d", state )
       
  1626                 }
       
  1627 
  1500             // Error might be different from KErrNone if there 
  1628             // Error might be different from KErrNone if there 
  1501             // is no preferred IAP among the available IAPs.
  1629             // is no preferred IAP among the available IAPs.
  1502             // 
  1630             // 
  1503             ProcessErrorComplete( KErrNone,
  1631             ProcessErrorComplete( KErrNone,
  1504                                   returnError,
  1632                                   returnError,
  1505                                   &neededAction );
  1633                                   &neededAction );
  1506             break;
       
  1507             
  1634             
  1508         case ERoaming: 
  1635             iMyServer.HandlePendingMsgs( currentIap,
  1509             // ERoaming means commsfw stack is moving to new IAP and failed.
  1636                                          KErrNone,
  1510             // Hence, MPM should mark to current iap as zero. 
  1637                                          returnError,
       
  1638                                          &neededAction );
       
  1639             return;
       
  1640             }
       
  1641         }
       
  1642     else if ( state == EStarted )
       
  1643         {
       
  1644         // Process error according to the fact that the connection 
       
  1645         // has already been started.
       
  1646         // KErrConnectionTerminated is received when user disconnects
       
  1647         // connection from Settings/Connection mgr.
       
  1648         //       
       
  1649         if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) || ( error == KErrConnectionTerminated )
       
  1650                 || ( error == KErrDisconnected && iMyServer.IsPhoneOffline() ) )
       
  1651             {
       
  1652             neededAction = EPropagateError;
       
  1653 
       
  1654             MPMLOGSTRING(
       
  1655                 "CMPMServerSession::HandleServerProcessErrorL - \
       
  1656 Tell BM to end the client connection with appropriate error code" )
       
  1657 
       
  1658             // Send error notification. 
       
  1659             // Not sent if connection not registered
       
  1660             // 
       
  1661             TRAP_IGNORE( ErrorNotificationL( error,
       
  1662                                              EMPMMobilityErrorNotification ) )
       
  1663             }
       
  1664         else if ( iPreferredIAPRequested )
       
  1665             {
       
  1666             // IAP connection
  1511             //
  1667             //
  1512             iMyServer.ResetBMConnection( iConnId, currentIap, *this );
  1668             if( snapId == 0 )
  1513                 
       
  1514             // Notification will be sent with latest 
       
  1515             // availability info
       
  1516             //
       
  1517             iStoredIapInfo.ResetStoredIapInfo();
       
  1518             
       
  1519             neededAction = EIgnoreError;
       
  1520 
       
  1521             iMyServer.HandleServerBlackListIap( connId, 
       
  1522                                                 currentIap, 
       
  1523                                                 ETemporary );
       
  1524             if ( ( presumedIap != 0 ) && 
       
  1525                 ( presumedIap != currentIap ) )
       
  1526                 {
       
  1527                 iMyServer.HandleServerBlackListIap( connId, 
       
  1528                                                     presumedIap, 
       
  1529                                                     ETemporary );
       
  1530                 }
       
  1531             TRAP( error, PrefIAPNotificationL( availableIAPs, 
       
  1532                                                    EBearerMan ) );
       
  1533             if ( error == KErrNotFound )
       
  1534                 {
  1669                 {
  1535                 neededAction = EPropagateError;
  1670                 neededAction = EPropagateError;
  1536 
  1671     
  1537                 returnError = &error;
       
  1538 
       
  1539                 TRAP_IGNORE( ErrorNotificationL( KErrNotFound, 
       
  1540                                                 EMPMMobilityErrorNotification ) );
       
  1541                 MPMLOGSTRING(
  1672                 MPMLOGSTRING(
  1542                     "CMPMServerSession::HandleServerProcessErrorL - \
  1673                     "CMPMServerSession::HandleServerProcessErrorL - \
  1543                 Tell BM to end the client connection with appropriate error code" )
  1674 Tell BM to end the client connection with appropriate error code" )
  1544                 }
  1675 
       
  1676                 TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1677                                                  EMPMMobilityErrorNotification ) )
       
  1678                 }
       
  1679             // SNAP connection
       
  1680             //
  1545             else
  1681             else
  1546                 {
  1682                 {
  1547                 MPMLOGSTRING(
  1683                 // If this has been WLAN IAP and the SNAP contains 
  1548                     "CMPMServerSession::HandleServerProcessErrorL - \
  1684                 // other WLAN IAPs, we need to perform WLAN scan before
  1549                 Tell BM to ignore error and let MPM notify application about preferred IAP" )
  1685                 // knowing the availability of those
  1550                 }
  1686                 //
  1551             
  1687                 RArray<TUint> iapPath;
  1552             // Error might be different from KErrNone if there 
  1688                 CleanupClosePushL( iapPath );
  1553             // is no preferred IAP among the available IAPs.
  1689 
  1554             // 
  1690                 iMyServer.HandleServerBlackListIap( connId, 
  1555             ProcessErrorComplete( KErrNone,
  1691                                                     currentIap, 
  1556                                   returnError,
  1692                                                     ETemporary );
  1557                                   &neededAction );
  1693                 if ( ( presumedIap != 0 ) && 
  1558             break;
  1694                      ( presumedIap != currentIap ) )
  1559       
  1695                     {
  1560         case EStarted:
  1696                     iMyServer.HandleServerBlackListIap( connId, 
  1561             // Process error according to the fact that the connection 
  1697                                                         presumedIap, 
  1562             // has already been started.
  1698                                                         ETemporary );
  1563             // KErrConnectionTerminated is received when user disconnects
  1699                     }
  1564             // connection from Settings/Connection mgr.
  1700 
  1565             //         
  1701                 // current iap is either WLAN or EasyWlan
  1566             if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) || ( error == KErrConnectionTerminated ) )
       
  1567                 {
       
  1568                 neededAction = EPropagateError;
       
  1569 
       
  1570                 MPMLOGSTRING(
       
  1571                     "CMPMServerSession::HandleServerProcessErrorL - \
       
  1572                     Tell BM to end the client connection with appropriate error code" )
       
  1573 
       
  1574                 // Send error notification. 
       
  1575                 // Not sent if connection not registered
       
  1576                 // 
  1702                 // 
  1577                 TRAP_IGNORE( ErrorNotificationL( error,
  1703                 if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
  1578                                              EMPMMobilityErrorNotification ) )
  1704                       iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
  1579                 }
       
  1580             else if ( iPreferredIAPRequested )
       
  1581                 {
       
  1582                 // IAP connection
       
  1583                 //
       
  1584                 if( snapId == 0 )
       
  1585                     {
  1705                     {
       
  1706                     // perform WLAN scan 
       
  1707                     // message is completed in callback function 
       
  1708                     // ProcessErrorWlanScanCompletedL
       
  1709                     // 
       
  1710                     iMyServer.Events()->ScanWLANNetworksL( this, 
       
  1711                                                            ConnectionId(), 
       
  1712                                                            EWlanScanCallbackProcessErr );
       
  1713                     CleanupStack::PopAndDestroy( &iapPath );
       
  1714                     return;
       
  1715                     }
       
  1716 
       
  1717                 CleanupStack::PopAndDestroy( &iapPath );
       
  1718                 neededAction = EIgnoreError;
       
  1719 
       
  1720                 TRAPD( err2, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
       
  1721                 if ( err2 == KErrNotFound )
       
  1722                     {
       
  1723                     error = err2;
  1586                     neededAction = EPropagateError;
  1724                     neededAction = EPropagateError;
  1587     
  1725 
       
  1726                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1727                                                      EMPMMobilityErrorNotification ) )
  1588                     MPMLOGSTRING(
  1728                     MPMLOGSTRING(
  1589                         "CMPMServerSession::HandleServerProcessErrorL - \
  1729                         "CMPMServerSession::HandleServerProcessErrorL - \
  1590                         Tell BM to end the client connection with appropriate error code" )
  1730 Tell BM to end the client connection with appropriate error code" )   
  1591 
       
  1592                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1593                                                      EMPMMobilityErrorNotification ) )
       
  1594                     }
  1731                     }
  1595                 // SNAP connection
       
  1596                 //
       
  1597                 else
  1732                 else
  1598                     {
  1733                     {
  1599                     // If this has been WLAN IAP and the SNAP contains 
  1734                     MPMLOGSTRING(
  1600                     // other WLAN IAPs, we need to perform WLAN scan before
  1735                         "CMPMServerSession::HandleServerProcessErrorL - \
  1601                     // knowing the availability of those
  1736 Tell BM to ignore error and let MPM notify application about preferred IAP" )
  1602                     //
       
  1603                     RArray<TUint> iapPath;
       
  1604                     CleanupClosePushL( iapPath );
       
  1605 
       
  1606                     iMyServer.HandleServerBlackListIap( connId, 
       
  1607                                                     currentIap, 
       
  1608                                                     ETemporary );
       
  1609                     if ( ( presumedIap != 0 ) && 
       
  1610                         ( presumedIap != currentIap ) )
       
  1611                         {
       
  1612                         iMyServer.HandleServerBlackListIap( connId, 
       
  1613                                                         presumedIap, 
       
  1614                                                         ETemporary );
       
  1615                         }
       
  1616 
       
  1617                     // current iap is WLAN
       
  1618                     // 
       
  1619                     if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
       
  1620                         iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
       
  1621                         {
       
  1622                         // perform WLAN scan 
       
  1623                         // message is completed in callback function 
       
  1624                         // ProcessErrorWlanScanCompletedL
       
  1625                         // 
       
  1626                         iMyServer.Events()->ScanWLANNetworksL( this, 
       
  1627                                                            ConnectionId(), 
       
  1628                                                            EWlanScanCallbackProcessErr );
       
  1629                         CleanupStack::PopAndDestroy( &iapPath );
       
  1630                         return;
       
  1631                         }
       
  1632 
       
  1633                     CleanupStack::PopAndDestroy( &iapPath );
       
  1634                     neededAction = EIgnoreError;
       
  1635 
       
  1636                     TRAPD( err2, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
       
  1637                     if ( err2 == KErrNotFound )
       
  1638                         {
       
  1639                         error = err2;
       
  1640                         neededAction = EPropagateError;
       
  1641 
       
  1642                         TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1643                                                          EMPMMobilityErrorNotification ) )
       
  1644                         MPMLOGSTRING(
       
  1645                             "CMPMServerSession::HandleServerProcessErrorL - \
       
  1646                             Tell BM to end the client connection with appropriate error code" )   
       
  1647                         }
       
  1648                     else
       
  1649                         {
       
  1650                         MPMLOGSTRING(
       
  1651                             "CMPMServerSession::HandleServerProcessErrorL - \
       
  1652                             Tell BM to ignore error and let MPM notify application about preferred IAP" )
       
  1653                         }
       
  1654                     }
  1737                     }
  1655                 }
  1738                 }
  1656             else
  1739             }
  1657                 {
  1740         else
  1658                 neededAction = EPropagateError;
  1741             {
  1659 
  1742             neededAction = EPropagateError;
  1660                 MPMLOGSTRING(
  1743 
  1661                     "CMPMServerSession::HandleServerProcessErrorL - \
  1744             MPMLOGSTRING(
  1662                     Tell BM to end the client connection with appropriate error code" )
  1745                 "CMPMServerSession::HandleServerProcessErrorL - \
  1663 
  1746 Tell BM to end the client connection with appropriate error code" )
  1664                 }
  1747 
  1665             ProcessErrorComplete( KErrNone, &error, &neededAction );
  1748             }
  1666             break;
  1749         ProcessErrorComplete( KErrNone, &error, &neededAction );
  1667             
  1750         
  1668         default:
  1751         }
  1669             MPMLOGSTRING2(
  1752     else
  1670                 "CMPMServerSession::HandleServerProcessErrorL Unknown state %d",
  1753         {
  1671                 state )
  1754         MPMLOGSTRING2(
  1672             ProcessErrorComplete( KErrCorrupt,
  1755             "CMPMServerSession::HandleServerProcessErrorL Unknown state %d",
  1673                                   NULL,
  1756             state )
  1674                                   NULL );
  1757         ProcessErrorComplete( KErrCorrupt,
  1675             break;
  1758                               NULL,
       
  1759                               NULL );
  1676         }
  1760         }
  1677     }
  1761     }
  1678 
  1762 
  1679 // -----------------------------------------------------------------------------
  1763 // -----------------------------------------------------------------------------
  1680 // CMPMServerSession::HandleServerRegisterPrefIAPNotifL
  1764 // CMPMServerSession::HandleServerRegisterPrefIAPNotifL
  2184         }
  2268         }
  2185 #endif // _DEBUG
  2269 #endif // _DEBUG
  2186 
  2270 
  2187     MPMLOGSTRING(
  2271     MPMLOGSTRING(
  2188             "CMPMServerSession::SortSnapL: Sorting completed" )
  2272             "CMPMServerSession::SortSnapL: Sorting completed" )
       
  2273     }
       
  2274 
       
  2275 // -----------------------------------------------------------------------------
       
  2276 // CMPMServerSession::UpdateConnectionDialog
       
  2277 // -----------------------------------------------------------------------------
       
  2278 //
       
  2279 void CMPMServerSession::UpdateConnectionDialogL()
       
  2280     {
       
  2281     if( iIapSelection )
       
  2282         {
       
  2283         iIapSelection->UpdateConnectionDialogL();
       
  2284         }
  2189     }
  2285     }
  2190 
  2286 
  2191 // -----------------------------------------------------------------------------
  2287 // -----------------------------------------------------------------------------
  2192 // CMPMServerSession::CompleteCarrierRejected
  2288 // CMPMServerSession::CompleteCarrierRejected
  2193 // -----------------------------------------------------------------------------
  2289 // -----------------------------------------------------------------------------
  2808     
  2904     
  2809     // Show the connecting discreet popup to the user when migrating to another iap
  2905     // Show the connecting discreet popup to the user when migrating to another iap
  2810     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
  2906     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
  2811             TExtendedConnPref::ENoteBehaviourConnDisableNotes) )
  2907             TExtendedConnPref::ENoteBehaviourConnDisableNotes) )
  2812         {
  2908         {
  2813         TBool connectionAlreadyActive = iMyServer.CheckIfStarted( aIapId, iConnId );
  2909         TConnectionState state = iMyServer.CheckUsageOfIap( aIapId, iConnId );
  2814         
  2910         TBool connectionAlreadyActive = (state == EStarted || state == EStarting || state == ERoaming);
  2815         iMyServer.ConnUiUtils()->ConnectingViaDiscreetPopup( aIapId,
  2911         CConnectionUiUtilities* connUiUtils = NULL;
  2816                                                   connectionAlreadyActive );
  2912         if (!connectionAlreadyActive )
       
  2913             {
       
  2914             TRAPD( popupError,
       
  2915                    connUiUtils = CConnectionUiUtilities::NewL();
       
  2916                    connUiUtils->ConnectingViaDiscreetPopup(
       
  2917                    			        aIapId );
       
  2918                    delete connUiUtils; );
       
  2919             if ( popupError && connUiUtils )
       
  2920                 {
       
  2921                 delete connUiUtils;
       
  2922                 }
       
  2923             }
  2817         }
  2924         }
  2818 
  2925 
  2819     TMpmNotificationStartIAP notifInfo;
  2926     TMpmNotificationStartIAP notifInfo;
  2820     notifInfo.iMPMNotificationType = EMPMStartIAPNotification;
  2927     notifInfo.iMPMNotificationType = EMPMStartIAPNotification;
  2821     notifInfo.iInfo.iIap = aIapId;
  2928     notifInfo.iInfo.iIap = aIapId;
  3013                 // Check if any of the unavailable WLAN IAPs have 
  3120                 // Check if any of the unavailable WLAN IAPs have 
  3014                 // the same SSID as the active WLAN connection.
  3121                 // the same SSID as the active WLAN connection.
  3015                 //
  3122                 //
  3016                 TBool usesSame( EFalse ); 
  3123                 TBool usesSame( EFalse ); 
  3017 
  3124 
  3018                 TRAP_IGNORE( iMyServer.CommsDatAccess()->MatchSSIDL( ssid, 
  3125                 if ( !iMyServer.CommsDatAccess()->CheckEasyWLanL( unavailableIAPs[i] ) )
  3019                                                                      unavailableIAPs[i], 
  3126                     {
  3020                                                                      usesSame,
  3127                     TRAP_IGNORE( iMyServer.CommsDatAccess()->MatchSSIDL( ssid, 
  3021                                                                      *this ) )
  3128                                                               unavailableIAPs[i], 
       
  3129                                                               usesSame,
       
  3130                                                               *this ) )
  3022                                                               
  3131                                                               
  3023                 if ( usesSame )
  3132                     if ( usesSame )
  3024                     {
  3133                         {
  3025                     // Append unavailable IAP to list of available IAPs
  3134                         // Append unavailable IAP to list of available IAPs
  3026                     // if it uses same SSID as active WLAN connection.
  3135                         // if it uses same SSID as active WLAN connection.
  3027                     // 
  3136                         // 
  3028                     MPMLOGSTRING2(
  3137                         MPMLOGSTRING2(
  3029                         "CMPMServerSession::AvailableUnblacklistedIapsL:\
  3138                             "CMPMServerSession::AvailableUnblacklistedIapsL:\
  3030  Append unavailable IapId = %i", unavailableIAPs[i] )
  3139  Append unavailable IapId = %i", unavailableIAPs[i] )
  3031                     aAvailableIAPs.AppendL( unavailableIAPs[i] );
  3140                         aAvailableIAPs.AppendL( unavailableIAPs[i] );
       
  3141                         }
  3032                     }
  3142                     }
  3033                 }
  3143                 }
  3034             }
  3144             }
  3035         CleanupStack::PopAndDestroy( &unavailableIAPs );
  3145         CleanupStack::PopAndDestroy( &unavailableIAPs );
  3036         }
  3146         }
  3244     TInt                aError,
  3354     TInt                aError,
  3245     const TMpmConnPref* aPolicyPref )
  3355     const TMpmConnPref* aPolicyPref )
  3246     {
  3356     {
  3247     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete aError = %d", aError )
  3357     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete aError = %d", aError )
  3248 
  3358 
       
  3359     // Show error popup if it's allowed per client request.
       
  3360 	// Error popup shown to SNAP only if error discreet has not been shown for IAP.
       
  3361     if ( ChooseBestIapCalled() && (!( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3362             TExtendedConnPref::ENoteBehaviourConnDisableNotes ))
       
  3363               && ( aError != KErrNone )
       
  3364               && ( iErrorDiscreetPopupShown == EFalse ) )
       
  3365         {
       
  3366         CConnectionUiUtilities* connUiUtils = NULL;
       
  3367         TRAPD( error, connUiUtils = CConnectionUiUtilities::NewL() );
       
  3368         if ( error == KErrNone && connUiUtils )
       
  3369             {
       
  3370             // Note: Below function shows the discreet popup only if the error code
       
  3371             // belongs to the set of errors that are shown to the user.
       
  3372             // Otherwise the popup is not shown.
       
  3373             connUiUtils->ConnectionErrorDiscreetPopup( aError );
       
  3374             delete connUiUtils;
       
  3375             connUiUtils = NULL;
       
  3376             }
       
  3377         }
  3249     
  3378     
  3250     // Try to write back arguments and complete message.
  3379     // Try to write back arguments and complete message.
  3251     // 
  3380     // 
  3252     if ( !iChooseIapMessage.IsNull() )
  3381     if ( !iChooseIapMessage.IsNull() )
  3253         {
  3382         {
  3299                 }
  3428                 }
  3300             }
  3429             }
  3301         MPMLOGSTRING( "CMPMServerSession::ChooseIapComplete Message completed" )
  3430         MPMLOGSTRING( "CMPMServerSession::ChooseIapComplete Message completed" )
  3302         iChooseIapMessage.Complete( aError );
  3431         iChooseIapMessage.Complete( aError );
  3303         }
  3432         }
  3304 
       
  3305     // Show error popup if it's allowed per client request
       
  3306     // Error popup shown to SNAP only if error discreet has not been shown for IAP.
       
  3307     if ( ChooseBestIapCalled() && (!( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3308             TExtendedConnPref::ENoteBehaviourConnDisableNotes ))
       
  3309             && ( aError != KErrNone ) 
       
  3310             && ( iErrorDiscreetPopupShown == EFalse ) )
       
  3311         {
       
  3312         // Note: Below function shows the discreet popup only if the error code
       
  3313         // belongs to the set of errors that are shown to the user.
       
  3314         // Otherwise the popup is not shown.
       
  3315         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( aError );
       
  3316         }
       
  3317     else if ( aError == KErrNone )
       
  3318         {
       
  3319         if (!( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3320             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) &&
       
  3321             ( IsMMSIap( aPolicyPref->IapId() ) == EFalse ) )
       
  3322             {
       
  3323             TBool connectionAlreadyActive =
       
  3324                 MyServer().CheckIfStarted( aPolicyPref->IapId(), iConnId );
       
  3325 
       
  3326             iMyServer.ConnUiUtils()->ConnectingViaDiscreetPopup( aPolicyPref->IapId(),
       
  3327                                                       connectionAlreadyActive );
       
  3328             }            
       
  3329         }
       
  3330     
  3433     
  3331     // Enable showing error discreet popup for SNAP again
  3434     // Enable showing error discreet popup for SNAP again
  3332     iErrorDiscreetPopupShown = EFalse;
  3435     iErrorDiscreetPopupShown = EFalse;
  3333     }
  3436     }
  3334 
  3437 
  3340 void CMPMServerSession::ProcessErrorComplete( TInt             aError, 
  3443 void CMPMServerSession::ProcessErrorComplete( TInt             aError, 
  3341                                               TInt*            aErrorReturned,
  3444                                               TInt*            aErrorReturned,
  3342                                               TBMNeededAction* aNeededAction )
  3445                                               TBMNeededAction* aNeededAction )
  3343     {
  3446     {
  3344     MPMLOGSTRING2( "CMPMServerSession::ProcessErrorComplete aError = %d", aError )
  3447     MPMLOGSTRING2( "CMPMServerSession::ProcessErrorComplete aError = %d", aError )
       
  3448 
       
  3449     delete iDisconnectDlg;
       
  3450     iDisconnectDlg = NULL;
  3345     
  3451     
  3346     if ( !iProcessErrorMessage.IsNull() )
  3452     if ( !iProcessErrorMessage.IsNull() )
  3347         {
  3453         {
  3348         // Try to write back arguments and complete message.
  3454         // Try to write back arguments and complete message.
  3349         // Traps are not necesary here. If WriteL functions leave the
  3455         // Traps are not necesary here. If WriteL functions leave the
  3476                 }
  3582                 }
  3477             }
  3583             }
  3478         }
  3584         }
  3479     
  3585     
  3480     return EFalse;
  3586     return EFalse;
  3481     }
       
  3482 
       
  3483 // -----------------------------------------------------------------------------
       
  3484 // CMPMServerSession::SetVpnUserConnectionUsed
       
  3485 // -----------------------------------------------------------------------------
       
  3486 //
       
  3487 void CMPMServerSession::SetVpnUserConnectionUsed( const TBool aUseVpnUserConnection )
       
  3488     {
       
  3489     if ( aUseVpnUserConnection )
       
  3490         {
       
  3491         iVpnUserConnectionUsed = ETrue;
       
  3492         iMyServer.AddVpnUserConnectionSession();        
       
  3493         }
       
  3494     else 
       
  3495         {
       
  3496         iVpnUserConnectionUsed = EFalse;
       
  3497         iMyServer.RemoveVpnUserConnectionSession();        
       
  3498         }
       
  3499     }
  3587     }
  3500 
  3588 
  3501 // -----------------------------------------------------------------------------
  3589 // -----------------------------------------------------------------------------
  3502 // CMPMServerSession::IsWlanOnlyL
  3590 // CMPMServerSession::IsWlanOnlyL
  3503 // -----------------------------------------------------------------------------
  3591 // -----------------------------------------------------------------------------