networksecurity/tls/secsock/GenericSecureSocket.h
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     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 // Generic Secure Socket Interface
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23 #ifndef __GENERICSECURESOCKET_H__
       
    24 #define __GENERICSECURESOCKET_H__
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <es_sock.h>
       
    28 
       
    29 class MGenericSecureSocket
       
    30 /** 
       
    31  * Interface to provide Generic Secure Socket Functionality. 
       
    32  * 
       
    33  * @prototype
       
    34  * @internalComponent
       
    35  * 
       
    36  * @since v9.2 
       
    37  */
       
    38 	{
       
    39 public:
       
    40 	/**
       
    41 	Send data over the generic socket for the secure socket
       
    42 	@param aDataToSend encrypted data to send for secure socket
       
    43 	@param aFlags Flags which are passed through to protocol
       
    44 	@param aStatus Request Status
       
    45 	*/
       
    46 	virtual void Send(const TDesC8& aDataToSend, TUint aFlags, TRequestStatus& aStatus)=0;
       
    47 
       
    48 	/**
       
    49 	Cancel the current send operation
       
    50 	*/
       
    51 	virtual void CancelSend()=0;
       
    52 	
       
    53 	/**
       
    54 	Receive data from the generic socket for the secure socket
       
    55 	@param aDataReceived encrypted data received for the secure socket
       
    56 	@param aFlags Flags which are passed through to protocol
       
    57 	@param aStatus Request Status.  On return KErrNone if successful, 
       
    58 	       otherwise another of the system-wide error
       
    59 	*/
       
    60 	virtual void Recv(TDes8& aDataReceived, TUint aFlags, TRequestStatus& aStatus)=0;
       
    61 
       
    62 	/**
       
    63 	Cancel the current recv operation
       
    64 	*/
       
    65 	virtual void CancelRecv()=0;
       
    66 	
       
    67 	/**
       
    68 	Read data from the generic socket for the secure socket
       
    69 	@param aDataRead encrypted data read for the secure socket
       
    70 	@param aStatus Request Status.  On return KErrNone if successful, 
       
    71 	       otherwise another of the system-wide error
       
    72 	*/
       
    73 	virtual void Read(TDes8& aDataRead, TRequestStatus& aStatus)=0;
       
    74 
       
    75 	/**
       
    76 	Cancel the current read operation
       
    77 	*/
       
    78 	virtual void CancelRead()=0;
       
    79 
       
    80 	/**
       
    81 	Sets a socket option
       
    82 	@param aOptionName An integer constant which identifies an option.
       
    83 	@param aOptionLevel An integer constant which identifies level of an option
       
    84 	@param aOption Option value packaged in a descriptor.
       
    85 	@return KErrNone if successful, otherwise another of the system-wide error codes. 
       
    86 	*/
       
    87 	virtual TInt SetOpt(TUint aOptionName, TUint aOptionLevel, const TDesC8& aOption)=0;
       
    88 
       
    89 	/**
       
    90 	Gets a socket option
       
    91 	@param aOptionName An integer constant which identifies an option.
       
    92 	@param aOptionLevel An integer constant which identifies level of an option
       
    93 	@param aOption Option value packaged in a descriptor.
       
    94 	@return KErrNone if successful, otherwise another of the system-wide error codes. 
       
    95 	*/
       
    96 	virtual TInt GetOpt(TUint aOptionName, TUint aOptionLevel, TDes8& aOption)=0;
       
    97 
       
    98 	/**
       
    99 	Gets the local address of a bound socket. 
       
   100 	@param aAddr Local address which is filled in on return. 
       
   101 	*/
       
   102 	virtual void LocalName(TSockAddr& aAddr)=0;
       
   103 
       
   104 	/**
       
   105 	Gets the remote address of a bound socket. 
       
   106 	@param aAddr Remote address which is filled in on return. 
       
   107 	*/
       
   108 	virtual void RemoteName(TSockAddr& aAddr)=0;
       
   109 
       
   110 	/**
       
   111 	Close the Generic Socket
       
   112 	*/
       
   113 	virtual void Close()=0;
       
   114 	};
       
   115 
       
   116 
       
   117 template<class TYPE>
       
   118 class CGenericSecureSocket : public MGenericSecureSocket
       
   119 /** 
       
   120  * Templated Class to provide wrapper using Generic Secure Socket
       
   121  * 
       
   122  * @prototype
       
   123  * @internalComponent
       
   124  * 
       
   125  * @since v9.2 
       
   126  */
       
   127 	{
       
   128 public:
       
   129 	CGenericSecureSocket(TYPE& aProvider);
       
   130 	~CGenericSecureSocket();
       
   131 
       
   132 	void Send(const TDesC8& aDataToSend, TUint aFlags, TRequestStatus& aStatus);
       
   133 	void CancelSend();
       
   134 	
       
   135 	void Recv(TDes8& aDataReceived, TUint aFlags, TRequestStatus& aStatus);
       
   136 	void CancelRecv();
       
   137 	
       
   138 	void Read(TDes8& aDataRead, TRequestStatus& aStatus);
       
   139 	void CancelRead();
       
   140 
       
   141 	TInt SetOpt(TUint aOptionName, TUint aOptionLevel, const TDesC8& aOption);
       
   142 	TInt GetOpt(TUint aOptionName, TUint aOptionLevel, TDes8& aOption);
       
   143 
       
   144 	void LocalName(TSockAddr& aAddr);
       
   145 	void RemoteName(TSockAddr& aAddr);
       
   146 
       
   147 	void Close();
       
   148 
       
   149 private:
       
   150 	TYPE& iProvider;
       
   151 	};
       
   152 
       
   153 #include <genericsecuresocket.inl>
       
   154 
       
   155 #endif // __GENERICSECURESOCKET_H__