|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: Declares the CUpnpBaseContentHandler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __UPNPBASECONTENTHANDLER_H__ |
|
20 #define __UPNPBASECONTENTHANDLER_H__ |
|
21 |
|
22 #include "upnperrors.h" |
|
23 #include "upnpcommonupnplits.h" |
|
24 |
|
25 #include <Xml/ContentHandler.h> |
|
26 #include <Xml/DocumentParameters.h> |
|
27 #include <f32file.h> |
|
28 #include <CStack.h> |
|
29 |
|
30 #include <Xml/Parser.h> |
|
31 #include <Xml/ParserFeature.h> |
|
32 #include <Xml/MatchData.h> |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * This class implements the interface MContentHandler required by a client of the xml framework |
|
38 * It is designed to be used by xml parser that generates events using callback methods |
|
39 * |
|
40 * @since Series60 2.6 |
|
41 */ |
|
42 |
|
43 // for upnpcontenthandlers |
|
44 _LIT8(KUpnpRoot, "root"); |
|
45 _LIT8(KUpnpIconList, "iconList"); |
|
46 _LIT8(KUpnpUpc, "UPC"); |
|
47 _LIT8(KUpnpInmpro3, "INMPR03"); |
|
48 _LIT8(KUpnpScpd, "scpd"); |
|
49 _LIT8(KUpnpActionList, "actionList"); |
|
50 _LIT8(KUpnpArgument, "argument"); |
|
51 _LIT8(KUpnpArgumentList, "argumentList"); |
|
52 _LIT8(KUpnpServiceStateTable, "serviceStateTable"); |
|
53 _LIT8(KUpnpName, "name"); |
|
54 _LIT8(KUpnpIn, "in"); |
|
55 _LIT8(KUpnpDirection, "direction"); |
|
56 _LIT8(KUpnpRelatedStateVariable, "relatedStateVariable"); |
|
57 _LIT8(KUpnpDataType, "dataType"); |
|
58 _LIT8(KUpnpAllowedValue, "allowedValue"); |
|
59 _LIT8(KUpnpDefaultValue, "defaultValue"); |
|
60 _LIT8(KUpnpValue, "value"); |
|
61 _LIT8(KUpnpMinimum, "minimum"); |
|
62 _LIT8(KUpnpMaximum, "maximum"); |
|
63 _LIT8(KUpnpStep, "step"); |
|
64 |
|
65 using namespace Xml; |
|
66 |
|
67 |
|
68 class CUpnpBaseContentHandler : public CBase, public MContentHandler |
|
69 { |
|
70 public: |
|
71 /** |
|
72 * Destructor |
|
73 */ |
|
74 virtual ~CUpnpBaseContentHandler(); |
|
75 |
|
76 /** |
|
77 * Removes all elements from the stack |
|
78 */ |
|
79 void ClearResultsL(); |
|
80 |
|
81 public: // from MContentHandler |
|
82 |
|
83 /** |
|
84 * This method is a callback to indicate the start of the document. |
|
85 * @param aDocParam Specifies the various parameters of the document. |
|
86 * @arg aDocParam.iCharacterSetName The character encoding of the document. |
|
87 * @param aErrorCode is the error code. |
|
88 * If this is not KErrNone then special action may be required. |
|
89 */ |
|
90 virtual void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); |
|
91 |
|
92 /** |
|
93 * This method is a callback to indicate the end of the document. |
|
94 * @param aErrorCode is the error code. |
|
95 * If this is not KErrNone then special action may be required. |
|
96 */ |
|
97 virtual void OnEndDocumentL(TInt aErrorCode); |
|
98 |
|
99 /** |
|
100 * This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping. |
|
101 * This method is always called before the corresponding OnStartElementL method. |
|
102 * @param aPrefix is the Namespace prefix being declared. |
|
103 * @param aUri is the Namespace URI the prefix is mapped to. |
|
104 * @param aErrorCode is the error code. |
|
105 * If this is not KErrNone then special action may be required. |
|
106 */ |
|
107 virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, |
|
108 TInt aErrorCode); |
|
109 /** |
|
110 * This method is a notification of the end of the scope of a prefix-URI mapping. |
|
111 * This method is called after the corresponding DoEndElementL method. |
|
112 * @param aPrefix is the Namespace prefix that was mapped. |
|
113 * @param aErrorCode is the error code. |
|
114 * If this is not KErrNone then special action may be required. |
|
115 */ |
|
116 virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
117 |
|
118 /** |
|
119 * This method is a notification of ignorable whitespace in element content. |
|
120 * @param aBytes are the ignored bytes from the document being parsed. |
|
121 * @param aErrorCode is the error code. |
|
122 * If this is not KErrNone then special action may be required. |
|
123 */ |
|
124 virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
125 |
|
126 /** |
|
127 * This method is a notification of a skipped entity. If the parser encounters an |
|
128 * external entity it does not need to expand it - it can return the entity as aName |
|
129 * for the client to deal with. |
|
130 * @param aName is the name of the skipped entity. |
|
131 * @param aErrorCode is the error code. |
|
132 * If this is not KErrNone then special action may be required. |
|
133 */ |
|
134 virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
135 |
|
136 /** |
|
137 This method is a receive notification of a processing instruction. |
|
138 * @param aTarget is the processing instruction target. |
|
139 * @param aData is the processing instruction data. If empty none was supplied. |
|
140 * @param aErrorCode is the error code. |
|
141 * If this is not KErrNone then special action may be required. |
|
142 */ |
|
143 virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, |
|
144 TInt aErrorCode); |
|
145 /** |
|
146 * This method indicates an error has occurred. |
|
147 * @param aError is the error code |
|
148 */ |
|
149 virtual void OnError(TInt aErrorCode); |
|
150 |
|
151 /** |
|
152 * This method obtains the interface matching the specified uid. |
|
153 * @return 0 if no interface matching the uid is found. |
|
154 * Otherwise, the this pointer cast to that interface. |
|
155 * @param aUid the uid identifying the required interface. |
|
156 */ |
|
157 virtual TAny* GetExtendedInterface(const TInt32 aUid); |
|
158 |
|
159 /** |
|
160 * Removes all elements from the stack if parsing failed |
|
161 */ |
|
162 virtual void ClearStack(); |
|
163 |
|
164 protected: |
|
165 |
|
166 /** |
|
167 * Default C++ constructor |
|
168 */ |
|
169 CUpnpBaseContentHandler(); |
|
170 |
|
171 /** |
|
172 * 2nd phase constructor dedicated to future, inherited class |
|
173 */ |
|
174 void BaseConstructL(); |
|
175 |
|
176 /** |
|
177 * Gets an object most recently pushed onto the stack |
|
178 * @return |
|
179 */ |
|
180 CBase* GetElementL(); |
|
181 |
|
182 /** |
|
183 * This method shows whether parsing of a xml document is finished |
|
184 * @since Series60 3.2 |
|
185 * @return TBool |
|
186 */ |
|
187 virtual TBool IsReady() = 0; |
|
188 |
|
189 /** |
|
190 * Sets a flag to indicate that parsing of the xml document has thrown an error |
|
191 * @since Series60 3.2 |
|
192 */ |
|
193 virtual void SetError() = 0; |
|
194 |
|
195 /** |
|
196 * Sets a flag to indicate that parsing of the xml document has finished |
|
197 * @since Series60 3.2 |
|
198 */ |
|
199 virtual void SetFinish() = 0; |
|
200 |
|
201 /** |
|
202 * Get content value. |
|
203 * @since Series60 3.2 |
|
204 */ |
|
205 HBufC8* GetContentL(); |
|
206 |
|
207 protected: |
|
208 |
|
209 CStack<CBase, EFalse> *iStack; |
|
210 HBufC8* iContent; |
|
211 CParser* iParser; |
|
212 TBuf8<KMaxInfoSize> iInfo; |
|
213 HBufC8* iBodyTag1; |
|
214 HBufC8* iBodyTag2; |
|
215 TBool iChunk; |
|
216 |
|
217 }; |
|
218 |
|
219 #endif //__UPNPBASECONTENTHANDLER_H__ |