bearermanagement/mpm/src/mpmserversession.cpp
changeset 0 5a93021fdf25
child 1 40cb640ef159
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: MPM server session implementation
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19 @file mpmserversession.cpp
       
    20 Mobility Policy Manager server session implementation.
       
    21 */
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <e32svr.h>
       
    25 #include <gsmerror.h>     // KErrPacketDataTsyMaxPdpContextsReached 
       
    26 #include <etelpckt.h>     // KErrUmtsMaxNumOfContextExceededByNetwork
       
    27 #include <bldvariant.hrh>                // For feature flags
       
    28 #include <featmgr.h>                     // FeatureManager
       
    29 #include <centralrepository.h>           // CRepository 
       
    30 #include <CoreApplicationUIsSDKCRKeys.h> // KCRUidCoreApplicationUIs, 
       
    31                                          // KCoreAppUIsNetworkConnectionAllowed
       
    32 #include <es_sock.h>
       
    33 #include <commdb.h>
       
    34 #include <commdbconnpref.h>
       
    35 #include <cmpluginbaseeng.h>
       
    36 #include <cdblen.h>
       
    37 #include <cmgenconnsettings.h>
       
    38 
       
    39 #include "mpmcommsdataccess.h"
       
    40 #include "mpmserversession.h"
       
    41 #include "mpmconnmonevents.h"
       
    42 #include "mpmdialog.h"
       
    43 #include "mpmdisconnectdlg.h"
       
    44 #include "mpmconfirmdlgstarting.h"
       
    45 #include "mpmconfirmdlgroaming.h"
       
    46 #include "mpmlogger.h"
       
    47 #include "mpmpropertydef.h"
       
    48 #include "mpmdefaultconnection.h"
       
    49 #include "mpmiapselection.h"
       
    50 #include "mpmcsidwatcher.h"
       
    51 
       
    52 // ============================ MEMBER FUNCTIONS ===============================
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CMPMServerSession::NewL
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CMPMServerSession* CMPMServerSession::NewL(CMPMServer& aServer)
       
    59     {
       
    60     CMPMServerSession* self = new ( ELeave ) CMPMServerSession(aServer);
       
    61     CleanupStack::PushL(self);
       
    62     self->ConstructL();
       
    63     CleanupStack::Pop(self);
       
    64     return self;
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CMPMServerSession::CMPMServerSession
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CMPMServerSession::CMPMServerSession(CMPMServer& aServer)
       
    73     : CSession2(), 
       
    74       iMyServer( aServer ),
       
    75       iDisconnectDlg( NULL ),
       
    76       iConfirmDlgRoaming( NULL ),
       
    77       iStoredIapInfo(),
       
    78       iIapSelection( NULL ),
       
    79       iMigrateState( EMigrateNone )
       
    80     {
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CMPMServerSession::ConstructL
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CMPMServerSession::ConstructL()
       
    89     {
       
    90     MPMLOGSTRING( "CMPMServerSession::ConstructL" )
       
    91     if ( !iMyServer.Events() )
       
    92         {
       
    93         iMyServer.SetEvents(CMPMConnMonEvents::NewL(
       
    94             *const_cast<CMPMServer*>( &iMyServer ), *this ));
       
    95         }
       
    96 
       
    97     FeatureManager::InitializeLibL();
       
    98     iOfflineFeatureSupported = FeatureManager::FeatureSupported( 
       
    99                                    KFeatureIdOfflineMode );
       
   100  
       
   101      FeatureManager::UnInitializeLib();
       
   102                                        
       
   103     // Append session pointer to server
       
   104     // 
       
   105     iMyServer.AppendSessionL( this );
       
   106     }
       
   107 
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CMPMServerSession::~CMPMServerSession
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 CMPMServerSession::~CMPMServerSession()
       
   114     {
       
   115     delete iDisconnectDlg;
       
   116     delete iConfirmDlgRoaming;
       
   117     delete iIapSelection;
       
   118 
       
   119     // Remove serverside objects for notification session.
       
   120     // 
       
   121     iMyServer.RemoveSession( this );
       
   122 
       
   123     if (UserConnection())
       
   124         {
       
   125         iMyServer.ClearUserConnection();
       
   126         ClearUserConnection();
       
   127         
       
   128         // Set PS keys to zero
       
   129         RProperty::Set( KMPMUserConnectionCategory,
       
   130                         KMPMPSKeyUserConnectionSnap,
       
   131                         0 );
       
   132         
       
   133         RProperty::Set( KMPMUserConnectionCategory,
       
   134                         KMPMPSKeyUserConnectionIap,
       
   135                         0 );
       
   136         
       
   137         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
       
   138 User connection deactivated" )
       
   139         }   
       
   140 
       
   141     // Make sure the connection is removed from server's information array.
       
   142     iMyServer.RemoveBMConnection( iConnId, *this );
       
   143     }
       
   144 
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CMPMServerSession::ServiceL
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CMPMServerSession::ServiceL( const RMessage2& aMessage )
       
   151     {
       
   152     switch ( aMessage.Function() )
       
   153         {
       
   154         case EMPMServerChooseIap:
       
   155             {
       
   156             HandleServerChooseIapL( aMessage );
       
   157             break;
       
   158             }
       
   159         case EMPMServerCancelRequest:
       
   160             {
       
   161             HandleServerCancelRequest( aMessage );
       
   162             break;
       
   163             }
       
   164         case EMPMServerApplicationLeavesConnection:
       
   165             {
       
   166             HandleServerApplicationLeavesConnection( aMessage );
       
   167             break;
       
   168             }
       
   169         case EMPMServerIapConnectionStopped:
       
   170             {
       
   171             HandleServerIapConnectionStopped( aMessage );
       
   172             break;
       
   173             }
       
   174         case EMPMServerProcessError:
       
   175             {
       
   176             HandleServerProcessErrorL( aMessage );
       
   177             break;
       
   178             }
       
   179         case EMPMServerRegisterPrefIAPNotif:
       
   180             {
       
   181             HandleServerRegisterPrefIAPNotifL( aMessage ); 
       
   182             break;
       
   183             }
       
   184         case EMPMServerUnregisterPrefIAPNotif:
       
   185             {
       
   186             HandleServerUnregisterPrefIAPNotif( aMessage );
       
   187             break;
       
   188             }
       
   189         case EMPMServerWaitNotification:
       
   190             {
       
   191             HandleServerWaitNotificationL( aMessage );
       
   192             break;                                              
       
   193             }
       
   194         case EMPMServerSortSNAP:
       
   195             {
       
   196             HandleServerSortSNAPL( aMessage ); 
       
   197             break;
       
   198             }
       
   199         case EMPMServerApplicationJoinsConnection:
       
   200             {
       
   201             HandleServerApplicationJoinsConnection( aMessage );
       
   202             break;
       
   203             }
       
   204         case EMPMServerIapConnectionActivated:
       
   205             {
       
   206             HandleServerIapConnectionActivatedL( aMessage );
       
   207             break;
       
   208             }
       
   209         case EMPMServerIapConnectionStarted:
       
   210             {
       
   211             HandleServerIapConnectionStartedL( aMessage );
       
   212             break;
       
   213             }
       
   214         case EMPMServerApplicationConnectionEnds:
       
   215             {
       
   216             HandleServerApplicationConnectionEnds( aMessage );
       
   217             break;
       
   218             }
       
   219         case EMPMServerApplicationMigratesToCarrier:
       
   220             {
       
   221             HandleServerApplicationMigratesToCarrierL( aMessage );
       
   222             break;
       
   223             }
       
   224         case EMPMServerApplicationIgnoredTheCarrier:
       
   225             {
       
   226             HandleServerApplicationIgnoredTheCarrier( aMessage );
       
   227             break;
       
   228             }
       
   229         case EMPMServerApplicationAcceptedTheCarrier:
       
   230             {
       
   231             HandleServerApplicationAcceptedTheCarrier( aMessage );
       
   232             break;
       
   233             }
       
   234         case EMPMServerApplicationRejectedTheCarrier:
       
   235             {
       
   236             HandleServerApplicationRejectedTheCarrierL( aMessage );
       
   237             break;
       
   238             }
       
   239         case EMPMServerEasyWlanSsid:
       
   240             {
       
   241             // Easy WLAN SSID not used anymore as connecting 
       
   242             // notes have been removed
       
   243             //
       
   244             MPMLOGSTRING( "CMPMServerSession::ServiceL \
       
   245 completing EMPMServerEasyWlanSsid" )
       
   246             aMessage.Complete( KErrNone );
       
   247             break;
       
   248             }
       
   249         case EMPMServerReselectIap:
       
   250             {
       
   251             HandleServerReselectIapL( aMessage );
       
   252             break;
       
   253             }
       
   254 #ifdef _DEBUG
       
   255         case EMPMDebugGenerateStopIAPNotification:
       
   256             {
       
   257             HandleDebugGenerateStopIAPNotification( aMessage );
       
   258             break;
       
   259             }
       
   260         case EMPMDebugSwitchConnMonEventsOn:
       
   261             {
       
   262             HandleDebugFilterConnMonEvents( aMessage, EFalse );
       
   263             break;
       
   264             }
       
   265         case EMPMDebugSwitchConnMonEventsOff:
       
   266             {
       
   267             HandleDebugFilterConnMonEvents( aMessage, ETrue );
       
   268             break;
       
   269             }
       
   270         case EMPMDebugShutdown:
       
   271             {
       
   272             HandleDebugShutdown( aMessage, ETrue );
       
   273             break;
       
   274             }    
       
   275 #endif //_DEBUG
       
   276         default:
       
   277             {
       
   278             iMyServer.PanicClient( KErrNotSupported );
       
   279             }
       
   280         }
       
   281     }
       
   282 
       
   283 #ifdef _DEBUG
       
   284 void CMPMServerSession::HandleDebugGenerateStopIAPNotification( const RMessage2& aMessage )
       
   285     {
       
   286     MPMLOGSTRING( "CMPMServerSession::HandleDebugGenerateStopIAPNotification" )
       
   287     TInt iap = static_cast<TInt>( aMessage.Int0() );
       
   288     MyServer().StopConnections( iap );
       
   289     aMessage.Complete( KErrNone );
       
   290     }
       
   291 	
       
   292 void CMPMServerSession::HandleDebugFilterConnMonEvents( const RMessage2& aMessage, const TBool aVal )
       
   293     {
       
   294     MPMLOGSTRING2( "CMPMServerSession::HandleDebugFilterConnMonEvents FilteringEnabled=%d", aVal )
       
   295     TInt iap = static_cast<TInt>( aMessage.Int0() );
       
   296     MyServer().Events()->FilterAvailableIAPEvents( aVal );
       
   297     aMessage.Complete( KErrNone );
       
   298     }
       
   299     
       
   300 void CMPMServerSession::HandleDebugShutdown( const RMessage2& aMessage, const TBool /*aVal*/ )
       
   301     {
       
   302     MPMLOGSTRING( "CMPMServerSession::HandleDebugShutdown" )
       
   303     aMessage.Complete( KErrNone );
       
   304     
       
   305     TFindProcess processFinder( _L("*MPMServer*") );
       
   306     TFullName    name;
       
   307     
       
   308     if ( processFinder.Next( name ) == KErrNone ) 
       
   309         {
       
   310         RProcess process;
       
   311         
       
   312         TInt err = process.Open( name );
       
   313         
       
   314         if ( err == KErrNone ) 
       
   315             {
       
   316             process.Kill( 0 );
       
   317             }
       
   318                 
       
   319         process.Close();
       
   320         }    
       
   321     }    
       
   322 #endif //_DEBUG
       
   323 
       
   324 // -----------------------------------------------------------------------------
       
   325 // CMPMServerSession::ServiceError
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 void CMPMServerSession::ServiceError( const RMessage2& aMessage, 
       
   329                                       TInt             aError )
       
   330 
       
   331     {
       
   332     // Handles the situation when a call to CSession2::ServiceL(), 
       
   333     // which services a client request, leaves.
       
   334     // 
       
   335     // The default behaviour of this function is to complete the message, 
       
   336     // using the leave value, if it has not already been completed.
       
   337     // 
       
   338     // Servers can re-implement this as appropriate.
       
   339     // 
       
   340     MPMLOGSTRING3(
       
   341         "CMPMServerSession::ServiceError: Service %d failed with error: %d",
       
   342          aMessage.Function(),
       
   343          aError )
       
   344     if( aMessage.Function() == EMPMServerChooseIap ||
       
   345         aMessage.Function() == EMPMServerReselectIap )
       
   346         {
       
   347         // complete locally stored iChooseIapMessage
       
   348         //
       
   349         ChooseIapComplete( aError, NULL );
       
   350         }
       
   351     else if( aMessage.Function() == EMPMServerProcessError )
       
   352         {
       
   353         // complete locally stored iProcessErrorMessage
       
   354         //
       
   355         ProcessErrorComplete( aError, NULL, NULL );
       
   356         }
       
   357     else if( !aMessage.IsNull() )
       
   358         {
       
   359         // Complete message if it hasn't been 
       
   360         // already completed
       
   361         //
       
   362         aMessage.Complete( aError );        
       
   363         }
       
   364     else
       
   365         {
       
   366         MPMLOGSTRING(
       
   367         "CMPMServerSession::ServiceError: Message has already been completed" )
       
   368         }    
       
   369     }
       
   370 
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // CMPMServerSession::HandleServerChooseIapL
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 void CMPMServerSession::HandleServerChooseIapL( const RMessage2& aMessage )
       
   377     {
       
   378     MPMLOGSTRING2( "CMPMServerSession::HandleServerChooseIapL session <0x%x>", this )
       
   379 
       
   380     // Read the Connection Id of the application
       
   381     //
       
   382     iConnId = aMessage.Int1();
       
   383     MPMLOGSTRING2( "CMPMServerSession::HandleServerChooseIapL: \
       
   384 Connection Id = 0x%x", iConnId )
       
   385 
       
   386     // Sanity check that client only has one outstanding ChooseBestIAP() or ReselectBestIAP() -call.
       
   387     //
       
   388     if ( !iChooseIapMessage.IsNull() )
       
   389         {
       
   390         MPMLOGSTRING2( "CMPMServerSession::HandleServerChooseIapL: - Error \
       
   391 ChooseBestIAP() or ReselectBestIAP() already exists %d", KErrServerBusy );
       
   392         aMessage.Complete( KErrServerBusy );
       
   393         }
       
   394 
       
   395     // Sanity check that client doesn't call ChooseBestIAPL() twice for the same session.
       
   396     //
       
   397     if ( ChooseBestIapCalled() )
       
   398         {
       
   399         MPMLOGSTRING2( "CMPMServerSession::HandleServerChooseIapL: - Error \
       
   400 ChooseBestIAP() already completed or in progress %d", KErrAlreadyExists )
       
   401         aMessage.Complete( KErrAlreadyExists );
       
   402         return;
       
   403         }
       
   404 
       
   405     // We must save the RMessage in order to complete it later.
       
   406     //
       
   407     iChooseIapMessage = aMessage;
       
   408     TConnPref connPref;
       
   409     aMessage.ReadL( KFirstArgument, connPref );
       
   410 
       
   411     // Extract connection preferences
       
   412     //
       
   413     TMpmConnPref mpmConnPref;
       
   414     TInt error = ExtractConnPref( connPref, mpmConnPref );
       
   415     
       
   416     if ( error != KErrNone )
       
   417         {
       
   418         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL - Error \
       
   419 while extracting TCommDbConnPref from TConnPref" )
       
   420         aMessage.Complete( error );
       
   421         return;
       
   422         }
       
   423 
       
   424     // Store the Uid of the application to the member variable so 
       
   425     // that it can be used to avoid DisconnectDialog popping up when 
       
   426     // AlwaysOnline connection is being established.
       
   427     // 
       
   428     iAppUid = aMessage.Int2();
       
   429 
       
   430     if ( !iIapSelection )
       
   431         {
       
   432         iIapSelection = CMPMIapSelection::NewL( iMyServer.CommsDatAccess(),
       
   433                                                 this ); 
       
   434         }
       
   435     
       
   436     MPMLOGSTRING3( "CMPMServerSession::HandleServerChooseIapL - iap %d \
       
   437 connType %d", mpmConnPref.IapId(), mpmConnPref.ConnType() )
       
   438 
       
   439     iIapSelection->ChooseIapL( mpmConnPref );
       
   440 
       
   441     if ( iAppUid == iMyServer.CsIdWatcher()->ConnectScreenId() )
       
   442         {
       
   443         MPMLOGSTRING( "CMPMServerSession::HandleServerChooseIapL -\
       
   444  User connection activated" )
       
   445         
       
   446         // This is user connection
       
   447         iMyServer.SetUserConnection();
       
   448         SetUserConnection();
       
   449         iMyServer.SetUserConnPref( mpmConnPref );
       
   450         
       
   451         // Set PS keys according to user connection
       
   452         // Do not check return values. Can do nothing in case of failing.
       
   453         RProperty::Set( KMPMUserConnectionCategory,
       
   454                         KMPMPSKeyUserConnectionSnap,
       
   455                         mpmConnPref.SnapId() );
       
   456         
       
   457         RProperty::Set( KMPMUserConnectionCategory,
       
   458                         KMPMPSKeyUserConnectionIap,
       
   459                         mpmConnPref.IapId() );
       
   460         }
       
   461     }
       
   462 
       
   463 
       
   464 // -----------------------------------------------------------------------------
       
   465 // CMPMServerSession::HandleServerCancelRequest
       
   466 // -----------------------------------------------------------------------------
       
   467 //
       
   468 void CMPMServerSession::HandleServerCancelRequest( const RMessage2& aMessage )
       
   469     {
       
   470     TInt cancelcode = aMessage.Int0();
       
   471     MPMLOGSTRING2(
       
   472         "CMPMServerSession::HandleServerCancelRequest - Request code = %i", 
       
   473         cancelcode )
       
   474 
       
   475     switch ( cancelcode )
       
   476         {
       
   477         case EMPMReselectBestIAP:
       
   478         case EMPMChooseBestIAP:
       
   479             {
       
   480             // Complete original request
       
   481             // 
       
   482             ChooseIapComplete( KErrCancel, NULL );
       
   483             
       
   484             // Complete cancel request 
       
   485             //
       
   486             MPMLOGSTRING(
       
   487             "CMPMServerSession::HandleServerCancelRequest - Complete with KErrNone" )
       
   488             aMessage.Complete( KErrNone );
       
   489             
       
   490             // Cancel WLAN scan request if one exists
       
   491             //
       
   492             TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ) )
       
   493             
       
   494             if ( iIapSelection )
       
   495                 {
       
   496                 delete iIapSelection;
       
   497                 iIapSelection = NULL;
       
   498                 }
       
   499             return;
       
   500             }
       
   501         case EMPMProcessError:
       
   502             {
       
   503             ProcessErrorComplete( KErrCancel,
       
   504                                   NULL,
       
   505                                   NULL );
       
   506             // Complete cancel request 
       
   507             //
       
   508             MPMLOGSTRING(
       
   509             "CMPMServerSession::HandleServerCancelRequest - Complete with KErrNone" )
       
   510             aMessage.Complete( KErrNone );
       
   511 
       
   512             // Cancel WLAN scan request if one exists
       
   513             //
       
   514             TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ) )
       
   515 
       
   516             if ( iDisconnectDlg )
       
   517                 {
       
   518                 MPMLOGSTRING( "CMPMServerSession::HandleServerCancelRequest: \
       
   519 removing dconn dlg" )
       
   520                 delete iDisconnectDlg;
       
   521                 iDisconnectDlg = NULL;
       
   522                 }
       
   523             return;
       
   524             }
       
   525         case EMPMWaitNotification:
       
   526             {
       
   527             if ( iNotifRequested )
       
   528                 {
       
   529                 iNotifRequested = EFalse;
       
   530                 iNotifMessage.Complete( KErrCancel );
       
   531                 }
       
   532             break;
       
   533             }
       
   534         case EMPMSortSNAP:
       
   535             {
       
   536             if ( !iServerSortSNAPMessage.IsNull() )
       
   537                 {
       
   538                 // TODO Change CancelScanL to non-leaving.
       
   539                 // Otherwise, nothing clever can be done here.
       
   540                 // And OOM may risk MPM stability.
       
   541                 TRAP_IGNORE( iMyServer.Events()->CancelScanL( *this ))
       
   542                 iServerSortSNAPMessage.Complete( KErrCancel );
       
   543                 }
       
   544             break;
       
   545             }
       
   546         default:
       
   547             {
       
   548             MPMLOGSTRING( "CMPMServerSession::HandleServerCancelRequest - \
       
   549 Unknown cancel request received" )
       
   550             }
       
   551         }
       
   552     MPMLOGSTRING( 
       
   553     "CMPMServerSession::HandleServerCancelRequest - Complete with KErrNone" )
       
   554     aMessage.Complete( KErrNone );
       
   555     }
       
   556 
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 // CMPMServerSession::HandleServerApplicationJoinsConnection
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 void CMPMServerSession::HandleServerApplicationJoinsConnection(
       
   563     const RMessage2& aMessage )
       
   564     {
       
   565     // Read Iap Id
       
   566     //
       
   567     TUint32 joinIap = static_cast<TUint32>( aMessage.Int0() );
       
   568 
       
   569     // Read the Connection Id of the application
       
   570     //
       
   571     TConnectionId joinId = aMessage.Int1();
       
   572     
       
   573     //-jl- Make sure id is known & assert it stays the same.
       
   574     ASSERT(iConnId == joinId || iConnId == NULL);
       
   575     iConnId = joinId;
       
   576 
       
   577     MPMLOGSTRING3(
       
   578         "CMPMServerSession::HandleServerApplicationJoinsConnection \
       
   579 - IAP Id = %i, Connection Id = 0x%x", joinIap, joinId )
       
   580 
       
   581     // Get the current connection SNAP for this Connection Id
       
   582     //
       
   583     TUint32 snapId = iMyServer.GetBMSnap( joinId );
       
   584 
       
   585     
       
   586     // Decides the correct state by the IAP status.
       
   587     if ( iMyServer.StartedConnectionExists( joinIap ) == joinIap )
       
   588         {
       
   589         iMyServer.AppendBMConnection( joinId, 
       
   590                                   snapId, 
       
   591                                   joinIap, 
       
   592                                   EStarted,
       
   593 								  *this );
       
   594         }
       
   595     else
       
   596         {
       
   597         iMyServer.AppendBMConnection( joinId, 
       
   598                                   snapId, 
       
   599                                   joinIap, 
       
   600                                   EStarting,
       
   601 								  *this );
       
   602         }
       
   603 
       
   604     aMessage.Complete( KErrNone );
       
   605     }
       
   606 
       
   607 
       
   608 // -----------------------------------------------------------------------------
       
   609 // CMPMServerSession::HandleServerApplicationLeavesConnection
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 void CMPMServerSession::HandleServerApplicationLeavesConnection(
       
   613     const RMessage2& aMessage )
       
   614     {
       
   615     // Read Iap Id
       
   616     //
       
   617     TUint32 leaveIap = static_cast<TUint32>( aMessage.Int0() );
       
   618 
       
   619     // Read the Connection Id of the application
       
   620     //
       
   621     TConnectionId leaveId = aMessage.Int1();
       
   622 
       
   623     MPMLOGSTRING3(
       
   624         "CMPMServerSession::HandleServerApplicationLeavesConnectionL \
       
   625 - IAP Id = %i, Connection Id = 0x%x", leaveIap, leaveId )
       
   626 
       
   627     iMyServer.Events()->ResetConnInfo( leaveId );
       
   628     iMyServer.ResetBMConnection( leaveId, leaveIap, *this );
       
   629 
       
   630     aMessage.Complete( KErrNone );
       
   631     }
       
   632 
       
   633 
       
   634 // -----------------------------------------------------------------------------
       
   635 // CMPMServerSession::HandleServerIapConnectionActivatedL
       
   636 // -----------------------------------------------------------------------------
       
   637 //
       
   638 void CMPMServerSession::HandleServerIapConnectionActivatedL(
       
   639     const RMessage2& aMessage )
       
   640     {
       
   641     // Read Iap Id
       
   642     //
       
   643     TUint32 activatedIap = static_cast<TUint32>( aMessage.Int0() );
       
   644 
       
   645     // Read the Connection Id of the application
       
   646     //
       
   647     TConnectionId activatedId = aMessage.Int1();
       
   648 
       
   649     //-jl- Make sure id is known & assert it stays the same.
       
   650     ASSERT(iConnId == activatedId || iConnId == NULL);
       
   651     iConnId = activatedId;
       
   652     
       
   653     MPMLOGSTRING3(
       
   654         "CMPMServerSession::HandleServerIapConnectionActivatedL \
       
   655 - IAP Id = %i, Connection Id = 0x%x", activatedIap, activatedId )
       
   656 
       
   657     MPMLOGSTRING(
       
   658         "CMPMServerSession::HandleServerIapConnectionActivatedL \
       
   659 - Complete IapConnectionActivated" )
       
   660     aMessage.Complete( KErrNone );
       
   661     }
       
   662 
       
   663 
       
   664 // -----------------------------------------------------------------------------
       
   665 // CMPMServerSession::HandleServerIapConnectionStarted
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 void CMPMServerSession::HandleServerIapConnectionStartedL(
       
   669     const RMessage2& aMessage )
       
   670     {
       
   671     // Read Iap Id
       
   672     //
       
   673     TUint32 startedIap = static_cast<TUint32>( aMessage.Int0() );
       
   674 
       
   675     // Read the Connection Id of the application
       
   676     //
       
   677     TConnectionId startedId = aMessage.Int1();
       
   678 
       
   679     //-jl- Make sure id is known & assert it stays the same.
       
   680     ASSERT(iConnId == startedId || iConnId == NULL);
       
   681     iConnId = startedId;
       
   682     
       
   683     MPMLOGSTRING3( "CMPMServerSession::HandleServerIapConnectionStarted\
       
   684  - IAP Id = %i, Connection Id = 0x%x", startedIap, startedId )
       
   685 
       
   686     iMyServer.AppendBMIAPConnectionL( startedIap, startedId, *this );
       
   687 
       
   688     // Unblacklist all IAPs related to the connection error 
       
   689     // when connection has started.
       
   690     // 
       
   691     iMyServer.HandleServerUnblackListIap( startedId, ETemporary );
       
   692 
       
   693     // Complete the message as soon as possible to avoid latency in BM
       
   694     // 
       
   695     aMessage.Complete( KErrNone );
       
   696     
       
   697     IapSelectionL()->ConnectionStarted();
       
   698     }
       
   699 
       
   700 
       
   701 // -----------------------------------------------------------------------------
       
   702 // CMPMServerSession::HandleServerIapConnectionStopped
       
   703 // -----------------------------------------------------------------------------
       
   704 //
       
   705 void CMPMServerSession::HandleServerIapConnectionStopped(
       
   706     const RMessage2& aMessage )
       
   707     {
       
   708     // Read Iap Id
       
   709     //
       
   710     TUint32 stoppedIap = static_cast<TUint32>( aMessage.Int0() );
       
   711 
       
   712     // Read the Connection Id of the application
       
   713     //
       
   714     TConnectionId stoppedId = aMessage.Int1();
       
   715 
       
   716     MPMLOGSTRING3( "CMPMServerSession::HandleServerIapConnectionStopped\
       
   717  - IAP Id = %i, Connection Id = 0x%x", stoppedIap, stoppedId )
       
   718 
       
   719     iMyServer.RemoveBMIAPConnection( stoppedIap, stoppedId, *this );
       
   720 
       
   721     // Complete the message as soon as possible to avoid latency in BM
       
   722     // 
       
   723     aMessage.Complete( KErrNone );
       
   724 
       
   725     }
       
   726 
       
   727 
       
   728 // -----------------------------------------------------------------------------
       
   729 // CMPMServerSession::HandleServerApplicationConnectionEnds
       
   730 // -----------------------------------------------------------------------------
       
   731 //
       
   732 void CMPMServerSession::HandleServerApplicationConnectionEnds( 
       
   733     const RMessage2& aMessage )
       
   734     {
       
   735     // Read the Connection Id of the application
       
   736     //
       
   737     TConnectionId endId = aMessage.Int0();
       
   738 
       
   739     if (UserConnection())
       
   740         {
       
   741         iMyServer.ClearUserConnection();
       
   742         ClearUserConnection();
       
   743         
       
   744         // Set PS keys to zero
       
   745         RProperty::Set( KMPMUserConnectionCategory,
       
   746                         KMPMPSKeyUserConnectionSnap,
       
   747                         0 );
       
   748         
       
   749         RProperty::Set( KMPMUserConnectionCategory,
       
   750                         KMPMPSKeyUserConnectionIap,
       
   751                         0 );
       
   752         
       
   753         MPMLOGSTRING( "CMPMServerSession::HandleServerApplicationConnectionEnds -\
       
   754 User connection deactivated" )
       
   755         }   
       
   756 
       
   757     MPMLOGSTRING2( "CMPMServerSession::HandleServerApplicationConnectionEnds\
       
   758  - Connection Id = 0x%x", endId )
       
   759 
       
   760     // Unblacklist all IAPs related to this connection  
       
   761     // when connection closes.
       
   762     // 
       
   763     iMyServer.HandleServerUnblackListIap( endId, 0 );
       
   764 
       
   765     // Remove info about this connection
       
   766     // 
       
   767     iMyServer.Events()->RemoveConnInfo( endId );
       
   768 
       
   769     // SNAP lifetime is determined by the two calls ChooseBestIAP 
       
   770     // and ApplicationConnectionEnds.
       
   771     // 
       
   772     iMyServer.RemoveBMConnection( endId, *this );
       
   773 
       
   774     // Clear notification registration if one exists for the connection
       
   775     //
       
   776     iPreferredIAPRequested = EFalse;
       
   777     
       
   778     // Complete message before calling synchronous Cancel functions
       
   779     aMessage.Complete( KErrNone );
       
   780 
       
   781     delete iConfirmDlgRoaming;
       
   782     iConfirmDlgRoaming = NULL;
       
   783     
       
   784     if( iIapSelection )
       
   785         {
       
   786         delete iIapSelection;
       
   787         iIapSelection = NULL;        
       
   788         }
       
   789     }
       
   790 
       
   791 // -----------------------------------------------------------------------------
       
   792 // CMPMServerSession::IsConfirmFirstL
       
   793 // -----------------------------------------------------------------------------
       
   794 //
       
   795 TBool CMPMServerSession::IsConfirmFirstL( const TUint32 aIapId )
       
   796     {
       
   797     TCmGenConnSettings  genConnSettings;
       
   798     TBool               isConfirmFirst( EFalse );
       
   799 
       
   800     MPMLOGSTRING3( "CMPMServerSession::IsConfirmFirstL - IAP Id = %i Connection Id = 0x%x", 
       
   801                    aIapId,
       
   802                    iConnId )
       
   803 
       
   804     // check whether a started connection exists which already 
       
   805     // uses this IAP. If so, it won't need to be confirmed again
       
   806     // 
       
   807     if( iMyServer.CheckIfStarted( aIapId ) )
       
   808         {
       
   809         MPMLOGSTRING(
       
   810         "CMPMServerSession::IsConfirmFirstL - IAP already started, \
       
   811 confirm not necesary - False" )
       
   812         return EFalse;
       
   813         }
       
   814 
       
   815     if ( IsBackgroundApplication( iAppUid ) || IsMMSIap( aIapId ) )
       
   816         {
       
   817         MPMLOGSTRING(
       
   818         "CMPMServerSession::IsConfirmFirstL - background IAP, \
       
   819 should not be confirmed - False" )
       
   820         return EFalse;
       
   821         }
       
   822 
       
   823     // Read global OCC seamlessness values from CommsDat's DefConn table
       
   824     genConnSettings = iMyServer.CommsDatAccess()->ReadGenConnSettingsL();
       
   825 
       
   826     TUint32 currentSeamlessness( genConnSettings.iSeamlessnessHome );
       
   827     
       
   828     if ( iMyServer.IsVisitorNetwork() )
       
   829         {
       
   830         currentSeamlessness = genConnSettings.iSeamlessnessVisitor; 
       
   831         }
       
   832 
       
   833     if ( currentSeamlessness == ECmSeamlessnessShowprogress ||
       
   834          currentSeamlessness == ECmSeamlessnessFullySeamless )
       
   835         {
       
   836         MPMLOGSTRING( "CMPMServerSession::IsConfirmFirstL - False" )
       
   837         isConfirmFirst = EFalse;
       
   838         }
       
   839     else 
       
   840         {
       
   841         // The currentSeamlessness value ECmSeamlessnessConfirmFirst 
       
   842         // matches with need to display confirmation dialog.
       
   843         // 
       
   844         MPMLOGSTRING(
       
   845             "CMPMServerSession::IsConfirmFirstL - True" )
       
   846         isConfirmFirst = ETrue;
       
   847         }
       
   848     return isConfirmFirst;
       
   849     }
       
   850 
       
   851 
       
   852 // -----------------------------------------------------------------------------
       
   853 // CMPMServerSession::HandleServerApplicationMigratesToCarrierL
       
   854 // -----------------------------------------------------------------------------
       
   855 //
       
   856 void CMPMServerSession::HandleServerApplicationMigratesToCarrierL(
       
   857     const RMessage2& aMessage )
       
   858     {
       
   859     // Read Iap Id
       
   860     //
       
   861     iMigrateIap = static_cast<TUint32>( aMessage.Int0() );
       
   862 
       
   863     // Complete the message ApplicationMigratesToCarrier already here, 
       
   864     // otherwise MPM would be hanging Esock thread when displaying the 
       
   865     // confirmation dialog while roaming.
       
   866     // 
       
   867     aMessage.Complete( KErrNone );
       
   868 
       
   869     MPMLOGSTRING3(
       
   870         "CMPMServerSession::HandleServerApplicationMigratesToCarrierL\
       
   871  - IAP Id = %i, Connection Id = 0x%x", iMigrateIap, iConnId )
       
   872 
       
   873     delete iConfirmDlgRoaming;
       
   874     iConfirmDlgRoaming = NULL;
       
   875 
       
   876     // Get the current connection SNAP for this Connection Id
       
   877     //
       
   878     TUint32 snapId = iMyServer.GetBMSnap( iConnId );
       
   879 
       
   880     // We have to find out the current IAP of connection in order 
       
   881     // to determine whether this is an upgrade or downgrade.
       
   882     // 
       
   883     TUint32 currentIap = iMyServer.GetBMIap( iConnId );
       
   884 
       
   885     iMyServer.AppendBMConnection( iConnId, 
       
   886                                   snapId, 
       
   887                                   iMigrateIap, 
       
   888                                   ERoaming,
       
   889                                   *this );
       
   890 
       
   891     iMigrateState = EMigrateUserConfirmation;
       
   892 
       
   893     // Confirm only if this IAP is not already in use
       
   894     //
       
   895     if ( ( currentIap != iMigrateIap ) && 
       
   896          IsConfirmFirstL( iMigrateIap ) )
       
   897         {
       
   898         TBool             nextBestExists( EFalse );
       
   899         TMpmConnPref      mpmConnPref;
       
   900         RAvailableIAPList availableIAPList;
       
   901 
       
   902         CleanupClosePushL( availableIAPList );
       
   903         AvailableUnblacklistedIapsL( availableIAPList, 
       
   904                                      iConnId );
       
   905 
       
   906         mpmConnPref.SetSnapId( snapId );
       
   907 
       
   908         IapSelectionL()->ChooseBestIAPL( mpmConnPref, availableIAPList, nextBestExists );
       
   909 
       
   910         TBool reconnect ( EFalse );      
       
   911         if ( !IsUpgrade( currentIap, iMigrateIap, availableIAPList ) )
       
   912                     {
       
   913                     reconnect = ETrue;
       
   914                     }
       
   915 
       
   916         //Display confirm dialog only if we are moving to cellular IAP
       
   917         if ( MyServer().CommsDatAccess()->CheckWlanL( iMigrateIap ) == ENotWlanIap )
       
   918             {
       
   919             if ( !( iIapSelection->MpmConnPref().NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) )
       
   920                 {
       
   921                 if ( MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
       
   922                     {
       
   923                     //Check if cellular data usage query has already been presented to the user in this country
       
   924                     if ( MyServer().RoamingWatcher()->AskCellularDataUsageAbroad() == true )
       
   925                         {
       
   926                         //International roaming
       
   927                         iConfirmDlgRoaming = CMPMConfirmDlgRoaming::NewL( 
       
   928                                 *this, 
       
   929                                 snapId, 
       
   930                                 iMigrateIap, 
       
   931                                 CMPMConfirmDlg::EConfirmDlgVisitorNetwork, 
       
   932                                 reconnect );
       
   933                         }
       
   934                     else
       
   935                         {
       
   936                         //Handle like user would have answered "Connect this time" to dialog
       
   937                         RoamingConfirmationCompletedL( KErrNone, EMsgQueryThisTime, reconnect );
       
   938                         }
       
   939                     }
       
   940                 else
       
   941                     {
       
   942                     //Home network
       
   943                     iConfirmDlgRoaming = CMPMConfirmDlgRoaming::NewL( 
       
   944                             *this, 
       
   945                             snapId, 
       
   946                             iMigrateIap, 
       
   947                             CMPMConfirmDlg::EConfirmDlgHomeNetwork,
       
   948                             reconnect );
       
   949                     }
       
   950                 }
       
   951             
       
   952             else
       
   953                 {
       
   954                 RoamingConfirmationCompletedL( KErrCancel, EMsgQueryCancelled, reconnect );
       
   955                 }
       
   956             }
       
   957         //IAP was WLAN IAP
       
   958         else
       
   959             {
       
   960             //Handle like user would have answered "Connect this time" to dialog
       
   961             RoamingConfirmationCompletedL( KErrNone, EMsgQueryThisTime, reconnect );
       
   962             }
       
   963                 
       
   964         // Release memory
       
   965         //
       
   966         CleanupStack::PopAndDestroy( &availableIAPList );
       
   967         }
       
   968     else
       
   969         {
       
   970         // Handle next state in migration
       
   971         //
       
   972         MigrateCallbackL( KErrNone );
       
   973         }
       
   974     }
       
   975 
       
   976 // -----------------------------------------------------------------------------
       
   977 // CMPMServerSession::MigrateCallbackL
       
   978 // -----------------------------------------------------------------------------
       
   979 //
       
   980 void CMPMServerSession::MigrateCallbackL( TInt aError )
       
   981 	{
       
   982 	if( iMigrateState == EMigrateUserConfirmation )
       
   983 	    {
       
   984 	    MPMLOGSTRING2( "CMPMServerSession<0x%x>::MigrateCallbackL: State user confirmation",
       
   985 	                   iConnId )
       
   986 	    if( aError == KErrNone )
       
   987 	        {
       
   988 	        iMigrateState = EMigrateOfflineConfirmation;
       
   989     	    if( IapSelectionL()->StartWlanQueryIfNeededL( iMigrateIap, ETrue ) )
       
   990 	            {
       
   991 	            return;
       
   992                 }
       
   993 	        }
       
   994 	    }
       
   995 	else if( iMigrateState == EMigrateOfflineConfirmation )
       
   996 	    {
       
   997 	    MPMLOGSTRING3( "CMPMServerSession<0x%x>::MigrateCallbackL: State offline confirmation error: %d", 
       
   998 	                   iConnId,
       
   999 	                   aError )
       
  1000         if( aError != KErrNone )
       
  1001             {
       
  1002             ErrorNotificationL( aError, EMPMMobilityErrorNotification );
       
  1003             }
       
  1004 	    }
       
  1005 	else // EMigrateNone
       
  1006 	    {
       
  1007         MPMLOGSTRING2( "CMPMServerSession<0x%x>::MigrateCallbackL: State none",
       
  1008                        iConnId )
       
  1009 	    
       
  1010 	    }
       
  1011     MigrateDoneL( aError );
       
  1012 	}
       
  1013 
       
  1014 // -----------------------------------------------------------------------------
       
  1015 // CMPMServerSession::RoamingConfirmationCompletedL
       
  1016 // -----------------------------------------------------------------------------
       
  1017 //
       
  1018 void CMPMServerSession::RoamingConfirmationCompletedL( TInt                   aError, 
       
  1019                                                       TMsgQueryLinkedResults aResponse,
       
  1020                                                       TBool                  aReconnect )
       
  1021     {
       
  1022     TInt error( KErrNone);
       
  1023     MPMLOGSTRING5( "CMPMServerSession<0x%x>::RoamingConfirmationCompleted: \
       
  1024 aError %d, aResponse %d, aReconnect %d", 
       
  1025                    iConnId,
       
  1026                    aError,
       
  1027                    aResponse,
       
  1028                    aReconnect )
       
  1029 
       
  1030     if( aError == KErrNone )
       
  1031         {
       
  1032         if( aResponse == EMsgQueryCancelled )
       
  1033             {
       
  1034             if( !aReconnect )
       
  1035                 {
       
  1036                 // Send a preferred IAP notification
       
  1037                 // 
       
  1038                 TConnMonIapInfo availableIAPs;
       
  1039                 availableIAPs = GetAvailableIAPs();
       
  1040 
       
  1041                 // Get the current and presumed IapId for this connId 
       
  1042                 //
       
  1043                 TUint32 currentIap  = iMyServer.GetBMIap( ConnectionId() );
       
  1044                 TUint32 presumedIap = MyServer().Events()->PresumedIapId( 
       
  1045                                           ConnectionId(), iMigrateIap );
       
  1046 
       
  1047                 MyServer().HandleServerBlackListIap( ConnectionId(), 
       
  1048                                                      currentIap, 
       
  1049                                                      EConnectionLifetime );
       
  1050                 if ( ( presumedIap != 0 ) && 
       
  1051                      ( presumedIap != currentIap ) )
       
  1052                     {
       
  1053                     iMyServer.HandleServerBlackListIap( ConnectionId(), 
       
  1054                                                         presumedIap, 
       
  1055                                                         EConnectionLifetime );
       
  1056                     }
       
  1057 
       
  1058                 TRAPD( err, PrefIAPNotificationL( availableIAPs, 
       
  1059                                                   EConfirmDlgRoaming ) );
       
  1060                 if ( err == KErrNotFound )
       
  1061                     {
       
  1062                     // We need to send a notification error to BearerMan 
       
  1063                     // if sending preferred IAP notifications failed. 
       
  1064                     // 
       
  1065                     ErrorNotificationL( KErrNotFound,
       
  1066                                         EMPMMobilityErrorNotification );
       
  1067 
       
  1068                     }
       
  1069                 }
       
  1070             else // aReconnect
       
  1071                 {
       
  1072                 ErrorNotificationL( KErrCancel,
       
  1073                                     EMPMMobilityErrorNotification );
       
  1074                 }
       
  1075       
       
  1076             error = KErrCancel;
       
  1077             }
       
  1078         //User selected Connect automatically
       
  1079         else if  ( aResponse == EMsgQueryAutomatically ) 
       
  1080             {
       
  1081             //Store selected value to commsdat if we are in home network
       
  1082             if ( MyServer().RoamingWatcher()->RoamingStatus() == EMPMHomenetwork )
       
  1083                 {
       
  1084                 TCmGenConnSettings genConnSettings;
       
  1085 
       
  1086                 TRAPD(errorCode,genConnSettings = MyServer().CommsDatAccess()->ReadGenConnSettingsL()); // call a function
       
  1087 
       
  1088                 //If reading of database failed we do not write back to the database to prevent random values
       
  1089                 if (errorCode == KErrNone)
       
  1090                     {
       
  1091                     genConnSettings.iSeamlessnessHome = ECmSeamlessnessShowprogress;        
       
  1092                     TRAP_IGNORE(MyServer().CommsDatAccess()->WriteGenConnSettingsL( genConnSettings )); 
       
  1093                     }
       
  1094                 } 
       
  1095             else
       
  1096                 {
       
  1097                 //In foreign country connect automatically is not stored in commsdat
       
  1098                 //even user selected so. We just do not ask confirmation for the cellular
       
  1099                 //connection again in this country:
       
  1100                 MyServer().RoamingWatcher()->SetAskCellularDataUsageAbroad( false );            
       
  1101                 }
       
  1102             }
       
  1103         
       
  1104         //user selected connect this time
       
  1105         else
       
  1106             {
       
  1107             MPMLOGSTRING3( "CMPMServerSession<0x%x>::RoamingConfirmationCompleted: \
       
  1108 Unknown response: %d", iConnId, aResponse )
       
  1109             }
       
  1110         }
       
  1111     else // error occurred
       
  1112         {
       
  1113         ErrorNotificationL( aError, EMPMMobilityErrorNotification );
       
  1114         error = KErrCancel;
       
  1115         }
       
  1116     MigrateCallbackL( error ); 
       
  1117     }
       
  1118     
       
  1119 // -----------------------------------------------------------------------------
       
  1120 // CMPMServerSession::StopConnection
       
  1121 // -----------------------------------------------------------------------------
       
  1122 //
       
  1123 TInt CMPMServerSession::StopConnection()
       
  1124     { 
       
  1125     TInt ret = KErrNone;
       
  1126     MPMLOGSTRING( "CMPMServerSession::StopConnection" )
       
  1127     
       
  1128     TConnectionState state( EIdle );
       
  1129        
       
  1130     iMyServer.GetConnectionState( iConnId, state );
       
  1131         
       
  1132     if ( state == EStarted || state == EStarting )
       
  1133         {
       
  1134         TRAP(ret, StopIAPNotificationL());
       
  1135         }
       
  1136             
       
  1137     return ret;
       
  1138     } 
       
  1139 
       
  1140 // -----------------------------------------------------------------------------
       
  1141 // CMPMServerSession::HandleServerApplicationIgnoredTheCarrier
       
  1142 // -----------------------------------------------------------------------------
       
  1143 //
       
  1144 void CMPMServerSession::HandleServerApplicationIgnoredTheCarrier(
       
  1145     const RMessage2& aMessage )
       
  1146     {
       
  1147     TInt error( KErrNotFound );
       
  1148     
       
  1149     // MPM has been waiting for the response to preferred.
       
  1150     // Release the possible new notifications.
       
  1151     //
       
  1152     iStoredIapInfo.ResetStoredIapInfo();
       
  1153     
       
  1154     // Read Iap Id
       
  1155     //
       
  1156     TUint32 ignoredIap = static_cast<TUint32>( aMessage.Int0() );
       
  1157 
       
  1158     // Read the Connection Id of the application
       
  1159     //
       
  1160     TConnectionId ignoredId = aMessage.Int1();
       
  1161 
       
  1162     MPMLOGSTRING3(
       
  1163         "CMPMServerSession::HandleServerApplicationIgnoredTheCarrier \
       
  1164 - IAP Id = %i, Connection Id = 0x%x", ignoredIap, ignoredId )
       
  1165 
       
  1166     // Blacklisting should be done before ResetConnInfo(), 
       
  1167     // since iPresumedIapId is reset during ResetConnInfo(). 
       
  1168     // 
       
  1169     iMyServer.HandleServerBlackListIap( ignoredId, 
       
  1170                                         ignoredIap, 
       
  1171                                         EConnectionLifetime );
       
  1172 
       
  1173     iMyServer.Events()->ResetConnInfo( ignoredId );
       
  1174 
       
  1175     TConnMonIapInfo availableIAPs;
       
  1176     availableIAPs = GetAvailableIAPs();
       
  1177 
       
  1178     if ( availableIAPs.iCount > 0 ) 
       
  1179         {
       
  1180         TRAP( error, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
       
  1181         if ( error == KErrNotFound )
       
  1182             {
       
  1183             TRAP( error, ErrorNotificationL( KErrNotFound,
       
  1184                                              EMPMMobilityErrorNotification ) );
       
  1185             }
       
  1186         }
       
  1187     else
       
  1188         {
       
  1189         MPMLOGSTRING(
       
  1190             "CMPMServerSession::HandleServerApplicationIgnoredTheCarrier - \
       
  1191 No IAPs available, send error notification" )
       
  1192         TRAP( error, ErrorNotificationL( KErrNotFound, 
       
  1193                                          EMPMMobilityErrorNotification ) );
       
  1194         }
       
  1195     aMessage.Complete( error );
       
  1196     }
       
  1197 
       
  1198 
       
  1199 // -----------------------------------------------------------------------------
       
  1200 // CMPMServerSession::HandleServerApplicationAcceptedTheCarrier
       
  1201 // -----------------------------------------------------------------------------
       
  1202 //
       
  1203 void CMPMServerSession::HandleServerApplicationAcceptedTheCarrier(
       
  1204     const RMessage2& aMessage )
       
  1205     {    
       
  1206     // Read Iap Id
       
  1207     //
       
  1208     TUint32 acceptedIap = static_cast<TUint32>( aMessage.Int0() );
       
  1209 
       
  1210     // Read the Connection Id of the application
       
  1211     //
       
  1212     TConnectionId acceptedId = aMessage.Int1();
       
  1213 
       
  1214     MPMLOGSTRING3(
       
  1215         "CMPMServerSession::HandleServerApplicationAcceptedTheCarrier \
       
  1216 - IAP Id = %i, Connection Id = 0x%x", acceptedIap, acceptedId )
       
  1217 
       
  1218     // Get the current connection SNAP for this Connection Id
       
  1219     //
       
  1220     TUint32 snapId = iMyServer.GetBMSnap( acceptedId );
       
  1221 
       
  1222     iMyServer.AppendBMConnection( acceptedId, 
       
  1223                                   snapId, 
       
  1224                                   acceptedIap, 
       
  1225                                   EStarted,
       
  1226                                   *this );
       
  1227 
       
  1228     aMessage.Complete( KErrNone );
       
  1229     
       
  1230     // If there is saved IAP info, handle it now
       
  1231     //
       
  1232     TConnMonIapInfo iapInfo;
       
  1233     if( iStoredIapInfo.HandleIapInfoWaiting( iapInfo ) )
       
  1234         {
       
  1235         iStoredIapInfo.ResetStoredIapInfo();
       
  1236         // Attempt to send the preferred IAP notification 
       
  1237         // if notification has arrived during roaming. 
       
  1238         //
       
  1239         TRAPD( error, PrefIAPNotificationL( iapInfo, EConnMon ) );
       
  1240         if( error != KErrNone )
       
  1241             {
       
  1242             MPMLOGSTRING2(
       
  1243             "CMPMServerSession::HandleServerApplicationAcceptedTheCarrier \
       
  1244 PrefIAPNotification error = %i, ", error )            
       
  1245             }
       
  1246         }
       
  1247     else 
       
  1248         {
       
  1249         iStoredIapInfo.ResetStoredIapInfo();
       
  1250         }
       
  1251     }
       
  1252 
       
  1253 
       
  1254 // -----------------------------------------------------------------------------
       
  1255 // CMPMServerSession::HandleServerApplicationRejectedTheCarrierL
       
  1256 // -----------------------------------------------------------------------------
       
  1257 //
       
  1258 void CMPMServerSession::HandleServerApplicationRejectedTheCarrierL(
       
  1259     const RMessage2& aMessage )
       
  1260     {
       
  1261     // PrefIAPNotif will be attempted with latest available IAPs
       
  1262     //
       
  1263     iStoredIapInfo.ResetStoredIapInfo();
       
  1264 
       
  1265     TInt error( KErrNone );
       
  1266 
       
  1267     // Read Iap Id
       
  1268     //
       
  1269     TUint32 rejectedIap = static_cast<TUint32>( aMessage.Int0() );
       
  1270 
       
  1271     // Read the Connection Id of the application
       
  1272     //
       
  1273     TConnectionId rejectedId = aMessage.Int1();
       
  1274 
       
  1275     MPMLOGSTRING3(
       
  1276         "CMPMServerSession::HandleServerApplicationRejectedTheCarrierL \
       
  1277 - IAP Id = %i, Connection Id = 0x%x", rejectedIap, rejectedId )
       
  1278 
       
  1279     // Blacklisting should be done before ResetConnInfo(), 
       
  1280     // since iPresumedIapId is reset during ResetConnInfo(). 
       
  1281     // 
       
  1282     iMyServer.HandleServerBlackListIap( rejectedId, 
       
  1283                                         rejectedIap, 
       
  1284                                         EConnectionLifetime );
       
  1285 
       
  1286     iMyServer.Events()->ResetConnInfo( rejectedId );
       
  1287     iMyServer.ResetBMConnection( rejectedId, rejectedIap, *this );
       
  1288 
       
  1289     // If possible to roam from a WLAN IAP to another WLAN IAP
       
  1290     // perform WLAN scan first.
       
  1291     // Currently ConnMon can't send notifications during this time as it 
       
  1292     // handles requests syncronously. So, that shouldn't cause problems now, 
       
  1293     // but issue should be reviewed if that changes. 
       
  1294     //
       
  1295     TUint32 snapId = iMyServer.GetBMSnap( rejectedId );
       
  1296     RArray<TUint> iapPath;
       
  1297     CleanupClosePushL( iapPath );
       
  1298     if( ( iMyServer.CommsDatAccess()->CheckWlanL( rejectedIap ) != ENotWlanIap ) && 
       
  1299           iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
       
  1300         {
       
  1301             // perform WLAN scan 
       
  1302             // message is completed in callback function 
       
  1303             // CompleteCarrierRejected
       
  1304             // 
       
  1305             iMyServer.Events()->ScanWLANNetworksL( this, 
       
  1306                                                    ConnectionId(), 
       
  1307                                                    EWlanScanCallbackCarrierRejected );
       
  1308             CleanupStack::PopAndDestroy( &iapPath );
       
  1309             aMessage.Complete( error );
       
  1310             return;    
       
  1311         }
       
  1312     else 
       
  1313         {
       
  1314         CompleteCarrierRejected();
       
  1315         }
       
  1316     CleanupStack::PopAndDestroy( &iapPath );
       
  1317     aMessage.Complete( error );
       
  1318     }
       
  1319 
       
  1320 // -----------------------------------------------------------------------------
       
  1321 // CMPMServerSession::GetServiceIdSettingL
       
  1322 // -----------------------------------------------------------------------------
       
  1323 //
       
  1324 TInt CMPMServerSession::GetServiceIdSettingL()
       
  1325     {
       
  1326     TUint32 iap( 0 );
       
  1327     TInt id( KErrNotFound );
       
  1328 
       
  1329     MPMLOGSTRING2( "CMPMServerSession::GetServiceIdSettingL - \
       
  1330 Setting name %S", &KIapProxyServiceSetting() )
       
  1331 
       
  1332     iap = GetPresumedIap();
       
  1333     if( !iap )
       
  1334         {
       
  1335         MPMLOGSTRING( "CMPMServerSession::HandleServerGetIntSetting - \
       
  1336         Iap for the connection not found" )
       
  1337         id = KErrNotFound;
       
  1338         }
       
  1339     else
       
  1340         {
       
  1341         id = iMyServer.CommsDatAccess()->GetIapServiceIdL( iap );
       
  1342         // validate commsdat value.
       
  1343         id = id > 0 && id <= 256 ? id : KErrNotFound;
       
  1344         }
       
  1345     return id;  
       
  1346     }
       
  1347 
       
  1348 // -----------------------------------------------------------------------------
       
  1349 // CMPMServerSession::HandleServerReselectIapL
       
  1350 // -----------------------------------------------------------------------------
       
  1351 //
       
  1352 void CMPMServerSession::HandleServerReselectIapL( const RMessage2& aMessage )
       
  1353     {
       
  1354     MPMLOGSTRING2( "CMPMServerSession::HandleServerReselectIapL session <0x%x>", this )
       
  1355     // Sanity check that client only has one outstanding ChooseBestIAP() or ReselectBestIAP() -call.
       
  1356     //
       
  1357     if ( !iChooseIapMessage.IsNull() )
       
  1358         {
       
  1359         MPMLOGSTRING2( "CMPMServerSession::HandleServerReselectIapL: - Error \
       
  1360  ChooseBestIAP() or ReselectBestIAP() already exists %d", KErrServerBusy )
       
  1361         aMessage.Complete( KErrServerBusy );
       
  1362         }
       
  1363 
       
  1364     // We must save the RMessage in order to complete it later.
       
  1365     //
       
  1366     iChooseIapMessage = aMessage;
       
  1367 
       
  1368     if ( !ChooseBestIapCalled() )
       
  1369         {
       
  1370         MPMLOGSTRING( "CMPMServerSession::HandleServerReselectIapL - Error: \
       
  1371 ChooseBestIap hasn't been called yet" )
       
  1372         aMessage.Complete( KErrNotReady );
       
  1373         return;
       
  1374         }
       
  1375 
       
  1376     MPMLOGSTRING3( "CMPMServerSession::HandleServerReselectIapL - iap %d \
       
  1377 connType %d", iIapSelection->MpmConnPref().IapId(), iIapSelection->MpmConnPref().ConnType() )
       
  1378 
       
  1379     iIapSelection->ChooseIapL( iIapSelection->MpmConnPref() );
       
  1380     }
       
  1381 
       
  1382 // -----------------------------------------------------------------------------
       
  1383 // CMPMServerSession::HandleServerProcessErrorL
       
  1384 // -----------------------------------------------------------------------------
       
  1385 //
       
  1386 void CMPMServerSession::HandleServerProcessErrorL(
       
  1387     const RMessage2& aMessage )
       
  1388     {
       
  1389     // Store message. This is used to complete the message later 
       
  1390     // if asynchronous services are needed first or in Service error
       
  1391     iProcessErrorMessage = aMessage;
       
  1392     
       
  1393     if ( iIapSelection )
       
  1394         {
       
  1395         iIapSelection->StopDisplayingStartingDlg();
       
  1396         }
       
  1397 
       
  1398     // Read Error code
       
  1399     //
       
  1400     TInt error( KErrNone );
       
  1401     TPtr8 errorPtr( reinterpret_cast< TUint8* >( NULL ), 0 );
       
  1402     errorPtr.Set( reinterpret_cast< TUint8* >( &error ),
       
  1403                   sizeof( error ),
       
  1404                   sizeof( error ) );
       
  1405 
       
  1406     // Read the contents of the client pointer into a TPtr8.
       
  1407     // 
       
  1408     TInt res = iProcessErrorMessage.Read( KFirstArgument, errorPtr );
       
  1409     if ( res != KErrNone )
       
  1410         {
       
  1411         iMyServer.PanicClient( KErrBadDescriptor );
       
  1412         return;
       
  1413         }
       
  1414 
       
  1415     if ( !ChooseBestIapCalled() )
       
  1416         {
       
  1417         MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
       
  1418 Warning: ChooseBestIap has not been called yet" )
       
  1419         TBMNeededAction neededAction( EPropagateError );
       
  1420         ProcessErrorComplete( KErrNone, &error, &neededAction );
       
  1421         return;
       
  1422         }
       
  1423 
       
  1424     // Show error popup if it's allowed per client request
       
  1425     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  1426             TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
       
  1427         {
       
  1428         CConnectionUiUtilities* connUiUtils = CConnectionUiUtilities::NewL();
       
  1429         // Note: Below function shows the discreet popup only if the error code
       
  1430         // belongs to the set of errors that are shown to the user.
       
  1431         // Otherwise the popup is not shown.
       
  1432         connUiUtils->ConnectionErrorDiscreetPopup( error );
       
  1433         delete connUiUtils;
       
  1434         connUiUtils = NULL;
       
  1435         }
       
  1436 
       
  1437     // Read the Connection Id of the application
       
  1438     // 
       
  1439     TConnectionId connId = iProcessErrorMessage.Int1();
       
  1440 
       
  1441     MPMLOGSTRING3( "CMPMServerSession::HandleServerProcessErrorL\
       
  1442  - error code = %i, Connection Id = 0x%x", error, connId )
       
  1443 
       
  1444     // Get the current connection IapId for this connId 
       
  1445     //
       
  1446     TUint32 currentIap = iMyServer.GetBMIap( connId );
       
  1447 
       
  1448     // Get the current connection SNAP for this Connection Id
       
  1449     //
       
  1450     TUint32 snapId = iMyServer.GetBMSnap( connId );
       
  1451 
       
  1452     TConnMonIapInfo availableIAPs;
       
  1453     availableIAPs = GetAvailableIAPs();
       
  1454 
       
  1455     RemoveUnavailableIap( availableIAPs, currentIap );
       
  1456 
       
  1457     TBMNeededAction neededAction( EIgnoreError );
       
  1458 
       
  1459     // Get the state of the connection for this Iap Id.
       
  1460     // 
       
  1461     TConnectionState state;
       
  1462     iMyServer.GetConnectionState( connId, state );
       
  1463 
       
  1464     // We need to blacklist the presumed IAP too
       
  1465     // 
       
  1466     TUint32 presumedIap = MyServer().Events()->PresumedIapId( connId, 
       
  1467                                                               currentIap );
       
  1468 
       
  1469     // Reset connection info.
       
  1470     // 
       
  1471     iMyServer.Events()->ResetIapConnInfo( currentIap );
       
  1472 
       
  1473     // Check if IAP is reported by MMS
       
  1474     //
       
  1475     TBool isMMSIap = IsMMSIap( currentIap );
       
  1476     if ( isMMSIap )
       
  1477         {
       
  1478         MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
       
  1479         - DisconnectDialog is not started because of MMS reported IAP" )
       
  1480         }
       
  1481 
       
  1482     TInt* returnError( NULL );
       
  1483     if ( ( state == EStarting ) || ( state == ERoaming ) )
       
  1484         {
       
  1485         // Process error according to the fact that the connection 
       
  1486         // has not yet been started.
       
  1487         // 
       
  1488         if ( DisconnectDlgErrorCode( error ) &&
       
  1489              !IsBackgroundApplication( iAppUid ) &&
       
  1490              !isMMSIap && 
       
  1491              iIapSelection->MpmConnPref().DisconnectDialog() &&
       
  1492              iMyServer.StartedConnectionExists() != KErrNotFound )
       
  1493             {
       
  1494             // Start the Disconnect dialog
       
  1495             // 
       
  1496             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL\
       
  1497  - Start Disconnect dialog" )
       
  1498             iDisconnectDlg = CMPMDisconnectDlg::NewL( *const_cast<CMPMServerSession*>(this),
       
  1499                                                       error,
       
  1500                                                       *MyServer().DisconnectQueue() );
       
  1501             return;
       
  1502             }
       
  1503         else
       
  1504             {
       
  1505             MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
       
  1506 Error not handled with disconnect dialog" )
       
  1507 
       
  1508             if ( state == EStarting ) 
       
  1509                 {
       
  1510                 if ( ( snapId == 0 ) || ( error == KErrCancel ) )
       
  1511                     {
       
  1512                     neededAction = EPropagateError;
       
  1513 
       
  1514                     MPMLOGSTRING(
       
  1515                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1516 Tell BM to end the client connection with appropriate error code" )
       
  1517                     }
       
  1518                 else
       
  1519                     {
       
  1520                     neededAction = EDoReselection;
       
  1521 
       
  1522                     MPMLOGSTRING(
       
  1523                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1524 Tell BM to ignore error and do reselection" )
       
  1525 
       
  1526                     iMyServer.HandleServerBlackListIap( connId, 
       
  1527                                                         currentIap, 
       
  1528                                                         ETemporary );
       
  1529                     if ( ( presumedIap != 0 ) && 
       
  1530                          ( presumedIap != currentIap ) )
       
  1531                         {
       
  1532                         iMyServer.HandleServerBlackListIap( connId, 
       
  1533                                                             presumedIap, 
       
  1534                                                             ETemporary );
       
  1535                         }
       
  1536                     }
       
  1537                 }
       
  1538             else if ( state == ERoaming ) 
       
  1539                 {
       
  1540                 // ERoaming means commsfw stack is moving to new IAP and failed.
       
  1541                 // Hence, MPM should mark to current iap as zero. 
       
  1542                 //
       
  1543                 iMyServer.ResetBMConnection( iConnId, currentIap, *this );
       
  1544                 
       
  1545                 // Notification will be sent with latest 
       
  1546                 // availability info
       
  1547                 //
       
  1548                 iStoredIapInfo.ResetStoredIapInfo();
       
  1549 
       
  1550                 neededAction = EIgnoreError;
       
  1551 
       
  1552                 iMyServer.HandleServerBlackListIap( connId, 
       
  1553                                                     currentIap, 
       
  1554                                                     ETemporary );
       
  1555                 if ( ( presumedIap != 0 ) && 
       
  1556                      ( presumedIap != currentIap ) )
       
  1557                     {
       
  1558                     iMyServer.HandleServerBlackListIap( connId, 
       
  1559                                                         presumedIap, 
       
  1560                                                         ETemporary );
       
  1561                     }
       
  1562                 TRAP( error, PrefIAPNotificationL( availableIAPs, 
       
  1563                                                    EBearerMan ) );
       
  1564                 if ( error == KErrNotFound )
       
  1565                     {
       
  1566                     neededAction = EPropagateError;
       
  1567 
       
  1568                     returnError = &error;
       
  1569 
       
  1570                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound, 
       
  1571                                                      EMPMMobilityErrorNotification ) );
       
  1572                     MPMLOGSTRING(
       
  1573                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1574 Tell BM to end the client connection with appropriate error code" )
       
  1575                     }
       
  1576                 else
       
  1577                     {
       
  1578                     MPMLOGSTRING(
       
  1579                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1580 Tell BM to ignore error and let MPM notify application about preferred IAP" )
       
  1581                     }
       
  1582                 }
       
  1583             else
       
  1584                 {
       
  1585                 MPMLOGSTRING2(
       
  1586                     "CMPMServerSession::HandleServerProcessErrorL - \
       
  1587 Unknown state %d", state )
       
  1588                 }
       
  1589 
       
  1590             // Error might be different from KErrNone if there 
       
  1591             // is no preferred IAP among the available IAPs.
       
  1592             // 
       
  1593             ProcessErrorComplete( KErrNone,
       
  1594                                   returnError,
       
  1595                                   &neededAction );
       
  1596             return;
       
  1597             }
       
  1598         }
       
  1599     else if ( state == EStarted )
       
  1600         {
       
  1601         // Process error according to the fact that the connection 
       
  1602         // has already been started.
       
  1603         //         
       
  1604         if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) )
       
  1605             {
       
  1606             neededAction = EPropagateError;
       
  1607 
       
  1608             MPMLOGSTRING(
       
  1609                 "CMPMServerSession::HandleServerProcessErrorL - \
       
  1610 Tell BM to end the client connection with appropriate error code" )
       
  1611 
       
  1612             // Send error notification. 
       
  1613             // Not sent if connection not registered
       
  1614             // 
       
  1615             TRAP_IGNORE( ErrorNotificationL( error,
       
  1616                                              EMPMMobilityErrorNotification ) )
       
  1617             }
       
  1618         else if ( iPreferredIAPRequested )
       
  1619             {
       
  1620             // IAP connection
       
  1621             //
       
  1622             if( snapId == 0 )
       
  1623                 {
       
  1624                 neededAction = EPropagateError;
       
  1625     
       
  1626                 MPMLOGSTRING(
       
  1627                     "CMPMServerSession::HandleServerProcessErrorL - \
       
  1628 Tell BM to end the client connection with appropriate error code" )
       
  1629 
       
  1630                 TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1631                                                  EMPMMobilityErrorNotification ) )
       
  1632                 }
       
  1633             // SNAP connection
       
  1634             //
       
  1635             else
       
  1636                 {
       
  1637                 // If this has been WLAN IAP and the SNAP contains 
       
  1638                 // other WLAN IAPs, we need to perform WLAN scan before
       
  1639                 // knowing the availability of those
       
  1640                 //
       
  1641                 RArray<TUint> iapPath;
       
  1642                 CleanupClosePushL( iapPath );
       
  1643 
       
  1644                 iMyServer.HandleServerBlackListIap( connId, 
       
  1645                                                     currentIap, 
       
  1646                                                     ETemporary );
       
  1647                 if ( ( presumedIap != 0 ) && 
       
  1648                      ( presumedIap != currentIap ) )
       
  1649                     {
       
  1650                     iMyServer.HandleServerBlackListIap( connId, 
       
  1651                                                         presumedIap, 
       
  1652                                                         ETemporary );
       
  1653                     }
       
  1654 
       
  1655                 // current iap is either WLAN or EasyWlan
       
  1656                 // 
       
  1657                 if( ( iMyServer.CommsDatAccess()->CheckWlanL( currentIap ) != ENotWlanIap ) && 
       
  1658                       iMyServer.CommsDatAccess()->SnapContainsWlanL( snapId, iapPath, KMPMNrWlansTwo ) )
       
  1659                     {
       
  1660                     // perform WLAN scan 
       
  1661                     // message is completed in callback function 
       
  1662                     // ProcessErrorWlanScanCompletedL
       
  1663                     // 
       
  1664                     iMyServer.Events()->ScanWLANNetworksL( this, 
       
  1665                                                            ConnectionId(), 
       
  1666                                                            EWlanScanCallbackProcessErr );
       
  1667                     CleanupStack::PopAndDestroy( &iapPath );
       
  1668                     return;
       
  1669                     }
       
  1670 
       
  1671                 CleanupStack::PopAndDestroy( &iapPath );
       
  1672                 neededAction = EIgnoreError;
       
  1673 
       
  1674                 TRAPD( err2, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
       
  1675                 if ( err2 == KErrNotFound )
       
  1676                     {
       
  1677                     error = err2;
       
  1678                     neededAction = EPropagateError;
       
  1679 
       
  1680                     TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1681                                                      EMPMMobilityErrorNotification ) )
       
  1682                     MPMLOGSTRING(
       
  1683                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1684 Tell BM to end the client connection with appropriate error code" )   
       
  1685                     }
       
  1686                 else
       
  1687                     {
       
  1688                     MPMLOGSTRING(
       
  1689                         "CMPMServerSession::HandleServerProcessErrorL - \
       
  1690 Tell BM to ignore error and let MPM notify application about preferred IAP" )
       
  1691                     }
       
  1692                 }
       
  1693             }
       
  1694         else
       
  1695             {
       
  1696             neededAction = EPropagateError;
       
  1697 
       
  1698             MPMLOGSTRING(
       
  1699                 "CMPMServerSession::HandleServerProcessErrorL - \
       
  1700 Tell BM to end the client connection with appropriate error code" )
       
  1701 
       
  1702             }
       
  1703         ProcessErrorComplete( KErrNone, &error, &neededAction );
       
  1704         
       
  1705         }
       
  1706     else
       
  1707         {
       
  1708         MPMLOGSTRING2(
       
  1709             "CMPMServerSession::HandleServerProcessErrorL Unknown state %d",
       
  1710             state )
       
  1711         ProcessErrorComplete( KErrCorrupt,
       
  1712                               NULL,
       
  1713                               NULL );
       
  1714         }
       
  1715     }
       
  1716 
       
  1717 // -----------------------------------------------------------------------------
       
  1718 // CMPMServerSession::HandleServerRegisterPrefIAPNotifL
       
  1719 // -----------------------------------------------------------------------------
       
  1720 //
       
  1721 void CMPMServerSession::HandleServerRegisterPrefIAPNotifL(
       
  1722     const RMessage2& aMessage )
       
  1723     {
       
  1724     MPMLOGSTRING( "CMPMServerSession::HandleServerRegisterPrefIAPNotifL" )
       
  1725 
       
  1726     // Read the Connection Id of the application
       
  1727     //
       
  1728     TConnectionId regId = aMessage.Int0();
       
  1729     MPMLOGSTRING2( "CMPMServerSession::HandleServerRegisterPrefIAPNotifL \
       
  1730 - regId = 0x%x", regId )
       
  1731 
       
  1732     // Get the current connection SNAP for this Connection Id
       
  1733     //
       
  1734     TUint32 regNetId = iMyServer.GetBMSnap( regId );
       
  1735 
       
  1736     // Get the current connection IapId for this Connection Id 
       
  1737     //
       
  1738     TUint32 currentIap = iMyServer.GetBMIap( regId );
       
  1739     MPMLOGSTRING2( "CMPMServerSession::HandleServerRegisterPrefIAPNotifL \
       
  1740 - currentIap = %i", currentIap)
       
  1741 
       
  1742     // Check that there is a connection using 
       
  1743     // either IAP or SNAP
       
  1744     // 
       
  1745     if ( regNetId == 0 && currentIap == 0 )
       
  1746         {
       
  1747         MPMLOGSTRING( "CMPMServerSession::\
       
  1748         HandleServerRegisterPrefIAPNotifL - return KErrNotSupported" )
       
  1749         aMessage.Complete( KErrNotSupported );
       
  1750         return;
       
  1751         }
       
  1752 
       
  1753     // Append info about registration
       
  1754     iPreferredIAPRequested = ETrue;
       
  1755 
       
  1756     TConnMonIapInfo availableIAPs;
       
  1757     availableIAPs = GetAvailableIAPs();
       
  1758 
       
  1759     MPMLOGSTRING2( "CMPMServerSession::HandleServerRegisterPrefIAPNotifL \
       
  1760 - IAPs count: %d", availableIAPs.iCount)
       
  1761 
       
  1762 #ifdef _DEBUG
       
  1763     for (TUint i = 0; i < availableIAPs.Count(); i++)
       
  1764         {
       
  1765         MPMLOGSTRING2(
       
  1766                 "CMPMServerSession::HandleServerRegisterPrefIAPNotifL \
       
  1767 - IAP: %d", availableIAPs.iIap[i].iIapId)
       
  1768         }
       
  1769 #endif // _DEBUG
       
  1770 
       
  1771     // Call now the method that handles notifications for
       
  1772     // checking if notification is already triggered
       
  1773     // If SNAP is 0, don't try sending notifications 
       
  1774     //
       
  1775     if ( availableIAPs.iCount > 0 && regNetId )
       
  1776         {
       
  1777         PrefIAPNotificationL( availableIAPs, EBearerMan );
       
  1778         }
       
  1779 
       
  1780     // In case the mobility application register to preferred IAP notification
       
  1781     // we have to make sure we get availability every once in a while.
       
  1782     // 
       
  1783     RArray<TUint> iapPath;
       
  1784     CleanupClosePushL( iapPath );
       
  1785     CleanupStack::PopAndDestroy( &iapPath );
       
  1786     aMessage.Complete( KErrNone );
       
  1787     }
       
  1788 
       
  1789 
       
  1790 // -----------------------------------------------------------------------------
       
  1791 // CMPMServerSession::HandleServerUnregisterPrefIAPNotif
       
  1792 // -----------------------------------------------------------------------------
       
  1793 //
       
  1794 void CMPMServerSession::HandleServerUnregisterPrefIAPNotif(
       
  1795     const RMessage2& aMessage )
       
  1796     {
       
  1797     // Read the Connection Id of the application
       
  1798     //
       
  1799     TConnectionId unregId = aMessage.Int0();
       
  1800     MPMLOGSTRING2( "CMPMServerSession::HandleServerUnregisterPrefIAPNotif\
       
  1801  - unregId = 0x%x", unregId )
       
  1802 
       
  1803     // Currently will remove all registration for this Connection Id. 
       
  1804     // If needed change BM-MPM API to support unregistration for certain SNAP
       
  1805     //
       
  1806     iPreferredIAPRequested = EFalse;
       
  1807     iLastNotifiedIap = 0;
       
  1808     // Unblacklist all IAPs related to this connection 
       
  1809     // when unregistering from preferred IAP notification.
       
  1810     // 
       
  1811     iMyServer.HandleServerUnblackListIap( unregId, 0 );
       
  1812 
       
  1813     aMessage.Complete( KErrNone );
       
  1814     }
       
  1815 
       
  1816 
       
  1817 // -----------------------------------------------------------------------------
       
  1818 // CMPMServerSession::HandleServerWaitNotificationL
       
  1819 // -----------------------------------------------------------------------------
       
  1820 //
       
  1821 void CMPMServerSession::HandleServerWaitNotificationL(
       
  1822     const RMessage2& aMessage )
       
  1823     {
       
  1824     MPMLOGSTRING2( "CMPMServerSession::HandleServerWaitNotification - \
       
  1825 iNotifRequested = %i", iNotifRequested )
       
  1826 
       
  1827     if ( !iNotifRequested )
       
  1828         {
       
  1829         // Save message for later completion
       
  1830         //
       
  1831         iNotifMessage = aMessage;
       
  1832 
       
  1833         // Set requested flag
       
  1834         //
       
  1835         iNotifRequested = ETrue;
       
  1836         }
       
  1837     else
       
  1838         {
       
  1839         aMessage.Complete( KErrServerBusy );
       
  1840         }
       
  1841     }
       
  1842 
       
  1843 // -----------------------------------------------------------------------------
       
  1844 // CMPMServerSession::HandleServerSortSNAPL
       
  1845 // -----------------------------------------------------------------------------
       
  1846 //
       
  1847 void CMPMServerSession::HandleServerSortSNAPL( const RMessage2& aMessage )
       
  1848     {
       
  1849     MPMLOGSTRING( "CMPMServerSession::HandleServerSortSNAPL()" )
       
  1850     if ( !iServerSortSNAPMessage.IsNull() )
       
  1851         {
       
  1852         MPMLOGSTRING2(
       
  1853         "CMPMServerSession::HandleServerSortSNAPL: Failed with: %d",KErrNotReady )
       
  1854 
       
  1855         // Error, only one request of each type per session.
       
  1856         aMessage.Complete( KErrNotReady );
       
  1857         }
       
  1858     
       
  1859         // Store message for later usage.
       
  1860     iServerSortSNAPMessage = aMessage;
       
  1861 
       
  1862     TUint32 aSeconds = static_cast<TUint32>( iServerSortSNAPMessage.Int2() );
       
  1863     
       
  1864     // To display up to date information the WLAN scan should be done first
       
  1865     iMyServer.Events()->ScanWLANNetworksL( this, 
       
  1866                                            ConnectionId(), 
       
  1867                                            EWlanScanCallbackSortSnap, 
       
  1868                                            aSeconds );
       
  1869     }
       
  1870     
       
  1871 // -----------------------------------------------------------------------------
       
  1872 // CMPMServerSession::CompleteServerSortSNAPL
       
  1873 // -----------------------------------------------------------------------------
       
  1874 //
       
  1875 void CMPMServerSession::CompleteServerSortSNAP()
       
  1876     {
       
  1877     if ( iServerSortSNAPMessage.IsNull() )
       
  1878         {
       
  1879         return;
       
  1880         }
       
  1881 
       
  1882     // Read SNAP
       
  1883     //
       
  1884     TUint32 snapId = static_cast<TUint32>( iServerSortSNAPMessage.Int0() );
       
  1885 
       
  1886     MPMLOGSTRING2( "CMPMServerSession::CompleteServerSortSNAPL - SNAP = %i", 
       
  1887         snapId )
       
  1888 
       
  1889     TMpmSnapBuffer sortedIapList;
       
  1890 
       
  1891     TRAPD( err, SortSnapL( snapId, sortedIapList ) )
       
  1892     if ( err != KErrNone )
       
  1893         {
       
  1894         MPMLOGSTRING2(
       
  1895             "CMPMServerSession::CompleteServerSortSNAPL: Sorting failed with: %d", err )
       
  1896         iServerSortSNAPMessage.Complete( err );
       
  1897         return;
       
  1898         }
       
  1899 
       
  1900     // Write results to message
       
  1901     // 
       
  1902     TPtrC8 e( reinterpret_cast< TUint8* >( &sortedIapList ), 
       
  1903               sizeof( sortedIapList ) );
       
  1904     TRAP( err, iServerSortSNAPMessage.WriteL( KSecondArgument, e ) )
       
  1905     if ( err != KErrNone )
       
  1906         {
       
  1907         MPMLOGSTRING2(
       
  1908             "CMPMServerSession::CompleteServerSortSNAPL: RMessage.WriteL() Failure: %d", err )
       
  1909         iServerSortSNAPMessage.Complete( err );
       
  1910         return;
       
  1911         }
       
  1912 
       
  1913     MPMLOGSTRING(
       
  1914         "CMPMServerSession::CompleteServerSortSNAPL: Sorting available uncategorised IAPs completed" )
       
  1915     iServerSortSNAPMessage.Complete( KErrNone );
       
  1916     return;
       
  1917     }
       
  1918 
       
  1919 // -----------------------------------------------------------------------------
       
  1920 // CMPMServerSession::ProcessErrorWlanScanCompletedL
       
  1921 // -----------------------------------------------------------------------------
       
  1922 //
       
  1923 void CMPMServerSession::ProcessErrorWlanScanCompletedL()
       
  1924     {
       
  1925     MPMLOGSTRING( "CMPMServerSession::ProcessErrorWlanScanCompletedL" )
       
  1926     TBMNeededAction neededAction( EIgnoreError );
       
  1927 
       
  1928     // Read the Connection Id of the application
       
  1929     // 
       
  1930     TConnectionId connId = iProcessErrorMessage.Int1();
       
  1931 
       
  1932     // Read Error code
       
  1933     //
       
  1934     TInt error( KErrNone);
       
  1935     
       
  1936     TPtr8 errorPtr( reinterpret_cast< TUint8* >( NULL ), 0 );
       
  1937     errorPtr.Set( reinterpret_cast< TUint8* >( &error ),
       
  1938                   sizeof( error ),
       
  1939                   sizeof( error ) );
       
  1940 
       
  1941     // Read the contents of the client pointer into a TPtr8.
       
  1942     // 
       
  1943     TInt res = iProcessErrorMessage.Read( KFirstArgument, errorPtr );
       
  1944     if ( res != KErrNone )
       
  1945         {
       
  1946         iMyServer.PanicClient( KErrBadDescriptor );
       
  1947         return;
       
  1948         }
       
  1949 
       
  1950     // Get the current connection IapId for this connId 
       
  1951     //
       
  1952     TUint32 currentIap = iMyServer.GetBMIap( connId );
       
  1953 
       
  1954     // get available iaps
       
  1955     TConnMonIapInfo availableIAPs;
       
  1956     availableIAPs = GetAvailableIAPs();
       
  1957 
       
  1958     RemoveUnavailableIap( availableIAPs, currentIap );
       
  1959 
       
  1960     TRAPD( err2, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
       
  1961     if ( err2 == KErrNotFound )
       
  1962         {
       
  1963         error = err2;
       
  1964         neededAction = EPropagateError;
       
  1965 
       
  1966         TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  1967                                          EMPMMobilityErrorNotification ) )
       
  1968        MPMLOGSTRING( "CMPMServerSession::ProcessErrorWlanScanCompletedL - \
       
  1969 Tell BM to end the client connection with appropriate error code" )
       
  1970        }
       
  1971     else
       
  1972        {
       
  1973        MPMLOGSTRING( "CMPMServerSession::ProcessErrorWlanScanCompletedL - \
       
  1974 Tell BM to ignore error and let MPM notify application about preferred IAP" )
       
  1975         }
       
  1976         
       
  1977     ProcessErrorComplete( KErrNone, &error, &neededAction );
       
  1978     }
       
  1979 
       
  1980 // -----------------------------------------------------------------------------
       
  1981 // CMPMServerSession::SortSnapL
       
  1982 // -----------------------------------------------------------------------------
       
  1983 //
       
  1984 void CMPMServerSession::SortSnapL( const TUint32 aSnapId, 
       
  1985                                    TMpmSnapBuffer& aSortedIaps )
       
  1986     {
       
  1987     MPMLOGSTRING2( "CMPMServerSession::SortSnapL - SNAP = %i", 
       
  1988         aSnapId )
       
  1989 
       
  1990     TBool hideIap( EFalse ); 
       
  1991 
       
  1992     // In case snapId is zero, return the 
       
  1993     // list of available uncategorised IAPs 
       
  1994     // 
       
  1995     if ( aSnapId == KSortUncategorisedIaps )
       
  1996         {
       
  1997         RAvailableIAPList availableUncatIAPList;
       
  1998         CleanupClosePushL( availableUncatIAPList );
       
  1999         AvailableUnblacklistedIapsL( availableUncatIAPList, iConnId );
       
  2000 
       
  2001         iMyServer.CommsDatAccess()->RemoveCategorisedIapsL( availableUncatIAPList );
       
  2002 
       
  2003         aSortedIaps.Reset();
       
  2004 
       
  2005         for ( TInt i( 0 ); ( (i < availableUncatIAPList.Count()) ); i++ )
       
  2006             {
       
  2007             // Check first if metadata EMetaHiddenAgent is enabled.
       
  2008             // 
       
  2009             hideIap = iMyServer.CommsDatAccess()->CheckHiddenAgentL( availableUncatIAPList[i] );
       
  2010             if ( hideIap )
       
  2011                 {
       
  2012                 // In that case IAP can't be shown in Connection Dialog.
       
  2013                 // 
       
  2014                 MPMLOGSTRING2( 
       
  2015                     "CMPMServerSession::SortSnapL: Remove HiddenAgent IAP = %i", 
       
  2016                     availableUncatIAPList[i] )
       
  2017                 }
       
  2018             else
       
  2019                 {
       
  2020                 aSortedIaps.iIapId[aSortedIaps.iCount] = availableUncatIAPList[i];
       
  2021                 aSortedIaps.iCount++;
       
  2022                 }
       
  2023             }
       
  2024 
       
  2025 #ifdef _DEBUG
       
  2026         // Print info into the log file
       
  2027         //
       
  2028         MPMLOGSTRING( "CMPMServerSession::SortSnapL: Sorted IAPs" )
       
  2029         for ( TInt p = 0; p < aSortedIaps.Count(); p++ )
       
  2030             {
       
  2031             MPMLOGSTRING2(
       
  2032                 "CMPMServerSession::SortSnapL: IapId = %i", 
       
  2033                 aSortedIaps.iIapId[p] )
       
  2034             }
       
  2035 #endif // _DEBUG
       
  2036 
       
  2037         // Release memory
       
  2038         //
       
  2039         CleanupStack::PopAndDestroy( &availableUncatIAPList );
       
  2040         return;
       
  2041         }
       
  2042 
       
  2043     RArray<TNetIap> destNetIaps, embeddedIaps;
       
  2044     CleanupClosePushL( destNetIaps );
       
  2045     CleanupClosePushL( embeddedIaps );
       
  2046 
       
  2047     // Find the valid IAPs belonging to the Snap.
       
  2048     //
       
  2049     iMyServer.CommsDatAccess()->SearchDNEntriesWithEmbeddedL( aSnapId, destNetIaps, embeddedIaps );
       
  2050 
       
  2051     RAvailableIAPList availableIAPList;
       
  2052     CleanupClosePushL( availableIAPList );
       
  2053     AvailableUnblacklistedIapsL( availableIAPList, iConnId );
       
  2054 
       
  2055     // Remove any unavailable IAP from destNetIaps
       
  2056     // 
       
  2057     TInt ret        = KErrNotFound;
       
  2058     TInt destCount  = destNetIaps.Count();
       
  2059     
       
  2060     // Decrement by one, because count is n, 
       
  2061     // but indexes in array are 0 .. n-1.
       
  2062     // 
       
  2063     destCount--;
       
  2064 
       
  2065     // This time we are browsing the array from the end to the beginning, 
       
  2066     // because removing one element from array affects index numbering.
       
  2067     // 
       
  2068     for ( TInt k = destCount; k >= 0; k-- )
       
  2069         {
       
  2070         ret = availableIAPList.Find( destNetIaps[k].iIapId );
       
  2071         if ( ret == KErrNotFound )
       
  2072             {
       
  2073             MPMLOGSTRING2( "CMPMServerSession::SortSnapL: \
       
  2074 Remove unavailable IAP = %i", destNetIaps[k].iIapId )
       
  2075             destNetIaps.Remove( k );
       
  2076             }
       
  2077         else
       
  2078             {
       
  2079             // Check first if metadata EMetaHiddenAgent is enabled.
       
  2080             // 
       
  2081             hideIap = iMyServer.CommsDatAccess()->CheckHiddenAgentL( destNetIaps[k].iIapId );
       
  2082             if ( hideIap )
       
  2083                 {
       
  2084                 // In that case IAP can't be shown in Connection Dialog.
       
  2085                 // 
       
  2086                 MPMLOGSTRING2( 
       
  2087                     "CMPMServerSession::SortSnapL: Remove HiddenAgent IAP = %i", 
       
  2088                     destNetIaps[k].iIapId )
       
  2089                 destNetIaps.Remove( k );
       
  2090                 }
       
  2091             }
       
  2092         }
       
  2093 
       
  2094     // Remove any unavailable IAP from embeddedIaps
       
  2095     // 
       
  2096     if ( embeddedIaps.Count() > 0 )
       
  2097         {
       
  2098         TInt embedCount = embeddedIaps.Count();
       
  2099         embedCount--;
       
  2100 
       
  2101         for ( TInt m = embedCount; m >= 0; m-- )
       
  2102             {
       
  2103             ret = availableIAPList.Find( embeddedIaps[m].iIapId );
       
  2104             if ( ret == KErrNotFound )
       
  2105                 {
       
  2106                 MPMLOGSTRING2( "CMPMServerSession::SortSnapL: \
       
  2107 Remove unavailable IAP = %i", embeddedIaps[m].iIapId )
       
  2108                 embeddedIaps.Remove( m );
       
  2109                 }
       
  2110             else
       
  2111                 {
       
  2112                 // Check first if metadata EMetaHiddenAgent is enabled.
       
  2113                 // 
       
  2114                 hideIap = iMyServer.CommsDatAccess()->CheckHiddenAgentL( embeddedIaps[m].iIapId );
       
  2115                 if ( hideIap )
       
  2116                     {
       
  2117                     // In that case IAP can't be shown in Connection Dialog.
       
  2118                     // 
       
  2119                     MPMLOGSTRING2( 
       
  2120                         "CMPMServerSession::SortSnapL: Remove HiddenAgent IAP = %i", 
       
  2121                         embeddedIaps[m].iIapId )
       
  2122                     embeddedIaps.Remove( m );
       
  2123                     }
       
  2124                 }
       
  2125             }
       
  2126         }
       
  2127 
       
  2128     // Determine the actual priorities for virtual IAPs and embedded Snaps
       
  2129     // 
       
  2130     iMyServer.CommsDatAccess()->DeterminePrioritiesL( destNetIaps, availableIAPList,
       
  2131                                                       *this );
       
  2132     if ( embeddedIaps.Count() > 0 )
       
  2133         {
       
  2134         iMyServer.CommsDatAccess()->DeterminePrioritiesL( embeddedIaps,
       
  2135                                                           availableIAPList,
       
  2136                                                           *this );
       
  2137         }
       
  2138 
       
  2139     aSortedIaps.Reset();
       
  2140 
       
  2141     // Start sorting destNetIaps and embeddedIaps.
       
  2142     // 
       
  2143     for( TInt p = 0; ( destNetIaps.Count()  > 0 ) || 
       
  2144                      ( embeddedIaps.Count() > 0 ); p++ )
       
  2145         {
       
  2146         // Go through the destNetIaps-array and check the global bearer 
       
  2147         // priority for both destNetIaps and embeddedIaps until the best 
       
  2148         // available IAP is found.
       
  2149         // 
       
  2150         TUint32 destNetPriority( KLowestPriority );
       
  2151         TUint32 embeddedPriority( KLowestPriority );
       
  2152 
       
  2153         if( destNetIaps.Count() > 0 )
       
  2154             {
       
  2155             iMyServer.CommsDatAccess()->GlobalBearerPriorityL( destNetIaps[0].iIapId, 
       
  2156                                    destNetPriority );
       
  2157             }
       
  2158 
       
  2159         if( embeddedIaps.Count() > 0 )
       
  2160             {
       
  2161             iMyServer.CommsDatAccess()->GlobalBearerPriorityL( embeddedIaps[0].iIapId, 
       
  2162                                    embeddedPriority );
       
  2163             }
       
  2164 
       
  2165         // Compare the global bearer priorities of the first IAPs and 
       
  2166         // select the better. 
       
  2167         // 
       
  2168         // If the priorities are equal, prioritize the Snap 
       
  2169         // over the embedded Snap.
       
  2170         // 
       
  2171         // When comparing the priorities, smaller value is better.
       
  2172         // 
       
  2173         // Finally, append IapId to sortedList.
       
  2174         //
       
  2175         if( destNetPriority <= embeddedPriority )
       
  2176             {
       
  2177             if( destNetIaps.Count() > 0 )
       
  2178                 {
       
  2179                 aSortedIaps.iIapId[p] = destNetIaps[0].iIapId;
       
  2180                 aSortedIaps.iCount++;
       
  2181                 MPMLOGSTRING2(
       
  2182                     "CMPMServerSession::SortSnapL: IapId = %i", 
       
  2183                     destNetIaps[0].iIapId )
       
  2184                 MPMLOGSTRING2(
       
  2185                     "CMPMServerSession::SortSnapL: Snap  = %i", 
       
  2186                     destNetIaps[0].iSnap )
       
  2187                 destNetIaps.Remove( 0 );
       
  2188                 }
       
  2189             }
       
  2190         else
       
  2191             {
       
  2192             if( embeddedIaps.Count() > 0 )
       
  2193                 {
       
  2194                 aSortedIaps.iIapId[p] = embeddedIaps[0].iIapId;
       
  2195                 aSortedIaps.iCount++;
       
  2196                 MPMLOGSTRING2(
       
  2197                     "CMPMServerSession::SortSnapL: IapId = %i", 
       
  2198                     embeddedIaps[0].iIapId )
       
  2199                 MPMLOGSTRING2(
       
  2200                     "CMPMServerSession::SortSnapL: Snap  = %i", 
       
  2201                     embeddedIaps[0].iSnap )
       
  2202                 embeddedIaps.Remove( 0 );
       
  2203                 }
       
  2204             }
       
  2205         }
       
  2206 
       
  2207     // Release memory
       
  2208     //
       
  2209     CleanupStack::PopAndDestroy( &availableIAPList );
       
  2210     CleanupStack::PopAndDestroy( &embeddedIaps );
       
  2211     CleanupStack::PopAndDestroy( &destNetIaps );
       
  2212 
       
  2213 #ifdef _DEBUG
       
  2214     // Print info into the log file
       
  2215     //
       
  2216     MPMLOGSTRING( "CMPMServerSession::SortSnapL: Sorted IAPs" )
       
  2217     for ( TInt n = 0; n < aSortedIaps.Count(); n++ )
       
  2218         {
       
  2219         MPMLOGSTRING2(
       
  2220             "CMPMServerSession::SortSnapL: IapId = %i", 
       
  2221             aSortedIaps.iIapId[n] )
       
  2222         }
       
  2223 #endif // _DEBUG
       
  2224 
       
  2225     MPMLOGSTRING(
       
  2226             "CMPMServerSession::SortSnapL: Sorting completed" )
       
  2227     }
       
  2228 
       
  2229 // -----------------------------------------------------------------------------
       
  2230 // CMPMServerSession::UpdateConnectionDialog
       
  2231 // -----------------------------------------------------------------------------
       
  2232 //
       
  2233 void CMPMServerSession::UpdateConnectionDialogL()
       
  2234     {
       
  2235     if( iIapSelection )
       
  2236         {
       
  2237         iIapSelection->UpdateConnectionDialogL();
       
  2238         }
       
  2239     }
       
  2240 
       
  2241 // -----------------------------------------------------------------------------
       
  2242 // CMPMServerSession::CompleteCarrierRejected
       
  2243 // -----------------------------------------------------------------------------
       
  2244 //
       
  2245 void CMPMServerSession::CompleteCarrierRejected()
       
  2246     {
       
  2247     TInt error( KErrNotFound );
       
  2248 
       
  2249     MPMLOGSTRING( "CMPMServerSession::CompleteCarrierRejected" )
       
  2250 
       
  2251     TConnMonIapInfo availableIAPs;
       
  2252     availableIAPs = GetAvailableIAPs();
       
  2253 
       
  2254     if ( availableIAPs.iCount > 0 ) 
       
  2255         {
       
  2256         TRAP( error, PrefIAPNotificationL( availableIAPs, EBearerMan ) );
       
  2257         if ( error == KErrNotFound )
       
  2258             {
       
  2259             TRAP( error, ErrorNotificationL( KErrNotFound,
       
  2260                                              EMPMMobilityErrorNotification ) );
       
  2261             }
       
  2262         }
       
  2263     else
       
  2264         {
       
  2265         MPMLOGSTRING(
       
  2266             "CMPMServerSession::CompleteCarrierRejected - \
       
  2267 No IAPs available, send error notification" )
       
  2268         TRAP( error, ErrorNotificationL( KErrNotFound,
       
  2269                                          EMPMMobilityErrorNotification ) );
       
  2270         }
       
  2271     }
       
  2272 
       
  2273 // -----------------------------------------------------------------------------
       
  2274 // CMPMServerSession::ExtractConnPref
       
  2275 // -----------------------------------------------------------------------------
       
  2276 //
       
  2277 TInt CMPMServerSession::ExtractConnPref(
       
  2278     const TConnPref& aBasePref,
       
  2279     TMpmConnPref& aMpmConnPref ) const
       
  2280     {
       
  2281     TInt error( KErrNone );
       
  2282 
       
  2283     // Extract connection preferences from TConnPref to TMpmConnPref
       
  2284     // based on the type of the connection preferences.
       
  2285     //
       
  2286     switch ( aBasePref.ExtensionId() )
       
  2287         {
       
  2288         case TConnPref::EConnPrefCommDb: // TCommDbConnPref
       
  2289             {
       
  2290             MPMLOGSTRING(
       
  2291                 "CMPMServerSession::ExtractConnPref - EConnPrefCommDb" )
       
  2292             error = ExtractConnPrefCommDb( aBasePref, aMpmConnPref );
       
  2293             break;
       
  2294             }
       
  2295         case TConnPref::EConnPrefCommDbMulti: // TCommDbMultiConnPref
       
  2296             {
       
  2297             MPMLOGSTRING(
       
  2298                 "CMPMServerSession::ExtractConnPref - EConnPrefCommDbMulti" )
       
  2299             error = ExtractConnPrefCommDbMulti( aBasePref, aMpmConnPref );
       
  2300             break;
       
  2301             }
       
  2302         case TConnPref::EConnPrefSnap: // TConnSnapPref
       
  2303             {
       
  2304             MPMLOGSTRING(
       
  2305                 "CMPMServerSession::ExtractConnPref - EConnPrefSnap" )
       
  2306             error = ExtractConnPrefSnap( aBasePref, aMpmConnPref );
       
  2307             break;
       
  2308             }
       
  2309         case TMpmConnPref::EConnPrefMpm: // TMpmConnPref
       
  2310             {
       
  2311             MPMLOGSTRING(
       
  2312                 "CMPMServerSession::ExtractConnPref - EConnPrefMpm" )
       
  2313             error = ExtractConnPrefMpm( aBasePref, aMpmConnPref );
       
  2314             break;
       
  2315             }
       
  2316         case TConnPref::EConnPrefUnknown: // Default connection
       
  2317             {
       
  2318             MPMLOGSTRING( "CMPMServerSession::ExtractConnPref - \
       
  2319 EConnPrefUnknown overriding to default conn" )
       
  2320             break;
       
  2321             }
       
  2322         default:
       
  2323             {
       
  2324             MPMLOGSTRING( "CMPMServerSession::ExtractConnPref - \
       
  2325 Unrecognised connection preference type" )
       
  2326             error = KErrArgument;
       
  2327             }
       
  2328         }
       
  2329 
       
  2330     ResolveConnType( aMpmConnPref );
       
  2331 
       
  2332     MPMLOGSTRING2( "CMPMServerSession::ExtractConnPref - \
       
  2333 Error code in the end: %d", error )
       
  2334     return error;
       
  2335     }
       
  2336 
       
  2337 // -----------------------------------------------------------------------------
       
  2338 // CMPMServerSession::ExtractConnPrefCommDb
       
  2339 // -----------------------------------------------------------------------------
       
  2340 //
       
  2341 TInt CMPMServerSession::ExtractConnPrefCommDb(
       
  2342     const TConnPref& aBasePref,
       
  2343     TMpmConnPref& aMpmConnPref ) const
       
  2344     {
       
  2345     ASSERT( aBasePref.ExtensionId() == TConnPref::EConnPrefCommDb );
       
  2346     TInt error( KErrNone );
       
  2347 
       
  2348     // Cast down to a TCommDbConnPref
       
  2349     TCommDbConnPref commDbPref;
       
  2350     commDbPref = TCommDbConnPref::Cast( aBasePref );
       
  2351 
       
  2352     // This is an old sanity check which is not complete but we cannot
       
  2353     // expand it to keep backwards compatibility.
       
  2354     if ( commDbPref.IapId() == 0 && commDbPref.NetId() != 0 &&
       
  2355          commDbPref.DialogPreference() != ECommDbDialogPrefPrompt )
       
  2356         {
       
  2357         error = KErrArgument;
       
  2358         }
       
  2359     else
       
  2360         {
       
  2361         // Map dialog preference. Only request for connection selection
       
  2362         // dialog is needed as other values either match the default values of TMpmConnPref
       
  2363         // or are ignored (ECommDbDialogPrefWarn and
       
  2364         // ECommDbDialogPrefPromptIfWrongMode).
       
  2365         if ( commDbPref.DialogPreference() == ECommDbDialogPrefPrompt )
       
  2366             {
       
  2367             aMpmConnPref.SetConnSelectionDialog( ETrue );
       
  2368             }
       
  2369         else
       
  2370             {
       
  2371             // Map IAP id.
       
  2372             aMpmConnPref.SetIapId( commDbPref.IapId() );
       
  2373             }
       
  2374 
       
  2375         // commDbPref.NetId() is ignored as it's retrieved by MPM based on
       
  2376         // final selection.
       
  2377         // commDbPref.Direction() is ignored as it's not used in MPM.
       
  2378 
       
  2379         // Transfer bearerset from aCommDbPref to aMpmConnPref
       
  2380         // in case 'prompt from user' or 'explicit SNAP requested'.
       
  2381         // If only IAP is given, bearer set is ignored and not set.
       
  2382         // If bearer set is set for IAP connection here, implementation of
       
  2383         // "WLAN Only" setting feature will prevent cellular IAP connection
       
  2384         // from happening
       
  2385         if ( commDbPref.DialogPreference() != ECommDbDialogPrefUnknown &&
       
  2386              ( commDbPref.IapId() == 0 ||
       
  2387                commDbPref.DialogPreference() == ECommDbDialogPrefPrompt ) )
       
  2388             {
       
  2389             if ( commDbPref.BearerSet() & ECommDbBearerWLAN )
       
  2390                 {
       
  2391                 aMpmConnPref.SetBearerSet( aMpmConnPref.BearerSet() | 
       
  2392                         TExtendedConnPref::EExtendedConnBearerWLAN );
       
  2393                 }
       
  2394 
       
  2395             if ( commDbPref.BearerSet() & ECommDbBearerWcdma ||
       
  2396                  commDbPref.BearerSet() & DeprecatedCDMA2000 )
       
  2397                 {
       
  2398                 aMpmConnPref.SetBearerSet( aMpmConnPref.BearerSet() | 
       
  2399                         TExtendedConnPref::EExtendedConnBearerCellular );
       
  2400                 }
       
  2401             }
       
  2402         }
       
  2403 
       
  2404     return error;
       
  2405     }
       
  2406 
       
  2407 // -----------------------------------------------------------------------------
       
  2408 // CMPMServerSession::ExtractConnPrefCommDbMulti
       
  2409 // -----------------------------------------------------------------------------
       
  2410 //
       
  2411 TInt CMPMServerSession::ExtractConnPrefCommDbMulti(
       
  2412     const TConnPref& aBasePref,
       
  2413     TMpmConnPref& aMpmConnPref ) const
       
  2414     {
       
  2415     ASSERT( aBasePref.ExtensionId() == TConnPref::EConnPrefCommDbMulti );
       
  2416     TInt error( KErrNone );
       
  2417 
       
  2418     // Cast down to a TCommDbMultiConnPref
       
  2419     TCommDbMultiConnPref multiPrefs;
       
  2420     multiPrefs = TCommDbMultiConnPref::Cast( aBasePref );
       
  2421 
       
  2422     // Try to retrieve the connection preference for the first attempt
       
  2423     TCommDbConnPref commDbPref;
       
  2424     error = multiPrefs.GetPreference( 1, commDbPref );
       
  2425 
       
  2426     if ( error == KErrNone )
       
  2427         {
       
  2428         error = ExtractConnPrefCommDb( commDbPref, aMpmConnPref );
       
  2429         }
       
  2430 
       
  2431     return error;
       
  2432     }
       
  2433 
       
  2434 // -----------------------------------------------------------------------------
       
  2435 // CMPMServerSession::ExtractConnPrefSnap
       
  2436 // -----------------------------------------------------------------------------
       
  2437 //
       
  2438 TInt CMPMServerSession::ExtractConnPrefSnap(
       
  2439     const TConnPref& aBasePref,
       
  2440     TMpmConnPref& aMpmConnPref ) const
       
  2441     {
       
  2442     ASSERT( aBasePref.ExtensionId() == TConnPref::EConnPrefSnap );
       
  2443 
       
  2444     // Cast down to a TConnSnapPref
       
  2445     TConnSnapPref snapPref;
       
  2446     snapPref = *reinterpret_cast<TCommSnapPref*>(
       
  2447             const_cast<TConnPref*>( &aBasePref ) );
       
  2448 
       
  2449     // Check whether old net id, new snap id, or zero is given.
       
  2450     // If snap id equals to zero, doing nothing here implies default
       
  2451     // connection is used. We cannot give error in this case because it has
       
  2452     // worked as default connection request earlier.
       
  2453     TInt snapid(0);
       
  2454     TInt error( KErrNone );
       
  2455     if ( snapPref.Snap() > 0 &&
       
  2456          snapPref.Snap() <= 0x100 )
       
  2457         {
       
  2458         // Old Destination network id passed. Convert to SNAP id.
       
  2459         TRAP( error,
       
  2460               snapid = iMyServer.CommsDatAccess()->MapNetIdtoSnapAPL(
       
  2461                   snapPref.Snap() ) );
       
  2462         }
       
  2463     else if ( snapPref.Snap() != 0 )
       
  2464         {
       
  2465         // Snap id passed.
       
  2466         snapid = snapPref.Snap();
       
  2467         }
       
  2468 
       
  2469     aMpmConnPref.SetSnapId( snapid );
       
  2470 
       
  2471     return error;
       
  2472     }
       
  2473 
       
  2474 // -----------------------------------------------------------------------------
       
  2475 // CMPMServerSession::ExtractConnPrefMpm
       
  2476 // -----------------------------------------------------------------------------
       
  2477 //
       
  2478 TInt CMPMServerSession::ExtractConnPrefMpm(
       
  2479     const TConnPref& aBasePref,
       
  2480     TMpmConnPref& aMpmConnPref ) const
       
  2481     {    
       
  2482     ASSERT( aBasePref.ExtensionId() == TMpmConnPref::EConnPrefMpm );
       
  2483     TInt error( KErrNone );
       
  2484 
       
  2485     aMpmConnPref = *reinterpret_cast<TMpmConnPref*>(
       
  2486         const_cast<TConnPref*>( &aBasePref ) );
       
  2487 
       
  2488     // Validate connection preferences and if they are valid, resolve needed
       
  2489     // information into more practical format for MPM.
       
  2490     error = ValidateExtendedConnPref( aMpmConnPref );
       
  2491     if ( error == KErrNone )
       
  2492         {
       
  2493         // Find the SNAP id based on SNAP purpose.
       
  2494         CMManager::TSnapPurpose aSnapPurpose = aMpmConnPref.SnapPurpose();
       
  2495         TInt error = KErrNone;
       
  2496         
       
  2497         // MPM searches SnapId for requested purpose by going through all
       
  2498         // destinations in CommsDat.
       
  2499         if ( aSnapPurpose != CMManager::ESnapPurposeUnknown )
       
  2500             {
       
  2501             TUint32 snapId(0);
       
  2502             TRAP( error, snapId = iMyServer.CommsDatAccess()->DestinationIdL(
       
  2503                                       aSnapPurpose ) );
       
  2504             if ( error == KErrNone )
       
  2505                 {
       
  2506                 aMpmConnPref.SetSnapId( snapId );
       
  2507                 }
       
  2508             }
       
  2509 
       
  2510         // Mark IAP as mandated if IAP id is given. 
       
  2511         if ( aMpmConnPref.IapId() != 0 )
       
  2512             {
       
  2513             aMpmConnPref.SetMandateIap( ETrue );
       
  2514             }
       
  2515         }
       
  2516 
       
  2517     return error;
       
  2518     }
       
  2519 
       
  2520 // -----------------------------------------------------------------------------
       
  2521 // CMPMServerSession::ValidateExtendedConnPref
       
  2522 // 
       
  2523 // Makes a sanity check to the custom preferences and return KErrArgument
       
  2524 // if there are illegal combinations in the connection preferences
       
  2525 // -----------------------------------------------------------------------------
       
  2526 //
       
  2527 TInt CMPMServerSession::ValidateExtendedConnPref(
       
  2528     TMpmConnPref& aMpmConnPref ) const
       
  2529     {     
       
  2530     // If iap id is set, neither snap nor bearer set can be defined
       
  2531     if ( aMpmConnPref.IapId() != 0 )
       
  2532         {
       
  2533         if ( ( aMpmConnPref.SnapId() != 0 ) ||
       
  2534              ( aMpmConnPref.BearerSet() !=
       
  2535                TExtendedConnPref::EExtendedConnBearerUnknown ) )
       
  2536             {
       
  2537             return KErrArgument;
       
  2538             }
       
  2539         }
       
  2540     
       
  2541     // If snap purpose is set, then neither iap nor snap id should be defined
       
  2542     if ( aMpmConnPref.SnapPurpose() != CMManager::ESnapPurposeUnknown )
       
  2543         {
       
  2544         if ( ( aMpmConnPref.IapId() != 0 )  || 
       
  2545              ( aMpmConnPref.SnapId() != 0 ) )
       
  2546             {
       
  2547             return KErrArgument;
       
  2548             }
       
  2549         }
       
  2550     
       
  2551     // If selection dialog is enabled, Snap id, iap id and snap purpose
       
  2552     // should not be set
       
  2553     if ( aMpmConnPref.ConnSelectionDialog() )
       
  2554         {
       
  2555         if ( ( aMpmConnPref.SnapId() != 0 )  || 
       
  2556              ( aMpmConnPref.IapId() != 0 ) || 
       
  2557              ( aMpmConnPref.SnapPurpose() != CMManager::ESnapPurposeUnknown ) )
       
  2558             {
       
  2559             return KErrArgument;
       
  2560             }
       
  2561         }
       
  2562     
       
  2563     // Check that the given enumerations are within the enumeration ranges
       
  2564     if ( ( aMpmConnPref.SnapPurpose() < CMManager::ESnapPurposeUnknown ) ||
       
  2565          ( aMpmConnPref.SnapPurpose() > CMManager::ESnapPurposeIntranet ) ||
       
  2566          ( aMpmConnPref.NoteBehaviour() >
       
  2567            TExtendedConnPref::ENoteBehaviourConnSilent ) ||
       
  2568          ( aMpmConnPref.BearerSet() > 
       
  2569                ( TExtendedConnPref::EExtendedConnBearerCellular + 
       
  2570                  TExtendedConnPref::EExtendedConnBearerWLAN ) ) )
       
  2571         {
       
  2572         return KErrArgument;
       
  2573         }
       
  2574     
       
  2575     // Check that one of SNAP purpose, SNAP id, IAP id or Connection selection
       
  2576     // dialog is given
       
  2577     if ( ( aMpmConnPref.SnapPurpose() == CMManager::ESnapPurposeUnknown ) &&
       
  2578          ( aMpmConnPref.SnapId() == 0 ) &&
       
  2579          ( aMpmConnPref.IapId() == 0 ) &&
       
  2580          ( aMpmConnPref.ConnSelectionDialog() == EFalse ) )
       
  2581         {
       
  2582         return KErrArgument;
       
  2583         }
       
  2584     
       
  2585     return KErrNone;
       
  2586     }
       
  2587 
       
  2588 // -----------------------------------------------------------------------------
       
  2589 // CMPMServerSession::ResolveConnType
       
  2590 // -----------------------------------------------------------------------------
       
  2591 //
       
  2592 void CMPMServerSession::ResolveConnType( TMpmConnPref& aMpmConnPref ) const
       
  2593     {
       
  2594     // Define the connection type based on the connection preferences.
       
  2595     if ( aMpmConnPref.ConnSelectionDialog() )
       
  2596         {
       
  2597         // Connection selection dialog was requested.
       
  2598         aMpmConnPref.SetConnType( TMpmConnPref::EConnTypeImplicit );
       
  2599         }
       
  2600     else if ( aMpmConnPref.IapId() != 0 ||
       
  2601               aMpmConnPref.SnapId() != 0 ||
       
  2602               aMpmConnPref.SnapPurpose() != CMManager::ESnapPurposeUnknown )
       
  2603         {
       
  2604         // Either IAP id, SNAP id or SNAP purpose was given.
       
  2605         aMpmConnPref.SetConnType( TMpmConnPref::EConnTypeExplicit );
       
  2606         }
       
  2607     else
       
  2608         {
       
  2609         // Otherwise this is handled as a request to default connection.
       
  2610         aMpmConnPref.SetConnType( TMpmConnPref::EConnTypeDefault );
       
  2611         }
       
  2612     }
       
  2613 
       
  2614 // -----------------------------------------------------------------------------
       
  2615 // CMPMServerSession::IapSelectionL
       
  2616 // -----------------------------------------------------------------------------
       
  2617 //
       
  2618 CMPMIapSelection* CMPMServerSession::IapSelectionL()
       
  2619     {
       
  2620     if( !iIapSelection )
       
  2621         {
       
  2622         MPMLOGSTRING( "CMPMServerSession::IapSelectionL error, no connection started" )
       
  2623         User::Leave( KErrNotFound );
       
  2624         }
       
  2625     return iIapSelection;
       
  2626     }
       
  2627 
       
  2628 // -----------------------------------------------------------------------------
       
  2629 // CMPMServerSession::PrefIAPNotificationL
       
  2630 // -----------------------------------------------------------------------------
       
  2631 //
       
  2632 void CMPMServerSession::PrefIAPNotificationL(
       
  2633     const TConnMonIapInfo&      aIapInfo,
       
  2634     const TPrefIAPNotifCaller   aCaller )
       
  2635     {
       
  2636     MPMLOGSTRING( "CMPMServerSession::PrefIAPNotificationL" )
       
  2637 
       
  2638     if ( !iNotifRequested || !iPreferredIAPRequested )
       
  2639         {
       
  2640         MPMLOGSTRING( "CMPMServerSession::PrefIAPNotificationL - \
       
  2641 No notification requested" )
       
  2642         return;
       
  2643         }
       
  2644     
       
  2645     // Dig out the state of this connection.
       
  2646     //
       
  2647     TConnectionState state;
       
  2648     iMyServer.GetConnectionState( iConnId, state );
       
  2649     
       
  2650     // If session is roaming, notification must be delayed.
       
  2651     // But, only ConnMon initiated notifications need to be delayed.
       
  2652     // Required notifications must go through whenever MPM decides
       
  2653     // to initiate them.
       
  2654     //
       
  2655     if( ( iStoredIapInfo.HoldPrefIapNotif() && aCaller == EConnMon)  ||
       
  2656         ( state == ERoaming && aCaller == EConnMon ) )
       
  2657         {
       
  2658         MPMLOGSTRING( "CMPMServerSession::PrefIAPNotificationL - \
       
  2659 Mobility ongoing, notification will be handled later" )
       
  2660         iStoredIapInfo.SetStoredIapInfo( aIapInfo );
       
  2661         return;
       
  2662         }
       
  2663 
       
  2664     TInt err(0);
       
  2665     TInt currentIap = MyServer().GetBMIap( iConnId );
       
  2666     MPMLOGSTRING4( "CMPMServerSession::PrefIAPNotificationL - \
       
  2667 current iap %d, last notified %d, err %d ", currentIap, iLastNotifiedIap, err )
       
  2668     if( err != KErrNone )
       
  2669         {
       
  2670         MPMLOGSTRING( "CMPMServerSession::PrefIAPNotificationL: Connection is not \
       
  2671 registered for notifications" )
       
  2672         return;
       
  2673         }
       
  2674         
       
  2675     TBool iapTypeLanOrWlan( EFalse );
       
  2676     RAvailableIAPList  availableIAPList;
       
  2677     CleanupClosePushL( availableIAPList );
       
  2678     TUint32 validateIapId( 0 );
       
  2679     TUint32 oldIapId( 0 );
       
  2680 
       
  2681     TMpmNotificationPrefIAPAvailable notifInfo;
       
  2682     notifInfo.iMPMNotificationType = EMPMPreferredIAPAvailable;
       
  2683 
       
  2684     AvailableUnblacklistedIapsL( availableIAPList, aIapInfo, iConnId);
       
  2685     oldIapId = currentIap;
       
  2686             
       
  2687     // If connection is using SNAP
       
  2688     // 
       
  2689     TUint32 snap = iMyServer.GetBMSnap( iConnId );
       
  2690     if( snap != 0 )
       
  2691         {
       
  2692         TMpmConnPref tempMpmConnPref;
       
  2693         tempMpmConnPref.SetIapId( 0 );
       
  2694         tempMpmConnPref.SetSnapId( snap );
       
  2695         IapSelectionL()->ChooseBestIAPL( tempMpmConnPref, availableIAPList );
       
  2696         validateIapId = tempMpmConnPref.IapId();
       
  2697         if ( ( validateIapId == 0 ) && ( aCaller == EConnMon ) )
       
  2698             {
       
  2699             // Since Connection Monitor is the only component which 
       
  2700             // is unaware of Connection Id and SNAP, it can't send 
       
  2701             // the error notification in case ChooseBestIAPL could 
       
  2702             // not find any available IAP for this SNAP. 
       
  2703             // 
       
  2704             // All the other components take responsibility of 
       
  2705             // sending the error notification. 
       
  2706             // 
       
  2707             TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  2708                                              EMPMMobilityErrorNotification ) )
       
  2709             }
       
  2710 
       
  2711         TUint32 retNetId = 0;
       
  2712         iMyServer.CommsDatAccess()->ValidateIapL( iConnId, 
       
  2713                                        validateIapId, 
       
  2714                                        retNetId, 
       
  2715                                        iapTypeLanOrWlan,
       
  2716                                        *this );
       
  2717         
       
  2718         if ( CheckNotifNeed( currentIap,
       
  2719                              iLastNotifiedIap,
       
  2720                              validateIapId ) )
       
  2721             {
       
  2722             MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \
       
  2723 Sending pref iap notification connId: 0x%x", iConnId )
       
  2724 
       
  2725             iLastNotifiedIap = validateIapId; 
       
  2726 
       
  2727             notifInfo.iIsUpgrade = IsUpgrade( oldIapId, 
       
  2728                                               validateIapId, 
       
  2729                                               availableIAPList );
       
  2730 
       
  2731             // Put real value of iIsSeamless here for NLR.
       
  2732             // 
       
  2733             notifInfo.iIsSeamless = EFalse;
       
  2734             notifInfo.iConnId = iConnId;
       
  2735 
       
  2736             MPMLOGSTRING3( "CMPMServerSession::PrefIAPNotificationL: \
       
  2737 Roaming from Iap %i to Iap %i", oldIapId, validateIapId )
       
  2738 
       
  2739             notifInfo.iNewIapId = validateIapId;
       
  2740             notifInfo.iOldIapId = oldIapId;
       
  2741                     
       
  2742             if ( aCaller != EConfirmDlgRoaming )
       
  2743                 {
       
  2744                 delete iConfirmDlgRoaming;
       
  2745                 iConfirmDlgRoaming = NULL;
       
  2746                 }
       
  2747 
       
  2748             // Write buffer to BM
       
  2749             //
       
  2750             TPtrC8 d( reinterpret_cast< TUint8* >( &notifInfo ),
       
  2751                       notifInfo.Length() );
       
  2752             iNotifMessage.WriteL( KFirstArgument, d );
       
  2753 
       
  2754             // Reset flag
       
  2755             //
       
  2756             iNotifRequested = EFalse;
       
  2757 
       
  2758             // Hold the preferred IAP already during the preferred IAP notification.
       
  2759             // In Freeway new PreferredCarrier can only be processed after the
       
  2760             // response for the previous one is received.
       
  2761             //
       
  2762             iStoredIapInfo.SetHoldPrefIapNotif();
       
  2763             
       
  2764             // Now complete WaitNotification to BM
       
  2765             //
       
  2766             MPMLOGSTRING( "CMPMServerSession::PrefIAPNotificationL - \
       
  2767 Send preferred IAP notification" )
       
  2768             iNotifMessage.Complete( KErrNone );
       
  2769             }
       
  2770         }
       
  2771         // Connection is using IAP
       
  2772         // In this case only check if the current IAP is found 
       
  2773         // in available IAP list.
       
  2774         // If it's not, then notify error.
       
  2775         // 
       
  2776     else 
       
  2777         {
       
  2778         err = availableIAPList.Find( oldIapId );
       
  2779         if( err == KErrNotFound )
       
  2780             {
       
  2781             MPMLOGSTRING2( "CMPMServerSession::PrefIAPNotificationL: \
       
  2782 SNAP 0 and IAP %d not available, notifying error", oldIapId )
       
  2783             TRAP_IGNORE( ErrorNotificationL( KErrNotFound,
       
  2784                                              EMPMMobilityErrorNotification ) )
       
  2785             }
       
  2786         }
       
  2787 
       
  2788     // Release memory
       
  2789     //
       
  2790     CleanupStack::PopAndDestroy( &availableIAPList );
       
  2791     }
       
  2792 
       
  2793 
       
  2794 // -----------------------------------------------------------------------------
       
  2795 // CMPMServerSession::StartIAPNotificationL
       
  2796 // -----------------------------------------------------------------------------
       
  2797 //
       
  2798 void CMPMServerSession::StartIAPNotificationL( const TUint32 aIapId )
       
  2799     {
       
  2800     MPMLOGSTRING3( "CMPMServerSession::StartIAPNotificationL: aConnId = 0x%x,\
       
  2801  aIapId = %i", iConnId, aIapId )
       
  2802 
       
  2803     iStoredIapInfo.SetHoldPrefIapNotif();
       
  2804     
       
  2805     if ( !iNotifRequested )
       
  2806         {
       
  2807         MPMLOGSTRING( "CMPMServerSession::StartIAPNotificationL - \
       
  2808 No notification requested" )
       
  2809         return;
       
  2810         }
       
  2811 
       
  2812     TMpmNotificationStartIAP notifInfo;
       
  2813     notifInfo.iMPMNotificationType = EMPMStartIAPNotification;
       
  2814     notifInfo.iInfo.iIap = aIapId;
       
  2815     notifInfo.iInfo.iConnId = iConnId;
       
  2816     notifInfo.iInfo.iServiceId = GetServiceIdSettingL();    
       
  2817 
       
  2818     // Write buffer to BM
       
  2819     //
       
  2820     TPtrC8 d(reinterpret_cast< TUint8* >( &notifInfo ),
       
  2821                 notifInfo.Length() );
       
  2822     iNotifMessage.WriteL( KFirstArgument, d );
       
  2823 
       
  2824     // Reset flag
       
  2825     //
       
  2826     iNotifRequested = EFalse;
       
  2827 
       
  2828     // Now complete WaitNotification to BM
       
  2829     //
       
  2830     MPMLOGSTRING( "CMPMServerSession::StartIAPNotificationL - \
       
  2831 Send start IAP notification" )
       
  2832     iNotifMessage.Complete( KErrNone );
       
  2833     }
       
  2834 
       
  2835 // -----------------------------------------------------------------------------
       
  2836 // CMPMServerSession::StopIAPNotificationL
       
  2837 // -----------------------------------------------------------------------------
       
  2838 //
       
  2839 void CMPMServerSession::StopIAPNotificationL( TInt aIapId )
       
  2840     {
       
  2841     MPMLOGSTRING2( "CMPMServerSession::StopIAPNotificationL: aConnId = 0x%x", iConnId)
       
  2842     
       
  2843     if ( !iNotifRequested )
       
  2844         {
       
  2845         MPMLOGSTRING( "CMPMServerSession::StopIAPNotificationL - \
       
  2846 No notification requested" )
       
  2847         return;
       
  2848         }
       
  2849 
       
  2850     TMpmNotificationStopIAP notifInfo;
       
  2851     notifInfo.iMPMNotificationType = EMPMStopIAPNotification;
       
  2852     notifInfo.iInfo.iConnId = iConnId;
       
  2853     notifInfo.iInfo.iIap = aIapId;
       
  2854 
       
  2855     // Write buffer to BM
       
  2856     //
       
  2857     TPtrC8 d(reinterpret_cast< TUint8* >( &notifInfo ),
       
  2858                 notifInfo.Length() );
       
  2859     iNotifMessage.WriteL( KFirstArgument, d );
       
  2860 
       
  2861     // Reset flag
       
  2862     //
       
  2863     iNotifRequested = EFalse;
       
  2864 
       
  2865     // Now complete WaitNotification to BM
       
  2866     //
       
  2867     MPMLOGSTRING( "CMPMServerSession::StopIAPNotificationL - \
       
  2868 Send stop IAP notification" )
       
  2869     iNotifMessage.Complete( KErrNone );
       
  2870     }
       
  2871 
       
  2872 // -----------------------------------------------------------------------------
       
  2873 // CMPMServerSession::ErrorMobilityNotificationL
       
  2874 // -----------------------------------------------------------------------------
       
  2875 //
       
  2876 void CMPMServerSession::MobilityErrorNotificationL( TInt aError )
       
  2877     {
       
  2878     MPMLOGSTRING2(
       
  2879         "CMPMServerSession::MobilityErrorNotificationL: aError = %i ",
       
  2880         aError )
       
  2881         
       
  2882     ErrorNotificationL( aError, EMPMMobilityErrorNotification );
       
  2883     }
       
  2884     
       
  2885 // -----------------------------------------------------------------------------
       
  2886 // CMPMServerSession::ErrorClientNotificationL
       
  2887 // -----------------------------------------------------------------------------
       
  2888 //
       
  2889 void CMPMServerSession::ClientErrorNotificationL( TInt aError )
       
  2890     {
       
  2891     MPMLOGSTRING2(
       
  2892         "CMPMServerSession::ClientErrorNotificationL: aError = %i ",
       
  2893         aError )
       
  2894         
       
  2895     ErrorNotificationL( aError, EMPMClientErrorNotification );
       
  2896     }
       
  2897 
       
  2898 // -----------------------------------------------------------------------------
       
  2899 // CMPMServerSession::ErrorNotificationL
       
  2900 // -----------------------------------------------------------------------------
       
  2901 //
       
  2902 void CMPMServerSession::ErrorNotificationL( TInt aError, 
       
  2903                                             TMpmNotifications aNotificationType )
       
  2904     {
       
  2905     MPMLOGSTRING3(
       
  2906         "CMPMServerSession::ErrorNotificationL: aError = %i, aNotificationType = %i",
       
  2907         aError, aNotificationType )
       
  2908 
       
  2909     if ( !iNotifRequested )
       
  2910         {
       
  2911         MPMLOGSTRING( "CMPMServerSession::ErrorNotificationL - \
       
  2912 No notification requested" )
       
  2913         return;
       
  2914         }
       
  2915 
       
  2916     TMpmNotificationError errorNotif;
       
  2917     
       
  2918     errorNotif.iMPMNotificationType = aNotificationType;
       
  2919     errorNotif.iError = aError;
       
  2920     errorNotif.iConnId = iConnId;
       
  2921 
       
  2922     // Write buffer to BM
       
  2923     TPtrC8 d(reinterpret_cast< TUint8* >( &errorNotif ),
       
  2924              errorNotif.Length() );
       
  2925     iNotifMessage.WriteL( KFirstArgument, d );
       
  2926 
       
  2927     // Reset flag
       
  2928     iNotifRequested = EFalse;
       
  2929 
       
  2930     // Now complete error notification to BM
       
  2931     MPMLOGSTRING("CMPMServerSession::ErrorNotificationL - Send error notification" )
       
  2932     iNotifMessage.Complete( KErrNone );
       
  2933     }
       
  2934 
       
  2935 // -----------------------------------------------------------------------------
       
  2936 // CMPMServerSession::IsPhoneOfflineL
       
  2937 // 
       
  2938 // Checks if phone is in offline mode or not.
       
  2939 // Return ETrue if phone is in offline mode.
       
  2940 // Return EFalse if phone is not in offline mode.
       
  2941 // -----------------------------------------------------------------------------
       
  2942 //
       
  2943 TBool CMPMServerSession::IsPhoneOfflineL() const
       
  2944     {
       
  2945     MPMLOGSTRING( "CMPMServerSession::IsPhoneOfflineL" )
       
  2946     if ( iOfflineFeatureSupported )
       
  2947         {
       
  2948         CRepository* repository = CRepository::NewLC(KCRUidCoreApplicationUIs);
       
  2949         TInt connAllowed = ECoreAppUIsNetworkConnectionAllowed;
       
  2950         repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
       
  2951         CleanupStack::PopAndDestroy( repository ); 
       
  2952         if ( !connAllowed )
       
  2953             {
       
  2954             MPMLOGSTRING(
       
  2955                 "CMPMServerSession::IsPhoneOfflineL Phone is in offline mode" )
       
  2956             return ETrue;
       
  2957             }
       
  2958         }
       
  2959     MPMLOGSTRING(
       
  2960         "CMPMServerSession::IsPhoneOfflineL Phone is not in offline mode" )
       
  2961     return EFalse;
       
  2962     }
       
  2963 
       
  2964 // -----------------------------------------------------------------------------
       
  2965 // CMPMServerSession::AvailableUnblacklistedIapsL
       
  2966 // -----------------------------------------------------------------------------
       
  2967 //
       
  2968 void CMPMServerSession::AvailableUnblacklistedIapsL( 
       
  2969     RAvailableIAPList&  aAvailableIAPs, 
       
  2970     const TConnectionId aConnId )
       
  2971     {
       
  2972     MPMLOGSTRING( "CMPMServerSession::AvailableUnblacklistedIapsL" )
       
  2973 
       
  2974     TConnMonIapInfo availableIAPList;
       
  2975     availableIAPList = GetAvailableIAPs();
       
  2976 
       
  2977     AvailableUnblacklistedIapsL( aAvailableIAPs, 
       
  2978                                  availableIAPList, 
       
  2979                                  aConnId );
       
  2980     }
       
  2981 
       
  2982 
       
  2983 // -----------------------------------------------------------------------------
       
  2984 // CMPMServerSession::AvailableUnblacklistedIapsL
       
  2985 // -----------------------------------------------------------------------------
       
  2986 //
       
  2987 void CMPMServerSession::AvailableUnblacklistedIapsL( 
       
  2988     RAvailableIAPList&  aAvailableIAPs, 
       
  2989     const TConnMonIapInfo&    aIapInfo, 
       
  2990     const TConnectionId aConnId )
       
  2991     {
       
  2992     RArray<TUint32> blacklistiaps;
       
  2993     CleanupClosePushL( blacklistiaps );
       
  2994     TWlanSsid       ssid;
       
  2995     TUint32         iapId( 0 );
       
  2996 
       
  2997     aAvailableIAPs.Reset();
       
  2998 
       
  2999     for (TUint i = 0; i < aIapInfo.iCount; i++)
       
  3000         {
       
  3001         aAvailableIAPs.AppendL( aIapInfo.iIap[i].iIapId );
       
  3002         }
       
  3003 
       
  3004     // Get list of blacklisted IAPs.
       
  3005     // 
       
  3006     iMyServer.GetBlacklistedIAP( aConnId, blacklistiaps );
       
  3007 
       
  3008     // If there is an active WLAN connection
       
  3009     // 
       
  3010     if ( iMyServer.Events()->ActiveWlanConnection( ssid, iapId ) )
       
  3011         {
       
  3012         RAvailableIAPList unavailableIAPs;
       
  3013         CleanupClosePushL( unavailableIAPs );
       
  3014         TRAP_IGNORE( UnavailableIAPsL( aAvailableIAPs, 
       
  3015                                    unavailableIAPs ) )
       
  3016         
       
  3017         TBool activeAvailable( ETrue );
       
  3018         if (unavailableIAPs.Find(iapId) != KErrNotFound)
       
  3019             {
       
  3020             MPMLOGSTRING( "CMPMServerSession::AvailableUnblacklistedIapsL: Active IAP unavailable" )
       
  3021             activeAvailable = EFalse;
       
  3022             }
       
  3023     
       
  3024         // If the active WLAN connection is blacklisted, then 
       
  3025         // there is no need to check if any of the unavailable 
       
  3026         // WLAN IAPs have same SSID as active WLAN connection.
       
  3027         //
       
  3028         // Same goes for unavailable active connection.
       
  3029         // 
       
  3030         if ( activeAvailable && 
       
  3031              blacklistiaps.Find( iapId ) == KErrNotFound )
       
  3032             {
       
  3033             for ( TInt i( 0 ); ( (i < unavailableIAPs.Count()) ); i++ )
       
  3034                 {
       
  3035                 // Check if any of the unavailable WLAN IAPs have 
       
  3036                 // the same SSID as the active WLAN connection.
       
  3037                 //
       
  3038                 TBool usesSame( EFalse ); 
       
  3039 
       
  3040                 if ( !iMyServer.CommsDatAccess()->CheckEasyWLanL( unavailableIAPs[i] ) )
       
  3041                     {
       
  3042                     TRAP_IGNORE( iMyServer.CommsDatAccess()->MatchSSIDL( ssid, 
       
  3043                                                               unavailableIAPs[i], 
       
  3044                                                               usesSame,
       
  3045                                                               *this ) )
       
  3046                                                               
       
  3047                     if ( usesSame )
       
  3048                         {
       
  3049                         // Append unavailable IAP to list of available IAPs
       
  3050                         // if it uses same SSID as active WLAN connection.
       
  3051                         // 
       
  3052                         MPMLOGSTRING2(
       
  3053                             "CMPMServerSession::AvailableUnblacklistedIapsL:\
       
  3054  Append unavailable IapId = %i", unavailableIAPs[i] )
       
  3055                         aAvailableIAPs.AppendL( unavailableIAPs[i] );
       
  3056                         }
       
  3057                     }
       
  3058                 }
       
  3059             }
       
  3060         CleanupStack::PopAndDestroy( &unavailableIAPs );
       
  3061         }
       
  3062 
       
  3063     TInt index( KErrNotFound );
       
  3064 
       
  3065     // Remove any blacklisted IAP.
       
  3066     // 
       
  3067     for (TInt i = 0; i < blacklistiaps.Count(); i++)
       
  3068         {
       
  3069         index = aAvailableIAPs.Find( blacklistiaps[i] );
       
  3070         if (( index != KErrNotFound ) && ( index < aAvailableIAPs.Count() ))
       
  3071             {
       
  3072             MPMLOGSTRING2( "CMPMServerSession::AvailableUnblacklistedIapsL: \
       
  3073 Remove blacklisted IapId = %i", aAvailableIAPs[index] )
       
  3074             aAvailableIAPs.Remove( index );
       
  3075             }
       
  3076         }
       
  3077     CleanupStack::PopAndDestroy( &blacklistiaps );
       
  3078     }
       
  3079 
       
  3080 
       
  3081 // -----------------------------------------------------------------------------
       
  3082 // CMPMServerSession::IsUpgrade
       
  3083 // -----------------------------------------------------------------------------
       
  3084 //
       
  3085 TBool CMPMServerSession::IsUpgrade( 
       
  3086     const TUint32               aIapId, 
       
  3087     const TUint32               aMigrateIapId,
       
  3088     const RAvailableIAPList&    aAvailableIAPs ) const
       
  3089     {
       
  3090     if ( aIapId == aMigrateIapId )
       
  3091         {
       
  3092         // If the current Iap Id and migrate Iap Id are identical, 
       
  3093         // then it is considered that this a downgrade. 
       
  3094         // 
       
  3095         MPMLOGSTRING( "CMPMServerSession::IsUpgrade - Downgrade" )
       
  3096         return EFalse;
       
  3097         }
       
  3098 
       
  3099     if ( aAvailableIAPs.Find( aIapId ) == KErrNotFound )
       
  3100         {
       
  3101         // If the registered Iap Id is not found in the list of 
       
  3102         // available IAPs, then it is considered that the new 
       
  3103         // validated IAP is a downgrade compared to previous.
       
  3104         // 
       
  3105         MPMLOGSTRING( "CMPMServerSession::IsUpgrade - Downgrade" )
       
  3106         return EFalse;
       
  3107         }
       
  3108     else
       
  3109         {
       
  3110         // If the registered Iap Id is found in the list of 
       
  3111         // available IAPs, then it is considered that the new 
       
  3112         // validated IAP is an upgrade compared to previous.
       
  3113         // 
       
  3114         MPMLOGSTRING( "CMPMServerSession::IsUpgrade - Upgrade" )
       
  3115         return ETrue;
       
  3116         }
       
  3117     }
       
  3118 
       
  3119 // -----------------------------------------------------------------------------
       
  3120 // CMPMServerSession::CheckNotifNeed
       
  3121 // -----------------------------------------------------------------------------
       
  3122 //
       
  3123 TBool CMPMServerSession::CheckNotifNeed( const TUint32       aCurrentIap,
       
  3124                                          const TUint32       aLastNotifiedIap,
       
  3125                                          const TUint32       aValidatedIap )
       
  3126     {
       
  3127     TBool retValue( EFalse );
       
  3128 
       
  3129     // Get the state of the connection for this Connection Id
       
  3130     // 
       
  3131     TConnectionState state;
       
  3132     iMyServer.GetConnectionState( iConnId, 
       
  3133                                   state );
       
  3134     // New IAP to be notified is different from last
       
  3135     if ( aValidatedIap != aLastNotifiedIap )
       
  3136         {
       
  3137         if( aCurrentIap == aValidatedIap)
       
  3138             {
       
  3139             MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: current IAP is same preferred IAP, no need to send notification" )
       
  3140             retValue = EFalse;
       
  3141             }
       
  3142         else
       
  3143             {
       
  3144             MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: notif needed" )
       
  3145             retValue = ETrue;
       
  3146             }
       
  3147        }
       
  3148     else
       
  3149         {
       
  3150         MPMLOGSTRING( "CMPMServerSession::CheckNotifNeed: Last notified IAP is same as preferred IAP, no need to send notification" )
       
  3151         }
       
  3152     return retValue;
       
  3153     }
       
  3154 
       
  3155 // -----------------------------------------------------------------------------
       
  3156 // CMPMServerSession::UnavailableIAPsL
       
  3157 // -----------------------------------------------------------------------------
       
  3158 //
       
  3159 void CMPMServerSession::UnavailableIAPsL( 
       
  3160     const RAvailableIAPList aAvailableIAPs, 
       
  3161     RAvailableIAPList&      aUnavailableIAPs )
       
  3162     {
       
  3163     TInt err( KErrNone );
       
  3164 
       
  3165     CCommsDatabase* commsDatabase = CCommsDatabase::NewL();
       
  3166     CleanupStack::PushL(commsDatabase);
       
  3167 
       
  3168     // Make hidden records visible
       
  3169     // 
       
  3170     commsDatabase->ShowHiddenRecords();
       
  3171 
       
  3172     // Iterate the IAP table from CommsDat
       
  3173     CCommsDbTableView* table = NULL;
       
  3174     table = commsDatabase->OpenTableLC( TPtrC( IAP ) );
       
  3175 
       
  3176     err = table->GotoFirstRecord();
       
  3177 
       
  3178     while ( !err )
       
  3179         {
       
  3180         TUint32 iapId( 0 );
       
  3181 
       
  3182         // Read IAP's ID
       
  3183         //
       
  3184         table->ReadUintL( TPtrC( COMMDB_ID ), iapId );
       
  3185         
       
  3186         if ( aAvailableIAPs.Find( iapId ) == KErrNotFound )
       
  3187             {
       
  3188             aUnavailableIAPs.AppendL( iapId );
       
  3189             }
       
  3190 
       
  3191         err = table->GotoNextRecord();
       
  3192         }
       
  3193 
       
  3194     // Release memory
       
  3195     //
       
  3196     CleanupStack::PopAndDestroy( table );
       
  3197     CleanupStack::PopAndDestroy( commsDatabase );
       
  3198     }
       
  3199 
       
  3200 // -----------------------------------------------------------------------------
       
  3201 // CMPMServerSession::RemoveUnavailableIap
       
  3202 // -----------------------------------------------------------------------------
       
  3203 //
       
  3204 void CMPMServerSession::RemoveUnavailableIap( TConnMonIapInfo& aIapInfo, 
       
  3205                                               const TUint32    aIapId )
       
  3206     {
       
  3207     TConnMonIapInfo iapInfo = aIapInfo;
       
  3208     TBool found( EFalse );
       
  3209 
       
  3210     for ( TUint i( 0 );( ( i < iapInfo.Count() ) && !found ); i++ )
       
  3211         {
       
  3212         if ( iapInfo.iIap[i].iIapId == aIapId )
       
  3213             {
       
  3214             found = ETrue;
       
  3215 
       
  3216             MPMLOGSTRING2( "CMPMServerSession::RemoveUnavailableIap - IAP: %d", 
       
  3217                 iapInfo.iIap[i].iIapId ) 
       
  3218             
       
  3219             // Since iapInfo.Remove( i ) is not supported
       
  3220             // 
       
  3221             TUint k( 0 );
       
  3222             for ( k = i; ( ( k + 1 ) < iapInfo.Count() ); k++ )
       
  3223                 {
       
  3224                 iapInfo.iIap[k] = iapInfo.iIap[k+1];
       
  3225                 }
       
  3226             iapInfo.iIap[k].iIapId = 0;
       
  3227             iapInfo.iCount--;
       
  3228             }
       
  3229         }
       
  3230 
       
  3231     aIapInfo = iapInfo;
       
  3232     }
       
  3233 
       
  3234 
       
  3235 // -----------------------------------------------------------------------------
       
  3236 // CMPMServerSession::IsBackgroundApplication
       
  3237 // -----------------------------------------------------------------------------
       
  3238 //
       
  3239 TBool CMPMServerSession::IsBackgroundApplication( TUint32 aUid ) const
       
  3240     {
       
  3241     if( aUid == KUidSimApplicationToolkit || 
       
  3242         aUid == KUidDVBH ||
       
  3243         aUid == KUidAlwaysOnlineStarter)
       
  3244         {
       
  3245         return ETrue;
       
  3246         }
       
  3247     else
       
  3248         {
       
  3249         return EFalse;
       
  3250         }
       
  3251     }
       
  3252 
       
  3253 // -----------------------------------------------------------------------------
       
  3254 // CMPMServerSession::ChooseIapComplete
       
  3255 // -----------------------------------------------------------------------------
       
  3256 //
       
  3257 void CMPMServerSession::ChooseIapComplete( 
       
  3258     TInt                aError,
       
  3259     const TMpmConnPref* aPolicyPref )
       
  3260     {
       
  3261     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete aError = %d", aError )
       
  3262 
       
  3263     // Show error popup if it's allowed per client request
       
  3264     if ( !( iIapSelection->MpmConnPref().NoteBehaviour() &
       
  3265             TExtendedConnPref::ENoteBehaviourConnDisableNotes )
       
  3266             && ( aError != KErrNone ) )
       
  3267         {
       
  3268         CConnectionUiUtilities* connUiUtils = CConnectionUiUtilities::NewL();
       
  3269         // Note: Below function shows the discreet popup only if the error code
       
  3270         // belongs to the set of errors that are shown to the user.
       
  3271         // Otherwise the popup is not shown.
       
  3272         connUiUtils->ConnectionErrorDiscreetPopup( aError );
       
  3273         delete connUiUtils;
       
  3274         connUiUtils = NULL;
       
  3275         }
       
  3276     
       
  3277     // Try to write back arguments and complete message.
       
  3278     // 
       
  3279     if ( !iChooseIapMessage.IsNull() )
       
  3280         {
       
  3281         if ( aError == KErrNone && aPolicyPref )
       
  3282             {
       
  3283             MPMLOGSTRING4( "CMPMServerSession::ChooseIapComplete \
       
  3284 IAP Id = %d, SNAP Id = %d, Net Id = %d",
       
  3285                 aPolicyPref->IapId(),
       
  3286                 aPolicyPref->SnapId(),
       
  3287                 aPolicyPref->NetId() )
       
  3288 
       
  3289             TPolicyConnPref pref;
       
  3290             pref.SetIapId( aPolicyPref->IapId() );
       
  3291             pref.SetNetId( aPolicyPref->NetId() );
       
  3292             TInt serviceid(0);
       
  3293             
       
  3294             // Resolve the original serviceid for the application.
       
  3295             //
       
  3296             TRAPD( err, serviceid = GetServiceIdSettingL() )
       
  3297             if ( err != KErrNone )
       
  3298                 {
       
  3299                 MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete GetServiceIdSettingL Leaved %d", err )
       
  3300                 pref.SetServiceId( 0 );
       
  3301                 }
       
  3302             else
       
  3303                 {
       
  3304                 pref.SetServiceId( serviceid );
       
  3305                 }
       
  3306             MPMLOGSTRING4( "CMPMServerSession::ChooseIapComplete writing policy pref \
       
  3307 iap %d net id %d service id %d", pref.IapId(), pref.NetId(), pref.ServiceId() )
       
  3308             switch ( iChooseIapMessage.Function() )
       
  3309                 {
       
  3310                 case EMPMServerChooseIap:
       
  3311                     {
       
  3312                     TRAP( aError, iChooseIapMessage.WriteL( KFourthArgument, pref ) )
       
  3313                     break;
       
  3314                     }
       
  3315                 case EMPMServerReselectIap:
       
  3316                     {
       
  3317                     TRAP( aError, iChooseIapMessage.WriteL( KSecondArgument, pref ) )
       
  3318                     break;
       
  3319                     }
       
  3320                 default:
       
  3321                     {
       
  3322                     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete - Error \
       
  3323 Inconsistent state %d", KErrGeneral )
       
  3324                     aError = KErrGeneral;
       
  3325                     }
       
  3326                 }
       
  3327             }
       
  3328         MPMLOGSTRING( "CMPMServerSession::ChooseIapComplete Message completed" )
       
  3329         iChooseIapMessage.Complete( aError );
       
  3330         }
       
  3331     }
       
  3332 
       
  3333 
       
  3334 // -----------------------------------------------------------------------------
       
  3335 // CMPMServerSession::ProcessErrorComplete
       
  3336 // -----------------------------------------------------------------------------
       
  3337 //
       
  3338 void CMPMServerSession::ProcessErrorComplete( TInt             aError, 
       
  3339                                               TInt*            aErrorReturned,
       
  3340                                               TBMNeededAction* aNeededAction )
       
  3341     {
       
  3342     MPMLOGSTRING2( "CMPMServerSession::ProcessErrorComplete aError = %d", aError )
       
  3343 
       
  3344     delete iDisconnectDlg;
       
  3345     iDisconnectDlg = NULL;
       
  3346     
       
  3347     if ( !iProcessErrorMessage.IsNull() )
       
  3348         {
       
  3349         // Try to write back arguments and complete message.
       
  3350         // Traps are not necesary here. If WriteL functions leave the
       
  3351         // message is still completed in ServiceError
       
  3352         //
       
  3353         if( aErrorReturned )
       
  3354             {
       
  3355             MPMLOGSTRING2( "CMPMServerSession::ProcessErrorComplete returned error = %d", 
       
  3356                            *aErrorReturned )
       
  3357 
       
  3358             TPtrC8 d( reinterpret_cast< TUint8* >( aErrorReturned ), 
       
  3359                                                    sizeof( aErrorReturned ) );
       
  3360             TRAP_IGNORE( iProcessErrorMessage.WriteL( KFirstArgument, d ) )
       
  3361                         }
       
  3362         if( aNeededAction )
       
  3363             {
       
  3364             MPMLOGSTRING2( "CMPMServerSession::ProcessErrorComplete needed action = %d", 
       
  3365                            *aNeededAction )
       
  3366             TPtrC8 c( reinterpret_cast< TUint8* >( aNeededAction ), 
       
  3367                                                    sizeof( aNeededAction ) );
       
  3368             TRAP_IGNORE( iProcessErrorMessage.WriteL( KThirdArgument, c ) )
       
  3369             }
       
  3370         MPMLOGSTRING( "CMPMServerSession::ProcessErrorComplete completing message" )
       
  3371         iProcessErrorMessage.Complete( aError );    
       
  3372         }
       
  3373     }
       
  3374 
       
  3375 // -----------------------------------------------------------------------------
       
  3376 // CMPMServerSession::DisconnectDlgErrorCode
       
  3377 // -----------------------------------------------------------------------------
       
  3378 //
       
  3379 TBool CMPMServerSession::DisconnectDlgErrorCode( TInt aError ) const
       
  3380     {
       
  3381     if ( aError == KErrGprsInsufficientResources               || // -4154
       
  3382          aError == KErrPacketDataTsyMaxPdpContextsReached      || // -6000
       
  3383          aError == KErrUmtsMaxNumOfContextExceededByNetwork    || // -4179
       
  3384          aError == KErrUmtsMaxNumOfContextExceededByPhone )       // -4178
       
  3385         {
       
  3386         MPMLOGSTRING2( "CMPMServerSession::DisconnectDlgErrorCode - \
       
  3387 Error %d, is disconnect dlg error code", aError )
       
  3388         return ETrue;
       
  3389         }
       
  3390     else
       
  3391         {
       
  3392         MPMLOGSTRING2( "CMPMServerSession::DisconnectDlgErrorCode - \
       
  3393 Error %d, is not disconnect dlg error code", aError )
       
  3394         return EFalse;
       
  3395         }
       
  3396     }
       
  3397 
       
  3398 // -----------------------------------------------------------------------------
       
  3399 // CMPMServerSession::GetPresumedIap
       
  3400 // -----------------------------------------------------------------------------
       
  3401 //
       
  3402 TUint32 CMPMServerSession::GetPresumedIap()
       
  3403     {
       
  3404     TUint32 presumedIap( 0 ), realIap = iMyServer.GetBMIap( iConnId );
       
  3405     if( realIap != 0 )
       
  3406         {
       
  3407         presumedIap = iMyServer.Events()->PresumedIapId( iConnId, realIap );
       
  3408         }
       
  3409     MPMLOGSTRING3( "CMPMServerSession::GetPresumedIap - \
       
  3410 Real IAP %d, presumed Iap %d", realIap, presumedIap )
       
  3411     return presumedIap;
       
  3412     }
       
  3413     
       
  3414 // -----------------------------------------------------------------------------
       
  3415 // CMPMServerSession::MigrateDoneL
       
  3416 // -----------------------------------------------------------------------------
       
  3417 //
       
  3418 void CMPMServerSession::MigrateDoneL( TInt aError )
       
  3419     {
       
  3420     MPMLOGSTRING3( "CMPMServerSession<0x%x>::MigrateCompleteL: error %d",
       
  3421 	               iConnId,
       
  3422 	               aError )
       
  3423 
       
  3424     if( aError == KErrNone )
       
  3425         {
       
  3426         // Send a notification to BearerMan 
       
  3427         // to start the Iap
       
  3428         //
       
  3429         TRAP_IGNORE( StartIAPNotificationL( iMigrateIap ) )        
       
  3430         }
       
  3431     iMigrateState = EMigrateNone;
       
  3432     iMigrateIap = 0;
       
  3433     }
       
  3434 
       
  3435 // -----------------------------------------------------------------------------
       
  3436 // CMPMServerSession::UseUserConnPref
       
  3437 // -----------------------------------------------------------------------------
       
  3438 //
       
  3439 TBool CMPMServerSession::UseUserConnPref()
       
  3440     {
       
  3441     if ((iAppUid != iMyServer.CsIdWatcher()->ConnectScreenId()) &&
       
  3442         iMyServer.UserConnection())
       
  3443         {
       
  3444         MPMLOGSTRING( "CMPMServerSession::UseUserConnPref - User connection active" );
       
  3445         
       
  3446         // Check whether default connection will be used
       
  3447         if ( iIapSelection->MpmConnPref().ConnType() == TMpmConnPref::EConnTypeDefault )
       
  3448             {
       
  3449             return ETrue;
       
  3450             }
       
  3451         else if ( ( iIapSelection->MpmConnPref().ConnType() ==
       
  3452                     TMpmConnPref::EConnTypeImplicit ) &&
       
  3453                   PrefsAllowWlan() )
       
  3454             {            
       
  3455             MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
       
  3456  Prompt from the user" );
       
  3457             // Prompt from the user -> use user connection
       
  3458             return ETrue;
       
  3459             }
       
  3460         else
       
  3461             {
       
  3462             MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
       
  3463  Application preferencies" );
       
  3464             TBool isInternetSnap = EFalse;
       
  3465             TInt error = KErrNone;
       
  3466     
       
  3467             // Check whether iap belongs to internet snap
       
  3468             TRAP( error, isInternetSnap =
       
  3469                              iMyServer.CommsDatAccess()->IsInternetSnapL(
       
  3470                                      iIapSelection->MpmConnPref().IapId(),
       
  3471                                      iIapSelection->MpmConnPref().SnapId() ) );
       
  3472 
       
  3473             if ( ( error == KErrNone ) && ( isInternetSnap ) && PrefsAllowWlan() )
       
  3474                 {
       
  3475                 // Iap belongs to internet snap -> use user connection
       
  3476                 return ETrue;
       
  3477                 }
       
  3478             }
       
  3479         }
       
  3480     
       
  3481     return EFalse;
       
  3482     }
       
  3483 
       
  3484 // -----------------------------------------------------------------------------
       
  3485 // CMPMServerSession::IsWlanOnlyL
       
  3486 // -----------------------------------------------------------------------------
       
  3487 //
       
  3488 TBool CMPMServerSession::IsWlanOnlyL( TBool& aNewWlansAllowed )
       
  3489     {
       
  3490     TCmGenConnSettings  genConnSettings;
       
  3491 
       
  3492     MPMLOGSTRING( "CMPMServerSession::IsWlanOnlyL")
       
  3493 
       
  3494     // Read global OCC seamlessness values from CommsDat's DefConn table
       
  3495     genConnSettings = iMyServer.CommsDatAccess()->ReadGenConnSettingsL();
       
  3496 
       
  3497     // Find out if new wlans can be prompted
       
  3498     if ( genConnSettings.iUsageOfWlan == ECmUsageOfWlanKnownAndNew )
       
  3499         {
       
  3500         aNewWlansAllowed = ETrue;
       
  3501         MPMLOGSTRING( "CMPMServerSession::IsWlanOnlyL: aNewWlansAllowed: True" )
       
  3502         }
       
  3503     else
       
  3504         {
       
  3505         aNewWlansAllowed = EFalse;
       
  3506         MPMLOGSTRING( "CMPMServerSession::IsWlanOnlyL: aNewWlansAllowed: False" )
       
  3507         }
       
  3508         
       
  3509     // Find out is only WLAN connection is allowed in current network
       
  3510     TUint32 currentSeamlessness( genConnSettings.iSeamlessnessHome );
       
  3511     
       
  3512     if ( iMyServer.IsVisitorNetwork() )
       
  3513         {
       
  3514         currentSeamlessness = genConnSettings.iSeamlessnessVisitor;  
       
  3515         }
       
  3516     
       
  3517     if ( currentSeamlessness == ECmSeamlessnessDisabled )
       
  3518         {
       
  3519         MPMLOGSTRING( "CMPMServerSession::IsWlanOnlyL: True" )
       
  3520         return ETrue;
       
  3521         }
       
  3522     else 
       
  3523         {
       
  3524         MPMLOGSTRING( "CMPMServerSession::IsWlanOnlyL: False" )
       
  3525         return EFalse;
       
  3526         }
       
  3527     }
       
  3528 
       
  3529 // -----------------------------------------------------------------------------
       
  3530 // CMPMServerSession::ForcedRoaming()
       
  3531 // -----------------------------------------------------------------------------
       
  3532 //
       
  3533 TBool CMPMServerSession::ForcedRoaming()
       
  3534     {
       
  3535     TBool forcedRoaming( EFalse );
       
  3536     if ( iIapSelection != NULL )
       
  3537         {
       
  3538         forcedRoaming = iIapSelection->MpmConnPref().ForcedRoaming();
       
  3539         }
       
  3540     return forcedRoaming;
       
  3541     }
       
  3542 
       
  3543 // -----------------------------------------------------------------------------
       
  3544 // CMPMServerSession::RemoveIapsAccordingToBearerSetL()
       
  3545 // -----------------------------------------------------------------------------
       
  3546 //
       
  3547 void CMPMServerSession::RemoveIapsAccordingToBearerSetL( TConnMonIapInfo& aIapInfo )
       
  3548     {
       
  3549     if (!iIapSelection)
       
  3550         {
       
  3551         // Iap selection hasn't done for this session -> just return
       
  3552         return;
       
  3553         }
       
  3554     
       
  3555     // Drop iaps not according to bearer set
       
  3556     if ( iIapSelection->MpmConnPref().BearerSet() != 
       
  3557          TExtendedConnPref::EExtendedConnBearerUnknown )
       
  3558         {
       
  3559         TInt index = 0;
       
  3560         
       
  3561         while ( index != aIapInfo.iCount )
       
  3562             {
       
  3563             // Get bearer type
       
  3564             TMPMBearerType bearerType = EMPMBearerTypeOther;
       
  3565             bearerType =
       
  3566                 iMyServer.CommsDatAccess()->GetBearerTypeL ( aIapInfo.iIap[index].iIapId );
       
  3567             
       
  3568             if ( (( bearerType == EMPMBearerTypePacketData ) &&
       
  3569                   ( iIapSelection->MpmConnPref().BearerSet() & 
       
  3570                     TExtendedConnPref::EExtendedConnBearerCellular )) )
       
  3571                 {
       
  3572                 // Don't remove this iap
       
  3573                 index++;
       
  3574                 continue;
       
  3575                 }
       
  3576             else if ( (( bearerType == EMPMBearerTypeWlan ) &&
       
  3577                   ( iIapSelection->MpmConnPref().BearerSet() & 
       
  3578                     TExtendedConnPref::EExtendedConnBearerWLAN )) )
       
  3579                 {
       
  3580                 // Don't remove this iap
       
  3581                 index++;
       
  3582                 continue;
       
  3583                 }
       
  3584             else
       
  3585                 {
       
  3586                 // Remove this iap from the list
       
  3587                 for ( TInt index2 = index; index2 < aIapInfo.iCount; index2++ )
       
  3588                     {
       
  3589                     aIapInfo.iIap[index2].iIapId = aIapInfo.iIap[index2 + 1].iIapId;
       
  3590                     }
       
  3591                 
       
  3592                 aIapInfo.iCount--;
       
  3593                 }
       
  3594             }
       
  3595         }
       
  3596     }
       
  3597 
       
  3598 // -----------------------------------------------------------------------------
       
  3599 // CMPMServerSession::GetAvailableIAPs()
       
  3600 // -----------------------------------------------------------------------------
       
  3601 //
       
  3602 TConnMonIapInfo CMPMServerSession::GetAvailableIAPs()
       
  3603     {
       
  3604     TConnMonIapInfo availableIAPs;
       
  3605     
       
  3606     availableIAPs = MyServer().Events()->GetAvailableIAPs();
       
  3607     
       
  3608     // Remove iaps not according to bearer set
       
  3609     TRAP_IGNORE ( RemoveIapsAccordingToBearerSetL ( availableIAPs ) );
       
  3610     
       
  3611     return availableIAPs;
       
  3612     }
       
  3613     
       
  3614 // -----------------------------------------------------------------------------
       
  3615 // CMPMServerSession::IsBearerAccepted()
       
  3616 // -----------------------------------------------------------------------------
       
  3617 //
       
  3618 TBool CMPMServerSession::IsBearerAccepted( TMPMBearerType aBearerType )
       
  3619     {
       
  3620     TBool returnValue = EFalse;
       
  3621     
       
  3622     if ( !iIapSelection ||
       
  3623         ( iIapSelection->MpmConnPref().BearerSet() == 
       
  3624         TExtendedConnPref::EExtendedConnBearerUnknown ) )
       
  3625         {
       
  3626         // Iap selection hasn't been done for this session or all bearers
       
  3627         // are accepted -> just return true
       
  3628         returnValue = ETrue;
       
  3629         }
       
  3630     else
       
  3631         {
       
  3632         switch ( aBearerType )
       
  3633             {
       
  3634             case EMPMBearerTypeWlan:
       
  3635                 if ( iIapSelection->MpmConnPref().BearerSet() & 
       
  3636                     TExtendedConnPref::EExtendedConnBearerWLAN )
       
  3637                     {
       
  3638                     returnValue = ETrue;
       
  3639                     }
       
  3640                 break;
       
  3641                 
       
  3642             case EMPMBearerTypePacketData:
       
  3643                 if ( iIapSelection->MpmConnPref().BearerSet() & 
       
  3644                     TExtendedConnPref::EExtendedConnBearerCellular )
       
  3645                     {
       
  3646                     returnValue = ETrue;
       
  3647                     }
       
  3648                 break;
       
  3649                 
       
  3650             default:
       
  3651                 break;
       
  3652             }
       
  3653         }
       
  3654     
       
  3655     return returnValue;
       
  3656     }
       
  3657 
       
  3658 // -----------------------------------------------------------------------------
       
  3659 // CMPMServerSession::IsMMSIap()
       
  3660 // -----------------------------------------------------------------------------
       
  3661 //
       
  3662 TBool CMPMServerSession::IsMMSIap( TUint32 aIap )
       
  3663     {
       
  3664     // Check if IAP is reported by MMS
       
  3665     //
       
  3666     TBool isMMSIap = EFalse;
       
  3667     if( aIap != 0 )
       
  3668         {
       
  3669         // get property if it's defined 
       
  3670         TInt err( KErrNone );
       
  3671         TInt mmsIap( 0 );
       
  3672         err = RProperty::Get( KMPMCathegory, KMPMPropertyKeyMMS, mmsIap);    
       
  3673                             
       
  3674         // If successful compare IAPs
       
  3675         if( err == KErrNone ) 
       
  3676             {
       
  3677             if( aIap == mmsIap )
       
  3678                 {
       
  3679                 isMMSIap = ETrue;
       
  3680                 }
       
  3681             }
       
  3682         } 
       
  3683     MPMLOGSTRING2( "CMPMServerSession::IsMmsIap: Returning bool value: %d",
       
  3684                    isMMSIap )
       
  3685     return isMMSIap;
       
  3686     }
       
  3687 
       
  3688 // -----------------------------------------------------------------------------
       
  3689 // CMPMServerSession::PrefsAllowWlan
       
  3690 // -----------------------------------------------------------------------------
       
  3691 //
       
  3692 TBool CMPMServerSession::PrefsAllowWlan()
       
  3693     {
       
  3694     // WLAN connection can be used if application has not specified any bearerset
       
  3695     // or when bearerset has WLAN enabled.
       
  3696     //
       
  3697     if ( ( iIapSelection->MpmConnPref().BearerSet() == 
       
  3698            TExtendedConnPref::EExtendedConnBearerUnknown ) 
       
  3699          ||
       
  3700          ( iIapSelection->MpmConnPref().BearerSet() &
       
  3701            TExtendedConnPref::EExtendedConnBearerWLAN ) )
       
  3702         {
       
  3703         return ETrue;
       
  3704         }
       
  3705     else
       
  3706         {
       
  3707         return EFalse;
       
  3708         }
       
  3709     }
       
  3710         
       
  3711 // -----------------------------------------------------------------------------
       
  3712 // TNetIap::TNetIap
       
  3713 // -----------------------------------------------------------------------------
       
  3714 //
       
  3715 TNetIap::TNetIap() 
       
  3716     : iSnap( 0 ),
       
  3717       iEmbeddedSnap( 0 ),
       
  3718       iIapId( 0 ),
       
  3719       iRanking( 0 ),
       
  3720       iGlobalPriority( 0 )
       
  3721     {
       
  3722     }
       
  3723 
       
  3724 
       
  3725 // -----------------------------------------------------------------------------
       
  3726 // TNetIap::CompareRanking
       
  3727 // -----------------------------------------------------------------------------
       
  3728 //
       
  3729 TInt TNetIap::CompareRanking( const TNetIap& aFirst,
       
  3730                               const TNetIap& aSecond )
       
  3731     {
       
  3732     if ( aFirst.iRanking < aSecond.iRanking )
       
  3733         {
       
  3734         return KSmaller;
       
  3735         }
       
  3736     else if ( aFirst.iRanking > aSecond.iRanking )
       
  3737         {
       
  3738         return KBigger;
       
  3739         }
       
  3740     else
       
  3741         {
       
  3742         return KEqual;
       
  3743         }
       
  3744     }
       
  3745     
       
  3746 // -----------------------------------------------------------------------------
       
  3747 // TNetIap::CompareGlobalAndLocalPriority
       
  3748 // -----------------------------------------------------------------------------
       
  3749 //
       
  3750 TInt TNetIap::CompareGlobalAndLocalPriority( const TNetIap& aFirst,
       
  3751                                              const TNetIap& aSecond )
       
  3752     {
       
  3753     if ( aFirst.iGlobalPriority < aSecond.iGlobalPriority )
       
  3754         {
       
  3755         return KSmaller;
       
  3756         }
       
  3757     else if ( aFirst.iGlobalPriority > aSecond.iGlobalPriority )
       
  3758         {
       
  3759         return KBigger;
       
  3760         }
       
  3761     else
       
  3762         {
       
  3763         // If global priorities are equal,
       
  3764         // order based on ranking
       
  3765         // 
       
  3766         return TNetIap::CompareRanking( aFirst, aSecond );
       
  3767         }
       
  3768     }    
       
  3769 // -----------------------------------------------------------------------------
       
  3770 // TStoredIapInfo::TStoredIapInfo
       
  3771 // -----------------------------------------------------------------------------
       
  3772 //
       
  3773 TStoredIapInfo::TStoredIapInfo()
       
  3774     : iHoldPrefIapNotif( EFalse ),
       
  3775       iIapInfoWaiting( EFalse ),
       
  3776       iStoredIapInfo()
       
  3777     {
       
  3778     }
       
  3779     
       
  3780 // -----------------------------------------------------------------------------
       
  3781 // TStoredIapInfo::HoldPrefIapNotif
       
  3782 // -----------------------------------------------------------------------------
       
  3783 //      
       
  3784 TBool TStoredIapInfo::HoldPrefIapNotif() const
       
  3785     {
       
  3786     MPMLOGSTRING2( "TStoredIapInfo::HoldPrefIapNotif value %d", iHoldPrefIapNotif )
       
  3787     return iHoldPrefIapNotif;
       
  3788     }
       
  3789 
       
  3790 // -----------------------------------------------------------------------------
       
  3791 // TStoredIapInfo::SetHoldPrefIapNotif
       
  3792 // -----------------------------------------------------------------------------
       
  3793 //
       
  3794 void TStoredIapInfo::SetHoldPrefIapNotif()
       
  3795     {
       
  3796     MPMLOGSTRING( "TStoredIapInfo::SetHoldPrefIapNotif" )
       
  3797     iHoldPrefIapNotif = ETrue;
       
  3798     }
       
  3799 
       
  3800 // -----------------------------------------------------------------------------
       
  3801 // TStoredIapInfo::HandleIapInfoWaiting
       
  3802 // -----------------------------------------------------------------------------
       
  3803 //
       
  3804 TBool TStoredIapInfo::HandleIapInfoWaiting( TConnMonIapInfo& aStoredIapInfo )
       
  3805     {
       
  3806     if( iIapInfoWaiting )
       
  3807         {
       
  3808         iHoldPrefIapNotif = EFalse;
       
  3809         aStoredIapInfo = iStoredIapInfo; 
       
  3810         }
       
  3811     MPMLOGSTRING2( "TStoredIapInfo::HandleIapInfoWaiting value %d", iIapInfoWaiting )
       
  3812     return iIapInfoWaiting;
       
  3813     }
       
  3814 
       
  3815 // -----------------------------------------------------------------------------
       
  3816 // TStoredIapInfo::SetStoredIapInfo
       
  3817 // -----------------------------------------------------------------------------
       
  3818 //
       
  3819 void TStoredIapInfo::SetStoredIapInfo( const TConnMonIapInfo& aStoredIapInfo )
       
  3820     {
       
  3821     MPMLOGSTRING( "TStoredIapInfo::SetStoredIapInfo" )
       
  3822     iIapInfoWaiting = ETrue;
       
  3823     iStoredIapInfo = aStoredIapInfo;
       
  3824     }
       
  3825 
       
  3826 // -----------------------------------------------------------------------------
       
  3827 // TStoredIapInfo::ResetStoredIapInfo
       
  3828 // -----------------------------------------------------------------------------
       
  3829 //
       
  3830 void TStoredIapInfo::ResetStoredIapInfo()
       
  3831     {
       
  3832     MPMLOGSTRING( "TStoredIapInfo::ResetStoredIapInfo" )
       
  3833     iHoldPrefIapNotif = EFalse;
       
  3834     iIapInfoWaiting = EFalse;
       
  3835     }
       
  3836 
       
  3837 
       
  3838 //  End of File