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