os/security/authorisation/userpromptservice/server/source/upsclient/upsclientserver.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/authorisation/userpromptservice/server/source/upsclient/upsclientserver.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,595 @@
     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 +* Implements an interface to keep and access decision record fields.
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @internalTechnology
    1.26 + @released
    1.27 +*/
    1.28 +#include <s32strm.h>
    1.29 +#include <ups/upstypes.h>
    1.30 +#include <ups/upsconst.h>
    1.31 +#include "upslog.h"
    1.32 +#include <ups/upserr.h>
    1.33 +#include "upscommon.h"
    1.34 +
    1.35 +namespace UserPromptService {
    1.36 +
    1.37 +CDecisionRecord::CDecisionRecord()
    1.38 +/**
    1.39 +	Constructor for the decision record. 
    1.40 + */								 
    1.41 +	{
    1.42 +	
    1.43 +	}
    1.44 +
    1.45 +CDecisionRecord::CDecisionRecord(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
    1.46 +								 const TUint8 aResult, const TUint16& aMajorPolicyVersion, const TUint32 aEvaluatorInfo, const TUint32& aRecordId)
    1.47 +/**
    1.48 +	Constructor for the decision record. Assigns the ID values. 
    1.49 + */								 
    1.50 +	:iClientSid(aClientSid),iEvaluatorId(aEvaluatorId),
    1.51 +	 iServiceId(aServiceId),iServerSid(aServerSid),
    1.52 +	 iResult(aResult),iMajorPolicyVersion(aMajorPolicyVersion),
    1.53 +	 iRecordId(aRecordId),iEvaluatorInfo(aEvaluatorInfo)
    1.54 +	{
    1.55 +	
    1.56 +	}
    1.57 +
    1.58 +
    1.59 +CDecisionRecord::~CDecisionRecord()
    1.60 +/**
    1.61 +	Destructor for the decision record object
    1.62 + */
    1.63 +	{
    1.64 +	iFingerprint.Close();		
    1.65 +	iClientEntity.Close();
    1.66 +	iDescription.Close();
    1.67 +	}
    1.68 +	
    1.69 +EXPORT_C CDecisionRecord* CDecisionRecord::NewL(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
    1.70 +								 	            const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TDesC& aDescription, const TUint8 aResult, 
    1.71 +								 	            const TUint16& aMajorPolicyVersion, const TUint32 aEvaluatorInfo, const TUint32& aRecordId)
    1.72 +/**
    1.73 +	Creates a decision record object. The function leaves, if creation of the record object fails.
    1.74 +	 
    1.75 +	@param aClientSid	  Secure Id of client application
    1.76 +	@param aEvaluatorId	  UID for the policy evaluator DLL
    1.77 +	@param aServiceId 	  UID for service e.g. sms, mms, telephony, gprs
    1.78 +	@param aServerSid  	  Secure Id for the system server that the decision applies to
    1.79 +	@param aFingerprint   Hash of the destination and/or opaque data. Maximum length is 32 bytes.
    1.80 +	@param aClientEntity  The name of the entity within the client that requested the service. Maximum length is 32 bytes. 
    1.81 +	@param aDescription	  A copy of description and/or opaque. 
    1.82 +	@param aResult		  Whether the request should be approved (=1) or denied (=0)
    1.83 +	@param aMajorPolicyVersion The major version of the policy file.
    1.84 +	@param aEvaluatorInfo Policy evaluator specific data
    1.85 +	@param aRecordId	  An auto-incrementing record number.
    1.86 +	
    1.87 +	@return    			  A pointer to the newly allocated decision record object, if creation is successful.
    1.88 + */								 	   
    1.89 +	{
    1.90 +	CDecisionRecord* self = CDecisionRecord::NewLC(aClientSid,aEvaluatorId,aServiceId,aServerSid,aFingerprint,aClientEntity,
    1.91 +												   aDescription,aResult,aMajorPolicyVersion,aEvaluatorInfo,aRecordId);
    1.92 +	CleanupStack::Pop(self);
    1.93 +	return self;
    1.94 +	}
    1.95 +
    1.96 +
    1.97 +EXPORT_C CDecisionRecord* CDecisionRecord::NewLC(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
    1.98 +								 	    		 const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TDesC& aDescription, const TUint8 aResult, 
    1.99 +								 	    		 const TUint16& aMajorPolicyVersion, const TUint32 aEvaluatorInfo, const TUint32& aRecordId)
   1.100 +/**
   1.101 +	Creates a decision record object. The function leaves, if creation of the record object fails.
   1.102 +	
   1.103 +	@return    			  A pointer to the newly allocated decision record object, if creation is successful.
   1.104 +				  		  The pointer is also put onto the cleanup stack.
   1.105 +	@see CDecisionRecord::NewL()
   1.106 + */									 	   
   1.107 +	{
   1.108 +	CDecisionRecord* self = new (ELeave) CDecisionRecord(aClientSid,aEvaluatorId,aServiceId,aServerSid,aResult,
   1.109 +														 aMajorPolicyVersion,aEvaluatorInfo,aRecordId);
   1.110 +	CleanupStack::PushL(self);
   1.111 +	self->ConstructL(aFingerprint,aClientEntity,aDescription);
   1.112 +	return self;
   1.113 +	}	
   1.114 +
   1.115 +EXPORT_C CDecisionRecord* CDecisionRecord::NewLC()
   1.116 +/**
   1.117 +	Creates a decision record object. The function leaves, if creation of the record object fails.
   1.118 +	
   1.119 +	@return    			  A pointer to the newly allocated decision record object, if creation is successful.
   1.120 +				  		  The pointer is also put onto the cleanup stack.
   1.121 + */									 	   
   1.122 +	{
   1.123 +	CDecisionRecord* self = new (ELeave) CDecisionRecord();
   1.124 +	CleanupStack::PushL(self);
   1.125 +	return self;
   1.126 +	}	
   1.127 +	
   1.128 +void CDecisionRecord::ConstructL(const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TDesC& aDescription)
   1.129 +/**
   1.130 +	Second phase constructor for the decision record. Sets members allocated on the heap.
   1.131 +	The function leaves, if any buffer allocation fails.
   1.132 +	@see CDecisionRecord::NewL()
   1.133 + */
   1.134 +	{
   1.135 +		
   1.136 +	iFingerprint.CreateL(aFingerprint);
   1.137 +	
   1.138 +	iClientEntity.CreateL(aClientEntity);
   1.139 +	
   1.140 +	iDescription.CreateL(aDescription);
   1.141 +
   1.142 +	ValidateL();
   1.143 +	}
   1.144 +
   1.145 +void CDecisionRecord::ValidateL()
   1.146 +/**
   1.147 +	Check both the fingerprint and client entity are not too long.
   1.148 +	An absent fingerprint or client entity is represent by an empty string.
   1.149 +*/
   1.150 +	{
   1.151 +	if(iFingerprint.Length()  > (TInt)KUpsMaxFingerprintLength)
   1.152 +	    {
   1.153 +	    DEBUG_PRINTF2(_L8("The fingerprint length (%d) has not been satisfied during decision construction!"),iFingerprint.Length());
   1.154 +	    User::Leave(KErrUpsBadFingerprintLength);
   1.155 +	    }
   1.156 +	    	
   1.157 +	if(iClientEntity.Length() > (TInt)KUpsMaxClientEntityLength)
   1.158 +		{
   1.159 +		DEBUG_PRINTF2(_L8("The client entity length (%d) has not been satisfied during decision construction!"),iClientEntity.Length());
   1.160 +		User::Leave(KErrUpsBadClientEntityLength);
   1.161 +		}
   1.162 +	}
   1.163 +
   1.164 +EXPORT_C void CDecisionRecord::ExternalizeL(RWriteStream& aStream) const
   1.165 +/**
   1.166 +	Externalise this CDecisionRecord object to the specified stream.
   1.167 +*/
   1.168 +	{
   1.169 +	aStream.WriteUint32L(iClientSid.iId);
   1.170 +	aStream.WriteInt32L(iEvaluatorId.iUid);
   1.171 +	aStream.WriteInt32L(iServiceId.iUid);
   1.172 +	aStream.WriteUint32L(iServerSid.iId);
   1.173 +	aStream << iFingerprint;
   1.174 +	aStream << iClientEntity;
   1.175 +	aStream << iDescription;
   1.176 +	aStream << iResult;
   1.177 +	aStream << iMajorPolicyVersion;
   1.178 +	aStream << iRecordId;
   1.179 +	aStream << iEvaluatorInfo;
   1.180 +	}
   1.181 +
   1.182 +EXPORT_C void CDecisionRecord::InternalizeL(RReadStream& aStream)
   1.183 +/**
   1.184 +	Internalise this CDecisionRecord object from the specified stream.
   1.185 +*/
   1.186 +	{
   1.187 +	iClientSid.iId= aStream.ReadUint32L();
   1.188 +	iEvaluatorId.iUid = aStream.ReadInt32L();
   1.189 +	iServiceId.iUid = aStream.ReadInt32L();
   1.190 +	iServerSid.iId = aStream.ReadUint32L();
   1.191 +
   1.192 +	iFingerprint.Close();
   1.193 +	iFingerprint.CreateL(aStream, KMaskDesLength8);
   1.194 +
   1.195 +	iClientEntity.Close();
   1.196 +	iClientEntity.CreateL(aStream, KMaskDesLength8);
   1.197 +
   1.198 +	iDescription.Close();
   1.199 +	iDescription.CreateL(aStream, KMaskDesLength16);
   1.200 +
   1.201 +	aStream >> iResult;
   1.202 +	aStream >> iMajorPolicyVersion;
   1.203 +	aStream >> iRecordId;
   1.204 +	aStream >> iEvaluatorInfo;
   1.205 +
   1.206 +	ValidateL();
   1.207 +	}
   1.208 +
   1.209 +CDecisionFilter::CDecisionFilter()
   1.210 +/**
   1.211 +	Constructor for an empty decision filter.
   1.212 + */
   1.213 +	{
   1.214 +	
   1.215 +	}
   1.216 +
   1.217 +	
   1.218 +CDecisionFilter::CDecisionFilter(const TSecureId& aClientSid, const TUid& aEvaluatorId, 
   1.219 +	const TUid& aServiceId, const TSecureId& aServerSid, const TUint16& aVersion)
   1.220 +	:iClientSid(aClientSid),iEvaluatorId(aEvaluatorId),iServiceId(aServiceId),
   1.221 +	iServerSid(aServerSid),iMajorPolicyVersion(aVersion)
   1.222 +/**
   1.223 +	Constructor for the decision filter. Assigns the ID values.
   1.224 + */
   1.225 +	{
   1.226 +	iSetFlag[KPosClientSid]	  = KSetClientSid	| UserPromptService::EEqual;
   1.227 +	iSetFlag[KPosEvaluatorId] = KSetEvaluatorId | UserPromptService::EEqual;
   1.228 +	iSetFlag[KPosServiceId]	  = KSetServiceId	| UserPromptService::EEqual;
   1.229 +	iSetFlag[KPosServerSid]	  = KSetServerSid	| UserPromptService::EEqual;
   1.230 +	iSetFlag[KPosMajorPolicyVersion] = KSetMajorPolicyVersion | UserPromptService::EEqual;
   1.231 +	}
   1.232 +		
   1.233 +				
   1.234 +CDecisionFilter::~CDecisionFilter()
   1.235 +/**
   1.236 +	Destructor for the decision filter
   1.237 + */
   1.238 +	{
   1.239 +	delete iFingerprint;
   1.240 +	delete iClientEntity;	
   1.241 +	}
   1.242 +	
   1.243 +	
   1.244 +EXPORT_C CDecisionFilter* CDecisionFilter::NewL()
   1.245 +/**
   1.246 +	Creates an empty filter object. The function is used to define any number of filter keys.
   1.247 +	It leaves, if the creation of the filter object fails.
   1.248 +		
   1.249 +	@return	   A pointer to the newly allocated filter object, if creation is successful. 
   1.250 + */
   1.251 +	{
   1.252 +	CDecisionFilter* self = CDecisionFilter::NewLC();
   1.253 +	CleanupStack::Pop(self);
   1.254 +	return self;
   1.255 +	}
   1.256 +	
   1.257 +	
   1.258 +EXPORT_C CDecisionFilter* CDecisionFilter::NewLC()
   1.259 +/**
   1.260 +	Creates an empty filter object. The function is used to define any number of filter keys.
   1.261 +	It leaves, if the creation of the filter object fails.
   1.262 +
   1.263 +	@return	   A pointer to the newly allocated filter object, if creation is successful. 
   1.264 +			   The pointer is also put onto the cleanup stack.
   1.265 + */
   1.266 +	{
   1.267 +	CDecisionFilter* self = new (ELeave) CDecisionFilter();
   1.268 +	CleanupStack::PushL(self);
   1.269 +	return self;
   1.270 +	}
   1.271 +	
   1.272 +	
   1.273 +EXPORT_C CDecisionFilter* CDecisionFilter::NewL(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
   1.274 +												const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TUint16& aVersion)
   1.275 +/**
   1.276 +	Creates a filter object and assigns all filter keys. The function leaves, if creation of the filter object fails.
   1.277 +	 
   1.278 +	@param aClientSid	 Secure Id of client application
   1.279 +	@param aEvaluatorId	 UID for the policy evaluator DLL
   1.280 +	@param aServiceId	 UID for service e.g. sms, mms, telephony, gprs
   1.281 +	@param aServerSid	 Secure Id for the system server that the decision applies to
   1.282 +	@param aFingerprint	 Hash of the destination and/or opaque data.
   1.283 +	@param aClientEntity The name of the entity within the client that requested the service. 
   1.284 +	@param aVersion      Major version of policy file.
   1.285 +	@return				 A pointer to the newly allocated filter object, if creation is successful.
   1.286 + */									
   1.287 +	{
   1.288 +	CDecisionFilter* self = CDecisionFilter::NewLC(aClientSid,aEvaluatorId,aServiceId,aServerSid,aFingerprint,aClientEntity,aVersion);
   1.289 +	CleanupStack::Pop(self);
   1.290 +	return self;
   1.291 +	}
   1.292 +	
   1.293 +	
   1.294 +EXPORT_C CDecisionFilter* CDecisionFilter::NewLC(const TSecureId& aClientSid,const TUid& aEvaluatorId,const TUid& aServiceId,const TSecureId& aServerSid,
   1.295 +												 const TDesC8& aFingerprint,const TDesC8& aClientEntity,const TUint16& aVersion)
   1.296 +/**
   1.297 +	Creates a filter object and assigns all filter keys. The function leaves, if creation of the filter object fails.
   1.298 +	 
   1.299 +	@param aClientSid	 Secure Id of client application
   1.300 +	@param aEvaluatorId	 UID for the policy evaluator DLL
   1.301 +	@param aServiceId	 UID for service e.g. sms, mms, telephony, gprs
   1.302 +	@param aServerSid	 Secure Id for the system server that the decision applies to
   1.303 +	@param aFingerprint	 Hash of the destination and/or opaque data.
   1.304 +	@param aClientEntity The name of the entity within the client that requested the service.
   1.305 +	@param aVersion      Major version of policy file.
   1.306 +	@return				 A pointer to the newly allocated filter object, if creation is successful.
   1.307 +						 The pointer is also put onto the cleanup stack.
   1.308 + */												 
   1.309 +	{
   1.310 +	CDecisionFilter* self = new (ELeave) CDecisionFilter(aClientSid,aEvaluatorId,aServiceId,aServerSid,aVersion);
   1.311 +	CleanupStack::PushL(self);
   1.312 +	self->ConstructL(aFingerprint,aClientEntity);
   1.313 +	return self;
   1.314 +	}	
   1.315 +
   1.316 +
   1.317 +void CDecisionFilter::ConstructL(const TDesC8& aFingerprint, const TDesC8& aClientEntity)
   1.318 +/**
   1.319 +	Second phase constructor for the decision filter. Sets members allocated on the heap.
   1.320 +	The function leaves, if any buffer allocation fails.
   1.321 + */
   1.322 +	{
   1.323 +		
   1.324 +	iFingerprint = aFingerprint.AllocL();
   1.325 +	iSetFlag[KPosFingerprint] |= KSetFingerprint;
   1.326 +	
   1.327 +	iClientEntity = aClientEntity.AllocL();
   1.328 +	iSetFlag[KPosClientEntity] |= KSetClientEntity;
   1.329 +
   1.330 +	ValidateL();
   1.331 +	}
   1.332 +	
   1.333 +void CDecisionFilter::ValidateL()
   1.334 +/**
   1.335 +	Check fingerprint and client entity lengths are valid.
   1.336 +*/
   1.337 +	{
   1.338 +	if((iSetFlag[KPosFingerprint] & KSetFingerprint) &&
   1.339 +		((iFingerprint == 0) || (iFingerprint->Length()	> KUpsMaxFingerprintLength)))
   1.340 +		{
   1.341 +		DEBUG_PRINTF2(_L8("The fingerprint length (%d) has not been satisfied during filter construction!"),(iFingerprint) ? (iFingerprint->Length()) : (0));
   1.342 +		User::Leave(KErrUpsBadFingerprintLength);
   1.343 +		}
   1.344 +		
   1.345 +	if((iSetFlag[KPosClientEntity] & KSetClientEntity) &&
   1.346 +		((iClientEntity == 0) || (iClientEntity->Length() > KUpsMaxClientEntityLength)))
   1.347 +		{
   1.348 +		DEBUG_PRINTF2(_L8("The client entity length (%d) has not been satisfied during filter construction!"),(iClientEntity) ? (iClientEntity->Length()) : (0));
   1.349 +		User::Leave(KErrUpsBadClientEntityLength);
   1.350 +		}
   1.351 +	}
   1.352 +	
   1.353 +EXPORT_C void CDecisionFilter::SetClientSid(const TSecureId& aSid, TComparisonOp aOp)
   1.354 +/**
   1.355 +	Sets the Secure ID of the client application.
   1.356 +
   1.357 +	@param aUid		SID for the client application
   1.358 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.359 + */
   1.360 +	{
   1.361 +	iClientSid = aSid;
   1.362 +	iSetFlag[KPosClientSid] |= KSetClientSid;
   1.363 +	iSetFlag[KPosClientSid] |= aOp;
   1.364 +	}
   1.365 +	
   1.366 +	
   1.367 +EXPORT_C void CDecisionFilter::SetEvaluatorId(const TUid& aUid, TComparisonOp aOp)
   1.368 +/**
   1.369 +	Sets the UID of the policy evaluator DLL.
   1.370 +
   1.371 +	@param aUid		UID for the policy evaluator DLL
   1.372 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.373 + */
   1.374 +	{
   1.375 +	iEvaluatorId = aUid;
   1.376 +	iSetFlag[KPosEvaluatorId] |= KSetEvaluatorId;
   1.377 +	iSetFlag[KPosEvaluatorId] |= aOp;
   1.378 +	}
   1.379 +
   1.380 +
   1.381 +EXPORT_C void CDecisionFilter::SetServiceId(const TUid& aUid, TComparisonOp aOp)
   1.382 +/**
   1.383 +	Sets the Secure ID of the service.
   1.384 +
   1.385 +	@param aUid		UID for the service
   1.386 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.387 + */
   1.388 +	{
   1.389 +	iServiceId = aUid;
   1.390 +	iSetFlag[KPosServiceId] |= KSetServiceId;
   1.391 +	iSetFlag[KPosServiceId] |= aOp;
   1.392 +	}
   1.393 +	
   1.394 +		
   1.395 +EXPORT_C void CDecisionFilter::SetServerSid(const TSecureId& aSid, TComparisonOp aOp)
   1.396 +/**
   1.397 +	Sets the Secure ID of the system server.
   1.398 +	
   1.399 +	@param aUid		UID for the system server
   1.400 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.401 + */
   1.402 +	{
   1.403 +	iServerSid = aSid;
   1.404 +	iSetFlag[KPosServerSid] |= KSetServerSid;
   1.405 +	iSetFlag[KPosServerSid] |= aOp;
   1.406 +	}
   1.407 +	
   1.408 +	
   1.409 +EXPORT_C void CDecisionFilter::SetFingerprintL(const TDesC8& aFingerprint, TComparisonOp aOp)
   1.410 +/**
   1.411 +	Sets the fingerprint. A buffer is allocated on the heap and aFingerprint copied into it.
   1.412 +	The function leaves, if the buffer allocation fails.
   1.413 +	 
   1.414 +	@param aFingerprint		Hash of the destination and/or opaque data. (Maximum length is 32 bytes)
   1.415 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.416 + */
   1.417 +	{
   1.418 +	//Fingerprint's length can not be longer than KUpsMaxFingerprintLength
   1.419 +	if(aFingerprint.Length() > KUpsMaxFingerprintLength)
   1.420 +		{
   1.421 +		User::Leave(KErrUpsBadFingerprintLength);
   1.422 +		}
   1.423 +
   1.424 +	delete iFingerprint;
   1.425 +	iFingerprint = 0;
   1.426 +			
   1.427 +	iFingerprint = aFingerprint.AllocL();
   1.428 +	iSetFlag[KPosFingerprint] |= KSetFingerprint;
   1.429 +	iSetFlag[KPosFingerprint] |= aOp;
   1.430 +	}
   1.431 +	
   1.432 +	
   1.433 +EXPORT_C void CDecisionFilter::SetClientEntityL(const TDesC8& aClientEntity, TComparisonOp aOp)
   1.434 +/**
   1.435 +	Sets the client entity. A buffer is allocated on the heap and aClientEntity copied into it.
   1.436 +	The function leaves, if the buffer allocation fails.
   1.437 +	 
   1.438 +	@param aClientEntity	The name of the entity within the client. (Maximum length is 32 bytes) 
   1.439 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.440 + */
   1.441 +	{
   1.442 +	//ClientEntity's length can not be longer than KUpsMaxClientEntityLength
   1.443 +	if(aClientEntity.Length() > KUpsMaxClientEntityLength)
   1.444 +		{
   1.445 +		User::Leave(KErrUpsBadClientEntityLength);
   1.446 +		}
   1.447 +		
   1.448 +	delete iClientEntity;
   1.449 +	iClientEntity = 0;
   1.450 +		
   1.451 +	iClientEntity = aClientEntity.AllocL();
   1.452 +	iSetFlag[KPosClientEntity] |= KSetClientEntity;
   1.453 +	iSetFlag[KPosClientEntity] |= aOp;
   1.454 +	}
   1.455 +
   1.456 +
   1.457 +EXPORT_C void CDecisionFilter::SetMajorPolicyVersion(const TUint16& aVersion, TComparisonOp aOp)
   1.458 +/**
   1.459 +	Sets the major version of the policy file.
   1.460 +	
   1.461 +	@param aVersion		Major policy version.
   1.462 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.463 + */
   1.464 +	{
   1.465 +	iMajorPolicyVersion = aVersion;
   1.466 +	iSetFlag[KPosMajorPolicyVersion] |= KSetMajorPolicyVersion;
   1.467 +	iSetFlag[KPosMajorPolicyVersion] |= aOp;
   1.468 +	}
   1.469 +
   1.470 +
   1.471 +EXPORT_C void CDecisionFilter::SetRecordId(const TUint32& aId, TComparisonOp aOp)
   1.472 +/**
   1.473 +	Sets the unique Id number of the decision record which is searched.
   1.474 +	
   1.475 +	@param aId	A unique record Id.
   1.476 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.477 + */
   1.478 +	{
   1.479 +	iRecordId = aId;
   1.480 +	iSetFlag[KPosRecordId] |= KSetRecordId;
   1.481 +	iSetFlag[KPosRecordId] |= aOp;
   1.482 +	}
   1.483 +
   1.484 +
   1.485 +EXPORT_C void CDecisionFilter::SetDescriptionL(const TDesC& aDescription, const TComparisonOp aOp)
   1.486 +/**
   1.487 +	Sets the description field. A buffer is allocated on the heap and aDescription copied into it.
   1.488 +	The function leaves, if the buffer allocation fails.
   1.489 +	 
   1.490 +	@param aDescription	A copy of description and/or opaque. (Maximum length is 32 bytes) 
   1.491 +	@param aOp			Comparision operator which is used to create SQL statement.
   1.492 + */
   1.493 +	{	
   1.494 +	delete iDescription;
   1.495 +	iDescription = 0;
   1.496 +		
   1.497 +	iDescription = aDescription.AllocL();
   1.498 +	iSetFlag[KPosDescription] |= KSetDescription;
   1.499 +	iSetFlag[KPosDescription] |= aOp;
   1.500 +	}
   1.501 +	
   1.502 +	
   1.503 +EXPORT_C void CDecisionFilter::SetResult(const TUint8& aResult, const TComparisonOp aOp)
   1.504 +/**
   1.505 +	Sets the result field of the decision record which is searched.
   1.506 +	
   1.507 +	@param aResult	Whether the request should be approved.
   1.508 +	@param aOp		Comparision operator which is used to create SQL statement.
   1.509 + */
   1.510 +	{
   1.511 +	iResult = aResult;
   1.512 +	iSetFlag[KPosResult] |= KSetResult;
   1.513 +	iSetFlag[KPosResult] |= aOp;
   1.514 +	}
   1.515 +	
   1.516 +	
   1.517 +EXPORT_C void CDecisionFilter::SetEvaluatorInfo(const TUint32& aEvaluatorInfo, const TComparisonOp aOp)
   1.518 +/**
   1.519 +	Sets the evaluator info field of the decision record which is searched.
   1.520 +	
   1.521 +	@param aEvaluatorInfo	Policy evaluator specific data
   1.522 +	@param aOp				Comparision operator which is used to create SQL statement.
   1.523 + */
   1.524 +	{
   1.525 +	iEvaluatorInfo = aEvaluatorInfo;
   1.526 +	iSetFlag[KPosEvaluatorInfo] |= KSetEvaluatorInfo;
   1.527 +	iSetFlag[KPosEvaluatorInfo] |= aOp;
   1.528 +	}
   1.529 +	
   1.530 +	
   1.531 +EXPORT_C void CDecisionFilter::ExternalizeL(RWriteStream& aStream) const
   1.532 +/**
   1.533 +	Externalise this CDecisionFilter object to the specified stream.
   1.534 +*/
   1.535 +	{
   1.536 +	aStream << iClientSid.iId;		// TSecureId 
   1.537 +	aStream << iEvaluatorId.iUid;	// TUid 
   1.538 +	aStream << iServiceId.iUid;		// TUid 
   1.539 +	aStream << iServerSid.iId;		// TSecureId 
   1.540 +
   1.541 +	aStream << ((iFingerprint) ? (*iFingerprint) : (KNullDesC8())); 	// HBufC8* 
   1.542 +	aStream << ((iClientEntity) ? (*iClientEntity) : (KNullDesC8()));	// HBufC8* 
   1.543 +
   1.544 +	for(int i = 0; i < KFilterKeysNumber; ++i)
   1.545 +		{
   1.546 +		aStream.WriteUint16L(iSetFlag[i]);// TUint16 
   1.547 +		}
   1.548 +
   1.549 +	aStream << iMajorPolicyVersion;// TUint16 
   1.550 +	aStream << iRecordId;// TUint32 
   1.551 +	}
   1.552 +EXPORT_C void CDecisionFilter::InternalizeL(RReadStream& aStream)
   1.553 +/**
   1.554 +	Internalise this CDecisionFilter object from the specified stream.
   1.555 +*/
   1.556 +	{
   1.557 +	iClientSid.iId= aStream.ReadUint32L();		// TSecureId 
   1.558 +	iEvaluatorId.iUid= aStream.ReadInt32L();	// TUid 
   1.559 +	iServiceId.iUid= aStream.ReadInt32L();		// TUid 
   1.560 +	iServerSid.iId= aStream.ReadUint32L();		// TSecureId 
   1.561 +
   1.562 +	// iFingerprint is always present in stream, so internalise it and then delete it if it is not setup.
   1.563 +	delete iFingerprint;
   1.564 +	iFingerprint = 0;
   1.565 +	iFingerprint = HBufC8::NewL(aStream, KMaskDesLength8);
   1.566 +
   1.567 +	// iClientEntity is always present in stream, so internalise it and then delete it if it is not setup.
   1.568 +	delete iClientEntity;
   1.569 +	iClientEntity = 0;
   1.570 +	iClientEntity = HBufC8::NewL(aStream, KMaskDesLength8);
   1.571 +	
   1.572 +	for(int i = 0; i < KFilterKeysNumber; ++i)
   1.573 +		{
   1.574 +		iSetFlag[i] = aStream.ReadUint16L();// TUint16 
   1.575 +		}
   1.576 +
   1.577 +	// Delete iFingerprint if not setup
   1.578 +	if((iSetFlag[KPosFingerprint] & KSetFingerprint) == 0)
   1.579 +		{
   1.580 +		delete iFingerprint;
   1.581 +		iFingerprint = 0;
   1.582 +		}
   1.583 +
   1.584 +	// Delete iClientEntity if not setup
   1.585 +	if((iSetFlag[KPosClientEntity] & KSetClientEntity) == 0)
   1.586 +		{
   1.587 +		delete iClientEntity;
   1.588 +		iClientEntity = 0;
   1.589 +		}
   1.590 +
   1.591 +	iMajorPolicyVersion = aStream.ReadUint16L();// TUint16 
   1.592 +	iRecordId = aStream.ReadUint32L();// TUint32 
   1.593 +
   1.594 +	ValidateL();
   1.595 +	}
   1.596 +
   1.597 +} // End of  UserPromptService namespace
   1.598 +// End of file