datacommsserver/esockserver/inc/es_api_ext.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 // CS_API_EXT.H
       
    15 //
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef CS_API_EXT_H
       
    25 #define CS_API_EXT_H
       
    26 
       
    27 #include <es_sock.h>
       
    28 #include <comms-infras/api_ext_list.h>
       
    29 #include <comms-infras/trbuf.h>
       
    30 
       
    31 class TCommsApiExtReqMsg;
       
    32 
       
    33 _LIT(KApiExtPanic, "ESock_ApiExtItf");
       
    34 
       
    35 /**
       
    36 	API extension interface panic codes
       
    37 
       
    38 	@internalTechnology
       
    39 */
       
    40 enum TApiExtPanic
       
    41 	{
       
    42 	EApiExtBadHandle = 0,	//< The session/subsession handle of the extension interface is invalid
       
    43 	EApiExtMetaOverflow,			//< Storing a message into a descriptor has overflowed
       
    44 	};
       
    45 
       
    46 const TUint KMaxExtApiIpcMsgLength = 256;
       
    47 
       
    48 class MCommsApiExtProvider
       
    49 /**
       
    50 Comms API extension provider interface.
       
    51 
       
    52 @internalTechnology
       
    53 */
       
    54 	{
       
    55 public:
       
    56 	virtual TInt Handle() const = 0;
       
    57 	virtual TInt Close(const TIpcArgs& aArgs) const = 0;	
       
    58 	virtual TInt Send(const TIpcArgs& aArgs) const = 0;	
       
    59 	virtual void SendReceive(const TIpcArgs& aArgs,TRequestStatus& aStatus) const = 0;
       
    60 	virtual void Release() = 0;
       
    61 	};
       
    62 
       
    63 class CCommsSessionApiExtProvider : public MCommsApiExtProvider
       
    64 	{
       
    65 	friend class RCommsApiExtensionBase;
       
    66 private:
       
    67 	CCommsSessionApiExtProvider(RCommsSession& session);
       
    68 	static CCommsSessionApiExtProvider *Open(RCommsSession& aExtensionProvider, TSupportedCommsApiExt aInterfaceId, TInt &error);
       
    69 	TInt Close(const TIpcArgs& aArgs) const;	
       
    70 	TInt Handle() const;
       
    71 	TInt Send(const TIpcArgs& aArgs) const;	
       
    72 	void SendReceive(const TIpcArgs& aArgs,TRequestStatus& aStatus) const;
       
    73 	void Release();
       
    74 
       
    75 private:
       
    76 	const RCommsSession iSession;
       
    77 	};
       
    78 	
       
    79 class CCommsSubSessionApiExtProvider : public MCommsApiExtProvider
       
    80 	{
       
    81 	friend class RCommsApiExtensionBase;
       
    82 private:
       
    83 	CCommsSubSessionApiExtProvider(RCommsSubSession& subSession);
       
    84 	static CCommsSubSessionApiExtProvider *Open(RCommsSubSession& aExtensionProvider, TSupportedCommsApiExt aInterfaceId, TInt &error);
       
    85 	TInt Close(const TIpcArgs& aArgs) const;	
       
    86 	TInt Handle() const;
       
    87 	TInt Send(const TIpcArgs& aArgs) const;	
       
    88 	void SendReceive(const TIpcArgs& aArgs,TRequestStatus& aStatus) const;
       
    89 	void Release();
       
    90 
       
    91 private:
       
    92 	const RCommsSubSession iSubSession;
       
    93 	};
       
    94 	
       
    95 	
       
    96 class RCommsApiExtensionBase
       
    97 /**
       
    98 Base class for Comms API extensions.
       
    99 
       
   100 @internalTechnology
       
   101 @released
       
   102 */
       
   103 	{
       
   104 protected:
       
   105 	IMPORT_C explicit RCommsApiExtensionBase();
       
   106 	IMPORT_C TInt Open(RCommsSession& aExtensionProvider, TSupportedCommsApiExt aInterfaceId);
       
   107 	IMPORT_C TInt Open(RCommsSubSession& aExtensionProvider, TSupportedCommsApiExt aInterfaceId);
       
   108 	IMPORT_C void Close();
       
   109 	IMPORT_C void SendRequest(TCommsApiExtReqMsg& aRequestMsg, TDes8& aResponseBuf, TRequestStatus& aStatus);
       
   110 	IMPORT_C void SendMessage(TCommsApiExtReqMsg& aRequestMsg);
       
   111 
       
   112 protected:
       
   113 	MCommsApiExtProvider *iProvider;
       
   114 	TSupportedCommsApiExt iInterfaceId;
       
   115 
       
   116 private:
       
   117 	RPointerArray<Elements::TRBuf8> iBuffers;
       
   118 	};
       
   119 
       
   120 template<TSupportedCommsApiExt T>
       
   121 class RCommsApiExtension : public RCommsApiExtensionBase
       
   122 /**
       
   123 Comms API extensions template. New extension APIs may derive from this template.
       
   124 
       
   125 @internalTechnology
       
   126 @released
       
   127 */
       
   128 	{
       
   129 public:
       
   130 	inline TInt Open(RCommsSession& aExtensionProvider);
       
   131 	inline TInt Open(RCommsSubSession& aExtensionProvider);
       
   132 	};
       
   133 
       
   134 template<TSupportedCommsApiExt T>
       
   135 TInt RCommsApiExtension<T>::Open(RCommsSession& aExtensionProvider)
       
   136 	{
       
   137 	return RCommsApiExtensionBase::Open(aExtensionProvider,T);
       
   138 	}
       
   139 
       
   140 template<TSupportedCommsApiExt T>
       
   141 TInt RCommsApiExtension<T>::Open(RCommsSubSession& aExtensionProvider)
       
   142 	{
       
   143 	return RCommsApiExtensionBase::Open(aExtensionProvider,T);
       
   144 	}
       
   145 
       
   146 #endif // CS_API_EXT_H
       
   147