metadataengine/client/src/mdeproperty.cpp
changeset 0 c53acadfccc6
child 19 b73252188534
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     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 #include "mdeproperty.h"
       
    20 
       
    21 #include "mdcitem.h"
       
    22 #include "mdscommoninternal.h"
       
    23 #include "mdepropertydef.h"
       
    24 #include "mdcserializationbuffer.h"
       
    25 #include "mdeobject.h"
       
    26 #include "mdeobjectdef.h"
       
    27 #include "mdeerror.h"
       
    28 #include "mdesession.h"
       
    29 
       
    30 CMdEProperty::CMdEProperty(const CMdEPropertyDef& aDef, const CMdEObject& aObject)
       
    31 		: CMdEInstanceItem( CONST_CAST( CMdESession*, &aDef.NamespaceDef().Session() ), KNoId), 
       
    32 		iModFlags(EMdEPropertyModChange), iDef(aDef), iObject(aObject)
       
    33 	{
       
    34 	}
       
    35 
       
    36 CMdEProperty* CMdEProperty::NewL(const CMdEPropertyDef& aDef, const CMdEObject& aObject)
       
    37     {
       
    38     CMdEProperty* self = NewLC(aDef, aObject);
       
    39     CleanupStack::Pop(self);
       
    40     return self;
       
    41     }
       
    42 
       
    43 
       
    44 CMdEProperty* CMdEProperty::NewLC(const CMdEPropertyDef& aDef, const CMdEObject& aObject)
       
    45     {
       
    46     CMdEProperty* self = new (ELeave) CMdEProperty( aDef, aObject );
       
    47     CleanupStack::PushL(self);
       
    48     self->BaseConstructL();
       
    49     return self;
       
    50     }
       
    51 
       
    52 
       
    53 CMdEProperty* CMdEProperty::NewL( const CMdEObject& aObject, CMdCSerializationBuffer& aBuffer )
       
    54 	{
       
    55 	CMdEProperty* ret = CMdEProperty::NewLC( aObject, aBuffer );
       
    56 	CleanupStack::Pop( ret );
       
    57 	return ret;
       
    58 	}
       
    59 
       
    60 CMdEProperty* CMdEProperty::NewLC( const CMdEObject& aObject, CMdCSerializationBuffer& aBuffer )
       
    61 	{
       
    62 	const TMdCProperty& serializedProperty = TMdCProperty::GetFromBufferL( aBuffer );
       
    63 	CMdEPropertyDef* propDef = aObject.Def().GetPropertyDefL( serializedProperty.iPropertyDefId );
       
    64 	CMdEProperty* property = new(ELeave) CMdEProperty( *propDef, aObject );
       
    65 	CleanupStack::PushL( property );
       
    66 	property->BaseConstructL();
       
    67 
       
    68 	if ( propDef->PropertyType() == EPropertyText  && property )
       
    69 		{
       
    70 		__ASSERT_DEBUG( serializedProperty.iValue.iPtr.iCount > 0, User::Panic( _L("Empty text property!"), KErrCorrupt ));
       
    71 		aBuffer.PositionL( serializedProperty.iValue.iPtr.iOffset );
       
    72 		property->iValue.iText = aBuffer.ReceiveDes16L();
       
    73 		}
       
    74 	else if( property )
       
    75 		{
       
    76 		property->iValue = serializedProperty.iValue;
       
    77 		}
       
    78 	
       
    79 	// reset flags
       
    80 	if (property)
       
    81 		{
       
    82 		property->iModFlags = EMdEPropertyModNone;
       
    83 		}
       
    84 
       
    85 	return property;
       
    86 	}
       
    87 
       
    88 void CMdEProperty::BaseConstructL()
       
    89 	{
       
    90 	InstanceItemBaseConstruct();
       
    91 	}
       
    92 
       
    93 CMdEProperty::~CMdEProperty()
       
    94 	{
       
    95 	if (iDef.PropertyType() == EPropertyText)
       
    96 		{
       
    97 		delete iValue.iText;
       
    98 		}
       
    99 	}
       
   100 
       
   101 EXPORT_C const CMdEPropertyDef& CMdEProperty::Def() const
       
   102 	{
       
   103 	return iDef;
       
   104 	}
       
   105 
       
   106 EXPORT_C const CMdEObject& CMdEProperty::Object() const
       
   107 	{
       
   108 	return iObject;
       
   109 	}
       
   110 
       
   111 EXPORT_C TBool CMdEProperty::Modified() const
       
   112 	{
       
   113 	return iModFlags != EMdEPropertyModNone;
       
   114 	}
       
   115 
       
   116 TUint8 CMdEProperty::ModFlags() const
       
   117 	{
       
   118 	return iModFlags;
       
   119 	}
       
   120 
       
   121 void CMdEProperty::SetRemoved()
       
   122 	{
       
   123 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   124 	SetId( KNoId );
       
   125 	
       
   126 	iModFlags |= EMdEPropertyModRemove;
       
   127 	}
       
   128 
       
   129 TBool CMdEProperty::Removed()
       
   130 	{
       
   131 	return iModFlags & EMdEPropertyModRemove;
       
   132 	}
       
   133 
       
   134 void CMdEProperty::ClearFlags()
       
   135 	{
       
   136 	// set ID to property -> CMdEItem::InDatabase returns ETrue
       
   137 	SetId( ~KNoId );
       
   138 	
       
   139 	iModFlags = EMdEPropertyModNone;
       
   140 	}
       
   141 
       
   142 void CMdEProperty::SetModified()
       
   143 	{
       
   144 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   145 	SetId( KNoId );
       
   146 	
       
   147 	iModFlags |= EMdEPropertyModChange;
       
   148 	}
       
   149 
       
   150 TMdEInstanceType CMdEProperty::InstanceType() const
       
   151 	{
       
   152 	return EMdETypeProperty;
       
   153 	}
       
   154 
       
   155 EXPORT_C TBool CMdEProperty::BoolValueL() const
       
   156 	{
       
   157 	if ( iDef.PropertyType() != EPropertyBool )
       
   158 		{
       
   159 		User::Leave( KErrMdEIncorrectType );
       
   160 		}
       
   161 	return iValue.iInt32;
       
   162 	}
       
   163 
       
   164 EXPORT_C TInt8 CMdEProperty::Int8ValueL() const
       
   165 	{
       
   166 	if ( iDef.PropertyType() != EPropertyInt8 )
       
   167 		{
       
   168 		User::Leave( KErrMdEIncorrectType );
       
   169 		}
       
   170 	return iValue.iInt32;
       
   171 	}
       
   172 
       
   173 EXPORT_C TUint8 CMdEProperty::Uint8ValueL() const
       
   174 	{
       
   175 	if ( iDef.PropertyType() != EPropertyUint8 )
       
   176 		{
       
   177 		User::Leave( KErrMdEIncorrectType );
       
   178 		}
       
   179 	return iValue.iUint32;
       
   180 	}
       
   181 
       
   182 EXPORT_C TInt16 CMdEProperty::Int16ValueL() const
       
   183 	{
       
   184 	if ( iDef.PropertyType() != EPropertyInt16 )
       
   185 		{
       
   186 		User::Leave( KErrMdEIncorrectType );
       
   187 		}
       
   188 	return iValue.iInt32;
       
   189 	}
       
   190 
       
   191 EXPORT_C TUint16 CMdEProperty::Uint16ValueL() const
       
   192 	{
       
   193 	if ( iDef.PropertyType() != EPropertyUint16 )
       
   194 		{
       
   195 		User::Leave( KErrMdEIncorrectType );
       
   196 		}
       
   197 	return iValue.iUint32;
       
   198 	}
       
   199 
       
   200 EXPORT_C TInt32 CMdEProperty::Int32ValueL() const
       
   201 	{
       
   202 	if ( iDef.PropertyType() != EPropertyInt32 )
       
   203 		{
       
   204 		User::Leave( KErrMdEIncorrectType );
       
   205 		}
       
   206 	return iValue.iInt32;
       
   207 	}
       
   208 
       
   209 EXPORT_C TUint32 CMdEProperty::Uint32ValueL() const
       
   210 	{
       
   211 	if ( iDef.PropertyType() != EPropertyUint32 )
       
   212 		{
       
   213 		User::Leave( KErrMdEIncorrectType );
       
   214 		}
       
   215 	return iValue.iUint32;
       
   216 	}
       
   217 
       
   218 EXPORT_C TInt64 CMdEProperty::Int64ValueL() const
       
   219 	{
       
   220 	if ( iDef.PropertyType() != EPropertyInt64 )
       
   221 		{
       
   222 		User::Leave( KErrMdEIncorrectType );
       
   223 		}
       
   224 	return iValue.iInt64;
       
   225 	}
       
   226 
       
   227 EXPORT_C TReal32 CMdEProperty::Real32ValueL() const
       
   228 	{
       
   229 	if ( iDef.PropertyType() != EPropertyReal32 )
       
   230 		{
       
   231 		User::Leave( KErrMdEIncorrectType );
       
   232 		}
       
   233 	return iValue.iReal;
       
   234 	}
       
   235 
       
   236 EXPORT_C TReal64 CMdEProperty::Real64ValueL() const
       
   237 	{
       
   238 	if ( iDef.PropertyType() != EPropertyReal64 )
       
   239 		{
       
   240 		User::Leave( KErrMdEIncorrectType );
       
   241 		}
       
   242 	return iValue.iReal;
       
   243 	}
       
   244 
       
   245 EXPORT_C TTime CMdEProperty::TimeValueL() const
       
   246 	{
       
   247 	if ( iDef.PropertyType() != EPropertyTime )
       
   248 		{
       
   249 		User::Leave( KErrMdEIncorrectType );
       
   250 		}
       
   251 	return TTime(iValue.iInt64);
       
   252 	}
       
   253 
       
   254 EXPORT_C const TDesC& CMdEProperty::TextValueL() const
       
   255 	{
       
   256 	if ( iDef.PropertyType() != EPropertyText )
       
   257 		{
       
   258 		User::Leave( KErrMdEIncorrectType );
       
   259 		}
       
   260 	return *iValue.iText;
       
   261 	}
       
   262 
       
   263 
       
   264 EXPORT_C void CMdEProperty::SetBoolValueL(TBool aValue)
       
   265 	{
       
   266 	if ( iDef.PropertyType() != EPropertyBool )
       
   267 		{
       
   268 		User::Leave( KErrMdEIncorrectType );
       
   269 		}
       
   270 #ifdef _DEBUG
       
   271     TMdCValueUnion value;
       
   272     value.iInt32 = aValue;
       
   273     CheckValueMinMaxL( value );
       
   274 #endif
       
   275 	iValue.iInt32 = aValue;
       
   276 	
       
   277 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   278 	SetId( KNoId );
       
   279 	
       
   280     iModFlags = EMdEPropertyModChange;
       
   281 	}
       
   282 
       
   283 EXPORT_C void CMdEProperty::SetInt8ValueL(TInt8 aValue)
       
   284 	{
       
   285 	if ( iDef.PropertyType() != EPropertyInt8 )
       
   286 		{
       
   287 		User::Leave( KErrMdEIncorrectType );
       
   288 		}
       
   289 #ifdef _DEBUG
       
   290     TMdCValueUnion value;
       
   291     value.iInt32 = aValue;
       
   292     CheckValueMinMaxL( value );
       
   293 #endif
       
   294 	iValue.iInt32 = aValue;
       
   295 	
       
   296 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   297 	SetId( KNoId );
       
   298 	
       
   299     iModFlags = EMdEPropertyModChange;
       
   300 	}
       
   301 
       
   302 EXPORT_C void CMdEProperty::SetUint8ValueL(TUint8 aValue)
       
   303 	{
       
   304 	if ( iDef.PropertyType() != EPropertyUint8 )
       
   305 		{
       
   306 		User::Leave( KErrMdEIncorrectType );
       
   307 		}
       
   308 #ifdef _DEBUG
       
   309     TMdCValueUnion value;
       
   310     value.iUint32 = aValue;
       
   311     CheckValueMinMaxL( value );
       
   312 #endif
       
   313 	iValue.iUint32 = aValue;
       
   314 	
       
   315 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   316 	SetId( KNoId );
       
   317 	
       
   318     iModFlags = EMdEPropertyModChange;
       
   319 	}
       
   320 
       
   321 
       
   322 EXPORT_C void CMdEProperty::SetInt16ValueL(TInt16 aValue)
       
   323 	{
       
   324 	if ( iDef.PropertyType() != EPropertyInt16 )
       
   325 		{
       
   326 		User::Leave( KErrMdEIncorrectType );
       
   327 		}
       
   328 #ifdef _DEBUG
       
   329     TMdCValueUnion value;
       
   330     value.iInt32 = aValue;
       
   331     CheckValueMinMaxL( value );
       
   332 #endif
       
   333 	iValue.iInt32 = aValue;
       
   334 	
       
   335 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   336 	SetId( KNoId );
       
   337 	
       
   338     iModFlags = EMdEPropertyModChange;
       
   339 	}
       
   340 
       
   341 EXPORT_C void CMdEProperty::SetUint16ValueL(TUint16 aValue)
       
   342 	{
       
   343 	if ( iDef.PropertyType() != EPropertyUint16 )
       
   344 		{
       
   345 		User::Leave( KErrMdEIncorrectType );
       
   346 		}
       
   347 #ifdef _DEBUG
       
   348     TMdCValueUnion value;
       
   349     value.iUint32 = aValue;
       
   350     CheckValueMinMaxL( value );
       
   351 #endif
       
   352 	iValue.iUint32 = aValue;
       
   353 	
       
   354 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   355 	SetId( KNoId );
       
   356 	
       
   357     iModFlags = EMdEPropertyModChange;
       
   358 	}
       
   359 
       
   360 EXPORT_C void CMdEProperty::SetInt32ValueL(TInt32 aValue)
       
   361 	{
       
   362 	if ( iDef.PropertyType() != EPropertyInt32 )
       
   363 		{
       
   364 		User::Leave( KErrMdEIncorrectType );
       
   365 		}
       
   366 #ifdef _DEBUG
       
   367     TMdCValueUnion value;
       
   368     value.iInt32 = aValue;
       
   369     CheckValueMinMaxL( value );
       
   370 #endif
       
   371 	iValue.iInt32 = aValue;
       
   372 	
       
   373 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   374 	SetId( KNoId );
       
   375 	
       
   376     iModFlags = EMdEPropertyModChange;
       
   377 	}
       
   378 
       
   379 EXPORT_C void CMdEProperty::SetUint32ValueL(TUint32 aValue)
       
   380 	{
       
   381 	if ( iDef.PropertyType() != EPropertyUint32 )
       
   382 		{
       
   383 		User::Leave( KErrMdEIncorrectType );
       
   384 		}
       
   385 #ifdef _DEBUG
       
   386     TMdCValueUnion value;
       
   387     value.iUint32 = aValue;
       
   388     CheckValueMinMaxL( value );
       
   389 #endif
       
   390 	iValue.iUint32 = aValue;
       
   391 	
       
   392 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   393 	SetId( KNoId );
       
   394 	
       
   395     iModFlags = EMdEPropertyModChange;
       
   396 	}
       
   397 
       
   398 EXPORT_C void CMdEProperty::SetInt64ValueL(TInt64 aValue)
       
   399 	{
       
   400 	if ( iDef.PropertyType() != EPropertyInt64 )
       
   401 		{
       
   402 		User::Leave( KErrMdEIncorrectType );
       
   403 		}
       
   404 #ifdef _DEBUG
       
   405     TMdCValueUnion value;
       
   406     value.iInt64 = aValue;
       
   407     CheckValueMinMaxL( value );
       
   408 #endif
       
   409 	iValue.iInt64 = aValue;
       
   410 	
       
   411 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   412 	SetId( KNoId );
       
   413 	
       
   414     iModFlags = EMdEPropertyModChange;
       
   415 	}
       
   416 
       
   417 EXPORT_C void CMdEProperty::SetReal32ValueL(TReal32 aValue)
       
   418 	{
       
   419 	if ( iDef.PropertyType() != EPropertyReal32 )
       
   420 		{
       
   421 		User::Leave( KErrMdEIncorrectType );
       
   422 		}
       
   423 #ifdef _DEBUG
       
   424     TMdCValueUnion value;
       
   425     value.iReal = aValue;
       
   426     CheckValueMinMaxL( value );
       
   427 #endif
       
   428 	iValue.iReal = aValue;
       
   429 	
       
   430 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   431 	SetId( KNoId );
       
   432 	
       
   433     iModFlags = EMdEPropertyModChange;
       
   434 	}
       
   435 
       
   436 EXPORT_C void CMdEProperty::SetReal64ValueL(TReal64 aValue)
       
   437 	{
       
   438 	if ( iDef.PropertyType() != EPropertyReal64 )
       
   439 		{
       
   440 		User::Leave( KErrMdEIncorrectType );
       
   441 		}
       
   442 #ifdef _DEBUG
       
   443     TMdCValueUnion value;
       
   444     value.iReal = aValue;
       
   445     CheckValueMinMaxL( value );
       
   446 #endif
       
   447 	iValue.iReal = aValue;
       
   448 	
       
   449 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   450 	SetId( KNoId );
       
   451 	
       
   452     iModFlags = EMdEPropertyModChange;
       
   453 	}
       
   454 
       
   455 EXPORT_C void CMdEProperty::SetTimeValueL(const TTime& aValue)
       
   456 	{
       
   457 	if ( iDef.PropertyType() != EPropertyTime )
       
   458 		{
       
   459 		User::Leave( KErrMdEIncorrectType );
       
   460 		}
       
   461 #ifdef _DEBUG
       
   462     TMdCValueUnion value;
       
   463     value.iInt64 = aValue.Int64();
       
   464     CheckValueMinMaxL( value );
       
   465 #endif
       
   466 	iValue.iInt64 = aValue.Int64();
       
   467 	
       
   468 	// remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   469 	SetId( KNoId );
       
   470 	
       
   471     iModFlags = EMdEPropertyModChange;
       
   472 	}
       
   473 
       
   474 EXPORT_C void CMdEProperty::SetTextValueL(const TDesC& aValue)
       
   475     {
       
   476 #ifdef _DEBUG
       
   477     TMdCValueUnion value;
       
   478     value.iText = (HBufC*)&aValue;
       
   479     CheckValueMinMaxL( value );
       
   480 #endif
       
   481 
       
   482     DoSetTextValueL( aValue );
       
   483     
       
   484     // remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   485 	SetId( KNoId );
       
   486     
       
   487     iModFlags = EMdEPropertyModChange;
       
   488     }
       
   489 
       
   490 #ifdef _DEBUG
       
   491 #include <e32debug.h>
       
   492 
       
   493 void CMdEProperty::CheckValueMinMaxL( const TMdCValueUnion& aValue ) const
       
   494 	{
       
   495 	_LIT( KFunctionName, "CMdEProperty::CheckValueMinMaxL" );
       
   496     switch( iDef.PropertyType() )
       
   497 	    {
       
   498 	    case EPropertyBool:
       
   499 	    	break;
       
   500 	    case EPropertyInt8:
       
   501 	    case EPropertyInt16:
       
   502 	    case EPropertyInt32:
       
   503 	    	if ( !(iDef.MinInt32ValueL() <= aValue.iInt32 && aValue.iInt32 <= iDef.MaxInt32ValueL()) )
       
   504 	    		{
       
   505 #ifdef _DEBUG
       
   506 	    		RDebug::Print( _L("Incorrect property[%S] value: %d"), &iDef.Name(), aValue );
       
   507 #endif
       
   508 	    		User::Panic( KFunctionName, KErrArgument );
       
   509 	    		}
       
   510 	    	break;
       
   511 	    case EPropertyUint8:
       
   512 	    case EPropertyUint16:
       
   513 	    case EPropertyUint32:
       
   514 	    	if ( !(iDef.MinUint32ValueL() <= aValue.iUint32 && aValue.iUint32 <= iDef.MaxUint32ValueL()) )
       
   515 	    		{
       
   516 #ifdef _DEBUG
       
   517 	    		RDebug::Print( _L("Incorrect property[%S] value: %u"), &iDef.Name(), aValue );
       
   518 #endif
       
   519 	    		User::Panic( KFunctionName, KErrArgument );
       
   520 	    		}
       
   521     		break;
       
   522 	    case EPropertyInt64:
       
   523 	    	if ( !(iDef.MinInt64ValueL() <= aValue.iInt64 && aValue.iInt64 <= iDef.MaxInt64ValueL()) )
       
   524 	    		{
       
   525 #ifdef _DEBUG
       
   526 	    		RDebug::Print( _L("Incorrect property[%S] value: %Ld"), &iDef.Name(), aValue );
       
   527 #endif
       
   528 	    		User::Panic( KFunctionName, KErrArgument );
       
   529 	    		}
       
   530 			break;
       
   531 	    case EPropertyTime:
       
   532 	    	if ( !(iDef.MinTimeValueL().Int64() <= aValue.iInt64 && aValue.iInt64 <= iDef.MaxTimeValueL().Int64()) )
       
   533 	    		{
       
   534 #ifdef _DEBUG
       
   535 	    		RDebug::Print( _L("Incorrect property[%S] value: %Ld"), &iDef.Name(), aValue );
       
   536 #endif
       
   537 	    		User::Panic( KFunctionName, KErrArgument );
       
   538 	    		}
       
   539 			break;
       
   540 	    case EPropertyReal32:
       
   541 	    case EPropertyReal64:
       
   542 	    	if ( !(iDef.MinRealValueL() <= aValue.iReal && aValue.iReal <= iDef.MaxRealValueL()) )
       
   543 	    		{
       
   544 #ifdef _DEBUG
       
   545 	    		RDebug::Print( _L("Incorrect property[%S] value: %.2f"), &iDef.Name(), aValue );
       
   546 #endif
       
   547 	    		User::Panic( KFunctionName, KErrArgument );
       
   548 	    		}
       
   549 			break;
       
   550 	    case EPropertyText:
       
   551 			const TInt valueLength = aValue.iText->Length();
       
   552 			if ( !(iDef.MinTextLengthL() <= valueLength && valueLength <= iDef.MaxTextLengthL()) )
       
   553 				{
       
   554 #ifdef _DEBUG
       
   555 				RDebug::Print( _L("Incorrect property[%S] value: \"%S\", length: %d"), &iDef.Name(), aValue.iText, valueLength );
       
   556 #endif
       
   557 				User::Panic( KFunctionName, KErrArgument );
       
   558 				}
       
   559 			break;
       
   560 	    }
       
   561 	}
       
   562 #endif
       
   563 
       
   564 void CMdEProperty::DoSetTextValueL(const TDesC& aValue)
       
   565     {
       
   566     if ( iValue.iText )
       
   567     	{
       
   568     	if ( iValue.iText->Size() == aValue.Size() )
       
   569     		{
       
   570     		TPtr16 ptr(iValue.iText->Des());
       
   571     		ptr.Copy( aValue );
       
   572     		}
       
   573     	else
       
   574     		{
       
   575 		    delete iValue.iText;
       
   576 		    iValue.iText = NULL;
       
   577     		}
       
   578     	}
       
   579 
       
   580     if ( !iValue.iText )
       
   581     	{
       
   582     	iValue.iText = aValue.AllocL();
       
   583     	}
       
   584     
       
   585     // remove ID from property -> CMdEItem::InDatabase returns EFalse
       
   586 	SetId( KNoId );
       
   587     
       
   588     iModFlags = EMdEPropertyModChange;
       
   589     }
       
   590 
       
   591 TUint32 CMdEProperty::RequiredBufferSize() const
       
   592 	{
       
   593 	TUint32 size = sizeof( TMdCProperty );
       
   594 	if ( iDef.PropertyType() == EPropertyText )
       
   595 		{
       
   596 		size += CMdCSerializationBuffer::RequiredSize( *iValue.iText );
       
   597 		}
       
   598 	return size;
       
   599 	}
       
   600 
       
   601 TMdCOffset CMdEProperty::SerializeL(CMdCSerializationBuffer& aBuffer, TMdCOffset aFreespaceOffset) const
       
   602 	{
       
   603 	const TMdCOffset propertyOffset = aBuffer.Position();
       
   604 	TMdCProperty property;
       
   605 	property.iPropertyDefId = Def().Id();
       
   606 	property.iModFlags = iModFlags;
       
   607 	if ( iDef.PropertyType() == EPropertyText )
       
   608 		{
       
   609 		property.iValue.iPtr.iCount = iValue.iText->Length();
       
   610 		property.iValue.iPtr.iOffset = aFreespaceOffset;
       
   611 		aBuffer.PositionL( aFreespaceOffset );
       
   612 		aFreespaceOffset = aBuffer.InsertL( *iValue.iText );
       
   613 		}
       
   614 	else
       
   615 		{
       
   616 		property.iValue = iValue;
       
   617 		}
       
   618 	
       
   619 	// serialize property itself
       
   620 	aBuffer.PositionL( propertyOffset );
       
   621 	property.SerializeL( aBuffer );
       
   622 
       
   623 	return aFreespaceOffset;
       
   624 	}
       
   625