1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/authorisation/userpromptservice/test/tups/src/tupsproperty.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,101 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <e32base.h>
1.25 +#include <bacline.h>
1.26 +#include <f32file.h>
1.27 +#include <e32property.h>
1.28 +#include <numberconversion.h>
1.29 +#include "tupsproperty.h"
1.30 +
1.31 +
1.32 +CUpsProperty* CUpsProperty::NewL(const TUid& aCategory)
1.33 + {
1.34 + CUpsProperty* self = new(ELeave) CUpsProperty(aCategory);
1.35 + return self;
1.36 + }
1.37 +
1.38 +CUpsProperty::CUpsProperty(const TUid& aCategory)
1.39 + : iCategory(aCategory)
1.40 + {
1.41 +
1.42 + }
1.43 +
1.44 +void CUpsProperty::GetL(TInt aInstanceNumber, TInt aPropertyKey, TType aType, TInt& aValue)
1.45 + {
1.46 + TInt key;
1.47 + if (aType == EPolicyEvaluator)
1.48 + {
1.49 + key = GetPropertyKey(aPropertyKey, KPe_Start, KInstanceInterval, aInstanceNumber);
1.50 + }
1.51 + else
1.52 + {
1.53 + key = GetPropertyKey(aPropertyKey, KDc_Start, KInstanceInterval, aInstanceNumber);
1.54 + }
1.55 + User::LeaveIfError(RProperty::Get(iCategory, key, aValue));
1.56 + }
1.57 +
1.58 +void CUpsProperty::GetL(TInt aInstanceNumber, TInt aPropertyKey, TType aType, TDes& aValue)
1.59 + {
1.60 + TInt key;
1.61 + if (aType == EPolicyEvaluator)
1.62 + {
1.63 + key = GetPropertyKey(aPropertyKey, KPe_Start, KInstanceInterval, aInstanceNumber);
1.64 + }
1.65 + else
1.66 + {
1.67 + key = GetPropertyKey(aPropertyKey, KDc_Start, KInstanceInterval, aInstanceNumber);
1.68 + }
1.69 + User::LeaveIfError(RProperty::Get(iCategory, key, aValue));
1.70 + }
1.71 +
1.72 +void CUpsProperty::SetL(TInt aInstanceNumber, TInt aPropertyKey, TType aType, TInt aValue)
1.73 + {
1.74 + TInt key;
1.75 + if (aType == EPolicyEvaluator)
1.76 + {
1.77 + key = GetPropertyKey(aPropertyKey, KPe_Start, KInstanceInterval, aInstanceNumber);
1.78 + }
1.79 + else
1.80 + {
1.81 + key = GetPropertyKey(aPropertyKey, KDc_Start, KInstanceInterval, aInstanceNumber);
1.82 + }
1.83 + User::LeaveIfError(RProperty::Set(iCategory, key, aValue));
1.84 + }
1.85 +
1.86 +void CUpsProperty::SetL(TInt aInstanceNumber, TInt aPropertyKey, TType aType, TDes& aValue)
1.87 + {
1.88 + TInt key;
1.89 + if (aType == EPolicyEvaluator)
1.90 + {
1.91 + key = GetPropertyKey(aPropertyKey, KPe_Start, KInstanceInterval, aInstanceNumber);
1.92 + }
1.93 + else
1.94 + {
1.95 + key = GetPropertyKey(aPropertyKey, KDc_Start, KInstanceInterval, aInstanceNumber);
1.96 + }
1.97 + User::LeaveIfError(RProperty::Set(iCategory, key, aValue));
1.98 + }
1.99 +
1.100 +TInt CUpsProperty::GetPropertyKey(TInt aPropertyKey, TInt aStart, TInt aInterval, TInt aInstanceNumber)
1.101 + {
1.102 + TInt actualKey = ((aInstanceNumber - 1) * aInterval) + aPropertyKey + aStart;
1.103 + return actualKey;
1.104 + }