44
|
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 |
#include "WapBoundCLWSP.h"
|
|
17 |
#include "WapMsgUtils.h"
|
|
18 |
#include "CLWSPPduHandler.h"
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
CSWSWapBoundCLWSPService* CSWSWapBoundCLWSPService::NewL()
|
|
23 |
/**
|
|
24 |
Static new function
|
|
25 |
@internalComponent
|
|
26 |
@released
|
|
27 |
@since v8.0
|
|
28 |
*/
|
|
29 |
{
|
|
30 |
CSWSWapBoundCLWSPService* me = new(ELeave)CSWSWapBoundCLWSPService();
|
|
31 |
CleanupStack::PushL(me);
|
|
32 |
me->ConstructL();
|
|
33 |
CleanupStack::Pop(me);
|
|
34 |
return me;
|
|
35 |
}
|
|
36 |
|
|
37 |
CSWSWapBoundCLWSPService::CSWSWapBoundCLWSPService()
|
|
38 |
: CWapBoundCLWSPService()
|
|
39 |
/**
|
|
40 |
Constructor
|
|
41 |
@internalComponent
|
|
42 |
@released
|
|
43 |
@since v8.0
|
|
44 |
*/
|
|
45 |
{
|
|
46 |
}
|
|
47 |
|
|
48 |
CSWSWapBoundCLWSPService::~CSWSWapBoundCLWSPService()
|
|
49 |
/**
|
|
50 |
Destructor
|
|
51 |
@internalComponent
|
|
52 |
@released
|
|
53 |
@since v8.0
|
|
54 |
*/
|
|
55 |
{
|
|
56 |
delete iAgent;
|
|
57 |
}
|
|
58 |
|
|
59 |
void CSWSWapBoundCLWSPService::ConstructL()
|
|
60 |
/**
|
|
61 |
Second phase constructor
|
|
62 |
@internalComponent
|
|
63 |
@released
|
|
64 |
@since v8.0
|
|
65 |
*/
|
|
66 |
{
|
|
67 |
// Parent class construction
|
|
68 |
CWapBoundCLWSPService::ConstructL();
|
|
69 |
iAgent=CWspMessageApiAgent::NewL();
|
|
70 |
}
|
|
71 |
|
|
72 |
TInt CSWSWapBoundCLWSPService::Connect(Wap::TBearer aBearer, Wap::TPort aPort, TBool aSecure)
|
|
73 |
/**
|
|
74 |
Opens a End-point which is to be used to listen for the incoming method result messages from any sender;
|
|
75 |
@internalComponent
|
|
76 |
@released
|
|
77 |
@since v8.0
|
|
78 |
@param aBearer (in) the bearer to listen on (use EAll for all bearers)
|
|
79 |
@param aPort (in) the port to listen on. If set to 0, a local port will be chosen for the client's first SendTo
|
|
80 |
@param aSecure (in) security flag indicates whether WTLS will be used or not
|
|
81 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
82 |
*/
|
|
83 |
{
|
|
84 |
if(aSecure)
|
|
85 |
{
|
|
86 |
return KErrNotSupported;
|
|
87 |
}
|
|
88 |
return iAgent->Connect(aBearer, aPort, aSecure);
|
|
89 |
}
|
|
90 |
|
|
91 |
TInt CSWSWapBoundCLWSPService::MethodInvoke(Wap::TBearer aBearer, const TDesC8& aRemoteHost, Wap::TPort aRemotePort, TUint aMethod, const TDesC& aURI, const TDesC8& aReqHeaders, const TDesC8& aReqBody, const TUint8 aTransactionId)
|
|
92 |
/**
|
|
93 |
A synchronous call to send a method invoke method to the remote host.
|
|
94 |
@internalComponent
|
|
95 |
@released
|
|
96 |
@since v8.0
|
|
97 |
@param aBearer (in) the bearer that will be used
|
|
98 |
@param aRemoteHost (in) the remotehost to be sent message to
|
|
99 |
@param aRemotePort (in) the remoteport to be sent message to
|
|
100 |
@param aMethod (in) the method that will be invoked on server
|
|
101 |
@param aURI (in) the uri to build wsp message
|
|
102 |
@param aReqHeaders (in) the wsp header to be used to build method invoke message
|
|
103 |
@param aReqBody (in) the wsp body to be used to build method invoke message
|
|
104 |
@param aTransactionId (in) the transaction Id of the method invoke message
|
|
105 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
106 |
*/
|
|
107 |
{
|
|
108 |
return iAgent->SendWspMessage(aBearer, aRemoteHost, aRemotePort, TWSPPduType(aMethod), aURI, aReqHeaders, aReqBody, aTransactionId);
|
|
109 |
}
|
|
110 |
|
|
111 |
TInt CSWSWapBoundCLWSPService::MethodResult(TDes8& aReqHeaders, TDes8& aReqBody, TPckgBuf<TUint8>& aTransactionIdPckg, TWSPStatus& aWspStatus, TRequestStatus& aReqStatus, TUint32 aTimeout)
|
|
112 |
/**
|
|
113 |
Request an asynchronous notification upon arrival of the method result messages on the listening connection.
|
|
114 |
The request completes upon receipt of the message, filling the buffers with as much received data as possible.
|
|
115 |
A return code will indicate whether further data remains. The call must be re-issued for subsequent messages
|
|
116 |
or to receive remaining data from a previous method result message.
|
|
117 |
@internalComponent
|
|
118 |
@released
|
|
119 |
@since v8.0
|
|
120 |
@param aReqHeaders (out) (client-allocated) - when a method result message arrives the header data is written here
|
|
121 |
@param aReqBody (out) (client-allocated) - when a method result message arrives the body data is written here
|
|
122 |
@param aTransactionIdPckg (out) when a method result message arrives an integer ID that uniquely specifies the message is written here
|
|
123 |
@param aWspStatus (out) when a method result message arrives, the wsp status is written here.
|
|
124 |
@param aReqStatus (inout) used by the service provider to notify the client when a method result has arrived
|
|
125 |
@param aTimeout (in) an optional millisecond time-out which allows a timed read to be made. If no data is received
|
|
126 |
within the timeout period the request completes with KErrTimedOut. If a value of 0 is supplied the timeout is infinite.
|
|
127 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
128 |
*/
|
|
129 |
{
|
|
130 |
return iAgent->ReceiveWspMessage(aReqHeaders, aReqBody, aTransactionIdPckg, aWspStatus, aReqStatus, aTimeout);
|
|
131 |
}
|
|
132 |
|
|
133 |
void CSWSWapBoundCLWSPService::CancelReq()
|
|
134 |
/**
|
|
135 |
Cancel a previously-requested method result notification. If a method result message arrives the client will not be notified.
|
|
136 |
@internalComponent
|
|
137 |
@released
|
|
138 |
@since v8.0
|
|
139 |
*/
|
|
140 |
{
|
|
141 |
iAgent->CancelRequest();
|
|
142 |
}
|
|
143 |
|
|
144 |
TInt CSWSWapBoundCLWSPService::GetLocalPort(Wap::TPort& aPort)
|
|
145 |
/**
|
|
146 |
Get the local address of this endpoint.
|
|
147 |
@internalComponent
|
|
148 |
@released
|
|
149 |
@since v8.0
|
|
150 |
@param aPort (out) the port of the local host
|
|
151 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
152 |
*/
|
|
153 |
{
|
|
154 |
return iAgent->GetLocalPort(aPort);
|
|
155 |
}
|
|
156 |
|
|
157 |
TInt CSWSWapBoundCLWSPService::GetLocalAddress(HBufC8*& aLocalHost)
|
|
158 |
/**
|
|
159 |
Get the local address of this endpoint.
|
|
160 |
@internalComponent
|
|
161 |
@released
|
|
162 |
@since v8.0
|
|
163 |
@param aLocalHost (inout) the address of the local host. A reference to a HBufC8 pointer should
|
|
164 |
be passed in. This pointer MUST be null! A HBufC8 will be allocated to hold the address, ownership
|
|
165 |
of this buffer will be passed over to the client.
|
|
166 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
167 |
*/
|
|
168 |
{
|
|
169 |
return iAgent->GetLocalAddress(aLocalHost);
|
|
170 |
}
|
|
171 |
|
|
172 |
TInt CSWSWapBoundCLWSPService::GetBearer(Wap::TBearer& aBearer)
|
|
173 |
/**
|
|
174 |
Get the bearer on which the method result message arrived.
|
|
175 |
Useful when EAll was specified in Connect()
|
|
176 |
@internalComponent
|
|
177 |
@released
|
|
178 |
@since v8.0
|
|
179 |
@param aBearer (out) the bearer
|
|
180 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
181 |
*/
|
|
182 |
{
|
|
183 |
return iAgent->GetBearer(aBearer);
|
|
184 |
}
|
|
185 |
|
|
186 |
TInt CSWSWapBoundCLWSPService::GetServerAddress(HBufC8*& aServerAddress)
|
|
187 |
/**
|
|
188 |
Get the remote address of the last wsp method result message
|
|
189 |
@internalComponent
|
|
190 |
@released
|
|
191 |
@since v8.0
|
|
192 |
Cannot be called when there is an outstanding MethodResult().
|
|
193 |
@param aServerAddress the address of the remote server.
|
|
194 |
A reference to a HBufC8 pointer should be passed in. An HBufC8 will be allocated
|
|
195 |
to hold the address ,ownership of this buffer will be passed over to the client.
|
|
196 |
@returns KErrNone on successful completion, KErrNotSupported if not implemented or one of the system error codes on failure.
|
|
197 |
*/
|
|
198 |
{
|
|
199 |
return iAgent->GetServerAddress(aServerAddress);
|
|
200 |
}
|
|
201 |
|