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