authorisation/userpromptservice/test/tups/src/tupsproperty.cpp
changeset 8 35751d3474b7
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2007-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 the License "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32std.h>
       
    21 #include <e32base.h>
       
    22 #include <bacline.h>
       
    23 #include <f32file.h>
       
    24 #include <e32property.h>
       
    25 #include <numberconversion.h>
       
    26 #include "tupsproperty.h"
       
    27 
       
    28 
       
    29 CUpsProperty* CUpsProperty::NewL(const TUid& aCategory)
       
    30 	{
       
    31 	CUpsProperty* self = new(ELeave) CUpsProperty(aCategory);
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 CUpsProperty::CUpsProperty(const TUid& aCategory)
       
    36 	: iCategory(aCategory)
       
    37 	{
       
    38 	
       
    39 	}
       
    40 
       
    41 void CUpsProperty::GetL(TInt aInstanceNumber, TInt aPropertyKey, TType aType, TInt& aValue)
       
    42 	{
       
    43 	TInt key;
       
    44 	if (aType == EPolicyEvaluator)
       
    45 		{
       
    46 		key = GetPropertyKey(aPropertyKey, KPe_Start, KInstanceInterval, aInstanceNumber);
       
    47 		}
       
    48 	else
       
    49 		{
       
    50 		key = GetPropertyKey(aPropertyKey, KDc_Start, KInstanceInterval, aInstanceNumber);
       
    51 		}
       
    52 	User::LeaveIfError(RProperty::Get(iCategory, key, aValue));
       
    53 	}
       
    54 
       
    55 void CUpsProperty::GetL(TInt aInstanceNumber, TInt aPropertyKey, TType aType, TDes& aValue)
       
    56 	{
       
    57 	TInt key;
       
    58 	if (aType == EPolicyEvaluator)
       
    59 		{
       
    60 		key = GetPropertyKey(aPropertyKey, KPe_Start, KInstanceInterval, aInstanceNumber);
       
    61 		}
       
    62 	else
       
    63 		{
       
    64 		key = GetPropertyKey(aPropertyKey, KDc_Start, KInstanceInterval, aInstanceNumber);
       
    65 		}
       
    66 	User::LeaveIfError(RProperty::Get(iCategory, key, aValue));
       
    67 	}
       
    68 
       
    69 void CUpsProperty::SetL(TInt aInstanceNumber, TInt aPropertyKey, TType aType, TInt aValue)
       
    70 	{
       
    71 	TInt key;
       
    72 	if (aType == EPolicyEvaluator)
       
    73 		{
       
    74 		key = GetPropertyKey(aPropertyKey, KPe_Start, KInstanceInterval, aInstanceNumber);
       
    75 		}
       
    76 	else
       
    77 		{
       
    78 		key = GetPropertyKey(aPropertyKey, KDc_Start, KInstanceInterval, aInstanceNumber);
       
    79 		}
       
    80 	User::LeaveIfError(RProperty::Set(iCategory, key, aValue));
       
    81 	}
       
    82 
       
    83 void CUpsProperty::SetL(TInt aInstanceNumber, TInt aPropertyKey, TType aType, TDes& aValue)
       
    84 	{
       
    85 	TInt key;
       
    86 	if (aType == EPolicyEvaluator)
       
    87 		{
       
    88 		key = GetPropertyKey(aPropertyKey, KPe_Start, KInstanceInterval, aInstanceNumber);
       
    89 		}
       
    90 	else
       
    91 		{
       
    92 		key = GetPropertyKey(aPropertyKey, KDc_Start, KInstanceInterval, aInstanceNumber);
       
    93 		}
       
    94 	User::LeaveIfError(RProperty::Set(iCategory, key, aValue));
       
    95 	}
       
    96 
       
    97 TInt CUpsProperty::GetPropertyKey(TInt aPropertyKey, TInt aStart, TInt aInterval, TInt aInstanceNumber)
       
    98 	{
       
    99 	TInt actualKey = ((aInstanceNumber - 1) * aInterval) + aPropertyKey + aStart;
       
   100 	return actualKey;
       
   101 	}