|
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 "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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MDEOBJECT_H__ |
|
20 #define __MDEOBJECT_H__ |
|
21 |
|
22 //#include <uri16.h> |
|
23 |
|
24 #include <mdeinstanceitem.h> |
|
25 |
|
26 // CMdEProperty compatibility wrappers |
|
27 #include <mdetextproperty.h> |
|
28 #include <mdenumberproperty.h> |
|
29 |
|
30 /* Forward declarations. */ |
|
31 class CMdEObjectDef; |
|
32 class CMdEPropertyDef; |
|
33 class CMdEProperty; |
|
34 class CMdCSerializationBuffer; |
|
35 class CMdENamespaceDef; |
|
36 |
|
37 NONSHARABLE_CLASS( TMdEObject ) |
|
38 { |
|
39 public: |
|
40 /* Constructors and destructor. */ |
|
41 |
|
42 /** |
|
43 * Constructs a new object. |
|
44 */ |
|
45 IMPORT_C TMdEObject(); |
|
46 |
|
47 /** |
|
48 * Returns the ID of the object. |
|
49 * |
|
50 * @return Object ID. |
|
51 */ |
|
52 IMPORT_C TItemId Id() const; |
|
53 |
|
54 /** |
|
55 * Returns the definition of the object. Leaves with error code |
|
56 * KErrNotFound if object definition is missing. |
|
57 * |
|
58 * @return Object definition. |
|
59 */ |
|
60 IMPORT_C const CMdEObjectDef& DefL() const; |
|
61 |
|
62 /** |
|
63 * Returns whether object is confidential or not. |
|
64 * |
|
65 * @return <code>ETrue</code>, if the object has been set to confidential. |
|
66 * <code>EFalse</code>, otherwise. |
|
67 */ |
|
68 IMPORT_C TBool Confidential() const; |
|
69 |
|
70 /** |
|
71 * Returns whether object is placeholder or not. |
|
72 * |
|
73 * @return <code>ETrue</code>, if the object has been set to placeholder. |
|
74 * <code>EFalse</code>, otherwise. |
|
75 */ |
|
76 IMPORT_C TBool Placeholder() const; |
|
77 |
|
78 /** |
|
79 * Returns whether object is removed or not. |
|
80 * |
|
81 * @return <code>ETrue</code>, if the object has been set to removed. |
|
82 * <code>EFalse</code>, otherwise. |
|
83 */ |
|
84 IMPORT_C TBool Removed() const; |
|
85 |
|
86 /** |
|
87 * Returns whether object is present or not. |
|
88 * |
|
89 * @return <code>ETrue</code>, if the object has been set to not present. |
|
90 * <code>EFalse</code>, otherwise. |
|
91 */ |
|
92 IMPORT_C TBool NotPresent() const; |
|
93 |
|
94 public: |
|
95 /** |
|
96 * Calculates required size for buffer to serialize object |
|
97 * |
|
98 * @return necessary buffer size |
|
99 */ |
|
100 static TUint32 RequiredBufferSize(); |
|
101 |
|
102 /** |
|
103 * Retrieve object from serialized buffer |
|
104 * |
|
105 * @param aBuffer buffer where serialized object is |
|
106 * @param aNamespaceDef namespace definition of namespace where object is |
|
107 * located |
|
108 */ |
|
109 void DeSerializeL(CMdCSerializationBuffer& aBuffer, |
|
110 CMdENamespaceDef& aNamespaceDef); |
|
111 |
|
112 protected: |
|
113 /** object ID */ |
|
114 TItemId iId; |
|
115 |
|
116 /** Pointer to object definition, this doesn't own it. */ |
|
117 CMdEObjectDef* iDef; |
|
118 |
|
119 /** various flags */ |
|
120 TUint32 iFlags; |
|
121 }; |
|
122 |
|
123 /** |
|
124 * Object. |
|
125 */ |
|
126 NONSHARABLE_CLASS(CMdEObject) : public CMdEInstanceItem |
|
127 { |
|
128 public: |
|
129 |
|
130 /* Constructors and destructor. */ |
|
131 |
|
132 /** |
|
133 * Constructs a new object from serialized buffer |
|
134 * |
|
135 * @param aBuffer buffer which contains serialized object |
|
136 * @param aNamespaceDef reference to namespace where to object is created |
|
137 */ |
|
138 static CMdEObject* NewL( CMdESession* aSession, CMdCSerializationBuffer& aBuffer, CMdENamespaceDef& aNamespaceDef ); |
|
139 |
|
140 /** |
|
141 * Constructs a new object from serialized buffer and leave it on stack |
|
142 * |
|
143 * @param aBuffer buffer which contains serialized object |
|
144 * @param aNamespaceDef reference to namespace where to object is created |
|
145 */ |
|
146 static CMdEObject* NewLC( CMdESession* aSession, CMdCSerializationBuffer& aBuffer, CMdENamespaceDef& aNamespaceDef ); |
|
147 |
|
148 /** |
|
149 * Constructs a new object. |
|
150 * |
|
151 * @param aDef Definition of the new object. |
|
152 * @param aUri URI of the new object. |
|
153 * @param aMediaId mediaid of object. Defaults to 0. |
|
154 */ |
|
155 |
|
156 static CMdEObject* NewL( CMdEObjectDef& aDef, const TDesC& aUri, TUint32 aMediaId = 0 ); |
|
157 |
|
158 /** |
|
159 * Constructs a new object. |
|
160 * |
|
161 * @param aDef Definition of the new object. |
|
162 * @param aUri URI of the new object. |
|
163 * @param aMediaId mediaid of object. Defaults to 0. |
|
164 */ |
|
165 static CMdEObject* NewLC( CMdEObjectDef& aDef, const TDesC& aUri, TUint32 aMediaId = 0 ); |
|
166 |
|
167 |
|
168 /** |
|
169 * Destructor. |
|
170 */ |
|
171 virtual ~CMdEObject(); |
|
172 |
|
173 /* Methods. */ |
|
174 |
|
175 /** |
|
176 * Returns the definition of the object. |
|
177 * |
|
178 * @return Object definition. |
|
179 */ |
|
180 IMPORT_C CMdEObjectDef& Def() const; |
|
181 |
|
182 /** |
|
183 * Sets the definition of the object. Object's old object definition must |
|
184 * be "Object" and object must not belong to any session, otherwise method |
|
185 * leaves with error code KErrNotSupported. |
|
186 * |
|
187 * @param aDef New object definition. |
|
188 */ |
|
189 IMPORT_C void SetDefL(CMdEObjectDef& aDef); |
|
190 |
|
191 /** |
|
192 * Returns the URI of the object. |
|
193 * |
|
194 * @return URI. |
|
195 */ |
|
196 IMPORT_C const TDesC& Uri() const; |
|
197 |
|
198 /** |
|
199 * Sets the URI of the object. |
|
200 * |
|
201 * @param aUri New URI. |
|
202 */ |
|
203 IMPORT_C void SetUriL(const TDesC& aUri); |
|
204 |
|
205 /** |
|
206 * Returns whether object is confidential or not. |
|
207 * |
|
208 * @return <code>ETrue</code>, if the object has been set to confidential. |
|
209 * <code>EFalse</code>, otherwise. |
|
210 */ |
|
211 IMPORT_C TBool Confidential() const; |
|
212 |
|
213 /** |
|
214 * Returns whether object is confidential or not. |
|
215 * |
|
216 * @param aValue <code>ETrue</code>, if the object is confidential. |
|
217 * <code>EFalse</code>, otherwise. |
|
218 */ |
|
219 IMPORT_C void SetConfidential(TBool aValue); |
|
220 |
|
221 /** |
|
222 * Returns whether object is placeholder or not. |
|
223 * |
|
224 * @return <code>ETrue</code>, if the object has been set to placeholder. |
|
225 * <code>EFalse</code>, otherwise. |
|
226 */ |
|
227 IMPORT_C TBool Placeholder() const; |
|
228 |
|
229 /** |
|
230 * Returns whether object is placeholder or not. |
|
231 * |
|
232 * @param aValue <code>ETrue</code>, if the object is placeholder. |
|
233 * <code>EFalse</code>, otherwise. |
|
234 */ |
|
235 IMPORT_C void SetPlaceholder(TBool aValue); |
|
236 |
|
237 |
|
238 /** |
|
239 * Returns the Media ID of the object. |
|
240 * |
|
241 * @return Media ID. |
|
242 */ |
|
243 IMPORT_C TUint32 MediaId() const; |
|
244 |
|
245 /** |
|
246 * Sets the Media ID of the object. |
|
247 * |
|
248 * @param aMediaId New Media ID. |
|
249 */ |
|
250 IMPORT_C void SetMediaId(TUint32 aMediaId); |
|
251 |
|
252 /** |
|
253 * Returns the usage count of the object. |
|
254 * |
|
255 * @return usage count |
|
256 */ |
|
257 IMPORT_C TUint32 UsageCount() const; |
|
258 |
|
259 /** |
|
260 * Returns the Guid of the object. |
|
261 * |
|
262 * @param aGuidHigh reference where GuidHigh will be stored |
|
263 * @param aGuidLow reference where GuidLow will be stored |
|
264 */ |
|
265 IMPORT_C void Guid( TInt64& aGuidHigh, TInt64& aGuidLow ) const; |
|
266 |
|
267 /** |
|
268 * Sets the Guid of the object. |
|
269 * |
|
270 * @param aGuidHigh new GuidHigh value |
|
271 * @param aGuidLow new GuidLow value |
|
272 */ |
|
273 IMPORT_C void SetGuid( const TInt64& aGuidHigh, const TInt64& aGuidLow ); |
|
274 |
|
275 /** |
|
276 * Returns whether the object is open for modifications or not. |
|
277 * |
|
278 * @return <code>ETrue</code>, if the object is open for modifications. |
|
279 * <code>EFalse</code>, otherwise. |
|
280 */ |
|
281 IMPORT_C TBool OpenForModifications() const; |
|
282 |
|
283 /* Methods for accessing properties. */ |
|
284 |
|
285 /** |
|
286 * Returns the number of properties. |
|
287 * |
|
288 * @return number of properties |
|
289 */ |
|
290 IMPORT_C TInt PropertyCount() const; |
|
291 |
|
292 /** |
|
293 * Returns the property at the specified index. |
|
294 * |
|
295 * @param aIndex index |
|
296 * |
|
297 * @return property |
|
298 */ |
|
299 IMPORT_C CMdEProperty& PropertyL(TInt aIndex) const; |
|
300 |
|
301 /** |
|
302 * Returns the property by given property def |
|
303 * |
|
304 * Example: |
|
305 * CMdENamespaceDef& defaultNamespace = iMdeSession->GetDefaultNamespaceDefL(); |
|
306 * CMdEObjectDef& imageDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject ); |
|
307 * CMdEObject* image = iMdESession->OpenObjectL( 17, imageDef ); |
|
308 * |
|
309 * CMdEPropertyDef& lastModDatePropDef = imageDef.GetPropertyDefL( |
|
310 * Object::KLastModifiedDateProperty ); |
|
311 * |
|
312 * CMdEProperty* lastModDateProp = NULL; |
|
313 * image->Property( lastModDatePropDef, lastModDateProp ); |
|
314 * |
|
315 * @param aDef property definition |
|
316 * @param aProperty ref to pointer that will receive property address, if such is found. |
|
317 * @param aStartAt index where to begin search(by default starts from beginning) |
|
318 * |
|
319 * @return Index, or <code>KErrNotFound</code>. |
|
320 */ |
|
321 IMPORT_C TInt Property(const CMdEPropertyDef& aDef, CMdEProperty*& aProperty, TInt aStartAt=0) const; |
|
322 |
|
323 /** |
|
324 * Returns the number of properties of the specified definition. |
|
325 * |
|
326 * @param aDef property definition |
|
327 * |
|
328 * @return number of properties |
|
329 */ |
|
330 IMPORT_C TInt PropertyCount(const CMdEPropertyDef& aDef) const; |
|
331 |
|
332 /** |
|
333 * Adds a new bool property to the object. If property definition doesn't |
|
334 * match with value, method leaves with error code KErrArgument. |
|
335 * |
|
336 * Example: |
|
337 * CMdEPropertyDef& receivedDef = objectDef.GetPropertyDefL( MdeConstants::Message::KReceivedProperty ); |
|
338 * metadataObject.AddBoolPropertyL( receivedDef, ETrue ); |
|
339 * |
|
340 * @param aDef Definition of the new property. |
|
341 * @param aValue Value of the new property. |
|
342 * |
|
343 * @return New property. |
|
344 */ |
|
345 IMPORT_C CMdEProperty& AddBoolPropertyL(CMdEPropertyDef& aDef, TBool aValue); |
|
346 |
|
347 /** |
|
348 * Adds a new signed 8-bit integer property to the object. If property |
|
349 * definition doesn't match with value, method leaves with error code |
|
350 * KErrArgument. |
|
351 * |
|
352 * Example: |
|
353 * CMdEPropertyDef& eightBitDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
354 * metadataObject.AddInt8PropertyL( eightBitDef, value ); |
|
355 * |
|
356 * @param aDef Definition of the new property. |
|
357 * @param aValue Value of the new property. |
|
358 * |
|
359 * @return New property. |
|
360 */ |
|
361 IMPORT_C CMdEProperty& AddInt8PropertyL(CMdEPropertyDef& aDef, TInt8 aValue); |
|
362 |
|
363 /** |
|
364 * Adds a new unsigned 8-bit integer property to the object. If property |
|
365 * definition doesn't match with value, method leaves with error code |
|
366 * KErrArgument. |
|
367 * |
|
368 * Example: |
|
369 * CMdEPropertyDef& eightBitDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
370 * metadataObject.AddUint8PropertyL( eightBitDef, value ); |
|
371 * |
|
372 * @param aDef Definition of the new property. |
|
373 * @param aValue Value of the new property. |
|
374 * |
|
375 * @return New property. |
|
376 */ |
|
377 IMPORT_C CMdEProperty& AddUint8PropertyL(CMdEPropertyDef& aDef, TUint8 aValue); |
|
378 |
|
379 /** |
|
380 * Adds a new signed 16-bit integer property to the object. If property |
|
381 * definition doesn't match with value, method leaves with error code |
|
382 * KErrArgument. |
|
383 * |
|
384 * Example: |
|
385 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
386 * metadataObject.AddInt16PropertyL( propertyDef, value ); |
|
387 * |
|
388 * @param aDef Definition of the new property. |
|
389 * @param aValue Value of the new property. |
|
390 * |
|
391 * @return New property. |
|
392 */ |
|
393 IMPORT_C CMdEProperty& AddInt16PropertyL(CMdEPropertyDef& aDef, TInt16 aValue); |
|
394 |
|
395 /** |
|
396 * Adds a new unsigned 16-bit integer property to the object. If property |
|
397 * definition doesn't match with value, method leaves with error code |
|
398 * KErrArgument. |
|
399 * |
|
400 * Example: |
|
401 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
402 * metadataObject.AddUint16PropertyL( propertyDef, value ); |
|
403 * |
|
404 * @param aDef Definition of the new property. |
|
405 * @param aValue Value of the new property. |
|
406 * |
|
407 * @return New property. |
|
408 */ |
|
409 IMPORT_C CMdEProperty& AddUint16PropertyL(CMdEPropertyDef& aDef, TUint16 aValue); |
|
410 |
|
411 /** |
|
412 * Adds a new signed 32-bit integer property to the object. If property |
|
413 * definition doesn't match with value, method leaves with error code |
|
414 * KErrArgument. |
|
415 * |
|
416 * Example: |
|
417 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
418 * metadataObject.AddInt32PropertyL( propertyDef, value ); |
|
419 * |
|
420 * @param aDef Definition of the new property. |
|
421 * @param aValue Value of the new property. |
|
422 * |
|
423 * @return New property. |
|
424 */ |
|
425 IMPORT_C CMdEProperty& AddInt32PropertyL(CMdEPropertyDef& aDef, TInt32 aValue); |
|
426 |
|
427 /** |
|
428 * Adds a new unsigned 32-bit integer property to the object. If property |
|
429 * definition doesn't match with value, method leaves with error code |
|
430 * KErrArgument. |
|
431 * |
|
432 * Example: |
|
433 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
434 * metadataObject.AddUint32PropertyL( propertyDef, value ); |
|
435 * |
|
436 * @param aDef Definition of the new property. If property definition doesn't |
|
437 * match with value, method leaves with error code KErrArgument. |
|
438 * @param aValue Value of the new property. |
|
439 * |
|
440 * @return New property. |
|
441 */ |
|
442 IMPORT_C CMdEProperty& AddUint32PropertyL(CMdEPropertyDef& aDef, TUint32 aValue); |
|
443 |
|
444 /** |
|
445 * Adds a new 64-bit integer property to the object. If property definition |
|
446 * doesn't match with value, method leaves with error code KErrArgument. |
|
447 * |
|
448 * Example: |
|
449 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
450 * metadataObject.AddInt64PropertyL( propertyDef, value ); |
|
451 * |
|
452 * @param aDef Definition of the new property. |
|
453 * @param aValue Value of the new property. |
|
454 * |
|
455 * @return New property. |
|
456 */ |
|
457 IMPORT_C CMdEProperty& AddInt64PropertyL(CMdEPropertyDef& aDef, TInt64 aValue); |
|
458 |
|
459 /** |
|
460 * Adds a new 32-bit real property to the object. If property definition |
|
461 * doesn't match with value, method leaves with error code KErrArgument. |
|
462 * |
|
463 * Example: |
|
464 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
465 * metadataObject.AddReal32PropertyL( propertyDef, realValue ); |
|
466 * |
|
467 * @param aDef Definition of the new property. |
|
468 * @param aValue Value of the new property. |
|
469 * |
|
470 * @return New property. |
|
471 */ |
|
472 IMPORT_C CMdEProperty& AddReal32PropertyL(CMdEPropertyDef& aDef, TReal32 aValue); |
|
473 |
|
474 /** |
|
475 * Adds a new 64-bit real property to the object. If property definition |
|
476 * doesn't match with value, method leaves with error code KErrArgument. |
|
477 * |
|
478 * Example: |
|
479 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
480 * metadataObject.AddReal64PropertyL( propertyDef, realValue ); |
|
481 * |
|
482 * @param aDef Definition of the new property. |
|
483 * @param aValue Value of the new property. |
|
484 * |
|
485 * @return New property. |
|
486 */ |
|
487 IMPORT_C CMdEProperty& AddReal64PropertyL(CMdEPropertyDef& aDef, TReal64 aValue); |
|
488 |
|
489 /** |
|
490 * Adds a new text property to the object. If property definition doesn't |
|
491 * match with value, method leaves with error code KErrArgument. |
|
492 * |
|
493 * Example: |
|
494 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
495 * metadataObject.AddTextPropertyL( propertyDef, text ); |
|
496 * |
|
497 * @param aDef Definition of the new property. |
|
498 * @param aValue Value of the new property. |
|
499 * |
|
500 * @return New property. |
|
501 */ |
|
502 IMPORT_C CMdEProperty& AddTextPropertyL(CMdEPropertyDef& aDef, const TDesC& aValue); |
|
503 |
|
504 /** |
|
505 * Adds a new time property to the object. If property definition doesn't |
|
506 * match with value, method leaves with error code KErrArgument. |
|
507 * |
|
508 * Example: |
|
509 * CMdEPropertyDef& propertyDef = objectDef.GetPropertyDefL( MdeConstants::Object::KProperty ); |
|
510 * metadataObject.AddTimePropertyL( propertyDef, time ); |
|
511 * |
|
512 * @param aDef Definition of the new property. |
|
513 * @param aValue Value of the new property. |
|
514 * |
|
515 * @return New property. |
|
516 */ |
|
517 IMPORT_C CMdEProperty& AddTimePropertyL(CMdEPropertyDef& aDef, TTime aValue); |
|
518 |
|
519 /** |
|
520 * Removes the property at the specified index. |
|
521 * |
|
522 * @param aIndex index |
|
523 */ |
|
524 IMPORT_C void RemoveProperty(TInt aIndex); |
|
525 |
|
526 |
|
527 /* Methods for accessing free text keywords. */ |
|
528 |
|
529 /** |
|
530 * Returns the number of free text keywords. |
|
531 * |
|
532 * @return number of free text keywords |
|
533 */ |
|
534 IMPORT_C TInt FreeTextCount() const; |
|
535 |
|
536 /** |
|
537 * Returns the free text keyword at the specified index |
|
538 * |
|
539 * @param aIndex index |
|
540 * |
|
541 * @return free text keyword |
|
542 */ |
|
543 IMPORT_C TPtrC FreeText(TInt aIndex) const; |
|
544 |
|
545 /** |
|
546 * Returns the index of the specified free text. |
|
547 * |
|
548 * @param aFreeText Free text. |
|
549 * |
|
550 * @return Index, or <code>KErrNotFound</code>. |
|
551 */ |
|
552 IMPORT_C TInt FreeTextIndex(const TDesC& aFreeText) const; |
|
553 |
|
554 /** |
|
555 * Adds a new free text keyword. |
|
556 * |
|
557 * @param aFreeText free text keyword |
|
558 */ |
|
559 IMPORT_C void AddFreeTextL(const TDesC& aFreeText); |
|
560 |
|
561 /** |
|
562 * Removes the free text keyword at the specified index. |
|
563 * |
|
564 * @param aIndex index |
|
565 */ |
|
566 IMPORT_C void RemoveFreeText(TInt aIndex); |
|
567 |
|
568 /** |
|
569 * Move all properties from object which is given as a paremeter to this object |
|
570 * |
|
571 * @param aObject object from where move properties |
|
572 */ |
|
573 IMPORT_C void MovePropertiesL(CMdEObject& aObject); |
|
574 |
|
575 /** |
|
576 * Returns whether the object has been modified or not. |
|
577 * |
|
578 * @return <code>ETrue</code>, if the URI, MediaId or Guids has been modified. |
|
579 * <code>EFalse</code>, otherwise. |
|
580 */ |
|
581 TBool ObjectModified() const; |
|
582 |
|
583 /** |
|
584 * Returns whether the free text array has been modified or not. |
|
585 * |
|
586 * @return <code>ETrue</code>, if FreeTexts has been modified. |
|
587 * <code>EFalse</code>, otherwise. |
|
588 */ |
|
589 TBool FreeTextModified() const; |
|
590 |
|
591 /** |
|
592 * Returns whether one of the properties has been modified or not. |
|
593 * |
|
594 * @return Are properties modified. |
|
595 */ |
|
596 TBool PropertyModified() const; |
|
597 |
|
598 /* |
|
599 * clear all modification flags and removes removed properties |
|
600 */ |
|
601 void ClearObject( TBool aClearFlags = ETrue ); |
|
602 |
|
603 /** |
|
604 * Sets that the object is not open for modifications. |
|
605 */ |
|
606 void SetNotOpenForModifications(); |
|
607 |
|
608 /** |
|
609 * Left locked automatically after it's added to DB. |
|
610 */ |
|
611 void AutoLockL() const; |
|
612 |
|
613 /** |
|
614 * Calculates required size for buffer to serialize object |
|
615 * |
|
616 * @return necessary buffer size |
|
617 */ |
|
618 TUint32 RequiredBufferSize() const; |
|
619 |
|
620 /** |
|
621 * Serialize object |
|
622 * RequiredBufferSize() MUST be always called before this function! |
|
623 * |
|
624 * @param aBuffer buffer where serialized object should go |
|
625 */ |
|
626 TMdCOffset SerializeL(CMdCSerializationBuffer& aBuffer, TMdCOffset aFreespaceOffset) const; |
|
627 |
|
628 protected: |
|
629 |
|
630 virtual TMdEInstanceType InstanceType() const; |
|
631 |
|
632 private: |
|
633 |
|
634 /** |
|
635 * Constructs a new object. |
|
636 * |
|
637 * @param aSession session owner |
|
638 * @param aId object id |
|
639 * @param aDef Definition of the new object. |
|
640 */ |
|
641 CMdEObject( CMdESession* aSession, TItemId aId, CMdEObjectDef& aDef ); |
|
642 |
|
643 /** |
|
644 * Second-phase constructor. |
|
645 * @param aUri URI of the new object. |
|
646 * @param aMediaId mediaid of object. Defaults to 0. |
|
647 */ |
|
648 void ConstructL( const TDesC& aUri, TUint32 aMediaId = 0 ); |
|
649 |
|
650 /** |
|
651 * Sets the URI of the object. |
|
652 * |
|
653 * @param aUri New URI. |
|
654 */ |
|
655 void DoSetUriL(const TDesC& aUri); |
|
656 |
|
657 /** |
|
658 * Adds a new property to the object. |
|
659 * |
|
660 * @param aProperty New property. |
|
661 * @param aState Modification state of the new property. |
|
662 */ |
|
663 void DoAddPropertyL(CMdEProperty& aProperty); |
|
664 |
|
665 /** |
|
666 * Compares two properties. |
|
667 * |
|
668 * @param aFirst First property. |
|
669 * @param aSecond Second property. |
|
670 * |
|
671 * @return 0, if the properties are equal; |
|
672 * a negative value, if the first property is less than the second; |
|
673 * a positive value, if the first property is greater than the second. |
|
674 */ |
|
675 static TInt CompareProperties(const CMdEProperty& aFirst, |
|
676 const CMdEProperty& aSecond); |
|
677 |
|
678 /** |
|
679 * Adds a new free text to the object. |
|
680 * |
|
681 * @param aFreeText New free text. |
|
682 */ |
|
683 TInt DoAddFreeTextL(const HBufC& aFreeText); |
|
684 |
|
685 /** |
|
686 * Compares two free texts. |
|
687 * |
|
688 * @param aFirst First free text. |
|
689 * @param aSecond Second free text. |
|
690 * |
|
691 * @return 0, if the texts are equal; |
|
692 * a negative value, if the first text is less than the second; |
|
693 * a positive value, if the first text is greater than the second. |
|
694 */ |
|
695 static TInt CompareFreeTexts(const HBufC& aFirst, const HBufC& aSecond); |
|
696 |
|
697 /** |
|
698 * Returns how many properties is modified and should be send to server |
|
699 */ |
|
700 TUint32 ModifiedPropertiesCount() const; |
|
701 |
|
702 private: |
|
703 |
|
704 /** Object definition. |
|
705 * This pointer must be initialized in constructor and |
|
706 * not must be NULL in any point. */ |
|
707 CMdEObjectDef* iDef; |
|
708 |
|
709 /** Array for properties. */ |
|
710 RPointerArray<CMdEProperty> iPropertyArray; |
|
711 |
|
712 /** Array for free text. */ |
|
713 RPointerArray<HBufC> iFreeTextArray; |
|
714 |
|
715 /** various flags */ |
|
716 mutable TUint32 iFlags; |
|
717 |
|
718 /** memory card Id */ |
|
719 TUint32 iMediaId; |
|
720 |
|
721 /** usage count (read-only) */ |
|
722 TUint32 iUsageCount; |
|
723 |
|
724 /** Guid Low and High */ |
|
725 TInt64 iGuidHigh; |
|
726 TInt64 iGuidLow; |
|
727 |
|
728 /** URI descriptor. */ |
|
729 HBufC* iUri; |
|
730 |
|
731 mutable CMdEProperty* iProperty; |
|
732 }; |
|
733 |
|
734 |
|
735 #endif // __MDEOBJECT_H__ |