44
|
1 |
// Copyright (c) 2003-2010 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 |
//
|
45
|
15 |
#include "OstTraceDefinitions.h"
|
|
16 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
17 |
#include "ActiveSocketTraces.h"
|
|
18 |
#endif
|
44
|
19 |
|
|
20 |
#include "ActiveSocket.h"
|
|
21 |
#include <es_wsms.h>
|
|
22 |
#include "CLWSPPduHandler.h"
|
|
23 |
#include "wapmsgerr.h"
|
|
24 |
#include <wap_sock.h>
|
|
25 |
#include "WapMessageApiAgent.h"
|
|
26 |
#include "WapMsgUtils.h"
|
|
27 |
|
|
28 |
using namespace Wap;
|
|
29 |
|
|
30 |
void CActiveSocket::NewL(RSocketServ& aSocketServ, RPointerArray<CActiveSocket>& aActiveSockets, Wap::TBearer aBearer, TWapMessageType aType, MProgressNotify* aNotify, Wap::TPort aLocalPort, RConnection* aConnection)
|
|
31 |
/**
|
|
32 |
The static new function instanciates corresponding Bearers in terms of the input bearer type.
|
|
33 |
This function is used by Bound Wap APIs which listen the incoming packet to a specific port.
|
|
34 |
@internalComponent
|
|
35 |
@released
|
|
36 |
@since v8.0
|
|
37 |
@param aSocketServ the shared RSocketServ instance used in the Wap messaging API which owns this bearer
|
|
38 |
@param aActiveSockets the bearer array used in the Wap messaging API which owns the bearer
|
|
39 |
@param aBearer the bearer to listen on (use EAll for all bearers)
|
|
40 |
@param aType the type of the wap message that will received
|
|
41 |
@param aNotify the instance to be notified when a wap message is received
|
|
42 |
@param aLocalPort the port to listen on
|
|
43 |
@param aConnection the shared connection from Wap messaging API client
|
|
44 |
*/
|
|
45 |
{
|
|
46 |
//Instanciate the corresponding
|
|
47 |
switch(aBearer)
|
|
48 |
{
|
|
49 |
case Wap::ESMS7:
|
|
50 |
case Wap::ESMS:
|
|
51 |
case Wap::EWAPSMS7:
|
|
52 |
case Wap::EWAPSMS:
|
|
53 |
{
|
|
54 |
CActiveSocket* me = new(ELeave) CActiveSocketSMS(aSocketServ, aNotify, aBearer, aLocalPort);
|
|
55 |
CleanupStack::PushL(me);
|
|
56 |
me->ConstructL(aType);
|
|
57 |
aActiveSockets.AppendL(me);
|
|
58 |
CleanupStack::Pop(me);
|
|
59 |
break;
|
|
60 |
}
|
|
61 |
case Wap::EIP:
|
|
62 |
{
|
|
63 |
CActiveSocket* me = new(ELeave) CActiveSocketUDP(aSocketServ, aNotify, aBearer, aLocalPort, aConnection);
|
|
64 |
CleanupStack::PushL(me);
|
|
65 |
me->ConstructL(aType);
|
|
66 |
aActiveSockets.AppendL(me);
|
|
67 |
CleanupStack::Pop(me);
|
|
68 |
break;
|
|
69 |
}
|
|
70 |
case Wap::EAll:
|
|
71 |
{
|
|
72 |
CActiveSocket* me = new(ELeave) CActiveSocketUDP(aSocketServ, aNotify, Wap::EIP, aLocalPort, aConnection);
|
|
73 |
CleanupStack::PushL(me);
|
|
74 |
me->ConstructL(aType);
|
|
75 |
CActiveSocket* me1 = new(ELeave) CActiveSocketSMS(aSocketServ, aNotify, Wap::ESMS, aLocalPort);
|
|
76 |
CleanupStack::PushL(me1);
|
|
77 |
me1->ConstructL(aType);
|
|
78 |
aActiveSockets.ReserveL(2); // pre-allocate the memory
|
|
79 |
aActiveSockets.AppendL(me1);
|
|
80 |
CleanupStack::Pop(me1);
|
|
81 |
aActiveSockets.AppendL(me);
|
|
82 |
CleanupStack::Pop(me);
|
|
83 |
break;
|
|
84 |
}
|
|
85 |
default:
|
|
86 |
{
|
45
|
87 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_NEWL_1, "CActiveSocket::NewL Unknown Bearer Type");
|
44
|
88 |
User::Leave(Wap::EBearerError);
|
|
89 |
}
|
|
90 |
}
|
|
91 |
}
|
|
92 |
|
|
93 |
void CActiveSocket::NewL(RSocketServ& aSocketServ, RPointerArray<CActiveSocket>& aActiveSockets, Wap::TBearer aBearer, TWapMessageType aType, MProgressNotify* aNotify, const TSockAddr& aRemoteAddr, RConnection* aConnection)
|
|
94 |
/**
|
|
95 |
The static new function instanciates corresponding Bearers in terms of the input bearer type.
|
|
96 |
This function is used by Fully specified Wap APIs which will open a socket with a single, named remote host.
|
|
97 |
@internalComponent
|
|
98 |
@released
|
|
99 |
@since v8.0
|
|
100 |
@param aSocketServ the shared RSocketServ instance used in the Wap messaging API which owns this bearer
|
|
101 |
@param aActiveSockets the bearer array used in the Wap messaging API which owns the bearer
|
|
102 |
@param aBearer the bearer to listen on (use EAll for all bearers)
|
|
103 |
@param aType the type of the wap message that will received
|
|
104 |
@param aNotify the instance to be notified when a wap message is received
|
|
105 |
@param aRemoteAddr the remote host to be communicate with
|
|
106 |
@param aConnection the shared connection from Wap messaging API client
|
|
107 |
*/
|
|
108 |
{
|
|
109 |
//Instanciate the corresponding
|
|
110 |
switch(aBearer)
|
|
111 |
{
|
|
112 |
case Wap::ESMS7:
|
|
113 |
case Wap::ESMS:
|
|
114 |
case Wap::EWAPSMS7:
|
|
115 |
case Wap::EWAPSMS:
|
|
116 |
{
|
|
117 |
CActiveSocket* me = new(ELeave) CActiveSocketSMS(aSocketServ, aNotify, aBearer, aRemoteAddr);
|
|
118 |
CleanupStack::PushL(me);
|
|
119 |
me->ConstructL(aType);
|
|
120 |
aActiveSockets.AppendL(me);
|
|
121 |
CleanupStack::Pop(me);
|
|
122 |
break;
|
|
123 |
}
|
|
124 |
case Wap::EIP:
|
|
125 |
{
|
|
126 |
CActiveSocket* me = new(ELeave) CActiveSocketUDP(aSocketServ, aNotify, aBearer, aRemoteAddr, aConnection);
|
|
127 |
CleanupStack::PushL(me);
|
|
128 |
me->ConstructL(aType);
|
|
129 |
aActiveSockets.AppendL(me);
|
|
130 |
CleanupStack::Pop(me);
|
|
131 |
break;
|
|
132 |
}
|
|
133 |
case Wap::EAll:
|
|
134 |
{
|
|
135 |
CActiveSocket* me = new(ELeave) CActiveSocketUDP(aSocketServ, aNotify, aBearer, aRemoteAddr, aConnection);
|
|
136 |
CleanupStack::PushL(me);
|
|
137 |
me->ConstructL(aType);
|
|
138 |
CActiveSocket* me1 = new(ELeave) CActiveSocketSMS(aSocketServ, aNotify, aBearer, aRemoteAddr);
|
|
139 |
CleanupStack::PushL(me1);
|
|
140 |
me1->ConstructL(aType);
|
|
141 |
aActiveSockets.ReserveL(2); // pre-allocate the memory
|
|
142 |
aActiveSockets.AppendL(me1);
|
|
143 |
CleanupStack::Pop(me1);
|
|
144 |
aActiveSockets.AppendL(me);
|
|
145 |
CleanupStack::Pop(me);
|
|
146 |
break;
|
|
147 |
}
|
|
148 |
default:
|
|
149 |
{
|
45
|
150 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_NEWL_1_1, "CActiveSocket::NewL Unknown Bearer Type");
|
44
|
151 |
User::Leave(Wap::EBearerError);
|
|
152 |
}
|
|
153 |
}
|
|
154 |
}
|
|
155 |
|
|
156 |
CActiveSocket::CActiveSocket(RSocketServ& aSocketServ, Wap::TBearer aBearerType, MProgressNotify* aNotify, Wap::TPort aLocalPort)
|
|
157 |
:CActive(EPriorityStandard), iLocalAddr(0), iSocketServ(aSocketServ), iBearerType(aBearerType), iLocalPort(aLocalPort), iSocketState(ESocketIdle),iNotify(aNotify), iBuf(0,0), iRxlength(0), iBufCon(0,0)
|
|
158 |
/**
|
|
159 |
Constructor of bearer base class for Bound Wap APIs
|
|
160 |
@internalComponent
|
|
161 |
@released
|
|
162 |
@since v8.0
|
|
163 |
*/
|
|
164 |
{
|
|
165 |
CActiveScheduler::Add(this);
|
|
166 |
}
|
|
167 |
|
|
168 |
CActiveSocket::CActiveSocket(RSocketServ& aSocketServ, Wap::TBearer aBearerType, MProgressNotify* aNotify, const TSockAddr& aRemoteAddr, Wap::TPort aLocalPort): CActive(EPriorityStandard),
|
|
169 |
iRemoteAddr(aRemoteAddr), iLocalAddr(0), iSocketServ(aSocketServ), iBearerType(aBearerType), iLocalPort(aLocalPort), iSocketState(ESocketIdle), iNotify(aNotify), iBuf(0,0), iRxlength(0), iBufCon(0,0)
|
|
170 |
/**
|
|
171 |
Constructor of bearer base class for fully specified Wap APIs
|
|
172 |
@internalComponent
|
|
173 |
@released
|
|
174 |
@since v8.0
|
|
175 |
*/
|
|
176 |
{
|
|
177 |
CActiveScheduler::Add(this);
|
|
178 |
}
|
|
179 |
|
|
180 |
CActiveSocket::~CActiveSocket()
|
|
181 |
/**
|
|
182 |
Destructor
|
|
183 |
@internalComponent
|
|
184 |
@released
|
|
185 |
@since v8.0
|
|
186 |
*/
|
|
187 |
{
|
|
188 |
Cancel();
|
|
189 |
iSocket.Close();
|
|
190 |
if (iMessageRecord)
|
|
191 |
{
|
|
192 |
delete iMessageRecord;
|
|
193 |
}
|
|
194 |
}
|
|
195 |
|
|
196 |
void CActiveSocket::ConstructL(TWapMessageType aType)
|
|
197 |
/**
|
|
198 |
Second Phase Constructor
|
|
199 |
@internalComponent
|
|
200 |
@released
|
|
201 |
@param aType the type of Wap message which is received.
|
|
202 |
@since v8.0
|
|
203 |
*/
|
|
204 |
{
|
|
205 |
iMessageRecord=CWapMessageRecord::NewL(aType);
|
|
206 |
}
|
|
207 |
|
|
208 |
RSocket& CActiveSocket::Socket()
|
|
209 |
/**
|
|
210 |
To get the RSocket instance ownd by this bearer
|
|
211 |
@internalComponent
|
|
212 |
@released
|
|
213 |
@since v8.0
|
|
214 |
@returns the reference of the RSocket instance.
|
|
215 |
*/
|
|
216 |
{
|
|
217 |
return iSocket;
|
|
218 |
}
|
|
219 |
|
|
220 |
Wap::TBearer CActiveSocket::GetBearerType()
|
|
221 |
/**
|
|
222 |
To get the bearer type of this bearer
|
|
223 |
@internalComponent
|
|
224 |
@released
|
|
225 |
@since v8.0
|
|
226 |
@returns the bearer type
|
|
227 |
*/
|
|
228 |
{
|
|
229 |
return iBearerType;
|
|
230 |
}
|
|
231 |
|
|
232 |
TSockAddr& CActiveSocket::GetLocalAddress()
|
|
233 |
/**
|
|
234 |
To get the local address of this bearer
|
|
235 |
@internalComponent
|
|
236 |
@released
|
|
237 |
@since v8.0
|
|
238 |
@returns the lcoal address instance
|
|
239 |
*/
|
|
240 |
{
|
|
241 |
iSocket.LocalName(iLocalAddr);
|
|
242 |
return iLocalAddr;
|
|
243 |
}
|
|
244 |
|
|
245 |
TSockAddr& CActiveSocket::GetRemoteAddress()
|
|
246 |
/**
|
|
247 |
To get the remote address of the last received packet
|
|
248 |
@internalComponent
|
|
249 |
@released
|
|
250 |
@since v8.0
|
|
251 |
@returns the remote address instance
|
|
252 |
*/
|
|
253 |
{
|
|
254 |
return iRemoteAddr;
|
|
255 |
}
|
|
256 |
|
|
257 |
TInt CActiveSocket::GetRemoteAddress(HBufC8*& aAddr)
|
|
258 |
/**
|
|
259 |
To get the remote address of the last received packet
|
|
260 |
@internalComponent
|
|
261 |
@released
|
|
262 |
@since v8.0
|
|
263 |
@param aAddr the remote host name
|
|
264 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
265 |
*/
|
|
266 |
{
|
|
267 |
TRAPD(err, aAddr=iRemoteAddr.AllocL())
|
|
268 |
if (err==KErrNone)
|
|
269 |
{
|
|
270 |
Wap::TPort port;
|
|
271 |
TPtr8 des=aAddr->Des();
|
|
272 |
TRAP(err, CSWSWapMsgUtils::AnalyseAddrL(iRemoteAddr, iBearerType, des, port))
|
|
273 |
}
|
|
274 |
else
|
|
275 |
{
|
45
|
276 |
OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_GETREMOTEADDRESS_1, "CActiveSocket::GetRemoteAddress: Alloc Memory Err=%d", err);
|
44
|
277 |
}
|
|
278 |
return err;
|
|
279 |
}
|
|
280 |
|
|
281 |
TInt CActiveSocket::GetLocalPort(Wap::TPort& aLocalPort)
|
|
282 |
/**
|
|
283 |
To get the lcoal port of this bearer
|
|
284 |
@internalComponent
|
|
285 |
@released
|
|
286 |
@since v8.0
|
|
287 |
@param aLocalPort the local port of this bearer
|
|
288 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
289 |
*/
|
|
290 |
{
|
|
291 |
GetLocalAddress();
|
|
292 |
aLocalPort=Wap::TPort(iLocalAddr.Port());
|
|
293 |
return KErrNone;
|
|
294 |
}
|
|
295 |
|
|
296 |
TUint32 CActiveSocket::GetPduSize()
|
|
297 |
/**
|
|
298 |
To get the received Wdp Pdu length
|
|
299 |
@internalComponent
|
|
300 |
@released
|
|
301 |
@since v8.0
|
|
302 |
@returns the length of the received Wdp pdu.
|
|
303 |
*/
|
|
304 |
{
|
|
305 |
return iMessageRecord->GetPduSize();
|
|
306 |
}
|
|
307 |
|
|
308 |
TWapMessageState CActiveSocket::GetDataState()
|
|
309 |
/**
|
|
310 |
To get the state of the data that is being received
|
|
311 |
@internalComponent
|
|
312 |
@released
|
|
313 |
@since v8.0
|
|
314 |
@returns the state of the data that is being received
|
|
315 |
*/
|
|
316 |
{
|
|
317 |
return iMessageRecord->GetDataState();
|
|
318 |
}
|
|
319 |
|
|
320 |
void CActiveSocket::SetDataState(TWapMessageState aState)
|
|
321 |
/**
|
|
322 |
To set the state of the data that is being received
|
|
323 |
@internalComponent
|
|
324 |
@released
|
|
325 |
@since v8.0
|
|
326 |
@param aState the state of the data that is being received
|
|
327 |
*/
|
|
328 |
{
|
|
329 |
iMessageRecord->SetDataState(aState);
|
|
330 |
}
|
|
331 |
|
|
332 |
TInt CActiveSocket::GetPduData(TDes8& aBuffer, TBool& aTruncated)
|
|
333 |
/**
|
|
334 |
To get the received Wdp pdu.
|
|
335 |
@internalComponent
|
|
336 |
@released
|
|
337 |
@since v8.0
|
|
338 |
@param aBuffer the buffer to read the received WDP pdu
|
|
339 |
@param aTruncated the flag to represent if the data has be truncated or not
|
|
340 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
341 |
*/
|
|
342 |
{
|
|
343 |
return iMessageRecord->GetPduData(aBuffer, aTruncated);
|
|
344 |
}
|
|
345 |
|
|
346 |
TInt CActiveSocket::GetWspData(TDes8& aWspHeader, TDes8& aWspBody, TUint8& aTransactionId, TWSPStatus& aStatus)
|
|
347 |
/**
|
|
348 |
To get the received Wsp header, body, tranaction ID and Wsp status.
|
|
349 |
@internalComponent
|
|
350 |
@released
|
|
351 |
@since v8.0
|
|
352 |
@param aWspHeader the buffer to read the received Wsp header
|
|
353 |
@param aWspBody the buffer to read the received Wsp body
|
|
354 |
@param aTransactionId the transaction ID of the received Wsp Message
|
|
355 |
@param aStatus the Wsp status of the received Wsp Message
|
|
356 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
357 |
*/
|
|
358 |
{
|
|
359 |
return iMessageRecord->GetWspData(aWspHeader, aWspBody, aTransactionId, aStatus);
|
|
360 |
}
|
|
361 |
void CActiveSocket::UnpackPduToWspDataL()
|
|
362 |
/**
|
|
363 |
To extract the Wsp header, body, transaction ID and status from the received WDP pdu
|
|
364 |
@internalComponent
|
|
365 |
@released
|
|
366 |
@since v8.0
|
|
367 |
*/
|
|
368 |
{
|
|
369 |
iMessageRecord->UnpackPduToWspDataL();
|
|
370 |
}
|
|
371 |
|
|
372 |
void CActiveSocket::CleanUpData()
|
|
373 |
{
|
|
374 |
TPtr8 zero(0,0);
|
|
375 |
iBuf.Set(zero);
|
|
376 |
iBufCon.Set(zero);
|
|
377 |
iMessageRecord->CleanUpData();
|
|
378 |
}
|
|
379 |
|
|
380 |
/** SMS active socket
|
|
381 |
*/
|
|
382 |
CActiveSocketSMS::CActiveSocketSMS(RSocketServ& aSocketServ, MProgressNotify* aNotify, Wap::TBearer aBearer, Wap::TPort aLocalPort)
|
|
383 |
:CActiveSocket(aSocketServ, aBearer, aNotify, aLocalPort)
|
|
384 |
/**
|
|
385 |
Constructor of SMS bearer for Bound Wap APIs
|
|
386 |
@internalComponent
|
|
387 |
@released
|
|
388 |
@since v8.0
|
|
389 |
*/
|
|
390 |
{
|
|
391 |
}
|
|
392 |
|
|
393 |
CActiveSocketSMS::CActiveSocketSMS(RSocketServ& aSocketServ, MProgressNotify* aNotify, Wap::TBearer aBearer, const TSockAddr& aRemoteAddr)
|
|
394 |
:CActiveSocket(aSocketServ, aBearer, aNotify, aRemoteAddr, (Wap::TPort)EWapPortUnspecified)
|
|
395 |
/**
|
|
396 |
Constructor of SMS bearer for fully specified Wap APIs
|
|
397 |
@internalComponent
|
|
398 |
@released
|
|
399 |
@since v8.0
|
|
400 |
*/
|
|
401 |
{
|
|
402 |
}
|
|
403 |
|
|
404 |
CActiveSocketSMS::~CActiveSocketSMS()
|
|
405 |
/**
|
|
406 |
Destructor of SMS bearer for fully specified Wap APIs
|
|
407 |
@internalComponent
|
|
408 |
@released
|
|
409 |
@since v8.0
|
|
410 |
*/
|
|
411 |
{
|
|
412 |
}
|
|
413 |
|
|
414 |
void CActiveSocketSMS::ConstructL(TWapMessageType aType)
|
|
415 |
/**
|
|
416 |
Second Phase Constructor
|
|
417 |
@internalComponent
|
|
418 |
@released
|
|
419 |
@param aType the type of Wap message which is received.
|
|
420 |
@since v8.0
|
|
421 |
*/
|
|
422 |
{
|
|
423 |
CActiveSocket::ConstructL(aType);
|
|
424 |
User::LeaveIfError(iSocket.Open(iSocketServ, KWAPSMSAddrFamily, KSockDatagram, KWAPSMSDatagramProtocol));
|
|
425 |
User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0));
|
|
426 |
TWapAddr wapAddr;
|
|
427 |
wapAddr.SetWapPort(TWapPortNumber(iLocalPort));
|
|
428 |
TInt err=iSocket.Bind(wapAddr);
|
|
429 |
if (err==KErrInUse)
|
|
430 |
{
|
|
431 |
User::Leave(Wap::EPortAlreadyBound);
|
|
432 |
}
|
|
433 |
}
|
|
434 |
|
|
435 |
TInt CActiveSocketSMS::AwaitRecvDataSize()
|
|
436 |
/**
|
|
437 |
Read the received Wdp pdu length.
|
|
438 |
@internalComponent
|
|
439 |
@released
|
|
440 |
@since v8.0
|
|
441 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
442 |
*/
|
|
443 |
{
|
|
444 |
TPckgBuf<TUint32>* length=iMessageRecord->GetPduSizeRef();
|
|
445 |
iSocket.Ioctl(KSOGetLength, iStatus, length, KSolWapProv);
|
|
446 |
iMessageRecord->SetDataState(ERequestingLength);
|
|
447 |
iSocketState=ESocketWaitingForLength;
|
|
448 |
SetActive();
|
|
449 |
return KErrNone;
|
|
450 |
}
|
|
451 |
|
|
452 |
TInt CActiveSocketSMS::Receive()
|
|
453 |
/**
|
|
454 |
Read the received Wdp pdu.
|
|
455 |
@internalComponent
|
|
456 |
@released
|
|
457 |
@since v8.0
|
|
458 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
459 |
*/
|
|
460 |
{
|
|
461 |
TInt err=KErrNone;
|
|
462 |
TRAP(err, iMessageRecord->CreatePduBufferL(EFalse))
|
|
463 |
if (err!=KErrNone)
|
|
464 |
{
|
|
465 |
return err;
|
|
466 |
}
|
|
467 |
HBufC8*& pdu=iMessageRecord->GetPduPtr();
|
|
468 |
iBuf.Set(pdu->Des());
|
|
469 |
iSocket.RecvFrom(iBuf, iRemoteAddr, 0, iStatus);
|
|
470 |
iMessageRecord->SetDataState(ERequestingData);
|
|
471 |
iSocketState=ESocketWaitingForData;
|
|
472 |
SetActive();
|
|
473 |
return KErrNone;
|
|
474 |
}
|
|
475 |
|
|
476 |
void CActiveSocketSMS::RunL()
|
|
477 |
/**
|
|
478 |
Overload the CActive virtual methods
|
|
479 |
@internalComponent
|
|
480 |
@released
|
|
481 |
@since v8.0
|
|
482 |
*/
|
|
483 |
{
|
|
484 |
switch (iSocketState)
|
|
485 |
{
|
|
486 |
case ESocketWaitingForLength:
|
|
487 |
{
|
45
|
488 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_1, "CActiveSocketSMS::RunL() ESocketWaitingForLength");
|
44
|
489 |
iMessageRecord->SetDataState(EPendingLength);
|
|
490 |
iSocketState=ESocketIdle;
|
|
491 |
TWapNotificationInfo info(iBearerType, iStatus.Int());
|
|
492 |
TWapNotificationInfoBuf infoBuf(info);
|
|
493 |
iNotify->Notification(EPduLengthReceived, infoBuf);
|
|
494 |
break;
|
|
495 |
}
|
|
496 |
case ESocketWaitingForData:
|
|
497 |
{
|
45
|
498 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_2, "CActiveSocketSMS::RunL() ESocketWaitingForData");
|
44
|
499 |
iMessageRecord->SetDataState(EPendingData);
|
|
500 |
iSocketState=ESocketIdle;
|
|
501 |
TWapNotificationInfo info(iBearerType, iStatus.Int());
|
|
502 |
TWapNotificationInfoBuf infoBuf(info);
|
|
503 |
iNotify->Notification(EPduReceived, infoBuf);
|
|
504 |
iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0);
|
|
505 |
break;
|
|
506 |
}
|
|
507 |
default:
|
45
|
508 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_3, "CActiveSocketSMS::RunL() Unknown State");
|
44
|
509 |
}
|
|
510 |
}
|
|
511 |
void CActiveSocketSMS::DoCancel()
|
|
512 |
/**
|
|
513 |
Overload the CActive virtual methods
|
|
514 |
@internalComponent
|
|
515 |
@released
|
|
516 |
@since v8.0
|
|
517 |
*/
|
|
518 |
{
|
|
519 |
switch (iSocketState)
|
|
520 |
{
|
|
521 |
case ESocketWaitingForLength:
|
|
522 |
{
|
|
523 |
iSocket.CancelIoctl();
|
|
524 |
break;
|
|
525 |
}
|
|
526 |
case ESocketWaitingForData:
|
|
527 |
{
|
|
528 |
iSocket.CancelRecv();
|
|
529 |
break;
|
|
530 |
}
|
|
531 |
default:
|
45
|
532 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_DOCANCEL_1, "CActiveSocketSMS::DoCancel() Unknown State");
|
44
|
533 |
}
|
|
534 |
}
|
|
535 |
|
|
536 |
//
|
|
537 |
// UDP active socket
|
|
538 |
//
|
|
539 |
CActiveSocketUDP::CActiveSocketUDP(RSocketServ& aSocketServ, MProgressNotify* aNotify, Wap::TBearer aBearer, Wap::TPort aLocalPort, RConnection* aConnection)
|
|
540 |
:CActiveSocket(aSocketServ, aBearer, aNotify, aLocalPort),iConnection(aConnection)
|
|
541 |
/**
|
|
542 |
Constructor for Bound Wap APIs
|
|
543 |
@internalComponent
|
|
544 |
@released
|
|
545 |
@since v8.0
|
|
546 |
*/
|
|
547 |
{
|
|
548 |
}
|
|
549 |
|
|
550 |
CActiveSocketUDP::CActiveSocketUDP(RSocketServ& aSocketServ, MProgressNotify* aNotify, Wap::TBearer aBearer, const TSockAddr& aRemoteAddr, RConnection* aConnection)
|
|
551 |
:CActiveSocket(aSocketServ, aBearer, aNotify, aRemoteAddr,0), iConnection(aConnection)
|
|
552 |
/**
|
|
553 |
Constructor for FullySpec Wap APIs
|
|
554 |
@internalComponent
|
|
555 |
@released
|
|
556 |
@since v8.0
|
|
557 |
*/
|
|
558 |
{
|
|
559 |
}
|
|
560 |
|
|
561 |
void CActiveSocketUDP::ConstructL(TWapMessageType aType)
|
|
562 |
/**
|
|
563 |
Second Phase constructor
|
|
564 |
@internalComponent
|
|
565 |
@released
|
|
566 |
@since v8.0
|
|
567 |
*/
|
|
568 |
{
|
|
569 |
CActiveSocket::ConstructL(aType);
|
|
570 |
if (!iConnection)
|
|
571 |
{
|
|
572 |
User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockDatagram, KProtocolInetUdp));
|
|
573 |
}
|
|
574 |
else
|
|
575 |
{
|
|
576 |
User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockDatagram, KProtocolInetUdp, *iConnection));
|
|
577 |
}
|
|
578 |
TInetAddr inetAddr(iLocalPort);
|
|
579 |
TInt err=iSocket.Bind(inetAddr);
|
|
580 |
if (err==KErrInUse)
|
|
581 |
{
|
|
582 |
User::Leave(Wap::EPortAlreadyBound);
|
|
583 |
}
|
|
584 |
}
|
|
585 |
|
|
586 |
CActiveSocketUDP::~CActiveSocketUDP()
|
|
587 |
/**
|
|
588 |
Destructor
|
|
589 |
@internalComponent
|
|
590 |
@released
|
|
591 |
@since v8.0
|
|
592 |
*/
|
|
593 |
{
|
|
594 |
}
|
|
595 |
|
|
596 |
TInt CActiveSocketUDP::AwaitRecvDataSize()
|
|
597 |
/**
|
|
598 |
Wait for Pdu data size
|
|
599 |
@internalComponent
|
|
600 |
@released
|
|
601 |
@since v8.0
|
|
602 |
*/
|
|
603 |
{
|
|
604 |
iRxlength=0;
|
|
605 |
TRAPD(err, iMessageRecord->CreatePduBufferL(ETrue))
|
|
606 |
if (err!=KErrNone)
|
|
607 |
{
|
|
608 |
return err;
|
|
609 |
}
|
|
610 |
HBufC8*& pdu=iMessageRecord->GetPduPtr();
|
|
611 |
iBuf.Set(pdu->Des());
|
|
612 |
iSocket.RecvFrom(iBuf, iRemoteAddr, 0, iStatus, iRxlength);
|
|
613 |
iMessageRecord->SetDataState(ERequestingLength);
|
|
614 |
iSocketState=ESocketWaitingForLength;
|
|
615 |
SetActive();
|
|
616 |
return KErrNone;
|
|
617 |
}
|
|
618 |
|
|
619 |
TInt CActiveSocketUDP::Receive()
|
|
620 |
/**
|
|
621 |
Receive the pdu
|
|
622 |
@internalComponent
|
|
623 |
@released
|
|
624 |
@since v8.0
|
|
625 |
*/
|
|
626 |
{
|
|
627 |
if(iMessageRecord->GetDataState()==EContinuous)
|
|
628 |
{
|
|
629 |
TRAPD(err, iMessageRecord->CreatePduBufferL(ETrue))
|
|
630 |
if (err!=KErrNone)
|
|
631 |
{
|
|
632 |
return err;
|
|
633 |
}
|
|
634 |
HBufC8*& pdu=iMessageRecord->GetPduPtr();
|
|
635 |
iBuf.Set(pdu->Des());
|
|
636 |
iBuf.SetLength(iBuf.Length()+1);
|
|
637 |
iBufCon.Set(&iBuf[iBuf.Length()-1],0,iBuf.MaxLength()-iBuf.Length());
|
|
638 |
iBuf.SetLength(iBuf.Length()+iRxlength()-1);
|
|
639 |
iSocket.RecvFrom(iBufCon, iRemoteAddr, KSockReadContinuation, iStatus,iRxlength);
|
|
640 |
iMessageRecord->SetDataState(ERequestingData);
|
|
641 |
iSocketState=ESocketWaitingForData;
|
|
642 |
SetActive();
|
|
643 |
}
|
|
644 |
else
|
|
645 |
{
|
|
646 |
iMessageRecord->SetDataState(ERequestingData);
|
|
647 |
iSocketState=ESocketWaitingForData;
|
|
648 |
iStatus = KRequestPending;
|
|
649 |
SetActive();
|
|
650 |
TRequestStatus* reqStatus=&iStatus;
|
|
651 |
User::RequestComplete(reqStatus, KErrNone);
|
|
652 |
}
|
|
653 |
return KErrNone;
|
|
654 |
}
|
|
655 |
|
|
656 |
void CActiveSocketUDP::RunL()
|
|
657 |
/**
|
|
658 |
RunL()
|
|
659 |
@internalComponent
|
|
660 |
@released
|
|
661 |
@since v8.0
|
|
662 |
*/
|
|
663 |
{
|
|
664 |
switch (iSocketState)
|
|
665 |
{
|
|
666 |
case ESocketWaitingForLength:
|
|
667 |
{
|
45
|
668 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_1, "CActiveSocketUDP::RunL() ESocketWaitingForLength");
|
44
|
669 |
iMessageRecord->SetPduSize(iBuf.Length()+ iRxlength());
|
|
670 |
if(iRxlength() > 0)
|
|
671 |
{
|
|
672 |
iMessageRecord->SetDataState(EContinuous);
|
|
673 |
}
|
|
674 |
else
|
|
675 |
{
|
|
676 |
iMessageRecord->SetDataState(EPendingLength);
|
|
677 |
}
|
|
678 |
iSocketState=ESocketIdle;
|
|
679 |
TWapNotificationInfo info(iBearerType, iStatus.Int());
|
|
680 |
TWapNotificationInfoBuf infoBuf(info);
|
|
681 |
iNotify->Notification(EPduLengthReceived, infoBuf);
|
|
682 |
break;
|
|
683 |
}
|
|
684 |
case ESocketWaitingForData:
|
|
685 |
{
|
45
|
686 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_2, "CActiveSocketUDP::RunL() ESocketWaitingForData");
|
44
|
687 |
iMessageRecord->SetDataState(EPendingData);
|
|
688 |
iSocketState=ESocketIdle;
|
|
689 |
TWapNotificationInfo info(iBearerType, iStatus.Int());
|
|
690 |
TWapNotificationInfoBuf infoBuf(info);
|
|
691 |
iNotify->Notification(EPduReceived, infoBuf);
|
|
692 |
break;
|
|
693 |
}
|
|
694 |
default:
|
45
|
695 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_3, "CActiveSocketUDP::RunL() Unknown State");
|
44
|
696 |
break;
|
|
697 |
}
|
|
698 |
}
|
|
699 |
|
|
700 |
void CActiveSocketUDP::DoCancel()
|
|
701 |
/**
|
|
702 |
Cancel the outstanding request on UDP bearer
|
|
703 |
@internalComponent
|
|
704 |
@released
|
|
705 |
@since v8.0
|
|
706 |
*/
|
|
707 |
{
|
|
708 |
switch (iSocketState)
|
|
709 |
{
|
|
710 |
case ESocketWaitingForLength:
|
|
711 |
{
|
|
712 |
iSocket.CancelRecv();
|
|
713 |
break;
|
|
714 |
}
|
|
715 |
case ESocketWaitingForData:
|
|
716 |
{
|
|
717 |
break;
|
|
718 |
}
|
|
719 |
default:
|
45
|
720 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_DOCANCEL_1, "CActiveSocketUDP::DoCancel() Unknown State");
|
44
|
721 |
}
|
|
722 |
}
|
|
723 |
|
|
724 |
//
|
|
725 |
//CWapMessageRecord
|
|
726 |
//
|
|
727 |
CWapMessageRecord* CWapMessageRecord::NewL(TWapMessageType aType)
|
|
728 |
/**
|
|
729 |
The static funtion to instanciate the Pdu data record
|
|
730 |
@internalComponent
|
|
731 |
@released
|
|
732 |
@since v8.0
|
|
733 |
@param aType the type of Wap message which is received.
|
|
734 |
@returns the data record instance.
|
|
735 |
*/
|
|
736 |
{
|
|
737 |
CWapMessageRecord* me;
|
|
738 |
if (aType==EWapWsp)
|
|
739 |
{
|
|
740 |
me = new(ELeave) CWspMessageRecord();
|
|
741 |
}
|
|
742 |
else
|
|
743 |
{
|
|
744 |
me = new(ELeave) CWdpMessageRecord();
|
|
745 |
}
|
|
746 |
return me;
|
|
747 |
}
|
|
748 |
|
|
749 |
CWapMessageRecord::CWapMessageRecord()
|
|
750 |
/**
|
|
751 |
Constructor
|
|
752 |
@internalComponent
|
|
753 |
@released
|
|
754 |
@since v8.0
|
|
755 |
*/
|
|
756 |
{
|
|
757 |
}
|
|
758 |
|
|
759 |
CWapMessageRecord::~CWapMessageRecord()
|
|
760 |
/**
|
|
761 |
Destructor
|
|
762 |
@internalComponent
|
|
763 |
@released
|
|
764 |
@since v8.0
|
|
765 |
*/
|
|
766 |
{
|
|
767 |
if (iPdu)
|
|
768 |
{
|
|
769 |
delete iPdu;
|
|
770 |
}
|
|
771 |
}
|
|
772 |
|
|
773 |
TWapMessageState CWapMessageRecord::GetDataState()
|
|
774 |
/**
|
|
775 |
To get the state of the data that is being received
|
|
776 |
@internalComponent
|
|
777 |
@released
|
|
778 |
@since v8.0
|
|
779 |
returns the state of the data that is being received
|
|
780 |
*/
|
|
781 |
{
|
|
782 |
return iState;
|
|
783 |
}
|
|
784 |
|
|
785 |
void CWapMessageRecord::SetDataState(TWapMessageState aState)
|
|
786 |
/**
|
|
787 |
To set the state of the data that is being received
|
|
788 |
@internalComponent
|
|
789 |
@released
|
|
790 |
@since v8.0
|
|
791 |
@param the state of the data that is being received
|
|
792 |
*/
|
|
793 |
{
|
|
794 |
iState=aState;
|
|
795 |
}
|
|
796 |
|
|
797 |
TPckgBuf<TUint32>* CWapMessageRecord::GetPduSizeRef()
|
|
798 |
/**
|
|
799 |
To get the buffer which is used to contain the received data length
|
|
800 |
@internalComponent
|
|
801 |
@released
|
|
802 |
@since v8.0
|
|
803 |
@returns the pointer to the buffer length
|
|
804 |
*/
|
|
805 |
{
|
|
806 |
return &iDataLength;
|
|
807 |
}
|
|
808 |
|
|
809 |
void CWapMessageRecord::SetPduSize(TUint32 aLength)
|
|
810 |
{
|
|
811 |
iDataLength=aLength;
|
|
812 |
}
|
|
813 |
|
|
814 |
TUint32 CWapMessageRecord::GetPduSize()
|
|
815 |
/**
|
|
816 |
To get the received wdp pdu length
|
|
817 |
@internalComponent
|
|
818 |
@released
|
|
819 |
@since v8.0
|
|
820 |
@returns the received wdp pdu length
|
|
821 |
*/
|
|
822 |
{
|
|
823 |
iState=EGotLength;
|
|
824 |
return iDataLength();
|
|
825 |
}
|
|
826 |
|
|
827 |
HBufC8*& CWapMessageRecord::GetPduPtr()
|
|
828 |
/**
|
|
829 |
To get the received wdp pdu.
|
|
830 |
@internalComponent
|
|
831 |
@released
|
|
832 |
@since v8.0
|
|
833 |
@returns the pointer the received wdp buffer
|
|
834 |
*/
|
|
835 |
{
|
|
836 |
return iPdu;
|
|
837 |
}
|
|
838 |
|
|
839 |
void CWapMessageRecord::CreatePduBufferL(TBool aFixLengthFlag)
|
|
840 |
/**
|
|
841 |
create the wdp pdu buffer according to the length
|
|
842 |
@internalComponent
|
|
843 |
@released
|
|
844 |
@since v8.0
|
|
845 |
*/
|
|
846 |
{
|
|
847 |
if (iState==EContinuous)
|
|
848 |
{
|
|
849 |
iPdu = iPdu->ReAllocL(iDataLength());
|
|
850 |
}
|
|
851 |
else if (!aFixLengthFlag)
|
|
852 |
{
|
|
853 |
iPdu=HBufC8::NewL(iDataLength());
|
|
854 |
}
|
|
855 |
else
|
|
856 |
{
|
|
857 |
iPdu=HBufC8::NewL(KMaxUdpBearerDataBufferLength);
|
|
858 |
}
|
|
859 |
}
|
|
860 |
|
|
861 |
void CWapMessageRecord::CleanUpData()
|
|
862 |
/**
|
|
863 |
clean up the receive buffer.
|
|
864 |
@internalComponent
|
|
865 |
@released
|
|
866 |
@since v8.0
|
|
867 |
*/
|
|
868 |
{
|
|
869 |
if (iPdu)
|
|
870 |
{
|
|
871 |
delete iPdu;
|
|
872 |
iPdu=NULL;
|
|
873 |
}
|
|
874 |
iDataLength.FillZ();
|
|
875 |
iState=EIdle;
|
|
876 |
}
|
|
877 |
|
|
878 |
//
|
|
879 |
//CWspMessageRecord methods
|
|
880 |
//
|
|
881 |
CWspMessageRecord::CWspMessageRecord()
|
|
882 |
/**
|
|
883 |
Constructor
|
|
884 |
@internalComponent
|
|
885 |
@released
|
|
886 |
@since v8.0
|
|
887 |
*/
|
|
888 |
{
|
|
889 |
}
|
|
890 |
|
|
891 |
CWspMessageRecord::~CWspMessageRecord()
|
|
892 |
/**
|
|
893 |
Destructor
|
|
894 |
@internalComponent
|
|
895 |
@released
|
|
896 |
@since v8.0
|
|
897 |
*/
|
|
898 |
{
|
|
899 |
if (iWspHeader)
|
|
900 |
{
|
|
901 |
delete iWspHeader;
|
|
902 |
}
|
|
903 |
if (iWspBody)
|
|
904 |
{
|
|
905 |
delete iWspBody;
|
|
906 |
}
|
|
907 |
}
|
|
908 |
|
|
909 |
void CWspMessageRecord::UnpackPduToWspDataL()
|
|
910 |
/**
|
|
911 |
To unpack the received wdp pdu to wsp message.
|
|
912 |
@internalComponent
|
|
913 |
@released
|
|
914 |
@since v8.0
|
|
915 |
*/
|
|
916 |
{
|
|
917 |
TWSPPduType type;
|
|
918 |
CCLWSPPduHandler::UnpackWSPPduL(iPdu, type, iWspHeader, iWspBody, iTransactionId, iWspStatus);
|
|
919 |
}
|
|
920 |
|
|
921 |
TInt CWspMessageRecord::GetWspData(TDes8& aWspHeader, TDes8& aWspBody, TUint8& aTransactionId, TWSPStatus& aWspStatus)
|
|
922 |
/**
|
|
923 |
To read the wsp message from the buffer
|
|
924 |
@internalComponent
|
|
925 |
@released
|
|
926 |
@since v8.0
|
|
927 |
@param aWspHeader the buffer to contain the wsp header
|
|
928 |
@param aWspBody the buffer to contain the wsp body
|
|
929 |
@param iTransactionId the received transaction ID
|
|
930 |
@param aWspStatus the received wsp status
|
|
931 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
932 |
*/
|
|
933 |
{
|
|
934 |
if (!iWspHeader && !iWspBody)
|
|
935 |
{
|
|
936 |
// if no data, should not be here at all
|
45
|
937 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWSPMESSAGERECORD_GETWSPDATA_1, "CWspMessageRecord::GetWspData() No Data Available");
|
44
|
938 |
CleanUpData();
|
|
939 |
return KErrBadDescriptor;
|
|
940 |
}
|
|
941 |
TInt ret=KErrNone;
|
|
942 |
//Copy the transaction ID
|
|
943 |
aTransactionId=iTransactionId;
|
|
944 |
aWspStatus=iWspStatus;
|
|
945 |
//Copy the header
|
|
946 |
TInt bufferLength;
|
|
947 |
if (iWspHeader)
|
|
948 |
{
|
|
949 |
bufferLength=aWspHeader.MaxLength();
|
|
950 |
TPtrC8 remainHeader=iWspHeader->Mid(iHeaderOffset);
|
|
951 |
//Client Header buffer is not long enough
|
|
952 |
if (bufferLength<remainHeader.Length())
|
|
953 |
{
|
|
954 |
aWspHeader.Copy(remainHeader.Ptr(), bufferLength);
|
|
955 |
iHeaderOffset+=bufferLength;
|
|
956 |
iState=EReading;
|
|
957 |
ret=Wap::EMoreData;
|
|
958 |
}
|
|
959 |
else
|
|
960 |
{
|
|
961 |
aWspHeader.Copy(remainHeader);
|
|
962 |
iHeaderOffset=0;
|
|
963 |
delete iWspHeader;
|
|
964 |
iWspHeader=NULL;
|
|
965 |
}
|
|
966 |
}
|
|
967 |
if (iWspBody)
|
|
968 |
{
|
|
969 |
//Copy the Body
|
|
970 |
bufferLength=aWspBody.MaxLength();
|
|
971 |
TPtrC8 remainBody=iWspBody->Mid(iBodyOffset);
|
|
972 |
|
|
973 |
//Client Header buffer is not long enough
|
|
974 |
if (bufferLength<remainBody.Length())
|
|
975 |
{
|
|
976 |
aWspBody.Copy(remainBody.Ptr(), bufferLength);
|
|
977 |
iBodyOffset+=bufferLength;
|
|
978 |
iState=EReading;
|
|
979 |
ret=Wap::EMoreData;
|
|
980 |
}
|
|
981 |
else
|
|
982 |
{
|
|
983 |
aWspBody.Copy(remainBody);
|
|
984 |
iBodyOffset=0;
|
|
985 |
delete iWspBody;
|
|
986 |
iWspBody=NULL;
|
|
987 |
}
|
|
988 |
}
|
|
989 |
//All Wsp Data has been read.
|
|
990 |
if (ret==KErrNone)
|
|
991 |
{
|
|
992 |
delete iPdu;
|
|
993 |
iPdu=NULL;
|
|
994 |
iDataLength.FillZ();
|
|
995 |
iState=EIdle;
|
|
996 |
}
|
|
997 |
return ret;
|
|
998 |
}
|
|
999 |
|
|
1000 |
TInt CWspMessageRecord::GetPduData(TDes8& /*aBuffer*/, TBool& /*aTruncated*/)
|
|
1001 |
/**
|
|
1002 |
Not supported
|
|
1003 |
@internalComponent
|
|
1004 |
@released
|
|
1005 |
@since v8.0
|
|
1006 |
*/
|
|
1007 |
{//Should not be used
|
|
1008 |
return KErrNotSupported;
|
|
1009 |
}
|
|
1010 |
|
|
1011 |
void CWspMessageRecord::CleanUpData()
|
|
1012 |
/**
|
|
1013 |
To clean up the wsp related data
|
|
1014 |
@internalComponent
|
|
1015 |
@released
|
|
1016 |
@since v8.0
|
|
1017 |
*/
|
|
1018 |
{
|
|
1019 |
CWapMessageRecord::CleanUpData();
|
|
1020 |
if (iWspHeader)
|
|
1021 |
{
|
|
1022 |
delete iWspHeader;
|
|
1023 |
iWspHeader=NULL;
|
|
1024 |
}
|
|
1025 |
if (iWspBody)
|
|
1026 |
{
|
|
1027 |
delete iWspBody;
|
|
1028 |
iWspBody=NULL;
|
|
1029 |
}
|
|
1030 |
iTransactionId=0;
|
|
1031 |
iHeaderOffset=0;
|
|
1032 |
iBodyOffset=0;
|
|
1033 |
}
|
|
1034 |
//
|
|
1035 |
//CWspMessageRecord method
|
|
1036 |
//
|
|
1037 |
CWdpMessageRecord::CWdpMessageRecord()
|
|
1038 |
/**
|
|
1039 |
Constructor
|
|
1040 |
@internalComponent
|
|
1041 |
@released
|
|
1042 |
@since v8.0
|
|
1043 |
*/
|
|
1044 |
{
|
|
1045 |
}
|
|
1046 |
|
|
1047 |
CWdpMessageRecord::~CWdpMessageRecord()
|
|
1048 |
/**
|
|
1049 |
Destructor
|
|
1050 |
@internalComponent
|
|
1051 |
@released
|
|
1052 |
@since v8.0
|
|
1053 |
*/
|
|
1054 |
{
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
TInt CWdpMessageRecord::GetPduData(TDes8& aBuffer, TBool& aTruncated)
|
|
1058 |
/**
|
|
1059 |
To read the received Wdp pdu
|
|
1060 |
@internalComponent
|
|
1061 |
@released
|
|
1062 |
@since v8.0
|
|
1063 |
@param aBuffer the buffer to contain the received wdp pdu
|
|
1064 |
@param aTruncated the flag to represent if the data is truncated or not
|
|
1065 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
1066 |
*/
|
|
1067 |
{
|
|
1068 |
if (!iPdu)
|
|
1069 |
{
|
|
1070 |
//Should not be here at all
|
45
|
1071 |
OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWDPMESSAGERECORD_GETPDUDATA_1, "CWdpMessageRecord::GetPduData No Data Available");
|
44
|
1072 |
CleanUpData();
|
|
1073 |
return KErrBadDescriptor;
|
|
1074 |
}
|
|
1075 |
TInt ret=KErrNone;
|
|
1076 |
TInt bufLength=aBuffer.MaxLength();
|
|
1077 |
TPtrC8 remainPdu=iPdu->Mid(iPduOffset);
|
|
1078 |
if (bufLength<remainPdu.Length())
|
|
1079 |
{
|
|
1080 |
aBuffer.Copy(remainPdu.Ptr(), bufLength);
|
|
1081 |
iPduOffset+=bufLength;
|
|
1082 |
iState=EReading;
|
|
1083 |
aTruncated=ETrue;
|
|
1084 |
ret=Wap::EMoreData;
|
|
1085 |
}
|
|
1086 |
else
|
|
1087 |
{
|
|
1088 |
aBuffer.Copy(remainPdu);
|
|
1089 |
aTruncated=EFalse;
|
|
1090 |
CleanUpData();
|
|
1091 |
}
|
|
1092 |
return ret;
|
|
1093 |
}
|
|
1094 |
|
|
1095 |
void CWdpMessageRecord::UnpackPduToWspDataL()
|
|
1096 |
/**
|
|
1097 |
Not supported
|
|
1098 |
@internalComponent
|
|
1099 |
@released
|
|
1100 |
@since v8.0
|
|
1101 |
*/
|
|
1102 |
{
|
|
1103 |
//Should not be used
|
|
1104 |
User::Leave(KErrNotSupported);
|
|
1105 |
}
|
|
1106 |
|
|
1107 |
TInt CWdpMessageRecord::GetWspData(TDes8& /*aWspHeader*/, TDes8& /*aWspBody*/, TUint8& /*aTransactionId*/, TWSPStatus& /*aWspStatus*/)
|
|
1108 |
/**
|
|
1109 |
Not supported
|
|
1110 |
@internalComponent
|
|
1111 |
@released
|
|
1112 |
@since v8.0
|
|
1113 |
*/
|
|
1114 |
{
|
|
1115 |
//Should not be used
|
|
1116 |
return KErrNotSupported;
|
|
1117 |
}
|
|
1118 |
|
|
1119 |
void CWdpMessageRecord::CleanUpData()
|
|
1120 |
/**
|
|
1121 |
To clean up the wdp related data
|
|
1122 |
@internalComponent
|
|
1123 |
@released
|
|
1124 |
@since v8.0
|
|
1125 |
*/
|
|
1126 |
{
|
|
1127 |
CWapMessageRecord::CleanUpData();
|
|
1128 |
iPduOffset=0;
|
|
1129 |
}
|