commsfwsupport/commselements/serverden/inc/sd_apiextensionclient.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2008-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 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 #ifndef SYMBIAN_DEN_APIEXTENSION_CLIENT_H
       
    22 #define SYMBIAN_DEN_APIEXTENSION_CLIENT_H
       
    23 
       
    24 #include <elements/metavirtctor.h>
       
    25 #include <elements/sd_std.h>
       
    26 #include <elements/h_trbuf.h>
       
    27 
       
    28 
       
    29 #ifdef _DEBUG
       
    30 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
       
    31 // (if it could happen through user error then you should give it an explicit, documented, category + code)
       
    32 _LIT(KSpecAssert_ElemSvrDenApiXCH, "ElemSvrDenApiXCH");
       
    33 #endif
       
    34 
       
    35 namespace NetInterfaces
       
    36 {
       
    37 class TInterfaceControl;
       
    38 }
       
    39 
       
    40 namespace Elements
       
    41 {
       
    42 class RResponseMsg;
       
    43 }
       
    44 
       
    45 namespace Den
       
    46 {
       
    47 
       
    48 class TApiExtIdentification : public TBuf8<0x10> //flags, interface id, scope id plus reserved for future use
       
    49 /**
       
    50 @internalTechnology
       
    51 */
       
    52 	{
       
    53 public:
       
    54 	//We only use this one ctr by design.
       
    55 	//When used with no params the structure is not initialised and InterfaceId() reads 0.
       
    56 	inline explicit TApiExtIdentification(TInt aInterfaceId = 0, TInt aScopeId = 0)
       
    57 		{
       
    58 		Append(reinterpret_cast<const TUint8*>(&aInterfaceId), sizeof(aInterfaceId));
       
    59 		Append(reinterpret_cast<const TUint8*>(&aScopeId), sizeof(aScopeId));
       
    60 		}
       
    61 
       
    62 	inline TInt InterfaceId() const
       
    63 		{
       
    64 		__ASSERT_DEBUG(Length()>=2*sizeof(TInt), User::Panic(KSpecAssert_ElemSvrDenApiXCH, 1));
       
    65 		return *reinterpret_cast<const TInt*>(Ptr());
       
    66 		}
       
    67 
       
    68 	inline TInt ScopeId() const
       
    69 		{
       
    70 		__ASSERT_DEBUG(Length()>=2*sizeof(TInt), User::Panic(KSpecAssert_ElemSvrDenApiXCH, 2));
       
    71 		return *(reinterpret_cast<const TInt*>(Ptr())+1);
       
    72 		}
       
    73 	};
       
    74 
       
    75 class RApiExtSubSessionBase;
       
    76 class RApiExtSessionBase;
       
    77 
       
    78 //-=========================================================
       
    79 //
       
    80 // Messages
       
    81 //
       
    82 //-=========================================================
       
    83 
       
    84 class TApiExtReqMsg : public Meta::SMetaDataNetCtor
       
    85 /**
       
    86 	A self routing API extension request message.
       
    87 
       
    88 	@internalTechnology
       
    89 */
       
    90 	{
       
    91 public:
       
    92 	//[MZ]: Please consult before thinking of increasing any of these
       
    93 	//values or classification.
       
    94 
       
    95 	/**
       
    96 		Used for in-place (on the stack) reconstruction of the message
       
    97 		@internalTechnology
       
    98 	*/
       
    99 	static const TUint KMaxApiExtIpcMsgExternalisedSize = 512;
       
   100 
       
   101 	/**
       
   102 		Used for in-place (on the stack) reconstruction of the message.
       
   103 		Usually slightly bigger than the externalised form (empty buffers
       
   104 		by value, compression, etc).
       
   105 		@internalTechnology
       
   106 	*/
       
   107 	static const TUint KMaxApiExtIpcMsgStructureSize = KMaxApiExtIpcMsgExternalisedSize + 256;
       
   108 	};
       
   109 
       
   110 class TApiExtSubSessionReqMsg : public TApiExtReqMsg
       
   111 /**
       
   112 	A subsession API extension request message.
       
   113 
       
   114 	@internalTechnology
       
   115 */
       
   116 	{
       
   117 public:
       
   118 	EXPORT_TYPEID_TABLE
       
   119 
       
   120 public:
       
   121 	virtual void DispatchL(NetInterfaces::TInterfaceControl& aIntfCtl,
       
   122 	                       TSubSessionUniqueId aClientUniqueId,
       
   123 	                       Elements::RResponseMsg& aResponseMsg) = 0;
       
   124 	};
       
   125 
       
   126 class TApiExtSessionReqMsg : public TApiExtReqMsg
       
   127 /**
       
   128 	A session API extension request message.
       
   129 
       
   130 	@internalTechnology
       
   131 */
       
   132 	{
       
   133 public:
       
   134 	EXPORT_TYPEID_TABLE
       
   135 
       
   136 public:
       
   137 	virtual void DispatchL(NetInterfaces::TInterfaceControl& aIntfCtl,
       
   138 	                       TSessionUniqueId aClientUniqueId,
       
   139 	                       Elements::RResponseMsg& aResponseMsg) = 0;
       
   140 	};
       
   141 
       
   142 class TApiExtRespMsg : public Meta::SMetaDataECom
       
   143 /**	API extension response message.
       
   144 
       
   145 	@internalTechnology
       
   146 */
       
   147 	{
       
   148 public:
       
   149 	EXPORT_TYPEID_TABLE
       
   150 
       
   151 public:
       
   152 	/** Creates a new API extension message using ECOM.
       
   153 
       
   154     @param aTypeId Id of the class (Composed of Uid of the implementation and an integer sub-type).
       
   155     @return a generic pointer to a specific message if successful, otherwise leaves with system error code.
       
   156     */
       
   157 	IMPORT_C static TApiExtRespMsg* NewL(const Meta::STypeId& aTypeId);
       
   158 
       
   159 	/** Creates a new API extension message using ECOM.
       
   160 
       
   161     @param aMsgBuffer a buffer containing the serialised form of the message object.
       
   162     @return a generic pointer to a specific event if successful, otherwise leaves with system error code.
       
   163     */
       
   164 	IMPORT_C static TApiExtRespMsg* NewL(const TDesC8& aMsgBuffer);
       
   165 	};
       
   166 
       
   167 //-=========================================================
       
   168 //
       
   169 // Client Side APIs
       
   170 //
       
   171 //-=========================================================
       
   172 class RApiExtCommonBase
       
   173 /**
       
   174 	API extension base class
       
   175 
       
   176 	Provides buffer management for asynchronous IPC calls.
       
   177 
       
   178 	@internalTechnology
       
   179 */
       
   180 	{
       
   181 	friend class RApiExtSubSessionBase; //to access iIdentification
       
   182 	friend class RApiExtSessionBase; //to access iIdentification
       
   183 
       
   184 protected:
       
   185 	TInt PrepareForSending(TApiExtReqMsg& aRequestMsg, Elements::TRBuf8*& aBuffer) const;
       
   186 	void Close();
       
   187 
       
   188 protected:
       
   189 	TApiExtIdentification iIdentification; //Interface id, scope id, etc
       
   190 
       
   191 private:
       
   192 	mutable RPointerArray<Elements::TRBuf8> iBuffers;
       
   193 	};
       
   194 
       
   195 class RExtendableSubSessionBase : public RSubSessionBase
       
   196 /**
       
   197 	Base class for client SubSessions supporting extensions.
       
   198 
       
   199 	@internalTechnology
       
   200 */
       
   201 	{
       
   202 	friend class RApiExtSubSessionBase;
       
   203 	};
       
   204 
       
   205 class RApiExtSubSessionBase : public RApiExtCommonBase
       
   206 /**
       
   207 	Base class for client extension interfaces, opened on RExtendableSubSessionBase
       
   208 
       
   209 	@internalTechnology
       
   210 */
       
   211 	{
       
   212 public:
       
   213 	IMPORT_C void Close();
       
   214 
       
   215 protected:
       
   216 	IMPORT_C TInt Open(RExtendableSubSessionBase& aExtendableInterface, TInt aInterfaceId);
       
   217 	IMPORT_C void SendReceive(TApiExtReqMsg& aMsg, TDes8& aReqAndRespBuf, TRequestStatus& aStatus) const;
       
   218 	IMPORT_C void SendReceive(TApiExtReqMsg& aMsg, TDes8& aReqAndRespBuf, TDes8& aReqAndRespBuf2, TRequestStatus& aStatus) const;
       
   219 	IMPORT_C void Send(TApiExtReqMsg& aMsg, TRequestStatus& aStatus) const;
       
   220 	IMPORT_C void Send(TApiExtReqMsg& aMsg, TDes8& aReqAndRespBuf2, TRequestStatus& aStatus) const;
       
   221 	IMPORT_C void Send(TApiExtReqMsg& aMsg, const RHandleBase& aHandleBase, TRequestStatus& aStatus) const;
       
   222 
       
   223 protected:
       
   224 	RExtendableSubSessionBase iSubSession;
       
   225 	};
       
   226 
       
   227 class RExtendableSessionBase : public RSessionBase
       
   228 /**
       
   229 	Base class for client Sessions supporting extensions.
       
   230 
       
   231 	@internalTechnology
       
   232 */
       
   233 	{
       
   234 	friend class RApiExtSessionBase;
       
   235 	};
       
   236 
       
   237 class RApiExtSessionBase : public RApiExtCommonBase
       
   238 /**
       
   239 	Base class for client extension interfaces, opened on RExtendableSessionBase
       
   240 
       
   241 	@internalTechnology
       
   242 */
       
   243 	{
       
   244 public:
       
   245 	IMPORT_C void Close();
       
   246 
       
   247 protected:
       
   248 	IMPORT_C TInt Open(RExtendableSessionBase& aExtendableInterface, TInt aInterfaceId);
       
   249 	IMPORT_C void SendReceive(TApiExtReqMsg& aMsg, TDes8& aReqAndRespBuf, TRequestStatus& aStatus) const;
       
   250 	IMPORT_C void SendReceive(TApiExtReqMsg& aMsg, TDes8& aReqAndRespBuf, TDes8& aReqAndRespBuf2, TRequestStatus& aStatus) const;
       
   251 	IMPORT_C void Send(TApiExtReqMsg& aMsg, TRequestStatus& aStatus) const;
       
   252 	IMPORT_C void Send(TApiExtReqMsg& aMsg, TDes8& aReqAndRespBuf2, TRequestStatus& aStatus) const;
       
   253 	IMPORT_C void Send(TApiExtReqMsg& aMsg, const RHandleBase& aHandleBase, TRequestStatus& aStatus) const;
       
   254 
       
   255 protected:
       
   256 	RExtendableSessionBase iSession;
       
   257 	};
       
   258 
       
   259 } //namespace Den
       
   260 
       
   261 #endif //SYMBIAN_DEN_APIEXTENSION_CLIENT_H
       
   262