persistentstorage/dbms/security/SC_TextIn.h
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // CPDTextLoader class
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __SC_TEXTIN_H__
       
    19 #define __SC_TEXTIN_H__
       
    20 
       
    21 #include <s32file.h>
       
    22 #include "SC_Defs.h"
       
    23 #include "SC_Policy.h"
       
    24 
       
    25 namespace DBSC
       
    26 {
       
    27 
       
    28 /**
       
    29 This enum describes the possible statement types in a text policy file, recogizable by
       
    30 CPDTextLoader implementation.
       
    31 @internalComponent
       
    32 */
       
    33 typedef enum 
       
    34 	{
       
    35 	EStmtTEof, 
       
    36 	EStmtTComment, 
       
    37 	EStmtTBlank, 
       
    38 	EStmtTDatabase, 
       
    39 	EStmtTTable, 
       
    40 	EStmtTName, 
       
    41 	EStmtTRead, 
       
    42 	EStmtTWrite, 
       
    43 	EStmtTSchema, 
       
    44 	EStmtTCapability, 
       
    45 	EStmtTSID, 
       
    46 	EStmtTVID, 
       
    47 	EStmtTBackup,
       
    48 	EStmtTInvalid //Include the new enum items before "EStmtTInvalid"
       
    49 	} TStmtType;
       
    50 
       
    51 /**
       
    52 This enum describes the possible statement classes in a text policy file, recogizable by
       
    53 CPDTextLoader implementation.
       
    54 @internalComponent
       
    55 */
       
    56 typedef enum 
       
    57 	{
       
    58 	EStmtCNoData,			//Blank, Comments
       
    59 	EStmtCPolicyObj,		//Database, Table
       
    60 	EStmtCPolicyType,		//Read, Write, Schema
       
    61 	EStmtCPolicyItem,		//Capability, SID, VID
       
    62 	EStmtCBackup,			//Backup & restore
       
    63 	EStmtCInvalid
       
    64 	} TStmtClass;
       
    65 
       
    66 //Forward declaration
       
    67 struct TStmtProps;
       
    68 
       
    69 /**
       
    70 CPDTextLoader class is an implementation of MPolicyDomainLoader interface and is used
       
    71 for loading security policies from a text policy file. The class uses TPolicyDomainBuilder
       
    72 class functionality for adding loaded policies to the controlled by TPolicyDomainBuilder
       
    73 instance CPolicyDomain collection.
       
    74 @see MPolicyDomainLoader
       
    75 @see TPolicyDomainBuilder
       
    76 @see CPolicyBase::RPolicyCollection
       
    77 @see CPolicyDomain
       
    78 @internalComponent
       
    79 */
       
    80 class CPDTextLoader : public CBase, public MPolicyDomainLoader
       
    81 	{
       
    82 public:
       
    83 	static CPDTextLoader* NewLC(RFs& aFs, const TDesC& aTextFileName);
       
    84 	virtual ~CPDTextLoader();
       
    85 	virtual void RunL(TPolicyDomainBuilder& aPolicyDomainBuilder);
       
    86 
       
    87 private:
       
    88 	inline CPDTextLoader();
       
    89 	void ConstructL(RFs& aFs, const TDesC& aTextFileName);
       
    90 	TBool IsEofL();
       
    91 	void GetStmtPropsL(const TDesC& aStmt, TStmtProps& aStmtProps) const;
       
    92 	TBool TryGetStmt1Props(const TDesC& aStmt, TStmtProps& aStmtProps) const;
       
    93 	TBool TryGetStmt2Props(const TDesC& aStmt, TStmtProps& aStmtProps) const;
       
    94 	TBool LoadStmtL(TPtr& aStmt);
       
    95 	TStmtClass LoadNextStmtL(TStmtProps& aStmtProps);
       
    96 	void LoadNextStmtOfTypeL(TStmtProps& aStmtProps, TStmtType aStmtType);
       
    97 	const CDbPolicy* LoadDbPolicyL(TPolicyDomainBuilder& aPolicyDomainBuilder, 
       
    98 									 TStmtProps& aStmtProps);
       
    99 	void LoadTblPoliciesL(TPolicyDomainBuilder& aPolicyDomainBuilder, TStmtProps& aStmtProps, 
       
   100 						  const CDbPolicy* aDbPolicy);
       
   101 	void LoadBackupSIDL(TPolicyDomainBuilder& aPolicyDomainBuilder, TStmtProps& aStmtProps);
       
   102 	void LoadSecurityPoliciesL(CPolicyBase::RPolicyCollection& aPolicyColl, TStmtProps& aStmtProps);
       
   103 	void LoadSecurityPolicyL(TSecurityPolicy& aSecurityPolicy, TStmtProps& aStmtProps);
       
   104 	void GetCapabilitiesL(const TDesC& aCapabilityStr, RArray<TCapability>& aCapability) const;
       
   105 	TUint GetIdL(const TDesC& aStr) const;
       
   106 
       
   107 private:
       
   108 	RFileReadStream			iRdStream;
       
   109 	TBuf8<KMaxStmtLength>	iStmt8;
       
   110 	TBuf<KMaxStmtLength>	iStmt;
       
   111 	};
       
   112 
       
   113 } //end of - namespace DBSC
       
   114 
       
   115 #endif//__SC_TEXTIN_H__