wapstack/wapmessageapi/sws/WapMessageApiAgent.h
author hgs
Mon, 19 Jul 2010 14:53:33 +0100
changeset 52 60785a088077
parent 44 8b72faa1200f
permissions -rw-r--r--
201025_04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     2
// All rights reserved.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     7
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     8
// Initial Contributors:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    10
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    11
// Contributors:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    12
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    13
// Description:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    14
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    15
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    16
#ifndef __MSGAPIAGENT_H__
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    17
#define __MSGAPIAGENT_H__
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    18
#include "ActiveSocket.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    19
#include "WapSwsTimeOut.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    20
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    21
class MProgressNotify
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    22
/** 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    23
Interface from the ActiveSocket to MessageApiAgent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    24
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    25
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    26
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    27
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    28
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    29
	public:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    30
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    31
	The interface that will be called when WDP pdu length and data are received by CActiveSocket.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    32
	@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    33
	@param aMessage the message type received from CActiveSocket
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    34
	@param aData the data received from CActiveSocket
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    35
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    36
	virtual void Notification(TInt aMessage, const TDesC8& aData) = 0;	
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    37
	};
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    38
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    39
class CWapAsyncCallBack : public CActive
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    40
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    41
public:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    42
	CWapAsyncCallBack( const TCallBack& aCallBack, TInt aPriority );
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    43
	~CWapAsyncCallBack();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    45
public: // API
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    46
	void CallBack();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    47
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    48
private:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    49
	void RunL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    50
	void DoCancel();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    51
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    52
private:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    53
	TCallBack iCallBack;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    54
	};
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    55
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    56
class CWapMessageApiAgent : public CBase, public MTimeOutNotify, public MProgressNotify
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    57
/** 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    58
The base class of CWspMessageApiAgent and CWdpMessageApiAgent, which handle Wsp and Wdp
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    59
for SWS message APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    60
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    61
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    62
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    63
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    64
{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    65
public:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    66
	virtual ~CWapMessageApiAgent();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    67
	void ConstructL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    68
	CActiveSocket* GetActiveSocketByBearer(Wap::TBearer aBearer);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    69
	CActiveSocket* GetActiveSocketByStatus(TWapMessageState aState);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    70
	TInt Connect(Wap::TBearer aBearer, Wap::TPort aPort, TBool aSecure);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    71
	TInt Connect(Wap::TBearer aBearer, Wap::TPort aPort, TBool aSecure, TInetAddr aInetAddr);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    72
	TInt Connect(Wap::TBearer aBearer, Wap::TPort aPort, TBool aSecure, TInt aSocketServHandle, RConnection* aConnection);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    73
	TInt Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer, TBool aSecure, TInetAddr aInetAddr);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    74
	TInt Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer, TBool aSecure);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    75
	TInt Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer, TBool aSecure, TInt aSocketServHandle, RConnection* aConnection);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    76
	TInt GetLocalPort(Wap::TPort& aPort);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    77
	TInt GetLocalAddress(HBufC8*& aLocalHost);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    78
	TInt GetBearer(Wap::TBearer& aBearer);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    79
	TInt GetServerAddress(HBufC8*& aRemoteHost);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    80
	virtual void TimerExpired();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    81
	void CancelRequest();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    82
	static TInt CompleteReading(TAny* aAgent);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    83
protected:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    84
	CWapMessageApiAgent(TWapMessageType aMessageType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    85
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    86
	RSocketServ instance used by all the bearers.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    87
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    88
	RSocketServ iSocketServ;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    89
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    90
	The array to contain all the bearers
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    91
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    92
	RPointerArray<CActiveSocket> iBearers;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    93
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    94
	The Wdp and Wsp receiving timer.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    95
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    96
	CTimeOutTimer* iTimeoutTimer;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    97
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    98
	Flag the show if there is outstanding request.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    99
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   100
	TBool iRequestActive;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   101
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   102
	The pointer to Wap message client's request status
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   103
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   104
	TRequestStatus* iRequestStatus;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   105
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   106
	The last error code of active socket in reading state
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   107
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   108
	TInt iLastReadingError;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   109
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   110
	The asynchronous completion of reading
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   111
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   112
	CWapAsyncCallBack* iAsyncReadCompletion;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   113
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   114
	The bearer that receives that last PDU
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   115
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   116
	Wap::TBearer iLastPduBearer;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   117
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   118
	Flag to show if the API has been connected or not
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   119
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   120
	TBool iIsOpen;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   121
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   122
	The type of the Wap message handled by this API agent.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   123
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   124
	TWapMessageType iMessageType;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   125
private:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   126
	TInt DoCompleteReading();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   127
};
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   128
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   129
class CWspMessageApiAgent : public CWapMessageApiAgent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   130
/** 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   131
The class to handle Wsp PDU for SWS message APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   132
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   133
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   134
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   135
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   136
{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   137
public:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   138
	static CWspMessageApiAgent* NewL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   139
	CWspMessageApiAgent();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   140
	virtual ~CWspMessageApiAgent();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   141
	void ConstructL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   142
	TInt SendWspMessage(Wap::TBearer aBearer, const TDesC8& aRemoteHost, Wap::TPort aRemotePort, TUint aMethod, const TDesC& aURI, const TDesC8& aReqHeaders, const TDesC8& aReqBody, TUint8 aTransactionId);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   143
	TInt SendWspMessage(TUint aMethod, const TDesC& aURI, const TDesC8& aReqHeaders, const TDesC8& aReqBody, TUint8 aTransactionId);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   144
	TInt ReceiveWspMessage(TDes8& aWspHeaders, TDes8& aWspBody, TPckgBuf<TUint8>& aPushIdPckg, TWSPStatus& aWspStatus, TRequestStatus& aReqStatus, TUint32 aTimeout);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   145
	virtual void Notification(TInt aMessage, const TDesC8& aData);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   146
private:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   147
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   148
	The pointer to the WSP message client's requested header buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   149
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   150
	TDes8* iClientReqHeaders;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   151
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   152
	The pointer to the WSP message client's requested body buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   153
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   154
	TDes8* iClientReqBody;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   155
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   156
	The pointer to the WSP message client's requested transaction ID.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   157
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   158
	TUint8*	iClientTransactionId;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   159
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   160
	The pointer to the WSP message client's requested WSP status.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   161
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   162
	TWSPStatus* iClientWspStatus;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   163
};
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   164
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   165
class CWdpMessageApiAgent : public CWapMessageApiAgent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   166
/** 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   167
The class to handle Wdp PDU for SWS message APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   168
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   169
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   170
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   171
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   172
{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   173
public:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   174
	static CWdpMessageApiAgent* NewL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   175
	CWdpMessageApiAgent();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   176
	virtual ~CWdpMessageApiAgent();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   177
	void ConstructL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   178
	TInt ReceiveWdpMessage(TDes8& aRemoteHost, Wap::TPort& aRemotePort, TDes8& aBuffer, TBool& aTruncated, TRequestStatus& aReqStatus, TUint32 aTimeout);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   179
	TInt AwaitRecvDataSize(TPckg<TUint16>& aDataSizePckg, TRequestStatus& aReqStatus);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   180
	TInt SendWdpMessage(const TDesC8& aBuffer, const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   181
	TInt SendWdpMessage(const TDesC8& aBuffer);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   182
	virtual void Notification(TInt aMessage, const TDesC8& aData);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   183
private:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   184
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   185
	The pointer to Wdp message client's requested data buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   186
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   187
	TDes8*	iClientPduBuffer;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   188
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   189
	The pointer to Wdp message client's request data size
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   190
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   191
	TPckg<TUint16>* iClientDataSize;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   192
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   193
	The pointer to client's requested remote host buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   194
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   195
	TDes8* iClientRemoteHost;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   196
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   197
	The pointer to client's requested remote port buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   198
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   199
	Wap::TPort* iClientRemotePort;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   200
	/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   201
	The pointer to client's requested flag.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   202
	*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   203
	TBool* iClientTruncated;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   204
};
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   205
#endif //__MSGAPIAGENT_H__