|
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 "WapFullySpecWDP.h" |
|
17 #include "WapMsgUtils.h" |
|
18 |
|
19 CSWSWapFullySpecWDPService* CSWSWapFullySpecWDPService::NewL() |
|
20 /** |
|
21 Static new function |
|
22 @internalComponent |
|
23 @released |
|
24 @since v8.0 |
|
25 */ |
|
26 { |
|
27 CSWSWapFullySpecWDPService* me = new(ELeave)CSWSWapFullySpecWDPService(); |
|
28 CleanupStack::PushL(me); |
|
29 me->ConstructL(); |
|
30 CleanupStack::Pop(me); |
|
31 return me; |
|
32 } |
|
33 |
|
34 CSWSWapFullySpecWDPService::CSWSWapFullySpecWDPService() |
|
35 : CWapFullySpecDatagramService() |
|
36 /** |
|
37 Constructor |
|
38 @internalComponent |
|
39 @released |
|
40 @since v8.0 |
|
41 */ |
|
42 { |
|
43 } |
|
44 |
|
45 CSWSWapFullySpecWDPService::~CSWSWapFullySpecWDPService() |
|
46 /** |
|
47 Destructor |
|
48 @internalComponent |
|
49 @released |
|
50 @since v8.0 |
|
51 */ |
|
52 { |
|
53 delete iAgent; |
|
54 } |
|
55 |
|
56 void CSWSWapFullySpecWDPService::ConstructL() |
|
57 /** |
|
58 Second Phase Constructor |
|
59 @internalComponent |
|
60 @released |
|
61 @since v8.0 |
|
62 */ |
|
63 { |
|
64 // Parent class construction |
|
65 CWapFullySpecDatagramService::ConstructL(); |
|
66 iAgent=CWdpMessageApiAgent::NewL(); |
|
67 } |
|
68 |
|
69 TInt CSWSWapFullySpecWDPService::Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer, TInetAddr /*aInetAddr*/) |
|
70 /** |
|
71 Connect to the SWS, opening an endpoint which is to be used only with a single, named remote host.All CWapFullySpecDatagramService implementaions must automatically close this endpoint upon destruction. |
|
72 @internalComponent |
|
73 @released |
|
74 @since v8.0 |
|
75 @param aRemoteHost (in) the bearer-dependent address of the remote host with which the data will be exchanged |
|
76 @param aRemotePort (in) the port on the remote host to which data will be sent |
|
77 @param aBearer (in) the bearer to use (not EAll) |
|
78 @param aInetAddr (in) the ip address of the network interface that should be used in a multihomed system. |
|
79 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
80 */ |
|
81 { |
|
82 return iAgent->Connect(aRemoteHost, aRemotePort, aBearer, EFalse); |
|
83 } |
|
84 |
|
85 TInt CSWSWapFullySpecWDPService::Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer) |
|
86 /** |
|
87 Connect to the wapstack, opening an endpoint which is to be used only with a single, named remote host. |
|
88 @internalComponent |
|
89 @released |
|
90 @since v8.0 |
|
91 @param aRemoteHost (in) the bearer-dependent address of the remote host with which the data will be exchange |
|
92 @param aRemotePort (in) the port on the remote host to which data will be sent |
|
93 @param aBearer (in) the bearer to use (not EAll) |
|
94 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
95 */ |
|
96 { |
|
97 TInetAddr inetAddr( KInetAddrAny, 0); |
|
98 return(Connect(aRemoteHost, aRemotePort, aBearer, inetAddr)); |
|
99 } |
|
100 |
|
101 TInt CSWSWapFullySpecWDPService::Send(const TDesC8& aBuffer) |
|
102 /** |
|
103 Send data on a fully-specified connection. |
|
104 @internalComponent |
|
105 @released |
|
106 @since v8.0 |
|
107 @param aBuffer (in) the data buffer to be written over the connection |
|
108 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
109 */ |
|
110 { |
|
111 return iAgent->SendWdpMessage(aBuffer); |
|
112 } |
|
113 |
|
114 TInt CSWSWapFullySpecWDPService::AwaitRecvDataSize(TPckg<TUint16>& aDataSizePckg, TRequestStatus& aReqStatus) |
|
115 /** |
|
116 receive data on a bound port. |
|
117 @internalComponent |
|
118 @released |
|
119 @since v8.0 |
|
120 An asynchronous notification is sent to the client when data arrives. |
|
121 @param aDataSizePckg size of data received |
|
122 @param aReqStatus (inout) used to notify the client that a datagram was received |
|
123 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
124 */ |
|
125 { |
|
126 return iAgent->AwaitRecvDataSize(aDataSizePckg, aReqStatus); |
|
127 } |
|
128 |
|
129 TInt CSWSWapFullySpecWDPService::Recv(TDes8& aBuffer, TBool& aTruncated, TRequestStatus& aReqStatus, TUint32 aTimeout) |
|
130 /** |
|
131 receive data on a bound port. |
|
132 An asynchronous notification is sent to the client when data arrives. |
|
133 @internalComponent |
|
134 @released |
|
135 @since v8.0 |
|
136 @param aBuffer (out) a client-allocated data buffer to be filled with data received. Data that overflows the buffer is discarded. |
|
137 @param aTruncated (out) indicates whether the received datagram was truncated to fit in the client's supplied buffer |
|
138 @param aReqStatus (inout) used to notify the client that a datagram was received |
|
139 @param aTimeout (in) an optional millisecond time-out which allows a timed read to be made. If no data is received |
|
140 within the timeout period the request completes with KErrTimedOut. If a value of 0 is supplied the timeout is infinite. |
|
141 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
142 */ |
|
143 { |
|
144 return iAgent->ReceiveWdpMessage(iHostName, iPort, aBuffer, aTruncated, aReqStatus, aTimeout); |
|
145 } |
|
146 |
|
147 void CSWSWapFullySpecWDPService::CancelRecv() |
|
148 /** |
|
149 Cancel a previously requested asynchronous Recv or AwaitRecvDataSize notification. |
|
150 If a datagram arrives at the local host, it will be discarded. |
|
151 @internalComponent |
|
152 @released |
|
153 @since v8.0 |
|
154 */ |
|
155 { |
|
156 iAgent->CancelRequest(); |
|
157 } |
|
158 |
|
159 TInt CSWSWapFullySpecWDPService::GetLocalPort(Wap::TPort& aPort) |
|
160 /** |
|
161 Get the local port of this endpoint.Useful if one was chosen automatically. |
|
162 @internalComponent |
|
163 @released |
|
164 @since v8.0 |
|
165 @param aPort (out) the port number |
|
166 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
167 */ |
|
168 |
|
169 { |
|
170 return iAgent->GetLocalPort(aPort); |
|
171 } |
|
172 |
|
173 TInt CSWSWapFullySpecWDPService::GetLocalAddress(HBufC8*& aLocalHost) |
|
174 /** |
|
175 Get the local address of this endpoint. |
|
176 @internalComponent |
|
177 @released |
|
178 @since v8.0 |
|
179 @param aLocalHost (inout) the address of the local host. A reference to a HBufC8 pointer should |
|
180 be passed in. This pointer MUST be null! A HBufC8 will be allocated to hold the address, ownership |
|
181 of this buffer will be passed over to the client. |
|
182 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
183 */ |
|
184 { |
|
185 return iAgent->GetLocalAddress(aLocalHost); |
|
186 } |
|
187 |
|
188 TInt CSWSWapFullySpecWDPService::GetDatagramSizes(TUint16& aMaxSize, TUint16& aNominalSize) |
|
189 /** |
|
190 Query the WDP bearer for its maximum datagram size and its nominal datagram size. |
|
191 @internalComponent |
|
192 @released |
|
193 @since v8.0 |
|
194 @param aMaxSize (out) the maximum datagram size |
|
195 @param aNominalSize (out) the nominal datagram size (nominal = size within which a datagram won't |
|
196 have to be split into smaller individual messages and then re-assembled at the other end). |
|
197 This will fail for a stream connection |
|
198 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
199 */ |
|
200 { |
|
201 // Can only retrieve this info from the capcodec when its a connection, not datagram! |
|
202 aMaxSize = KWapStackMaxDatagramSize; |
|
203 aNominalSize = KWapStackNorminalDatagramSize; |
|
204 return KErrNone; |
|
205 } |
|
206 |