1 /* |
|
2 * Copyright (c) 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: Location Centre Server object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_LCREGISTRATIONPARSER_H |
|
20 #define C_LCREGISTRATIONPARSER_H |
|
21 |
|
22 // SYSTEM INCLUDES |
|
23 #include <Xml/Parser.h> |
|
24 #include <Xml/ContentHandler.h> |
|
25 #include <Xml/documentparameters.h> |
|
26 #include <f32file.h> |
|
27 |
|
28 //USER INCLUDE |
|
29 #include "lcregxmltagtype.h" |
|
30 |
|
31 |
|
32 // DATA TYPES |
|
33 enum TXmlParserElementState |
|
34 { |
|
35 EXmlParserOnStartElement, |
|
36 EXmlParserOnEndElement |
|
37 }; |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class CLcRegAppInfo; |
|
41 |
|
42 /** |
|
43 * class CLcRegistrationParser. |
|
44 * |
|
45 * This class is inherited from CBase. This |
|
46 * class is used as a parser for parsing the Location Centre Registration file. |
|
47 * @since S60 v5.0 |
|
48 */ |
|
49 class CLcRegistrationParser : public CBase, public Xml::MContentHandler |
|
50 { |
|
51 public: |
|
52 /** |
|
53 * Constructs a new instance of CLcRegistrationParser. |
|
54 * |
|
55 * @return The new instance of CLcRegistrationParser object. |
|
56 * @leave System wide error code if the object creation fails. |
|
57 */ |
|
58 static CLcRegistrationParser* NewL( RFs& aFs ); |
|
59 |
|
60 /** |
|
61 * C++ Destructor. |
|
62 * Frees all the resources associated with this Location Centre |
|
63 * server registry handler |
|
64 */ |
|
65 ~CLcRegistrationParser(); |
|
66 |
|
67 public: // New functions |
|
68 /** |
|
69 * create and initialize the parser. |
|
70 * |
|
71 * @param aFile Filename to be parsed |
|
72 * index. |
|
73 * @return returns a CLcRegAppInfo* object. |
|
74 */ |
|
75 CLcRegAppInfo* ParseFileL( const TDesC& aFile ); |
|
76 |
|
77 public: // Functions from base class MContentHandler |
|
78 |
|
79 /** |
|
80 * From From Xml::MContentHandler. |
|
81 * |
|
82 * @param aDocParam Document parameters. |
|
83 * @param aErrorCode A error code. |
|
84 */ |
|
85 void OnStartDocumentL( |
|
86 /* IN */ const Xml::RDocumentParameters& aDocParam, |
|
87 /* IN */ TInt aErrorCode |
|
88 ); |
|
89 |
|
90 /** |
|
91 * From From Xml::MContentHandler. |
|
92 * |
|
93 * @param aErrorCode A error code. |
|
94 */ |
|
95 void OnEndDocumentL(TInt aErrorCode); |
|
96 |
|
97 /** |
|
98 * From From Xml::MContentHandler. |
|
99 * |
|
100 * @param aElement Tag information. |
|
101 * @param aAttributes Attributes. |
|
102 * @param aErrorCode A error code. |
|
103 */ |
|
104 void OnStartElementL( |
|
105 /* IN */ const Xml::RTagInfo& aElement, |
|
106 /* IN */ const Xml::RAttributeArray& aAttributes, |
|
107 /* IN */ TInt aErrorCode |
|
108 ); |
|
109 |
|
110 /** |
|
111 * From From Xml::MContentHandler. |
|
112 * |
|
113 * @param aElement Tag information. |
|
114 * @param aErrorCode A error code. |
|
115 */ |
|
116 void OnEndElementL( |
|
117 /* IN */ const Xml::RTagInfo& aElement, |
|
118 /* IN */ TInt aErrorCode |
|
119 ); |
|
120 |
|
121 /** |
|
122 * From From Xml::MContentHandler. |
|
123 * |
|
124 * @param aBytes Tag content. |
|
125 * @param aErrorCode A error code. |
|
126 */ |
|
127 void OnContentL( |
|
128 /* IN */ const TDesC8& aBytes, |
|
129 /* IN */ TInt aErrorCode |
|
130 ); |
|
131 |
|
132 /** |
|
133 * From From Xml::MContentHandler. |
|
134 * |
|
135 * @param aPrefix A prefix. |
|
136 * @param aUri A Uri. |
|
137 * @param aErrorCode A error code. |
|
138 */ |
|
139 void OnStartPrefixMappingL( |
|
140 /* IN */ const RString& aPrefix, |
|
141 /* IN */ const RString& aUri, |
|
142 /* IN */ TInt aErrorCode |
|
143 ); |
|
144 |
|
145 /** |
|
146 * From From Xml::MContentHandler. |
|
147 * |
|
148 * @param aPrefix A prefix. |
|
149 * @param aErrorCode A error code. |
|
150 */ |
|
151 void OnEndPrefixMappingL( |
|
152 /* IN */ const RString& aPrefix, |
|
153 /* IN */ TInt aErrorCode |
|
154 ); |
|
155 |
|
156 /** |
|
157 * From From Xml::MContentHandler. |
|
158 * |
|
159 * @param aBytes A bytes. |
|
160 * @param aErrorCode A error code. |
|
161 */ |
|
162 void OnIgnorableWhiteSpaceL( |
|
163 /* IN */ const TDesC8& aBytes, |
|
164 /* IN */ TInt aErrorCode |
|
165 ); |
|
166 |
|
167 /** |
|
168 * From From Xml::MContentHandler. |
|
169 * |
|
170 * @param aName A skipped entity. |
|
171 * @param aErrorCode A error code. |
|
172 */ |
|
173 void OnSkippedEntityL( |
|
174 /* IN */ const RString& aName, |
|
175 /* IN */ TInt aErrorCode |
|
176 ); |
|
177 |
|
178 /** |
|
179 * From From Xml::MContentHandler. |
|
180 * |
|
181 * @param aTarget A target. |
|
182 * @param aData A data. |
|
183 * @param aErrorCode A error code. |
|
184 */ |
|
185 void OnProcessingInstructionL( |
|
186 /* IN */ const TDesC8& aTarget, |
|
187 /* IN */ const TDesC8& aData, |
|
188 /* IN */ TInt aErrorCode |
|
189 ); |
|
190 |
|
191 /** |
|
192 * From From Xml::MContentHandler. |
|
193 * |
|
194 */ |
|
195 void OnOutOfData(); |
|
196 |
|
197 /** |
|
198 * From From Xml::MContentHandler. |
|
199 * |
|
200 * @param aErrorCode A error code. |
|
201 */ |
|
202 void OnError(/* IN */ TInt aErrorCode); |
|
203 |
|
204 /** |
|
205 * From From Xml::MContentHandler. |
|
206 * |
|
207 * @param aUid A Uid of extended interface. |
|
208 */ |
|
209 TAny* GetExtendedInterface(/* IN */ const TInt32 aUid); |
|
210 |
|
211 private: |
|
212 /** |
|
213 * C++ Default constructor |
|
214 */ |
|
215 CLcRegistrationParser( RFs& aFs ); |
|
216 |
|
217 |
|
218 private: |
|
219 /** |
|
220 * Reads the attribute value for related elements. |
|
221 * |
|
222 * @param aElement Tag information. |
|
223 * @param aAttributes Attributes. |
|
224 */ |
|
225 void CollectAttributeValueL( |
|
226 const Xml::RTagInfo& aElement, |
|
227 const Xml::RAttributeArray& aAttributes); |
|
228 |
|
229 /** |
|
230 * Sets read content. |
|
231 * |
|
232 * @param aTag Tag to set content for. |
|
233 * @param aContent Content to set. |
|
234 */ |
|
235 void SetContentL( |
|
236 TLcRegXmlTagType aTag, |
|
237 const TDesC& aContent |
|
238 ); |
|
239 |
|
240 /** |
|
241 * Set a parsed tag. |
|
242 * |
|
243 * @param aTag Tag to set parsed state for. |
|
244 */ |
|
245 void SetParserTagL(TLcRegXmlTagType aTag); |
|
246 |
|
247 /** |
|
248 * Check that sequence order is correct. |
|
249 * |
|
250 * @param aTag Tag to check it is in right order. |
|
251 */ |
|
252 void CheckSequenceOrderL(TLcRegXmlTagType aTag); |
|
253 |
|
254 /** |
|
255 * Check mandatory tag are correct. |
|
256 * |
|
257 * @param aXmlState This contains wheather |
|
258 * parser state is in OnStartelement / OnEndElement |
|
259 * @param aTag Tag to check it is in right order. |
|
260 */ |
|
261 void CheckMandatoryTagsL( |
|
262 TXmlParserElementState aXmlState, |
|
263 TLcRegXmlTagType aTag |
|
264 ); |
|
265 |
|
266 /** |
|
267 * This function takes the Java midletname as input |
|
268 * parameter and returns the application Uid by which |
|
269 * this can be validate through app shell. |
|
270 * |
|
271 * @param aMidletName Contains the Java application midletname. |
|
272 * @return It returns the corresponding application uid |
|
273 * assigned to this midletname. |
|
274 */ |
|
275 TUint32 JavaAppUidL( const TDesC& aMidletName ); |
|
276 |
|
277 /** |
|
278 * This function checks the attribute name |
|
279 * associated with the corresponding element |
|
280 * and if it is not valid one leaves with KErrNotSupported. |
|
281 * Also checks no of attributs should be present with the element. |
|
282 * |
|
283 * @param aElement Contain the element name. |
|
284 * @param aAttributes Holds the attribute array |
|
285 * |
|
286 * @return It returns the valid attribute type |
|
287 */ |
|
288 TLcRegXmlTagType CheckAndReturnValidAttrL( |
|
289 TLcRegXmlTagType aElement, |
|
290 const Xml::RAttributeArray& aAttributes ); |
|
291 |
|
292 |
|
293 // By default, prohibit copy constructor |
|
294 CLcRegistrationParser( const CLcRegistrationParser& ); |
|
295 // Prohibit assigment operator |
|
296 CLcRegistrationParser& operator= ( const CLcRegistrationParser& ); |
|
297 |
|
298 private: //data member |
|
299 //own: Application registration info |
|
300 CLcRegAppInfo* iRegAppInfo; |
|
301 |
|
302 // File server reference from registry |
|
303 RFs& iFs; |
|
304 |
|
305 // Parser stuff |
|
306 HBufC8* iReadContent; |
|
307 |
|
308 // Input stuff |
|
309 TUint32 iParsedTag; |
|
310 TUint32 iParsingTag; |
|
311 RArray<TLcRegXmlTagType> iParserTreeTags; |
|
312 |
|
313 //Own: used to copy all the attribute value of an element |
|
314 HBufC* iAttributeBuf; |
|
315 |
|
316 // Holds the registration file full path name |
|
317 TFileName iFileName; |
|
318 |
|
319 // Holds the parser framework error status |
|
320 TInt iParserError; |
|
321 }; |
|
322 |
|
323 #endif // C_LCREGISTRATIONPARSER_H |
|