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