policymanagement/policyengine/policyengineserver/inc/PolicyParser.h
changeset 0 b497e44ab2fc
child 1 a9c0ce913924
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2000 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 "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: Implementation of policymanagement components
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef POLICY_PARSER_HEADER_
       
    20 #define POLICY_PARSER_HEADER_
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 
       
    25 #include "ElementBase.h"
       
    26 #include "PolicyEngineClientServer.h"
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <contenthandler.h>
       
    30 #include <documentparameters.h>
       
    31 #include <cstack.h>
       
    32 #include <parser.h>
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 enum TAllowedExternalIdConflicts
       
    37 {
       
    38 	KNoExternalIdCheck = 0,
       
    39 	KSameExternalIdAllowedForRoot,
       
    40 	KNoExternalIdConflictsAllowed
       
    41 };
       
    42 
       
    43 
       
    44 // MACROS
       
    45 // DATA TYPES
       
    46 // FUNCTION PROTOTYPES
       
    47 // FORWARD DECLARATIONS
       
    48 
       
    49 class CElementBase;
       
    50 class CPolicyStorage;
       
    51 
       
    52 // CLASS DECLARATION
       
    53 
       
    54 namespace ParserUtility
       
    55 {
       
    56 	TBool ContainsCDataField( TPtrC8& aChunk);
       
    57 	void ReadCDataAreaL( TPtrC8& aCDataArea, TPtrC8& aChunk, TPtrC8& aFinalPart);
       
    58 	void RemoveCDataMarksL( TPtrC8& aData);
       
    59 	TInt LineCounter( TPtrC8& aData);
       
    60 }
       
    61 
       
    62 class CPolicyParser : public CBase, public Xml::MContentHandler
       
    63 {
       
    64 	public:
       
    65 		static CPolicyParser * NewL( CPolicyStorage * aStorage);
       
    66 		CPolicyParser( CPolicyStorage * aStorage);
       
    67 		virtual ~CPolicyParser();
       
    68 	
       
    69 		void ConstructL();
       
    70 	
       
    71 		CElementBase * ParseXACMLObjects( TInt& aError, const TDesC8 &aXACML, TDes8 &aReturnText);
       
    72 		TInt ParseNativeObjects( CElementBase * aSeedElement, const TDesC8 &aNative, TBool aAddToEditableCache);
       
    73 		void HandleErrorL( const TDesC8 &aText);
       
    74 		void HandleErrorL( const TDesC8 &aText, const TDesC8 &aErrorElement);
       
    75 		void HandleErrorL( const TAny * aPointer, const TDesC8 &aError, const TDesC8 &aErrorElement);
       
    76 		TDesC8& ActiveElementName();
       
    77 		void HandleNativeErrorL( TInt aError);
       
    78 		
       
    79 		TLanguageSelector Language();
       
    80 		
       
    81 		void SetExternalIdChecked( TAllowedExternalIdConflicts aCheckerState);
       
    82 		void CheckExternalIdL( const HBufC8 * iExternalId);
       
    83 		void SetLineOffset( TInt aLine);
       
    84 		
       
    85 		//Validity Check functions
       
    86 		void CheckCompiningAlgorithmsL( TNativeElementTypes aType, const TDesC8& aAlgorithmId );
       
    87 		void CheckFunctionIdL( const TNativeElementTypes& aType, const TDesC8& aFunctionId );
       
    88 		void CheckEffectL( const TDesC8& aEffect );
       
    89 		void CheckDataTypeL( const TDesC8& aDataType );
       
    90 	
       
    91 		//convert XACML to Native 
       
    92 		const TDesC8& ConvertElementNamesL( const TDesC8& aElementName );
       
    93 		const TDesC8& ConvertAttributesL( const TDesC8& aType );
       
    94 		static const TDesC8& ConvertValues( TLanguageSelector aOriginalLanguage, const TDesC8& aValue);
       
    95 			
       
    96 		//from content handler
       
    97 		void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode);
       
    98     	void OnEndDocumentL(TInt aErrorCode);
       
    99     	void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode);
       
   100     	void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
       
   101     	void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
       
   102     	void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
       
   103     	void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
       
   104     	void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
       
   105     	void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
       
   106     	void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
       
   107     	void OnError(TInt aErrorCode);
       
   108 		TAny* GetExtendedInterface(const TInt32 aUid);
       
   109 	
       
   110 	private:
       
   111 		void CreateIdElementsL( const TDesC8& aIdString);
       
   112 		void ParseL( const TDesC8 &aXACML);
       
   113 	
       
   114 	private: 
       
   115 		TPtrC8 iActiveElementName;
       
   116 		TInt iActiveLine;
       
   117 		TInt iLineOffset;
       
   118 		Xml::CParser * iParser;
       
   119 		CStack<CElementBase, EFalse> * iElementStack;
       
   120 		CElementBase * iActiveElement;
       
   121 		CElementBase * iRootElement;
       
   122 		CPolicyStorage * iStorage;
       
   123 		TLanguageSelector iLanguage;
       
   124 		TAllowedExternalIdConflicts iCheckerState;
       
   125 		TBool iErrorHandling;
       
   126 		TBuf8<KMaxReturnMessageLength> iReturnText;
       
   127 		TBool iAddToEditableCache;
       
   128 		TBool iValidCharacterSet;
       
   129 };
       
   130 
       
   131 
       
   132 #endif