|
1 // Copyright (c) 2005-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 __TESTCONTENTHANDLER_H__ |
|
17 #define __TESTCONTENTHANDLER_H__ |
|
18 |
|
19 #include "XmlEngExtendedContentHandler.h" |
|
20 #include <Xml\DocumentParameters.h> |
|
21 #include <Xml\ContentHandler.h> |
|
22 #include <f32file.h> |
|
23 |
|
24 using namespace Xml; |
|
25 |
|
26 const TInt KShortInfoSize = 256; |
|
27 const TInt KLongInfoSize = 1000; |
|
28 |
|
29 class CTestHandler : public CBase, public MContentHandler, public MXmlEngExtendedHandler |
|
30 { |
|
31 |
|
32 public: |
|
33 |
|
34 static CTestHandler* NewL(const RFile & aFileName); |
|
35 static CTestHandler* NewLC(const RFile & aFileName); |
|
36 |
|
37 ~CTestHandler(); |
|
38 |
|
39 /** |
|
40 This method is a callback to indicate the start of the document. |
|
41 @param aDocParam Specifies the various parameters of the document. |
|
42 aDocParam.iCharacterSetName The character encoding of the document. |
|
43 @param aErrorCode is the error code. |
|
44 If this is not KErrNone then special action may be required. |
|
45 */ |
|
46 void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); |
|
47 |
|
48 |
|
49 /** |
|
50 This method is a callback to indicate the end of the document. |
|
51 @param aErrorCode is the error code. |
|
52 If this is not KErrNone then special action may be required. |
|
53 */ |
|
54 void OnEndDocumentL(TInt aErrorCode); |
|
55 |
|
56 |
|
57 /** |
|
58 This method is a callback to indicate an element has been parsed. |
|
59 @param aElement is a handle to the element's details. |
|
60 @param aAttributes contains the attributes for the element. |
|
61 @param aErrorCode is the error code. |
|
62 If this is not KErrNone then special action may be required. |
|
63 */ |
|
64 void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, |
|
65 TInt aErrorCode); |
|
66 |
|
67 |
|
68 /** |
|
69 This method is a callback to indicate the end of the element has been reached. |
|
70 @param aElement is a handle to the element's details. |
|
71 @param aErrorCode is the error code. |
|
72 If this is not KErrNone then special action may be required. |
|
73 */ |
|
74 void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); |
|
75 |
|
76 |
|
77 /** |
|
78 This method is a callback that sends the content of the element. |
|
79 Not all the content may be returned in one go. The data may be sent in chunks. |
|
80 When an OnEndElementL is received this means there is no more content to be sent. |
|
81 @param aBytes is the raw content data for the element. |
|
82 The client is responsible for converting the data to the |
|
83 required character set if necessary. |
|
84 In some instances the content may be binary and must not be converted. |
|
85 @param aErrorCode is the error code. |
|
86 If this is not KErrNone then special action may be required. |
|
87 */ |
|
88 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
89 |
|
90 |
|
91 /** |
|
92 This method is a callback that sends the binary content of the element. |
|
93 @param aBytes is the raw binary content data for the element. |
|
94 @param aCid is the content data id |
|
95 @param aErrorCode is the error code. |
|
96 If this is not KErrNone then special action may be required. |
|
97 */ |
|
98 void OnBinaryContentL(const TDesC8& aBytes, const TDesC8& aCid, TInt aErrorCode); |
|
99 |
|
100 /** |
|
101 This method is a callback that sends data container reference |
|
102 @param aContainer Container encapsulating binary data |
|
103 @param aErrorCode is the error code. |
|
104 If this is not KErrNone then special action may be required. |
|
105 */ |
|
106 void OnDataContainerL(const TXmlEngDataContainer& aContainer, TInt aErrorCode); |
|
107 |
|
108 /** |
|
109 This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping. |
|
110 This method is always called before the corresponding OnStartElementL method. |
|
111 @param aPrefix is the Namespace prefix being declared. |
|
112 @param aUri is the Namespace URI the prefix is mapped to. |
|
113 @param aErrorCode is the error code. |
|
114 If this is not KErrNone then special action may be required. |
|
115 */ |
|
116 void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, |
|
117 TInt aErrorCode); |
|
118 |
|
119 |
|
120 /** |
|
121 This method is a notification of the end of the scope of a prefix-URI mapping. |
|
122 This method is called after the corresponding DoEndElementL method. |
|
123 @param aPrefix is the Namespace prefix that was mapped. |
|
124 @param aErrorCode is the error code. |
|
125 If this is not KErrNone then special action may be required. |
|
126 */ |
|
127 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
128 |
|
129 |
|
130 /** |
|
131 This method is a notification of ignorable whitespace in element content. |
|
132 @param aBytes are the ignored bytes from the document being parsed. |
|
133 @param aErrorCode is the error code. |
|
134 If this is not KErrNone then special action may be required. |
|
135 */ |
|
136 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
137 |
|
138 |
|
139 /** |
|
140 This method is a notification of a skipped entity. If the parser encounters an |
|
141 external entity it does not need to expand it - it can return the entity as aName |
|
142 for the client to deal with. |
|
143 @param aName is the name of the skipped entity. |
|
144 @param aErrorCode is the error code. |
|
145 If this is not KErrNone then special action may be required. |
|
146 */ |
|
147 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
148 |
|
149 |
|
150 /** |
|
151 This method is a receive notification of a processing instruction. |
|
152 @param aTarget is the processing instruction target. |
|
153 @param aData is the processing instruction data. If empty none was supplied. |
|
154 @param aErrorCode is the error code. |
|
155 If this is not KErrNone then special action may be required. |
|
156 */ |
|
157 void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, |
|
158 TInt aErrorCode); |
|
159 |
|
160 |
|
161 /** |
|
162 This method indicates an error has occurred. |
|
163 @param aError is the error code |
|
164 */ |
|
165 void OnError(TInt aErrorCode); |
|
166 |
|
167 |
|
168 /** |
|
169 This method obtains the interface matching the specified uid. |
|
170 @return 0 if no interface matching the uid is found. |
|
171 Otherwise, the this pointer cast to that interface. |
|
172 @param aUid the uid identifying the required interface. |
|
173 */ |
|
174 TAny* GetExtendedInterface(const TInt32 aUid); |
|
175 |
|
176 CTestHandler(); |
|
177 void ConstructL(const RFile & aFileName); |
|
178 |
|
179 private: |
|
180 RFile iLog; |
|
181 |
|
182 }; |
|
183 |
|
184 #endif //__CONTENTHANDLER_H__ |