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 // INCLUDE FILES |
|
20 #include <Xml/Parser.h> |
|
21 #include <Xml/MatchData.h> |
|
22 #include <utf.h> |
|
23 #include <Xml/XmlParserErrors.h> |
|
24 #include <javaregistryincludes.h> |
|
25 |
|
26 // USER INCLUDE |
|
27 #include "lcregistrationparser.h" |
|
28 #include "lcregxmltaginfo.h" |
|
29 #include "lcregxmlparserutils.h" |
|
30 #include "lcregxmltagtype.h" |
|
31 #include "lcregappinfo.h" |
|
32 |
|
33 #include "lcdebug.h" |
|
34 |
|
35 // CONSTANTS |
|
36 /** |
|
37 * Maximum length of UUID of a service can be |
|
38 */ |
|
39 const TInt KUUIDMaxLength = 1028; |
|
40 const TInt KMaxLangCodeLen = 2; |
|
41 |
|
42 |
|
43 // ============================ MEMBER FUNCTIONS =============================== |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CLcRegistrationParser::CLcRegistrationParser |
|
47 // C++ default constructor can NOT contain any code, that |
|
48 // might leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CLcRegistrationParser::CLcRegistrationParser( RFs& aFs ): |
|
52 iFs( aFs ) |
|
53 { |
|
54 iParserError = KErrNone; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CPosLmXmlEncoder::NewL |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CLcRegistrationParser* CLcRegistrationParser::NewL( RFs& aFs ) |
|
63 { |
|
64 CLcRegistrationParser* self = new( ELeave ) CLcRegistrationParser( aFs ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CLcRegistrationParser::~CLcRegistrationParser() |
|
70 // Destructor. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CLcRegistrationParser::~CLcRegistrationParser() |
|
74 { |
|
75 delete iReadContent; |
|
76 |
|
77 iParserTreeTags.Reset(); |
|
78 iParserTreeTags.Close(); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CLcRegistrationParser::ParseFileL |
|
83 // |
|
84 // (other items were commented in a header). |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CLcRegAppInfo* CLcRegistrationParser::ParseFileL( const TDesC& aFile ) |
|
88 { |
|
89 DEBUG("+ CLcRegistrationParser::ParseFileL" ) |
|
90 CLcRegAppInfo* regAppInfo = CLcRegAppInfo::NewL(); |
|
91 CleanupStack::PushL( regAppInfo ); |
|
92 |
|
93 HBufC* attributeBuf = HBufC::NewLC( KUUIDMaxLength ); |
|
94 |
|
95 iRegAppInfo = regAppInfo; |
|
96 iAttributeBuf = attributeBuf; |
|
97 // Check the file name here. |
|
98 if( aFile.Length() <= KMaxFileName ) |
|
99 { |
|
100 iFileName.Copy( aFile ); |
|
101 } |
|
102 else |
|
103 { |
|
104 DEBUG("Error : Bad file name") |
|
105 User::Leave( KErrBadName ); |
|
106 } |
|
107 |
|
108 iParserTreeTags.Reset(); |
|
109 iParsingTag = ELcXmlNothing; |
|
110 iParsedTag = ELcXmlNothing; |
|
111 |
|
112 _LIT8(KXmlMimeType, "text/xml"); |
|
113 |
|
114 // Create Symbian XML parser |
|
115 // Create parser |
|
116 |
|
117 Xml::CParser* iRegParser = Xml::CParser::NewLC( KXmlMimeType, *this ); |
|
118 |
|
119 iRegParser->ParseBeginL(); |
|
120 // check the error code return from the parser |
|
121 |
|
122 Xml::ParseL( *iRegParser, iFs, aFile ); |
|
123 // Leave here if Parser framework found some error |
|
124 User::LeaveIfError( iParserError ); |
|
125 |
|
126 CleanupStack::PopAndDestroy( 2, attributeBuf ); |
|
127 CleanupStack::Pop( regAppInfo ); |
|
128 DEBUG("- CLcRegistrationParser::ParseFileL" ) |
|
129 return regAppInfo; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CLcRegistrationParser::OnStartDocumentL |
|
134 // |
|
135 // (other items were commented in a header). |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CLcRegistrationParser::OnStartDocumentL( |
|
139 const Xml::RDocumentParameters& /*aDocParam*/, |
|
140 TInt /*aErrorCode*/) |
|
141 { |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CLcRegistrationParser::OnEndDocumentL |
|
146 // |
|
147 // (other items were commented in a header). |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CLcRegistrationParser::OnEndDocumentL(TInt /*aErrorCode*/) |
|
151 { |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CLcRegistrationParser::OnStartElementL |
|
156 // |
|
157 // (other items were commented in a header). |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CLcRegistrationParser::OnStartElementL( |
|
161 const Xml::RTagInfo& aElement, |
|
162 const Xml::RAttributeArray& aAttributes, |
|
163 TInt /*aErrorCode*/ ) |
|
164 { |
|
165 DEBUG("+ CLcRegistrationParser::OnStartElementL" ) |
|
166 delete iReadContent; |
|
167 iReadContent = NULL; |
|
168 // get the tag name and validate it |
|
169 TLcRegXmlTagType startTag = |
|
170 TLcRegXmlTagInfo::TagTypeL( aElement.LocalName().DesC() ); |
|
171 |
|
172 if( startTag == ELcXmlUnknown ) |
|
173 { |
|
174 User::Leave( KErrNotSupported ); |
|
175 } |
|
176 |
|
177 SetParserTagL( startTag ); |
|
178 |
|
179 // Check parser status |
|
180 CheckMandatoryTagsL( EXmlParserOnStartElement, startTag ); |
|
181 |
|
182 //Collect attribute value for element |
|
183 CollectAttributeValueL( aElement, aAttributes ); |
|
184 |
|
185 DEBUG("- CLcRegistrationParser::OnStartElementL" ) |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CLcRegistrationParser::SetParserTagL |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CLcRegistrationParser::SetParserTagL( TLcRegXmlTagType aTag ) |
|
193 { |
|
194 DEBUG("+ CLcRegistrationParser::SetParserTagL" ) |
|
195 |
|
196 if( !iParserTreeTags.Count() ) |
|
197 { |
|
198 if( aTag == ELcXmlLocationCentreRegistration ) |
|
199 { |
|
200 iParserTreeTags.Append( aTag ); |
|
201 } |
|
202 else |
|
203 { |
|
204 DEBUG("CLcRegistrationParser::SetParserTagL Not Supported" ) |
|
205 |
|
206 User::Leave( KErrNotSupported ); |
|
207 } |
|
208 } |
|
209 else |
|
210 { |
|
211 if( iParserTreeTags.Find( aTag ) == KErrNotFound ) |
|
212 { |
|
213 User::LeaveIfError( iParserTreeTags.Append( aTag ) ); |
|
214 CheckSequenceOrderL( aTag ); |
|
215 } |
|
216 else |
|
217 { |
|
218 User::Leave( EXmlRecursiveEntity ); |
|
219 } |
|
220 } |
|
221 DEBUG("- CLcRegistrationParser::SetParserTagL" ) |
|
222 } |
|
223 |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CLcRegistrationParser::CheckSequenceOrderL |
|
227 // |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 void CLcRegistrationParser::CheckSequenceOrderL( TLcRegXmlTagType aTag ) |
|
231 { |
|
232 DEBUG("+ CLcRegistrationParser::CheckSequenceOrderL" ) |
|
233 |
|
234 switch ( aTag ) |
|
235 { |
|
236 case ELcXmlLocationCentreRegistration: |
|
237 { |
|
238 if( iParserTreeTags.Count() > 1 ) |
|
239 { |
|
240 User::Leave( KErrNotSupported ); |
|
241 } |
|
242 break; |
|
243 } |
|
244 case ELcXmlService: |
|
245 { |
|
246 if( iParserTreeTags.Count() != 1 && |
|
247 iParserTreeTags.Find( ELcXmlLocationCentreRegistration ) == KErrNotFound ) |
|
248 { |
|
249 User::Leave( KErrNotSupported ); |
|
250 } |
|
251 break; |
|
252 } |
|
253 case ELcXmlRegFileName: |
|
254 case ELcXmlFileIcon: |
|
255 case ELcXmlFeature: |
|
256 case ELcXmlRunMode: |
|
257 case ELcXmlWebService: |
|
258 case ELcXmlDocument: |
|
259 case ELcXmlApplication: |
|
260 { |
|
261 if( iParserTreeTags[1] != ELcXmlService ) |
|
262 { |
|
263 User::Leave( KErrNotSupported ); |
|
264 } |
|
265 break; |
|
266 } |
|
267 case ELcXmlApplicationNative: |
|
268 case ELcXmlApplicationJava: |
|
269 case ELcXmlApplicationParams: |
|
270 { |
|
271 if( iParserTreeTags.Find( ELcXmlApplication ) == KErrNotFound || |
|
272 iParserTreeTags[1] != ELcXmlService |
|
273 ) |
|
274 { |
|
275 User::Leave( KErrNotSupported ); |
|
276 } |
|
277 break; |
|
278 } |
|
279 default: |
|
280 break; |
|
281 } |
|
282 |
|
283 DEBUG("- CLcRegistrationParser::CheckSequenceOrderL" ) |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CLcRegistrationParser::CheckMandatoryTagsL |
|
288 // |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 void CLcRegistrationParser::CheckMandatoryTagsL( |
|
292 TXmlParserElementState aXmlState, |
|
293 TLcRegXmlTagType aTag ) |
|
294 { |
|
295 DEBUG("+ CLcRegistrationParser::CheckMandatoryTagsL" ) |
|
296 |
|
297 if ( aXmlState == EXmlParserOnStartElement ) |
|
298 { |
|
299 switch ( aTag ) |
|
300 { |
|
301 case ELcXmlApplication: |
|
302 { |
|
303 if( iParsedTag != ELcXmlRunMode ) |
|
304 { |
|
305 User::Leave( KErrNotSupported ); |
|
306 } |
|
307 iParsingTag = ELcXmlApplication; |
|
308 } |
|
309 break; |
|
310 case ELcXmlWebService: |
|
311 case ELcXmlDocument: |
|
312 { |
|
313 if( iParsedTag != ELcXmlRunMode ) |
|
314 { |
|
315 User::Leave( KErrNotSupported ); |
|
316 } |
|
317 } |
|
318 break; |
|
319 case ELcXmlApplicationNative: |
|
320 case ELcXmlApplicationJava: |
|
321 case ELcXmlApplicationParams: |
|
322 { |
|
323 if( iParsingTag != ELcXmlApplication ) |
|
324 { |
|
325 User::Leave( KErrNotSupported ); |
|
326 } |
|
327 break; |
|
328 } |
|
329 default: |
|
330 break; |
|
331 } |
|
332 } |
|
333 else |
|
334 { |
|
335 // aXmlState == EXmlParserOnEndElement |
|
336 TInt count = iParserTreeTags.Count(); |
|
337 if( count > 0 ) |
|
338 { |
|
339 switch ( aTag ) |
|
340 { |
|
341 case ELcXmlLocationCentreRegistration: |
|
342 { |
|
343 if( iParsedTag != ELcXmlService ) |
|
344 { |
|
345 User::Leave( KErrNotSupported ); |
|
346 } |
|
347 break; |
|
348 } |
|
349 case ELcXmlService: |
|
350 { |
|
351 if( iParsedTag != ELcXmlApplication ) |
|
352 { |
|
353 if( iParsedTag != ELcXmlDocument ) |
|
354 { |
|
355 if( iParsedTag != ELcXmlWebService ) |
|
356 { |
|
357 User::Leave( KErrNotSupported ); |
|
358 } |
|
359 } |
|
360 } |
|
361 iParsedTag = ELcXmlService; |
|
362 break; |
|
363 } |
|
364 case ELcXmlRunMode: |
|
365 { |
|
366 iParsedTag = ELcXmlRunMode; |
|
367 break; |
|
368 } |
|
369 case ELcXmlWebService: |
|
370 { |
|
371 iParsedTag = ELcXmlWebService; |
|
372 break; |
|
373 } |
|
374 case ELcXmlDocument: |
|
375 { |
|
376 iParsedTag = ELcXmlDocument; |
|
377 break; |
|
378 } |
|
379 case ELcXmlApplication: |
|
380 { |
|
381 iParsedTag = ELcXmlApplication; |
|
382 break; |
|
383 } |
|
384 default: |
|
385 break; |
|
386 } |
|
387 iParserTreeTags.Remove( count-1 ); |
|
388 } |
|
389 } |
|
390 DEBUG("- CLcRegistrationParser::CheckMandatoryTagsL" ) |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CLcRegistrationParser::CheckAndReturnValidAttrL |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 TLcRegXmlTagType CLcRegistrationParser::CheckAndReturnValidAttrL( |
|
398 TLcRegXmlTagType aElement, |
|
399 const Xml::RAttributeArray& aAttributes ) |
|
400 { |
|
401 DEBUG("+ CLcRegistrationParser::CheckAndReturnValidAttrL" ) |
|
402 |
|
403 TInt count( aAttributes.Count() ); |
|
404 switch( aElement ) |
|
405 { |
|
406 case ELcXmlLocationCentreRegistration: |
|
407 case ELcXmlFeature: |
|
408 case ELcXmlApplication: |
|
409 case ELcXmlApplicationParams: |
|
410 { |
|
411 if( count != 0 ) |
|
412 { |
|
413 User::Leave( KErrNotSupported ); |
|
414 } |
|
415 break; |
|
416 } |
|
417 case ELcXmlService: |
|
418 case ELcXmlRegFileName: |
|
419 case ELcXmlRunMode: |
|
420 case ELcXmlWebService: |
|
421 case ELcXmlDocument: |
|
422 case ELcXmlApplicationNative: |
|
423 case ELcXmlApplicationJava: |
|
424 { |
|
425 // If all the above element's doesn't have any attribute |
|
426 // invalid registration file. |
|
427 if( count == 0 || |
|
428 count > 1 ) |
|
429 { |
|
430 User::Leave( KErrNotSupported ); |
|
431 } |
|
432 break; |
|
433 } |
|
434 case ELcXmlFileIcon: |
|
435 { |
|
436 // If all the above element's doesn't have any attribute |
|
437 // invalid registration file. |
|
438 if( count != 2 ) |
|
439 { |
|
440 User::Leave( KErrNotSupported ); |
|
441 } |
|
442 break; |
|
443 } |
|
444 default: |
|
445 break; |
|
446 } |
|
447 |
|
448 // Checking attribute name validity |
|
449 TLcRegXmlTagType tagAttr = ELcXmlUnknown; |
|
450 // validate the attribute name. |
|
451 for( TInt i = 0; i < count; i++ ) |
|
452 { |
|
453 tagAttr = |
|
454 TLcRegXmlTagInfo::TagAttrTypeL( aElement, |
|
455 aAttributes[i].Attribute().LocalName().DesC() ); |
|
456 |
|
457 // Check the tag attribute value |
|
458 // if it is not according to XML schema then it's a invalid registration file |
|
459 if( aElement > ELcXmlApplicationParams && tagAttr == ELcXmlUnknown ) |
|
460 { |
|
461 User::Leave( KErrNotSupported ); |
|
462 } |
|
463 } |
|
464 DEBUG("- CLcRegistrationParser::CheckAndReturnValidAttrL" ) |
|
465 |
|
466 return tagAttr; |
|
467 } |
|
468 |
|
469 // ----------------------------------------------------------------------------- |
|
470 // CLcRegistrationParser::CollectAttributeValueL |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 void CLcRegistrationParser::CollectAttributeValueL( |
|
474 const Xml::RTagInfo& aElement, |
|
475 const Xml::RAttributeArray& aAttributes ) |
|
476 { |
|
477 DEBUG("+ CLcRegistrationParser::CollectAttributeValueL") |
|
478 |
|
479 TInt count( aAttributes.Count() ); |
|
480 TParse parse; |
|
481 TBuf<KMaxFileName> fileName( iFileName ); |
|
482 |
|
483 TLcRegXmlTagType tag = |
|
484 TLcRegXmlTagInfo::TagTypeL( aElement.LocalName().DesC() ); |
|
485 |
|
486 // Check if the element's defiened in XML registration API |
|
487 // schema have any valid attribute if no attribute and attribute |
|
488 // is not valid one then don't registered. |
|
489 TLcRegXmlTagType tagAttr = CheckAndReturnValidAttrL( tag, aAttributes ); |
|
490 |
|
491 DEBUG1(" Tag : %d", tagAttr) |
|
492 |
|
493 // If validity done then collect attributa value |
|
494 switch ( tagAttr ) |
|
495 { |
|
496 case ELcXmlServiceAttrUuid: |
|
497 { |
|
498 TPtrC8 uidValue( aAttributes[0].Value().DesC() ); |
|
499 if( uidValue.Length() > KUUIDMaxLength || |
|
500 uidValue.Length() <= 0 ) |
|
501 { |
|
502 User::Leave( KErrNotSupported ); |
|
503 } |
|
504 iAttributeBuf->Des().Copy( uidValue ); |
|
505 iRegAppInfo->SetIdL( *iAttributeBuf ); |
|
506 } |
|
507 break; |
|
508 case ELcXmlRegFileNameAttrLang: |
|
509 { |
|
510 TPtrC8 langValue( aAttributes[0].Value().DesC() ); |
|
511 if( langValue.Length() > KMaxLangCodeLen ) |
|
512 { |
|
513 User::Leave( KErrNotSupported ); |
|
514 } |
|
515 iAttributeBuf->Des().Copy( langValue ); |
|
516 User::LeaveIfError( iRegAppInfo->SetNameLanguage( *iAttributeBuf ) ); |
|
517 } |
|
518 break; |
|
519 case ELcXmlFileIconAttrfile: |
|
520 case ELcXmlFileIconAttrFrame: |
|
521 { |
|
522 // Set the file name and type |
|
523 for (TInt i = 0; i< count; i++ ) |
|
524 { |
|
525 if( !aAttributes[i].Attribute().LocalName().DesC().Compare( KLcXmlFileIconAttrfile ) ) |
|
526 { |
|
527 TPtrC8 iconfile( aAttributes[i].Value().DesC() ); |
|
528 if( iconfile.Length() > KMaxFileName ) |
|
529 { |
|
530 User::Leave( KErrNotSupported ); |
|
531 } |
|
532 iAttributeBuf->Des().Copy( iconfile ); |
|
533 // Check the drive letter of the document name |
|
534 // if no drive letter then append drive letter of registration file name |
|
535 parse.Set( *iAttributeBuf,NULL,NULL ); |
|
536 if( parse.Drive().Length() == 0 ) |
|
537 { |
|
538 parse.Set(fileName,NULL,NULL); |
|
539 fileName.Zero(); |
|
540 fileName.Append( parse.Drive() ); |
|
541 fileName.Append( *iAttributeBuf ); |
|
542 iAttributeBuf->Des().Copy( fileName ); |
|
543 } |
|
544 iRegAppInfo->SetIconFileL( *iAttributeBuf ); |
|
545 iRegAppInfo->SetIconFileType( CLcAppInfo::EMifFile ); |
|
546 } |
|
547 else if( !aAttributes[i].Attribute().LocalName().DesC().Compare( KLcXmlFileIconAttrFrame ) ) |
|
548 { |
|
549 // Set the frame no. |
|
550 TPtrC8 iconFrame( aAttributes[i].Value().DesC() ); |
|
551 if( iconFrame.Length() > sizeof( TUint32 ) ) |
|
552 { |
|
553 User::Leave( KErrNotSupported ); |
|
554 } |
|
555 iAttributeBuf->Des().Copy( iconFrame ); |
|
556 TLex lexer( *iAttributeBuf ); |
|
557 TUint32 frameNo = 0; |
|
558 TUint limit = 0xFFFFFFFF; |
|
559 User::LeaveIfError( lexer.BoundedVal( frameNo, EHex, limit ) ); |
|
560 iRegAppInfo->SetFrameNo( frameNo ); |
|
561 } |
|
562 else |
|
563 { |
|
564 User::Leave( KErrNotSupported ); |
|
565 } |
|
566 } |
|
567 } |
|
568 break; |
|
569 case ELcXmlRunModeAttrDefault: |
|
570 { |
|
571 TPtrC8 runMode( aAttributes[0].Value().DesC() ); |
|
572 if( runMode.Length() > KLcAppRunModeStandalone.iTypeLength ) |
|
573 { |
|
574 User::Leave( KErrNotSupported ); |
|
575 } |
|
576 iAttributeBuf->Des().Copy( runMode ); |
|
577 if( !iAttributeBuf->Des().Compare( KLcAppRunModeStandalone ) ) |
|
578 { |
|
579 iRegAppInfo->SetLaunchMode( CLcLocationAppInfo::EStandAloneMode ); |
|
580 } |
|
581 else if( !iAttributeBuf->Des().Compare(KLcAppRunModeChild) ) |
|
582 { |
|
583 iRegAppInfo->SetLaunchMode( CLcLocationAppInfo::EChainedMode ); |
|
584 } |
|
585 else |
|
586 { |
|
587 User::Leave( KErrNotSupported ); |
|
588 } |
|
589 } |
|
590 break; |
|
591 case ELcXmlApplicationNativeAttrSid: |
|
592 { |
|
593 TPtrC8 appSid( aAttributes[0].Value().DesC() ); |
|
594 // length must be greater than zero |
|
595 if( appSid.Length() <= 0 ) |
|
596 { |
|
597 User::Leave( KErrNotSupported ); |
|
598 } |
|
599 // Check if the SID is in [SID] format. |
|
600 // If it is then remove the '[' and ']' from it. |
|
601 if( appSid[0] == '[' && |
|
602 appSid[appSid.Length() - 1 ] == ']' ) |
|
603 { |
|
604 // Check SID length.If it is zero or |
|
605 // greater then 10(because sid is 8 and then |
|
606 // two angle brackets equals to 10) dont't registered |
|
607 if( appSid.Length() > 10 ) |
|
608 { |
|
609 User::Leave( KErrNotSupported ); |
|
610 } |
|
611 iAttributeBuf->Des().Zero(); |
|
612 for(TInt i = 0; i < appSid.Length() - 2; i++ ) |
|
613 { |
|
614 iAttributeBuf->Des().Append( appSid[i+1] ); |
|
615 } |
|
616 } |
|
617 else |
|
618 { |
|
619 User::Leave( KErrNotSupported ); |
|
620 } |
|
621 iRegAppInfo->SetApplicationDataL( *iAttributeBuf ); |
|
622 iRegAppInfo->SetApplicationType( ELcNativeApplication ); |
|
623 } |
|
624 break; |
|
625 case ELcXmlApplicationJavaAttrName: |
|
626 { |
|
627 |
|
628 |
|
629 // Obtain the UID corresponding to the Java Application |
|
630 // Midlet name. |
|
631 TPtrC8 javaName( aAttributes[0].Value().DesC() ); |
|
632 if( javaName.Length() > KUUIDMaxLength ) |
|
633 { |
|
634 User::Leave( KErrNotSupported ); |
|
635 } |
|
636 iAttributeBuf->Des().Copy(javaName); |
|
637 iAttributeBuf->Des().Format(_L("%x"), JavaAppUidL( *iAttributeBuf ) ); |
|
638 |
|
639 iRegAppInfo->SetApplicationDataL( *iAttributeBuf ); |
|
640 iRegAppInfo->SetApplicationType(ELcNativeApplication); |
|
641 |
|
642 |
|
643 } |
|
644 break; |
|
645 case ELcXmlWebServiceAttrUrl: |
|
646 { |
|
647 TPtrC8 webUri( aAttributes[0].Value().DesC() ); |
|
648 if( webUri.Length() > KUUIDMaxLength ) |
|
649 { |
|
650 User::Leave( KErrNotSupported ); |
|
651 } |
|
652 iAttributeBuf->Des().Copy( webUri ); |
|
653 iRegAppInfo->SetApplicationDataL( *iAttributeBuf ); |
|
654 iRegAppInfo->SetApplicationType( ELcWebUrl ); |
|
655 } |
|
656 break; |
|
657 case ELcXmlDocumentAttrFile: |
|
658 { |
|
659 TPtrC8 docFile( aAttributes[0].Value().DesC() ); |
|
660 if( docFile.Length() > KMaxFileName ) |
|
661 { |
|
662 User::Leave( KErrNotSupported ); |
|
663 } |
|
664 iAttributeBuf->Des().Copy( docFile ); |
|
665 // Check the drive letter of the document name |
|
666 // if no drive letter then append drive letter of registration file name |
|
667 parse.Set( *iAttributeBuf,NULL,NULL ); |
|
668 if( parse.Drive().Length() == 0 ) |
|
669 { |
|
670 parse.Set(fileName,NULL,NULL); |
|
671 fileName.Zero(); |
|
672 fileName.Append( parse.Drive() ); |
|
673 fileName.Append( *iAttributeBuf ); |
|
674 iAttributeBuf->Des().Copy( fileName ); |
|
675 } |
|
676 iRegAppInfo->SetApplicationDataL( *iAttributeBuf ); |
|
677 iRegAppInfo->SetApplicationType( ELcDocument ); |
|
678 } |
|
679 break; |
|
680 default: |
|
681 break; |
|
682 } |
|
683 |
|
684 DEBUG("- CLcRegistrationParser::CollectAttributeValueL") |
|
685 } |
|
686 |
|
687 // --------------------------------------------------------------------------- |
|
688 // void CLcRegistrationParser::JavaAppUidL |
|
689 // --------------------------------------------------------------------------- |
|
690 // |
|
691 TUint32 CLcRegistrationParser::JavaAppUidL( const TDesC& aMidletName ) |
|
692 { |
|
693 TUint32 uidValue = 0; |
|
694 DEBUG("+ CLcRegistrationParser::JavaAppUidL") |
|
695 |
|
696 // Create a new Registry class |
|
697 Java::CJavaRegistry* registry = Java::CJavaRegistry::NewLC(); |
|
698 |
|
699 // Obtain all the UIDs and check if the required UID corresponding |
|
700 // to the Midlet name exists |
|
701 RArray<TUid> uidArray; |
|
702 CleanupClosePushL( uidArray ); |
|
703 registry->GetRegistryEntryUidsL( uidArray ); |
|
704 |
|
705 for( TInt i = 0; i < uidArray.Count(); i++ ) |
|
706 { |
|
707 // Obtain the Registry entry corresponding to the current UID |
|
708 Java::CJavaRegistryEntry* registryEntry = registry->RegistryEntryL( uidArray[i]); |
|
709 if( registryEntry ) |
|
710 { |
|
711 if ( !aMidletName.Compare( registryEntry->Name() ) ) |
|
712 { |
|
713 uidValue = ( registryEntry->Uid().iUid ); |
|
714 delete registryEntry; |
|
715 break; |
|
716 } |
|
717 } |
|
718 delete registryEntry; |
|
719 } |
|
720 |
|
721 CleanupStack::PopAndDestroy( 2, registry ); // uidArray |
|
722 DEBUG1("UID %d", uidValue) |
|
723 DEBUG("- CLcRegistrationParser::JavaAppUidL") |
|
724 return uidValue; |
|
725 } |
|
726 |
|
727 // ----------------------------------------------------------------------------- |
|
728 // CLcRegistrationParser::OnEndElementL |
|
729 // |
|
730 // (other items were commented in a header). |
|
731 // ----------------------------------------------------------------------------- |
|
732 // |
|
733 void CLcRegistrationParser::OnEndElementL( |
|
734 const Xml::RTagInfo& aElement, |
|
735 TInt /*aErrorCode*/ ) |
|
736 { |
|
737 DEBUG("+ CLcRegistrationParser::OnEndElementL" ) |
|
738 |
|
739 // End element |
|
740 TLcRegXmlTagType endTag = |
|
741 TLcRegXmlTagInfo::TagTypeL( aElement.LocalName().DesC() ); |
|
742 |
|
743 if( endTag == ELcXmlUnknown ) |
|
744 { |
|
745 User::Leave( KErrNotSupported ); |
|
746 } |
|
747 // Check parser status |
|
748 CheckMandatoryTagsL( EXmlParserOnEndElement, endTag ); |
|
749 |
|
750 // Read property/content for end element |
|
751 if (iReadContent) |
|
752 { |
|
753 HBufC* content = HBufC::NewLC( iReadContent->Length() ); |
|
754 TPtr16 ptr = content->Des(); |
|
755 |
|
756 // Convert property/content |
|
757 LcRegXmlParserUtils::Utf8ToUnicodeL( *iReadContent, ptr ); |
|
758 |
|
759 // Set content on appinfo related objects and parser status |
|
760 SetContentL( endTag, *content ); |
|
761 |
|
762 // Reset/delete read/converted content |
|
763 CleanupStack::PopAndDestroy( content ); |
|
764 |
|
765 delete iReadContent; |
|
766 iReadContent = NULL; |
|
767 } |
|
768 |
|
769 DEBUG("- CLcRegistrationParser::OnEndElementL" ) |
|
770 } |
|
771 // ----------------------------------------------------------------------------- |
|
772 // CLcRegistrationParser::SetContentL |
|
773 // |
|
774 // (other items were commented in a header). |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 void CLcRegistrationParser::SetContentL( |
|
778 TLcRegXmlTagType aTag, |
|
779 const TDesC& aContent ) |
|
780 { |
|
781 DEBUG("+ CLcRegistrationParser::SetContentL" ) |
|
782 |
|
783 switch( aTag ) |
|
784 { |
|
785 case ELcXmlRegFileName: |
|
786 { |
|
787 iRegAppInfo->SetAppNameL( aContent ); |
|
788 break; |
|
789 } |
|
790 case ELcXmlFeature: |
|
791 { |
|
792 if( !aContent.Compare( KLcAppCharSettings ) ) |
|
793 { |
|
794 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharSettings ); |
|
795 } |
|
796 else if( !aContent.Compare( KLcAppCharPersonalData ) ) |
|
797 { |
|
798 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharPersonalDataManagement ); |
|
799 } |
|
800 else if( !aContent.Compare( KLcAppCharNavigation ) ) |
|
801 { |
|
802 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharNavigation ); |
|
803 } |
|
804 else if( !aContent.Compare( KLcAppCharMaps ) ) |
|
805 { |
|
806 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharMaps ); |
|
807 } |
|
808 else if( !aContent.Compare( KLcAppCharLocationEvents ) ) |
|
809 { |
|
810 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharLocationBasedEvents ); |
|
811 } |
|
812 else if( !aContent.Compare( KLcAppCharRemotePositioning ) ) |
|
813 { |
|
814 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharRemotePositioning ); |
|
815 } |
|
816 else if( !aContent.Compare( KLcAppCharNetworkService ) ) |
|
817 { |
|
818 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharNetworkService ); |
|
819 } |
|
820 else if( !aContent.Compare( KLcAppCharLocationMessaging ) ) |
|
821 { |
|
822 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharLocationEnhancedMessages ); |
|
823 } |
|
824 else if( !aContent.Compare( KLcAppCharLocalContent ) ) |
|
825 { |
|
826 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharOnDeviceLocationBasedContent ); |
|
827 } |
|
828 else if( !aContent.Compare( KLcAppCharRemoteContent ) ) |
|
829 { |
|
830 iRegAppInfo->SetApplicationCharacteristics( CLcLocationAppInfo::EAppCharRemoteLocationBasedContent ); |
|
831 } |
|
832 else |
|
833 { |
|
834 User::Leave( KErrNotSupported ); |
|
835 } |
|
836 break; |
|
837 } |
|
838 case ELcXmlApplicationParams: |
|
839 { |
|
840 iRegAppInfo->SetCommandLineParametersL( aContent ); |
|
841 break; |
|
842 } |
|
843 default: |
|
844 break; |
|
845 } |
|
846 |
|
847 DEBUG("- CLcRegistrationParser::SetContentL" ) |
|
848 } |
|
849 |
|
850 // ----------------------------------------------------------------------------- |
|
851 // CLcRegistrationParser::OnContentL |
|
852 // |
|
853 // (other items were commented in a header). |
|
854 // ----------------------------------------------------------------------------- |
|
855 // |
|
856 void CLcRegistrationParser::OnContentL( |
|
857 const TDesC8& aBytes, TInt /*aErrorCode*/ ) |
|
858 { |
|
859 DEBUG("+ CLcRegistrationParser::OnContentL") |
|
860 // If there are content from a previous parsing |
|
861 // then we need to concatenate data/strings. |
|
862 if (iReadContent) |
|
863 { |
|
864 HBufC8* prevContent = iReadContent; |
|
865 CleanupStack::PushL( prevContent ); |
|
866 iReadContent = NULL; |
|
867 |
|
868 iReadContent = HBufC8::NewL( prevContent->Length() + aBytes.Length() ); |
|
869 iReadContent->Des().Append( *prevContent ); |
|
870 iReadContent->Des().Append( aBytes ); |
|
871 CleanupStack::PopAndDestroy( prevContent ); |
|
872 } |
|
873 else |
|
874 { |
|
875 iReadContent = aBytes.AllocL(); |
|
876 } |
|
877 DEBUG("- CLcRegistrationParser::OnContentL") |
|
878 } |
|
879 |
|
880 // ----------------------------------------------------------------------------- |
|
881 // CLcRegistrationParser::OnStartPrefixMappingL |
|
882 // |
|
883 // (other items were commented in a header). |
|
884 // ----------------------------------------------------------------------------- |
|
885 // |
|
886 void CLcRegistrationParser::OnStartPrefixMappingL( |
|
887 const RString& /*aPrefix*/, |
|
888 const RString& /*aUri*/, |
|
889 TInt /*aErrorCode*/ ) |
|
890 { |
|
891 } |
|
892 |
|
893 // ----------------------------------------------------------------------------- |
|
894 // CLcRegistrationParser::OnEndPrefixMappingL |
|
895 // |
|
896 // (other items were commented in a header). |
|
897 // ----------------------------------------------------------------------------- |
|
898 // |
|
899 void CLcRegistrationParser::OnEndPrefixMappingL( |
|
900 const RString& /*aPrefix*/, TInt /*aErrorCode*/ ) |
|
901 { |
|
902 } |
|
903 |
|
904 // ----------------------------------------------------------------------------- |
|
905 // CLcRegistrationParser::OnIgnorableWhiteSpaceL |
|
906 // |
|
907 // (other items were commented in a header). |
|
908 // ----------------------------------------------------------------------------- |
|
909 // |
|
910 void CLcRegistrationParser::OnIgnorableWhiteSpaceL( |
|
911 const TDesC8& /*aBytes*/, TInt /*aErrorCode*/ ) |
|
912 { |
|
913 } |
|
914 |
|
915 // ----------------------------------------------------------------------------- |
|
916 // CLcRegistrationParser::OnSkippedEntityL |
|
917 // |
|
918 // (other items were commented in a header). |
|
919 // ----------------------------------------------------------------------------- |
|
920 // |
|
921 void CLcRegistrationParser::OnSkippedEntityL( |
|
922 const RString& /*aName*/, TInt /*aErrorCode*/ ) |
|
923 { |
|
924 } |
|
925 |
|
926 // ----------------------------------------------------------------------------- |
|
927 // CLcRegistrationParser::OnProcessingInstructionL |
|
928 // |
|
929 // (other items were commented in a header). |
|
930 // ----------------------------------------------------------------------------- |
|
931 // |
|
932 void CLcRegistrationParser::OnProcessingInstructionL( |
|
933 const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, |
|
934 TInt /*aErrorCode*/ ) |
|
935 { |
|
936 } |
|
937 |
|
938 // ----------------------------------------------------------------------------- |
|
939 // CLcRegistrationParser::OnOutOfData |
|
940 // |
|
941 // (other items were commented in a header). |
|
942 // ----------------------------------------------------------------------------- |
|
943 // |
|
944 void CLcRegistrationParser::OnOutOfData() |
|
945 { |
|
946 } |
|
947 |
|
948 // ----------------------------------------------------------------------------- |
|
949 // CLcRegistrationParser::OnError |
|
950 // |
|
951 // (other items were commented in a header). |
|
952 // ----------------------------------------------------------------------------- |
|
953 // |
|
954 void CLcRegistrationParser::OnError( TInt aErrorCode ) |
|
955 { |
|
956 iParserError = aErrorCode; |
|
957 } |
|
958 |
|
959 // ----------------------------------------------------------------------------- |
|
960 // CLcRegistrationParser::GetExtendedInterface |
|
961 // |
|
962 // (other items were commented in a header). |
|
963 // ----------------------------------------------------------------------------- |
|
964 // |
|
965 TAny* CLcRegistrationParser::GetExtendedInterface( const TInt32 /*aUid*/ ) |
|
966 { |
|
967 return NULL; |
|
968 } |
|
969 |
|
970 // End of File |
|