bearermanagement/mpm/src/mpmserversession.cpp
changeset 40 c5b848e6c7d1
parent 32 5c4486441ae6
child 41 bbb64eb3bdee
equal deleted inserted replaced
34:3b0cec605979 40:c5b848e6c7d1
     1 /*
     1 /*
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2004-2010 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 "mpmdisconnectdlg.h"
       
    42 #include "mpmconfirmdlgstarting.h"
    41 #include "mpmconfirmdlgstarting.h"
    43 #include "mpmconfirmdlgroaming.h"
    42 #include "mpmconfirmdlgroaming.h"
    44 #include "mpmlogger.h"
    43 #include "mpmlogger.h"
    45 #include "mpmpropertydef.h"
    44 #include "mpmpropertydef.h"
    46 #include "mpmiapselection.h"
    45 #include "mpmiapselection.h"
    67 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    68 //
    67 //
    69 CMPMServerSession::CMPMServerSession(CMPMServer& aServer)
    68 CMPMServerSession::CMPMServerSession(CMPMServer& aServer)
    70     : CSession2(), 
    69     : CSession2(), 
    71       iMyServer( aServer ),
    70       iMyServer( aServer ),
    72       iDisconnectDlg( NULL ),
       
    73       iConfirmDlgRoaming( NULL ),
    71       iConfirmDlgRoaming( NULL ),
    74       iStoredIapInfo(),
    72       iStoredIapInfo(),
    75       iIapSelection( NULL ),
    73       iIapSelection( NULL ),
    76       iMigrateState( EMigrateNone ),
    74       iMigrateState( EMigrateNone )
    77       iDisconnectDialogShown( EFalse )
       
    78     {
    75     {
    79     }
    76     }
    80 
    77 
    81 
    78 
    82 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    87     {
    84     {
    88     MPMLOGSTRING( "CMPMServerSession::ConstructL" )
    85     MPMLOGSTRING( "CMPMServerSession::ConstructL" )
    89     if ( !iMyServer.Events() )
    86     if ( !iMyServer.Events() )
    90         {
    87         {
    91         iMyServer.SetEvents(CMPMConnMonEvents::NewL(
    88         iMyServer.SetEvents(CMPMConnMonEvents::NewL(
    92             *const_cast<CMPMServer*>( &iMyServer ), *this ));
    89             *const_cast<CMPMServer*>( &iMyServer ) ) );
    93         }
    90         }
    94 
    91 
    95     // Append session pointer to server
    92     // Append session pointer to server
    96     // 
    93     // 
    97     iMyServer.AppendSessionL( this );
    94     iMyServer.AppendSessionL( this );
   102 // CMPMServerSession::~CMPMServerSession
    99 // CMPMServerSession::~CMPMServerSession
   103 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
   104 //
   101 //
   105 CMPMServerSession::~CMPMServerSession()
   102 CMPMServerSession::~CMPMServerSession()
   106     {
   103     {
   107     delete iDisconnectDlg;
       
   108     delete iConfirmDlgRoaming;
   104     delete iConfirmDlgRoaming;
   109     delete iIapSelection;
   105     delete iIapSelection;
   110 
   106 
   111     // Remove serverside objects for notification session.
   107     // Remove serverside objects for notification session.
   112     // 
   108     // 
   418         aMessage.Complete( error );
   414         aMessage.Complete( error );
   419         return;
   415         return;
   420         }
   416         }
   421 
   417 
   422     // Store the Uid of the application to the member variable so 
   418     // Store the Uid of the application to the member variable so 
   423     // that it can be used to avoid DisconnectDialog popping up when 
   419     // that it can be used when AlwaysOnline connection is being established.
   424     // AlwaysOnline connection is being established.
       
   425     // 
   420     // 
   426     iAppUid = aMessage.Int2();
   421     iAppUid = aMessage.Int2();
   427 
   422 
   428     if ( !iIapSelection )
   423     if ( !iIapSelection )
   429         {
   424         {
   476             "CMPMServerSession::HandleServerCancelRequest - Complete with KErrNone" )
   471             "CMPMServerSession::HandleServerCancelRequest - Complete with KErrNone" )
   477             aMessage.Complete( KErrNone );
   472             aMessage.Complete( KErrNone );
   478             
   473             
   479             // Cancel WLAN scan request if one exists
   474             // Cancel WLAN scan request if one exists
   480             //
   475             //
   481             TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ) )
   476             TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ) )
   482             
   477             
   483             if ( iIapSelection )
   478             if ( iIapSelection )
   484                 {
   479                 {
   485                 delete iIapSelection;
   480                 delete iIapSelection;
   486                 iIapSelection = NULL;
   481                 iIapSelection = NULL;
   498             "CMPMServerSession::HandleServerCancelRequest - Complete with KErrNone" )
   493             "CMPMServerSession::HandleServerCancelRequest - Complete with KErrNone" )
   499             aMessage.Complete( KErrNone );
   494             aMessage.Complete( KErrNone );
   500 
   495 
   501             // Cancel WLAN scan request if one exists
   496             // Cancel WLAN scan request if one exists
   502             //
   497             //
   503             TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ) )
   498             TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ) )
   504 
   499 
   505             if ( iDisconnectDlg )
       
   506                 {
       
   507                 MPMLOGSTRING( "CMPMServerSession::HandleServerCancelRequest: \
       
   508 removing dconn dlg" )
       
   509                 delete iDisconnectDlg;
       
   510                 iDisconnectDlg = NULL;
       
   511                 }
       
   512             return;
   500             return;
   513             }
   501             }
   514         case EMPMWaitNotification:
   502         case EMPMWaitNotification:
   515             {
   503             {
   516             if ( iNotifRequested )
   504             if ( iNotifRequested )
   525             if ( !iServerSortSNAPMessage.IsNull() )
   513             if ( !iServerSortSNAPMessage.IsNull() )
   526                 {
   514                 {
   527                 // TODO Change CancelScanL to non-leaving.
   515                 // TODO Change CancelScanL to non-leaving.
   528                 // Otherwise, nothing clever can be done here.
   516                 // Otherwise, nothing clever can be done here.
   529                 // And OOM may risk MPM stability.
   517                 // And OOM may risk MPM stability.
   530                 TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ))
   518                 TRAP_IGNORE( iMyServer.Events()->CancelScanL( this ))
   531                 iServerSortSNAPMessage.Complete( KErrCancel );
   519                 iServerSortSNAPMessage.Complete( KErrCancel );
   532                 }
   520                 }
   533             break;
   521             break;
   534             }
   522             }
   535         default:
   523         default:
   807 
   795 
   808     if ( currentDataUsage == ECmCellularDataUsageConfirm )
   796     if ( currentDataUsage == ECmCellularDataUsageConfirm )
   809         {
   797         {
   810         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" )
   798         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - True" )
   811         isConfirmFirst = ETrue;
   799         isConfirmFirst = ETrue;
   812         
       
   813         // iDisconnectDialogShown is set when disconnect dialog is shown.
       
   814         // Before the disconnect dialog is shown, data usage confirmation
       
   815         // dialog is already shown for the new PDP context. If you choose
       
   816         // to disconnect the active PDP context then data usage dialog is
       
   817         // shown again for the new context. So, set isConfirmFirst to
       
   818         // False to avoid duplicate cellular confirm dialog
       
   819         //
       
   820         if ( iDisconnectDialogShown )
       
   821             {
       
   822             MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL  - False; Data \
       
   823 confirmation dialog already shown for this IAP" )
       
   824             isConfirmFirst = EFalse;
       
   825             iDisconnectDialogShown = EFalse;
       
   826             }
       
   827         }
   800         }
   828     else 
   801     else 
   829         {
   802         {
   830         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" )
   803         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" )
   831         }
   804         }
  1383 Warning: ChooseBestIap has not been called yet" )
  1356 Warning: ChooseBestIap has not been called yet" )
  1384         TBMNeededAction neededAction( EPropagateError );
  1357         TBMNeededAction neededAction( EPropagateError );
  1385         ProcessErrorComplete( KErrNone, &error, &neededAction );
  1358         ProcessErrorComplete( KErrNone, &error, &neededAction );
  1386         return;
  1359         return;
  1387         }
  1360         }
  1388 
  1361     
  1389     // Show error popup if it's allowed per client request
  1362     // Read the Connection Id of the application
  1390     // Don't show the pop up if error code is for disconnect dialog
  1363     // 
  1391     //
  1364     TConnectionId connId = iProcessErrorMessage.Int1();
  1392     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
  1365 
  1393             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) &&
  1366     MPMLOGSTRING3( "CMPMServerSession::HandleServerProcessErrorL\
  1394          !DisconnectDlgErrorCode( error ) )
  1367  - error code = %i, Connection Id = 0x%x", error, connId )
       
  1368 
       
  1369     // Get the current connection IapId for this connId 
       
  1370     //
       
  1371     TUint32 currentIap = iMyServer.GetBMIap( connId );
       
  1372 
       
  1373     // Get the current connection SNAP for this Connection Id
       
  1374     //
       
  1375     TUint32 snapId = iMyServer.GetBMSnap( connId );
       
  1376 
       
  1377     // The popup is shown if the connection is not silent and the
       
  1378     // error is something else than a disconnect dialog error code.
       
  1379     // The popup is also shown if the connection is silent and the
       
  1380     // error is a disconnect dlg error, a background application 
       
  1381     // is not in question, a MMS IAP is not
       
  1382     // in question, and a started connection does not exist.
       
  1383     TBool silent = iIapSelection->MpmConnPref().NoteBehaviour() &
       
  1384                 TExtendedConnPref::ENoteBehaviourConnDisableNotes;
       
  1385     if ( !silent && ( !DisconnectDlgErrorCode( error ) ||
       
  1386             ( !IsBackgroundApplication( iAppUid ) &&
       
  1387             !IsMMSIap( currentIap ) && 
       
  1388             iMyServer.StartedConnectionExists() != KErrNotFound ) ) )
  1395         {
  1389         {
  1396         // Note: Below function shows the discreet popup only if the error code
  1390         // Note: Below function shows the discreet popup only if the error code
  1397         // belongs to the set of errors that are shown to the user.
  1391         // belongs to the set of errors that are shown to the user.
  1398         // Otherwise the popup is not shown.
  1392         // Otherwise the popup is not shown.
  1399         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( error );
  1393         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( error );
  1400         }
  1394         }  
  1401 
       
  1402     // Read the Connection Id of the application
       
  1403     // 
       
  1404     TConnectionId connId = iProcessErrorMessage.Int1();
       
  1405 
       
  1406     MPMLOGSTRING3( "CMPMServerSession::HandleServerProcessErrorL\
       
  1407  - error code = %i, Connection Id = 0x%x", error, connId )
       
  1408 
       
  1409     // Get the current connection IapId for this connId 
       
  1410     //
       
  1411     TUint32 currentIap = iMyServer.GetBMIap( connId );
       
  1412 
       
  1413     // Get the current connection SNAP for this Connection Id
       
  1414     //
       
  1415     TUint32 snapId = iMyServer.GetBMSnap( connId );
       
  1416 
  1395 
  1417     TConnMonIapInfo availableIAPs;
  1396     TConnMonIapInfo availableIAPs;
  1418     availableIAPs = GetAvailableIAPs();
  1397     availableIAPs = GetAvailableIAPs();
  1419 
  1398 
  1420     RemoveUnavailableIap( availableIAPs, currentIap );
  1399     RemoveUnavailableIap( availableIAPs, currentIap );
  1423 
  1402 
  1424     // Get the state of the connection for this Iap Id.
  1403     // Get the state of the connection for this Iap Id.
  1425     // 
  1404     // 
  1426     TConnectionState state;
  1405     TConnectionState state;
  1427     iMyServer.GetConnectionState( connId, state );
  1406     iMyServer.GetConnectionState( connId, state );
       
  1407     MPMLOGSTRING2(
       
  1408         "CMPMServerSession::HandleServerProcessErrorL - state %d", state )
  1428 
  1409 
  1429     // We need to blacklist the presumed IAP too
  1410     // We need to blacklist the presumed IAP too
  1430     // 
  1411     // 
  1431     TUint32 presumedIap = MyServer().Events()->PresumedIapId( connId, 
  1412     TUint32 presumedIap = MyServer().Events()->PresumedIapId( connId, 
  1432                                                               currentIap );
  1413                                                               currentIap );
  1433 
  1414 
  1434     // Reset connection info.
  1415     // Reset connection info.
  1435     // 
  1416     // 
  1436     iMyServer.Events()->ResetIapConnInfo( currentIap );
  1417     iMyServer.Events()->ResetIapConnInfo( currentIap );
  1437 
  1418 
  1438     // Check if IAP is reported by MMS
       
  1439     //
       
  1440     TBool isMMSIap = IsMMSIap( currentIap );
       
  1441     if ( isMMSIap )
       
  1442         {
       
  1443         MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
       
  1444         - DisconnectDialog is not started because of MMS reported IAP" )
       
  1445         }
       
  1446 
       
  1447     TInt* returnError( NULL );
  1419     TInt* returnError( NULL );
  1448     if ( ( state == EStarting ) || ( state == ERoaming ) )
  1420     switch ( state )
  1449         {
  1421         {
  1450         // Process error according to the fact that the connection 
  1422         case EStarting: 
  1451         // has not yet been started.
  1423             if ( ( snapId == 0 ) || ( error == KErrCancel ) )
  1452         // 
  1424                 {
  1453         if ( DisconnectDlgErrorCode( error ) &&
  1425                 neededAction = EPropagateError;
  1454              !IsBackgroundApplication( iAppUid ) &&
  1426 
  1455              !isMMSIap && 
  1427                 MPMLOGSTRING(
  1456              iIapSelection->MpmConnPref().DisconnectDialog() &&
  1428                     "CMPMServerSession::HandleServerProcessErrorL - \
  1457              iMyServer.StartedConnectionExists() != KErrNotFound )
  1429                 Tell BM to end the client connection with appropriate error code" )
  1458             {
  1430                 }
  1459             // Start the Disconnect dialog
  1431             else
  1460             // 
  1432                 {
  1461             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
  1433                 neededAction = EDoReselection;
  1462  - Start Disconnect dialog" )
  1434 
  1463             iDisconnectDlg = CMPMDisconnectDlg::NewL( *const_cast<CMPMServerSession*>(this),
  1435                 MPMLOGSTRING(
  1464                                                       error,
  1436                     "CMPMServerSession::HandleServerProcessErrorL - \
  1465                                                       *MyServer().DisconnectQueue() );
  1437                 Tell BM to ignore error and do reselection" )
  1466             iDisconnectDialogShown = ETrue;
       
  1467             return;
       
  1468             }
       
  1469         else
       
  1470             {
       
  1471             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
       
  1472 Error not handled with disconnect dialog" )
       
  1473 
       
  1474             if ( state == EStarting ) 
       
  1475                 {
       
  1476                 if ( ( snapId == 0 ) || ( error == KErrCancel ) )
       
  1477                     {
       
  1478                     neededAction = EPropagateError;
       
  1479 
       
  1480                     MPMLOGSTRING(
       
  1481                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1482 Tell BM to end the client connection with appropriate error code" )
       
  1483                     }
       
  1484                 else
       
  1485                     {
       
  1486                     neededAction = EDoReselection;
       
  1487 
       
  1488                     MPMLOGSTRING(
       
  1489                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1490 Tell BM to ignore error and do reselection" )
       
  1491 
       
  1492                     iMyServer.HandleServerBlackListIap( connId, 
       
  1493                                                         currentIap, 
       
  1494                                                         ETemporary );
       
  1495                     if ( ( presumedIap != 0 ) && 
       
  1496                          ( presumedIap != currentIap ) )
       
  1497                         {
       
  1498                         iMyServer.HandleServerBlackListIap( connId, 
       
  1499                                                             presumedIap, 
       
  1500                                                             ETemporary );
       
  1501                         }
       
  1502                     }
       
  1503                 }
       
  1504             else if ( state == ERoaming ) 
       
  1505                 {
       
  1506                 // ERoaming means commsfw stack is moving to new IAP and failed.
       
  1507                 // Hence, MPM should mark to current iap as zero. 
       
  1508                 //
       
  1509                 iMyServer.ResetBMConnection( iConnId, currentIap, *this );
       
  1510                 
       
  1511                 // Notification will be sent with latest 
       
  1512                 // availability info
       
  1513                 //
       
  1514                 iStoredIapInfo.ResetStoredIapInfo();
       
  1515 
       
  1516                 neededAction = EIgnoreError;
       
  1517 
  1438 
  1518                 iMyServer.HandleServerBlackListIap( connId, 
  1439                 iMyServer.HandleServerBlackListIap( connId, 
  1519                                                     currentIap, 
  1440                                                     currentIap, 
  1520                                                     ETemporary );
  1441                                                     ETemporary );
  1521                 if ( ( presumedIap != 0 ) && 
  1442                 if ( ( presumedIap != 0 ) && 
  1522                      ( presumedIap != currentIap ) )
  1443                     ( presumedIap != currentIap ) )
  1523                     {
  1444                     {
  1524                     iMyServer.HandleServerBlackListIap( connId, 
  1445                     iMyServer.HandleServerBlackListIap( connId, 
  1525                                                         presumedIap, 
  1446                                                         presumedIap, 
  1526                                                         ETemporary );
  1447                                                         ETemporary );
  1527                     }
  1448                     }
  1528                 TRAP( error, PrefIAPNotificationL( availableIAPs, 
  1449                 }
  1529                                                    EBearerMan ) );
       
  1530                 if ( error == KErrNotFound )
       
  1531                     {
       
  1532                     neededAction = EPropagateError;
       
  1533 
       
  1534                     returnError = &error;
       
  1535 
       
  1536                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound, 
       
  1537                                                      EMPMMobilityErrorNotification ) );
       
  1538                     MPMLOGSTRING(
       
  1539                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1540 Tell BM to end the client connection with appropriate error code" )
       
  1541                     }
       
  1542                 else
       
  1543                     {
       
  1544                     MPMLOGSTRING(
       
  1545                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1546 Tell BM to ignore error and let MPM notify application about preferred IAP" )
       
  1547                     }
       
  1548                 }
       
  1549             else
       
  1550                 {
       
  1551                 MPMLOGSTRING2(
       
  1552                     "CMPMServerSession::HandleServerProcessErrorL - \
       
  1553 Unknown state %d", state )
       
  1554                 }
       
  1555 
       
  1556             // Error might be different from KErrNone if there 
  1450             // Error might be different from KErrNone if there 
  1557             // is no preferred IAP among the available IAPs.
  1451             // is no preferred IAP among the available IAPs.
  1558             // 
  1452             // 
  1559             ProcessErrorComplete( KErrNone,
  1453             ProcessErrorComplete( KErrNone,
  1560                                   returnError,
  1454                                   returnError,
  1561                                   &neededAction );
  1455                                   &neededAction );
  1562             return;
  1456             break;
  1563             }
  1457             
  1564         }
  1458         case ERoaming: 
  1565     else if ( state == EStarted )
  1459             // ERoaming means commsfw stack is moving to new IAP and failed.
  1566         {
  1460             // Hence, MPM should mark to current iap as zero. 
  1567         // Process error according to the fact that the connection 
       
  1568         // has already been started.
       
  1569         //         
       
  1570         if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) )
       
  1571             {
       
  1572             neededAction = EPropagateError;
       
  1573 
       
  1574             MPMLOGSTRING(
       
  1575                 "CMPMServerSession::HandleServerProcessErrorL - \
       
  1576 Tell BM to end the client connection with appropriate error code" )
       
  1577 
       
  1578             // Send error notification. 
       
  1579             // Not sent if connection not registered
       
  1580             // 
       
  1581             TRAP_IGNORE( ErrorNotificationL( error,
       
  1582                                              EMPMMobilityErrorNotification ) )
       
  1583             }
       
  1584         else if ( iPreferredIAPRequested )
       
  1585             {
       
  1586             // IAP connection
       
  1587             //
  1461             //
  1588             if( snapId == 0 )
  1462             iMyServer.ResetBMConnection( iConnId, currentIap, *this );
       
  1463                 
       
  1464             // Notification will be sent with latest 
       
  1465             // availability info
       
  1466             //
       
  1467             iStoredIapInfo.ResetStoredIapInfo();
       
  1468             
       
  1469             neededAction = EIgnoreError;
       
  1470 
       
  1471             iMyServer.HandleServerBlackListIap( connId, 
       
  1472                                                 currentIap, 
       
  1473                                                 ETemporary );
       
  1474             if ( ( presumedIap != 0 ) && 
       
  1475                 ( presumedIap != currentIap ) )
       
  1476                 {
       
  1477                 iMyServer.HandleServerBlackListIap( connId, 
       
  1478                                                     presumedIap, 
       
  1479                                                     ETemporary );
       
  1480                 }
       
  1481             TRAP( error, PrefIAPNotificationL( availableIAPs, 
       
  1482                                                    EBearerMan ) );
       
  1483             if ( error == KErrNotFound )
  1589                 {
  1484                 {
  1590                 neededAction = EPropagateError;
  1485                 neededAction = EPropagateError;
  1591     
  1486 
       
  1487                 returnError = &error;
       
  1488 
       
  1489                 TRAP_IGNORE( ErrorNotificationL( KErrNotFound, 
       
  1490                                                 EMPMMobilityErrorNotification ) );
  1592                 MPMLOGSTRING(
  1491                 MPMLOGSTRING(
  1593                     "CMPMServerSession::HandleServerProcessErrorL - \
  1492                     "CMPMServerSession::HandleServerProcessErrorL - \
  1594 Tell BM to end the client connection with appropriate error code" )
  1493                 Tell BM to end the client connection with appropriate error code" )
  1595 
  1494                 }
  1596                 TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1597                                                  EMPMMobilityErrorNotification ) )
       
  1598                 }
       
  1599             // SNAP connection
       
  1600             //
       
  1601             else
  1495             else
  1602                 {
  1496                 {
  1603                 // If this has been WLAN IAP and the SNAP contains 
  1497                 MPMLOGSTRING(
  1604                 // other WLAN IAPs, we need to perform WLAN scan before
  1498                     "CMPMServerSession::HandleServerProcessErrorL - \
  1605                 // knowing the availability of those
  1499                 Tell BM to ignore error and let MPM notify application about preferred IAP" )
       
  1500                 }
       
  1501             
       
  1502             // Error might be different from KErrNone if there 
       
  1503             // is no preferred IAP among the available IAPs.
       
  1504             // 
       
  1505             ProcessErrorComplete( KErrNone,
       
  1506                                   returnError,
       
  1507                                   &neededAction );
       
  1508             break;
       
  1509       
       
  1510         case EStarted:
       
  1511             // Process error according to the fact that the connection 
       
  1512             // has already been started.
       
  1513             //         
       
  1514             if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) )
       
  1515                 {
       
  1516                 neededAction = EPropagateError;
       
  1517 
       
  1518                 MPMLOGSTRING(
       
  1519                     "CMPMServerSession::HandleServerProcessErrorL - \
       
  1520                     Tell BM to end the client connection with appropriate error code" )
       
  1521 
       
  1522                 // Send error notification. 
       
  1523                 // Not sent if connection not registered
       
  1524                 // 
       
  1525                 TRAP_IGNORE( ErrorNotificationL( error,
       
  1526                                              EMPMMobilityErrorNotification ) )
       
  1527                 }
       
  1528             else if ( iPreferredIAPRequested )
       
  1529                 {
       
  1530                 // IAP connection
  1606                 //
  1531                 //
  1607                 RArray<TUint> iapPath;
  1532                 if( snapId == 0 )
  1608                 CleanupClosePushL( iapPath );
  1533                     {
  1609 
  1534                     neededAction = EPropagateError;
  1610                 iMyServer.HandleServerBlackListIap( connId, 
  1535     
       
  1536                     MPMLOGSTRING(
       
  1537                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1538                         Tell BM to end the client connection with appropriate error code" )
       
  1539 
       
  1540                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1541                                                      EMPMMobilityErrorNotification ) )
       
  1542                     }
       
  1543                 // SNAP connection
       
  1544                 //
       
  1545                 else
       
  1546                     {
       
  1547                     // If this has been WLAN IAP and the SNAP contains 
       
  1548                     // other WLAN IAPs, we need to perform WLAN scan before
       
  1549                     // knowing the availability of those
       
  1550                     //
       
  1551                     RArray<TUint> iapPath;
       
  1552                     CleanupClosePushL( iapPath );
       
  1553 
       
  1554                     iMyServer.HandleServerBlackListIap( connId, 
  1611                                                     currentIap, 
  1555                                                     currentIap, 
  1612                                                     ETemporary );
  1556                                                     ETemporary );
  1613                 if ( ( presumedIap != 0 ) && 
  1557                     if ( ( presumedIap != 0 ) && 
  1614                      ( presumedIap != currentIap ) )
  1558                         ( presumedIap != currentIap ) )
  1615                     {
  1559                         {
  1616                     iMyServer.HandleServerBlackListIap( connId, 
  1560                         iMyServer.HandleServerBlackListIap( connId, 
  1617                                                         presumedIap, 
  1561                                                         presumedIap, 
  1618                                                         ETemporary );
  1562                                                         ETemporary );
  1619                     }
  1563                         }
  1620 
  1564 
  1621                 // current iap is WLAN
  1565                     // current iap is WLAN
  1622                 // 
       
  1623                 if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
       
  1624                       iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
       
  1625                     {
       
  1626                     // perform WLAN scan 
       
  1627                     // message is completed in callback function 
       
  1628                     // ProcessErrorWlanScanCompletedL
       
  1629                     // 
  1566                     // 
  1630                     iMyServer.Events()->ScanWLANNetworksL( this, 
  1567                     if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
       
  1568                         iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
       
  1569                         {
       
  1570                         // perform WLAN scan 
       
  1571                         // message is completed in callback function 
       
  1572                         // ProcessErrorWlanScanCompletedL
       
  1573                         // 
       
  1574                         iMyServer.Events()->ScanWLANNetworksL( this, 
  1631                                                            ConnectionId(), 
  1575                                                            ConnectionId(), 
  1632                                                            EWlanScanCallbackProcessErr );
  1576                                                            EWlanScanCallbackProcessErr );
       
  1577                         CleanupStack::PopAndDestroy( &iapPath );
       
  1578                         return;
       
  1579                         }
       
  1580 
  1633                     CleanupStack::PopAndDestroy( &iapPath );
  1581                     CleanupStack::PopAndDestroy( &iapPath );
  1634                     return;
  1582                     neededAction = EIgnoreError;
       
  1583 
       
  1584                     TRAPD( err2, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
       
  1585                     if ( err2 == KErrNotFound )
       
  1586                         {
       
  1587                         error = err2;
       
  1588                         neededAction = EPropagateError;
       
  1589 
       
  1590                         TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1591                                                          EMPMMobilityErrorNotification ) )
       
  1592                         MPMLOGSTRING(
       
  1593                             "CMPMServerSession::HandleServerProcessErrorL - \
       
  1594                             Tell BM to end the client connection with appropriate error code" )   
       
  1595                         }
       
  1596                     else
       
  1597                         {
       
  1598                         MPMLOGSTRING(
       
  1599                             "CMPMServerSession::HandleServerProcessErrorL - \
       
  1600                             Tell BM to ignore error and let MPM notify application about preferred IAP" )
       
  1601                         }
  1635                     }
  1602                     }
  1636 
  1603                 }
  1637                 CleanupStack::PopAndDestroy( &iapPath );
  1604             else
  1638                 neededAction = EIgnoreError;
  1605                 {
  1639 
  1606                 neededAction = EPropagateError;
  1640                 TRAPD( err2, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
  1607 
  1641                 if ( err2 == KErrNotFound )
  1608                 MPMLOGSTRING(
  1642                     {
  1609                     "CMPMServerSession::HandleServerProcessErrorL - \
  1643                     error = err2;
  1610                     Tell BM to end the client connection with appropriate error code" )
  1644                     neededAction = EPropagateError;
  1611 
  1645 
  1612                 }
  1646                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
  1613             ProcessErrorComplete( KErrNone, &error, &neededAction );
  1647                                                      EMPMMobilityErrorNotification ) )
  1614             break;
  1648                     MPMLOGSTRING(
  1615             
  1649                         "CMPMServerSession::HandleServerProcessErrorL - \
  1616         default:
  1650 Tell BM to end the client connection with appropriate error code" )   
  1617             MPMLOGSTRING2(
  1651                     }
  1618                 "CMPMServerSession::HandleServerProcessErrorL Unknown state %d",
  1652                 else
  1619                 state )
  1653                     {
  1620             ProcessErrorComplete( KErrCorrupt,
  1654                     MPMLOGSTRING(
  1621                                   NULL,
  1655                         "CMPMServerSession::HandleServerProcessErrorL - \
  1622                                   NULL );
  1656 Tell BM to ignore error and let MPM notify application about preferred IAP" )
  1623             break;
  1657                     }
       
  1658                 }
       
  1659             }
       
  1660         else
       
  1661             {
       
  1662             neededAction = EPropagateError;
       
  1663 
       
  1664             MPMLOGSTRING(
       
  1665                 "CMPMServerSession::HandleServerProcessErrorL - \
       
  1666 Tell BM to end the client connection with appropriate error code" )
       
  1667 
       
  1668             }
       
  1669         ProcessErrorComplete( KErrNone, &error, &neededAction );
       
  1670         
       
  1671         }
       
  1672     else
       
  1673         {
       
  1674         MPMLOGSTRING2(
       
  1675             "CMPMServerSession::HandleServerProcessErrorL Unknown state %d",
       
  1676             state )
       
  1677         ProcessErrorComplete( KErrCorrupt,
       
  1678                               NULL,
       
  1679                               NULL );
       
  1680         }
  1624         }
  1681     }
  1625     }
  1682 
  1626 
  1683 // -----------------------------------------------------------------------------
  1627 // -----------------------------------------------------------------------------
  1684 // CMPMServerSession::HandleServerRegisterPrefIAPNotifL
  1628 // CMPMServerSession::HandleServerRegisterPrefIAPNotifL
  3315         // Note: Below function shows the discreet popup only if the error code
  3259         // Note: Below function shows the discreet popup only if the error code
  3316         // belongs to the set of errors that are shown to the user.
  3260         // belongs to the set of errors that are shown to the user.
  3317         // Otherwise the popup is not shown.
  3261         // Otherwise the popup is not shown.
  3318         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( aError );
  3262         iMyServer.ConnUiUtils()->ConnectionErrorDiscreetPopup( aError );
  3319         }
  3263         }
  3320     else
  3264     else if ( aError == KErrNone )
  3321         {
  3265         {
  3322         if (!( iIapSelection->MpmConnPref().NoteBehaviour() &
  3266         if (!( iIapSelection->MpmConnPref().NoteBehaviour() &
  3323             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
  3267             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) &&
       
  3268             ( IsMMSIap( aPolicyPref->IapId() ) == EFalse ) )
  3324             {
  3269             {
  3325             TBool connectionAlreadyActive =
  3270             TBool connectionAlreadyActive =
  3326                 MyServer().CheckIfStarted( aPolicyPref->IapId(), iConnId );
  3271                 MyServer().CheckIfStarted( aPolicyPref->IapId(), iConnId );
  3327 
  3272 
  3328             iMyServer.ConnUiUtils()->ConnectingViaDiscreetPopup( aPolicyPref->IapId(),
  3273             iMyServer.ConnUiUtils()->ConnectingViaDiscreetPopup( aPolicyPref->IapId(),
  3339 void CMPMServerSession::ProcessErrorComplete( TInt             aError, 
  3284 void CMPMServerSession::ProcessErrorComplete( TInt             aError, 
  3340                                               TInt*            aErrorReturned,
  3285                                               TInt*            aErrorReturned,
  3341                                               TBMNeededAction* aNeededAction )
  3286                                               TBMNeededAction* aNeededAction )
  3342     {
  3287     {
  3343     MPMLOGSTRING2( "CMPMServerSession::ProcessErrorComplete aError = %d", aError )
  3288     MPMLOGSTRING2( "CMPMServerSession::ProcessErrorComplete aError = %d", aError )
  3344 
       
  3345     delete iDisconnectDlg;
       
  3346     iDisconnectDlg = NULL;
       
  3347     
  3289     
  3348     if ( !iProcessErrorMessage.IsNull() )
  3290     if ( !iProcessErrorMessage.IsNull() )
  3349         {
  3291         {
  3350         // Try to write back arguments and complete message.
  3292         // Try to write back arguments and complete message.
  3351         // Traps are not necesary here. If WriteL functions leave the
  3293         // Traps are not necesary here. If WriteL functions leave the