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