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 |
#ifndef ISIKERNEL_H
|
|
20 |
#define ISIKERNEL_H
|
|
21 |
|
|
22 |
|
|
23 |
// INCLUDE FILES
|
|
24 |
#include <kernel/kernel.h>
|
|
25 |
|
|
26 |
// MACROS
|
|
27 |
// None
|
|
28 |
|
|
29 |
// DATA TYPES
|
|
30 |
// None
|
|
31 |
|
|
32 |
// FUNCTION PROTOTYPES
|
|
33 |
//None
|
|
34 |
|
|
35 |
|
|
36 |
// FORWARD DECLARATIONS
|
|
37 |
class TIsiKernel;
|
|
38 |
class TIsiKernelSend;
|
|
39 |
class TIsiKernelReceiveC;
|
|
40 |
class TIsiKernelSubBlock;
|
|
41 |
|
|
42 |
enum TSubBlockType
|
|
43 |
{
|
|
44 |
|
|
45 |
EIsiSubBlockTypeId8Len8 = 1,
|
|
46 |
EIsiSubBlockTypeId8Len16,
|
|
47 |
EIsiSubBlockTypeId16Len8,
|
|
48 |
EIsiSubBlockTypeId16Len16,
|
|
49 |
EIsiSubBlockTypeId8Len32
|
|
50 |
|
|
51 |
};
|
|
52 |
|
|
53 |
enum TKernelIsiMessagePanics
|
|
54 |
{
|
|
55 |
EKernelIsiMessageInvalidOffset = 0,
|
|
56 |
EKernelIsiMessageInvalidSubBlockType,
|
|
57 |
EKernelIsiMessageInvalidSubblockLength,
|
|
58 |
EKernelIsiMessageInvalidValue,
|
|
59 |
EKernelIsiMessageInvalidResourceId
|
|
60 |
|
|
61 |
};
|
|
62 |
|
|
63 |
// CLASS DECLARATION
|
|
64 |
|
|
65 |
/**
|
|
66 |
* TIsiKernel
|
|
67 |
* This class implements the TIsiKernel
|
|
68 |
*/
|
|
69 |
class TIsiKernel
|
|
70 |
{
|
|
71 |
|
|
72 |
// Functions
|
|
73 |
public:
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Copies data into this TIsiKernel object replacing any existing data.
|
|
77 |
* @param TIsiKernel&
|
|
78 |
* @return TIsiKernel&
|
|
79 |
*/
|
|
80 |
IMPORT_C TIsiKernel& operator=( const TIsiKernel& );
|
|
81 |
|
|
82 |
|
|
83 |
protected:
|
|
84 |
/**
|
|
85 |
* Default C++ constructor.
|
|
86 |
* @param None
|
|
87 |
* @return
|
|
88 |
*/
|
|
89 |
IMPORT_C TIsiKernel();
|
|
90 |
|
|
91 |
|
|
92 |
// Data
|
|
93 |
protected:
|
|
94 |
|
|
95 |
|
|
96 |
};
|
|
97 |
|
|
98 |
class TIsiKernelReceiveC : public TIsiKernel
|
|
99 |
{
|
|
100 |
|
|
101 |
// Functions
|
|
102 |
public:
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Used to receive a message, subblock or data.
|
|
106 |
* @param const TDesC8& aBuf
|
|
107 |
*/
|
|
108 |
IMPORT_C TIsiKernelReceiveC( const TDesC8& aBuf );
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Get 16-bit data (TUint16) from message.
|
|
112 |
* @param const TUint aOffset
|
|
113 |
* @return TUint16
|
|
114 |
*/
|
|
115 |
IMPORT_C TUint16 Get16bit( const TUint aOffset ) const;
|
|
116 |
|
|
117 |
/**
|
|
118 |
* Get 32-bit data (TUint32) from message.
|
|
119 |
* @param const TUint aOffset
|
|
120 |
* @return TUint32
|
|
121 |
*/
|
|
122 |
IMPORT_C TUint32 Get32bit( const TUint aOffset ) const;
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Get 8-bit data (TUint8) from message.
|
|
126 |
* @param const TUint aOffset
|
|
127 |
* @return TUint8
|
|
128 |
*/
|
|
129 |
IMPORT_C TUint8 Get8bit( const TUint aOffset ) const;
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Get TPtr8 descriptor to message data.
|
|
133 |
* @param const TUint aOffset
|
|
134 |
* @param const TInt aLength
|
|
135 |
* @return const TPtrC8
|
|
136 |
*/
|
|
137 |
IMPORT_C const TPtrC8 GetData( const TUint aOffset, const TInt aLength ) const;
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Find subblock offset within message by using subblock id.
|
|
141 |
* @param TUint aSbStartOffset, TUint aSubblockId, TSubBlockType aType, TUint &aSubBlockOffset
|
|
142 |
* @return TInt
|
|
143 |
*/
|
|
144 |
IMPORT_C TInt FindSubBlockOffsetById ( const TUint aSbStartOffset,
|
|
145 |
const TUint aSubblockId,
|
|
146 |
const TSubBlockType aType,
|
|
147 |
TUint &aSubBlockOffset ) const;
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Find subblock offset within message by using subblock index
|
|
151 |
* @param TUint aSbStartOffset, TUint aSubblockId, TSubBlockType aType, TUint &aSubBlockOffset
|
|
152 |
* @return TInt
|
|
153 |
*/
|
|
154 |
IMPORT_C TInt FindSubBlockOffsetByIndex( const TUint aSbStartOffset,
|
|
155 |
const TUint aSubblockIndex,
|
|
156 |
const TSubBlockType aType,
|
|
157 |
TUint &aSubBlockOffset ) const;
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Get TPtrC8 descriptor to whole isi message.
|
|
161 |
* @return const TPtrC8
|
|
162 |
*/
|
|
163 |
IMPORT_C const TPtrC8 GetBuffer() const;
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Get 6-bit receiver device from message.
|
|
167 |
* @return TUint8
|
|
168 |
*/
|
|
169 |
IMPORT_C TUint8 GetReceiverDevice( ) const;
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Get 6-bit sender device from message.
|
|
173 |
* @return TUint8
|
|
174 |
*/
|
|
175 |
IMPORT_C TUint8 GetSenderDevice( ) const;
|
|
176 |
|
|
177 |
/**
|
|
178 |
* Gets 10-bit receiver object from message.
|
|
179 |
* @return TUint16
|
|
180 |
*/
|
|
181 |
IMPORT_C TUint16 GetReceiverObject( ) const;
|
|
182 |
|
|
183 |
/**
|
|
184 |
* Gets 10-bit sender object from message.
|
|
185 |
* @return TUint16
|
|
186 |
*/
|
|
187 |
IMPORT_C TUint16 GetSenderObject( ) const;
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Gets 24-bit extended resource id from message.
|
|
191 |
* @return TUint32
|
|
192 |
*/
|
|
193 |
IMPORT_C TUint32 GetExtendedResourceId( ) const;
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
// Data
|
|
198 |
protected:
|
|
199 |
|
|
200 |
// For message.
|
|
201 |
const TDesC8& iBuffer;
|
|
202 |
|
|
203 |
};
|
|
204 |
|
|
205 |
class TIsiKernelSend : public TIsiKernel
|
|
206 |
{
|
|
207 |
|
|
208 |
// Functions
|
|
209 |
public:
|
|
210 |
|
|
211 |
/**
|
|
212 |
* Adds message length and check fillers to the end of message,
|
|
213 |
* message buffer content and length are modified
|
|
214 |
* Must be used when creating a new message to be send.
|
|
215 |
* Checks also that critical information for the message is set.
|
|
216 |
* Critical information:Resource, MessageId.
|
|
217 |
* Returns the reference to the message to be send.
|
|
218 |
* @param None
|
|
219 |
* @return TDes8&
|
|
220 |
*/
|
|
221 |
IMPORT_C TDes8& Complete();
|
|
222 |
|
|
223 |
/**
|
|
224 |
* Copy descriptor to message data,
|
|
225 |
* message buffer content and length are modified.
|
|
226 |
* @param const TUint aOffset
|
|
227 |
* @param const TDesC8& aData
|
|
228 |
* @return none
|
|
229 |
*/
|
|
230 |
IMPORT_C void CopyData( const TUint aOffset, const TDesC8& aData );
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Used to generate a message, subblock or datastruct.
|
|
234 |
* Descriptor aBuf content is filled with zeroes
|
|
235 |
* and length is also reset to zero.
|
|
236 |
* @param TDes8& aBuf
|
|
237 |
* @param const TUint aLength
|
|
238 |
*/
|
|
239 |
IMPORT_C TIsiKernelSend( TDes8& aBuf, const TUint aLength );
|
|
240 |
|
|
241 |
/**
|
|
242 |
* Used to generate a message, subblock or datastruct.
|
|
243 |
* Descriptor aBuf content is filled with zeroes
|
|
244 |
* and length is also reset to zero.
|
|
245 |
* @param TDes8& aBuf
|
|
246 |
*/
|
|
247 |
IMPORT_C TIsiKernelSend( TDes8& aBuf );
|
|
248 |
|
|
249 |
/**
|
|
250 |
* Set 16-bit data (TUint16) to message,
|
|
251 |
* message buffer content and length are modified.
|
|
252 |
* @param const TUint aOffset
|
|
253 |
* @param const TUint16 aData
|
|
254 |
* @return none
|
|
255 |
*/
|
|
256 |
IMPORT_C void Set16bit( const TUint aOffset, const TUint16 aData );
|
|
257 |
|
|
258 |
/**
|
|
259 |
* Set 32-bit data (TUint) to message,
|
|
260 |
* message buffer content and length are modified.
|
|
261 |
* @param const TUint aOffset
|
|
262 |
* @param const TUint32 aData
|
|
263 |
* @return none
|
|
264 |
*/
|
|
265 |
IMPORT_C void Set32bit( const TUint aOffset, const TUint32 aData );
|
|
266 |
|
|
267 |
/**
|
|
268 |
* Set 8-bit (TUint8) data to message,
|
|
269 |
* message buffer content and length are modified.
|
|
270 |
* @param const TUint aOffset
|
|
271 |
* @param const TUint8 aData
|
|
272 |
* @return none
|
|
273 |
*/
|
|
274 |
IMPORT_C void Set8bit( const TUint aOffset, const TUint8 aData );
|
|
275 |
|
|
276 |
/**
|
|
277 |
* Set 6-bit (TUint8) receiver device to message,
|
|
278 |
* message buffer content and length are modified.
|
|
279 |
* @param const TUint8 aReceiverDevice
|
|
280 |
* @return none
|
|
281 |
*/
|
|
282 |
IMPORT_C void SetReceiverDevice( const TUint8 aReceiverDevice );
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Set 6-bit (TUint8) sender device to message,
|
|
286 |
* message buffer content and length are modified.
|
|
287 |
* @param const TUint8 aSenderDevice
|
|
288 |
* @return none
|
|
289 |
*/
|
|
290 |
IMPORT_C void SetSenderDevice( const TUint8 aSenderDevice );
|
|
291 |
|
|
292 |
/**
|
|
293 |
* Set 10-bit (TUint16) data to message,
|
|
294 |
* message buffer content and length are modified.
|
|
295 |
* @param const TUint16 aReceiverObject
|
|
296 |
* @return none
|
|
297 |
*/
|
|
298 |
IMPORT_C void SetReceiverObject( const TUint16 aReceiverObject );
|
|
299 |
|
|
300 |
/**
|
|
301 |
* Set 10-bit (TUint16) data to message,
|
|
302 |
* message buffer content and length are modified.
|
|
303 |
* @param const TUint16 aSenderObject
|
|
304 |
* @return none
|
|
305 |
*/
|
|
306 |
IMPORT_C void SetSenderObject( const TUint16 aSenderObject);
|
|
307 |
|
|
308 |
/**
|
|
309 |
* Set 24-bit (TUint32) extended resource id to message,
|
|
310 |
* message buffer content and length are modified.
|
|
311 |
* @param const TUint32 aExtendedResourceId
|
|
312 |
* @return none
|
|
313 |
* In the resource field in the PhoNet header is set to a fix value called PN_PREFIX telling
|
|
314 |
* that additional resource information can be found in the Type and SubType fields as follows:
|
|
315 |
* Media Receiver Sender PN_PREFIX Length Rec.Obj Send.Obj UTID MsgID Type SubType
|
|
316 |
*/
|
|
317 |
IMPORT_C void SetExtendedResourceId ( const TUint32 aExtendedResourceId );
|
|
318 |
|
|
319 |
// Data
|
|
320 |
protected:
|
|
321 |
|
|
322 |
// For message.
|
|
323 |
TDes8& iBuffer;
|
|
324 |
|
|
325 |
private:
|
|
326 |
TUint iFinalLength;
|
|
327 |
|
|
328 |
};
|
|
329 |
|
|
330 |
/**
|
|
331 |
* TIsiKernelSubBlock
|
|
332 |
* This class implements the TIsiKernelSubBlock
|
|
333 |
*/
|
|
334 |
class TIsiKernelSubBlock
|
|
335 |
{
|
|
336 |
public:
|
|
337 |
/**
|
|
338 |
* Used to generate a subblock
|
|
339 |
* @param TDes8& aMsg
|
|
340 |
* @param TUint16 aSbId
|
|
341 |
* @param const TSubBlockType aType
|
|
342 |
*/
|
|
343 |
IMPORT_C TIsiKernelSubBlock( TDes8& aMsg, TUint16 aSbId, const TSubBlockType aType );
|
|
344 |
|
|
345 |
/**
|
|
346 |
* Adds message length and check fillers to the end of message.
|
|
347 |
* Returns the reference to the message.
|
|
348 |
* @return TDes8&
|
|
349 |
*/
|
|
350 |
IMPORT_C TDes8& CompleteSubBlock();
|
|
351 |
|
|
352 |
protected:
|
|
353 |
TInt iSubBlockStart;
|
|
354 |
TDes8& iMsg;
|
|
355 |
TSubBlockType iSubBlockType;
|
|
356 |
|
|
357 |
};
|
|
358 |
|
|
359 |
|
|
360 |
#endif //ISIKERNEL_H
|