os/security/authorisation/userpromptservice/policies/source/policyreader.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/authorisation/userpromptservice/policies/source/policyreader.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,91 @@
     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 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @internalComponent
    1.25 + @released
    1.26 +*/
    1.27 +
    1.28 +#ifndef POLICYREADER_H
    1.29 +#define POLICYREADER_H
    1.30 +
    1.31 +#include <e32base.h>
    1.32 +#include <e32cmn.h>
    1.33 +#include <barsread2.h>
    1.34 +#include <barsc2.h>
    1.35 +
    1.36 +#include <ups/policy.h>
    1.37 +#include "serviceconfig.h"
    1.38 +namespace UserPromptService
    1.39 +{
    1.40 +
    1.41 +/**
    1.42 +Encapsulates the data in the policy file header. This is also used by the 
    1.43 +service config code.
    1.44 +*/
    1.45 +NONSHARABLE_CLASS(TPolicyHeader)
    1.46 +	{
    1.47 + public:
    1.48 +	TPolicyHeader();
    1.49 +	
    1.50 +	TInt iFormatVersion;				///< Version no. of resource format.
    1.51 +	TUint16 iMajorVersion;				///< The major version no. of the UPS policy file.
    1.52 +	TUint16 iMinorVersion;				///< The minor version no. of the UPS policy file.
    1.53 +	TAuthorisationPolicy iAuthPolicy;	///< Authorisation policy for this service.
    1.54 +	TUid iDefaultPolicyEvaluator;		///< The ECOM implementation UID of the default dialog creator.
    1.55 +	TUid iDefaultDialogCreator;			///< The ECOM implementation UID of the default dialog creator.		
    1.56 +	};
    1.57 +	   
    1.58 +/**
    1.59 + Class for parsing a single User Prompt Service policy resource files defined
    1.60 + by ups\policies.rh.\n
    1.61 + The policy file is opened when the reader object is constructed and 
    1.62 + the set of policies may be enumerated by repeatedly calling the NextPolicy
    1.63 + function. 
    1.64 + NextPolicy returns NULL when the end of the file has been reached. After
    1.65 + this the reader class should be destroyed.
    1.66 + */
    1.67 +NONSHARABLE_CLASS(CPolicyReader) : public CBase
    1.68 +	{
    1.69 +public:	
    1.70 +	IMPORT_C static CPolicyReader* NewL(RFs& aRFs, const TDesC& aPolicyFileName);
    1.71 +	IMPORT_C static CPolicyReader* NewLC(RFs& aRFs, const TDesC& aPolicyFileName);
    1.72 +	IMPORT_C CPolicy* NextPolicyL();
    1.73 +	IMPORT_C CPolicy* DefaultPolicyL();
    1.74 +	IMPORT_C const TPolicyHeader& Header() const;
    1.75 +	
    1.76 +	~CPolicyReader();
    1.77 +private:
    1.78 +	CPolicyReader();
    1.79 +	void ConstructL(RFs& aRfs, const TDesC& aPolicyFileName);
    1.80 +	CPolicy* ReadPolicyL();
    1.81 +	void ReadPolicyHeaderL();
    1.82 +	
    1.83 +	CResourceFile* iResourceFile;	///< Handle to the resource file	
    1.84 +	RResourceReader iReader;		///< Parses the resource file	
    1.85 +	TPolicyHeader iHeader;			///< Header information
    1.86 +	TInt iPolicyCount;				///< The number of policies in the file		
    1.87 +	TInt iPolicyNum;				///< The current policy being parsed
    1.88 +	};
    1.89 +
    1.90 +/// Policy files must only contain one top level resource.
    1.91 +static const int KPolicyResourceId = 1;
    1.92 +}
    1.93 +
    1.94 +#endif /* POLICYREADER_H */