os/security/authorisation/userpromptservice/policies/source/policyreader.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @internalComponent
sl@0
    22
 @released
sl@0
    23
*/
sl@0
    24
sl@0
    25
#ifndef POLICYREADER_H
sl@0
    26
#define POLICYREADER_H
sl@0
    27
sl@0
    28
#include <e32base.h>
sl@0
    29
#include <e32cmn.h>
sl@0
    30
#include <barsread2.h>
sl@0
    31
#include <barsc2.h>
sl@0
    32
sl@0
    33
#include <ups/policy.h>
sl@0
    34
#include "serviceconfig.h"
sl@0
    35
namespace UserPromptService
sl@0
    36
{
sl@0
    37
sl@0
    38
/**
sl@0
    39
Encapsulates the data in the policy file header. This is also used by the 
sl@0
    40
service config code.
sl@0
    41
*/
sl@0
    42
NONSHARABLE_CLASS(TPolicyHeader)
sl@0
    43
	{
sl@0
    44
 public:
sl@0
    45
	TPolicyHeader();
sl@0
    46
	
sl@0
    47
	TInt iFormatVersion;				///< Version no. of resource format.
sl@0
    48
	TUint16 iMajorVersion;				///< The major version no. of the UPS policy file.
sl@0
    49
	TUint16 iMinorVersion;				///< The minor version no. of the UPS policy file.
sl@0
    50
	TAuthorisationPolicy iAuthPolicy;	///< Authorisation policy for this service.
sl@0
    51
	TUid iDefaultPolicyEvaluator;		///< The ECOM implementation UID of the default dialog creator.
sl@0
    52
	TUid iDefaultDialogCreator;			///< The ECOM implementation UID of the default dialog creator.		
sl@0
    53
	};
sl@0
    54
	   
sl@0
    55
/**
sl@0
    56
 Class for parsing a single User Prompt Service policy resource files defined
sl@0
    57
 by ups\policies.rh.\n
sl@0
    58
 The policy file is opened when the reader object is constructed and 
sl@0
    59
 the set of policies may be enumerated by repeatedly calling the NextPolicy
sl@0
    60
 function. 
sl@0
    61
 NextPolicy returns NULL when the end of the file has been reached. After
sl@0
    62
 this the reader class should be destroyed.
sl@0
    63
 */
sl@0
    64
NONSHARABLE_CLASS(CPolicyReader) : public CBase
sl@0
    65
	{
sl@0
    66
public:	
sl@0
    67
	IMPORT_C static CPolicyReader* NewL(RFs& aRFs, const TDesC& aPolicyFileName);
sl@0
    68
	IMPORT_C static CPolicyReader* NewLC(RFs& aRFs, const TDesC& aPolicyFileName);
sl@0
    69
	IMPORT_C CPolicy* NextPolicyL();
sl@0
    70
	IMPORT_C CPolicy* DefaultPolicyL();
sl@0
    71
	IMPORT_C const TPolicyHeader& Header() const;
sl@0
    72
	
sl@0
    73
	~CPolicyReader();
sl@0
    74
private:
sl@0
    75
	CPolicyReader();
sl@0
    76
	void ConstructL(RFs& aRfs, const TDesC& aPolicyFileName);
sl@0
    77
	CPolicy* ReadPolicyL();
sl@0
    78
	void ReadPolicyHeaderL();
sl@0
    79
	
sl@0
    80
	CResourceFile* iResourceFile;	///< Handle to the resource file	
sl@0
    81
	RResourceReader iReader;		///< Parses the resource file	
sl@0
    82
	TPolicyHeader iHeader;			///< Header information
sl@0
    83
	TInt iPolicyCount;				///< The number of policies in the file		
sl@0
    84
	TInt iPolicyNum;				///< The current policy being parsed
sl@0
    85
	};
sl@0
    86
sl@0
    87
/// Policy files must only contain one top level resource.
sl@0
    88
static const int KPolicyResourceId = 1;
sl@0
    89
}
sl@0
    90
sl@0
    91
#endif /* POLICYREADER_H */