applayerpluginsandutils/uripermissionservices/server/inc/tldlistinitializer.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2008-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 
       
    15 
       
    16 #ifndef __TLDLISTINITIALIZER_H__
       
    17 #define __TLDLISTINITIALIZER_H__
       
    18 
       
    19 #include <xml/contenthandler.h>
       
    20 #include <xml/parser.h>
       
    21 
       
    22 class CUriListInterface;
       
    23 class CTldProperties;
       
    24 
       
    25 /**
       
    26 This class initializes the database from a pre-configured XML file. The XML file takes the following form
       
    27 
       
    28 */
       
    29 
       
    30 NONSHARABLE_CLASS ( CTldListInitializer ) : public CBase,
       
    31 											public Xml::MContentHandler
       
    32 	{
       
    33 	public:
       
    34 	
       
    35 	enum TParserState
       
    36 		{
       
    37 		EInitial,
       
    38 		EStartOfPolicyData,
       
    39 		EEndOfPolicyData,
       
    40 		EStartOfTLD,
       
    41 		EEndOfTLD,
       
    42 		EStartOfListtype,
       
    43 		EEndOfListtype
       
    44 		};
       
    45 		
       
    46 	static CTldListInitializer* NewL ( CUriListInterface& aListInterface );
       
    47 	~CTldListInitializer ();
       
    48 	
       
    49 	void ParseDocumentL ( const TDesC& aFile );
       
    50 	
       
    51 	// Virtual functions from MContentHandler
       
    52 	void OnStartDocumentL ( const Xml::RDocumentParameters &aDocParam, TInt aErrorCode );
       
    53 	void OnEndDocumentL ( TInt aErrorCode );	
       
    54 	void OnStartElementL ( const Xml::RTagInfo &aElement, const Xml::RAttributeArray &aAttributes, TInt aErrorCode );
       
    55 	void OnEndElementL ( const Xml::RTagInfo &aElement, TInt aErrorCode );
       
    56 	void OnContentL ( const TDesC8 &aBytes, TInt aErrorCode );
       
    57 	inline void OnStartPrefixMappingL ( const RString &aPrefix, const RString &aUri, TInt aErrorCode );
       
    58 	inline void OnEndPrefixMappingL ( const RString &aPrefix, TInt aErrorCode );
       
    59 	inline void OnIgnorableWhiteSpaceL ( const TDesC8 &aBytes, TInt aErrorCode );
       
    60 	inline void OnSkippedEntityL ( const RString &aName, TInt aErrorCode );
       
    61 	inline void OnProcessingInstructionL ( const TDesC8 &aTarget, const TDesC8 &aData, TInt aErrorCode );
       
    62 	inline void OnError ( TInt aErrorCode );
       
    63 	inline TAny* GetExtendedInterface ( const TInt32 aUid );
       
    64 	
       
    65 	private:
       
    66 	CTldListInitializer ( CUriListInterface& aListInterface );
       
    67 	void ConstructL ();
       
    68 	
       
    69 	void SetParserState ( TParserState aNewState );
       
    70 	TParserState ParserStateL ( const RString& aTag, TBool aEndElement =EFalse );
       
    71 	void SetListType ( TInt aIndex );
       
    72 	void SetTldNameL ( );
       
    73 	void SetValueL ( const TDesC8& aValue );
       
    74 	void SaveTldName(const Xml::RAttributeArray&  aAttributes);
       
    75 	
       
    76 	private:		
       
    77 	CUriListInterface& 	iListInterface;
       
    78 	CTldProperties*		iTldUriImpl;
       
    79 	RStringPool			iStringPool;
       
    80 	TParserState		iParserState;
       
    81 	RBuf8				iContent;
       
    82 	RBuf8				iTldName;
       
    83 	};
       
    84 
       
    85 #include "tldlistinitializer.inl"
       
    86 
       
    87 #endif // __TLDLISTINITIALIZER_H__