realtimenetprots/sipfw/SIP/ConnectionMgr/src/TTlsTransTlsConnecting.cpp
changeset 0 307788aac0a8
child 13 822e1f077722
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : TTlsTransTlsConnecting.cpp
       
    15 // Part of     : ConnectionMgr
       
    16 // implementation
       
    17 // Version     : SIP/5.0
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 #include "TTlsTransTlsConnecting.h"
       
    23 #include "MTlsTransStateOwner.h"
       
    24 
       
    25 
       
    26 const TInt KConnectTLSTimeout = 10000; // 10 seconds
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // TTlsTransTlsConnecting::EnterL
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 void TTlsTransTlsConnecting::EnterL()
       
    33     {
       
    34     //Check if CTransportTls has secure-socket. If yes, try to match
       
    35 	//the certificate. Otherwise create secure-socket in CTransportTls Object
       
    36     if (iOwner.HasSecureSocket())
       
    37         {
       
    38         //Get Server Certificte Info and do the matching
       
    39         //If matching is successful, go into Connected State
       
    40         // and start receiving data, otherwise Disconnect
       
    41         iValidCertificate = iOwner.MatchCertificateL();  
       
    42         }
       
    43     else
       
    44         {                     
       
    45         iValidCertificate = EFalse;
       
    46         iOwner.ConnectTlsL();    	
       
    47         // Have to start guard timer since CSecureSocket doesn't have any
       
    48         // timeout mechanism.
       
    49         iOwner.StartTimerL( KConnectTLSTimeout );
       
    50         }
       
    51     }
       
    52     
       
    53 // -----------------------------------------------------------------------------
       
    54 // TTlsTransTlsConnecting::ConnectionOpenL
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 TBool TTlsTransTlsConnecting::ConnectionOpenL()
       
    58     {
       
    59     iOwner.ChangeStateL( TTlsTransStateBase::ETlsConnecting );
       
    60 	//If the certificate is valid, move the state to connected
       
    61     if(iValidCertificate)
       
    62         {
       
    63         iOwner.ChangeStateL( TTlsTransStateBase::ETlsConnected );
       
    64         return ETrue;
       
    65         }
       
    66     else
       
    67         {
       
    68         //As the certificate does not match, destroy the TLS object and do
       
    69         //the necessary clean-up
       
    70         iOwner.Destroy();        
       
    71         return EFalse;
       
    72         }
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // TTlsTransTlsConnecting::TTlsTransTlsConnecting
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TTlsTransTlsConnecting::TTlsTransTlsConnecting( 
       
    80     MTlsTransStateOwner& aOwner ) : TTlsTransStateBase( aOwner )
       
    81     {
       
    82     }
       
    83 
       
    84 // End of File