|
1 /* |
|
2 * Copyright (c) 2010 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: UPnP Renderer config parser |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_UPNPRENDERERCFGPARSER_H |
|
19 #define C_UPNPRENDERERCFGPARSER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <xml/contenthandler.h> |
|
25 |
|
26 class CUpnpRendererCfg; |
|
27 |
|
28 namespace Xml |
|
29 { |
|
30 class CParser; |
|
31 class CMatchData; |
|
32 } |
|
33 |
|
34 class CUpnpRendererCfgParser : public CBase |
|
35 , public Xml::MContentHandler |
|
36 { |
|
37 |
|
38 /* |
|
39 * Valid tags in renderer configuration xml file |
|
40 */ |
|
41 enum TCfgElements |
|
42 { |
|
43 EUnknown, |
|
44 EConfig, |
|
45 ERenderer, |
|
46 ETranscoding, |
|
47 EPipeline, |
|
48 EProtocolInfo, |
|
49 ESizeMultiplier |
|
50 }; |
|
51 |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Static NewL |
|
56 * |
|
57 * @param none |
|
58 * @return instance to CUpnpRendererCfgParser |
|
59 */ |
|
60 IMPORT_C static CUpnpRendererCfgParser* NewL(); |
|
61 |
|
62 /** |
|
63 * Static NewLC |
|
64 * |
|
65 * @param none |
|
66 * @return instance to CUpnpRendererCfgParser |
|
67 */ |
|
68 IMPORT_C static CUpnpRendererCfgParser* NewLC(); |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 IMPORT_C ~CUpnpRendererCfgParser(); |
|
74 |
|
75 private: |
|
76 |
|
77 /** |
|
78 * Constructor |
|
79 */ |
|
80 CUpnpRendererCfgParser(); |
|
81 |
|
82 /** |
|
83 * 2nd phrase Constructor |
|
84 */ |
|
85 void ConstructL(); |
|
86 |
|
87 public: |
|
88 |
|
89 /** |
|
90 * Parse renderer config. |
|
91 * |
|
92 * @param aRendereConfig Reference to renderer config container; after |
|
93 * succesfull call, all the configs are stored in the container |
|
94 * |
|
95 * @see upnprenderercfg.h |
|
96 */ |
|
97 IMPORT_C void ParseRendererCfgL( CUpnpRendererCfg& aRendereConfig ); |
|
98 |
|
99 private: |
|
100 |
|
101 /* |
|
102 * Start parsing. |
|
103 * |
|
104 * @param aFile Renderer configuration xml file |
|
105 */ |
|
106 void XMLParseL( const TDesC& aFile ); |
|
107 |
|
108 /* |
|
109 * Reset memeber variables. |
|
110 */ |
|
111 inline void Reset(); |
|
112 |
|
113 /* |
|
114 * Fetch element enumeration. |
|
115 * |
|
116 * @param aElement Reference to element's tag info |
|
117 * |
|
118 * @return Enumeration of the element |
|
119 */ |
|
120 TCfgElements Element( const Xml::RTagInfo& aElement ); |
|
121 |
|
122 /* |
|
123 * Checks if an attribute array contains an attribute with matching name |
|
124 * and matching value. |
|
125 * |
|
126 * @param aAttributes Reference to atttribute array |
|
127 * @param aAttributeName Reference to 8-bit name descriptor |
|
128 * @param aAttributeValue Reference to 8-bit value descriptor |
|
129 * @param aExactValueMatch Boolean for exact value match |
|
130 * |
|
131 * @param ETrue if found, otherwise EFalse |
|
132 */ |
|
133 TBool ContainsAttribute( const Xml::RAttributeArray& aAttributes, |
|
134 const TDesC8& aAttributeName, const TDesC8& aAttributeValue, |
|
135 TBool aExactValueMatch ); |
|
136 |
|
137 private: // from MContentHandler |
|
138 |
|
139 /** |
|
140 * From MContentHandler. |
|
141 * @param aDocParam, not used. |
|
142 * @param aErrorCode, not used. |
|
143 */ |
|
144 void OnStartDocumentL( const Xml::RDocumentParameters& aDocParam, |
|
145 TInt aErrorCode ); |
|
146 |
|
147 /** |
|
148 * From MContentHandler. |
|
149 * @param aErrorCode, not used. |
|
150 */ |
|
151 void OnEndDocumentL( TInt aErrorCode ); |
|
152 |
|
153 /** |
|
154 * From MContentHandler. |
|
155 * @param aElement, holds the element info. |
|
156 * @param aAttributes, holds the element's attributes. |
|
157 * @param aErrorCode, if not KErrNone, the method is ignored. |
|
158 */ |
|
159 void OnStartElementL( const Xml::RTagInfo& aElement, |
|
160 const Xml::RAttributeArray& aAttributes, |
|
161 TInt aErrorCode ); |
|
162 |
|
163 /** |
|
164 * From MContentHandler. |
|
165 * @param aElement, holds the element info. |
|
166 * @param aErrorCode, if not KErrNone, the method is ignored. |
|
167 */ |
|
168 void OnEndElementL( const Xml::RTagInfo& aElement, TInt aErrorCode ); |
|
169 |
|
170 /** |
|
171 * From MContentHandler. |
|
172 * @param aBytes, The value of the content. |
|
173 * @param aErrorCode, if not KErrNone, the method is ignored. |
|
174 */ |
|
175 void OnContentL( const TDesC8& aBytes, TInt aErrorCode ); |
|
176 |
|
177 /** |
|
178 * From MContentHandler. |
|
179 * @param aPrefix, not used. |
|
180 * @param aUri, not used. |
|
181 * @param aErrorCode, not used. |
|
182 */ |
|
183 void OnStartPrefixMappingL( const RString& aPrefix, |
|
184 const RString& aUri, |
|
185 TInt aErrorCode ); |
|
186 |
|
187 /** |
|
188 * From MContentHandler. |
|
189 * @param aPrefix, not used. |
|
190 * @param aErrorCode, not used. |
|
191 */ |
|
192 void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode ); |
|
193 |
|
194 /** |
|
195 * From MContentHandler. |
|
196 * @param aBytes, not used. |
|
197 * @param aErrorCode, not used. |
|
198 */ |
|
199 void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode ); |
|
200 |
|
201 /** |
|
202 * From MContentHandler. |
|
203 * @param aName, not used. |
|
204 * @param aErrorCode, not used. |
|
205 */ |
|
206 void OnSkippedEntityL( const RString& aName, TInt aErrorCode ); |
|
207 |
|
208 /** |
|
209 * From MContentHandler. |
|
210 * @param aTarget, not used. |
|
211 * @param aData, not used. |
|
212 * @param aErrorCode, not used. |
|
213 */ |
|
214 void OnProcessingInstructionL( const TDesC8& aTarget, |
|
215 const TDesC8& aData, |
|
216 TInt aErrorCode ); |
|
217 |
|
218 /** |
|
219 * From MContentHandler. |
|
220 * @param aErrorCode |
|
221 */ |
|
222 void OnError( TInt aErrorCode ); |
|
223 |
|
224 /** |
|
225 * From MContentHandler. |
|
226 * @param aUid, not used. |
|
227 * @return None. |
|
228 */ |
|
229 TAny* GetExtendedInterface( const TInt32 aUid ); |
|
230 |
|
231 private: |
|
232 |
|
233 RFs iFs; |
|
234 TCfgElements iCurrentElement; |
|
235 TBool iCorrectModel; |
|
236 TBool iCorrectTranscoding; |
|
237 Xml::CParser* iParser; // owned |
|
238 Xml::CMatchData* iMatchData; // owned |
|
239 HBufC8* iModelName; // not owned |
|
240 HBufC8* iSrcMimeType; // not owned |
|
241 |
|
242 // not owned if ParseRendererCfgL() doesn't LEAVE; otherwise owned |
|
243 HBufC8* iPipeline; |
|
244 |
|
245 // not owned if ParseRendererCfgL() doesn't LEAVE; otherwise owned |
|
246 HBufC8* iProtocolInfo; |
|
247 |
|
248 TReal iSizeMultiplier; |
|
249 |
|
250 }; |
|
251 |
|
252 |
|
253 #endif // C_UPNPRENDERERCFGPARSER_H |
|
254 |