|
1 /* |
|
2 * Copyright (c) 2009 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef IA_UPDATE_XML_PARSER_H |
|
21 #define IA_UPDATE_XML_PARSER_H |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <e32cmn.h> |
|
26 #include <f32file.h> |
|
27 |
|
28 class CIAUpdateXmlSubParser; |
|
29 namespace Xml |
|
30 { |
|
31 class CParser; |
|
32 } |
|
33 |
|
34 |
|
35 /** |
|
36 * CIAUpdateXmlParser is the basic class |
|
37 * for IA Update XML parsers and provides basic XML parser |
|
38 * functionality. |
|
39 * |
|
40 * @since S60 v3.2 |
|
41 */ |
|
42 class CIAUpdateXmlParser : public CBase |
|
43 { |
|
44 |
|
45 public: |
|
46 |
|
47 /** |
|
48 * @param aSubParser This XML parser uses the sub parser to forward the |
|
49 * parsed elements and attributes for further handling. |
|
50 * NULL value is NOT accepted here. Ownership is transferred. |
|
51 * @return CIAUpdateXmlParser* Created object. |
|
52 * |
|
53 * @since S60 v3.2 |
|
54 */ |
|
55 IMPORT_C static CIAUpdateXmlParser* NewL( CIAUpdateXmlSubParser* aSubParser ); |
|
56 |
|
57 /** |
|
58 * @see CIAUpdateXmlParser::NewL |
|
59 * |
|
60 * @since S60 v3.2 |
|
61 */ |
|
62 IMPORT_C static CIAUpdateXmlParser* NewLC( CIAUpdateXmlSubParser* aSubParser ); |
|
63 |
|
64 |
|
65 /** |
|
66 * Destructor |
|
67 * |
|
68 * @since S60 v3.2 |
|
69 */ |
|
70 IMPORT_C virtual ~CIAUpdateXmlParser(); |
|
71 |
|
72 |
|
73 /** |
|
74 * Parses the data from the given XML file. |
|
75 * |
|
76 * @param aFilePath The path to the XML file. |
|
77 * |
|
78 * @since S60 v3.2 |
|
79 */ |
|
80 IMPORT_C void ParseFileL( const TDesC& aFilePath ); |
|
81 |
|
82 |
|
83 /** |
|
84 * Parses the data from the given XML file. |
|
85 * The correct file is searched from the application private |
|
86 * directories of different drives. The correct file is |
|
87 * searched by accepting the first file that is not in a ROM drive |
|
88 * or if no file from a non-ROM drive is found, then a file |
|
89 * from ROM is accepted if it is found. The file is searched by |
|
90 * starting from the A drive and first acceptable file is parsed. |
|
91 * |
|
92 * @para aFileName The name of the XML file. Notice, that this is only |
|
93 * the name of the file, not the whole path to the file. |
|
94 * |
|
95 * @since S60 v3.2 |
|
96 */ |
|
97 IMPORT_C void ParsePrivateFileL( const TDesC& aFileName ); |
|
98 |
|
99 |
|
100 /** |
|
101 * Parses the given data. |
|
102 * |
|
103 * @param aData XML data. |
|
104 * |
|
105 * @since S60 v3.2 |
|
106 */ |
|
107 IMPORT_C void ParseL( const TDesC8& aData ); |
|
108 |
|
109 /** |
|
110 * Parses the given data. |
|
111 * |
|
112 * @param aData XML data. |
|
113 * |
|
114 * @since S60 v3.2 |
|
115 */ |
|
116 IMPORT_C void ParseL( const TDesC& aData ); |
|
117 |
|
118 |
|
119 protected: |
|
120 |
|
121 /** |
|
122 * Constructor |
|
123 * |
|
124 * @see CIAUpdateXmlParser::NewL |
|
125 * |
|
126 * @since S60 v3.2 |
|
127 */ |
|
128 IMPORT_C CIAUpdateXmlParser( CIAUpdateXmlSubParser* aSubParser ); |
|
129 |
|
130 /** |
|
131 * 2nd. phase constructor. |
|
132 * |
|
133 * @since S60 v3.2 |
|
134 */ |
|
135 IMPORT_C virtual void ConstructL(); |
|
136 |
|
137 |
|
138 /** |
|
139 * @return CIAUpdateXmlSubParser& Reference to the sub parser that handles |
|
140 * the elements that this parser parses from the XML data. This sub parser is |
|
141 * the root element for the possible sub element hierarchy below it. |
|
142 * |
|
143 * @since S60 v3.2 |
|
144 */ |
|
145 IMPORT_C CIAUpdateXmlSubParser& SubParser(); |
|
146 |
|
147 |
|
148 private: |
|
149 |
|
150 // Prevent these if not implemented |
|
151 CIAUpdateXmlParser( const CIAUpdateXmlParser& aObject ); |
|
152 CIAUpdateXmlParser& operator =( const CIAUpdateXmlParser& aObject ); |
|
153 |
|
154 /** |
|
155 * @return Xml::CParser& Reference to the XML parser that gives the XML elements |
|
156 * for sub parsers. |
|
157 * |
|
158 * @since S60 v3.2 |
|
159 */ |
|
160 Xml::CParser& Parser(); |
|
161 |
|
162 HBufC8* ReadFileL( const TDesC& aFilePath ); |
|
163 HBufC8* ConvertUnicodeToUtf8L( const TDesC16& aUnicodeText ); |
|
164 void SetPrivateDriveL( RFs& aFs, const TDesC& aFileName ) const; |
|
165 TInt SetSessionPrivatePathL( RFs& aFs, const TDesC& aPath ) const; |
|
166 |
|
167 |
|
168 private: // data |
|
169 |
|
170 // This parser parses the XML data and gives the elements |
|
171 // for the sub parsers. |
|
172 Xml::CParser* iParser; |
|
173 |
|
174 // Sub parser is owned by this class object. |
|
175 CIAUpdateXmlSubParser* iSubParser; |
|
176 |
|
177 }; |
|
178 |
|
179 #endif // IA_UPDATE_XML_PARSER_H |
|
180 |