64 @param RFs& reference to RFs |
68 @param RFs& reference to RFs |
65 @return CSBEConfig* pointer to CSBEConfig |
69 @return CSBEConfig* pointer to CSBEConfig |
66 */ |
70 */ |
67 CSBEConfig* CSBEConfig::NewL(RFs& aRFs) |
71 CSBEConfig* CSBEConfig::NewL(RFs& aRFs) |
68 { |
72 { |
|
73 OstTraceFunctionEntry0( CSBECONFIG_NEWL_ENTRY ); |
69 CSBEConfig* self = new (ELeave) CSBEConfig(aRFs); |
74 CSBEConfig* self = new (ELeave) CSBEConfig(aRFs); |
|
75 OstTraceFunctionExit0( CSBECONFIG_NEWL_EXIT ); |
70 return self; |
76 return self; |
71 } |
77 } |
72 |
78 |
73 /** |
79 /** |
74 C++ Constructor |
80 C++ Constructor |
75 */ |
81 */ |
76 CSBEConfig::CSBEConfig(RFs& aRFs) : iRFs(aRFs), iFileName(KConfigFile), iConfigTagVisited(EFalse) |
82 CSBEConfig::CSBEConfig(RFs& aRFs) : iRFs(aRFs), iFileName(KConfigFile), iConfigTagVisited(EFalse) |
77 { |
83 { |
|
84 OstTraceFunctionEntry0( CSBECONFIG_CSBECONFIG_CONS_ENTRY ); |
78 SetDefault(); |
85 SetDefault(); |
|
86 OstTraceFunctionExit0( CSBECONFIG_CSBECONFIG_CONS_EXIT ); |
79 } |
87 } |
80 /** |
88 /** |
81 Destructor |
89 Destructor |
82 */ |
90 */ |
83 CSBEConfig::~CSBEConfig() |
91 CSBEConfig::~CSBEConfig() |
84 { |
92 { |
|
93 OstTraceFunctionEntry0( CSBECONFIG_CSBECONFIG_DES_ENTRY ); |
85 delete iConverter; |
94 delete iConverter; |
|
95 OstTraceFunctionExit0( CSBECONFIG_CSBECONFIG_DES_EXIT ); |
86 } |
96 } |
87 |
97 |
88 /** |
98 /** |
89 Heap Values |
99 Heap Values |
90 @param TInt& aMaxSize of the heap to try to allocate |
100 @param TInt& aMaxSize of the heap to try to allocate |
91 @param TInt& aReductionFactor in case allocation fail |
101 @param TInt& aReductionFactor in case allocation fail |
92 @param TInt& number of retries to try to reduce the heap by the ReductionFactor |
102 @param TInt& number of retries to try to reduce the heap by the ReductionFactor |
93 */ |
103 */ |
94 void CSBEConfig::HeapValues(TInt& aMaxSize, TInt& aReductionFactor, TInt& aMaxRetries) const |
104 void CSBEConfig::HeapValues(TInt& aMaxSize, TInt& aReductionFactor, TInt& aMaxRetries) const |
95 { |
105 { |
|
106 OstTraceFunctionEntry0( CSBECONFIG_HEAPVALUES_ENTRY ); |
96 aMaxSize = iSBEGSHMaxSize; |
107 aMaxSize = iSBEGSHMaxSize; |
97 aReductionFactor = iReductionFactor; |
108 aReductionFactor = iReductionFactor; |
98 aMaxRetries = iMaxRetries; |
109 aMaxRetries = iMaxRetries; |
|
110 OstTraceFunctionExit0( CSBECONFIG_HEAPVALUES_EXIT ); |
99 } |
111 } |
100 |
112 |
101 /** |
113 /** |
102 Secure Id for central repository, needed deprecated use of centrep tag in xml |
114 Secure Id for central repository, needed deprecated use of centrep tag in xml |
103 @return TSecureId& aSecureId |
115 @return TSecureId& aSecureId |
128 /** |
140 /** |
129 Set the values to Defaults |
141 Set the values to Defaults |
130 */ |
142 */ |
131 void CSBEConfig::SetDefault() |
143 void CSBEConfig::SetDefault() |
132 { |
144 { |
|
145 OstTraceFunctionEntry0( CSBECONFIG_SETDEFAULT_ENTRY ); |
133 iSBEGSHMaxSize = KSBEGSHDefaultSize; |
146 iSBEGSHMaxSize = KSBEGSHDefaultSize; |
134 iCentRepId = KCentRepSID; |
147 iCentRepId = KCentRepSID; |
135 iDrives.SetLength(KMaxDrives); |
148 iDrives.SetLength(KMaxDrives); |
136 iDrives.FillZ(); |
149 iDrives.FillZ(); |
137 iDrives[EDriveZ] = ETrue; |
150 iDrives[EDriveZ] = ETrue; |
138 iReductionFactor = KSBEGSHReductionFactor; |
151 iReductionFactor = KSBEGSHReductionFactor; |
139 iMaxRetries = KSBEGSHMaxRetries; |
152 iMaxRetries = KSBEGSHMaxRetries; |
140 iAppCloseDelay = KDefaultDelay; |
153 iAppCloseDelay = KDefaultDelay; |
|
154 OstTraceFunctionExit0( CSBECONFIG_SETDEFAULT_EXIT ); |
141 } |
155 } |
142 |
156 |
143 /** |
157 /** |
144 Method to convert string of drives (eg. cdez) to member variable TDriveList |
158 Method to convert string of drives (eg. cdez) to member variable TDriveList |
145 @param const TDesC8& reference to string |
159 @param const TDesC8& reference to string |
146 */ |
160 */ |
147 TInt CSBEConfig::StringToDrives(const TDesC8& aDes) |
161 TInt CSBEConfig::StringToDrives(const TDesC8& aDes) |
148 { |
162 { |
|
163 OstTraceFunctionEntry0( CSBECONFIG_STRINGTODRIVES_ENTRY ); |
149 iDrives.SetLength(KMaxDrives); |
164 iDrives.SetLength(KMaxDrives); |
150 iDrives.FillZ(); |
165 iDrives.FillZ(); |
151 |
166 |
152 TInt err = KErrNone; |
167 TInt err = KErrNone; |
153 TInt length = aDes.Length(); |
168 TInt length = aDes.Length(); |
159 { |
174 { |
160 break; |
175 break; |
161 } |
176 } |
162 iDrives[pos] = ETrue; |
177 iDrives[pos] = ETrue; |
163 } |
178 } |
|
179 OstTraceFunctionExit0( CSBECONFIG_STRINGTODRIVES_EXIT ); |
164 return err; |
180 return err; |
165 } |
181 } |
166 |
182 |
167 /** |
183 /** |
168 Parses the config file if found |
184 Parses the config file if found |
169 @leave with System wide Error Codes |
185 @leave with System wide Error Codes |
170 */ |
186 */ |
171 void CSBEConfig::ParseL() |
187 void CSBEConfig::ParseL() |
172 { |
188 { |
|
189 OstTraceFunctionEntry0( CSBECONFIG_PARSEL_ENTRY ); |
173 iRFs.PrivatePath(iFileName); |
190 iRFs.PrivatePath(iFileName); |
174 TFindFile findFile(iRFs); |
191 TFindFile findFile(iRFs); |
175 User::LeaveIfError(findFile.FindByPath(KConfigFile, &iFileName)); |
192 TInt err = findFile.FindByPath(KConfigFile, &iFileName); |
|
193 LEAVEIFERROR(err, OstTrace1(TRACE_ERROR, CSBECONFIG_PARSEL, "Leave: %d", err)); |
176 |
194 |
177 iFileName = findFile.File(); |
195 iFileName = findFile.File(); |
178 // Connect to the parser |
196 // Connect to the parser |
179 CParser* parser = CParser::NewLC(KMimeType, *this); |
197 CParser* parser = CParser::NewLC(KMimeType, *this); |
180 |
198 |
181 // Parse the file |
199 // Parse the file |
182 Xml::ParseL(*parser, iRFs, iFileName); |
200 Xml::ParseL(*parser, iRFs, iFileName); |
183 |
201 |
184 CleanupStack::PopAndDestroy(parser); |
202 CleanupStack::PopAndDestroy(parser); |
|
203 OstTraceFunctionExit0( CSBECONFIG_PARSEL_EXIT ); |
185 } |
204 } |
186 |
205 |
187 /** |
206 /** |
188 A method to handle attributes |
207 A method to handle attributes |
189 @param RAttributeArray& aAttributes |
208 @param RAttributeArray& aAttributes |
190 @return TInt System Wide Error |
209 @return TInt System Wide Error |
191 */ |
210 */ |
192 TInt CSBEConfig::HandleAttributesElement(const RAttributeArray& aAttributes) |
211 TInt CSBEConfig::HandleAttributesElement(const RAttributeArray& aAttributes) |
193 { |
212 { |
|
213 OstTraceFunctionEntry0( CSBECONFIG_HANDLEATTRIBUTESELEMENT_ENTRY ); |
194 TInt err = KErrNone; |
214 TInt err = KErrNone; |
195 // Loop through reading out attribute values |
215 // Loop through reading out attribute values |
196 const TUint count = aAttributes.Count(); |
216 const TUint count = aAttributes.Count(); |
197 for (TInt x = 0; x < count && err == KErrNone; x++) |
217 for (TInt x = 0; x < count && err == KErrNone; x++) |
198 { |
218 { |
203 TLex8 lex(value); |
223 TLex8 lex(value); |
204 TInt appCloseDelay = 0; |
224 TInt appCloseDelay = 0; |
205 err = lex.Val(appCloseDelay); |
225 err = lex.Val(appCloseDelay); |
206 if (appCloseDelay < 0) |
226 if (appCloseDelay < 0) |
207 { |
227 { |
208 __LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: the time delay is negative"); |
228 OstTrace0(TRACE_NORMAL, CSBECONFIG_HANDLEATTRIBUTESELEMENT, "Configuration Error: the time delay is negative"); |
209 err = KErrCorrupt; |
229 err = KErrCorrupt; |
210 } |
230 } |
211 else |
231 else |
212 { |
232 { |
213 iAppCloseDelay = appCloseDelay; |
233 iAppCloseDelay = appCloseDelay; |
217 { |
237 { |
218 TLex8 lex(value); |
238 TLex8 lex(value); |
219 err = lex.Val(iReductionFactor); |
239 err = lex.Val(iReductionFactor); |
220 if (iReductionFactor < 0) |
240 if (iReductionFactor < 0) |
221 { |
241 { |
222 __LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: the reductionFactor is negative"); |
242 OstTrace0(TRACE_NORMAL, DUP1_CSBECONFIG_HANDLEATTRIBUTESELEMENT, "Configuration Error: the reductionFactor is negative"); |
223 err = KErrCorrupt; |
243 err = KErrCorrupt; |
224 } |
244 } |
225 } |
245 } |
226 else if (!attrib.CompareF(KMaxRetries)) |
246 else if (!attrib.CompareF(KMaxRetries)) |
227 { |
247 { |
228 TLex8 lex(value); |
248 TLex8 lex(value); |
229 err = lex.Val(iMaxRetries); |
249 err = lex.Val(iMaxRetries); |
230 if (iMaxRetries < 0) |
250 if (iMaxRetries < 0) |
231 { |
251 { |
232 __LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: the maxRetries is negative"); |
252 OstTrace0(TRACE_NORMAL, DUP2_CSBECONFIG_HANDLEATTRIBUTESELEMENT, "Configuration Error: the maxRetries is negative"); |
233 err = KErrCorrupt; |
253 err = KErrCorrupt; |
234 } |
254 } |
235 } |
255 } |
236 if (!attrib.CompareF(KSize)) |
256 if (!attrib.CompareF(KSize)) |
237 { |
257 { |
238 TLex8 lex(value); |
258 TLex8 lex(value); |
239 err = lex.Val(iSBEGSHMaxSize); |
259 err = lex.Val(iSBEGSHMaxSize); |
240 if (iSBEGSHMaxSize < KMinHeapSize) |
260 if (iSBEGSHMaxSize < KMinHeapSize) |
241 { |
261 { |
242 __LOG1("CSBEConfig::HandleAttributesElement() - Configuration Error: heap size is less then minimum %d", KMinHeapSize); |
262 OstTrace1(TRACE_NORMAL, DUP3_CSBECONFIG_HANDLEATTRIBUTESELEMENT, "Configuration Error: heap size is less then minimum %d", KMinHeapSize); |
243 err = KErrCorrupt; |
263 err = KErrCorrupt; |
244 } |
264 } |
245 } // if |
265 } // if |
246 else if (!attrib.CompareF(KUid)) |
266 else if (!attrib.CompareF(KUid)) |
247 { |
267 { |
255 err = KErrCorrupt; |
275 err = KErrCorrupt; |
256 } |
276 } |
257 } |
277 } |
258 if (err != KErrNone) |
278 if (err != KErrNone) |
259 { |
279 { |
260 __LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: central_repostiory is NOT a HEX number"); |
280 OstTrace0(TRACE_NORMAL, DUP4_CSBECONFIG_HANDLEATTRIBUTESELEMENT, "Configuration Error: central_repostiory is NOT a HEX number"); |
261 err = KErrCorrupt; |
281 err = KErrCorrupt; |
262 } |
282 } |
263 } // else if |
283 } // else if |
264 else if (!attrib.CompareF(KList)) |
284 else if (!attrib.CompareF(KList)) |
265 { |
285 { |
266 err = StringToDrives(value); |
286 err = StringToDrives(value); |
267 if (err != KErrNone) |
287 if (err != KErrNone) |
268 { |
288 { |
269 __LOG("CSBEConfig::HandleAttributesElement() - Configuration Error: list doesn't have valid characters from a-z"); |
289 OstTrace0(TRACE_NORMAL, DUP5_CSBECONFIG_HANDLEATTRIBUTESELEMENT, "Configuration Error: list doesn't have valid characters from a-z"); |
270 } |
290 } |
271 } // else if |
291 } // else if |
272 |
292 |
273 } // for x |
293 } // for x |
|
294 OstTraceFunctionExit0( CSBECONFIG_HANDLEATTRIBUTESELEMENT_EXIT ); |
274 return err; |
295 return err; |
275 } |
296 } |
276 |
297 |
277 // From MContentHandler |
298 // From MContentHandler |
278 void CSBEConfig::OnStartDocumentL(const RDocumentParameters& /*aDocParam*/, TInt /*aErrorCode*/) |
299 void CSBEConfig::OnStartDocumentL(const RDocumentParameters& /*aDocParam*/, TInt /*aErrorCode*/) |
281 |
302 |
282 @see MContentHandler::OnStartDocumentL() |
303 @see MContentHandler::OnStartDocumentL() |
283 @leave if fails to set encoding |
304 @leave if fails to set encoding |
284 */ |
305 */ |
285 { |
306 { |
|
307 OstTraceFunctionEntry0( CSBECONFIG_ONSTARTDOCUMENTL_ENTRY ); |
286 // Create a converter for converting strings to Unicode |
308 // Create a converter for converting strings to Unicode |
287 iConverter = CCnvCharacterSetConverter::NewL(); |
309 iConverter = CCnvCharacterSetConverter::NewL(); |
288 |
310 |
289 // We only convert from UTF-8 to UTF-16 |
311 // We only convert from UTF-8 to UTF-16 |
290 if (iConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, iRFs) == CCnvCharacterSetConverter::ENotAvailable) |
312 if (iConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, iRFs) == CCnvCharacterSetConverter::ENotAvailable) |
291 { |
313 { |
|
314 OstTrace0(TRACE_ERROR, CSBECONFIG_ONSTARTDOCUMENTL, "Leave: KErrNotFound"); |
292 User::Leave(KErrNotFound); |
315 User::Leave(KErrNotFound); |
293 } |
316 } |
|
317 OstTraceFunctionExit0( CSBECONFIG_ONSTARTDOCUMENTL_EXIT ); |
294 } |
318 } |
295 |
319 |
296 void CSBEConfig::OnEndDocumentL(TInt /*aErrorCode*/) |
320 void CSBEConfig::OnEndDocumentL(TInt /*aErrorCode*/) |
297 /** |
321 /** |
298 End of document. destroys converter object |
322 End of document. destroys converter object |
299 |
323 |
300 @see MContentHandler::OnEndDocumentL() |
324 @see MContentHandler::OnEndDocumentL() |
301 */ |
325 */ |
302 { |
326 { |
|
327 OstTraceFunctionEntry0( CSBECONFIG_ONENDDOCUMENTL_ENTRY ); |
303 // We've finished parsing the document, hence destroy the converter object |
328 // We've finished parsing the document, hence destroy the converter object |
304 delete iConverter; |
329 delete iConverter; |
305 iConverter = NULL; |
330 iConverter = NULL; |
|
331 OstTraceFunctionExit0( CSBECONFIG_ONENDDOCUMENTL_EXIT ); |
306 } |
332 } |
307 |
333 |
308 void CSBEConfig::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrCode*/) |
334 void CSBEConfig::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt /*aErrCode*/) |
309 /** |
335 /** |
310 Element to parse on the start |
336 Element to parse on the start |
313 |
339 |
314 @param aElement RTagInfo& |
340 @param aElement RTagInfo& |
315 @param aAttributes RAttributeArray& |
341 @param aAttributes RAttributeArray& |
316 */ |
342 */ |
317 { |
343 { |
|
344 OstTraceFunctionEntry0( CSBECONFIG_ONSTARTELEMENTL_ENTRY ); |
318 TInt err = KErrNone; |
345 TInt err = KErrNone; |
319 TPtrC8 localName(aElement.LocalName().DesC()); |
346 TPtrC8 localName(aElement.LocalName().DesC()); |
320 if (!localName.CompareF(KConfig)) |
347 if (!localName.CompareF(KConfig)) |
321 { |
348 { |
322 iConfigTagVisited = ETrue; |
349 iConfigTagVisited = ETrue; |
334 } // else if |
361 } // else if |
335 else |
362 else |
336 { |
363 { |
337 err = KErrCorrupt; |
364 err = KErrCorrupt; |
338 } |
365 } |
339 User::LeaveIfError(err); |
366 LEAVEIFERROR(err, OstTrace1(TRACE_ERROR, CSBECONFIG_ONSTARTELEMENTL, "Leave: %d", err)); |
|
367 OstTraceFunctionExit0( CSBECONFIG_ONSTARTELEMENTL_EXIT ); |
340 } |
368 } |
341 |
369 |
342 void CSBEConfig::OnEndElementL(const RTagInfo& /*aElement*/, TInt /*aErrorCode*/) |
370 void CSBEConfig::OnEndElementL(const RTagInfo& /*aElement*/, TInt /*aErrorCode*/) |
343 /** |
371 /** |
344 Element to parse at the end |
372 Element to parse at the end |