|
1 /* |
|
2 * Copyright (c) 2006-2007 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: XML SAX Parser for UPnP. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef C_UPNPXMLPARSERLITE_H_ |
|
24 #define C_UPNPXMLPARSERLITE_H_ |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include <xml/contenthandler.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CUpnpObjectLite; |
|
32 class CUPnPObjectStackLite; |
|
33 //class CUpnpItem; |
|
34 //class CUpnpContainer; |
|
35 |
|
36 using namespace Xml; |
|
37 |
|
38 /** |
|
39 * XML SAX Parser for UPnP. |
|
40 * |
|
41 * @since s60 3.1 |
|
42 * @lib upnpxmlparser.lib |
|
43 */ |
|
44 class CUPnPXMLParserLite : public CBase, |
|
45 public MContentHandler |
|
46 { |
|
47 |
|
48 public: |
|
49 |
|
50 /** |
|
51 * 2-phased constructor. |
|
52 */ |
|
53 IMPORT_C static CUPnPXMLParserLite* NewL(); |
|
54 |
|
55 /** |
|
56 * 2-phased constructor. |
|
57 */ |
|
58 IMPORT_C static CUPnPXMLParserLite* NewLC(); |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 virtual ~CUPnPXMLParserLite(); |
|
64 |
|
65 public: |
|
66 |
|
67 /** |
|
68 * Parses xml data to the array of objects. |
|
69 * @param aResultArray, An array for objects in xml root. |
|
70 * @param aData, xml data. |
|
71 * @param aFormatString the format of title. If KNullDesC title will be |
|
72 * stored as it is. It's expected that the string is in the following |
|
73 * format: _L( "0\t%S---" ); where "0" is a placeholder for icon index |
|
74 * and %S is a placeholder for title |
|
75 * |
|
76 */ |
|
77 IMPORT_C void ParseResultDataL( RPointerArray<CUpnpObjectLite>& |
|
78 aResultArray, const TDesC8& aData, const TDesC& aFormatString = KNullDesC ); |
|
79 |
|
80 protected: // from MContentHandler |
|
81 |
|
82 /** |
|
83 * From MContentHandler. |
|
84 * @param aDocParam, not used. |
|
85 * @param aErrorCode, not used. |
|
86 */ |
|
87 void OnStartDocumentL( const RDocumentParameters& aDocParam, |
|
88 TInt aErrorCode ); |
|
89 |
|
90 /** |
|
91 * From MContentHandler. |
|
92 * @param aErrorCode, not used. |
|
93 */ |
|
94 void OnEndDocumentL( TInt aErrorCode ); |
|
95 |
|
96 /** |
|
97 * From MContentHandler. |
|
98 * @param aElement, holds the element info. |
|
99 * @param aAttributes, holds the element's attributes. |
|
100 * @param aErrorCode, if not KErrNone, the method is ignored. |
|
101 */ |
|
102 void OnStartElementL( const RTagInfo& aElement, |
|
103 const RAttributeArray& aAttributes, |
|
104 TInt aErrorCode ); |
|
105 |
|
106 /** |
|
107 * From MContentHandler. |
|
108 * @param aElement, holds the element info. |
|
109 * @param aErrorCode, if not KErrNone, the method is ignored. |
|
110 */ |
|
111 void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode ); |
|
112 |
|
113 /** |
|
114 * From MContentHandler. |
|
115 * @param aBytes, The value of the content. |
|
116 * @param aErrorCode, if not KErrNone, the method is ignored. |
|
117 */ |
|
118 void OnContentL( const TDesC8& aBytes, TInt aErrorCode ); |
|
119 |
|
120 /** |
|
121 * From MContentHandler. |
|
122 * @param aPrefix, not used. |
|
123 * @param aUri, not used. |
|
124 * @param aErrorCode, not used. |
|
125 */ |
|
126 void OnStartPrefixMappingL( const RString& aPrefix, |
|
127 const RString& aUri, |
|
128 TInt aErrorCode ); |
|
129 |
|
130 /** |
|
131 * From MContentHandler. |
|
132 * @param aPrefix, not used. |
|
133 * @param aErrorCode, not used. |
|
134 */ |
|
135 void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode ); |
|
136 |
|
137 /** |
|
138 * From MContentHandler. |
|
139 * @param aBytes, not used. |
|
140 * @param aErrorCode, not used. |
|
141 */ |
|
142 void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode ); |
|
143 |
|
144 /** |
|
145 * From MContentHandler. |
|
146 * @param aName, not used. |
|
147 * @param aErrorCode, not used. |
|
148 */ |
|
149 void OnSkippedEntityL( const RString& aName, TInt aErrorCode ); |
|
150 |
|
151 /** |
|
152 * From MContentHandler. |
|
153 * @param aTarget, not used. |
|
154 * @param aData, not used. |
|
155 * @param aErrorCode, not used. |
|
156 */ |
|
157 void OnProcessingInstructionL( const TDesC8& aTarget, |
|
158 const TDesC8& aData, |
|
159 TInt aErrorCode ); |
|
160 |
|
161 /** |
|
162 * From MContentHandler. |
|
163 * @param aErrorCode |
|
164 */ |
|
165 void OnError( TInt aErrorCode ); |
|
166 |
|
167 /** |
|
168 * From MContentHandler. |
|
169 * @param aUid, not used. |
|
170 * @return None. |
|
171 */ |
|
172 TAny* GetExtendedInterface( const TInt32 aUid ); |
|
173 |
|
174 |
|
175 private: |
|
176 |
|
177 /** |
|
178 * Constructor. |
|
179 */ |
|
180 CUPnPXMLParserLite(); |
|
181 |
|
182 /** |
|
183 * 2nd phase constructor. |
|
184 */ |
|
185 void ConstructL(); |
|
186 |
|
187 private: |
|
188 |
|
189 /** |
|
190 * Sets element's attributes to the object. |
|
191 * |
|
192 * @param aObject attributes will be set to this object |
|
193 * @param aAttributes attributes to set |
|
194 */ |
|
195 void SetAttributesL( CUpnpObjectLite& aObject, |
|
196 const RAttributeArray& aAttributes ); |
|
197 |
|
198 void SetIconIndex( const CUpnpObjectLite& aObject ); |
|
199 |
|
200 private: // data |
|
201 |
|
202 /** |
|
203 * A pointer to result array from the client. |
|
204 * Not own. |
|
205 */ |
|
206 RPointerArray<CUpnpObjectLite>* iResultRoot; |
|
207 |
|
208 /** |
|
209 * A stack for UPnP objects. |
|
210 * Own. |
|
211 */ |
|
212 CUPnPObjectStackLite* iStack; |
|
213 |
|
214 /** |
|
215 * Element value |
|
216 * Own. |
|
217 */ |
|
218 HBufC8* iElementValue; |
|
219 |
|
220 HBufC8* iTitleBuf; |
|
221 |
|
222 HBufC* iFormatString; |
|
223 |
|
224 TBool iTitle; |
|
225 TBool iObjectClass; |
|
226 }; |
|
227 |
|
228 #endif // C_UPNPXMLPARSER_H_ |
|
229 |
|
230 // End of File |