bearermanagement/mpm/src/mpmserversession.cpp
branchRCL_3
changeset 69 cf1b3ddbe9a1
parent 65 14754bf06654
equal deleted inserted replaced
65:14754bf06654 69:cf1b3ddbe9a1
    74       iDisconnectDlg( NULL ),
    74       iDisconnectDlg( NULL ),
    75       iConfirmDlgRoaming( NULL ),
    75       iConfirmDlgRoaming( NULL ),
    76       iStoredIapInfo(),
    76       iStoredIapInfo(),
    77       iIapSelection( NULL ),
    77       iIapSelection( NULL ),
    78       iMigrateState( EMigrateNone ),
    78       iMigrateState( EMigrateNone ),
    79       iDisconnectDialogShown( EFalse ),
    79       iDisconnectDialogShown( EFalse )
    80       iErrorDiscreetPopupShown( EFalse )
       
    81     {
    80     {
    82     }
    81     }
    83 
    82 
    84 
    83 
    85 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
   105 // CMPMServerSession::~CMPMServerSession
   104 // CMPMServerSession::~CMPMServerSession
   106 // -----------------------------------------------------------------------------
   105 // -----------------------------------------------------------------------------
   107 //
   106 //
   108 CMPMServerSession::~CMPMServerSession()
   107 CMPMServerSession::~CMPMServerSession()
   109     {
   108     {
   110     MPMLOGSTRING( "CMPMServerSession::~CMPMServerSession" )
   109     MPMLOGSTRING( "CMPMServerSession::~CMPMServerSession - start" )
   111 
   110 
   112 
   111     delete iDisconnectDlg;
   113     // Remove serverside objects for notification session.
   112     delete iConfirmDlgRoaming;
   114     // 
   113     delete iIapSelection;
   115     iMyServer.RemoveSession( this );
       
   116 
   114 
   117     if (UserConnection())
   115     if (UserConnection())
   118         {
   116         {
   119         iMyServer.ClearUserConnection();
   117         iMyServer.ClearUserConnection();
   120         ClearUserConnection();
   118         ClearUserConnection();
   135     // Clean up the blacklist table 
   133     // Clean up the blacklist table 
   136     iMyServer.HandleServerUnblackListIap( iConnId, 0 );
   134     iMyServer.HandleServerUnblackListIap( iConnId, 0 );
   137     
   135     
   138     // Make sure the connection is removed from server's information array.
   136     // Make sure the connection is removed from server's information array.
   139     iMyServer.RemoveBMConnection( iConnId, *this );
   137     iMyServer.RemoveBMConnection( iConnId, *this );
   140 
   138     
   141     delete iDisconnectDlg;
   139     // Remove server's objects releated to session.
   142     delete iConfirmDlgRoaming;
   140     iMyServer.RemoveSession( this );
   143     delete iIapSelection;
   141 
   144 
   142     MPMLOGSTRING( "CMPMServerSession::~CMPMServerSession - end" )
   145     }
   143     }
   146 
   144 
   147 
   145 
   148 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   149 // CMPMServerSession::ServiceL
   147 // CMPMServerSession::ServiceL
  1470             // belongs to the set of errors that are shown to the user.
  1468             // belongs to the set of errors that are shown to the user.
  1471             // Otherwise the popup is not shown.
  1469             // Otherwise the popup is not shown.
  1472             connUiUtils->ConnectionErrorDiscreetPopup( error );
  1470             connUiUtils->ConnectionErrorDiscreetPopup( error );
  1473             delete connUiUtils;
  1471             delete connUiUtils;
  1474             connUiUtils = NULL;
  1472             connUiUtils = NULL;
  1475             
       
  1476             // Error discreet popup has been shown. This is needed so that we
       
  1477             // dont show it again for SNAP.
       
  1478             iErrorDiscreetPopupShown = ETrue;
       
  1479             }
  1473             }
  1480         }
  1474         }
  1481 
  1475 
  1482     // Get the current connection IapId for this connId 
  1476     // Get the current connection IapId for this connId 
  1483     //
  1477     //
  1645         // Process error according to the fact that the connection 
  1639         // Process error according to the fact that the connection 
  1646         // has already been started.
  1640         // has already been started.
  1647         // KErrConnectionTerminated is received when user disconnects
  1641         // KErrConnectionTerminated is received when user disconnects
  1648         // connection from Settings/Connection mgr.
  1642         // connection from Settings/Connection mgr.
  1649         //       
  1643         //       
  1650         if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) || ( error == KErrConnectionTerminated )
  1644     if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) || ( error == KErrConnectionTerminated )
  1651                 || ( error == KErrDisconnected && iMyServer.IsPhoneOffline() ) )
  1645             || ( error == KErrDisconnected && iMyServer.IsPhoneOffline() ) )
  1652             {
  1646             {
  1653             neededAction = EPropagateError;
  1647             neededAction = EPropagateError;
  1654 
  1648 
  1655             MPMLOGSTRING(
  1649             MPMLOGSTRING(
  1656                 "CMPMServerSession::HandleServerProcessErrorL - \
  1650                 "CMPMServerSession::HandleServerProcessErrorL - \
  3355     TInt                aError,
  3349     TInt                aError,
  3356     const TMpmConnPref* aPolicyPref )
  3350     const TMpmConnPref* aPolicyPref )
  3357     {
  3351     {
  3358     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete aError = %d", aError )
  3352     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete aError = %d", aError )
  3359 
  3353 
       
  3354     // Show error popup if it's allowed per client request.
       
  3355 	// No error popup shown to SNAP.
       
  3356     if ( ChooseBestIapCalled() && (!( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3357             TExtendedConnPref::ENoteBehaviourConnDisableNotes ))
       
  3358             && ( aError != KErrNone ) 
       
  3359             && ( iIapSelection->MpmConnPref().SnapId() == 0 ) )
       
  3360         {
       
  3361         CConnectionUiUtilities* connUiUtils = NULL;
       
  3362         TRAPD( error, connUiUtils = CConnectionUiUtilities::NewL() );
       
  3363         if ( error == KErrNone && connUiUtils )
       
  3364             {
       
  3365             // Note: Below function shows the discreet popup only if the error code
       
  3366             // belongs to the set of errors that are shown to the user.
       
  3367             // Otherwise the popup is not shown.
       
  3368             connUiUtils->ConnectionErrorDiscreetPopup( aError );
       
  3369             delete connUiUtils;
       
  3370             connUiUtils = NULL;
       
  3371             }
       
  3372         }
       
  3373     
  3360     // Try to write back arguments and complete message.
  3374     // Try to write back arguments and complete message.
  3361     // 
  3375     // 
  3362     if ( !iChooseIapMessage.IsNull() )
  3376     if ( !iChooseIapMessage.IsNull() )
  3363         {
  3377         {
  3364         if ( aError == KErrNone && aPolicyPref )
  3378         if ( aError == KErrNone && aPolicyPref )
  3409                 }
  3423                 }
  3410             }
  3424             }
  3411         MPMLOGSTRING( "CMPMServerSession::ChooseIapComplete Message completed" )
  3425         MPMLOGSTRING( "CMPMServerSession::ChooseIapComplete Message completed" )
  3412         iChooseIapMessage.Complete( aError );
  3426         iChooseIapMessage.Complete( aError );
  3413         }
  3427         }
  3414 
       
  3415     CConnectionUiUtilities* connUiUtils( NULL );
       
  3416     
       
  3417     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete: this = %X", this )
       
  3418     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete: iIapSelection = %X", iIapSelection )
       
  3419 
       
  3420     // Enable showing error discreet popup for SNAP again
       
  3421     // Temp var used because session may get deleted during the showing of popup
       
  3422     TBool tempErrorDiscreetPopupShown = iErrorDiscreetPopupShown; 
       
  3423     iErrorDiscreetPopupShown = EFalse;
       
  3424     
       
  3425     // NOTE: Be careful with discreet popups! It jams session at this point
       
  3426     // for a moment, BUT the session may be called meanwhile.
       
  3427     // This may/will lead to problems e.g. if session is being deleted => all (heap) objects
       
  3428     // deleted in destructor are gone!
       
  3429     // Show error popup if it's allowed per client request.
       
  3430 	// Error popup shown to SNAP only if error discreet has not been shown for IAP.
       
  3431     if ( ChooseBestIapCalled() && (!( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3432             TExtendedConnPref::ENoteBehaviourConnDisableNotes ))
       
  3433               && ( aError != KErrNone )
       
  3434               && ( tempErrorDiscreetPopupShown == EFalse ) )
       
  3435         {
       
  3436         TRAPD( popupError, connUiUtils = CConnectionUiUtilities::NewL() );
       
  3437         if ( popupError == KErrNone )
       
  3438             {
       
  3439             // Note: Below function shows the discreet popup only if the error code
       
  3440             // belongs to the set of errors that are shown to the user.
       
  3441             // Otherwise the popup is not shown.
       
  3442             connUiUtils->ConnectionErrorDiscreetPopup( aError );
       
  3443             delete connUiUtils;
       
  3444             connUiUtils = NULL;
       
  3445             }
       
  3446         }
       
  3447     else if ( aPolicyPref &&
       
  3448                     ( aError == KErrNone ) &&
       
  3449                     !( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3450                             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
       
  3451         {
       
  3452         TConnectionState state = iMyServer.CheckUsageOfIap( aPolicyPref->IapId(), iConnId );
       
  3453 		TBool connectionAlreadyActive = (state == EStarted || state == EStarting || state == ERoaming);
       
  3454         if ( !connectionAlreadyActive &&
       
  3455                 ( IsMMSIap( aPolicyPref->IapId() ) == EFalse ) )
       
  3456             {
       
  3457             TRAPD( popupError, connUiUtils = CConnectionUiUtilities::NewL() );
       
  3458             if ( popupError == KErrNone )
       
  3459                 {
       
  3460                 connUiUtils->ConnectingViaDiscreetPopup( aPolicyPref->IapId() );
       
  3461                 delete connUiUtils;
       
  3462                 connUiUtils = NULL;
       
  3463                 }
       
  3464             }
       
  3465         }
       
  3466     }
  3428     }
  3467 
  3429 
  3468 
  3430 
  3469 // -----------------------------------------------------------------------------
  3431 // -----------------------------------------------------------------------------
  3470 // CMPMServerSession::ProcessErrorComplete
  3432 // CMPMServerSession::ProcessErrorComplete
  3571 // CMPMServerSession::UseUserConnPref
  3533 // CMPMServerSession::UseUserConnPref
  3572 // -----------------------------------------------------------------------------
  3534 // -----------------------------------------------------------------------------
  3573 //
  3535 //
  3574 TBool CMPMServerSession::UseUserConnPref()
  3536 TBool CMPMServerSession::UseUserConnPref()
  3575     {
  3537     {
  3576     if ((iAppUid != iMyServer.CsIdWatcher()->ConnectScreenId()) &&
  3538     if ( ( iAppUid != iMyServer.CsIdWatcher()->ConnectScreenId() ) &&
  3577         iMyServer.UserConnection())
  3539          iMyServer.UserConnection() )
  3578         {
  3540         {
  3579         MPMLOGSTRING( "CMPMServerSession::UseUserConnPref - User connection active" );
  3541         MPMLOGSTRING( "CMPMServerSession::UseUserConnPref - User connection active" );
       
  3542 
       
  3543         // If user connection is blacklisted for this connection, don't use it.
       
  3544         RArray<TUint32> blacklistedIaps;
       
  3545         CleanupClosePushL( blacklistedIaps );
       
  3546         iMyServer.GetBlacklistedIAP( iConnId, blacklistedIaps );
       
  3547         TInt blacklistedIapFoundError = blacklistedIaps.Find( iMyServer.UserConnPref()->IapId() );
       
  3548         CleanupStack::PopAndDestroy( &blacklistedIaps );
  3580         
  3549         
       
  3550         if ( blacklistedIapFoundError != KErrNotFound )
       
  3551             {
       
  3552             MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
       
  3553  User connection blacklisted -> don't use user connection" );
       
  3554             return EFalse;
       
  3555             }
       
  3556 
  3581         // Check whether default connection will be used
  3557         // Check whether default connection will be used
  3582         if ( iIapSelection->MpmConnPref().ConnType() == TMpmConnPref::EConnTypeDefault )
  3558         if ( iIapSelection->MpmConnPref().ConnType() == TMpmConnPref::EConnTypeDefault )
  3583             {
  3559             {
       
  3560             MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
       
  3561  Default connection -> use user connection" );
  3584             return ETrue;
  3562             return ETrue;
  3585             }
  3563             }
  3586         else if ( ( iIapSelection->MpmConnPref().ConnType() ==
  3564         else if ( ( iIapSelection->MpmConnPref().ConnType() ==
  3587                     TMpmConnPref::EConnTypeImplicit ) &&
  3565                     TMpmConnPref::EConnTypeImplicit ) &&
  3588                   PrefsAllowWlan() )
  3566                   PrefsAllowWlan() )
  3589             {            
  3567             {            
  3590             MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
  3568             MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
  3591  Prompt from the user" );
  3569  Prompt from the user -> use user connection" );
  3592             // Prompt from the user -> use user connection
  3570             // Prompt from the user -> use user connection
  3593             return ETrue;
  3571             return ETrue;
  3594             }
  3572             }
  3595         else
  3573         else
  3596             {
  3574             {
  3605                                      iIapSelection->MpmConnPref().IapId(),
  3583                                      iIapSelection->MpmConnPref().IapId(),
  3606                                      iIapSelection->MpmConnPref().SnapId() ) );
  3584                                      iIapSelection->MpmConnPref().SnapId() ) );
  3607 
  3585 
  3608             if ( ( error == KErrNone ) && ( isInternetSnap ) && PrefsAllowWlan() )
  3586             if ( ( error == KErrNone ) && ( isInternetSnap ) && PrefsAllowWlan() )
  3609                 {
  3587                 {
       
  3588                 MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
       
  3589  Application preferencies in Internet SNAP -> use user connection" );
  3610                 // Iap belongs to internet snap -> use user connection
  3590                 // Iap belongs to internet snap -> use user connection
  3611                 return ETrue;
  3591                 return ETrue;
  3612                 }
  3592                 }
  3613             }
  3593             }
  3614         }
  3594         }