applayerpluginsandutils/bookmarksupport/src/customproperty.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2005-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 // Class representing a single custom property.
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "customproperty.h"
       
    20 
       
    21 CCustomProperty* CCustomProperty::NewL(CRepository& aRepository)
       
    22 	{
       
    23 	CCustomProperty* self = new (ELeave) CCustomProperty(aRepository);
       
    24 	return self;
       
    25 	}
       
    26 	
       
    27 CCustomProperty::CCustomProperty(CRepository& aRepository)
       
    28 	: CRepositoryAccessor()
       
    29 	{
       
    30 	SetRepository(aRepository);
       
    31 	}
       
    32 
       
    33 CCustomProperty::~CCustomProperty()
       
    34 	{
       
    35 	}
       
    36 
       
    37 TUint32 CCustomProperty::IndexBase()
       
    38 	{
       
    39 	return iIndexBase;
       
    40 	}
       
    41 	
       
    42 void CCustomProperty::SetIdFromIndexBase(TUint32 aIndexBase)
       
    43 	{
       
    44 	iIndexBase = aIndexBase;
       
    45 	iEntryId = aIndexBase & KRepIndexMask;
       
    46 	}
       
    47 
       
    48 TUid CCustomProperty::Uid()
       
    49 	{
       
    50 	return iProperty.iId;
       
    51 	}
       
    52 	
       
    53 void CCustomProperty::SetUid(TUid aId)
       
    54 	{
       
    55 	iProperty.iId = aId;
       
    56 	}
       
    57 
       
    58 Bookmark::TPropertyType CCustomProperty::Type()
       
    59 	{
       
    60 	return iProperty.iDataType;
       
    61 	}
       
    62 
       
    63 void CCustomProperty::SetType(Bookmark::TPropertyType aType)
       
    64 	{
       
    65 	iProperty.iDataType = aType;
       
    66 	}
       
    67 	
       
    68 void CCustomProperty::TransNewL()
       
    69 	{
       
    70 	TPckgBuf<TProperty> pckg(iProperty);
       
    71 	// create entry in the repository
       
    72 	iRepository->Create(iIndexBase, pckg);
       
    73 	}
       
    74 	
       
    75 void CCustomProperty::TransSaveL()
       
    76 	{
       
    77 	TPckgBuf<TProperty> pckg(iProperty);
       
    78 	iRepository->Set(iIndexBase, pckg);
       
    79 	}
       
    80 
       
    81 void CCustomProperty::TransLoadL()
       
    82 	{
       
    83 	TPckgBuf<TProperty> pckg;
       
    84 	User::LeaveIfError(iRepository->Get(iIndexBase, pckg));
       
    85 	iProperty = pckg();
       
    86 	
       
    87 	SetClean();
       
    88 	}
       
    89 
       
    90 void CCustomProperty::TransRemoveL()
       
    91 	{
       
    92 	iRepository->Delete(iIndexBase);
       
    93 	}
       
    94