|
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 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef CMTPTYPEDEVICEPROPDESC_H |
|
22 #define CMTPTYPEDEVICEPROPDESC_H |
|
23 |
|
24 #include <e32std.h> |
|
25 #include <mtp/rmtptype.h> |
|
26 #include <mtp/cmtptypecompoundbase.h> |
|
27 |
|
28 /** |
|
29 Defines the MTP DevicePropDesc dataset. The DevicePropDesc dataset describes |
|
30 an MTP device property, and is generated in response to a GetDevicePropDesc |
|
31 operation request. |
|
32 @internalComponent |
|
33 */ |
|
34 class CMTPTypeDevicePropDesc : public CMTPTypeCompoundBase |
|
35 { |
|
36 public: |
|
37 |
|
38 /** |
|
39 MTP DevicePropDesc dataset element identifiers. |
|
40 */ |
|
41 enum TMTPDevicePropDescElement |
|
42 { |
|
43 /** |
|
44 Property Code (read-only). |
|
45 */ |
|
46 EDevicePropertyCode, |
|
47 |
|
48 /** |
|
49 Datatype (read-only). |
|
50 */ |
|
51 EDatatype, |
|
52 |
|
53 /** |
|
54 Get/Set. |
|
55 */ |
|
56 EGetSet, |
|
57 |
|
58 /** |
|
59 Factory Default Value. |
|
60 */ |
|
61 EFactoryDefaultValue, |
|
62 |
|
63 /** |
|
64 Factory Default Value. |
|
65 */ |
|
66 ECurrentValue, |
|
67 |
|
68 /** |
|
69 Form Flag (read-only). |
|
70 */ |
|
71 EFormFlag, |
|
72 |
|
73 /** |
|
74 FORM element. This element depends EFormFlag and is absent if EFormFlag |
|
75 is ENone. |
|
76 */ |
|
77 EForm, |
|
78 |
|
79 /** |
|
80 The number of dataset elements. |
|
81 */ |
|
82 ENumElements, |
|
83 }; |
|
84 |
|
85 /** |
|
86 MTP DevicePropDesc dataset Get/Set element values. |
|
87 */ |
|
88 enum TMTPDevicePropDescGetSet |
|
89 { |
|
90 /** |
|
91 Get. |
|
92 */ |
|
93 EReadOnly = 0x00, |
|
94 |
|
95 /** |
|
96 Get/Set. |
|
97 */ |
|
98 EReadWrite = 0x01, |
|
99 }; |
|
100 |
|
101 /** |
|
102 MTP DevicePropDesc dataset FormFlag element values. |
|
103 */ |
|
104 enum TMTPDevicePropDescFormFlag |
|
105 { |
|
106 /** |
|
107 None. |
|
108 */ |
|
109 ENone = 0x00, |
|
110 |
|
111 /** |
|
112 Range form. |
|
113 */ |
|
114 ERangeForm = 0x01, |
|
115 |
|
116 /** |
|
117 Enumeration form. |
|
118 */ |
|
119 EEnumerationForm = 0x02, |
|
120 }; |
|
121 |
|
122 /** |
|
123 Defines the MTP DevicePropDesc dataset meta data. |
|
124 */ |
|
125 struct TPropertyInfo |
|
126 { |
|
127 /** |
|
128 The property's MTP data type identifier datacode. |
|
129 */ |
|
130 TUint iDataType; |
|
131 |
|
132 /** |
|
133 The FormFlag identifier. |
|
134 */ |
|
135 TUint8 iFormFlag; |
|
136 |
|
137 /** |
|
138 The property's Get/Set flag. |
|
139 */ |
|
140 TUint8 iGetSet; |
|
141 }; |
|
142 |
|
143 public: |
|
144 |
|
145 IMPORT_C static CMTPTypeDevicePropDesc* NewL(TUint16 aPropertyCode); |
|
146 IMPORT_C static CMTPTypeDevicePropDesc* NewLC(TUint16 aPropertyCode); |
|
147 |
|
148 IMPORT_C static CMTPTypeDevicePropDesc* NewL(TUint16 aPropertyCode, const MMTPType& aForm); |
|
149 IMPORT_C static CMTPTypeDevicePropDesc* NewLC(TUint16 aPropertyCode, const MMTPType& aForm); |
|
150 |
|
151 IMPORT_C static CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewL(TUint16 aPropertyCode, TUint8 aGetSet, TUint8 aFormFlag, const MMTPType* aForm); |
|
152 IMPORT_C static CMTPTypeDevicePropDesc* CMTPTypeDevicePropDesc::NewLC(TUint16 aPropertyCode, TUint8 aGetSet, TUint8 aFormFlag, const MMTPType* aForm); |
|
153 |
|
154 IMPORT_C static CMTPTypeDevicePropDesc* NewL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm); |
|
155 IMPORT_C static CMTPTypeDevicePropDesc* NewLC(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm); |
|
156 |
|
157 IMPORT_C virtual ~CMTPTypeDevicePropDesc(); |
|
158 |
|
159 public: // From CMTPTypeCompoundBase |
|
160 |
|
161 IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk); |
|
162 IMPORT_C TInt NextWriteChunk(TPtr8& aChunk); |
|
163 IMPORT_C TUint Type() const; |
|
164 IMPORT_C TBool CommitRequired() const; |
|
165 IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); |
|
166 |
|
167 public: |
|
168 |
|
169 static void PropertyInfoL(TUint16 aPropertyCode, TPropertyInfo& aInfo); |
|
170 |
|
171 private: // From CMTPTypeCompoundBase |
|
172 |
|
173 const TElementInfo& ElementInfo(TInt aElementId) const; |
|
174 TBool ReadableElementL(TInt aElementId) const; |
|
175 TBool WriteableElementL(TInt aElementId) const; |
|
176 |
|
177 private: |
|
178 |
|
179 /* |
|
180 Defines the MTP DevicePropDesc FORM dataset. The FORM dataset is a |
|
181 component element of the DevicePropDesc dataset. |
|
182 @internalComponent |
|
183 */ |
|
184 class RMTPTypeDevicePropDescForm : public RMTPType |
|
185 { |
|
186 public: |
|
187 |
|
188 RMTPTypeDevicePropDescForm(); |
|
189 |
|
190 void SetMeta(TUint8 aFormFlag, TUint aDataType); |
|
191 |
|
192 private: |
|
193 |
|
194 MMTPType* CreateL(TUint aDataType); |
|
195 void Destroy(MMTPType* aType); |
|
196 |
|
197 private: |
|
198 |
|
199 /** |
|
200 The FORM dataset's MTP datatype code. |
|
201 */ |
|
202 TUint iDataType; |
|
203 |
|
204 /** |
|
205 The FORM dataset's FormFlag code. |
|
206 */ |
|
207 TUint8 iFormFlag; |
|
208 }; |
|
209 |
|
210 private: |
|
211 |
|
212 static CMTPTypeDevicePropDesc* NewLC(); |
|
213 |
|
214 CMTPTypeDevicePropDesc(); |
|
215 void ConstructL(TUint16 aPropertyCode, const MMTPType* aForm); |
|
216 void ConstructL(TUint16 aPropertyCode, const TPropertyInfo& aInfo, const MMTPType* aForm); |
|
217 |
|
218 TBool HasFormField(TUint8 aFormFlag) const; |
|
219 TInt UpdateWriteSequenceErr(TInt aErr); |
|
220 |
|
221 private: // Owned |
|
222 |
|
223 /** |
|
224 The write data stream states. |
|
225 */ |
|
226 enum TWriteSequenceState |
|
227 { |
|
228 /** |
|
229 Data stream is inactive. |
|
230 */ |
|
231 EWriteIdle, |
|
232 |
|
233 /** |
|
234 Streaming the first flat data chunk. |
|
235 */ |
|
236 EWriteFlat1Chunk, |
|
237 |
|
238 /** |
|
239 Streaming the EFactoryDefaultValue data chunk.. |
|
240 */ |
|
241 EWriteDefaultValueChunk, |
|
242 |
|
243 /** |
|
244 Streaming the ECurrentValue data chunk.. |
|
245 */ |
|
246 EWriteCurrentValueChunk, |
|
247 |
|
248 /** |
|
249 Streaming the second flat data chunk. |
|
250 */ |
|
251 EWriteFormFlagChunk, |
|
252 |
|
253 /** |
|
254 Streaming the EForm data chunk. |
|
255 */ |
|
256 EWriteFormChunk |
|
257 }; |
|
258 |
|
259 /** |
|
260 Data chunk identifiers. |
|
261 */ |
|
262 enum TChunkIds |
|
263 { |
|
264 /** |
|
265 The first flat data chunk ID. |
|
266 */ |
|
267 EIdFlat1Chunk, |
|
268 |
|
269 /** |
|
270 The EFactoryDefaultValue element data chunk ID. |
|
271 */ |
|
272 EIdDefaultValueChunk, |
|
273 |
|
274 /** |
|
275 The ECurrentValue element data chunk ID. |
|
276 */ |
|
277 EIdCurrentValueChunk, |
|
278 |
|
279 /** |
|
280 The second flat data chunk ID. |
|
281 */ |
|
282 EIdFormFlagChunk, |
|
283 |
|
284 /** |
|
285 The EForm element data chunk ID. |
|
286 */ |
|
287 EIdFormChunk, |
|
288 |
|
289 /** |
|
290 The number of data chunks. |
|
291 */ |
|
292 EIdNumChunks |
|
293 }; |
|
294 |
|
295 /** |
|
296 The write data stream error state. |
|
297 */ |
|
298 TUint iWriteSequenceErr; |
|
299 |
|
300 /** |
|
301 The write data stream state variable. |
|
302 */ |
|
303 TUint iWriteSequenceState; |
|
304 |
|
305 /** |
|
306 The write data stream completion state. This will be set to EFlat2Chunk for |
|
307 DevicePropDesc datasets with an EForm of ENone, otherwise this will be |
|
308 EFormChunk. |
|
309 */ |
|
310 TUint iWriteSequenceCompletionState; |
|
311 |
|
312 /** |
|
313 The dataset element metadata table content. |
|
314 */ |
|
315 static const CMTPTypeCompoundBase::TElementInfo iElementMetaData[]; |
|
316 |
|
317 /** |
|
318 The dataset element metadata table. |
|
319 */ |
|
320 const TFixedArray<TElementInfo, ENumElements> iElementInfo; |
|
321 |
|
322 /** |
|
323 The initialised flag indicating if construction is completeand that |
|
324 read-only elements can no longer be modified. |
|
325 */ |
|
326 TBool iInitialised; |
|
327 |
|
328 /** |
|
329 The size in bytes of the first flat data chunk. |
|
330 */ |
|
331 static const TUint KFlat1ChunkSize; |
|
332 |
|
333 /** |
|
334 The data chunk count of DevicePropDesc datasets with an EForm of other than |
|
335 ENone. |
|
336 */ |
|
337 static const TUint KNumChunksWithForm; |
|
338 |
|
339 /** |
|
340 The data chunk count of DevicePropDesc datasets with an EForm of ENone. |
|
341 */ |
|
342 static const TUint KNumChunksWithoutForm; |
|
343 |
|
344 /** |
|
345 The flat data chunk comprising elements EPropertyCode to EGetSet. |
|
346 */ |
|
347 RMTPTypeCompoundFlatChunk iChunkFlat1; |
|
348 |
|
349 /** |
|
350 The EFactoryDefaultValue element data chunk. |
|
351 */ |
|
352 RMTPType iChunkDefaultValue; |
|
353 |
|
354 /** |
|
355 The ECurrentValue element data chunk. |
|
356 */ |
|
357 RMTPType iChunkCurrentValue; |
|
358 |
|
359 /** |
|
360 The EFormFlag data chunk. |
|
361 */ |
|
362 TMTPTypeUint8 iChunkFormFlag; |
|
363 |
|
364 /** |
|
365 The EForm element data chunk. |
|
366 */ |
|
367 RMTPTypeDevicePropDescForm iChunkForm; |
|
368 }; |
|
369 |
|
370 /** |
|
371 Defines the MTP DevicePropDesc Enumeration FORM dataset. The Enumeration FORM |
|
372 dataset is a component element of the DevicePropDesc dataset. |
|
373 @see CMTPTypeDevicePropDesc |
|
374 @internalComponent |
|
375 */ |
|
376 class CMTPTypeDevicePropDescEnumerationForm : public CMTPTypeCompoundBase |
|
377 { |
|
378 |
|
379 public: |
|
380 |
|
381 IMPORT_C static CMTPTypeDevicePropDescEnumerationForm* NewL(TUint aDataType); |
|
382 IMPORT_C static CMTPTypeDevicePropDescEnumerationForm* NewLC(TUint aDataType); |
|
383 |
|
384 IMPORT_C virtual ~CMTPTypeDevicePropDescEnumerationForm(); |
|
385 |
|
386 IMPORT_C void AppendSupportedValueL(const MMTPType& aValue); |
|
387 |
|
388 IMPORT_C TUint16 NumberOfValues() const; |
|
389 IMPORT_C void SupportedValueL(TUint aIndex, MMTPType& aValue) const; |
|
390 |
|
391 public: // From CMTPTypeCompoundBase |
|
392 |
|
393 IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk); |
|
394 IMPORT_C TInt NextWriteChunk(TPtr8& aChunk); |
|
395 IMPORT_C TUint Type() const; |
|
396 IMPORT_C TBool CommitRequired() const; |
|
397 IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); |
|
398 |
|
399 private: // From CMTPTypeCompoundBase |
|
400 |
|
401 const TElementInfo& ElementInfo(TInt aElementId) const; |
|
402 TInt ValidateChunkCount() const; |
|
403 |
|
404 private: |
|
405 |
|
406 CMTPTypeDevicePropDescEnumerationForm(TUint aDataType); |
|
407 void ConstructL(); |
|
408 |
|
409 void AppendValueChunkL(); |
|
410 |
|
411 private: |
|
412 |
|
413 /** |
|
414 The write data stream states. |
|
415 */ |
|
416 enum TReadWriteSequenceState |
|
417 { |
|
418 /** |
|
419 Data stream is inactive. |
|
420 */ |
|
421 EIdle, |
|
422 |
|
423 /** |
|
424 Data stream is in progress. |
|
425 */ |
|
426 EInProgress |
|
427 }; |
|
428 |
|
429 /** |
|
430 The write data stream state variable. |
|
431 */ |
|
432 TUint iWriteSequenceState; |
|
433 |
|
434 /** |
|
435 The NumberOfValues element metadata content. |
|
436 */ |
|
437 CMTPTypeCompoundBase::TElementInfo iInfoNumberOfValues; |
|
438 |
|
439 /** |
|
440 The SupportedValue array elements metadata content. Note that this is |
|
441 declared mutable to allow state updates while processing a read data stream. |
|
442 */ |
|
443 mutable CMTPTypeCompoundBase::TElementInfo iInfoValue; |
|
444 |
|
445 /** |
|
446 The NumberOfValues element data chunk ID. |
|
447 */ |
|
448 static const TUint KNumberOfValuesChunk; |
|
449 |
|
450 /** |
|
451 The SupportedValue array elements metadata content. Note that this is |
|
452 declared mutable to allow state updates while processing a read data stream. |
|
453 */ |
|
454 static const TUint KValueChunks; |
|
455 |
|
456 /** |
|
457 The NumberOfPropDescs element data chunk. |
|
458 */ |
|
459 TMTPTypeUint16 iChunkNumberOfValues; |
|
460 |
|
461 /** |
|
462 The SupportedValue elements array data chunks. |
|
463 */ |
|
464 RArray<RMTPType> iChunksValue; |
|
465 }; |
|
466 |
|
467 /** |
|
468 Defines the MTP DevicePropDesc Range FORM dataset. The Range FORM dataset is a |
|
469 component element of the DevicePropDesc dataset. |
|
470 @see CMTPTypeDevicePropDesc |
|
471 @internalComponent |
|
472 */ |
|
473 class CMTPTypeDevicePropDescRangeForm : public CMTPTypeCompoundBase |
|
474 { |
|
475 public: |
|
476 |
|
477 /** |
|
478 MTP DevicePropDesc Range FORM element dataset identifiers. |
|
479 */ |
|
480 enum TMTPDevicePropDescElement |
|
481 { |
|
482 /** |
|
483 Minimum Value. |
|
484 */ |
|
485 EMinimumValue, |
|
486 |
|
487 /** |
|
488 Maximum Value. |
|
489 */ |
|
490 EMaximumValue, |
|
491 |
|
492 /** |
|
493 Step Size. |
|
494 */ |
|
495 EStepSize, |
|
496 |
|
497 /** |
|
498 The number of dataset elements. |
|
499 */ |
|
500 ENumElements, |
|
501 }; |
|
502 |
|
503 public: |
|
504 |
|
505 IMPORT_C static CMTPTypeDevicePropDescRangeForm* NewL(TUint aDataType); |
|
506 IMPORT_C static CMTPTypeDevicePropDescRangeForm* NewLC(TUint aDataType); |
|
507 |
|
508 IMPORT_C virtual ~CMTPTypeDevicePropDescRangeForm(); |
|
509 |
|
510 public: // From CMTPTypeCompoundBase |
|
511 |
|
512 IMPORT_C TUint Type() const; |
|
513 |
|
514 private: // From CMTPTypeCompoundBase |
|
515 |
|
516 const TElementInfo& ElementInfo(TInt aElementId) const; |
|
517 |
|
518 private: |
|
519 |
|
520 CMTPTypeDevicePropDescRangeForm(TUint aDataType); |
|
521 void ConstructL(); |
|
522 |
|
523 private: |
|
524 |
|
525 /** |
|
526 The element metadata content. |
|
527 */ |
|
528 mutable CMTPTypeCompoundBase::TElementInfo iInfoBuf; |
|
529 |
|
530 /** |
|
531 The property's MTP data type identifier datacode. |
|
532 */ |
|
533 TUint iDataType; |
|
534 |
|
535 /** |
|
536 The element data chunks. |
|
537 */ |
|
538 RArray<RMTPType> iChunks; |
|
539 }; |
|
540 |
|
541 #endif // CMTPTYPEDEVICEPROPDESC_H |