bearermanagement/mpm/src/mpmiapselection.cpp
branchRCL_3
changeset 24 05bc53fe583b
parent 23 fc7b30ed2058
child 25 83ca720e2b9a
equal deleted inserted replaced
23:fc7b30ed2058 24:05bc53fe583b
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "mpmiapselection.h"
    18 #include "mpmiapselection.h"
    19 #include "mpmlogger.h"
    19 #include "mpmlogger.h"
    20 #include "mpmdialog.h"
       
    21 #include "mpmserversession.h"
    20 #include "mpmserversession.h"
    22 #include "mpmcommsdataccess.h"
    21 #include "mpmcommsdataccess.h"
    23 #include "mpmconnmonevents.h"
    22 #include "mpmconnmonevents.h"
    24 #include "mpmconfirmdlgstarting.h"
    23 #include "mpmconfirmdlgstarting.h"
    25 #include "mpmdefaultconnection.h"
       
    26 #include "mpmwlanquerydialog.h"
       
    27 #include "extendedconnpref.h"
    24 #include "extendedconnpref.h"
    28 
    25 
    29 // ---------------------------------------------------------------------------
    26 // ---------------------------------------------------------------------------
    30 // CMPMIapSelection::CMPMIapSelection
    27 // CMPMIapSelection::CMPMIapSelection
    31 // ---------------------------------------------------------------------------
    28 // ---------------------------------------------------------------------------
    32 //
    29 //
    33 CMPMIapSelection::CMPMIapSelection( CMPMCommsDatAccess*  aCommsDatAccess,
    30 CMPMIapSelection::CMPMIapSelection( CMPMCommsDatAccess*  aCommsDatAccess,
    34                                     CMPMServerSession*   aSession )
    31                                     CMPMServerSession*   aSession,
       
    32                                     CConnectionUiUtilities* aConnUiUtils )
    35     : iChooseIapState( ENoConnection ),
    33     : iChooseIapState( ENoConnection ),
    36       iCommsDatAccess( aCommsDatAccess ),
    34       iCommsDatAccess( aCommsDatAccess ),
       
    35       iConnUiUtils( aConnUiUtils ),
    37       iStoredIapInfo(),
    36       iStoredIapInfo(),
    38       iSession( aSession ),
    37       iSession( aSession ),
    39       iConfirmDlgStarting( NULL ),
    38       iConfirmDlgStarting( NULL ),
    40       iDialog( NULL ),
       
    41       iWlanDialog( NULL ),
       
    42       iNextBestExists( EFalse ),
    39       iNextBestExists( EFalse ),
    43       iUserSelectionIapId( 0 ),
    40       iUserSelectionIapId( 0 ),
    44       iUserSelectionSnapId( 0 ),
    41       iUserSelectionSnapId( 0 ),
    45       iImplicitState( EImplicitStart ),
    42       iImplicitState( EImplicitStart ),
    46       iIsRoaming( EFalse ),
    43       iIsRoaming( EFalse ),
    60 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
    61 // CMPMIapSelection::NewL
    58 // CMPMIapSelection::NewL
    62 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    63 //
    60 //
    64 CMPMIapSelection* CMPMIapSelection::NewL( CMPMCommsDatAccess*  aCommsDatAccess,
    61 CMPMIapSelection* CMPMIapSelection::NewL( CMPMCommsDatAccess*  aCommsDatAccess,
    65                                           CMPMServerSession*   aSession )
    62                                           CMPMServerSession*   aSession,
       
    63                                           CConnectionUiUtilities* aConnUiUtils )
    66     {
    64     {
    67     CMPMIapSelection* self = new ( ELeave ) CMPMIapSelection( aCommsDatAccess,
    65     CMPMIapSelection* self = new ( ELeave ) CMPMIapSelection( aCommsDatAccess,
    68                                                               aSession );
    66                                                               aSession,
       
    67                                                               aConnUiUtils );
    69     CleanupStack::PushL( self );
    68     CleanupStack::PushL( self );
    70     self->ConstructL();
    69     self->ConstructL();
    71     CleanupStack::Pop( self );
    70     CleanupStack::Pop( self );
    72     return self;
    71     return self;
    73     }
    72     }
    82     // stop confirm dialog in case one exists
    81     // stop confirm dialog in case one exists
    83     //
    82     //
    84     StopDisplayingStartingDlg();
    83     StopDisplayingStartingDlg();
    85     
    84     
    86     delete iConfirmDlgStarting;
    85     delete iConfirmDlgStarting;
    87     delete iDialog;
       
    88     delete iWlanDialog;
       
    89     }
    86     }
    90 
    87 
    91 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
    92 // CMPMIapSelection::ChooseIapL
    89 // CMPMIapSelection::ChooseIapL
    93 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
   164             {            
   161             {            
   165             ChooseIapComplete( KErrPermissionDenied, NULL );
   162             ChooseIapComplete( KErrPermissionDenied, NULL );
   166             return;
   163             return;
   167             }
   164             }
   168         }
   165         }
   169     
   166         
       
   167            
   170     if  ( iChooseIapPref.ConnSelectionDialog() )
   168     if  ( iChooseIapPref.ConnSelectionDialog() )
   171         {
   169         {
   172         // Complete selection with error code if wlan only was set and bearer set as cellular 
   170         // Complete selection with error code if wlan only was set and bearer set as cellular 
   173         if ( wlanOnly && 
   171         if ( wlanOnly && 
   174              iChooseIapPref.BearerSet() == TExtendedConnPref::EExtendedConnBearerCellular ) 
   172              iChooseIapPref.BearerSet() == TExtendedConnPref::EExtendedConnBearerCellular ) 
   184     if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeDefault )
   182     if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeDefault )
   185         {
   183         {
   186         // Default connection is requested.
   184         // Default connection is requested.
   187 
   185 
   188         MPMLOGSTRING( "CMPMIapSelection::ChooseIapL:\
   186         MPMLOGSTRING( "CMPMIapSelection::ChooseIapL:\
   189  Default Connection" )
   187             Default Connection" )
   190 
   188 
   191         if ( iSession->UseUserConnPref() )
   189         if ( iSession->UseUserConnPref() )
   192             {
   190             {
   193             // User connection active -> use it
   191             // User connection active -> use it
   194             // Add info into the BM connections
   192             // Add info into the BM connections
   200 
   198 
   201             ChooseIapComplete( KErrNone, iSession->MyServer().UserConnPref());
   199             ChooseIapComplete( KErrNone, iSession->MyServer().UserConnPref());
   202             return;
   200             return;
   203             }
   201             }
   204 
   202 
       
   203         // Read the default connection values
   205         TCmDefConnType type( TCmDefConnType( 0 ) );
   204         TCmDefConnType type( TCmDefConnType( 0 ) );
   206         TUint32 id( 0 );
   205         TUint32 id( 0 );
   207         iSession->MyServer().DefaultConnection()->GetDefaultConnectionL( type, id );
   206         iCommsDatAccess->GetDefaultConnectionL( type, id );
   208         
   207         
   209         MPMLOGSTRING3( "CMPMIapSelection::ChooseIapL:\
   208         MPMLOGSTRING3( "CMPMIapSelection::ChooseIapL:\
   210  default connection type %d id %d", type, id )
   209             default connection type %d id %d", type, id )
   211        
   210         
   212         if( type == ECmDefConnConnectionMethod )
   211         // set the received snap id and open the connection
   213             {
   212         iChooseIapPref.SetSnapId( id );
   214             iChooseIapPref.SetIapId( id );
   213         ExplicitConnectionL();
   215             iChooseIapPref.SetSnapId( 0 );
       
   216             ExplicitConnectionL();
       
   217             }
       
   218         else if( type == ECmDefConnDestination )
       
   219             { 
       
   220             iChooseIapPref.SetSnapId( id );
       
   221             ExplicitConnectionL();
       
   222             }
       
   223         else
       
   224             {
       
   225             if( iCommsDatAccess->IsSnapEmptyL( id ) )
       
   226                 {
       
   227                 // start implicit connection
       
   228                 ImplicitConnectionL();
       
   229                 return;
       
   230                 }
       
   231 
       
   232             iChooseIapPref.SetSnapId( id );
       
   233 
       
   234             // start connection as if explicitly defined 
       
   235             // by application
       
   236             ExplicitConnectionL();
       
   237             }       
       
   238         }
   214         }
   239     else if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeExplicit )
   215     else if ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeExplicit )
   240         {
   216         {
   241         // Client has defined SNAP or IAP connection to be used.
   217         // Client has defined SNAP or IAP connection to be used.
   242         
   218         
   349         // in connection preferences
   325         // in connection preferences
   350         //
   326         //
   351         iChooseIapPref.SetIapId( validateIapId );
   327         iChooseIapPref.SetIapId( validateIapId );
   352         iChooseIapPref.SetNetId( retNetId );
   328         iChooseIapPref.SetNetId( retNetId );
   353 
   329 
   354         // In case offline mode is enabled, only LAN or WLAN is allowed.
   330         if ( !iapTypeLanOrWlan &&                  
   355         // If some other bearer has been requested, then error code 
   331              iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown )
   356         // KErrGprsOfflineMode should be returned instead of KErrNone.
       
   357         // 
       
   358         
       
   359         if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() ||                 
       
   360              iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) )
       
   361             {
   332             {
   362             ChooseIapComplete( KErrGprsOfflineMode, &iChooseIapPref );
   333             ChooseIapComplete( KErrGprsOfflineMode, &iChooseIapPref );
   363             }
   334             }
   364         else
   335         else
   365             {
   336             {
   366             TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( validateIapId );
   337             TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( validateIapId );
   367             if( wlanType != ENotWlanIap )
   338             if( wlanType != ENotWlanIap )
   368                 {
   339                 {
   369                 iChooseIapState = EExplicitConnection;
   340                 // Add info into the BM connections
   370                 iWlanDialog = CMPMWlanQueryDialog::NewL( *this, validateIapId );
   341                 iSession->MyServer().AppendBMConnection( iSession->ConnectionId(), 
   371                 iWlanDialog->StartWlanQueryL();
   342                                     iChooseIapPref.SnapId(),
       
   343                                     validateIapId,
       
   344                                     EStarting,
       
   345                                     *iSession );
       
   346                 ChooseIapComplete( KErrNone, &iChooseIapPref );
   372                 return;                
   347                 return;                
   373                 }
   348                 }
   374 
   349 
   375             // Check whether confirmation from user is needed for allowing cellular usage.
   350             // Check whether confirmation from user is needed for allowing cellular usage.
   376             // When application is starting an IAP confirmation is asked only when roaming.
   351             // When application is starting an IAP confirmation is asked only when roaming.
   377             // This is skipped for VPN (= virtual) IAPs
   352             // This is skipped for VPN (= virtual) IAPs
   378             if ( iSession->IsConfirmFirstL( validateIapId ) &&
   353             if ( iSession->IsConfirmFirstL( validateIapId ) &&
   379                  !( iSession->MyServer().CommsDatAccess()->IsVirtualIapL( validateIapId ) ))
   354                  !( iSession->MyServer().CommsDatAccess()->IsVirtualIapL( validateIapId ) ))
   380                 {
   355                 {
   381                 // Check if we are roaming and cellular data usage query has not yet been presented
   356                 // Check that queries aren't disabled and
   382                 // to the user in this country
   357                 // enough time has elapsed from the last query cancelled by the user.
   383                 if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
   358                 if ( !( iChooseIapPref.NoteBehaviour()
       
   359                         & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
       
   360                      !iSession->MyServer().IsConnPermQueryTimerOn() )
   384                     {
   361                     {
   385                     // Check that queries aren't disabled and
   362                     TConnectionId connId = iSession->ConnectionId();
   386                     // enough time has elapsed from the last query cancelled by the user.
   363 
   387                     if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
   364                     // Set confirmation type based on roaming status
   388                             !iSession->MyServer().IsConnPermQueryTimerOn() )
   365                     CMPMConfirmDlg::TDialogType type = 
   389                         {
   366                             CMPMConfirmDlg::EConfirmDlgHomeNetwork;
   390                         TConnectionId connId = iSession->ConnectionId();
   367                     if ( iSession->MyServer().RoamingWatcher()->RoamingStatus()
   391                                                             
   368                             == EMPMInternationalRoaming ) {
   392                         // International roaming
   369                         type = CMPMConfirmDlg::EConfirmDlgVisitorNetwork;
   393                         iConfirmDlgStarting = CMPMConfirmDlgStarting::NewL( 
   370                     }
   394                             *this, 
   371                     
   395                             connId,
   372                     iConfirmDlgStarting = CMPMConfirmDlgStarting::NewL( 
   396                             snap, 
   373                         *this, 
   397                             validateIapId, 
   374                         connId,
   398                             CMPMConfirmDlg::EConfirmDlgVisitorNetwork,
   375                         snap, 
   399                             iChooseIapPref,
   376                         validateIapId, 
   400                             iSession->MyServer(),
   377                         type,
   401                             *iSession,
   378                         iChooseIapPref,
   402                             EExplicitConnection );
   379                         iSession->MyServer(),
   403                         return;    
   380                         *iSession,
   404                         }
   381                         EExplicitConnection );
   405                     else
   382                     return;    
   406                         {
   383                     }
   407                         // Queries disabled, connection must fail
   384                 else
   408                         ChooseIapComplete( KErrPermissionDenied, &iChooseIapPref );
   385                     {
   409                         return;
   386                     // Queries disabled, connection must fail
   410                         }
   387                     ChooseIapComplete( KErrPermissionDenied, &iChooseIapPref );
       
   388                     return;
   411                     }
   389                     }
   412                 }
   390                 }
   413                            
   391                            
   414             // Add info into the BM connections
   392             // Add info into the BM connections
   415             //
   393             //
   460         CleanupStack::PopAndDestroy( &iapPath );
   438         CleanupStack::PopAndDestroy( &iapPath );
   461         }        
   439         }        
   462     }
   440     }
   463 
   441 
   464 // -----------------------------------------------------------------------------
   442 // -----------------------------------------------------------------------------
   465 // CMPMIapSelection::UpdateConnectionDialog
       
   466 // -----------------------------------------------------------------------------
       
   467 //
       
   468 void CMPMIapSelection::UpdateConnectionDialogL()
       
   469     {
       
   470     if( iDialog )
       
   471         {
       
   472         MPMLOGSTRING( "CMPMIapSelection::UpdateConnectionDialogL data will be updated" )
       
   473         iDialog->PublishSortSnapInfoL();
       
   474         }
       
   475     }
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // CMPMIapSelection::CompleteExplicitSnapConnectionL
   443 // CMPMIapSelection::CompleteExplicitSnapConnectionL
   479 // -----------------------------------------------------------------------------
   444 // -----------------------------------------------------------------------------
   480 //
   445 //
   481 void CMPMIapSelection::CompleteExplicitSnapConnectionL()
   446 void CMPMIapSelection::CompleteExplicitSnapConnectionL()
   482     {
   447     {
   496     ChooseBestIAPL( iChooseIapPref, availableIAPList, iNextBestExists );
   461     ChooseBestIAPL( iChooseIapPref, availableIAPList, iNextBestExists );
   497     TUint32 validateIapId = iChooseIapPref.IapId();
   462     TUint32 validateIapId = iChooseIapPref.IapId();
   498     // Check if any suitable IAP's were found, if not then complete selection with error code
   463     // Check if any suitable IAP's were found, if not then complete selection with error code
   499     if ( validateIapId == 0 )
   464     if ( validateIapId == 0 )
   500         {
   465         {
   501         ChooseIapComplete( KErrNotFound, NULL );
   466         if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
       
   467                 ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeDefault ||
       
   468                 ( iChooseIapPref.ConnType() == TMpmConnPref::EConnTypeExplicit &&
       
   469                   iCommsDatAccess->IsInternetSnapL( 0, snap ) ) ) )
       
   470             {
       
   471             ImplicitConnectionL();
       
   472             }
       
   473         else
       
   474             {
       
   475             ChooseIapComplete( KErrNotFound, NULL );
       
   476             }
   502         CleanupStack::PopAndDestroy( &availableIAPList );
   477         CleanupStack::PopAndDestroy( &availableIAPList );
   503         return;
   478         return;
   504         }
   479         }
   505     
   480     
   506     TUint32 retNetId( 0 );
   481     TUint32 retNetId( 0 );
   518 
   493 
   519     if ( !CheckGprsServicesAllowedL( iapTypeLanOrWlan ) )
   494     if ( !CheckGprsServicesAllowedL( iapTypeLanOrWlan ) )
   520         {
   495         {
   521         ChooseIapComplete( KErrGprsServicesNotAllowed, NULL );
   496         ChooseIapComplete( KErrGprsServicesNotAllowed, NULL );
   522         }
   497         }
   523     else if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() ||                 
   498     else if ( !iapTypeLanOrWlan &&                 
   524                iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) )
   499                iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown )
   525         {
   500         {
   526         // In case offline mode is enabled, only LAN or WLAN is allowed.
   501         // In case offline mode is enabled, only LAN or WLAN is allowed.
   527         // If some other bearer has been requested, then error code 
   502         // If some other bearer has been requested, then error code 
   528         // KErrGprsOfflineMode should be returned instead of KErrNone.
   503         // KErrGprsOfflineMode should be returned instead of KErrNone.
   529         // 
   504         // 
   538              !( iSession->MyServer().CommsDatAccess()->IsVirtualIapL( validateIapId ) ) )
   513              !( iSession->MyServer().CommsDatAccess()->IsVirtualIapL( validateIapId ) ) )
   539             {
   514             {
   540             // Check that queries aren't disabled and
   515             // Check that queries aren't disabled and
   541             // enough time has elapsed from the last query cancelled by the user.
   516             // enough time has elapsed from the last query cancelled by the user.
   542             if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
   517             if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
   543                     !iSession->MyServer().IsConnPermQueryTimerOn() )
   518                  !iSession->MyServer().IsConnPermQueryTimerOn() )
   544                 {
   519                 {
   545                 if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
   520                 if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
   546                     {
   521                     {
   547                     // International roaming
   522                     // International roaming
   548                     iConfirmDlgStarting = CMPMConfirmDlgStarting::NewL( 
   523                     iConfirmDlgStarting = CMPMConfirmDlgStarting::NewL( 
   578                 ChooseIapComplete( KErrPermissionDenied, &iChooseIapPref );
   553                 ChooseIapComplete( KErrPermissionDenied, &iChooseIapPref );
   579                 }
   554                 }
   580             }
   555             }
   581         else
   556         else
   582             {
   557             {
   583             if ( !StartWlanQueryIfNeededL( validateIapId ) )
   558             // Add info into the BM connections
   584                 {
   559             //
   585                 // Add info into the BM connections
   560             iSession->MyServer().AppendBMConnection( connId, 
   586                 //
       
   587                 iSession->MyServer().AppendBMConnection( connId, 
       
   588                         snap, 
   561                         snap, 
   589                         validateIapId, 
   562                         validateIapId, 
   590                         EStarting,
   563                         EStarting,
   591                         *iSession );
   564                         *iSession );
   592                 ChooseIapComplete( KErrNone, &iChooseIapPref );
   565             ChooseIapComplete( KErrNone, &iChooseIapPref );
   593 
       
   594                 }
       
   595 
       
   596             }
   566             }
   597         }
   567         }
   598 
   568 
   599     CleanupStack::PopAndDestroy( &availableIAPList );    
   569     CleanupStack::PopAndDestroy( &availableIAPList );    
   600     }
   570     }
   629         }
   599         }
   630     return ETrue;
   600     return ETrue;
   631     }
   601     }
   632 
   602 
   633 // -----------------------------------------------------------------------------
   603 // -----------------------------------------------------------------------------
   634 // CMPMIapSelection::StartWlanQueryIfNeededL
   604 // CMPMIapSelection::IsIapWlanL
   635 // -----------------------------------------------------------------------------
   605 // -----------------------------------------------------------------------------
   636 //
   606 //
   637 TBool CMPMIapSelection::StartWlanQueryIfNeededL( TUint32 aIapId, TBool aIsRoaming )
   607 TBool CMPMIapSelection::IsIapWlanL( TUint32 aIapId )
   638     {
   608     {
   639     MPMLOGSTRING3( "CMPMIapSelection::StartWlanQueryIfNeededL iap %d, isRoaming %d ", 
   609     MPMLOGSTRING2( "CMPMIapSelection::StartWlanQueryIfNeededL iap %d, ", aIapId)
   640                    aIapId,
       
   641                    aIsRoaming )
       
   642     TBool wlanQueryNeeded( EFalse );
       
   643     // If wlan iap check if offline note needed
       
   644     TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( aIapId );
   610     TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( aIapId );
   645     if( wlanType != ENotWlanIap )
   611     if( wlanType != EWlanIap )
   646         {
   612         {
   647         iIsRoaming = aIsRoaming;
   613         return EFalse;
   648         iChooseIapState = EExplicitConnection;
   614         }
   649         iWlanDialog = CMPMWlanQueryDialog::NewL( *this, aIapId );
   615     return ETrue;
   650         iWlanDialog->StartWlanQueryL();
       
   651         wlanQueryNeeded = ETrue;
       
   652         }
       
   653     return wlanQueryNeeded;
       
   654     }
   616     }
   655 
   617 
   656 // -----------------------------------------------------------------------------
   618 // -----------------------------------------------------------------------------
   657 // CMPMIapSelection::ImplicitConnectionCheckWlanScanNeededL
   619 // CMPMIapSelection::ImplicitConnectionCheckWlanScanNeededL
   658 // -----------------------------------------------------------------------------
   620 // -----------------------------------------------------------------------------
   659 //
   621 //
   660 void CMPMIapSelection::ImplicitConnectionCheckWlanScanNeededL()
   622 void CMPMIapSelection::ImplicitConnectionCheckWlanScanNeededL()
   661     {
   623     {
   662     __ASSERT_DEBUG( !iDialog, PanicServer( EMPMReceiveAlreadyActive ) );
       
   663 
       
   664     MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionCheckWlanScanNeededL" )
   624     MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionCheckWlanScanNeededL" )
   665 
   625 
   666     iCommsDatAccess->CheckWLANIapL( *iSession );
   626     iCommsDatAccess->CheckWLANIapL( *iSession );
   667 
   627 
   668     // Scan WLAN networks before displaying Connection Dialog in case: 
   628     // Scan WLAN networks before displaying Connection Dialog in case: 
   727 void CMPMIapSelection::ChooseIapComplete( 
   687 void CMPMIapSelection::ChooseIapComplete( 
   728     TInt                aError,
   688     TInt                aError,
   729     const TMpmConnPref* aPolicyPref )
   689     const TMpmConnPref* aPolicyPref )
   730     {
   690     {
   731     MPMLOGSTRING2( "CMPMIapSelection::ChooseIapComplete aError = %d", aError )
   691     MPMLOGSTRING2( "CMPMIapSelection::ChooseIapComplete aError = %d", aError )
   732     
       
   733     if ( ( aError == KErrNone ) &&
       
   734         !( iChooseIapPref.NoteBehaviour() &
       
   735            TExtendedConnPref::ENoteBehaviourConnDisableNotes ) )
       
   736         {
       
   737         TConnectionState state =
       
   738             iSession->MyServer().CheckUsageOfIap( aPolicyPref->IapId(), 
       
   739                                                   iSession->ConnectionId() );
       
   740         TBool connectionAlreadyActive = (state == EStarted || state == EStarting || state == ERoaming);
       
   741         if ( !connectionAlreadyActive &&
       
   742                 ( iSession->IsMMSIap( aPolicyPref->IapId() ) == EFalse ) )
       
   743             {
       
   744             CConnectionUiUtilities* connUiUtils( NULL );
       
   745             TRAPD( popupError, connUiUtils = CConnectionUiUtilities::NewL() );
       
   746             if ( popupError == KErrNone )
       
   747         	    {
       
   748             	connUiUtils->ConnectingViaDiscreetPopup( aPolicyPref->IapId() );
       
   749                	delete connUiUtils;
       
   750         	    }
       
   751             }
       
   752         }
       
   753     
       
   754     if( iWlanDialog )
       
   755         {
       
   756         delete iWlanDialog;
       
   757         iWlanDialog = NULL;
       
   758         }
       
   759 
   692 
   760     iSession->ChooseIapComplete( aError, aPolicyPref );
   693     iSession->ChooseIapComplete( aError, aPolicyPref );
   761     // Set choose iap state to none
   694     // Set choose iap state to none
   762     iChooseIapState = ENoConnection;
   695     iChooseIapState = ENoConnection;
   763     iNextBestExists = EFalse;
   696     iNextBestExists = EFalse;
   764     iUserSelectionSnapId = 0;
   697     iUserSelectionSnapId = 0;
   765     iUserSelectionIapId = 0;
   698     iUserSelectionIapId = 0;
   766     iImplicitState = EImplicitStart;
   699     iImplicitState = EImplicitStart;
   767     }
   700     }
   768 
   701 
   769 
       
   770 // -----------------------------------------------------------------------------
       
   771 // CMPMIapSelection::UserWlanSelectionDoneL
       
   772 // -----------------------------------------------------------------------------
       
   773 //
       
   774 void CMPMIapSelection::UserWlanSelectionDoneL( TInt aError, TUint32 aIapId )
       
   775     {
       
   776     MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL" )
       
   777 
       
   778     if( iIsRoaming )
       
   779         {
       
   780         iIsRoaming = EFalse;
       
   781         iSession->MigrateCallbackL( aError );
       
   782         delete iWlanDialog;
       
   783         iWlanDialog = NULL;
       
   784         }
       
   785     else
       
   786         {
       
   787         if( aError != KErrNone )
       
   788             {
       
   789             MPMLOGSTRING2( "CMPMIapSelection::UserWlanSelectionDoneL - Error = %d, completing", aError ) 
       
   790             ChooseIapComplete( aError, NULL );        
       
   791             }
       
   792         else
       
   793             {
       
   794             if( iChooseIapState == EImplicitConnection )
       
   795                 {
       
   796                 iUserSelectionIapId = aIapId;
       
   797                 ImplicitConnectionL();    
       
   798                 }
       
   799             else if( iChooseIapState == EExplicitConnection )
       
   800                 {
       
   801                 MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL completing explicit iap connection" ) 
       
   802                 iChooseIapPref.SetIapId( aIapId );
       
   803                 // Add info into the BM connections
       
   804                 //
       
   805                 iSession->MyServer().AppendBMConnection( iSession->ConnectionId(), 
       
   806                                                          iChooseIapPref.SnapId(),
       
   807                                                          aIapId,
       
   808                                                          EStarting,
       
   809                                                          *iSession );
       
   810                 iWlanDialog->StoreEasyWlanSelectionL();
       
   811                 delete iWlanDialog;
       
   812                 iWlanDialog = NULL;
       
   813 
       
   814                 ChooseIapComplete( KErrNone, &iChooseIapPref );
       
   815                 }
       
   816             else
       
   817                 {
       
   818                 MPMLOGSTRING( "CMPMIapSelection::UserWlanSelectionDoneL - error, no connection state" ) 
       
   819                 }
       
   820             
       
   821             }
       
   822         
       
   823         }
       
   824     }
       
   825 
       
   826 // -----------------------------------------------------------------------------
   702 // -----------------------------------------------------------------------------
   827 // CMPMIapSelection::HandleUserSelectionError
   703 // CMPMIapSelection::HandleUserSelectionError
   828 // -----------------------------------------------------------------------------
   704 // -----------------------------------------------------------------------------
   829 //
   705 //
   830 void CMPMIapSelection::HandleUserSelectionError( TInt aError  )
   706 void CMPMIapSelection::HandleUserSelectionError( TInt aError  )
   831     {
   707     {
   832     MPMLOGSTRING2( "CMPMIapSelection::HandleUserIapSelectionError - error %d", 
   708     MPMLOGSTRING2( "CMPMIapSelection::HandleUserIapSelectionError - error %d", 
   833         aError )
   709         aError )
   834     
   710     
   835     ChooseIapComplete( aError, NULL );
   711     ChooseIapComplete( aError, NULL );
   836     delete iDialog;
       
   837     iDialog = NULL;
       
   838     }
   712     }
   839 
   713 
   840        
   714        
   841 // -----------------------------------------------------------------------------
   715 // -----------------------------------------------------------------------------
   842 // CMPMIapSelection::HandleUserIapSelectionL
   716 // CMPMIapSelection::HandleUserIapSelectionL
   856     if ( !aIsIap )
   730     if ( !aIsIap )
   857         {
   731         {
   858         // User selected SNAP
   732         // User selected SNAP
   859         // 
   733         // 
   860         TMpmConnPref userPref;
   734         TMpmConnPref userPref;
   861         iUserSelectionSnapId = iCommsDatAccess->MapNetIdtoSnapAPL( aId );
   735         iUserSelectionSnapId = aId;
   862         userPref.SetSnapId( iUserSelectionSnapId );
   736         userPref.SetSnapId( iUserSelectionSnapId );
   863         userPref.SetIapId( 0 );
   737         userPref.SetIapId( 0 );
   864 
   738 
   865         MPMLOGSTRING2(
   739         MPMLOGSTRING2(
   866                 "CMPMIapSelection::HandleUserSelectionL: Snap = %i selected by the User", 
   740                 "CMPMIapSelection::HandleUserSelectionL: Snap = %i selected by the User", 
   881                 "CMPMIapSelection::HandleUserSelectionL: IAP Id <%i> selected by the User", 
   755                 "CMPMIapSelection::HandleUserSelectionL: IAP Id <%i> selected by the User", 
   882                 iUserSelectionIapId )
   756                 iUserSelectionIapId )
   883 
   757 
   884         }
   758         }
   885     
   759     
   886     // We are done
   760     // Letting a function leave here would panic the whole MPM.
   887     // 
       
   888     delete iDialog;
       
   889     iDialog = NULL;
       
   890     
       
   891     // Dialog is deleted. Letting a function leave here would panic the whole MPM.
       
   892     //
   761     //
   893     TRAPD( err, ImplicitConnectionL() );
   762     TRAPD( err, ImplicitConnectionL() );
   894     if( err != KErrNone )
   763     if( err != KErrNone )
   895         {
   764         {
   896         ChooseIapComplete( err, &iChooseIapPref );
   765         ChooseIapComplete( err, &iChooseIapPref );
   904 void CMPMIapSelection::ImplicitConnectionWlanNoteL()
   773 void CMPMIapSelection::ImplicitConnectionWlanNoteL()
   905     {
   774     {
   906     MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionWlanNoteL" )
   775     MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionWlanNoteL" )
   907     
   776     
   908     TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( iUserSelectionIapId );
   777     TWlanIapType wlanType = iCommsDatAccess->CheckWlanL( iUserSelectionIapId );
   909     // In case offline mode is enabled, only LAN or WLAN is allowed.
   778 
   910     // If some other bearer has been requested, then error code 
       
   911     // KErrGprsOfflineMode should be returned instead of KErrNone.
       
   912     // 
       
   913     if( wlanType != ENotWlanIap )
   779     if( wlanType != ENotWlanIap )
   914         {
   780         {
   915         iChooseIapState = EImplicitConnection;
   781         ImplicitConnectionL();
   916         iWlanDialog = CMPMWlanQueryDialog::NewL( *this, iUserSelectionIapId );
       
   917         iWlanDialog->StartWlanQueryL();
       
   918         return;                
   782         return;                
   919         }
   783         }
   920     else
   784     else
   921         {
   785         {
   922         // Check whether confirmation from user is needed for allowing cellular usage.
   786         // Check whether confirmation from user is needed for allowing cellular usage.
   930             if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
   794             if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
   931                 {
   795                 {
   932                 // Check that queries aren't disabled and
   796                 // Check that queries aren't disabled and
   933                 // enough time has elapsed from the last query cancelled by the user.
   797                 // enough time has elapsed from the last query cancelled by the user.
   934                 if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
   798                 if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
   935                         !iSession->MyServer().IsConnPermQueryTimerOn() )
   799                      !iSession->MyServer().IsConnPermQueryTimerOn() )
   936                     {
   800                     {
   937                     TConnectionId connId = iSession->ConnectionId();
   801                     TConnectionId connId = iSession->ConnectionId();
   938                                                                     
   802                                                                     
   939                     // International roaming
   803                     // International roaming
   940                     iConfirmDlgStarting = CMPMConfirmDlgStarting::NewL( 
   804                     iConfirmDlgStarting = CMPMConfirmDlgStarting::NewL( 
   975                                    iUserSelectionIapId, 
   839                                    iUserSelectionIapId, 
   976                                    retNetId, 
   840                                    retNetId, 
   977                                    iapTypeLanOrWlan,
   841                                    iapTypeLanOrWlan,
   978                                    *iSession );
   842                                    *iSession );
   979                                    
   843                                    
   980     if ( !iapTypeLanOrWlan && ( iSession->MyServer().IsPhoneOffline() ||            
   844     if ( !iapTypeLanOrWlan &&            
   981             iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown ) )
   845             iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMRoamingStatusUnknown )
   982         {
   846         {
   983         MPMLOGSTRING2( "CMPMIapSelection::CompleteImplicitConnectionL: Completing with code = %i",
   847         MPMLOGSTRING2( "CMPMIapSelection::CompleteImplicitConnectionL: Completing with code = %i",
   984                 KErrGprsOfflineMode )
   848                 KErrGprsOfflineMode )
   985         ChooseIapComplete( KErrGprsOfflineMode, NULL );
   849         ChooseIapComplete( KErrGprsOfflineMode, NULL );
   986         }
   850         }
   998         // in connection preferences
   862         // in connection preferences
   999         //            
   863         //            
  1000         iChooseIapPref.SetIapId( iUserSelectionIapId );
   864         iChooseIapPref.SetIapId( iUserSelectionIapId );
  1001         iChooseIapPref.SetNetId( retNetId );
   865         iChooseIapPref.SetNetId( retNetId );
  1002             
   866             
  1003         
       
  1004         if( iWlanDialog )
       
  1005             {
       
  1006             iWlanDialog->StoreEasyWlanSelectionL();
       
  1007             delete iWlanDialog;
       
  1008             iWlanDialog = NULL;
       
  1009             }
       
  1010         
       
  1011         ChooseIapComplete( KErrNone, &iChooseIapPref );
   867         ChooseIapComplete( KErrNone, &iChooseIapPref );
  1012         }
   868         }
  1013     
   869     
  1014     }
   870     }
  1015 
   871 
  1020 void CMPMIapSelection::ImplicitConnectionIapSelectionL()
   876 void CMPMIapSelection::ImplicitConnectionIapSelectionL()
  1021     {
   877     {
  1022     MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionIapSelectionL" )
   878     MPMLOGSTRING( "CMPMIapSelection::ImplicitConnectionIapSelectionL" )
  1023     iSession->AvailableUnblacklistedIapsL( iStoredAvailableIaps, iSession->ConnectionId() );
   879     iSession->AvailableUnblacklistedIapsL( iStoredAvailableIaps, iSession->ConnectionId() );
  1024 
   880 
  1025     // Create and initiate user dialog
   881     // The connection selection dialog doesn't exist any longer, thus
  1026     //
   882     // the HandleUserSelection is called with the Internet SNAP that is returned instead
  1027     iDialog = CMPMDialog::NewL( *this,
   883     TInt err = KErrNone;
  1028                                 iStoredAvailableIaps,
   884     TInt internetSnapId = 0;
  1029                                 iChooseIapPref.BearerSet(),
   885     // if the reading leaves, then the internet snap did not exist for some reason
  1030                                 *iSession->MyServer().ConnectDialogQueue(),
   886     TRAP ( err, internetSnapId = 
  1031                                 iSession->MyServer() );
   887         iCommsDatAccess->DestinationIdL( CMManager::ESnapPurposeInternet ));
       
   888     HandleUserSelectionL( false, internetSnapId, err );
  1032     }
   889     }
  1033 
   890 
  1034 // -----------------------------------------------------------------------------
   891 // -----------------------------------------------------------------------------
  1035 // CMPMIapSelection::ImplicitConnectionL
   892 // CMPMIapSelection::ImplicitConnectionL
  1036 // -----------------------------------------------------------------------------
   893 // -----------------------------------------------------------------------------