applayerpluginsandutils/httptransportplugins/httptransporthandler/chttpsecuresocket.h
changeset 0 b16258d2340f
child 5 337070b4fa18
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2003-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 //
       
    15 
       
    16 #ifndef __CHTTPSECURESOCKET_H__
       
    17 #define __CHTTPSECURESOCKET_H__
       
    18 
       
    19 // System includes
       
    20 #include <e32base.h>
       
    21 #include <ecom/ecom.h>
       
    22 #include <http/framework/csecuritypolicy.h>
       
    23 
       
    24 // User includes
       
    25 #include "mcommsinfoprovider.h"
       
    26 
       
    27 class CX509Certificate;
       
    28 
       
    29 /**	The ECOM interface definition for a secure socket class.
       
    30  */
       
    31 class CHttpSecureSocket : public CBase
       
    32 	{
       
    33 public:		// methods
       
    34 
       
    35 	inline static CHttpSecureSocket* NewL(RSocket& aSocket, MCommsInfoProvider& aCommsInfoProvider);
       
    36 
       
    37 	inline virtual ~CHttpSecureSocket();
       
    38 
       
    39 	virtual void StartSecureHandshakeL(TRequestStatus& aStatus, const TDesC8& aHostName) =0;
       
    40 
       
    41 	virtual void RecvOneOrMore(TDes8& aBuffer, TRequestStatus& aStatus, TSockXfrLength& aLength) =0;
       
    42 
       
    43 	virtual void CancelRecv() =0;
       
    44 
       
    45 	virtual void Send(const TDesC8& aBuffer, TRequestStatus& aStatus) =0;
       
    46 
       
    47 	virtual void CancelSend() =0;
       
    48 
       
    49 	virtual const CX509Certificate* ServerCert() = 0; 
       
    50 
       
    51 	virtual void CancelHandshake() =0;
       
    52 	
       
    53 	virtual TInt CipherSuite(TDes8& aCipherSuite) =0;
       
    54 
       
    55     virtual TInt PendingBytesToRead () =0;
       
    56 
       
    57 protected:
       
    58 	struct THttpSecureSocketParams
       
    59 		{
       
    60 		RSocket* iSocket;
       
    61 		MCommsInfoProvider* iCommsInfoProvider;
       
    62 		};
       
    63 
       
    64 
       
    65 private:	// Attributes
       
    66 
       
    67 	/**	The ECom destructor key identifier
       
    68 	*/
       
    69 	TUid iEcomDtorID;
       
    70 	};
       
    71 	
       
    72 	
       
    73 //-----------------------------------------------------------------------------
       
    74 
       
    75 
       
    76 inline CHttpSecureSocket* CHttpSecureSocket::NewL(RSocket& aSocket, MCommsInfoProvider& aCommsInfoProvider)
       
    77 	{
       
    78 	_LIT8(KDataTypeName, "http-secure-socket");
       
    79 
       
    80 	const TUid KUidSecSockInterface = {0x101F55F8};
       
    81 
       
    82 	TEComResolverParams resParams;
       
    83 	resParams.SetDataType(KDataTypeName());
       
    84 
       
    85 	THttpSecureSocketParams initParams;
       
    86 	initParams.iSocket = &aSocket;
       
    87 	initParams.iCommsInfoProvider = &aCommsInfoProvider;
       
    88 
       
    89 	TAny* ptr = REComSession::CreateImplementationL(KUidSecSockInterface, 
       
    90 									_FOFF(CHttpSecureSocket, iEcomDtorID),
       
    91 									&initParams,
       
    92 									resParams);
       
    93 
       
    94 	return REINTERPRET_CAST(CHttpSecureSocket*, ptr);
       
    95 	}
       
    96 	
       
    97 inline CHttpSecureSocket::~CHttpSecureSocket()
       
    98 	{
       
    99 	REComSession::DestroyedImplementation(iEcomDtorID);
       
   100 	} 	
       
   101 	
       
   102 #endif // __CHTTPSECURESOCKET_H__