sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: #ifndef POLICYREADER_H sl@0: #define POLICYREADER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include "serviceconfig.h" sl@0: namespace UserPromptService sl@0: { sl@0: sl@0: /** sl@0: Encapsulates the data in the policy file header. This is also used by the sl@0: service config code. sl@0: */ sl@0: NONSHARABLE_CLASS(TPolicyHeader) sl@0: { sl@0: public: sl@0: TPolicyHeader(); sl@0: sl@0: TInt iFormatVersion; ///< Version no. of resource format. sl@0: TUint16 iMajorVersion; ///< The major version no. of the UPS policy file. sl@0: TUint16 iMinorVersion; ///< The minor version no. of the UPS policy file. sl@0: TAuthorisationPolicy iAuthPolicy; ///< Authorisation policy for this service. sl@0: TUid iDefaultPolicyEvaluator; ///< The ECOM implementation UID of the default dialog creator. sl@0: TUid iDefaultDialogCreator; ///< The ECOM implementation UID of the default dialog creator. sl@0: }; sl@0: sl@0: /** sl@0: Class for parsing a single User Prompt Service policy resource files defined sl@0: by ups\policies.rh.\n sl@0: The policy file is opened when the reader object is constructed and sl@0: the set of policies may be enumerated by repeatedly calling the NextPolicy sl@0: function. sl@0: NextPolicy returns NULL when the end of the file has been reached. After sl@0: this the reader class should be destroyed. sl@0: */ sl@0: NONSHARABLE_CLASS(CPolicyReader) : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CPolicyReader* NewL(RFs& aRFs, const TDesC& aPolicyFileName); sl@0: IMPORT_C static CPolicyReader* NewLC(RFs& aRFs, const TDesC& aPolicyFileName); sl@0: IMPORT_C CPolicy* NextPolicyL(); sl@0: IMPORT_C CPolicy* DefaultPolicyL(); sl@0: IMPORT_C const TPolicyHeader& Header() const; sl@0: sl@0: ~CPolicyReader(); sl@0: private: sl@0: CPolicyReader(); sl@0: void ConstructL(RFs& aRfs, const TDesC& aPolicyFileName); sl@0: CPolicy* ReadPolicyL(); sl@0: void ReadPolicyHeaderL(); sl@0: sl@0: CResourceFile* iResourceFile; ///< Handle to the resource file sl@0: RResourceReader iReader; ///< Parses the resource file sl@0: TPolicyHeader iHeader; ///< Header information sl@0: TInt iPolicyCount; ///< The number of policies in the file sl@0: TInt iPolicyNum; ///< The current policy being parsed sl@0: }; sl@0: sl@0: /// Policy files must only contain one top level resource. sl@0: static const int KPolicyResourceId = 1; sl@0: } sl@0: sl@0: #endif /* POLICYREADER_H */