1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/common/inc/setting.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,822 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +using namespace NCentralRepositoryConstants;
1.20 +
1.21 +inline TServerSetting::TServerSetting()
1.22 + : iKey(0),
1.23 + iMeta(0),
1.24 + iAccessPolicy(0)
1.25 + {
1.26 + Mem::FillZ(&iValue, sizeof(iValue));
1.27 + }
1.28 +
1.29 +inline TServerSetting::TServerSetting(const TUint32 aKey)
1.30 + : iKey(aKey),
1.31 + iMeta(0),
1.32 + iAccessPolicy(0)
1.33 + {
1.34 + Mem::FillZ(&iValue, sizeof(iValue));
1.35 + }
1.36 +
1.37 +/** Ensures this setting has the same type and value of source. Where EString types
1.38 +are involved, safely removes previously-owned string, and deep copies string taken
1.39 +from source.
1.40 +Does not require source and destination type to match. Callers must check if important.
1.41 +@return KErrNone if successful or KErrNoMemory if no memory available for copying any string.
1.42 +@post If error code is not KErrNone, object is guaranteed to be in its original state.
1.43 +*/
1.44 +inline TInt TServerSetting::ReplaceTypeAndValue(const TServerSetting& source)
1.45 + {
1.46 + ASSERT(IsDeleted());
1.47 +
1.48 + if (source.IsStr())
1.49 + {
1.50 + const HBufC8* sourceBuf = source.GetStrValue();
1.51 + HBufC8* buf = sourceBuf ? sourceBuf->Alloc() : NULL;
1.52 + if (sourceBuf && !buf)
1.53 + {
1.54 + return KErrNoMemory;
1.55 + }
1.56 +
1.57 + ResetValue();
1.58 + SetType(EString);
1.59 + iValue.s = buf;
1.60 + }
1.61 + else if (source.IsReal())
1.62 + {
1.63 + if(!source.iValue.r)
1.64 + {
1.65 + return KErrCorrupt;
1.66 + }
1.67 +
1.68 + TReal* temp = new TReal(source.GetRealValue());
1.69 + if (temp == NULL)
1.70 + {
1.71 + return KErrNoMemory;
1.72 + }
1.73 +
1.74 + ResetValue();
1.75 + SetType(EReal);
1.76 + iValue.r = temp;
1.77 + }
1.78 + else
1.79 + {
1.80 + ResetValue();
1.81 + SetType(source.Type());
1.82 + if (source.IsInt())
1.83 + {
1.84 + iValue.i = source.GetIntValue();
1.85 + }
1.86 + }
1.87 +
1.88 + return KErrNone;
1.89 + }
1.90 +
1.91 +/** Replaces the contents of this setting with those of source, safely cleaning up previously-
1.92 +owned string, and making a deep copy of source string if of string type.
1.93 +Does not require source and destination type to match. Callers must check if important.
1.94 +@return KErrNone if successful or KErrNoMemory if no memory available for copying any string.
1.95 +@post If error code is not KErrNone, object is guaranteed to be in its original state.
1.96 +*/
1.97 +inline TInt TServerSetting::Replace(const TServerSetting& aSetting)
1.98 + {
1.99 + if (aSetting.IsStr())
1.100 + {
1.101 + const HBufC8* sourceBuf = aSetting.GetStrValue();
1.102 + HBufC8* targetBuf = sourceBuf ? sourceBuf->Alloc() : NULL;
1.103 + if (sourceBuf && !targetBuf)
1.104 + {
1.105 + return KErrNoMemory;
1.106 + }
1.107 + Reset();
1.108 + *this = aSetting;
1.109 + iValue.s = targetBuf;
1.110 + }
1.111 + else if (aSetting.IsReal())
1.112 + {
1.113 + TReal* temp = new TReal(aSetting.GetRealValue());
1.114 + if(temp == NULL)
1.115 + {
1.116 + return KErrNoMemory;
1.117 + }
1.118 +
1.119 + Reset();
1.120 + *this = aSetting;
1.121 + iValue.r = temp;
1.122 + temp = NULL;
1.123 + }
1.124 + else
1.125 + {
1.126 + Reset();
1.127 + *this = aSetting;
1.128 + }
1.129 + return KErrNone;
1.130 + }
1.131 +
1.132 +/** Transfer ownership of the contents of this setting with those of source, safely cleaning up previously-
1.133 +owned string, and making a deep copy of source string if of string type.
1.134 +Does not require source and destination type to match. Callers must check if important.
1.135 +@return KErrNone if successful or KErrNoMemory if no memory available for copying any string.
1.136 +@post If error code is not KErrNone, object is guaranteed to be in its original state.
1.137 +*/
1.138 +inline TInt TServerSetting::Transfer(TServerSetting& aSetting)
1.139 + {
1.140 + Reset();
1.141 + *this = aSetting;
1.142 +
1.143 + Mem::FillZ(&aSetting.iValue, sizeof(aSetting.iValue));
1.144 + aSetting.SetType(EDeleted);
1.145 +
1.146 + return KErrNone;
1.147 + }
1.148 +
1.149 +
1.150 +inline TUint32 TServerSetting::Key() const
1.151 + {
1.152 + return iKey;
1.153 + }
1.154 +
1.155 +inline void TServerSetting::SetKey(TUint32 aKey)
1.156 + {
1.157 + iKey = aKey;
1.158 + }
1.159 +
1.160 +inline TUint32 TServerSetting::Meta() const
1.161 + {
1.162 +#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
1.163 + return iMeta & ~KMetaInternal;
1.164 +#else
1.165 + return iMeta & ~KMetaType;
1.166 +#endif
1.167 + }
1.168 +
1.169 +inline void TServerSetting::SetMeta(const TUint32 aMeta)
1.170 + {
1.171 + iMeta = (iMeta & KMetaType) | (aMeta & ~KMetaType);
1.172 + }
1.173 +
1.174 +inline TUint32 TServerSetting::Type() const
1.175 + {
1.176 + return iMeta & KMetaType;
1.177 + }
1.178 +
1.179 +inline void TServerSetting::SetType(const TUint32 aType)
1.180 + {
1.181 + iMeta = (iMeta & ~KMetaType) | (aType & KMetaType);
1.182 + }
1.183 +
1.184 +inline TInt TServerSetting::GetIntValue() const
1.185 + {
1.186 + return iValue.i;
1.187 + }
1.188 +
1.189 +inline const TReal& TServerSetting::GetRealValue() const
1.190 + {
1.191 + return *(iValue.r);
1.192 + }
1.193 +
1.194 +inline const HBufC8* TServerSetting::GetStrValue() const
1.195 + {
1.196 + return iValue.s;
1.197 + }
1.198 +
1.199 +inline void TServerSetting::SetIntValue(TInt aVal)
1.200 + {
1.201 + SetType(EInt);
1.202 + iValue.i = aVal;
1.203 + }
1.204 +
1.205 +inline void TServerSetting::SetRealValue(const TReal* aVal)
1.206 + {
1.207 + ASSERT(aVal);
1.208 + SetType(EReal);
1.209 + iValue.r = const_cast<TReal*>(aVal);
1.210 + }
1.211 +
1.212 +
1.213 +inline void TServerSetting::SetStrValue(const HBufC8* aVal)
1.214 + {
1.215 + SetType(EString);
1.216 + if(aVal && !aVal->Length())
1.217 + {
1.218 + delete aVal;
1.219 + iValue.s = NULL;
1.220 + }
1.221 + else
1.222 + {
1.223 + iValue.s = const_cast<HBufC8*>(aVal);
1.224 + }
1.225 + }
1.226 +
1.227 +inline void TServerSetting::SetDeleted()
1.228 + {
1.229 + SetType(EDeleted);
1.230 + }
1.231 +
1.232 +inline TInt TServerSetting::CopyValue(TInt aVal)
1.233 + {
1.234 + Reset();
1.235 + SetIntValue(aVal);
1.236 + return KErrNone;
1.237 + }
1.238 +
1.239 +inline TInt TServerSetting::CopyValue(const TReal& aVal)
1.240 + {
1.241 + Reset();
1.242 + TReal* temp=new TReal(aVal);
1.243 + if (!temp)
1.244 + return KErrNoMemory;
1.245 + SetRealValue(temp);
1.246 + return KErrNone;
1.247 + }
1.248 +
1.249 +inline TInt TServerSetting::CopyValue(const TDesC8& aVal)
1.250 + {
1.251 + Reset();
1.252 + if (aVal.Length())
1.253 + {
1.254 + HBufC8* temp=aVal.Alloc();
1.255 + if (!temp)
1.256 + return KErrNoMemory;
1.257 + SetStrValue(temp);
1.258 + }
1.259 + else
1.260 + {
1.261 + SetStrValue(NULL);
1.262 + }
1.263 + return KErrNone;
1.264 + }
1.265 +
1.266 +inline void TServerSetting::CopyValueL(TInt aVal)
1.267 + {
1.268 + User::LeaveIfError(CopyValue(aVal));
1.269 + }
1.270 +
1.271 +inline void TServerSetting::CopyValueL(const TReal& aVal)
1.272 + {
1.273 + User::LeaveIfError(CopyValue(aVal));
1.274 + }
1.275 +
1.276 +inline void TServerSetting::CopyValueL(const TDesC8& aVal)
1.277 + {
1.278 + User::LeaveIfError(CopyValue(aVal));
1.279 + }
1.280 +
1.281 +inline TInt TServerSetting::AssignValueTo(TInt& aVal) const
1.282 + {
1.283 + return IsInt() ? (aVal=iValue.i, KErrNone) : KErrArgument;
1.284 + }
1.285 +
1.286 +inline TInt TServerSetting::AssignValueTo(TReal& aVal) const
1.287 + {
1.288 + return IsReal() ?
1.289 + (iValue.r ? (aVal=*(iValue.r), KErrNone) : KErrCorrupt)
1.290 + : KErrArgument;
1.291 + }
1.292 +
1.293 +inline TInt TServerSetting::AssignValueTo(TDes8& aVal) const
1.294 + {
1.295 + return IsStr() ?
1.296 + (iValue.s ? (aVal=iValue.s->Des(), KErrNone) : (aVal=KNullDesC8, KErrNone))
1.297 + : KErrArgument;
1.298 + }
1.299 +
1.300 +inline TInt TServerSetting::AssignValueFrom(TInt aVal)
1.301 + {
1.302 + return IsInt() ? (iValue.i=aVal, KErrNone) : KErrArgument;
1.303 + }
1.304 +
1.305 +inline TInt TServerSetting::AssignValueFrom(const TReal& aVal)
1.306 + {
1.307 + if(!IsReal())
1.308 + {
1.309 + return KErrArgument;
1.310 + }
1.311 + TReal* temp = new TReal(aVal);
1.312 + if (!temp)
1.313 + return KErrNoMemory;
1.314 + delete iValue.r;
1.315 + iValue.r = temp;
1.316 + temp = NULL;
1.317 + return KErrNone;
1.318 + }
1.319 +
1.320 +inline TInt TServerSetting::AssignValueFrom(const TDesC8& aVal)
1.321 + {
1.322 + if(!IsStr())
1.323 + return KErrArgument;
1.324 +
1.325 + if(aVal.Length())
1.326 + {
1.327 + HBufC8* buf = aVal.Alloc();
1.328 + if (!buf)
1.329 + return KErrNoMemory;
1.330 + delete iValue.s;
1.331 + iValue.s = buf;
1.332 + }
1.333 + else
1.334 + {
1.335 + delete iValue.s;
1.336 + iValue.s = NULL;
1.337 + }
1.338 + return KErrNone;
1.339 + }
1.340 +
1.341 +inline void TServerSetting::Reset()
1.342 + {
1.343 + ResetValue();
1.344 + iAccessPolicy = NULL;
1.345 + }
1.346 +
1.347 +inline void TServerSetting::ResetValue()
1.348 + {
1.349 + if(IsStr())
1.350 + {
1.351 + if(iValue.s)
1.352 + {
1.353 + delete iValue.s;
1.354 + }
1.355 + }
1.356 + if(IsReal())
1.357 + {
1.358 + ASSERT(iValue.r);
1.359 + delete iValue.r;
1.360 + }
1.361 + iValue.i = 0;
1.362 + }
1.363 +
1.364 +inline void TServerSetting::PushL() const
1.365 + {
1.366 + if(IsStr() && iValue.s)
1.367 + {
1.368 + CleanupStack::PushL(iValue.s);
1.369 + }
1.370 + else if(IsReal())
1.371 + {
1.372 + CleanupStack::PushL(iValue.r);
1.373 + }
1.374 + }
1.375 +
1.376 +inline void TServerSetting::Pop() const
1.377 + {
1.378 + if(IsStr() && iValue.s)
1.379 + {
1.380 + CleanupStack::Pop(iValue.s);
1.381 + }
1.382 + else if(IsReal())
1.383 + {
1.384 + CleanupStack::Pop(iValue.r);
1.385 + }
1.386 + }
1.387 +
1.388 +inline void TServerSetting::PopAndDestroy() const
1.389 + {
1.390 + if(IsStr() && iValue.s)
1.391 + {
1.392 + CleanupStack::PopAndDestroy(iValue.s);
1.393 + }
1.394 + else if(IsReal())
1.395 + {
1.396 + CleanupStack::PopAndDestroy(iValue.r);
1.397 + }
1.398 + }
1.399 +
1.400 +inline TInt TServerSetting::operator==(const TServerSetting& aSetting) const
1.401 + {
1.402 + return aSetting.IsInt() && *this==aSetting.iValue.i ||
1.403 + aSetting.IsReal() && aSetting.iValue.r && *this==*(aSetting.iValue.r) ||
1.404 + aSetting.IsStr() && !aSetting.iValue.s && !iValue.s ||
1.405 + aSetting.IsStr() && aSetting.iValue.s && *this==aSetting.iValue.s->Des();
1.406 + }
1.407 +
1.408 +inline TInt TServerSetting::operator==(TInt aVal) const
1.409 + {
1.410 + return IsInt() && iValue.i==aVal;
1.411 + }
1.412 +
1.413 +inline TInt TServerSetting::operator==(const TReal& aVal) const
1.414 + {
1.415 + return IsReal() && iValue.r && *(iValue.r)==aVal;
1.416 + }
1.417 +
1.418 +inline TInt TServerSetting::operator==(const TDesC8& aVal) const
1.419 + {
1.420 + return IsStr() && iValue.s && iValue.s->Des()==aVal;
1.421 + }
1.422 +
1.423 +inline TSettingsAccessPolicy* TServerSetting::AccessPolicy() const
1.424 + {
1.425 + return iAccessPolicy;
1.426 + }
1.427 +
1.428 +inline void TServerSetting::SetAccessPolicy(TSettingsAccessPolicy* aPolicy)
1.429 + {
1.430 + iAccessPolicy = aPolicy;
1.431 + }
1.432 +
1.433 +//inline const RArray<TSecurityPolicy>& TServerSetting::GetReadAccessPolicy()
1.434 +inline const TSecurityPolicy* TServerSetting::GetReadAccessPolicy() const
1.435 + {
1.436 + return iAccessPolicy ? iAccessPolicy->GetReadAccessPolicy() : NULL;
1.437 + }
1.438 +
1.439 +//inline const RArray<TSecurityPolicy>& TServerSetting::GetWriteAccessPolicy()
1.440 +inline const TSecurityPolicy* TServerSetting::GetWriteAccessPolicy() const
1.441 + {
1.442 + return iAccessPolicy ? iAccessPolicy->GetWriteAccessPolicy() : NULL;
1.443 + }
1.444 +
1.445 +inline TBool TServerSetting::HasAccessPolicy() const
1.446 + {
1.447 + return NULL != iAccessPolicy;
1.448 + }
1.449 +
1.450 +inline void TServerSetting::ExternalizeMetaL(RWriteStream& aStream) const
1.451 + {
1.452 + //Historically, CRE file stores type and meta information seperately for
1.453 + //TServerSetting. To save memory, this has been changed for the
1.454 + //in-memory representation but we must store and retrieve the meta in the
1.455 + //same way for compatibility with existing backup and cre files.
1.456 +#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
1.457 + aStream << (Meta() | (iMeta & KMetaIndividual)) ;
1.458 +#else
1.459 + aStream << Meta();
1.460 +#endif
1.461 + TUint32 type = Type();
1.462 + TUint8 temp = static_cast<TUint8>(type >> 28) ;
1.463 + aStream << temp ;
1.464 + }
1.465 +
1.466 +inline void TServerSetting::ExternalizeL(RWriteStream& aStream) const
1.467 + {
1.468 + aStream << iKey ;
1.469 + ExternalizeMetaL(aStream);
1.470 + switch (Type())
1.471 + {
1.472 + case EInt:
1.473 + {
1.474 + TInt32 integerValue = iValue.i ;
1.475 + aStream << integerValue ;
1.476 + break ;
1.477 + }
1.478 + case EReal :
1.479 + ASSERT(iValue.r);
1.480 + aStream << *(iValue.r) ;
1.481 + break ;
1.482 +
1.483 + case EString :
1.484 + if(iValue.s)
1.485 + {
1.486 + aStream << *(iValue.s) ;
1.487 + }
1.488 + else
1.489 + {
1.490 + aStream << KNullDesC8 ;
1.491 + }
1.492 + break ;
1.493 +
1.494 + case EDeleted :
1.495 + // Deleted settings should never be in a settings list being made
1.496 + // persistent. Hence, fail assert if attempting to externalize them:
1.497 + ASSERT(EFalse);
1.498 + break ;
1.499 + }
1.500 + }
1.501 +
1.502 +
1.503 +inline void TServerSetting::InternalizeMetaL(RReadStream& aStream)
1.504 + {
1.505 + //Historically, CRE file stores type and meta information seperately for
1.506 + //TServerSetting. To save memory, this has been changed for the
1.507 + //in-memory representation but we must store and retrieve the meta in the
1.508 + //same way for compatibility with existing backup and cre files.
1.509 + TUint32 meta;
1.510 + aStream >> meta;
1.511 + SetMeta(meta) ;
1.512 +
1.513 + TUint8 temp ;
1.514 + aStream >> temp ;
1.515 + TUint32 type = (static_cast<TUint32>(temp)) << 28;
1.516 + SetType(type);
1.517 + }
1.518 +
1.519 +inline void TServerSetting::InternalizeL(RReadStream& aStream)
1.520 +{
1.521 + aStream >> iKey ;
1.522 + InternalizeMetaL(aStream);
1.523 + switch (Type())
1.524 + {
1.525 + case EInt:
1.526 + {
1.527 + TInt32 integerValue;
1.528 + aStream >> integerValue ;
1.529 + iValue.i = integerValue ;
1.530 + break ;
1.531 + }
1.532 + case EReal:
1.533 + iValue.r = new(ELeave)TReal;
1.534 + aStream >> *(iValue.r);
1.535 + break ;
1.536 +
1.537 + case EString :
1.538 + {
1.539 + HBufC8* string = HBufC8::NewL (aStream, KMaxBinaryLength) ;
1.540 + if(string->Length())
1.541 + {
1.542 + iValue.s = string;
1.543 + }
1.544 + else
1.545 + {
1.546 + delete string;
1.547 + iValue.s = NULL;
1.548 + }
1.549 + break ;
1.550 + }
1.551 +
1.552 + case EDeleted :
1.553 + // Deleted settings should never be in a persistent settings list.
1.554 + // Hence, fail assert if attempting to internalize them:
1.555 + ASSERT(EFalse);
1.556 + break ;
1.557 + }
1.558 + }
1.559 +
1.560 +inline TBool TServerSetting::IsType(const TInt&) const
1.561 + {
1.562 + return Type() == EInt;
1.563 + }
1.564 +
1.565 +inline TBool TServerSetting::IsType(const TReal&) const
1.566 + {
1.567 + return Type() == EReal;
1.568 + }
1.569 +
1.570 +inline TBool TServerSetting::IsType(const TDesC8&) const
1.571 + {
1.572 + return Type() == EString;
1.573 + }
1.574 +
1.575 +inline TBool TServerSetting::IsType(const TDesC16&) const
1.576 + {
1.577 + return Type() == EString;
1.578 + }
1.579 +
1.580 +inline TBool TServerSetting::IsInt() const
1.581 + {
1.582 + return (iMeta & KMetaType) == EInt;
1.583 + }
1.584 +
1.585 +inline TBool TServerSetting::IsReal() const
1.586 + {
1.587 + return (iMeta & KMetaType) == EReal;
1.588 + }
1.589 +
1.590 +inline TBool TServerSetting::IsStr() const
1.591 + {
1.592 + return (iMeta & KMetaType) == EString;
1.593 + }
1.594 +
1.595 +inline TBool TServerSetting::IsDeleted() const
1.596 + {
1.597 + return (iMeta & KMetaType) == EDeleted;
1.598 + }
1.599 +
1.600 +inline TSettingsAccessPolicy::TSettingsAccessPolicy(TSecurityPolicy& aReadPolicy,
1.601 + TSecurityPolicy& aWritePolicy,
1.602 + TUint32 aLowKey, TUint32 aHighKey,
1.603 + TUint32 aKeyMask)
1.604 + {
1.605 + iLowKey = aLowKey;
1.606 + iHighKey = aHighKey;
1.607 + iKeyMask = aKeyMask;
1.608 + iReadAccessPolicy.Set(aReadPolicy.Package());
1.609 + iWriteAccessPolicy.Set(aWritePolicy.Package());
1.610 + }
1.611 +
1.612 +inline TSettingsAccessPolicy::TSettingsAccessPolicy(TSecurityPolicy& aReadPolicy,
1.613 + TSecurityPolicy& aWritePolicy,
1.614 + TUint32 aKey)
1.615 + {
1.616 + iLowKey = aKey;
1.617 + iHighKey = 0;
1.618 + iKeyMask = 0;
1.619 + iReadAccessPolicy.Set(aReadPolicy.Package());
1.620 + iWriteAccessPolicy.Set(aWritePolicy.Package());
1.621 + }
1.622 +
1.623 +inline TSettingsAccessPolicy::TSettingsAccessPolicy(TUint32 key)
1.624 + {
1.625 + iLowKey = key;
1.626 + iHighKey = 0;
1.627 + iKeyMask = 0;
1.628 + }
1.629 +
1.630 +inline TSettingsAccessPolicy::TSettingsAccessPolicy()
1.631 + {
1.632 + iLowKey = 0;
1.633 + iHighKey = 0;
1.634 + iKeyMask = 0;
1.635 + }
1.636 +
1.637 +inline TBool TSettingsAccessPolicy::IsInRange(TUint32 aKey) const
1.638 + {
1.639 + if((iLowKey<=aKey)&&(aKey<=iHighKey))
1.640 + return ETrue;
1.641 + else if((0 != iKeyMask)&&((iKeyMask&aKey)==iLowKey))
1.642 + return ETrue;
1.643 +
1.644 + return EFalse;
1.645 + }
1.646 +
1.647 +inline void TSettingsAccessPolicy::ExternalizeL(RWriteStream& aStream) const
1.648 +{
1.649 + aStream << iLowKey ;
1.650 + aStream << iHighKey ;
1.651 + aStream << iKeyMask ;
1.652 +
1.653 + // Externalize TSecurityPolicy objects as descriptors
1.654 + aStream << (iReadAccessPolicy.Package()) ;
1.655 + aStream << (iWriteAccessPolicy.Package()) ;
1.656 +}
1.657 +
1.658 +inline void TSettingsAccessPolicy::InternalizeL(RReadStream& aStream)
1.659 +{
1.660 + aStream >> iLowKey ;
1.661 + aStream >> iHighKey ;
1.662 + aStream >> iKeyMask ;
1.663 +
1.664 + // Internalize TSecurityPolicy objects as descriptors and then use them
1.665 + // to set the actual TSecurityPolicy member data.
1.666 + HBufC8* securityPolicyPackage ;
1.667 + securityPolicyPackage = HBufC8::NewLC(aStream, 10000);
1.668 + iReadAccessPolicy.Set(securityPolicyPackage->Des()) ;
1.669 + CleanupStack::PopAndDestroy(securityPolicyPackage) ;
1.670 +
1.671 + securityPolicyPackage = HBufC8::NewLC(aStream, 10000);
1.672 + iWriteAccessPolicy.Set(securityPolicyPackage->Des()) ;
1.673 + CleanupStack::PopAndDestroy(securityPolicyPackage) ;
1.674 +
1.675 + }
1.676 +
1.677 +inline TUint32 TSettingsAccessPolicy::LowKey() const
1.678 + {
1.679 + return iLowKey;
1.680 + }
1.681 +inline TUint32 TSettingsAccessPolicy::HighKey() const
1.682 + {
1.683 + return iHighKey;
1.684 + }
1.685 +inline TUint32 TSettingsAccessPolicy::KeyMask() const
1.686 + {
1.687 + return iKeyMask;
1.688 + }
1.689 +
1.690 +/**
1.691 +@internalTechnology
1.692 +It is responsility of client to check the key,
1.693 +this simply returns the TSecurityPolicy - it is set to EAlwaysFail if uninitialised
1.694 +*/
1.695 +inline const TSecurityPolicy* TSettingsAccessPolicy::GetReadAccessPolicy() const
1.696 + {
1.697 + return &iReadAccessPolicy;
1.698 + }
1.699 +
1.700 +
1.701 +/**
1.702 +@internalTechnology
1.703 +It is responsility of client to check the key,
1.704 +this simply returns the TSecurityPolicy - it is set to EAlwaysFail if uninitialised
1.705 +*/
1.706 +inline const TSecurityPolicy* TSettingsAccessPolicy::GetWriteAccessPolicy() const
1.707 + {
1.708 + return &iWriteAccessPolicy;
1.709 + }
1.710 +
1.711 +inline TSettingsDefaultMeta::TSettingsDefaultMeta(TUint32 aValue, TUint32 aLowKey,
1.712 + TUint32 aHighKey, TUint32 aKeyMask)
1.713 + {
1.714 + iLowKey = aLowKey;
1.715 + iHighKey = aHighKey;
1.716 + iKeyMask = aKeyMask;
1.717 + iDefaultMetaData = aValue;
1.718 + }
1.719 +
1.720 +inline TSettingsDefaultMeta::TSettingsDefaultMeta()
1.721 + {
1.722 + iLowKey = 0;
1.723 + iHighKey = 0;
1.724 + iKeyMask = 0;
1.725 + iDefaultMetaData = 0;
1.726 + }
1.727 +
1.728 +inline TUint32 TSettingsDefaultMeta::LowKey() const
1.729 + {
1.730 + return iLowKey;
1.731 + }
1.732 +
1.733 +inline TUint32 TSettingsDefaultMeta::HighKey() const
1.734 + {
1.735 + return iHighKey;
1.736 + }
1.737 +
1.738 +inline TUint32 TSettingsDefaultMeta::KeyMask() const
1.739 + {
1.740 + return iKeyMask;
1.741 + }
1.742 +
1.743 +inline TBool TSettingsDefaultMeta::IsInRange(TUint32 aKey) const
1.744 + {
1.745 + if((iLowKey<=aKey)&&(aKey<=iHighKey))
1.746 + return ETrue;
1.747 + else if((0 != iKeyMask)&&((iKeyMask&aKey)==iLowKey))
1.748 + return ETrue;
1.749 +
1.750 + return EFalse;
1.751 + }
1.752 +
1.753 +inline void TSettingsDefaultMeta::ExternalizeL(RWriteStream& aStream) const
1.754 + {
1.755 + aStream << iLowKey ;
1.756 + aStream << iHighKey ;
1.757 + aStream << iKeyMask ;
1.758 + aStream << iDefaultMetaData ;
1.759 + }
1.760 +
1.761 +inline void TSettingsDefaultMeta::InternalizeL(RReadStream& aStream)
1.762 + {
1.763 + aStream >> iLowKey ;
1.764 + aStream >> iHighKey ;
1.765 + aStream >> iKeyMask ;
1.766 + aStream >> iDefaultMetaData;
1.767 + }
1.768 +
1.769 +inline TSettingSingleMeta::TSettingSingleMeta(TUint32 aKey, TUint32 aMeta) : iKey(aKey), iMeta(aMeta)
1.770 + {
1.771 + }
1.772 +
1.773 +#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
1.774 +inline void TServerSetting::SetIndividualMeta(TBool aIndividualSettingMeta)
1.775 + {
1.776 + if (aIndividualSettingMeta)
1.777 + iMeta|= KMetaIndividual;
1.778 + else
1.779 + iMeta&=~KMetaIndividual;
1.780 + }
1.781 +
1.782 +//NEW: Copy the value only from a source, already validate the type
1.783 +inline TInt TServerSetting::CopyTypeValue(const TServerSetting& source)
1.784 + {
1.785 +
1.786 + if (source.IsStr())
1.787 + {
1.788 + const HBufC8* sourceBuf = source.GetStrValue();
1.789 + HBufC8* buf = sourceBuf ? sourceBuf->Alloc() : NULL;
1.790 + if (sourceBuf && !buf)
1.791 + {
1.792 + return KErrNoMemory;
1.793 + }
1.794 + ResetValue();
1.795 + SetType(EString);
1.796 + iValue.s = buf;
1.797 + }
1.798 + else if (source.IsReal())
1.799 + {
1.800 + if(!source.iValue.r)
1.801 + {
1.802 + return KErrCorrupt;
1.803 + }
1.804 +
1.805 + TReal* temp = new TReal(source.GetRealValue());
1.806 + if (temp == NULL)
1.807 + {
1.808 + return KErrNoMemory;
1.809 + }
1.810 + ResetValue();
1.811 + SetType(EReal);
1.812 + iValue.r = temp;
1.813 + }
1.814 + else
1.815 + {
1.816 + SetType(source.Type());
1.817 + if (source.IsInt())
1.818 + {
1.819 + iValue.i = source.GetIntValue();
1.820 + }
1.821 + }
1.822 +
1.823 + return KErrNone;
1.824 + }
1.825 +#endif