|
1 // Copyright (c) 2006-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 /** |
|
17 @file |
|
18 @publishedPartner |
|
19 */ |
|
20 |
|
21 #include <mtp/cmtptypecompoundbase.h> |
|
22 #include <mtp/cmtptypestring.h> |
|
23 #include <mtp/rmtptype.h> |
|
24 |
|
25 #include "mtpdatatypespanic.h" |
|
26 |
|
27 /** |
|
28 Destructor |
|
29 */ |
|
30 EXPORT_C CMTPTypeCompoundBase::~CMTPTypeCompoundBase() |
|
31 { |
|
32 Reset(); |
|
33 } |
|
34 |
|
35 /** |
|
36 Provides a copy of the specified element. |
|
37 @param aElementId The identifier of the requested element. |
|
38 @param aElement The MMTPType target data buffer. |
|
39 @leave KErrNotSupported, if the element is not readable. |
|
40 @leave One of the system wide error code, if a processing error occurs. |
|
41 @panic MTPDataTypes 3, if the target buffer type does not match the requested |
|
42 element. |
|
43 */ |
|
44 EXPORT_C void CMTPTypeCompoundBase::GetL(TInt aElementId, MMTPType& aElement) const |
|
45 { |
|
46 if (!ReadableElementL(aElementId)) |
|
47 { |
|
48 User::Leave(KErrNotSupported); |
|
49 } |
|
50 |
|
51 const TElementInfo& info(ElementInfo(aElementId)); |
|
52 if (info.iType == EMTPTypeFlat) |
|
53 { |
|
54 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
55 chunk->GetL(aElementId, aElement); |
|
56 } |
|
57 else |
|
58 { |
|
59 CopyL(*iChunks[info.iChunkId], aElement); |
|
60 } |
|
61 } |
|
62 |
|
63 /** |
|
64 Updates the specified element. |
|
65 @param aElementId The identifier of the element to update. |
|
66 @param aElement The MMTPType source data buffer. |
|
67 @leave KErrNotSupported, if the element is not writeable. |
|
68 @leave One of the system wide error code, if a processing error occurs. |
|
69 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
70 element. |
|
71 */ |
|
72 EXPORT_C void CMTPTypeCompoundBase::SetL(TInt aElementId, const MMTPType& aElement) |
|
73 { |
|
74 if (!WriteableElementL(aElementId)) |
|
75 { |
|
76 User::Leave(KErrNotSupported); |
|
77 } |
|
78 |
|
79 const TElementInfo& info(ElementInfo(aElementId)); |
|
80 if (info.iType == EMTPTypeFlat) |
|
81 { |
|
82 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
83 chunk->SetL(aElementId, aElement); |
|
84 } |
|
85 else |
|
86 { |
|
87 CopyL(aElement, *iChunks[info.iChunkId]); |
|
88 } |
|
89 } |
|
90 |
|
91 /** |
|
92 Updates the specified element. |
|
93 @param aElementId The identifier of the element to update. |
|
94 @param aData The source data. |
|
95 @leave KErrNotSupported, if the element is not writeable. |
|
96 @leave One of the system wide error code, if a processing error occurs. |
|
97 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
98 element. |
|
99 */ |
|
100 EXPORT_C void CMTPTypeCompoundBase::SetInt8L(TInt aElementId, TInt8 aData) |
|
101 { |
|
102 if (!WriteableElementL(aElementId)) |
|
103 { |
|
104 User::Leave(KErrNotSupported); |
|
105 } |
|
106 |
|
107 const TElementInfo& info(ElementInfo(aElementId)); |
|
108 switch (info.iType) |
|
109 { |
|
110 case EMTPTypeFlat: |
|
111 { |
|
112 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
113 chunk->SetInt8(aElementId, aData); |
|
114 } |
|
115 break; |
|
116 |
|
117 case EMTPTypeReference: |
|
118 { |
|
119 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
120 __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT8, Panic(EMTPTypeIdMismatch)); |
|
121 static_cast<TMTPTypeInt8&>(chunk->Data()).Set(aData); |
|
122 } |
|
123 break; |
|
124 |
|
125 case EMTPTypeINT8: |
|
126 { |
|
127 TMTPTypeInt8* chunk(static_cast<TMTPTypeInt8*>(iChunks[info.iChunkId])); |
|
128 chunk->Set(aData); |
|
129 } |
|
130 break; |
|
131 |
|
132 default: |
|
133 Panic(EMTPTypeIdMismatch); |
|
134 break; |
|
135 } |
|
136 } |
|
137 |
|
138 /** |
|
139 Updates the specified element. |
|
140 @param aElementId The identifier of the element to update. |
|
141 @param aData The source data. |
|
142 @leave KErrNotSupported, if the element is not writeable. |
|
143 @leave One of the system wide error code, if a processing error occurs. |
|
144 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
145 element. |
|
146 */ |
|
147 EXPORT_C void CMTPTypeCompoundBase::SetInt16L(TInt aElementId, TInt16 aData) |
|
148 { |
|
149 if (!WriteableElementL(aElementId)) |
|
150 { |
|
151 User::Leave(KErrNotSupported); |
|
152 } |
|
153 |
|
154 const TElementInfo& info(ElementInfo(aElementId)); |
|
155 switch (info.iType) |
|
156 { |
|
157 case EMTPTypeFlat: |
|
158 { |
|
159 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
160 chunk->SetInt16(aElementId, aData); |
|
161 } |
|
162 break; |
|
163 |
|
164 case EMTPTypeReference: |
|
165 { |
|
166 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
167 __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT16, Panic(EMTPTypeIdMismatch)); |
|
168 static_cast<TMTPTypeInt16&>(chunk->Data()).Set(aData); |
|
169 } |
|
170 break; |
|
171 |
|
172 case EMTPTypeINT16: |
|
173 { |
|
174 TMTPTypeInt16* chunk(static_cast<TMTPTypeInt16*>(iChunks[info.iChunkId])); |
|
175 chunk->Set(aData); |
|
176 } |
|
177 break; |
|
178 |
|
179 default: |
|
180 Panic(EMTPTypeIdMismatch); |
|
181 break; |
|
182 } |
|
183 } |
|
184 |
|
185 /** |
|
186 Updates the specified element. |
|
187 @param aElementId The identifier of the element to update. |
|
188 @param aData The source data. |
|
189 @leave KErrNotSupported, if the element is not writeable. |
|
190 @leave One of the system wide error code, if a processing error occurs. |
|
191 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
192 element. |
|
193 */ |
|
194 EXPORT_C void CMTPTypeCompoundBase::SetInt32L(TInt aElementId, TInt32 aData) |
|
195 { |
|
196 if (!WriteableElementL(aElementId)) |
|
197 { |
|
198 User::Leave(KErrNotSupported); |
|
199 } |
|
200 |
|
201 const TElementInfo& info(ElementInfo(aElementId)); |
|
202 switch (info.iType) |
|
203 { |
|
204 case EMTPTypeFlat: |
|
205 { |
|
206 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
207 chunk->SetInt32(aElementId, aData); |
|
208 } |
|
209 break; |
|
210 |
|
211 case EMTPTypeReference: |
|
212 { |
|
213 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
214 __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT32, Panic(EMTPTypeIdMismatch)); |
|
215 static_cast<TMTPTypeInt32&>(chunk->Data()).Set(aData); |
|
216 } |
|
217 break; |
|
218 |
|
219 case EMTPTypeINT32: |
|
220 { |
|
221 TMTPTypeInt32* chunk(static_cast<TMTPTypeInt32*>(iChunks[info.iChunkId])); |
|
222 chunk->Set(aData); |
|
223 } |
|
224 break; |
|
225 |
|
226 default: |
|
227 Panic(EMTPTypeIdMismatch); |
|
228 break; |
|
229 } |
|
230 } |
|
231 |
|
232 /** |
|
233 Updates the specified element. |
|
234 @param aElementId The identifier of the element to update. |
|
235 @param aData The source data. |
|
236 @leave KErrNotSupported, if the element is not writeable. |
|
237 @leave One of the system wide error code, if a processing error occurs. |
|
238 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
239 element. |
|
240 */ |
|
241 EXPORT_C void CMTPTypeCompoundBase::SetInt64L(TInt aElementId, TInt64 aData) |
|
242 { |
|
243 if (!WriteableElementL(aElementId)) |
|
244 { |
|
245 User::Leave(KErrNotSupported); |
|
246 } |
|
247 |
|
248 const TElementInfo& info(ElementInfo(aElementId)); |
|
249 switch (info.iType) |
|
250 { |
|
251 case EMTPTypeFlat: |
|
252 { |
|
253 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
254 chunk->SetInt64(aElementId, aData); |
|
255 } |
|
256 break; |
|
257 |
|
258 case EMTPTypeReference: |
|
259 { |
|
260 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
261 __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT64, Panic(EMTPTypeIdMismatch)); |
|
262 static_cast<TMTPTypeInt64&>(chunk->Data()).Set(aData); |
|
263 } |
|
264 break; |
|
265 |
|
266 case EMTPTypeINT64: |
|
267 { |
|
268 TMTPTypeInt64* chunk(static_cast<TMTPTypeInt64*>(iChunks[info.iChunkId])); |
|
269 chunk->Set(aData); |
|
270 } |
|
271 break; |
|
272 |
|
273 default: |
|
274 Panic(EMTPTypeIdMismatch); |
|
275 break; |
|
276 } |
|
277 } |
|
278 |
|
279 /** |
|
280 Updates the specified element. |
|
281 @param aElementId The identifier of the element to update. |
|
282 @param aData The source data. |
|
283 @leave KErrNotSupported, if the element is not writeable. |
|
284 @leave One of the system wide error code, if a processing error occurs. |
|
285 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
286 element. |
|
287 */ |
|
288 EXPORT_C void CMTPTypeCompoundBase::SetUint8L(TInt aElementId, TUint8 aData) |
|
289 { |
|
290 if (!WriteableElementL(aElementId)) |
|
291 { |
|
292 User::Leave(KErrNotSupported); |
|
293 } |
|
294 |
|
295 const TElementInfo& info(ElementInfo(aElementId)); |
|
296 switch (info.iType) |
|
297 { |
|
298 case EMTPTypeFlat: |
|
299 { |
|
300 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
301 chunk->SetUint8(aElementId, aData); |
|
302 } |
|
303 break; |
|
304 |
|
305 case EMTPTypeReference: |
|
306 { |
|
307 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
308 __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT8, Panic(EMTPTypeIdMismatch)); |
|
309 static_cast<TMTPTypeUint8&>(chunk->Data()).Set(aData); |
|
310 } |
|
311 break; |
|
312 |
|
313 case EMTPTypeUINT8: |
|
314 { |
|
315 TMTPTypeUint8* chunk(static_cast<TMTPTypeUint8*>(iChunks[info.iChunkId])); |
|
316 chunk->Set(aData); |
|
317 } |
|
318 break; |
|
319 |
|
320 default: |
|
321 Panic(EMTPTypeIdMismatch); |
|
322 break; |
|
323 } |
|
324 } |
|
325 |
|
326 /** |
|
327 Updates the specified element. |
|
328 @param aElementId The identifier of the element to update. |
|
329 @param aData The source data. |
|
330 @leave KErrNotSupported, if the element is not writeable. |
|
331 @leave One of the system wide error code, if a processing error occurs. |
|
332 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
333 element. |
|
334 */ |
|
335 EXPORT_C void CMTPTypeCompoundBase::SetUint16L(TInt aElementId, TUint16 aData) |
|
336 { |
|
337 if (!WriteableElementL(aElementId)) |
|
338 { |
|
339 User::Leave(KErrNotSupported); |
|
340 } |
|
341 |
|
342 const TElementInfo& info(ElementInfo(aElementId)); |
|
343 switch (info.iType) |
|
344 { |
|
345 case EMTPTypeFlat: |
|
346 { |
|
347 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
348 chunk->SetUint16(aElementId, aData); |
|
349 } |
|
350 break; |
|
351 |
|
352 case EMTPTypeReference: |
|
353 { |
|
354 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
355 __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT16, Panic(EMTPTypeIdMismatch)); |
|
356 static_cast<TMTPTypeUint16&>(chunk->Data()).Set(aData); |
|
357 } |
|
358 break; |
|
359 |
|
360 case EMTPTypeUINT16: |
|
361 { |
|
362 TMTPTypeUint16* chunk(static_cast<TMTPTypeUint16*>(iChunks[info.iChunkId])); |
|
363 chunk->Set(aData); |
|
364 } |
|
365 break; |
|
366 |
|
367 default: |
|
368 Panic(EMTPTypeIdMismatch); |
|
369 break; |
|
370 } |
|
371 } |
|
372 |
|
373 /** |
|
374 Updates the specified element. |
|
375 @param aElementId The identifier of the element to update. |
|
376 @param aData The source data. |
|
377 @leave KErrNotSupported, if the element is not writeable. |
|
378 @leave One of the system wide error code, if a processing error occurs. |
|
379 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
380 element. |
|
381 */ |
|
382 EXPORT_C void CMTPTypeCompoundBase::SetUint32L(TInt aElementId, TUint32 aData) |
|
383 { |
|
384 if (!WriteableElementL(aElementId)) |
|
385 { |
|
386 User::Leave(KErrNotSupported); |
|
387 } |
|
388 |
|
389 const TElementInfo& info(ElementInfo(aElementId)); |
|
390 switch (info.iType) |
|
391 { |
|
392 case EMTPTypeFlat: |
|
393 { |
|
394 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
395 chunk->SetUint32(aElementId, aData); |
|
396 } |
|
397 break; |
|
398 |
|
399 case EMTPTypeReference: |
|
400 { |
|
401 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
402 __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT32, Panic(EMTPTypeIdMismatch)); |
|
403 static_cast<TMTPTypeUint32&>(chunk->Data()).Set(aData); |
|
404 } |
|
405 break; |
|
406 |
|
407 case EMTPTypeUINT32: |
|
408 { |
|
409 TMTPTypeUint32* chunk(static_cast<TMTPTypeUint32*>(iChunks[info.iChunkId])); |
|
410 chunk->Set(aData); |
|
411 } |
|
412 break; |
|
413 |
|
414 default: |
|
415 Panic(EMTPTypeIdMismatch); |
|
416 break; |
|
417 } |
|
418 } |
|
419 |
|
420 /** |
|
421 Updates the specified element. |
|
422 @param aElementId The identifier of the element to update. |
|
423 @param aData The source data. |
|
424 @leave KErrNotSupported, if the element is not writeable. |
|
425 @leave One of the system wide error code, if a processing error occurs. |
|
426 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
427 element. |
|
428 */ |
|
429 EXPORT_C void CMTPTypeCompoundBase::SetUint64L(TInt aElementId, TUint64 aData) |
|
430 { |
|
431 if (!WriteableElementL(aElementId)) |
|
432 { |
|
433 User::Leave(KErrNotSupported); |
|
434 } |
|
435 |
|
436 const TElementInfo& info(ElementInfo(aElementId)); |
|
437 switch (info.iType) |
|
438 { |
|
439 case EMTPTypeFlat: |
|
440 { |
|
441 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
442 chunk->SetUint64(aElementId, aData); |
|
443 } |
|
444 break; |
|
445 |
|
446 case EMTPTypeReference: |
|
447 { |
|
448 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
449 __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT64, Panic(EMTPTypeIdMismatch)); |
|
450 static_cast<TMTPTypeUint64&>(chunk->Data()).Set(aData); |
|
451 } |
|
452 break; |
|
453 |
|
454 case EMTPTypeUINT64: |
|
455 { |
|
456 TMTPTypeUint64* chunk(static_cast<TMTPTypeUint64*>(iChunks[info.iChunkId])); |
|
457 chunk->Set(aData); |
|
458 } |
|
459 break; |
|
460 |
|
461 default: |
|
462 Panic(EMTPTypeIdMismatch); |
|
463 break; |
|
464 } |
|
465 } |
|
466 |
|
467 /** |
|
468 Updates the specified element. |
|
469 @param aElementId The identifier of the element to update. |
|
470 @param aString The source data. |
|
471 @leave KErrNotSupported, if the element is not writeable. |
|
472 @leave One of the system wide error code, if a processing error occurs. |
|
473 @panic MTPDataTypes 3, if the source data type does not match the requested |
|
474 element. |
|
475 */ |
|
476 EXPORT_C void CMTPTypeCompoundBase::SetStringL(TInt aElementId, const TDesC& aString) |
|
477 { |
|
478 if (!WriteableElementL(aElementId)) |
|
479 { |
|
480 User::Leave(KErrNotSupported); |
|
481 } |
|
482 |
|
483 const TElementInfo& info(ElementInfo(aElementId)); |
|
484 switch (info.iType) |
|
485 { |
|
486 case EMTPTypeReference: |
|
487 { |
|
488 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
489 __ASSERT_DEBUG(chunk->Type() == EMTPTypeString, Panic(EMTPTypeIdMismatch)); |
|
490 static_cast<CMTPTypeString&>(chunk->Data()).SetL(aString); |
|
491 } |
|
492 break; |
|
493 |
|
494 case EMTPTypeString: |
|
495 { |
|
496 CMTPTypeString* chunk(static_cast<CMTPTypeString*>(iChunks[info.iChunkId])); |
|
497 chunk->SetL(aString); |
|
498 } |
|
499 break; |
|
500 |
|
501 default: |
|
502 Panic(EMTPTypeIdMismatch); |
|
503 break; |
|
504 } |
|
505 } |
|
506 |
|
507 |
|
508 /** |
|
509 Provides the value of the specified element. |
|
510 @param aElementId The identifier of the requested element. |
|
511 @return The value of the element. |
|
512 @leave KErrNotSupported, if the element is not readable. |
|
513 @leave One of the system wide error code, if a processing error occurs. |
|
514 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
515 element. |
|
516 */ |
|
517 EXPORT_C TInt8 CMTPTypeCompoundBase::Int8L(TInt aElementId) const |
|
518 { |
|
519 if (!ReadableElementL(aElementId)) |
|
520 { |
|
521 User::Leave(KErrNotSupported); |
|
522 } |
|
523 |
|
524 TInt8 ret(0); |
|
525 |
|
526 const TElementInfo& info(ElementInfo(aElementId)); |
|
527 switch (info.iType) |
|
528 { |
|
529 case EMTPTypeFlat: |
|
530 { |
|
531 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
532 ret = chunk->Int8(aElementId); |
|
533 } |
|
534 break; |
|
535 |
|
536 case EMTPTypeReference: |
|
537 { |
|
538 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
539 __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT8, Panic(EMTPTypeIdMismatch)); |
|
540 ret = static_cast<TMTPTypeInt8&>(chunk->Data()).Value(); |
|
541 } |
|
542 break; |
|
543 |
|
544 case EMTPTypeINT8: |
|
545 { |
|
546 TMTPTypeInt8* chunk(static_cast<TMTPTypeInt8*>(iChunks[info.iChunkId])); |
|
547 ret = chunk->Value(); |
|
548 } |
|
549 break; |
|
550 |
|
551 default: |
|
552 Panic(EMTPTypeIdMismatch); |
|
553 break; |
|
554 } |
|
555 |
|
556 return ret; |
|
557 } |
|
558 |
|
559 /** |
|
560 Provides the value of the specified element. |
|
561 @param aElementId The identifier of the requested element. |
|
562 @return The value of the element. |
|
563 @leave KErrNotSupported, if the element is not readable. |
|
564 @leave One of the system wide error code, if a processing error occurs. |
|
565 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
566 element. |
|
567 */ |
|
568 EXPORT_C TInt16 CMTPTypeCompoundBase::Int16L(TInt aElementId) const |
|
569 { |
|
570 if (!ReadableElementL(aElementId)) |
|
571 { |
|
572 User::Leave(KErrNotSupported); |
|
573 } |
|
574 |
|
575 TInt16 ret(0); |
|
576 |
|
577 const TElementInfo& info(ElementInfo(aElementId)); |
|
578 switch (info.iType) |
|
579 { |
|
580 case EMTPTypeFlat: |
|
581 { |
|
582 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
583 ret = chunk->Int16(aElementId); |
|
584 } |
|
585 break; |
|
586 |
|
587 case EMTPTypeReference: |
|
588 { |
|
589 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
590 __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT16, Panic(EMTPTypeIdMismatch)); |
|
591 ret = static_cast<TMTPTypeInt16&>(chunk->Data()).Value(); |
|
592 } |
|
593 break; |
|
594 |
|
595 case EMTPTypeINT16: |
|
596 { |
|
597 TMTPTypeInt16* chunk(static_cast<TMTPTypeInt16*>(iChunks[info.iChunkId])); |
|
598 ret = chunk->Value(); |
|
599 } |
|
600 break; |
|
601 |
|
602 default: |
|
603 Panic(EMTPTypeIdMismatch); |
|
604 break; |
|
605 } |
|
606 |
|
607 return ret; |
|
608 } |
|
609 |
|
610 /** |
|
611 Provides the value of the specified element. |
|
612 @param aElementId The identifier of the requested element. |
|
613 @return The value of the element. |
|
614 @leave KErrNotSupported, if the element is not readable. |
|
615 @leave One of the system wide error code, if a processing error occurs. |
|
616 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
617 element. |
|
618 */ |
|
619 EXPORT_C TInt32 CMTPTypeCompoundBase::Int32L(TInt aElementId) const |
|
620 { |
|
621 if (!ReadableElementL(aElementId)) |
|
622 { |
|
623 User::Leave(KErrNotSupported); |
|
624 } |
|
625 |
|
626 TInt32 ret(0); |
|
627 |
|
628 const TElementInfo& info(ElementInfo(aElementId)); |
|
629 switch (info.iType) |
|
630 { |
|
631 case EMTPTypeFlat: |
|
632 { |
|
633 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
634 ret = chunk->Int32(aElementId); |
|
635 } |
|
636 break; |
|
637 |
|
638 case EMTPTypeReference: |
|
639 { |
|
640 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
641 __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT32, Panic(EMTPTypeIdMismatch)); |
|
642 ret = static_cast<TMTPTypeInt32&>(chunk->Data()).Value(); |
|
643 } |
|
644 break; |
|
645 |
|
646 case EMTPTypeINT32: |
|
647 { |
|
648 TMTPTypeInt32* chunk(static_cast<TMTPTypeInt32*>(iChunks[info.iChunkId])); |
|
649 ret = chunk->Value(); |
|
650 } |
|
651 break; |
|
652 |
|
653 default: |
|
654 Panic(EMTPTypeIdMismatch); |
|
655 break; |
|
656 } |
|
657 |
|
658 return ret; |
|
659 } |
|
660 |
|
661 /** |
|
662 Provides the value of the specified element. |
|
663 @param aElementId The identifier of the requested element. |
|
664 @return The value of the element. |
|
665 @leave KErrNotSupported, if the element is not readable. |
|
666 @leave One of the system wide error code, if a processing error occurs. |
|
667 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
668 element. |
|
669 */ |
|
670 EXPORT_C TInt64 CMTPTypeCompoundBase::Int64L(TInt aElementId) const |
|
671 { |
|
672 if (!ReadableElementL(aElementId)) |
|
673 { |
|
674 User::Leave(KErrNotSupported); |
|
675 } |
|
676 |
|
677 TInt64 ret(0); |
|
678 |
|
679 const TElementInfo& info(ElementInfo(aElementId)); |
|
680 switch (info.iType) |
|
681 { |
|
682 case EMTPTypeFlat: |
|
683 { |
|
684 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
685 ret = chunk->Int64(aElementId); |
|
686 } |
|
687 break; |
|
688 |
|
689 case EMTPTypeReference: |
|
690 { |
|
691 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
692 __ASSERT_DEBUG(chunk->Type() == EMTPTypeINT64, Panic(EMTPTypeIdMismatch)); |
|
693 ret = static_cast<TMTPTypeInt64&>(chunk->Data()).Value(); |
|
694 } |
|
695 break; |
|
696 |
|
697 case EMTPTypeINT64: |
|
698 { |
|
699 TMTPTypeInt64* chunk(static_cast<TMTPTypeInt64*>(iChunks[info.iChunkId])); |
|
700 ret = chunk->Value(); |
|
701 } |
|
702 break; |
|
703 |
|
704 default: |
|
705 Panic(EMTPTypeIdMismatch); |
|
706 break; |
|
707 } |
|
708 |
|
709 return ret; |
|
710 } |
|
711 |
|
712 /** |
|
713 Provides the value of the specified element. |
|
714 @param aElementId The identifier of the requested element. |
|
715 @return The value of the element. |
|
716 @leave KErrNotSupported, if the element is not readable. |
|
717 @leave One of the system wide error code, if a processing error occurs. |
|
718 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
719 element. |
|
720 */ |
|
721 EXPORT_C TUint8 CMTPTypeCompoundBase::Uint8L(TInt aElementId) const |
|
722 { |
|
723 if (!ReadableElementL(aElementId)) |
|
724 { |
|
725 User::Leave(KErrNotSupported); |
|
726 } |
|
727 |
|
728 TUint8 ret(0); |
|
729 |
|
730 const TElementInfo& info(ElementInfo(aElementId)); |
|
731 switch (info.iType) |
|
732 { |
|
733 case EMTPTypeFlat: |
|
734 { |
|
735 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
736 ret = chunk->Uint8(aElementId); |
|
737 } |
|
738 break; |
|
739 |
|
740 case EMTPTypeReference: |
|
741 { |
|
742 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
743 __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT8, Panic(EMTPTypeIdMismatch)); |
|
744 ret = static_cast<TMTPTypeUint8&>(chunk->Data()).Value(); |
|
745 } |
|
746 break; |
|
747 |
|
748 case EMTPTypeUINT8: |
|
749 { |
|
750 TMTPTypeUint8* chunk(static_cast<TMTPTypeUint8*>(iChunks[info.iChunkId])); |
|
751 ret = chunk->Value(); |
|
752 } |
|
753 break; |
|
754 |
|
755 default: |
|
756 Panic(EMTPTypeIdMismatch); |
|
757 break; |
|
758 } |
|
759 |
|
760 return ret; |
|
761 } |
|
762 |
|
763 /** |
|
764 Provides the value of the specified element. |
|
765 @param aElementId The identifier of the requested element. |
|
766 @return The value of the element. |
|
767 @leave KErrNotSupported, if the element is not readable. |
|
768 @leave One of the system wide error code, if a processing error occurs. |
|
769 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
770 element. |
|
771 */ |
|
772 EXPORT_C TUint16 CMTPTypeCompoundBase::Uint16L(TInt aElementId) const |
|
773 { |
|
774 if (!ReadableElementL(aElementId)) |
|
775 { |
|
776 User::Leave(KErrNotSupported); |
|
777 } |
|
778 |
|
779 TUint16 ret(0); |
|
780 |
|
781 const TElementInfo& info(ElementInfo(aElementId)); |
|
782 switch (info.iType) |
|
783 { |
|
784 case EMTPTypeFlat: |
|
785 { |
|
786 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
787 ret = chunk->Uint16(aElementId); |
|
788 } |
|
789 break; |
|
790 |
|
791 case EMTPTypeReference: |
|
792 { |
|
793 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
794 __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT16, Panic(EMTPTypeIdMismatch)); |
|
795 ret = static_cast<TMTPTypeUint16&>(chunk->Data()).Value(); |
|
796 } |
|
797 break; |
|
798 |
|
799 case EMTPTypeUINT16: |
|
800 { |
|
801 TMTPTypeUint16* chunk(static_cast<TMTPTypeUint16*>(iChunks[info.iChunkId])); |
|
802 ret = chunk->Value(); |
|
803 } |
|
804 break; |
|
805 |
|
806 default: |
|
807 Panic(EMTPTypeIdMismatch); |
|
808 break; |
|
809 } |
|
810 |
|
811 return ret; |
|
812 } |
|
813 |
|
814 /** |
|
815 Provides the value of the specified element. |
|
816 @param aElementId The identifier of the requested element. |
|
817 @return The value of the element. |
|
818 @leave KErrNotSupported, if the element is not readable. |
|
819 @leave One of the system wide error code, if a processing error occurs. |
|
820 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
821 element. |
|
822 */ |
|
823 EXPORT_C TUint32 CMTPTypeCompoundBase::Uint32L(TInt aElementId) const |
|
824 { |
|
825 if (!ReadableElementL(aElementId)) |
|
826 { |
|
827 User::Leave(KErrNotSupported); |
|
828 } |
|
829 |
|
830 TUint32 ret(0); |
|
831 |
|
832 const TElementInfo& info(ElementInfo(aElementId)); |
|
833 switch (info.iType) |
|
834 { |
|
835 case EMTPTypeFlat: |
|
836 { |
|
837 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
838 ret = chunk->Uint32(aElementId); |
|
839 } |
|
840 break; |
|
841 |
|
842 case EMTPTypeReference: |
|
843 { |
|
844 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
845 __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT32, Panic(EMTPTypeIdMismatch)); |
|
846 ret = static_cast<TMTPTypeUint32&>(chunk->Data()).Value(); |
|
847 } |
|
848 break; |
|
849 |
|
850 case EMTPTypeUINT32: |
|
851 { |
|
852 TMTPTypeUint32* chunk(static_cast<TMTPTypeUint32*>(iChunks[info.iChunkId])); |
|
853 ret = chunk->Value(); |
|
854 } |
|
855 break; |
|
856 |
|
857 case EMTPTypeUndefined: |
|
858 default: |
|
859 { |
|
860 TMTPTypeUint32 chunk; |
|
861 GetL(aElementId, chunk); |
|
862 ret = chunk.Value(); |
|
863 } |
|
864 break; |
|
865 } |
|
866 |
|
867 return ret; |
|
868 } |
|
869 |
|
870 /** |
|
871 Provides the value of the specified element. |
|
872 @param aElementId The identifier of the requested element. |
|
873 @return The value of the element. |
|
874 @leave KErrNotSupported, if the element is not readable. |
|
875 @leave One of the system wide error code, if a processing error occurs. |
|
876 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
877 element. |
|
878 */ |
|
879 EXPORT_C TUint64 CMTPTypeCompoundBase::Uint64L(TInt aElementId) const |
|
880 { |
|
881 if (!ReadableElementL(aElementId)) |
|
882 { |
|
883 User::Leave(KErrNotSupported); |
|
884 } |
|
885 |
|
886 TUint64 ret(0); |
|
887 |
|
888 const TElementInfo& info(ElementInfo(aElementId)); |
|
889 switch (info.iType) |
|
890 { |
|
891 case EMTPTypeFlat: |
|
892 { |
|
893 RMTPTypeCompoundFlatChunk* chunk(static_cast<RMTPTypeCompoundFlatChunk*>(iChunks[info.iChunkId])); |
|
894 ret = chunk->Uint64(aElementId); |
|
895 } |
|
896 break; |
|
897 |
|
898 case EMTPTypeReference: |
|
899 { |
|
900 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
901 __ASSERT_DEBUG(chunk->Type() == EMTPTypeUINT64, Panic(EMTPTypeIdMismatch)); |
|
902 ret = static_cast<TMTPTypeUint64&>(chunk->Data()).Value(); |
|
903 } |
|
904 break; |
|
905 |
|
906 case EMTPTypeUINT64: |
|
907 { |
|
908 TMTPTypeUint64* chunk(static_cast<TMTPTypeUint64*>(iChunks[info.iChunkId])); |
|
909 ret = chunk->Value(); |
|
910 } |
|
911 break; |
|
912 |
|
913 default: |
|
914 Panic(EMTPTypeIdMismatch); |
|
915 break; |
|
916 } |
|
917 |
|
918 return ret; |
|
919 } |
|
920 |
|
921 /** |
|
922 Provides the value of the specified element. |
|
923 @param aElementId The identifier of the requested element. |
|
924 @return The value of the element. |
|
925 @leave KErrNotSupported, if the element is not readable. |
|
926 @leave One of the system wide error code, if a processing error occurs. |
|
927 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
928 element. |
|
929 */ |
|
930 EXPORT_C TUint8 CMTPTypeCompoundBase::StringNumCharsL(TInt aElementId) const |
|
931 { |
|
932 if (!ReadableElementL(aElementId)) |
|
933 { |
|
934 User::Leave(KErrNotSupported); |
|
935 } |
|
936 |
|
937 TUint8 ret(0); |
|
938 |
|
939 const TElementInfo& info(ElementInfo(aElementId)); |
|
940 switch (info.iType) |
|
941 { |
|
942 case EMTPTypeReference: |
|
943 { |
|
944 |
|
945 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
946 __ASSERT_DEBUG(chunk->Type() == EMTPTypeString, Panic(EMTPTypeIdMismatch)); |
|
947 ret = static_cast<CMTPTypeString&>(chunk->Data()).NumChars(); |
|
948 } |
|
949 break; |
|
950 |
|
951 case EMTPTypeString: |
|
952 { |
|
953 CMTPTypeString* chunk(static_cast<CMTPTypeString*>(iChunks[info.iChunkId])); |
|
954 ret = chunk->NumChars(); |
|
955 } |
|
956 break; |
|
957 |
|
958 default: |
|
959 Panic(EMTPTypeIdMismatch); |
|
960 break; |
|
961 } |
|
962 |
|
963 return ret; |
|
964 } |
|
965 |
|
966 /** |
|
967 Provides the value of the specified element. |
|
968 @param aElementId The identifier of the requested element. |
|
969 @return The value of the element. |
|
970 @leave KErrNotSupported, if the element is not readable. |
|
971 @leave One of the system wide error code, if a processing error occurs. |
|
972 @panic MTPDataTypes 3, if the source buffer type does not match the requested |
|
973 element. |
|
974 */ |
|
975 EXPORT_C const TDesC& CMTPTypeCompoundBase::StringCharsL(TInt aElementId) const |
|
976 { |
|
977 if (!ReadableElementL(aElementId)) |
|
978 { |
|
979 User::Leave(KErrNotSupported); |
|
980 } |
|
981 |
|
982 const TElementInfo& info(ElementInfo(aElementId)); |
|
983 if (info.iType == EMTPTypeString) |
|
984 { |
|
985 CMTPTypeString* chunk(static_cast<CMTPTypeString*>(iChunks[info.iChunkId])); |
|
986 return chunk->StringChars(); |
|
987 } |
|
988 else if (info.iType == EMTPTypeReference) |
|
989 { |
|
990 RMTPType* chunk(static_cast<RMTPType*>(iChunks[info.iChunkId])); |
|
991 __ASSERT_DEBUG(chunk->Type() == EMTPTypeString, Panic(EMTPTypeIdMismatch)); |
|
992 return static_cast<CMTPTypeString&>(chunk->Data()).StringChars(); |
|
993 } |
|
994 else |
|
995 { |
|
996 Panic(EMTPTypeIdMismatch); |
|
997 } |
|
998 |
|
999 return KNullDesC; |
|
1000 } |
|
1001 |
|
1002 EXPORT_C TInt CMTPTypeCompoundBase::FirstReadChunk(TPtrC8& aChunk) const |
|
1003 { |
|
1004 TInt err(KErrNone); |
|
1005 aChunk.Set(NULL, 0); |
|
1006 |
|
1007 if (iChunks.Count() == 0) |
|
1008 { |
|
1009 err = KErrNotFound; |
|
1010 } |
|
1011 else |
|
1012 { |
|
1013 iReadChunk = 0; |
|
1014 err = UpdateReadState(iChunks[iReadChunk]->FirstReadChunk(aChunk)); |
|
1015 } |
|
1016 |
|
1017 return err; |
|
1018 } |
|
1019 |
|
1020 EXPORT_C TInt CMTPTypeCompoundBase::NextReadChunk(TPtrC8& aChunk) const |
|
1021 { |
|
1022 TInt err(KErrNotReady); |
|
1023 aChunk.Set(NULL, 0); |
|
1024 |
|
1025 switch (iReadSequenceState) |
|
1026 { |
|
1027 case EInProgressFirst: |
|
1028 err = UpdateReadState(iChunks[iReadChunk]->FirstReadChunk(aChunk)); |
|
1029 break; |
|
1030 |
|
1031 case EInProgressNext: |
|
1032 err = UpdateReadState(iChunks[iReadChunk]->NextReadChunk(aChunk)); |
|
1033 break; |
|
1034 |
|
1035 case EIdle: |
|
1036 default: |
|
1037 err = KErrNotReady; |
|
1038 break; |
|
1039 } |
|
1040 |
|
1041 return err; |
|
1042 } |
|
1043 |
|
1044 EXPORT_C TInt CMTPTypeCompoundBase::FirstWriteChunk(TPtr8& aChunk) |
|
1045 { |
|
1046 TInt err(KErrNone); |
|
1047 aChunk.Set(NULL, 0, 0); |
|
1048 |
|
1049 if (iChunks.Count() == 0) |
|
1050 { |
|
1051 err = KErrNotFound; |
|
1052 } |
|
1053 else |
|
1054 { |
|
1055 iWriteChunk = 0; |
|
1056 err = UpdateWriteState(iChunks[iWriteChunk]->FirstWriteChunk(aChunk)); |
|
1057 } |
|
1058 |
|
1059 return err; |
|
1060 } |
|
1061 |
|
1062 EXPORT_C TInt CMTPTypeCompoundBase::NextWriteChunk(TPtr8& aChunk) |
|
1063 { |
|
1064 TInt err(KErrNotReady); |
|
1065 aChunk.Set(NULL, 0, 0); |
|
1066 |
|
1067 switch (iWriteSequenceState) |
|
1068 { |
|
1069 case EInProgressFirst: |
|
1070 err = UpdateWriteState(iChunks[iWriteChunk]->FirstWriteChunk(aChunk)); |
|
1071 break; |
|
1072 |
|
1073 case EInProgressNext: |
|
1074 err = UpdateWriteState(iChunks[iWriteChunk]->NextWriteChunk(aChunk)); |
|
1075 break; |
|
1076 |
|
1077 case EIdle: |
|
1078 default: |
|
1079 err = KErrNotReady; |
|
1080 break; |
|
1081 } |
|
1082 |
|
1083 return err; |
|
1084 } |
|
1085 |
|
1086 EXPORT_C TInt CMTPTypeCompoundBase::NextWriteChunk(TPtr8& aChunk, TUint aDataLength) |
|
1087 { |
|
1088 TInt err(KErrNotReady); |
|
1089 aChunk.Set(NULL, 0, 0); |
|
1090 |
|
1091 switch (iWriteSequenceState) |
|
1092 { |
|
1093 case EInProgressFirst: |
|
1094 err = UpdateWriteState(iChunks[iWriteChunk]->FirstWriteChunk(aChunk, aDataLength)); |
|
1095 break; |
|
1096 |
|
1097 case EInProgressNext: |
|
1098 err = UpdateWriteState(iChunks[iWriteChunk]->NextWriteChunk(aChunk, aDataLength)); |
|
1099 break; |
|
1100 |
|
1101 case EIdle: |
|
1102 default: |
|
1103 err = KErrNotReady; |
|
1104 break; |
|
1105 } |
|
1106 |
|
1107 return err; |
|
1108 } |
|
1109 |
|
1110 EXPORT_C TUint64 CMTPTypeCompoundBase::Size() const |
|
1111 { |
|
1112 TUint64 size(0); |
|
1113 TUint numChunks(iChunks.Count()); |
|
1114 for (TUint i(0); (i < numChunks); i++) |
|
1115 { |
|
1116 TUint64 chunkSize(iChunks[i]->Size()); |
|
1117 size += chunkSize; |
|
1118 } |
|
1119 |
|
1120 return size; |
|
1121 } |
|
1122 |
|
1123 EXPORT_C TUint CMTPTypeCompoundBase::Type() const |
|
1124 { |
|
1125 return EMTPTypeCompound; |
|
1126 } |
|
1127 |
|
1128 EXPORT_C TBool CMTPTypeCompoundBase::CommitRequired() const |
|
1129 { |
|
1130 return ETrue; |
|
1131 } |
|
1132 |
|
1133 EXPORT_C MMTPType* CMTPTypeCompoundBase::CommitChunkL(TPtr8& aChunk) |
|
1134 { |
|
1135 MMTPType *chunk(iChunks[iWriteChunk]); |
|
1136 MMTPType* res = NULL; |
|
1137 if (chunk->CommitRequired()) |
|
1138 { |
|
1139 res = chunk->CommitChunkL(aChunk); |
|
1140 } |
|
1141 |
|
1142 if (iJustInTimeConstruction) |
|
1143 { |
|
1144 UpdateWriteState(iWriteErr); |
|
1145 } |
|
1146 |
|
1147 if (iWriteSequenceState == EInProgressFirst) |
|
1148 { |
|
1149 iWriteChunk++; |
|
1150 } |
|
1151 return res; |
|
1152 } |
|
1153 |
|
1154 |
|
1155 EXPORT_C TInt CMTPTypeCompoundBase::Validate() const |
|
1156 { |
|
1157 const TUint count(ChunkCount()); |
|
1158 TInt ret(KMTPDataTypeInvalid); |
|
1159 if (iExpectedChunkCount == KVariableChunkCount) |
|
1160 { |
|
1161 ret = ValidateChunkCount(); |
|
1162 } |
|
1163 else if (count == iExpectedChunkCount) |
|
1164 { |
|
1165 /* |
|
1166 The element count is correct. Verify that the last element was |
|
1167 correctly received. |
|
1168 */ |
|
1169 ret = KErrNone; |
|
1170 } |
|
1171 |
|
1172 if (ret == KErrNone) |
|
1173 { |
|
1174 /* |
|
1175 The element count is correct. Verify that the last element was |
|
1176 correctly received. |
|
1177 */ |
|
1178 ret = iChunks[count - 1]->Validate(); |
|
1179 } |
|
1180 return ret; |
|
1181 } |
|
1182 |
|
1183 /** |
|
1184 Constructor. |
|
1185 @param aJustInTimeConstruction This flag indicates that the derived class uses |
|
1186 a just-in-time construction technique when constructing iteself from a write |
|
1187 data stream. Typically this is used for types whose final structure is dependant |
|
1188 upon data contained within the data stream itself, e.g. a dataset with an |
|
1189 element whose data type is determined by meta data which precedes the element |
|
1190 in the data stream. |
|
1191 @param aExpectedChunkCount This flag is used by the derived class to indicate |
|
1192 the number of chunks which make up the compound type. A value of |
|
1193 KVariableChunkCount indicates that the type is of variable rather than fixed |
|
1194 length (e.g. a list of elements). If KVariableChunkCount is specified then the |
|
1195 derived class's ValidChunkCount method is invoked when the compound type is |
|
1196 validated (@see ValidateChunkCount). |
|
1197 @see Validate |
|
1198 @see ValidateChunkCount |
|
1199 @see KVariableChunkCount |
|
1200 */ |
|
1201 EXPORT_C CMTPTypeCompoundBase::CMTPTypeCompoundBase(TBool aJustInTimeConstruction, TUint aExpectedChunkCount) : |
|
1202 iExpectedChunkCount(aExpectedChunkCount), |
|
1203 iJustInTimeConstruction(aJustInTimeConstruction) |
|
1204 { |
|
1205 |
|
1206 } |
|
1207 |
|
1208 /** |
|
1209 Appends the specified data chunk to the compound type's sequence of chunks. |
|
1210 @param aChunk The chunk to be appended. |
|
1211 */ |
|
1212 EXPORT_C void CMTPTypeCompoundBase::ChunkAppendL(const MMTPType& aChunk) |
|
1213 { |
|
1214 iChunks.AppendL(&aChunk); |
|
1215 } |
|
1216 |
|
1217 /** |
|
1218 Removes the chunk at the specified position in the chunk sequence. |
|
1219 @param aChunkId The index of the chunk in in the chunk sequence. |
|
1220 */ |
|
1221 EXPORT_C void CMTPTypeCompoundBase::ChunkRemove(TUint aChunkId) |
|
1222 { |
|
1223 iChunks.Remove(aChunkId); |
|
1224 } |
|
1225 |
|
1226 /** |
|
1227 Provides the number of discrete data chunks of which the compound type is |
|
1228 composed. |
|
1229 @return The number of discrete data chunks components which make up the |
|
1230 compound type. |
|
1231 */ |
|
1232 EXPORT_C TUint CMTPTypeCompoundBase::ChunkCount() const |
|
1233 { |
|
1234 return iChunks.Count(); |
|
1235 } |
|
1236 |
|
1237 /** |
|
1238 Resets the compound base, removing all data chunk references. |
|
1239 */ |
|
1240 EXPORT_C void CMTPTypeCompoundBase::Reset() |
|
1241 { |
|
1242 iChunks.Close(); |
|
1243 } |
|
1244 |
|
1245 /** |
|
1246 Sets the expected chunk count. This flag is used by the derived class to |
|
1247 indicate the number of chunks which make up the compound type. A value of |
|
1248 KVariableChunkCount indicates that the type is of variable rather than fixed |
|
1249 length (e.g. a list of elements). If KVariableChunkCount is specified then the |
|
1250 derived class's ValidChunkCount method is invoked when the compound type is |
|
1251 validated (@see ValidateChunkCount). |
|
1252 @param aExpectedChunkCount The new expected chunk count. |
|
1253 */ |
|
1254 EXPORT_C void CMTPTypeCompoundBase::SetExpectedChunkCount(TUint aExpectedChunkCount) |
|
1255 { |
|
1256 iExpectedChunkCount = aExpectedChunkCount; |
|
1257 } |
|
1258 |
|
1259 /** |
|
1260 Indicates if the specified element can be read from. |
|
1261 @param aElementId The identifier of the requested element. |
|
1262 @return ETrue if the element is readable, otherwise EFalse. |
|
1263 */ |
|
1264 EXPORT_C TBool CMTPTypeCompoundBase::ReadableElementL(TInt /*aElementId*/) const |
|
1265 { |
|
1266 return ETrue; |
|
1267 } |
|
1268 |
|
1269 /** |
|
1270 Indicates if the specified element can be written to. |
|
1271 @param aElementId The identifier of the requested element. |
|
1272 @return ETrue if the element is writeable, otherwise EFalse. |
|
1273 */ |
|
1274 EXPORT_C TBool CMTPTypeCompoundBase::WriteableElementL(TInt /*aElementId*/) const |
|
1275 { |
|
1276 return ETrue; |
|
1277 } |
|
1278 |
|
1279 TInt CMTPTypeCompoundBase::UpdateReadState(TInt aErr) const |
|
1280 { |
|
1281 TInt ret(aErr); |
|
1282 |
|
1283 switch (aErr) |
|
1284 { |
|
1285 case KMTPChunkSequenceCompletion: |
|
1286 if (++iReadChunk < iChunks.Count()) |
|
1287 { |
|
1288 iReadSequenceState = EInProgressFirst; |
|
1289 ret = KErrNone; |
|
1290 } |
|
1291 else |
|
1292 { |
|
1293 iReadSequenceState = EIdle; |
|
1294 } |
|
1295 break; |
|
1296 |
|
1297 case KErrNone: |
|
1298 iReadSequenceState = EInProgressNext; |
|
1299 break; |
|
1300 |
|
1301 default: |
|
1302 break; |
|
1303 } |
|
1304 |
|
1305 return ret; |
|
1306 } |
|
1307 |
|
1308 /** |
|
1309 Validates that the number of chunks making up the compound type is valid. This |
|
1310 method is invoked on variable length compound types by the default @see Valid |
|
1311 implementation. |
|
1312 @see Valid |
|
1313 @see KVariableChunkCount |
|
1314 */ |
|
1315 EXPORT_C TInt CMTPTypeCompoundBase::ValidateChunkCount() const |
|
1316 { |
|
1317 return KMTPDataTypeInvalid; |
|
1318 } |
|
1319 |
|
1320 TInt CMTPTypeCompoundBase::UpdateWriteState(TInt aErr) |
|
1321 { |
|
1322 TInt ret(aErr); |
|
1323 |
|
1324 iWriteErr = aErr; |
|
1325 switch (iWriteErr) |
|
1326 { |
|
1327 case KMTPChunkSequenceCompletion: |
|
1328 if ((iWriteChunk + 1) < iChunks.Count()) |
|
1329 { |
|
1330 iWriteSequenceState = EInProgressFirst; |
|
1331 ret = KErrNone; |
|
1332 } |
|
1333 else |
|
1334 { |
|
1335 iWriteSequenceState = EIdle; |
|
1336 } |
|
1337 break; |
|
1338 |
|
1339 case KErrNone: |
|
1340 iWriteSequenceState = EInProgressNext; |
|
1341 break; |
|
1342 |
|
1343 default: |
|
1344 break; |
|
1345 } |
|
1346 |
|
1347 return ret; |
|
1348 } |
|
1349 |
|
1350 /** |
|
1351 Constructor. |
|
1352 @param aSize The size (in bytes) of the flat data chunk. |
|
1353 @param aParent The compound data type of which the flat data chunk is a component. |
|
1354 */ |
|
1355 EXPORT_C CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::RMTPTypeCompoundFlatChunk(TUint aSize, CMTPTypeCompoundBase& aParent) : |
|
1356 iSize(aSize), |
|
1357 iParent(&aParent) |
|
1358 { |
|
1359 |
|
1360 } |
|
1361 |
|
1362 /** |
|
1363 Releases the storage assigned to the flat data chunk. |
|
1364 */ |
|
1365 EXPORT_C void CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::Close() |
|
1366 { |
|
1367 iBuffer.Close(); |
|
1368 } |
|
1369 |
|
1370 /** |
|
1371 Allocates storage for the flat data chunk. |
|
1372 @leave One of the system wide error codes, if a processing failure occurs. |
|
1373 */ |
|
1374 EXPORT_C void CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::OpenL() |
|
1375 { |
|
1376 iBuffer.CreateMaxL(iSize); |
|
1377 iBuffer.FillZ(); |
|
1378 SetBuffer(iBuffer); |
|
1379 } |
|
1380 |
|
1381 EXPORT_C TUint CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::Type() const |
|
1382 { |
|
1383 return EMTPTypeFlat; |
|
1384 } |
|
1385 |
|
1386 const TMTPTypeFlatBase::TElementInfo& CMTPTypeCompoundBase::RMTPTypeCompoundFlatChunk::ElementInfo(TInt aElementId) const |
|
1387 { |
|
1388 return iParent->ElementInfo(aElementId).iFlatChunkInfo; |
|
1389 } |