vpnengine/ikesocket/src/ikeconnection.cpp
branchRCL_3
changeset 8 032d3a818f49
parent 0 33413c0669b9
equal deleted inserted replaced
4:29b591713d44 8:032d3a818f49
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   159     TInt err( iConnection.Open( iSocketServer ) );
   159     TInt err( iConnection.Open( iSocketServer ) );
   160     
   160     
   161     if ( err == KErrNone )
   161     if ( err == KErrNone )
   162         {
   162         {
   163         // Start connection.
   163         // Start connection.
   164         if ( iSnapId ) // SNAP
   164         TRAP( err, CreatePreferencesL( iIapId,
       
   165                                        iSnapId,
       
   166                                        aForcedRoaming ) );
       
   167         if ( err == KErrNone )
   165             {
   168             {
   166             TRAP( err, CreateSnapPreferencesL( iSnapId,
   169             iConnection.Start( iConnPrefList, iStatus );
   167                                                aForcedRoaming ) );
   170             }
   168             if ( err == KErrNone )
       
   169                 {
       
   170                 iConnection.Start( iConnPrefList, iStatus );
       
   171                 }
       
   172             }    
       
   173         else // IAP
       
   174             {
       
   175             // Create preference overrides.        
       
   176             iPrefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
       
   177             iPrefs.SetIapId( iIapId );        
       
   178             iConnection.Start( iPrefs, iStatus );
       
   179             }            
       
   180         }
   171         }
   181     
   172     
   182     if ( err != KErrNone )
   173     if ( err != KErrNone )
   183         {
   174         {
   184         TRequestStatus* ownStatus = &iStatus;
   175         TRequestStatus* ownStatus = &iStatus;
   334     IKESOCKET_ASSERT( aIpVersion == EIPv4 || aIpVersion == EIPv6 );
   325     IKESOCKET_ASSERT( aIpVersion == EIPv4 || aIpVersion == EIPv6 );
   335     return iLocalAddressResolver->GetLocalAddress( aIpVersion, aLocalIp );
   326     return iLocalAddressResolver->GetLocalAddress( aIpVersion, aLocalIp );
   336     }
   327     }
   337 
   328 
   338 // ---------------------------------------------------------------------------
   329 // ---------------------------------------------------------------------------
   339 // Creates connection preferences for SNAP usage. Connection preferences
   330 // Creates connection preferences. Connection preferences list is constructed.
   340 // list is constructed.
   331 // ---------------------------------------------------------------------------
   341 // ---------------------------------------------------------------------------
   332 //
   342 //
   333 void CIkeConnection::CreatePreferencesL( const TUint32 aIapId,
   343 void CIkeConnection::CreateSnapPreferencesL( const TUint32 aSnapId,
   334                                          const TUint32 aSnapId,
   344                                              const TBool aForcedRoaming )
   335                                          const TBool aForcedRoaming )
   345     {
   336     {
   346     CleanSnapPreferences();
   337     CleanPreferences();
   347     
   338     
   348     iExtendedPrefs.SetSnapId( aSnapId );
   339     if ( aIapId != 0 )
   349     iExtendedPrefs.SetForcedRoaming( aForcedRoaming );
   340         {
       
   341         iExtendedPrefs.SetIapId( aIapId );
       
   342         }
       
   343     else
       
   344         {
       
   345         iExtendedPrefs.SetSnapId( aSnapId );
       
   346         iExtendedPrefs.SetForcedRoaming( aForcedRoaming );
       
   347         }
       
   348     
       
   349     iExtendedPrefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnDisableNotes );
   350     
   350     
   351     iConnPrefList.AppendL( &iExtendedPrefs );  
   351     iConnPrefList.AppendL( &iExtendedPrefs );  
   352     }
   352     }
   353 
   353 
   354 // ---------------------------------------------------------------------------
   354 // ---------------------------------------------------------------------------
   355 // Cleans connection preferences created for SNAP usage.
   355 // Cleans connection preferences created for SNAP usage.
   356 // ---------------------------------------------------------------------------
   356 // ---------------------------------------------------------------------------
   357 //
   357 //
   358 void CIkeConnection::CleanSnapPreferences()
   358 void CIkeConnection::CleanPreferences()
   359     {
   359     {
   360     while( iConnPrefList.Count() > 0 )
   360     while( iConnPrefList.Count() > 0 )
   361         {
   361         {
   362         iConnPrefList.Remove( 0 );
   362         iConnPrefList.Remove( 0 );
   363         }       
   363         }       
   386 void CIkeConnection::DoStateAfterConnecting()
   386 void CIkeConnection::DoStateAfterConnecting()
   387     {
   387     {
   388     IKESOCKET_ASSERT( iLinkObserver );
   388     IKESOCKET_ASSERT( iLinkObserver );
   389     IKESOCKET_ASSERT( iState == EConnecting );
   389     IKESOCKET_ASSERT( iState == EConnecting );
   390     
   390     
   391     CleanSnapPreferences();
   391     CleanPreferences();
   392 
   392 
   393     TInt err( iStatus.Int() );
   393     TInt err( iStatus.Int() );
   394 
   394 
   395     if ( err == KErrNone )
   395     if ( err == KErrNone )
   396         {
   396         {
   441         Cancel();
   441         Cancel();
   442         
   442         
   443         iState = EIdle;
   443         iState = EIdle;
   444         iConnection.Close();
   444         iConnection.Close();
   445         
   445         
   446         CleanSnapPreferences();
   446         CleanPreferences();
   447 
   447 
   448         User::RequestComplete( iClientStatus, KErrCancel );
   448         User::RequestComplete( iClientStatus, KErrCancel );
   449         iClientStatus = NULL;
   449         iClientStatus = NULL;
   450         }
   450         }
   451     }
   451     }