alwayson_net_plugin/pdpcontextmanager2/src/caoconnectionimpl.cpp
changeset 3 f7816ffc66ed
parent 0 5a93021fdf25
equal deleted inserted replaced
2:086aae6fc07e 3:f7816ffc66ed
    33 namespace
    33 namespace
    34     {
    34     {
    35     // CONSTANTS
    35     // CONSTANTS
    36     _LIT( KPanicCat, "ConnectionImpl" );
    36     _LIT( KPanicCat, "ConnectionImpl" );
    37     
    37     
    38     // Default value that indicates that we do not want to prompt user for IAP
       
    39     const TCommDbDialogPref KDlgPreference = ECommDbDialogPrefDoNotPrompt;
       
    40     
       
    41     // DATA TYPES
    38     // DATA TYPES
    42     enum TPanicCode
    39     enum TPanicCode
    43         {
    40         {
    44         ENone,
    41         ENone,
    45         EConnectionAlreadyActive,
    42         EConnectionAlreadyActive,
    91     
    88     
    92     Cancel();
    89     Cancel();
    93     
    90     
    94     delete iCommsDatabase;
    91     delete iCommsDatabase;
    95     iConnection.Close();
    92     iConnection.Close();
       
    93     
       
    94     delete iExtPrefs;
       
    95     delete iPrefsList;
    96     }
    96     }
    97 
    97 
    98 
    98 
    99 // ---------------------------------------------------------------------------
    99 // ---------------------------------------------------------------------------
   100 // CAOConnectionImpl::ActivateConnection
   100 // CAOConnectionImpl::ActivateConnection
   110     // Change state to EOpeningLink
   110     // Change state to EOpeningLink
   111     ChangeState( EOpeningLink );
   111     ChangeState( EOpeningLink );
   112     
   112     
   113     // Check IAP
   113     // Check IAP
   114     TUint iap = iSettings.AccessPointId();
   114     TUint iap = iSettings.AccessPointId();
   115     if ( IsValidIAP( iap ) )
   115     if ( IsValidIAP( iap ) && iSettings.IsCellularAllowedByUser() )
   116         {
   116         {
   117         // Check that we really have RConnection handle opened
   117         // Check that we really have RConnection handle opened
   118         TInt err = KErrNone;
   118         TInt err = KErrNone;
   119         if( !iConnection.SubSessionHandle() )
   119         if( !iConnection.SubSessionHandle() )
   120             {
   120             {
   121             // Socket serv is closed only in destructor
   121             // Socket serv is closed only in destructor
   122             err = iConnection.Open( *iSocketServ );
   122             err = iConnection.Open( *iSocketServ );
   123             }
   123             }
   124     
   124     
   125         if( err == KErrNone )
   125         if( err == KErrNone )
   126             {
   126             {    		
   127 			// Set acces point settings
   127             // Start as a silent connection
   128 			iAccessPointSettings.SetIapId( iap );
   128             iExtPrefs->SetIapId( iap );
   129 			iAccessPointSettings.SetDialogPreference( KDlgPreference );
   129             iExtPrefs->SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent );
   130         
   130     		
   131 			// Start connection
   131             // Clean iPrefsList and append new prefs
   132     		iConnection.Start( iAccessPointSettings, iStatus );
   132             iPrefsList->Remove( 0 );
   133 			SetActive();
   133             TRAPD( err, iPrefsList->AppendL( iExtPrefs ) )
       
   134     		
       
   135             if ( err == KErrNone )
       
   136                 {
       
   137     		    iConnection.Start( *iPrefsList, iStatus );
       
   138                 SetActive();
       
   139                 }
       
   140             else
       
   141                 {
       
   142                 LOG_1( _L("iPrefsList->AppendL( iExtPrefs ) FAILED") );
       
   143                 ActivateSelf( KErrNotSupported );
       
   144                 }
   134             }
   145             }
   135         else
   146         else
   136             {
   147             {
   137             ActivateSelf( KErrNotSupported );
   148             ActivateSelf( KErrNotSupported );
   138             }
   149             }
   265     {
   276     {
   266     LOG_1( _L("CAOConnectionImpl::ConstructL") );
   277     LOG_1( _L("CAOConnectionImpl::ConstructL") );
   267     
   278     
   268     User::LeaveIfError( iConnection.Open( *iSocketServ, KAfInet ) );
   279     User::LeaveIfError( iConnection.Open( *iSocketServ, KAfInet ) );
   269     iCommsDatabase = CCommsDatabase::NewL( EDatabaseTypeUnspecified );
   280     iCommsDatabase = CCommsDatabase::NewL( EDatabaseTypeUnspecified );
       
   281     
       
   282     iExtPrefs = new (ELeave) TExtendedConnPref;
       
   283     iPrefsList = TConnPrefList::NewL();
   270     }
   284     }
   271 
   285 
   272 // ---------------------------------------------------------------------------
   286 // ---------------------------------------------------------------------------
   273 // CAOConnectionImpl::IsValidIAP
   287 // CAOConnectionImpl::IsValidIAP
   274 // ---------------------------------------------------------------------------
   288 // ---------------------------------------------------------------------------