sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "SaPrivate.h" sl@0: #include "SaCls.h" sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Count of the properties registered at startup. sl@0: 50 Uids issued from 0x100052C3 to 0x100052F4 sl@0: 0x100052C3 is not used, 0x100052C4 is used for KUidSystemAgentExe sl@0: leaving 48 for property uids sl@0: @internalComponent sl@0: */ sl@0: const TInt KPropertyCount = 48; sl@0: sl@0: //Security policy definitions for the KPropertyCount predefined properties. sl@0: _LIT_SECURITY_POLICY_C1(KSecurityPolicyNone, ECapability_None); sl@0: _LIT_SECURITY_POLICY_C1(KSecurityPolicyWriteDeviceData, ECapabilityWriteDeviceData); sl@0: _LIT_SECURITY_POLICY_S1(KSecurityPolicySwiSIDTrustedUi, 0x101F7295, ECapabilityTrustedUI); sl@0: _LIT_SECURITY_POLICY_S0(KSecurityPolicyJavaSID, 0x1020329F); sl@0: sl@0: // Security policy for secure backup engine sl@0: const TInt KSBESID = 0x10202D56; sl@0: _LIT_SECURITY_POLICY_S0(KSBEWritePolicy, KSBESID); sl@0: _LIT_SECURITY_POLICY_PASS(KSBEReadPolicy); sl@0: sl@0: // Security policy definitions for LBS sl@0: _LIT_SECURITY_POLICY_C1(KLBSLastKnownLocationReadPolicy, ECapabilityReadDeviceData); sl@0: _LIT_SECURITY_POLICY_S0(KLBSLastKnownLocationWritePolicy, 0x101f97b2); sl@0: _LIT_SECURITY_POLICY_PASS(KLBSGpsHwStatusReadPolicy); sl@0: _LIT_SECURITY_POLICY_C1(KLBSGpsHwStatusWritePolicy, ECapabilityWriteDeviceData); sl@0: sl@0: //The function initializes aWritePolicy parameter with the appropriate sl@0: //value, depending on the value of aPropertyUid parameter. sl@0: static void GetPropertyPolicies(const TUid& aPropertyUid, const TSecurityPolicy*& aWritePolicy) sl@0: { sl@0: switch(aPropertyUid.iUid) sl@0: { sl@0: case KUidPhonePwrValue: sl@0: case KUidSIMStatusValue: sl@0: case KUidNetworkStatusValue: sl@0: case KUidNetworkStrengthValue: sl@0: case KUidChargerStatusValue: sl@0: case KUidBatteryStrengthValue: sl@0: case KUidCurrentCallValue: sl@0: aWritePolicy = &KSecurityPolicyWriteDeviceData; sl@0: break; sl@0: default: sl@0: aWritePolicy = &KSecurityPolicyNone; sl@0: break; sl@0: }; sl@0: } sl@0: sl@0: /** sl@0: This function tries to define a property, and if it is not already defined, it sets its value to a default value. sl@0: @internalComponent sl@0: @leave Some of the system-wide error codes. sl@0: @param aCategory The UID that identifies the property category. sl@0: @param aKey The property sub-key, i.e. the key that identifies the specific property within the category. sl@0: @param aAttr This describes the property type, a TType value; persistence, as defined by the KPersistent bit, may be ORed in. sl@0: @param aReadPolicy A security policy defining the security attributes a process must have in order to read this value. sl@0: @param aWritePolicy A security policy defining the security attributes a process must have in order to write this value. sl@0: @param aDefaultValue The default value to assign to the property, if the property does not already exist and we define it. If the default value is zero (0) the property will not be set, since this is the default. sl@0: */ sl@0: static void DefinePSPropertyL(TUid aCategory, TInt aKey, TInt aAttr, const TSecurityPolicy &aReadPolicy, const TSecurityPolicy &aWritePolicy, TInt aDefaultValue) sl@0: { sl@0: TInt err = RProperty::Define(aCategory, aKey, aAttr, aReadPolicy, aWritePolicy); sl@0: sl@0: if (err != KErrAlreadyExists) sl@0: { sl@0: // Leave if the error is not one of KErrNone or KErrAlreadyExists sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: if (err == KErrNone && aDefaultValue != 0) sl@0: { sl@0: // Initialise the value if it was not already defined, and the value is not already set sl@0: User::LeaveIfError(RProperty::Set(aCategory, aKey, aDefaultValue)); sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: /** sl@0: The function creates P&S properties with uid's from 0x100052C5 to 0x100052C5 + KPropertyCount. sl@0: They were (and are) used by the implementation of SystemAgent server. sl@0: If a property is registered for the first time, its initial value will be set to KErrUnknown. sl@0: @internalComponent sl@0: @leave Some of the system-wide error codes. sl@0: */ sl@0: static void CreatePSPropertiesL() sl@0: { sl@0: TUid saUid = TUid::Uid(KUidPhonePwrValue); sl@0: for(TInt i=0;i