messagingfw/wappushfw/tpush/DummyStack/dummywapstack.h
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2000-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 #ifndef __DUMMYWAPSTACK_H__
       
    18 #define __DUMMYWAPSTACK_H__
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <e32std.h>
       
    22 #include "Dummywapstd.h"
       
    23 #include "DummyWapClient.h"
       
    24 
       
    25 /**
       
    26  *forward declaration
       
    27  */
       
    28 class CDummyWapSession;
       
    29 class CDummyWSPCLConn;
       
    30 class CDummyWSPCOConn;
       
    31 class CDummyWapStack;
       
    32 class CDummyWSPCOTrans;
       
    33 class CDummyWTLS;
       
    34 typedef TUint16 TPort;
       
    35 
       
    36 
       
    37 
       
    38 /**
       
    39  * Mixin class to allow communication between dummy stack and test harness
       
    40  */
       
    41 class MDummyWapStackObserver
       
    42 	{
       
    43 public:
       
    44 	virtual void DWSOUnitWaitPushL(CDummyWSPCLConn& aDummyCLConn)=0;
       
    45 	virtual void DWSOCancelUnitWaitPush(CDummyWSPCLConn& aDummyCLConn)=0;
       
    46 	virtual void DWSOServerShutDown()=0;
       
    47 	virtual void DWSOError(const TDesC& aDes, TInt aLineNum)=0;
       
    48 	virtual void DWSOConnect(CDummyWSPCOConn& aDummyCOConn)=0;
       
    49 	virtual void DWSOGetEventL(CDummyWSPCOConn& aDummyCOConn)=0;
       
    50 	virtual void DWSOCancelGetEvent(CDummyWSPCOConn& aDummyCOConn)=0;
       
    51 	virtual void DWSOAckTransaction(CDummyWSPCOTrans& aDummyCOTrans)=0;
       
    52 	};
       
    53 
       
    54 
       
    55 /**
       
    56  * This is the 'dummy' equivalent of the WAP stack server
       
    57  * 
       
    58  * It uses the singleton design pattern to ensure there is only one
       
    59  * instance of this object. It is responsible for creating and managing
       
    60  * client sessions with the server.
       
    61  */
       
    62 class CDummyWapStack : public CBase
       
    63 	{
       
    64 public:
       
    65 	IMPORT_C static CDummyWapStack* NewL(MDummyWapStackObserver& aObserver); 
       
    66 	~CDummyWapStack();
       
    67 
       
    68 	IMPORT_C CDummyWapSession* NewSessionL();
       
    69 	IMPORT_C void CloseSession(CDummyWapSession* aDummyWapSession);
       
    70 	//
       
    71 	IMPORT_C MDummyWapStackObserver& Observer();
       
    72 private:	
       
    73 	CDummyWapStack(MDummyWapStackObserver& aObserver);
       
    74 	void ConstructL();
       
    75 	CDummyWapStack* StackInstance(){return STATIC_CAST(CDummyWapStack* , Dll::Tls());};//return unique instance
       
    76 	void FreeTls();
       
    77 private:
       
    78 	MDummyWapStackObserver& iObserver;
       
    79 	RPointerArray<CDummyWapSession> iSessionsArray;
       
    80 	CDummyWapStack* iInstance;
       
    81 	};
       
    82  
       
    83 
       
    84 /**
       
    85  * This is the 'dummy' equivalent of a single client session with the server 
       
    86  *
       
    87  * It represents the CWAPSession class, which is reponsible for creating and
       
    88  * managing subsessions, ie. individual connections (CWAPConn objects)
       
    89  */
       
    90 class CDummyWapSession : public CBase
       
    91 	{
       
    92 public:
       
    93 	static CDummyWapSession* NewL();
       
    94 	~CDummyWapSession();
       
    95 
       
    96 	CDummyWSPCLConn* NewWSPCLConnL(TPort aLocalPort);
       
    97 	CDummyWSPCOConn* NewWSPCOConnL();
       
    98 	
       
    99 	void Close();
       
   100 private:
       
   101 	void ConstructL();
       
   102 private:
       
   103 	TInt iReferenceCount;
       
   104 	};
       
   105 
       
   106 
       
   107 /**
       
   108  * Base class for all 'dummy' WSP connections. 
       
   109  *
       
   110  * This is required so that the RWAPConn base class can correctly close the 
       
   111  * CDummy... classes, because the base class doesn't implement a virtual 
       
   112  * Close method
       
   113  */
       
   114 class CDummyWSPConn : public CBase
       
   115 	{
       
   116 public:
       
   117 	CDummyWSPConn(CDummyWapSession& aSession);
       
   118 	virtual void Close();
       
   119 	CDummyWTLS* WtlsL();
       
   120 private:
       
   121 	CDummyWapSession& iSession;
       
   122 	CDummyWTLS* iWtls;
       
   123 	};
       
   124 
       
   125 #ifndef __WAPMESSAGE_H__
       
   126 #ifndef __DUMMYWAPCLIENT_H__
       
   127 namespace Wap
       
   128 	{
       
   129 	// Bearer type definition
       
   130 	typedef enum
       
   131 		{
       
   132 		EAll,
       
   133 		EIP,
       
   134 		ESMS7,
       
   135 		ESMS,
       
   136 		EWAPSMS7,
       
   137 		EWAPSMS
       
   138 		} TBearer;
       
   139 
       
   140 	// Port number definition
       
   141 	typedef TUint16 TPort;
       
   142  
       
   143 	}
       
   144 #endif
       
   145 #endif
       
   146 
       
   147 /** 
       
   148  *  Dummy connectionless connection
       
   149  */
       
   150 class CDummyWSPCLConn : public CDummyWSPConn
       
   151 	{
       
   152 public:
       
   153 	CDummyWSPCLConn(CDummyWapSession& aSession, TPort aLocalPort);
       
   154 	~CDummyWSPCLConn();
       
   155 	virtual TInt Connect(Wap::TBearer aBearer, Wap::TPort aPort, TBool aSecure);
       
   156 	TInt AwaitPush(TDes8& aPushHeaders, TDes8& aPushBody, TPckgBuf<TUint8>& aPushIdPckg, TRequestStatus& aReqStatus);
       
   157 	void UnitWaitPushL(TDes8& aBody,TDes8& aHeaders,TPushID& aID,TRequestStatus& aStatus);
       
   158 	TInt CancelUnitWaitPush();
       
   159 	TInt CancelAwaitPush(); 
       
   160 	IMPORT_C void CompleteUnitWaitPushL(TDes8& aBody,TDes8& aHeaders);
       
   161 	TInt UnitWaitPushL(TDes8& aBody,TDes8& aHeaders,TPushID& aID);//Sync Version
       
   162 	IMPORT_C TBool HasMsgBeenCompleted();
       
   163 	inline TPort LocalPort(){return iLocalPort;}
       
   164 	IMPORT_C void SetServerAddressL(const TDesC8& aAddr);
       
   165 	const TDesC8& GetServerAddr();
       
   166 private:
       
   167 	TDes8*	 iClientBody;
       
   168 	TDes8*	 iClientHeaders;
       
   169 	TPushID* iID;
       
   170 	TRequestStatus* iStatus;
       
   171 	//
       
   172 	HBufC8* iPushHeadersData;
       
   173 	TInt iPushHeadersDataOffset;
       
   174 	HBufC8* iPushBodyData;
       
   175 	TInt iPushBodyDataOffset;
       
   176 	TPort iLocalPort; //using port we can identify this CL as either secure or unsecure 
       
   177 	HBufC8* iServerAddr;
       
   178 	};
       
   179 
       
   180 
       
   181 
       
   182 /** 
       
   183  * Dummy connection-orientated transaction
       
   184  */
       
   185 class CDummyWSPCOTrans : public CBase
       
   186 	{
       
   187 public:
       
   188 	IMPORT_C CDummyWSPCOTrans(CDummyWSPCOConn& aConnection);
       
   189 	IMPORT_C ~CDummyWSPCOTrans();
       
   190 	TInt Acknowledge(const TDesC8& aAckHeaders);
       
   191 	TInt GetData(TDes8& aBuffer, RWSPCOTrans::TDataType aDataType, TInt* aSizeLeft = 0) const;
       
   192 	TInt GetState(RWSPCOTrans::TState& aState) const;
       
   193 	TInt Abort(RWSPCOTrans::TAbortReason aReason);
       
   194 	TInt Release();
       
   195 	TInt Id(RWSPCOTrans::TTransID& aId);
       
   196 	//for testcode
       
   197 	IMPORT_C void SetData(const TDesC8& aBuffer,RWSPCOTrans::TDataType aDataType);
       
   198 	IMPORT_C void SetId(TInt aId);
       
   199 private:
       
   200 	CDummyWSPCOConn& iConnection;
       
   201 	RWSPCOTrans::TState iTransState;
       
   202 	TInt iId;
       
   203 
       
   204 	//TFixedArray<const TDesC8**,11> iDataArray;
       
   205 	TFixedArray<const TDesC8*,11> iDataArray;
       
   206 	TFixedArray<TInt*,11> iOffsetArray;
       
   207 	
       
   208 	const TDesC8* iClientAckHeaders;
       
   209 	};
       
   210 
       
   211 
       
   212 
       
   213 
       
   214 /**
       
   215  *  Dummy connection-orientated connection
       
   216  */
       
   217 class CDummyWSPCOConn : public CDummyWSPConn
       
   218 	{
       
   219 public:
       
   220 	CDummyWSPCOConn(CDummyWapSession& aSession);
       
   221 	~CDummyWSPCOConn();
       
   222 
       
   223 	TInt Connect(const TDesC8& aClientHeaders, class CCapCodec* aCap);
       
   224 	TInt Disconnect();
       
   225 	TInt GetSessionState(RWSPCOConn::TSessionState& aState);
       
   226 	TInt GetEvent(RWSPCOConn::TEvent& aEvent, RWSPCOTrans& aTrans, TRequestStatus& aStatus);
       
   227 	IMPORT_C void CancelGetEvent();
       
   228 	TInt GetNrOfEvents(TUint& aNrOfEvents);
       
   229 	//for testcode
       
   230 	IMPORT_C void CompleteGetEventL(RWSPCOConn::TEvent& aEvent,CDummyWSPCOTrans& aDummyTrans);
       
   231 	void RemoveTransaction(CDummyWSPCOTrans& aTrans);
       
   232 private:
       
   233 	const TDesC8* iClientHeaders;
       
   234 	CCapCodec* iCapCodec;
       
   235 	RWSPCOConn::TSessionState iSessionState;
       
   236 	RPointerArray<CDummyWSPCOTrans> iTransArray;
       
   237 
       
   238 	RWSPCOConn::TEvent* iEvent;
       
   239 	RWSPCOTrans* iTrans;
       
   240 	TRequestStatus* iStatus;
       
   241 	};
       
   242 
       
   243 
       
   244 
       
   245 
       
   246 
       
   247 /** 
       
   248  * Dummy WTLS 
       
   249  */
       
   250 class CDummyWTLS : public CBase
       
   251 	{
       
   252 public:
       
   253 	CDummyWTLS();
       
   254 	~CDummyWTLS();
       
   255 
       
   256 	TInt SetKeyExchangeSuite(RWTLS::TKeyExchangeSuite aSuite,RWTLS::TIdType IdType,const TDesC8& aKeyId);
       
   257 	TInt SetCipherSuites(const RWTLS::CipherSuiteArray& aCipherSuites);
       
   258 	TInt SetSequenceNumberMode(RWTLS::TSequenceNumberMode aMode);
       
   259 	TInt SetKeyRefreshRate(TUint8 aRate);
       
   260 	TInt SetSharedSecret(const TDesC8& aSharedSecret);
       
   261 	TInt SetRecordLengthUsage(TBool aUsage);
       
   262 	void Connect(TRequestStatus& aStatus, TBool aTwoPhaseHandshake);
       
   263 	void CancelConnect();
       
   264 	TInt ConnectPhaseTwo(TRequestStatus& aStatus);
       
   265 	void CancelConnectPhaseTwo();
       
   266 	TInt GetCipherSuite(RWTLS::TCipherSuite& aCipherSuite) const;
       
   267 	TInt GetSequenceNumberMode(RWTLS::TSequenceNumberMode& aMode) const;
       
   268 	TInt GetKeyRefreshRate(TUint8& aRate) const;
       
   269 private:
       
   270 	TRequestStatus* iConnect;
       
   271 	TRequestStatus* iConnectPhaseTwo;
       
   272 	TBool iTwoPhaseHandshake;
       
   273 	RWTLS::TSequenceNumberMode iSequenceNumMode;
       
   274 	TUint8 iKeyRefreshRate;
       
   275 	TBool iRecordLenUsage;
       
   276 	};
       
   277 
       
   278 #endif