natfw/natfwstunturnclient/src/cstunclientresolvingudp.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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 "cstunclientresolvingudp.h"
       
    24 
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CSTUNClientResolvingUDP::CSTUNClientResolvingUDP
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CSTUNClientResolvingUDP::CSTUNClientResolvingUDP(
       
    33     const CSTUNClientState& aGetSharedSecret,
       
    34     const CSTUNClientState& aReady ) :
       
    35     iGetSharedSecret( aGetSharedSecret ),
       
    36     iReady( aReady )
       
    37     {
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CSTUNClientResolvingUDP::CSTUNClientResolvingUDP
       
    42 // Dummy implementation. Default constructor is declared private and not used.
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CSTUNClientResolvingUDP::CSTUNClientResolvingUDP() :
       
    46     iGetSharedSecret( *( CSTUNClientState* )0x1 ),
       
    47     iReady( *( CSTUNClientState* )0x1 )
       
    48     {
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CSTUNClientResolvingUDP::CSTUNClientResolvingUDP
       
    53 // Dummy implementation, as copy constructor is declared private and not used.
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CSTUNClientResolvingUDP::CSTUNClientResolvingUDP(
       
    57     const CSTUNClientResolvingUDP& aResolvingUDP ) :    
       
    58     CSTUNClientState(),
       
    59     iGetSharedSecret( aResolvingUDP.iGetSharedSecret ),
       
    60     iReady( aResolvingUDP.iReady )
       
    61     {
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CSTUNClientResolvingUDP::~CSTUNClientResolvingUDP
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CSTUNClientResolvingUDP::~CSTUNClientResolvingUDP()
       
    69     {    
       
    70     }
       
    71     
       
    72 // ---------------------------------------------------------------------------
       
    73 // CSTUNClientResolvingUDP::ResolvingCompletedL
       
    74 // Release resolver resources after changing state, as invariant expects
       
    75 // resolver to exist in ResolvingUDP state.
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CSTUNClientResolvingUDP::ResolvingCompletedL(
       
    79     CSTUNClientImplementation& aContext,
       
    80     TBool aObtainSharedSecret ) const
       
    81     {
       
    82     if ( aObtainSharedSecret )
       
    83         {
       
    84         aContext.GetSharedSecretFromServerL();
       
    85         aContext.ChangeState( &iGetSharedSecret );
       
    86         }
       
    87     else
       
    88         {
       
    89         aContext.PassInitCompletedL( KErrNone );
       
    90         aContext.ChangeState( &iReady );
       
    91         }
       
    92     aContext.FreeResolverResources();
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CSTUNClientResolvingUDP::ResolvingFailed
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CSTUNClientResolvingUDP::ResolvingFailed(
       
   100     CSTUNClientImplementation& aContext,
       
   101     TInt aError ) const
       
   102     {
       
   103     __STUN_ASSERT_RETURN( aError != KErrNone, KErrArgument );
       
   104 
       
   105     aContext.Terminate( aError );
       
   106     }