|
1 /* |
|
2 * Copyright (c) 2005-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /******************************************************************************** |
|
21 * |
|
22 * Stat Packetisation Transport |
|
23 * |
|
24 *******************************************************************************/ |
|
25 #ifndef __STATPACKETISATION_H__ |
|
26 #define __STATPACKETISATION_H__ |
|
27 |
|
28 /******************************************************************************** |
|
29 * |
|
30 * System Includes |
|
31 * |
|
32 *******************************************************************************/ |
|
33 |
|
34 /******************************************************************************** |
|
35 * |
|
36 * Local Includes |
|
37 * |
|
38 *******************************************************************************/ |
|
39 #include "stat_interfaces.h" |
|
40 |
|
41 /******************************************************************************** |
|
42 * |
|
43 * Definitions |
|
44 * |
|
45 *******************************************************************************/ |
|
46 #define KIDSize 4 |
|
47 #define KLengthSize 4 |
|
48 #define KHeaderSize (KIDSize + KLengthSize) |
|
49 |
|
50 /******************************************************************************** |
|
51 * |
|
52 * Classes |
|
53 * |
|
54 *******************************************************************************/ |
|
55 class CStatTransportPacketisation : public CBase, public MStatApiTransport, public MNotifyStatTransport |
|
56 { |
|
57 public: |
|
58 // construction |
|
59 static CStatTransportPacketisation *NewL( MNotifyStatEngine *aStatEngine, MStatNetwork *aStatNetwork, TUint aPacketSize ); |
|
60 CStatTransportPacketisation(); |
|
61 virtual ~CStatTransportPacketisation(); |
|
62 |
|
63 // from MStatApiTransport |
|
64 TInt InitialiseL( void ); |
|
65 TInt ConnectL( TDesC *aRemoteHost ); |
|
66 TInt RequestSend( const TUint aCommand, MDataSupplier *const aDataSupplier); |
|
67 TInt RequestReceive( void ); |
|
68 TInt Disconnect( void ); |
|
69 TInt Release( void ); |
|
70 TText8 *Error( void ); |
|
71 |
|
72 // from MNotifyStatTransport |
|
73 void HandleInitialise( TInt aResult ); |
|
74 void HandleConnect( TInt aResult ); |
|
75 void HandleSend( TInt aResult ); |
|
76 void HandleReceive( TInt aResult, TDesC8 *aData, TUint aDataLength ); |
|
77 void HandleDisconnect( TInt aResult ); |
|
78 void HandleRelease( TInt aResult ); |
|
79 void HandleError( TInt aError, void *aErrorData ); |
|
80 void HandleInfo( const TDesC *aInfo ); |
|
81 |
|
82 private: |
|
83 // private helper functions |
|
84 void ConstructL( MNotifyStatEngine *aStatEngine, MStatNetwork *aStatNetwork, TUint aPacketSize ); |
|
85 void SendHeaderPacket( TUint aCommand, TUint aDataLength ); |
|
86 void SendAckPacket( TUint aCommand ); |
|
87 void BuildHeader( TUint aCommand, TUint aDataLength ); |
|
88 void NotifyEngineSend( TUint aResult ); |
|
89 void NotifyEngineReceive( TUint aResult ); |
|
90 |
|
91 private: |
|
92 // status enums |
|
93 enum TSendStatus { ESendIdle, ESendingInitialHeader, ESendingFragmentHeader, ESendingFragmentData, ESendingFragmentAck }; |
|
94 enum TReceiveStatus { EReceiveIdle, EReceivingInitialHeader, EReceivingFragmentHeader, EReceivingData, EReceivingFragmentAck }; |
|
95 |
|
96 private: |
|
97 // general members |
|
98 MNotifyStatEngine *iStatEngine; |
|
99 MStatNetwork *iStatNetwork; |
|
100 TCommStatus iTransportStatus; |
|
101 TSendStatus iSendStatus; |
|
102 TReceiveStatus iRecvStatus; |
|
103 TUint iDataPacketSize; |
|
104 |
|
105 // send buffers |
|
106 TBuf8<KHeaderSize> iSendHeader; |
|
107 HBufC8 *iSendFragment; |
|
108 TUint iSendCommand; |
|
109 TUint iSendDataLength; |
|
110 TUint iSendDataWritten; |
|
111 TUint iSendDataAcknowledged; |
|
112 |
|
113 // receive buffers |
|
114 TUint iRecvCommand; |
|
115 TUint iRecvDataLength; |
|
116 TUint iRecvDataReceived; |
|
117 TUint iRecvDataAcknowledged; |
|
118 |
|
119 MDataConsumer *iDataConsumer; // The data consumer is |
|
120 // use to pass data from the |
|
121 // transport layer to the |
|
122 // command decoder. |
|
123 // Each specific object is |
|
124 // valid for the context of a |
|
125 // single command (and |
|
126 // destroyed). |
|
127 |
|
128 MDataSupplier *iDataSupplier; // This is owned by other |
|
129 // objects and we are passed |
|
130 // a pointer for our own use |
|
131 // but we do not maintain this. |
|
132 }; |
|
133 |
|
134 #endif // __STATTCPIP_H__ |