sl@0: // Copyright (c) 2004-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: using namespace NCentralRepositoryConstants; sl@0: sl@0: inline TServerSetting::TServerSetting() sl@0: : iKey(0), sl@0: iMeta(0), sl@0: iAccessPolicy(0) sl@0: { sl@0: Mem::FillZ(&iValue, sizeof(iValue)); sl@0: } sl@0: sl@0: inline TServerSetting::TServerSetting(const TUint32 aKey) sl@0: : iKey(aKey), sl@0: iMeta(0), sl@0: iAccessPolicy(0) sl@0: { sl@0: Mem::FillZ(&iValue, sizeof(iValue)); sl@0: } sl@0: sl@0: /** Ensures this setting has the same type and value of source. Where EString types sl@0: are involved, safely removes previously-owned string, and deep copies string taken sl@0: from source. sl@0: Does not require source and destination type to match. Callers must check if important. sl@0: @return KErrNone if successful or KErrNoMemory if no memory available for copying any string. sl@0: @post If error code is not KErrNone, object is guaranteed to be in its original state. sl@0: */ sl@0: inline TInt TServerSetting::ReplaceTypeAndValue(const TServerSetting& source) sl@0: { sl@0: ASSERT(IsDeleted()); sl@0: sl@0: if (source.IsStr()) sl@0: { sl@0: const HBufC8* sourceBuf = source.GetStrValue(); sl@0: HBufC8* buf = sourceBuf ? sourceBuf->Alloc() : NULL; sl@0: if (sourceBuf && !buf) sl@0: { sl@0: return KErrNoMemory; sl@0: } sl@0: sl@0: ResetValue(); sl@0: SetType(EString); sl@0: iValue.s = buf; sl@0: } sl@0: else if (source.IsReal()) sl@0: { sl@0: if(!source.iValue.r) sl@0: { sl@0: return KErrCorrupt; sl@0: } sl@0: sl@0: TReal* temp = new TReal(source.GetRealValue()); sl@0: if (temp == NULL) sl@0: { sl@0: return KErrNoMemory; sl@0: } sl@0: sl@0: ResetValue(); sl@0: SetType(EReal); sl@0: iValue.r = temp; sl@0: } sl@0: else sl@0: { sl@0: ResetValue(); sl@0: SetType(source.Type()); sl@0: if (source.IsInt()) sl@0: { sl@0: iValue.i = source.GetIntValue(); sl@0: } sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** Replaces the contents of this setting with those of source, safely cleaning up previously- sl@0: owned string, and making a deep copy of source string if of string type. sl@0: Does not require source and destination type to match. Callers must check if important. sl@0: @return KErrNone if successful or KErrNoMemory if no memory available for copying any string. sl@0: @post If error code is not KErrNone, object is guaranteed to be in its original state. sl@0: */ sl@0: inline TInt TServerSetting::Replace(const TServerSetting& aSetting) sl@0: { sl@0: if (aSetting.IsStr()) sl@0: { sl@0: const HBufC8* sourceBuf = aSetting.GetStrValue(); sl@0: HBufC8* targetBuf = sourceBuf ? sourceBuf->Alloc() : NULL; sl@0: if (sourceBuf && !targetBuf) sl@0: { sl@0: return KErrNoMemory; sl@0: } sl@0: Reset(); sl@0: *this = aSetting; sl@0: iValue.s = targetBuf; sl@0: } sl@0: else if (aSetting.IsReal()) sl@0: { sl@0: TReal* temp = new TReal(aSetting.GetRealValue()); sl@0: if(temp == NULL) sl@0: { sl@0: return KErrNoMemory; sl@0: } sl@0: sl@0: Reset(); sl@0: *this = aSetting; sl@0: iValue.r = temp; sl@0: temp = NULL; sl@0: } sl@0: else sl@0: { sl@0: Reset(); sl@0: *this = aSetting; sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** Transfer ownership of the contents of this setting with those of source, safely cleaning up previously- sl@0: owned string, and making a deep copy of source string if of string type. sl@0: Does not require source and destination type to match. Callers must check if important. sl@0: @return KErrNone if successful or KErrNoMemory if no memory available for copying any string. sl@0: @post If error code is not KErrNone, object is guaranteed to be in its original state. sl@0: */ sl@0: inline TInt TServerSetting::Transfer(TServerSetting& aSetting) sl@0: { sl@0: Reset(); sl@0: *this = aSetting; sl@0: sl@0: Mem::FillZ(&aSetting.iValue, sizeof(aSetting.iValue)); sl@0: aSetting.SetType(EDeleted); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: inline TUint32 TServerSetting::Key() const sl@0: { sl@0: return iKey; sl@0: } sl@0: sl@0: inline void TServerSetting::SetKey(TUint32 aKey) sl@0: { sl@0: iKey = aKey; sl@0: } sl@0: sl@0: inline TUint32 TServerSetting::Meta() const sl@0: { sl@0: #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS sl@0: return iMeta & ~KMetaInternal; sl@0: #else sl@0: return iMeta & ~KMetaType; sl@0: #endif sl@0: } sl@0: sl@0: inline void TServerSetting::SetMeta(const TUint32 aMeta) sl@0: { sl@0: iMeta = (iMeta & KMetaType) | (aMeta & ~KMetaType); sl@0: } sl@0: sl@0: inline TUint32 TServerSetting::Type() const sl@0: { sl@0: return iMeta & KMetaType; sl@0: } sl@0: sl@0: inline void TServerSetting::SetType(const TUint32 aType) sl@0: { sl@0: iMeta = (iMeta & ~KMetaType) | (aType & KMetaType); sl@0: } sl@0: sl@0: inline TInt TServerSetting::GetIntValue() const sl@0: { sl@0: return iValue.i; sl@0: } sl@0: sl@0: inline const TReal& TServerSetting::GetRealValue() const sl@0: { sl@0: return *(iValue.r); sl@0: } sl@0: sl@0: inline const HBufC8* TServerSetting::GetStrValue() const sl@0: { sl@0: return iValue.s; sl@0: } sl@0: sl@0: inline void TServerSetting::SetIntValue(TInt aVal) sl@0: { sl@0: SetType(EInt); sl@0: iValue.i = aVal; sl@0: } sl@0: sl@0: inline void TServerSetting::SetRealValue(const TReal* aVal) sl@0: { sl@0: ASSERT(aVal); sl@0: SetType(EReal); sl@0: iValue.r = const_cast(aVal); sl@0: } sl@0: sl@0: sl@0: inline void TServerSetting::SetStrValue(const HBufC8* aVal) sl@0: { sl@0: SetType(EString); sl@0: if(aVal && !aVal->Length()) sl@0: { sl@0: delete aVal; sl@0: iValue.s = NULL; sl@0: } sl@0: else sl@0: { sl@0: iValue.s = const_cast(aVal); sl@0: } sl@0: } sl@0: sl@0: inline void TServerSetting::SetDeleted() sl@0: { sl@0: SetType(EDeleted); sl@0: } sl@0: sl@0: inline TInt TServerSetting::CopyValue(TInt aVal) sl@0: { sl@0: Reset(); sl@0: SetIntValue(aVal); sl@0: return KErrNone; sl@0: } sl@0: sl@0: inline TInt TServerSetting::CopyValue(const TReal& aVal) sl@0: { sl@0: Reset(); sl@0: TReal* temp=new TReal(aVal); sl@0: if (!temp) sl@0: return KErrNoMemory; sl@0: SetRealValue(temp); sl@0: return KErrNone; sl@0: } sl@0: sl@0: inline TInt TServerSetting::CopyValue(const TDesC8& aVal) sl@0: { sl@0: Reset(); sl@0: if (aVal.Length()) sl@0: { sl@0: HBufC8* temp=aVal.Alloc(); sl@0: if (!temp) sl@0: return KErrNoMemory; sl@0: SetStrValue(temp); sl@0: } sl@0: else sl@0: { sl@0: SetStrValue(NULL); sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: inline void TServerSetting::CopyValueL(TInt aVal) sl@0: { sl@0: User::LeaveIfError(CopyValue(aVal)); sl@0: } sl@0: sl@0: inline void TServerSetting::CopyValueL(const TReal& aVal) sl@0: { sl@0: User::LeaveIfError(CopyValue(aVal)); sl@0: } sl@0: sl@0: inline void TServerSetting::CopyValueL(const TDesC8& aVal) sl@0: { sl@0: User::LeaveIfError(CopyValue(aVal)); sl@0: } sl@0: sl@0: inline TInt TServerSetting::AssignValueTo(TInt& aVal) const sl@0: { sl@0: return IsInt() ? (aVal=iValue.i, KErrNone) : KErrArgument; sl@0: } sl@0: sl@0: inline TInt TServerSetting::AssignValueTo(TReal& aVal) const sl@0: { sl@0: return IsReal() ? sl@0: (iValue.r ? (aVal=*(iValue.r), KErrNone) : KErrCorrupt) sl@0: : KErrArgument; sl@0: } sl@0: sl@0: inline TInt TServerSetting::AssignValueTo(TDes8& aVal) const sl@0: { sl@0: return IsStr() ? sl@0: (iValue.s ? (aVal=iValue.s->Des(), KErrNone) : (aVal=KNullDesC8, KErrNone)) sl@0: : KErrArgument; sl@0: } sl@0: sl@0: inline TInt TServerSetting::AssignValueFrom(TInt aVal) sl@0: { sl@0: return IsInt() ? (iValue.i=aVal, KErrNone) : KErrArgument; sl@0: } sl@0: sl@0: inline TInt TServerSetting::AssignValueFrom(const TReal& aVal) sl@0: { sl@0: if(!IsReal()) sl@0: { sl@0: return KErrArgument; sl@0: } sl@0: TReal* temp = new TReal(aVal); sl@0: if (!temp) sl@0: return KErrNoMemory; sl@0: delete iValue.r; sl@0: iValue.r = temp; sl@0: temp = NULL; sl@0: return KErrNone; sl@0: } sl@0: sl@0: inline TInt TServerSetting::AssignValueFrom(const TDesC8& aVal) sl@0: { sl@0: if(!IsStr()) sl@0: return KErrArgument; sl@0: sl@0: if(aVal.Length()) sl@0: { sl@0: HBufC8* buf = aVal.Alloc(); sl@0: if (!buf) sl@0: return KErrNoMemory; sl@0: delete iValue.s; sl@0: iValue.s = buf; sl@0: } sl@0: else sl@0: { sl@0: delete iValue.s; sl@0: iValue.s = NULL; sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: inline void TServerSetting::Reset() sl@0: { sl@0: ResetValue(); sl@0: iAccessPolicy = NULL; sl@0: } sl@0: sl@0: inline void TServerSetting::ResetValue() sl@0: { sl@0: if(IsStr()) sl@0: { sl@0: if(iValue.s) sl@0: { sl@0: delete iValue.s; sl@0: } sl@0: } sl@0: if(IsReal()) sl@0: { sl@0: ASSERT(iValue.r); sl@0: delete iValue.r; sl@0: } sl@0: iValue.i = 0; sl@0: } sl@0: sl@0: inline void TServerSetting::PushL() const sl@0: { sl@0: if(IsStr() && iValue.s) sl@0: { sl@0: CleanupStack::PushL(iValue.s); sl@0: } sl@0: else if(IsReal()) sl@0: { sl@0: CleanupStack::PushL(iValue.r); sl@0: } sl@0: } sl@0: sl@0: inline void TServerSetting::Pop() const sl@0: { sl@0: if(IsStr() && iValue.s) sl@0: { sl@0: CleanupStack::Pop(iValue.s); sl@0: } sl@0: else if(IsReal()) sl@0: { sl@0: CleanupStack::Pop(iValue.r); sl@0: } sl@0: } sl@0: sl@0: inline void TServerSetting::PopAndDestroy() const sl@0: { sl@0: if(IsStr() && iValue.s) sl@0: { sl@0: CleanupStack::PopAndDestroy(iValue.s); sl@0: } sl@0: else if(IsReal()) sl@0: { sl@0: CleanupStack::PopAndDestroy(iValue.r); sl@0: } sl@0: } sl@0: sl@0: inline TInt TServerSetting::operator==(const TServerSetting& aSetting) const sl@0: { sl@0: return aSetting.IsInt() && *this==aSetting.iValue.i || sl@0: aSetting.IsReal() && aSetting.iValue.r && *this==*(aSetting.iValue.r) || sl@0: aSetting.IsStr() && !aSetting.iValue.s && !iValue.s || sl@0: aSetting.IsStr() && aSetting.iValue.s && *this==aSetting.iValue.s->Des(); sl@0: } sl@0: sl@0: inline TInt TServerSetting::operator==(TInt aVal) const sl@0: { sl@0: return IsInt() && iValue.i==aVal; sl@0: } sl@0: sl@0: inline TInt TServerSetting::operator==(const TReal& aVal) const sl@0: { sl@0: return IsReal() && iValue.r && *(iValue.r)==aVal; sl@0: } sl@0: sl@0: inline TInt TServerSetting::operator==(const TDesC8& aVal) const sl@0: { sl@0: return IsStr() && iValue.s && iValue.s->Des()==aVal; sl@0: } sl@0: sl@0: inline TSettingsAccessPolicy* TServerSetting::AccessPolicy() const sl@0: { sl@0: return iAccessPolicy; sl@0: } sl@0: sl@0: inline void TServerSetting::SetAccessPolicy(TSettingsAccessPolicy* aPolicy) sl@0: { sl@0: iAccessPolicy = aPolicy; sl@0: } sl@0: sl@0: //inline const RArray& TServerSetting::GetReadAccessPolicy() sl@0: inline const TSecurityPolicy* TServerSetting::GetReadAccessPolicy() const sl@0: { sl@0: return iAccessPolicy ? iAccessPolicy->GetReadAccessPolicy() : NULL; sl@0: } sl@0: sl@0: //inline const RArray& TServerSetting::GetWriteAccessPolicy() sl@0: inline const TSecurityPolicy* TServerSetting::GetWriteAccessPolicy() const sl@0: { sl@0: return iAccessPolicy ? iAccessPolicy->GetWriteAccessPolicy() : NULL; sl@0: } sl@0: sl@0: inline TBool TServerSetting::HasAccessPolicy() const sl@0: { sl@0: return NULL != iAccessPolicy; sl@0: } sl@0: sl@0: inline void TServerSetting::ExternalizeMetaL(RWriteStream& aStream) const sl@0: { sl@0: //Historically, CRE file stores type and meta information seperately for sl@0: //TServerSetting. To save memory, this has been changed for the sl@0: //in-memory representation but we must store and retrieve the meta in the sl@0: //same way for compatibility with existing backup and cre files. sl@0: #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS sl@0: aStream << (Meta() | (iMeta & KMetaIndividual)) ; sl@0: #else sl@0: aStream << Meta(); sl@0: #endif sl@0: TUint32 type = Type(); sl@0: TUint8 temp = static_cast(type >> 28) ; sl@0: aStream << temp ; sl@0: } sl@0: sl@0: inline void TServerSetting::ExternalizeL(RWriteStream& aStream) const sl@0: { sl@0: aStream << iKey ; sl@0: ExternalizeMetaL(aStream); sl@0: switch (Type()) sl@0: { sl@0: case EInt: sl@0: { sl@0: TInt32 integerValue = iValue.i ; sl@0: aStream << integerValue ; sl@0: break ; sl@0: } sl@0: case EReal : sl@0: ASSERT(iValue.r); sl@0: aStream << *(iValue.r) ; sl@0: break ; sl@0: sl@0: case EString : sl@0: if(iValue.s) sl@0: { sl@0: aStream << *(iValue.s) ; sl@0: } sl@0: else sl@0: { sl@0: aStream << KNullDesC8 ; sl@0: } sl@0: break ; sl@0: sl@0: case EDeleted : sl@0: // Deleted settings should never be in a settings list being made sl@0: // persistent. Hence, fail assert if attempting to externalize them: sl@0: ASSERT(EFalse); sl@0: break ; sl@0: } sl@0: } sl@0: sl@0: sl@0: inline void TServerSetting::InternalizeMetaL(RReadStream& aStream) sl@0: { sl@0: //Historically, CRE file stores type and meta information seperately for sl@0: //TServerSetting. To save memory, this has been changed for the sl@0: //in-memory representation but we must store and retrieve the meta in the sl@0: //same way for compatibility with existing backup and cre files. sl@0: TUint32 meta; sl@0: aStream >> meta; sl@0: SetMeta(meta) ; sl@0: sl@0: TUint8 temp ; sl@0: aStream >> temp ; sl@0: TUint32 type = (static_cast(temp)) << 28; sl@0: SetType(type); sl@0: } sl@0: sl@0: inline void TServerSetting::InternalizeL(RReadStream& aStream) sl@0: { sl@0: aStream >> iKey ; sl@0: InternalizeMetaL(aStream); sl@0: switch (Type()) sl@0: { sl@0: case EInt: sl@0: { sl@0: TInt32 integerValue; sl@0: aStream >> integerValue ; sl@0: iValue.i = integerValue ; sl@0: break ; sl@0: } sl@0: case EReal: sl@0: iValue.r = new(ELeave)TReal; sl@0: aStream >> *(iValue.r); sl@0: break ; sl@0: sl@0: case EString : sl@0: { sl@0: HBufC8* string = HBufC8::NewL (aStream, KMaxBinaryLength) ; sl@0: if(string->Length()) sl@0: { sl@0: iValue.s = string; sl@0: } sl@0: else sl@0: { sl@0: delete string; sl@0: iValue.s = NULL; sl@0: } sl@0: break ; sl@0: } sl@0: sl@0: case EDeleted : sl@0: // Deleted settings should never be in a persistent settings list. sl@0: // Hence, fail assert if attempting to internalize them: sl@0: ASSERT(EFalse); sl@0: break ; sl@0: } sl@0: } sl@0: sl@0: inline TBool TServerSetting::IsType(const TInt&) const sl@0: { sl@0: return Type() == EInt; sl@0: } sl@0: sl@0: inline TBool TServerSetting::IsType(const TReal&) const sl@0: { sl@0: return Type() == EReal; sl@0: } sl@0: sl@0: inline TBool TServerSetting::IsType(const TDesC8&) const sl@0: { sl@0: return Type() == EString; sl@0: } sl@0: sl@0: inline TBool TServerSetting::IsType(const TDesC16&) const sl@0: { sl@0: return Type() == EString; sl@0: } sl@0: sl@0: inline TBool TServerSetting::IsInt() const sl@0: { sl@0: return (iMeta & KMetaType) == EInt; sl@0: } sl@0: sl@0: inline TBool TServerSetting::IsReal() const sl@0: { sl@0: return (iMeta & KMetaType) == EReal; sl@0: } sl@0: sl@0: inline TBool TServerSetting::IsStr() const sl@0: { sl@0: return (iMeta & KMetaType) == EString; sl@0: } sl@0: sl@0: inline TBool TServerSetting::IsDeleted() const sl@0: { sl@0: return (iMeta & KMetaType) == EDeleted; sl@0: } sl@0: sl@0: inline TSettingsAccessPolicy::TSettingsAccessPolicy(TSecurityPolicy& aReadPolicy, sl@0: TSecurityPolicy& aWritePolicy, sl@0: TUint32 aLowKey, TUint32 aHighKey, sl@0: TUint32 aKeyMask) sl@0: { sl@0: iLowKey = aLowKey; sl@0: iHighKey = aHighKey; sl@0: iKeyMask = aKeyMask; sl@0: iReadAccessPolicy.Set(aReadPolicy.Package()); sl@0: iWriteAccessPolicy.Set(aWritePolicy.Package()); sl@0: } sl@0: sl@0: inline TSettingsAccessPolicy::TSettingsAccessPolicy(TSecurityPolicy& aReadPolicy, sl@0: TSecurityPolicy& aWritePolicy, sl@0: TUint32 aKey) sl@0: { sl@0: iLowKey = aKey; sl@0: iHighKey = 0; sl@0: iKeyMask = 0; sl@0: iReadAccessPolicy.Set(aReadPolicy.Package()); sl@0: iWriteAccessPolicy.Set(aWritePolicy.Package()); sl@0: } sl@0: sl@0: inline TSettingsAccessPolicy::TSettingsAccessPolicy(TUint32 key) sl@0: { sl@0: iLowKey = key; sl@0: iHighKey = 0; sl@0: iKeyMask = 0; sl@0: } sl@0: sl@0: inline TSettingsAccessPolicy::TSettingsAccessPolicy() sl@0: { sl@0: iLowKey = 0; sl@0: iHighKey = 0; sl@0: iKeyMask = 0; sl@0: } sl@0: sl@0: inline TBool TSettingsAccessPolicy::IsInRange(TUint32 aKey) const sl@0: { sl@0: if((iLowKey<=aKey)&&(aKey<=iHighKey)) sl@0: return ETrue; sl@0: else if((0 != iKeyMask)&&((iKeyMask&aKey)==iLowKey)) sl@0: return ETrue; sl@0: sl@0: return EFalse; sl@0: } sl@0: sl@0: inline void TSettingsAccessPolicy::ExternalizeL(RWriteStream& aStream) const sl@0: { sl@0: aStream << iLowKey ; sl@0: aStream << iHighKey ; sl@0: aStream << iKeyMask ; sl@0: sl@0: // Externalize TSecurityPolicy objects as descriptors sl@0: aStream << (iReadAccessPolicy.Package()) ; sl@0: aStream << (iWriteAccessPolicy.Package()) ; sl@0: } sl@0: sl@0: inline void TSettingsAccessPolicy::InternalizeL(RReadStream& aStream) sl@0: { sl@0: aStream >> iLowKey ; sl@0: aStream >> iHighKey ; sl@0: aStream >> iKeyMask ; sl@0: sl@0: // Internalize TSecurityPolicy objects as descriptors and then use them sl@0: // to set the actual TSecurityPolicy member data. sl@0: HBufC8* securityPolicyPackage ; sl@0: securityPolicyPackage = HBufC8::NewLC(aStream, 10000); sl@0: iReadAccessPolicy.Set(securityPolicyPackage->Des()) ; sl@0: CleanupStack::PopAndDestroy(securityPolicyPackage) ; sl@0: sl@0: securityPolicyPackage = HBufC8::NewLC(aStream, 10000); sl@0: iWriteAccessPolicy.Set(securityPolicyPackage->Des()) ; sl@0: CleanupStack::PopAndDestroy(securityPolicyPackage) ; sl@0: sl@0: } sl@0: sl@0: inline TUint32 TSettingsAccessPolicy::LowKey() const sl@0: { sl@0: return iLowKey; sl@0: } sl@0: inline TUint32 TSettingsAccessPolicy::HighKey() const sl@0: { sl@0: return iHighKey; sl@0: } sl@0: inline TUint32 TSettingsAccessPolicy::KeyMask() const sl@0: { sl@0: return iKeyMask; sl@0: } sl@0: sl@0: /** sl@0: @internalTechnology sl@0: It is responsility of client to check the key, sl@0: this simply returns the TSecurityPolicy - it is set to EAlwaysFail if uninitialised sl@0: */ sl@0: inline const TSecurityPolicy* TSettingsAccessPolicy::GetReadAccessPolicy() const sl@0: { sl@0: return &iReadAccessPolicy; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @internalTechnology sl@0: It is responsility of client to check the key, sl@0: this simply returns the TSecurityPolicy - it is set to EAlwaysFail if uninitialised sl@0: */ sl@0: inline const TSecurityPolicy* TSettingsAccessPolicy::GetWriteAccessPolicy() const sl@0: { sl@0: return &iWriteAccessPolicy; sl@0: } sl@0: sl@0: inline TSettingsDefaultMeta::TSettingsDefaultMeta(TUint32 aValue, TUint32 aLowKey, sl@0: TUint32 aHighKey, TUint32 aKeyMask) sl@0: { sl@0: iLowKey = aLowKey; sl@0: iHighKey = aHighKey; sl@0: iKeyMask = aKeyMask; sl@0: iDefaultMetaData = aValue; sl@0: } sl@0: sl@0: inline TSettingsDefaultMeta::TSettingsDefaultMeta() sl@0: { sl@0: iLowKey = 0; sl@0: iHighKey = 0; sl@0: iKeyMask = 0; sl@0: iDefaultMetaData = 0; sl@0: } sl@0: sl@0: inline TUint32 TSettingsDefaultMeta::LowKey() const sl@0: { sl@0: return iLowKey; sl@0: } sl@0: sl@0: inline TUint32 TSettingsDefaultMeta::HighKey() const sl@0: { sl@0: return iHighKey; sl@0: } sl@0: sl@0: inline TUint32 TSettingsDefaultMeta::KeyMask() const sl@0: { sl@0: return iKeyMask; sl@0: } sl@0: sl@0: inline TBool TSettingsDefaultMeta::IsInRange(TUint32 aKey) const sl@0: { sl@0: if((iLowKey<=aKey)&&(aKey<=iHighKey)) sl@0: return ETrue; sl@0: else if((0 != iKeyMask)&&((iKeyMask&aKey)==iLowKey)) sl@0: return ETrue; sl@0: sl@0: return EFalse; sl@0: } sl@0: sl@0: inline void TSettingsDefaultMeta::ExternalizeL(RWriteStream& aStream) const sl@0: { sl@0: aStream << iLowKey ; sl@0: aStream << iHighKey ; sl@0: aStream << iKeyMask ; sl@0: aStream << iDefaultMetaData ; sl@0: } sl@0: sl@0: inline void TSettingsDefaultMeta::InternalizeL(RReadStream& aStream) sl@0: { sl@0: aStream >> iLowKey ; sl@0: aStream >> iHighKey ; sl@0: aStream >> iKeyMask ; sl@0: aStream >> iDefaultMetaData; sl@0: } sl@0: sl@0: inline TSettingSingleMeta::TSettingSingleMeta(TUint32 aKey, TUint32 aMeta) : iKey(aKey), iMeta(aMeta) sl@0: { sl@0: } sl@0: sl@0: #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS sl@0: inline void TServerSetting::SetIndividualMeta(TBool aIndividualSettingMeta) sl@0: { sl@0: if (aIndividualSettingMeta) sl@0: iMeta|= KMetaIndividual; sl@0: else sl@0: iMeta&=~KMetaIndividual; sl@0: } sl@0: sl@0: //NEW: Copy the value only from a source, already validate the type sl@0: inline TInt TServerSetting::CopyTypeValue(const TServerSetting& source) sl@0: { sl@0: sl@0: if (source.IsStr()) sl@0: { sl@0: const HBufC8* sourceBuf = source.GetStrValue(); sl@0: HBufC8* buf = sourceBuf ? sourceBuf->Alloc() : NULL; sl@0: if (sourceBuf && !buf) sl@0: { sl@0: return KErrNoMemory; sl@0: } sl@0: ResetValue(); sl@0: SetType(EString); sl@0: iValue.s = buf; sl@0: } sl@0: else if (source.IsReal()) sl@0: { sl@0: if(!source.iValue.r) sl@0: { sl@0: return KErrCorrupt; sl@0: } sl@0: sl@0: TReal* temp = new TReal(source.GetRealValue()); sl@0: if (temp == NULL) sl@0: { sl@0: return KErrNoMemory; sl@0: } sl@0: ResetValue(); sl@0: SetType(EReal); sl@0: iValue.r = temp; sl@0: } sl@0: else sl@0: { sl@0: SetType(source.Type()); sl@0: if (source.IsInt()) sl@0: { sl@0: iValue.i = source.GetIntValue(); sl@0: } sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: #endif