vpnengine/kmdserver/src/fqdnresolver.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2008 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:  active object, that monitors the completion of FQDN resolve.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INTERNAL INCLUDES
       
    20 #include "vpnconnection.h"
       
    21 
       
    22 // CLASS HEADER
       
    23 #include "fqdnresolver.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Two-phased constructor.
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CFqdnResolver* CFqdnResolver::NewL( CVpnConnection& aConnection,
       
    32                                     MFqdnResolverCallback& aCallback )
       
    33     {
       
    34     CFqdnResolver* self = new (ELeave) CFqdnResolver( aConnection, aCallback );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // Destructor.
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CFqdnResolver::~CFqdnResolver()
       
    43     {   
       
    44     Cancel();
       
    45     
       
    46     __ASSERT_DEBUG( iFqdn == NULL, User::Invariant() );
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // Constructor.
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CFqdnResolver::CFqdnResolver( CVpnConnection& aConnection,
       
    54                               MFqdnResolverCallback& aCallback )
       
    55  : CActive( EPriorityStandard ),
       
    56    iConnection( aConnection ),
       
    57    iCallback( aCallback )
       
    58     {
       
    59     CActiveScheduler::Add( this );
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // Resolves an IP address from FQDN address asynchronously.
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 void CFqdnResolver::ResolveAddress( HBufC* aFqdn )
       
    67     {
       
    68     iFqdn = aFqdn;
       
    69     iConnection.ResolveAddress( *iFqdn, iNameEntry, iStatus );
       
    70     SetActive();
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // From class CActive
       
    75 // Handles completion of asynchronous FQDN address resolving. 
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CFqdnResolver::RunL()
       
    79     {
       
    80     delete iFqdn;
       
    81     iFqdn = NULL;
       
    82     
       
    83     iCallback.AddressResolveCompleted( iStatus.Int(), iNameEntry );
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // From class CActive
       
    88 // Cancels FQDN address resolving.
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CFqdnResolver::DoCancel()
       
    92     {    
       
    93     iConnection.CancelResolveAddress();
       
    94     
       
    95     delete iFqdn;
       
    96     iFqdn = NULL;    
       
    97     }