1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: GPRS Data channel |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CSATBIPGPRSDATACHANNEL_H |
|
21 #define CSATBIPGPRSDATACHANNEL_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <es_enum.h> // TConnectionInfo |
|
25 #include <in_sock.h> |
|
26 #include <etelqos.h> |
|
27 |
|
28 #include "MSatBIPDataChannel.h" |
|
29 #include "MSatBIPUtils.h" |
|
30 #include "TSatQoSParser.h" |
|
31 |
|
32 class CSatBIPUtils; |
|
33 class MSatSendDataObserver; |
|
34 class CSatBIPDataSender; |
|
35 class CSatBIPDataReceiver; |
|
36 class MSatConnectionObserver; |
|
37 class TSatChannelIdInfo; |
|
38 class TNotificationEventBuf; |
|
39 class CSubConQosR5ParamSet; |
|
40 class CSubConExtensionParameterSet; |
|
41 class CSatSActiveWrapper; |
|
42 class CSatBIPSubConnEventObserver; |
|
43 |
|
44 /** Maximum Address Length */ |
|
45 const TInt KMaxAddressLength = 50; |
|
46 |
|
47 /** Enum for connection stage */ |
|
48 enum TSatBIPConnectionStage |
|
49 { |
|
50 ESatBIPClosed, |
|
51 ESatBIPConnect, |
|
52 ESatBIPConnected, |
|
53 ESatBIPCancelled |
|
54 }; |
|
55 |
|
56 /** |
|
57 * GPRS Data channel for Bearer Independent Protocol. |
|
58 * |
|
59 * @lib SatServer |
|
60 * @since Series 60 3.0 |
|
61 */ |
|
62 class CSatBIPGPRSDataChannel : public CActive, |
|
63 public MSatBIPDataChannel |
|
64 { |
|
65 public: |
|
66 |
|
67 // Constructors and destructor |
|
68 |
|
69 /** |
|
70 * Two-phased constructor. |
|
71 * @param aUtils Interface for EventDownload commands |
|
72 * @param aSocketServer Reference to Socket server. |
|
73 * @param aChannelId ID for this data channel |
|
74 * @param aConnection Reference to Connection |
|
75 * @param aSubConnection ID Reference to SubConnection |
|
76 */ |
|
77 static CSatBIPGPRSDataChannel* NewL( CSatBIPUtils& aUtils, |
|
78 RSocketServ& aSocketServer, |
|
79 TSatChannelIdInfo& aChannelId, |
|
80 RConnection& aConnection, |
|
81 RSubConnection& aSubConnection |
|
82 ); |
|
83 |
|
84 /** |
|
85 * Two-phased constructor. |
|
86 * @param aUtils Interface for EventDownload commands |
|
87 * @param aSocketServer Reference to Socket server. |
|
88 * @param aChannelId ID for this data channel needs to add to comments |
|
89 * @param aConnection Reference to Connection |
|
90 * @param aSubConnection ID Reference to SubConnection |
|
91 */ |
|
92 static CSatBIPGPRSDataChannel* NewLC( CSatBIPUtils& aUtils, |
|
93 RSocketServ& aSocketServer, |
|
94 TSatChannelIdInfo& aChannelId, |
|
95 RConnection& aConnection, |
|
96 RSubConnection& aSubConnection ); |
|
97 |
|
98 /** |
|
99 * Destructor. |
|
100 */ |
|
101 virtual ~CSatBIPGPRSDataChannel(); |
|
102 |
|
103 // New functions |
|
104 |
|
105 /** |
|
106 * Notification that data has been received. |
|
107 * @param aData Holds received data. |
|
108 */ |
|
109 void DataReceivedNotificationL( const TDesC8& aData ); |
|
110 |
|
111 /** |
|
112 * Error notification while receiving |
|
113 * @param aError The error code |
|
114 */ |
|
115 void DataReceiveError( const TInt aError ); |
|
116 |
|
117 /** |
|
118 * Granted parameters event is received correctly. |
|
119 * @param aEventBuffer Holds the negotiated QoS parameters. |
|
120 */ |
|
121 void GrantedEventReceivedL( const TNotificationEventBuf& aEventBuffer ); |
|
122 |
|
123 /** |
|
124 * Return the subconnection. |
|
125 * @return Reference to SubConnection |
|
126 */ |
|
127 RSubConnection& SubConnection() const; |
|
128 |
|
129 // From base class MSatBIPDataChannel |
|
130 |
|
131 /** |
|
132 * From MSatBIPDataChannel Sets up connection. Does not activate it yet. |
|
133 * @param aConnParams includes all needed information to open the connection. |
|
134 */ |
|
135 void SetupConnectionL( const TSatBipConnectionInfo& aConnParams ); |
|
136 |
|
137 /** |
|
138 * Notification that data has been received. |
|
139 * @param aData Holds received data. |
|
140 */ |
|
141 void ActivateConnectionL( MSatConnectionObserver* aObserver ); |
|
142 |
|
143 /** |
|
144 * From MSatBIPDataChannel Returns Negotiated bearer parameters |
|
145 * @param aResult Output Negotiated bearer parameters |
|
146 */ |
|
147 void GetNegotiatedQoSParams( RSat::TBearerParams& aResult ) const; |
|
148 |
|
149 /** |
|
150 * From MSatBIPDataChannel Sends the data or stores it into a |
|
151 * buffer for later send. |
|
152 * @param aData Data to be send. |
|
153 * @param aSendImmedeately Indicates whether to send immediately or |
|
154 * store data to buffer for later send. |
|
155 * @param aFreeBufferSize The number of bytes of empty size in the buffer |
|
156 * @param aObserver Observer of the SendData procedure. When data is sent, |
|
157 * observer gets notification. If data is stored for later send, |
|
158 * observer is not notified. |
|
159 * @return Error code indicating the status of the command execution. |
|
160 */ |
|
161 TInt SendDataL( const TDes8& aData, |
|
162 const TBool aSendImmediately, |
|
163 TInt& aFreeBufferSize, |
|
164 MSatSendDataObserver* aObserver ); |
|
165 |
|
166 /** |
|
167 * From MSatBIPDataChannel Receives the data from the buffer. |
|
168 * @param aData Data to receive. |
|
169 * @param aBytesToRead The number of requested bytes to return |
|
170 * @param aAvailableBytes Number of unread bytes left in the buffer. |
|
171 * @return Error code indicating the status of the command execution. |
|
172 */ |
|
173 TInt ReceiveDataL( TDes8& aData, const TInt aBytesToRead, |
|
174 TInt& aAvailableBytes ); |
|
175 |
|
176 /** |
|
177 * From MSatBIPDataChannel Returns the ID of this data channel. |
|
178 * @return ID of this channel. |
|
179 */ |
|
180 TInt ChannelId() const; |
|
181 |
|
182 /** |
|
183 * From MSatBIPDataChannel Returns the ID of this data channel to |
|
184 * ChannelStatus. |
|
185 * @return ID that can be placed to ChannelStatus |
|
186 */ |
|
187 TUint8 ChannelStatusChannelId() const; |
|
188 |
|
189 /** |
|
190 * From MSatBIPDataChannel Returns the status of this channel. |
|
191 * @return Status of this data channel |
|
192 */ |
|
193 TInt Status() const; |
|
194 |
|
195 /** |
|
196 * From MSatBIPDataChannel Closes the connection and empties the buffers. |
|
197 */ |
|
198 void CloseChannel(); |
|
199 |
|
200 /** |
|
201 * From MSatBIPDataChannel Cancels all activities. |
|
202 */ |
|
203 void CancelAll(); |
|
204 |
|
205 /** |
|
206 * From MSatBIPDataChannel Indicates whether PDP contex is active or not. |
|
207 * @return TBool indicating context activation. |
|
208 */ |
|
209 TBool IsContextActive() const; |
|
210 |
|
211 /** |
|
212 * From MSatBIPDataChannel Returns connection information |
|
213 * @return Connection information |
|
214 */ |
|
215 const MSatBIPDataChannel::TSatBipConnectionInfo& ConnInfo() const; |
|
216 |
|
217 /** |
|
218 * From MSatBIPDataChannel Close socket if type is udp. |
|
219 */ |
|
220 void StopUdpSocket(); |
|
221 |
|
222 |
|
223 // From base class CActive |
|
224 |
|
225 /** |
|
226 * From CActive |
|
227 */ |
|
228 void RunL(); |
|
229 |
|
230 /** |
|
231 * From CActive |
|
232 */ |
|
233 void DoCancel(); |
|
234 |
|
235 /** |
|
236 * From CActive |
|
237 */ |
|
238 TInt RunError( TInt aError ); |
|
239 |
|
240 |
|
241 |
|
242 private: |
|
243 |
|
244 /** |
|
245 * C++ default constructor. |
|
246 * @param aUtils Interface for EventDownload commands |
|
247 * @param aSocketServer Reference to Socket server. |
|
248 * @param aChannelId ID for this data channel |
|
249 * @param aConnection Reference to RConnection |
|
250 * @param aSubConnection Reference to RSubConnection |
|
251 */ |
|
252 CSatBIPGPRSDataChannel( CSatBIPUtils& aUtils, |
|
253 RSocketServ& aSocketServer, |
|
254 TSatChannelIdInfo& aChannelId, |
|
255 RConnection& aConnection, |
|
256 RSubConnection& aSubConnection ); |
|
257 |
|
258 /** |
|
259 * By default Symbian 2nd phase constructor is private. |
|
260 */ |
|
261 void ConstructL(); |
|
262 |
|
263 /** |
|
264 * Opens and connects / binds socket |
|
265 * @param aAddrFamily Address family to use. |
|
266 */ |
|
267 void OpenSocketL(); |
|
268 |
|
269 /** |
|
270 * Opens sub-connection and attaches socket into it |
|
271 */ |
|
272 void OpenSubConnection(); |
|
273 |
|
274 /** |
|
275 * Sets QoS parameters to connection |
|
276 */ |
|
277 void SetSubConQoSParamsL(); |
|
278 |
|
279 /** |
|
280 * Starts to receive data from socket |
|
281 */ |
|
282 void StartReceiveL(); |
|
283 |
|
284 /** |
|
285 * Defines the IP address. |
|
286 * @param aAddr An 8-bit descriptor containing the IP address |
|
287 * @return IP address in TBuf descriptor, which may be 8- or 16-bit. |
|
288 */ |
|
289 TInetAddr DestAddress( const TPtrC8& aAddr ); |
|
290 |
|
291 /** |
|
292 * Write QoS Values used for requesting Primary PDP context to RCmManager |
|
293 */ |
|
294 void WritePrimaryPDPContextQoSParamsL(); |
|
295 |
|
296 /** |
|
297 * Write Default QoS values to RCmManager |
|
298 */ |
|
299 void WriteDefaultQoSParamsL(); |
|
300 |
|
301 /** |
|
302 * Sets up QoS parameters for connection or subconnection |
|
303 */ |
|
304 void SetConnQoSParamsL(); |
|
305 |
|
306 /** |
|
307 * Get the negotiated QoS parameters from granted event |
|
308 * @param aEvent SubConNotificationEvent |
|
309 * @param aNegQoSRel5 hold the negotiated QoS in Rel5 got from event |
|
310 * @return errCode if it fails to get the parameters from event. |
|
311 */ |
|
312 TInt GetSubConQoSR5ParamsFromEvent( |
|
313 CSubConNotificationEvent& aEvent, |
|
314 TSatQoSParser::TQoSRel5& aNegQoSRel5 ); |
|
315 |
|
316 private: // Data |
|
317 |
|
318 /** |
|
319 * Receive Buffer |
|
320 */ |
|
321 TBuf8<KSatBIPMinReceiveBufferSize> iRcvBuffer; |
|
322 |
|
323 /** |
|
324 * Status of this channel |
|
325 */ |
|
326 TInt iChannelStatus; |
|
327 |
|
328 /** |
|
329 * Socket to send / receive data |
|
330 */ |
|
331 RSocket iSocket; |
|
332 |
|
333 /** |
|
334 * Connection information |
|
335 */ |
|
336 MSatBIPDataChannel::TSatBipConnectionInfo iConnInfo; |
|
337 |
|
338 /** |
|
339 * Destination address |
|
340 */ |
|
341 TInetAddr iDestAddr; |
|
342 |
|
343 /** |
|
344 * Sourceaddress |
|
345 */ |
|
346 TInetAddr iSourceAddr; |
|
347 |
|
348 /** |
|
349 * Reference to BIP Utils. |
|
350 * Not own. |
|
351 */ |
|
352 CSatBIPUtils& iUtils; |
|
353 |
|
354 /** |
|
355 * Connection stage |
|
356 */ |
|
357 TSatBIPConnectionStage iConnStage; |
|
358 |
|
359 /** |
|
360 * Indicates the protocol |
|
361 */ |
|
362 TBool iUseTcpProtocol; |
|
363 |
|
364 /** |
|
365 * Reference to a socket server |
|
366 * Not own. |
|
367 */ |
|
368 RSocketServ& iSocketServ; |
|
369 |
|
370 /** |
|
371 * Identifier for this channel |
|
372 * Not own. |
|
373 */ |
|
374 TSatChannelIdInfo& iChannelId; |
|
375 |
|
376 /** |
|
377 * Connection information |
|
378 * Not own |
|
379 */ |
|
380 RConnection& iConnection; |
|
381 |
|
382 /** |
|
383 * Subconnection, represents a data channel |
|
384 * Not own |
|
385 */ |
|
386 RSubConnection& iSubConnection; |
|
387 |
|
388 /** |
|
389 * SendBuffer |
|
390 * Own. |
|
391 */ |
|
392 HBufC8* iSendStore; |
|
393 |
|
394 /** |
|
395 * SendData observer |
|
396 * Own. |
|
397 */ |
|
398 MSatSendDataObserver* iSendDataObserver; |
|
399 |
|
400 /** |
|
401 * Sender object |
|
402 * Own. |
|
403 */ |
|
404 CSatBIPDataSender* iSender; |
|
405 |
|
406 /** |
|
407 * Receiver object |
|
408 * Own. |
|
409 */ |
|
410 CSatBIPDataReceiver* iReceiver; |
|
411 |
|
412 /** |
|
413 * Connection observer |
|
414 * Own. |
|
415 */ |
|
416 MSatConnectionObserver* iConnectionObserver; |
|
417 |
|
418 /** |
|
419 * Observer for SubConnection parameters event; |
|
420 * Own. |
|
421 */ |
|
422 CSatBIPSubConnEventObserver* iSubConnEventObserver; |
|
423 |
|
424 }; |
|
425 |
|
426 #endif // CSATBIPGPRSDATACHANNEL_H |
|
427 |
|
428 |
|