|
1 /* |
|
2 * Copyright (c) 2005 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 "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: Property manager and value container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CPENGCONTACTLISTPROPERTY_H__ |
|
20 #define __CPENGCONTACTLISTPROPERTY_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 // FORWARD DECLARATION |
|
26 class CPEngContactListProperty; |
|
27 class RWriteStream; |
|
28 class RReadStream; |
|
29 |
|
30 // ENUMERATIONS |
|
31 |
|
32 /** |
|
33 * The property types. |
|
34 */ |
|
35 enum TPEngPropertyType |
|
36 { |
|
37 ETInt = 0, |
|
38 EDes8 = 1, |
|
39 EDes16 = 2 |
|
40 }; |
|
41 |
|
42 |
|
43 |
|
44 // CLASS DEFINITION |
|
45 /** |
|
46 * Property manager. |
|
47 * |
|
48 * @lib PEngListLib2 |
|
49 * @since 3.0 |
|
50 */ |
|
51 NONSHARABLE_CLASS( PEngPropertyManager ) |
|
52 { |
|
53 public: //New functions. |
|
54 |
|
55 /** |
|
56 * Gets a property value. |
|
57 * |
|
58 * @since 3.0 |
|
59 * @param aName Name of the property. |
|
60 * @param aLevel Level of the property to look for. |
|
61 * @param aValue Where value is be stored. |
|
62 * @return KErrNone if property was found. Else KErrNotFound. |
|
63 */ |
|
64 static TInt GetProperty( |
|
65 const RPointerArray<CPEngContactListProperty>& aProperties, |
|
66 TUint aName, |
|
67 TUint aLevel, |
|
68 TInt& aValue ); |
|
69 |
|
70 static TInt GetProperty( |
|
71 const RPointerArray<CPEngContactListProperty>& aProperties, |
|
72 TUint aName, |
|
73 TUint aLevel, |
|
74 TPtrC8& aValue ); |
|
75 |
|
76 static TInt GetProperty( |
|
77 const RPointerArray<CPEngContactListProperty>& aProperties, |
|
78 TUint aName, |
|
79 TUint aLevel, |
|
80 TPtrC16& aValue ); |
|
81 |
|
82 |
|
83 /** |
|
84 * Shortcut for getting integer type properties. |
|
85 * |
|
86 * @since 3.0 |
|
87 * @param aName Name of the property. |
|
88 * @param aLevel Level of the property to look for. |
|
89 * @return if property is found, its value, if not found |
|
90 * zero is returned as default value |
|
91 */ |
|
92 static TInt PropertyOrZero( |
|
93 const RPointerArray<CPEngContactListProperty>& aProperties, |
|
94 TUint aName, |
|
95 TUint aLevel ); |
|
96 |
|
97 /** |
|
98 * Sets a property. |
|
99 * |
|
100 * @since 3.0 |
|
101 * @param aName Name of the property. |
|
102 * @param aLevel Level of the property to set. |
|
103 * @param aValue Value to be set. |
|
104 * @return KErrNone if property was set successfully. |
|
105 * System wide error case if something failed. |
|
106 */ |
|
107 static void SetPropertyL( |
|
108 RPointerArray<CPEngContactListProperty>& aProperties, |
|
109 TUint aName, |
|
110 TUint aLevel, |
|
111 TInt aValue, |
|
112 TInt& aSize ); |
|
113 |
|
114 static void SetPropertyL( |
|
115 RPointerArray<CPEngContactListProperty>& aProperties, |
|
116 TUint aName, |
|
117 TUint aLevel, |
|
118 const TDesC8& aValue, |
|
119 TInt& aSize ); |
|
120 |
|
121 static void SetPropertyL( |
|
122 RPointerArray<CPEngContactListProperty>& aProperties, |
|
123 TUint aName, |
|
124 TUint aLevel, |
|
125 const TDesC16& aValue, |
|
126 TInt& aSize ); |
|
127 |
|
128 |
|
129 /** |
|
130 * Delete a property |
|
131 * |
|
132 * @since 3.0 |
|
133 * @param aName name of the property to delete |
|
134 * @param aLevel level of the property to delete |
|
135 * @return ETrue if property was found and deleted. Else EFalse. |
|
136 */ |
|
137 static TBool DeletePropertyL( |
|
138 RPointerArray<CPEngContactListProperty>& aProperties, |
|
139 TUint aName, |
|
140 TUint aLevel, |
|
141 TInt& aSize ); |
|
142 |
|
143 |
|
144 /** |
|
145 * Finds property in the array of the properties |
|
146 * |
|
147 * @since 3.0 |
|
148 * @param aName name of the property |
|
149 * @param aLevel level of the property |
|
150 * @param aType type of the property if it should be validated |
|
151 * @return property index |
|
152 */ |
|
153 static TInt FindProperty( |
|
154 const RPointerArray<CPEngContactListProperty>& aProperties, |
|
155 TUint aName, |
|
156 TUint aLevel ); |
|
157 |
|
158 static TInt FindProperty( |
|
159 const RPointerArray<CPEngContactListProperty>& aProperties, |
|
160 TUint aName, |
|
161 TUint aLevel, |
|
162 TPEngPropertyType aType ); |
|
163 |
|
164 |
|
165 /** |
|
166 * Externalize properties |
|
167 * |
|
168 * @since 3.0 |
|
169 * @param aProperties array of properties |
|
170 * @param aStream Write stream |
|
171 * @prama aStoreType storage type |
|
172 */ |
|
173 static void ExternalizePropertiesL( |
|
174 const RPointerArray<CPEngContactListProperty>& aProperties, |
|
175 RWriteStream& aStream, |
|
176 TInt aStoreType ); |
|
177 |
|
178 /** |
|
179 * Internalize properties |
|
180 * |
|
181 * @since 3.0 |
|
182 * @param aProperties array to store properties |
|
183 * @param aStream read stream to read properties from |
|
184 * @param aStoreType storage type |
|
185 * @prama aSize couter to update size |
|
186 */ |
|
187 static void InternalizePropertiesL( |
|
188 RPointerArray<CPEngContactListProperty>& aProperties, |
|
189 RReadStream& aStream, |
|
190 TInt& aSize ); |
|
191 }; |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 // CLASS DEFINITION |
|
197 /** |
|
198 * Property value container. |
|
199 * |
|
200 * @lib PEngListLib2 |
|
201 * @since 3.0 |
|
202 */ |
|
203 NONSHARABLE_CLASS( CPEngContactListProperty ): public CBase |
|
204 { |
|
205 public: // Constructors and destructor |
|
206 /** |
|
207 * Two-phased constructor. |
|
208 */ |
|
209 static CPEngContactListProperty* NewLC( TUint aName, |
|
210 TUint aLevel ); |
|
211 |
|
212 /** |
|
213 * Two-phased constructor. |
|
214 */ |
|
215 static CPEngContactListProperty* NewLC( RReadStream& aStream ); |
|
216 |
|
217 /** |
|
218 * Destructor. |
|
219 */ |
|
220 virtual ~CPEngContactListProperty(); |
|
221 |
|
222 |
|
223 public: // New functions |
|
224 |
|
225 /** |
|
226 * Name |
|
227 * |
|
228 * @since 3.0 |
|
229 * @return name of the property |
|
230 */ |
|
231 TUint Name() const; |
|
232 |
|
233 |
|
234 /** |
|
235 * Level of the property |
|
236 * |
|
237 * @since 3.0 |
|
238 * @return |
|
239 */ |
|
240 TUint Level() const; |
|
241 |
|
242 |
|
243 /** |
|
244 * Value |
|
245 * |
|
246 * @since 3.0 |
|
247 * @return value of chosen type of the property |
|
248 */ |
|
249 TInt ValueInt() const; |
|
250 const TDesC16& ValueDes16() const; |
|
251 const TDesC8& ValueDes8() const; |
|
252 |
|
253 |
|
254 /** |
|
255 * Set given value |
|
256 * |
|
257 * @since 3.0 |
|
258 * @param aValue new value to be set |
|
259 */ |
|
260 void SetValue( TUint aValue ); |
|
261 void SetValueL( const TDesC16& aValue ); |
|
262 void SetValueL( const TDesC8& aValue ); |
|
263 |
|
264 |
|
265 /** |
|
266 * Validate property type |
|
267 * |
|
268 * @since 3.0 |
|
269 * @param aType type to validate |
|
270 * @return ETrue if type is valid for the property |
|
271 */ |
|
272 TBool ValidateType( TPEngPropertyType aType ) const; |
|
273 |
|
274 |
|
275 /** |
|
276 * Externalizes property to the stream |
|
277 * |
|
278 * @since 3.0 |
|
279 * @param aStream Stream to write to. |
|
280 */ |
|
281 void ExternalizeL( RWriteStream& aStream, TInt aType ) const; |
|
282 |
|
283 |
|
284 /** |
|
285 * Size of the entry for storing. |
|
286 * |
|
287 * @since 3.0 |
|
288 * @return Entry stream size. |
|
289 */ |
|
290 TInt EntrySize(); |
|
291 |
|
292 |
|
293 /** |
|
294 * Internalize contact list settings from the stream |
|
295 * |
|
296 * @since 3.0 |
|
297 * @param aStream stream to read from. |
|
298 */ |
|
299 void InternalizeL( RReadStream& aStream ); |
|
300 |
|
301 |
|
302 private: |
|
303 |
|
304 /** |
|
305 * C++ default constructor. |
|
306 */ |
|
307 CPEngContactListProperty(); |
|
308 |
|
309 /** |
|
310 * Maps given property level to storage type. |
|
311 * @param aLevel The level to map. |
|
312 * @param Mapped storage type. |
|
313 */ |
|
314 static TInt StorageTypeForLevelL( TUint aLevel ); |
|
315 |
|
316 |
|
317 private: // Data |
|
318 |
|
319 /// OWN: Property name |
|
320 TUint iName; |
|
321 |
|
322 /// OWN: Property level |
|
323 TUint iLevel; |
|
324 |
|
325 /// OWN: Property TInt value |
|
326 TInt iTIntValue; |
|
327 |
|
328 /// OWN: TInt value validity |
|
329 TBool iTIntValueValid; |
|
330 |
|
331 /// OWN: Property TDes16 value |
|
332 HBufC16* iTDes16Value; |
|
333 |
|
334 /// OWN: Property TDes8 value |
|
335 HBufC8* iTDes8Value; |
|
336 }; |
|
337 |
|
338 #endif // __CPENGCONTACTLISTPROPERTY_H__ |