0
|
1 |
/*
|
|
2 |
* Copyright (c) 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 the License "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 |
#ifndef DISAUSERCHANNEL_H
|
|
21 |
#define DISAUSERCHANNEL_H
|
|
22 |
|
|
23 |
// INCLUDES
|
|
24 |
#include <kernel.h> // For DLogicalChannel
|
|
25 |
#include "internalapi.h" // For MIAD2ChannelApi, MChannel2IADApi
|
|
26 |
|
|
27 |
// CONSTANTS
|
|
28 |
|
|
29 |
// MACROS
|
|
30 |
|
|
31 |
// DATA TYPES
|
|
32 |
|
|
33 |
// FUNCTION PROTOTYPES
|
|
34 |
|
|
35 |
// FORWARD DECLARATIONS
|
|
36 |
|
|
37 |
// CLASS DECLARATION
|
|
38 |
class DQueue;
|
|
39 |
class DReqQueue;
|
|
40 |
class MDataMessageStatus;
|
|
41 |
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Channel to user side.
|
|
45 |
*
|
|
46 |
* @lib ISAAccessldd.ldd
|
|
47 |
*/
|
|
48 |
class DISAUserChannel : public DLogicalChannel, public MIAD2ChannelApi
|
|
49 |
{
|
|
50 |
|
|
51 |
public:
|
|
52 |
|
|
53 |
/**
|
|
54 |
* C++ default constructor.
|
|
55 |
*/
|
|
56 |
IMPORT_C DISAUserChannel();
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Destructor.
|
|
60 |
*/
|
|
61 |
~DISAUserChannel();
|
|
62 |
|
|
63 |
///// Functions from base class DLogicalChannel start
|
|
64 |
/**
|
|
65 |
* Second phase constructor. Run in user thread context. More description from DLogicalChannel.
|
|
66 |
* @param aUnit
|
|
67 |
* @param anInfo
|
|
68 |
* @param aVer
|
|
69 |
*/
|
|
70 |
virtual TInt DoCreate( TInt aUnit, const TDesC8* anInfo, const TVersion& aVer );
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Kernel message que function.
|
|
74 |
* @param aMsg
|
|
75 |
* @return None
|
|
76 |
*/
|
|
77 |
virtual void HandleMsg( TMessageBase* aMsg );
|
|
78 |
|
|
79 |
/**
|
|
80 |
* C++ default constructor.
|
|
81 |
*/
|
|
82 |
TInt Request( TInt aReqNo, TAny* a1, TAny* a2 );
|
|
83 |
///// Functions from base class DLogicalChannel end
|
|
84 |
|
|
85 |
///// Functions from MIAD2ChannelApi start
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Completes a channel request.
|
|
89 |
* @param aRequest, request to complete
|
|
90 |
* @param aStatusToComplete, status of the request to complete.
|
|
91 |
* @return void
|
|
92 |
*/
|
|
93 |
void CompleteChannelRequest( TInt aRequest, TInt aStatusToComplete );
|
|
94 |
|
|
95 |
/*
|
|
96 |
* Notifies the connection status.
|
|
97 |
* @param aStatus, connection status
|
|
98 |
* @return void
|
|
99 |
*/
|
|
100 |
void NotifyConnectionStatus( TIADConnectionStatus aStatus);
|
|
101 |
|
|
102 |
/*
|
|
103 |
* Notifies the state of data flowcontrol to this channel.
|
|
104 |
* @param aStatus, status of flowcontrol
|
|
105 |
* @return void
|
|
106 |
*/
|
|
107 |
void NotifyFlowCtrl( TIADFlowControlStatus aStatus );
|
|
108 |
|
|
109 |
/*
|
|
110 |
* Called when datamessage to this channel is to be received.
|
|
111 |
* When data message is written to user thread call MDataMesssageStatus::DataMessageDelivered.
|
|
112 |
* It's responsibility is to tell PEP that one data message e.g.a credit is used.
|
|
113 |
* PEP's should also keep count of data messages added to channel to be abel to control the legacy flowcontrol.
|
|
114 |
* @param aDataMessage, data message.
|
|
115 |
* @return void
|
|
116 |
*/
|
|
117 |
void ReceiveDataMsg( const TDesC8& aDataMessage );
|
|
118 |
|
|
119 |
/*
|
|
120 |
* Called when message to this channel is to be received.
|
|
121 |
* @param aDataMessage, data message.
|
|
122 |
* @return void
|
|
123 |
*/
|
|
124 |
void ReceiveMsg( const TDesC8& aMessage );
|
|
125 |
|
|
126 |
/*
|
|
127 |
* Register pep associated to this channel to listen data message deliveries.
|
|
128 |
* @param aPep, reference to pep.
|
|
129 |
* @return void
|
|
130 |
*/
|
|
131 |
void RegisterPep( MDataMessageStatus& aPep );
|
|
132 |
///// Functions from MIAD2ChannelApi end.
|
|
133 |
|
|
134 |
/*
|
|
135 |
* Returns the channelid of this channel.
|
|
136 |
* @return TUint16, a channel id.
|
|
137 |
*/
|
|
138 |
inline TUint16 GetChannelNumber(){ return iChannelNumber; };
|
|
139 |
|
|
140 |
///// Functions for internal use.
|
|
141 |
|
|
142 |
private:
|
|
143 |
|
|
144 |
/*
|
|
145 |
* Kernel message que function to be used in LDD thread context.
|
|
146 |
* @param aPtr, pointer to self
|
|
147 |
* @return void
|
|
148 |
*/
|
|
149 |
static void MsgQueFunc( TAny* aPtr );
|
|
150 |
|
|
151 |
/*
|
|
152 |
* DFC function that releases blocks used for messages.
|
|
153 |
* @param aPtr, pointer to self
|
|
154 |
* @return void
|
|
155 |
*/
|
|
156 |
static void CleanBlocksDfc( TAny* aPtr );
|
|
157 |
|
|
158 |
/*
|
|
159 |
* DFC function that releases blocks used for data messages.
|
|
160 |
* @param aPtr, pointer to self
|
|
161 |
* @return void
|
|
162 |
*/
|
|
163 |
static void CleanDataBlocksDfc( TAny* aPtr );
|
|
164 |
|
|
165 |
/*
|
|
166 |
* Handling of asynchronous requests.
|
|
167 |
* @param aFunction, request id
|
|
168 |
* @param a1, pointer to parameters.
|
|
169 |
* @return void
|
|
170 |
*/
|
|
171 |
void HandleAsyncRequest( TInt aFunction, TAny* a1 );
|
|
172 |
|
|
173 |
/*
|
|
174 |
* Handling of cancellation of asynchronous requests.
|
|
175 |
* @param aFunction, request id
|
|
176 |
* @param a1, pointer to parameters.
|
|
177 |
* @return void
|
|
178 |
*/
|
|
179 |
TInt HandleCancelRequest( TInt aFunction, TAny* a1 );
|
|
180 |
|
|
181 |
/*
|
|
182 |
* Handling of all requests.
|
|
183 |
* @param aFunction, request id
|
|
184 |
* @param a1, pointer to parameters.
|
|
185 |
* @param a2, pointer to parameters.
|
|
186 |
* @return void
|
|
187 |
*/
|
|
188 |
TInt HandleRequest( TInt aFunction, TAny* a1, TAny* a2 );
|
|
189 |
|
|
190 |
/*
|
|
191 |
* Handling of synchronous requests.
|
|
192 |
* @param aFunction, request id
|
|
193 |
* @param a1, pointer to parameters.
|
|
194 |
* @return void
|
|
195 |
*/
|
|
196 |
TInt HandleSyncRequest( TInt aFunction, TAny* a1 );
|
|
197 |
|
|
198 |
/**
|
|
199 |
* DFC function that empties message receive queue to user thread.
|
|
200 |
* @param aPtr, pointer to self
|
|
201 |
* @return None
|
|
202 |
*/
|
|
203 |
static void EmptyRxQueueDfc( TAny* aPtr );
|
|
204 |
|
|
205 |
/**
|
|
206 |
* DFC function that empties data message receive queue to user thread.
|
|
207 |
* @param aPtr, pointer to self
|
|
208 |
* @return None
|
|
209 |
*/
|
|
210 |
static void EmptyDataRxQueueDfc( TAny* aPtr );
|
|
211 |
|
|
212 |
/*
|
|
213 |
* DFC function to write and complete connection status change to user client.
|
|
214 |
* @param aPtr, pointer to self.
|
|
215 |
* @return void
|
|
216 |
*/
|
|
217 |
static void ConnectionStatusDfc( TAny* aPtr );
|
|
218 |
|
|
219 |
/**
|
|
220 |
* DFC function that completes channel requests to user thread.
|
|
221 |
* @param aPtr, pointer to self
|
|
222 |
* @return None
|
|
223 |
*/
|
|
224 |
static void CompleteChReqDfc( TAny* aPtr );
|
|
225 |
|
|
226 |
/**
|
|
227 |
* DFC function that completes flowcontrol status to user thread.
|
|
228 |
* @param aPtr, pointer to self
|
|
229 |
* @return None
|
|
230 |
*/
|
|
231 |
static void FlowCtrlStatusDfc( TAny* aPtr );
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Resets channel data message and message queues.
|
|
235 |
* @return None
|
|
236 |
*/
|
|
237 |
void ResetQueues();
|
|
238 |
|
|
239 |
/**
|
|
240 |
* Checks that function is run in appropriate thread context.
|
|
241 |
* NOTE! to be used only in UDEB for R&D purposes.
|
|
242 |
* @return None
|
|
243 |
*/
|
|
244 |
static void CheckDfc();
|
|
245 |
|
|
246 |
/**
|
|
247 |
* Do the cancellation of request.
|
|
248 |
* @param aRequest,
|
|
249 |
* @param aMask
|
|
250 |
* @return None
|
|
251 |
*/
|
|
252 |
void DoCancel( TInt aRequest, TInt aMask );
|
|
253 |
|
|
254 |
// CHECK FROM ALL HEADER FILES!!
|
|
255 |
//
|
|
256 |
// Compiler puts variables to 4bytes segments if 1,2,3 add filler bytes.
|
|
257 |
// So let's arrange variables so that they best fit in to 4byte segments.
|
|
258 |
// Also let's change TBool to TUint8 cause TBool is word (unless ANSI recommended bool is used.
|
|
259 |
|
|
260 |
private: // Data members
|
|
261 |
|
|
262 |
// Channel number of this channel.
|
|
263 |
TUint16 iChannelNumber;
|
|
264 |
TAny* iIADUserChannelNumberPtr;
|
|
265 |
// not owned
|
|
266 |
TAny* iIADConnectionStatusPtr;
|
|
267 |
TInt iConnectionStatus;
|
|
268 |
// Pointer to client flow control status, not owned
|
|
269 |
TAny* iIADFlowControlStatusPtr;
|
|
270 |
TInt iFlowCtrlStatus;
|
|
271 |
TInt iLastNotifiedFlowCtrlStatus;
|
|
272 |
// Pointers to client message buffers, not owned
|
|
273 |
TAny* iReceiveBufPtr;
|
|
274 |
// not owned
|
|
275 |
TAny* iDataReceiveBufPtr;
|
|
276 |
// not owned
|
|
277 |
TUint16* iNeededBufLen;
|
|
278 |
// not owned
|
|
279 |
TUint16* iNeededDataBufLen;
|
|
280 |
// owned
|
|
281 |
DQueue* iRx;
|
|
282 |
// owned
|
|
283 |
DQueue* iDataRx;
|
|
284 |
// owned
|
|
285 |
TDfc* iEmptyRxQueueDfc;
|
|
286 |
// owned
|
|
287 |
TDfc* iEmptyDataRxQueueDfc;
|
|
288 |
// owned
|
|
289 |
TDfc* iConnectionStatusDfc;
|
|
290 |
// owned
|
|
291 |
TDfc* iFlowCtrlStatusDfc;
|
|
292 |
// owned
|
|
293 |
TDfc* iCompleteChannelRequestDfc;
|
|
294 |
// Not owned.
|
|
295 |
DThread* iThread;
|
|
296 |
MDataMessageStatus* iPep;
|
|
297 |
MChannel2IADApi* iExtensionApi;
|
|
298 |
NFastMutex* iChFastMutex;
|
|
299 |
|
|
300 |
// owned
|
|
301 |
DReqQueue* iReqQueue;
|
|
302 |
TMessageQue iMsgQue;
|
|
303 |
DQueue* iRxDeAllocate;
|
|
304 |
TDfc* iCleanDfc;
|
|
305 |
DQueue* iDataRxDeAllocate;
|
|
306 |
TDfc* iCleanDataDfc;
|
|
307 |
|
|
308 |
};
|
|
309 |
|
|
310 |
#endif // DISAUSERCHANNEL_H
|
|
311 |
|
|
312 |
// End of File |