|
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 |
|
18 /** |
|
19 @file |
|
20 @publishedPartner |
|
21 @released |
|
22 */ |
|
23 |
|
24 #ifndef CMTPTYPEOBJECTPROPLIST_H |
|
25 #define CMTPTYPEOBJECTPROPLIST_H |
|
26 |
|
27 #include <e32std.h> |
|
28 #include <e32base.h> |
|
29 #include <mtp/rmtptype.h> |
|
30 //#include <mtp/cmtptypecompoundbase.h> |
|
31 |
|
32 class CMTPTypeObjectPropListElement; |
|
33 class CMTPTypeArray; |
|
34 /** |
|
35 Defines the MTP ObjectPropList dataset. The ObjectPropList dataset provides |
|
36 optimised access to object properties without needing to individually query |
|
37 each object/property pair. It also provides a more flexible querying mechanism |
|
38 for object properties in general. This dataset is used in the |
|
39 GetObjectPropList, SetObjectPropList, and SendObjectPropList requests. |
|
40 @publishedPartner |
|
41 @released |
|
42 */ |
|
43 |
|
44 class CMTPTypeObjectPropList : public CBase, public MMTPType |
|
45 { |
|
46 public: |
|
47 IMPORT_C static CMTPTypeObjectPropList* NewL(); |
|
48 IMPORT_C static CMTPTypeObjectPropList* NewLC(); |
|
49 IMPORT_C virtual ~CMTPTypeObjectPropList(); |
|
50 |
|
51 /** |
|
52 Reserve an object property element in buffer page. After setting the element's values, the element should |
|
53 be committed, otherwise the new element will be discarded without commitment. |
|
54 @param aHandle The object handle of the object property element. |
|
55 @param aPropCode The property code of the object property element. |
|
56 */ |
|
57 IMPORT_C CMTPTypeObjectPropListElement& ReservePropElemL(TUint32 aHandle, TUint16 aPropCode); |
|
58 |
|
59 /** |
|
60 Commit the reverved object property element in buffer page. |
|
61 @param aElem The object property element to be committed. |
|
62 */ |
|
63 IMPORT_C void CommitPropElemL(CMTPTypeObjectPropListElement& aElem); |
|
64 |
|
65 /** |
|
66 Reset the element cursor, so GetNextElementL() will return the first object property element |
|
67 in the object property list. |
|
68 */ |
|
69 IMPORT_C void ResetCursor() const; |
|
70 |
|
71 /** |
|
72 Get the next object property element in the object property list. |
|
73 */ |
|
74 IMPORT_C CMTPTypeObjectPropListElement& GetNextElementL() const; |
|
75 |
|
76 /** |
|
77 Get the size of the object property list. |
|
78 */ |
|
79 IMPORT_C TUint64 Size() const; |
|
80 |
|
81 /** |
|
82 Get the number of element in the object property list. |
|
83 */ |
|
84 IMPORT_C TUint32 NumberOfElements() const; |
|
85 |
|
86 /** |
|
87 Append all object property elements from another object property list. |
|
88 */ |
|
89 IMPORT_C void AppendObjectPropListL(const CMTPTypeObjectPropList& aSource); |
|
90 |
|
91 public: // From MMTPType |
|
92 IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const; |
|
93 IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const; |
|
94 IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk); |
|
95 IMPORT_C TInt NextWriteChunk(TPtr8& aChunk); |
|
96 IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk, TUint aDataLength); |
|
97 IMPORT_C TInt NextWriteChunk(TPtr8& aChunk, TUint aDataLength); |
|
98 |
|
99 IMPORT_C TUint Type() const; |
|
100 IMPORT_C TBool CommitRequired() const; |
|
101 IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); |
|
102 IMPORT_C TBool ReserveTransportHeader(TUint aHeaderLength, TPtr8& aHeader); |
|
103 IMPORT_C TInt Validate() const; |
|
104 |
|
105 private: |
|
106 friend class CMTPTypeObjectPropListElement; |
|
107 CMTPTypeObjectPropList(); |
|
108 void ConstructL(); |
|
109 TUint ArrayElemWidth(TUint16& aDataType) const; |
|
110 |
|
111 TBool ValueBufferConsistent(TUint aPageIdx, TUint aBufferIdx, TUint aValueSize) const; |
|
112 TBool ValueAddressAligned(TUint aPageIdx, TUint aBufferIdx) const; |
|
113 |
|
114 void ReserveNewPage(); |
|
115 |
|
116 void IncreaseIndexL(TUint& aPageIndex, TUint& aBufIndex, TUint aLength, TBool aReserveNewPage) const; |
|
117 |
|
118 /** |
|
119 Copy data from Element to buffer page. |
|
120 */ |
|
121 void MemoryCopyL(TAny* aTrg, TUint aSrcPageIndex, TUint aSrcBufIndex, TUint aLength) const; |
|
122 |
|
123 /** |
|
124 Copy data from buffer page to Element. |
|
125 */ |
|
126 void MemoryCopyL(TUint aTrgPageIndex, TUint aTrgBufIndex, const TAny* aSrc, TUint aLength); |
|
127 |
|
128 |
|
129 |
|
130 private: |
|
131 /* |
|
132 The objectproplist buffer pages, each page is 64k bytes. It will only allocate one page in ContructL |
|
133 */ |
|
134 RArray<RBuf8> iIOPages; |
|
135 |
|
136 /* |
|
137 The last page number of valid elements |
|
138 */ |
|
139 TUint iRevPageEnd; |
|
140 |
|
141 /* |
|
142 The Reserved data length for recieve |
|
143 */ |
|
144 TUint iRevDataEnd; |
|
145 |
|
146 /* |
|
147 The chunk index used by NextReadChunk |
|
148 */ |
|
149 mutable TUint iChunkIndex; |
|
150 /* |
|
151 The index of transport buffer header |
|
152 */ |
|
153 TUint iTransportHeaderIndex; |
|
154 /* |
|
155 If reserved a element but not committed, iPropElemCommitted will be set to ETrue, otherwise Efalse |
|
156 */ |
|
157 TBool iReservedElemCommitted; |
|
158 /* |
|
159 Pointed to the NumberOfelements field of ObjectPropList |
|
160 */ |
|
161 TUint32 iNumberOfElements; |
|
162 |
|
163 /* |
|
164 Current element to be read |
|
165 */ |
|
166 mutable CMTPTypeObjectPropListElement* iCurrentElement; |
|
167 |
|
168 /* |
|
169 The reverved element |
|
170 */ |
|
171 CMTPTypeObjectPropListElement* iReservedElement; |
|
172 |
|
173 mutable TBool iResetCursor; |
|
174 |
|
175 }; |
|
176 /** |
|
177 Defines the MTP ObjectPropList element dataset. The ObjectPropList element |
|
178 dataset describes an object property with a meta data triplet and a value. It |
|
179 is a component element of the ObjectPropList dataset. |
|
180 */ |
|
181 class CMTPTypeObjectPropListElement : public CBase |
|
182 { |
|
183 |
|
184 public: |
|
185 |
|
186 /** |
|
187 MTP ObjectPropList property quadruple dataset element identifiers. |
|
188 */ |
|
189 enum TMTPObjectPropListElement |
|
190 { |
|
191 /** |
|
192 The ObjectHandle of the object to which the property applies. |
|
193 */ |
|
194 EObjectHandle, |
|
195 |
|
196 /** |
|
197 The ObjectPropDesc property identifier datacode (read-only). |
|
198 */ |
|
199 EPropertyCode, |
|
200 |
|
201 /** |
|
202 The datatype code of the property (read-only). |
|
203 */ |
|
204 EDatatype, |
|
205 |
|
206 /** |
|
207 The value of the property. |
|
208 */ |
|
209 EValue, |
|
210 |
|
211 /** |
|
212 The number of dataset elements. |
|
213 */ |
|
214 ENumElements, |
|
215 }; |
|
216 |
|
217 public: |
|
218 IMPORT_C virtual ~CMTPTypeObjectPropListElement(); |
|
219 IMPORT_C TUint32 Size() const; |
|
220 |
|
221 IMPORT_C TUint8 Uint8L(TInt aElementId) const; |
|
222 IMPORT_C TUint16 Uint16L(TInt aElementId) const; |
|
223 IMPORT_C TUint32 Uint32L(TInt aElementId) const; |
|
224 IMPORT_C TUint64 Uint64L(TInt aElementId) const; |
|
225 IMPORT_C void Uint128L(TInt aElementId,TUint64& high, TUint64& low) const; |
|
226 IMPORT_C const TDesC& StringL(TInt aElementId) const; |
|
227 IMPORT_C const TDesC8& ArrayL(TInt aElementId) const; |
|
228 |
|
229 IMPORT_C void SetUint8L(TInt aElementId, TUint8 aData); |
|
230 IMPORT_C void SetUint16L(TInt aElementId, TUint16 aData); |
|
231 IMPORT_C void SetUint32L(TInt aElementId, TUint32 aData); |
|
232 IMPORT_C void SetUint64L(TInt aElementId, TUint64 aData); |
|
233 IMPORT_C void SetUint128L(TInt aElementId, TUint64 high, TUint64 low); |
|
234 IMPORT_C void SetStringL(TInt aElementId, const TDesC& aString); |
|
235 IMPORT_C void SetArrayL(TInt aElementId, const CMTPTypeArray& aArray); |
|
236 IMPORT_C void SetArrayL(TInt aElementId, const TDesC& aString); |
|
237 |
|
238 |
|
239 private: |
|
240 friend class CMTPTypeObjectPropList; |
|
241 static CMTPTypeObjectPropListElement* NewL(CMTPTypeObjectPropList* propList); |
|
242 static CMTPTypeObjectPropListElement* NewLC(CMTPTypeObjectPropList* propList); |
|
243 CMTPTypeObjectPropListElement(); |
|
244 void ConstructL(CMTPTypeObjectPropList* propList); |
|
245 void SetDataType(TUint16 aDataType); |
|
246 void GetValueL(TAny* aTrg, TUint aLength) const; |
|
247 void SetValueL(const TAny* aTrg, TUint aLength); |
|
248 |
|
249 private: |
|
250 mutable CMTPTypeObjectPropList* iPropList; |
|
251 TUint iPageIndex; |
|
252 TUint iBufIndex; |
|
253 |
|
254 mutable TUint32 iObjectHandle; |
|
255 mutable TUint16 iPropertyCode; |
|
256 mutable TUint16 iDataType; |
|
257 TUint32 iValueSize; |
|
258 // Pointed to string value |
|
259 mutable TPtrC iStringValue; |
|
260 // Pointed to array value |
|
261 mutable TPtrC8 iArrayValue; |
|
262 // If the buffer address of string data is not aligned, the data will be copied to iStringHolder |
|
263 mutable RBuf16 iStringHolder; |
|
264 // If the buffer address of string data is not aligned, the data will be copied to iStringHolder |
|
265 mutable TBool iArrayBuffered; |
|
266 |
|
267 }; |
|
268 |
|
269 #endif // CMTPTYPEOBJECTPROPLIST_H |