natfw/natfwstunturnclient/src/cstunclientresolvingtcp.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "stunassert.h"
       
    22 #include "cstunclientimplementation.h"
       
    23 #include "cstunclientresolvingtcp.h"
       
    24 
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CSTUNClientResolvingTCP::CSTUNClientResolvingTCP
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CSTUNClientResolvingTCP::CSTUNClientResolvingTCP(
       
    33     const CSTUNClientState& aResolvingTLS, 
       
    34     const CSTUNClientState& aResolvingUDP ) :
       
    35     iResolvingTLS( aResolvingTLS ), iResolvingUDP( aResolvingUDP ) 
       
    36     {
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CSTUNClientResolvingTCP::CSTUNClientResolvingTCP
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CSTUNClientResolvingTCP::CSTUNClientResolvingTCP(
       
    44     const CSTUNClientState& aResolvingUDP ) :
       
    45     iResolvingTLS( *( CSTUNClientState* )0x1 ),
       
    46     iResolvingUDP( aResolvingUDP )
       
    47     {
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CSTUNClientResolvingTCP::CSTUNClientResolvingTCP
       
    52 // Dummy implementation. Default constructor is declared private and not used.
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CSTUNClientResolvingTCP::CSTUNClientResolvingTCP() :
       
    56     iResolvingTLS( *( CSTUNClientState* )0x1 ),
       
    57     iResolvingUDP( *( CSTUNClientState* )0x1 )
       
    58     {
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CSTUNClientResolvingTCP::~CSTUNClientResolvingTCP
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CSTUNClientResolvingTCP::~CSTUNClientResolvingTCP()
       
    66     {    
       
    67     }
       
    68     
       
    69 // ---------------------------------------------------------------------------
       
    70 // CSTUNClientResolvingTCP::ResolvingCompletedL        
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CSTUNClientResolvingTCP::ResolvingCompletedL(
       
    74     CSTUNClientImplementation& aContext,
       
    75     TBool aObtainSharedSecret ) const
       
    76     {
       
    77     aContext.TcpResolvedL( aObtainSharedSecret );
       
    78     if ( aObtainSharedSecret )
       
    79         {
       
    80         aContext.ChangeState( &iResolvingTLS );
       
    81         }
       
    82     else
       
    83         {
       
    84         aContext.ChangeState( &iResolvingUDP );
       
    85         }
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CSTUNClientResolvingTCP::ResolvingFailed
       
    90 // Continue without using shared secret as TCP address couldn't be obtained.
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CSTUNClientResolvingTCP::ResolvingFailed(
       
    94     CSTUNClientImplementation& aContext,
       
    95     TInt aError ) const
       
    96     {
       
    97     __STUN_ASSERT_RETURN( aError != KErrNone, KErrArgument );
       
    98 
       
    99     TRAPD( err, ResolvingCompletedL( aContext, EFalse ) );
       
   100     if ( err != KErrNone )
       
   101         {
       
   102         aContext.Terminate( err );
       
   103         }
       
   104     }