35 #include <xercesc/parsers/XercesDOMParser.hpp> |
35 #include <xercesc/parsers/XercesDOMParser.hpp> |
36 #include <xercesc/sax/ErrorHandler.hpp> |
36 #include <xercesc/sax/ErrorHandler.hpp> |
37 #include <xercesc/dom/DOM.hpp> |
37 #include <xercesc/dom/DOM.hpp> |
38 |
38 |
39 #include "toolsconf.h" |
39 #include "toolsconf.h" |
40 #include "symbiantypes.h" |
|
41 #include "utf8_wrapper.h" |
|
42 |
|
43 // Xerces library uses XMLCh (UTF16 format) as its default character type. |
|
44 // We can store the UTF16 returned form the xerces library in the following |
|
45 // template class. |
|
46 typedef std::basic_string<XMLCh> XercesString; |
|
47 |
|
48 |
40 |
49 /** |
41 /** |
50 * This template is used to cleanup memory by calling a function as pointed |
42 * This template is used to cleanup memory by calling a function as pointed |
51 * by the first parameter as a function parameter. It can be used only used |
43 * by the first parameter as a function parameter. It can be used only used |
52 * with functions which take a pointer to a pointer as an argument. This is |
44 * with functions which take a pointer to a pointer as an argument. This is |
187 :iLocale(0), |
165 :iLocale(0), |
188 iIsIntValue(false), |
166 iIsIntValue(false), |
189 iIsStr8Bit(false) |
167 iIsStr8Bit(false) |
190 {} |
168 {} |
191 |
169 |
192 public: // Member Functions |
170 public: |
193 inline XercesString Name(); |
|
194 inline XercesString Value(); |
|
195 |
|
196 public: // Member variables |
|
197 std::wstring iName; |
171 std::wstring iName; |
198 int iLocale; |
172 int iLocale; |
199 std::wstring iValue; |
173 std::wstring iValue; |
200 bool iIsIntValue; |
174 bool iIsIntValue; |
201 int iIsStr8Bit; |
175 int iIsStr8Bit; |
202 }; // class TComponentProperty |
176 }; |
203 |
177 |
204 class TComponentDependency |
178 class TComponentDependency |
205 { |
179 { |
206 public: |
180 public: |
207 class TComponentDependencyDetail |
181 class TComponentDependencyDetail |
208 { |
182 { |
209 public: // Member Functions |
183 public: |
210 inline XercesString SupplierId(); |
|
211 inline XercesString FromVersion(); |
|
212 inline XercesString ToVersion(); |
|
213 |
|
214 public: // Member Variables |
|
215 std::wstring iSupplierId; |
184 std::wstring iSupplierId; |
216 std::wstring iFromVersion; |
185 std::wstring iFromVersion; |
217 std::wstring iToVersion; |
186 std::wstring iToVersion; |
218 }; // class TComponentDependencyDetail |
187 }; |
219 |
188 |
220 public: // Member Functions |
189 public: |
221 inline XercesString DependentId(); |
|
222 |
|
223 public: // Member Variables |
|
224 std::wstring iDependentId; |
190 std::wstring iDependentId; |
225 std::vector<TComponentDependencyDetail> iComponentDependencyList; |
191 std::vector<TComponentDependencyDetail> iComponentDependencyList; |
226 }; // class TComponentDependency |
192 }; |
227 |
193 |
228 class TComponentFile |
194 class TComponentFile |
229 { |
195 { |
230 public: |
196 public: |
231 TComponentFile() |
197 TComponentFile() |
235 { |
201 { |
236 public: |
202 public: |
237 TFileProperty() |
203 TFileProperty() |
238 :iIsIntValue(false) |
204 :iIsIntValue(false) |
239 {} |
205 {} |
240 public: // Member Functions |
|
241 inline XercesString Name(); |
|
242 inline XercesString Value(); |
|
243 |
|
244 public: // Member Variables |
|
245 std::wstring iName; |
206 std::wstring iName; |
246 std::wstring iValue; |
207 std::wstring iValue; |
247 bool iIsIntValue; |
208 bool iIsIntValue; |
248 }; // struct TFileProperty |
209 }; |
249 |
210 |
250 public: // Member Functions |
|
251 inline XercesString Location(); |
|
252 |
|
253 public: // Member Variables |
|
254 std::wstring iLocation; |
211 std::wstring iLocation; |
255 std::vector<TFileProperty> iFileProperties; |
212 std::vector<TFileProperty> iFileProperties; |
256 |
213 |
257 }; // class TComponentFile |
214 }; |
258 |
215 |
259 class TComponentDetails |
216 class TComponentDetails |
260 { |
217 { |
261 public: |
218 public: |
262 TComponentDetails() |
219 TComponentDetails() |
263 |
220 |
264 :iIsRomApplication(0), |
221 :iIsRemovable(1), |
265 iIsRemovable(1), |
|
266 iSize(0), |
222 iSize(0), |
267 iScomoState(1), |
223 iScomoState(1), |
268 iOriginVerified(1), |
224 iOriginVerified(1), |
269 iIsHidden(0) |
225 iIsHidden(0) |
270 {} |
226 {} |
273 { |
229 { |
274 public: |
230 public: |
275 |
231 |
276 TVersion() |
232 TVersion() |
277 {} |
233 {} |
278 public: |
|
279 inline XercesString MajorVersion(); |
|
280 inline XercesString MinorVersion(); |
|
281 inline XercesString BuildVersion(); |
|
282 |
234 |
283 public: |
235 public: |
284 std::wstring iMajor; |
236 std::wstring iMajor; |
285 std::wstring iMinor; |
237 std::wstring iMinor; |
286 std::wstring iBuild; |
238 std::wstring iBuild; |
287 }; // class TVersion |
239 }; |
288 |
240 |
289 public: // Member Functions |
|
290 inline XercesString GlobalId(); |
|
291 |
|
292 int iIsRomApplication; |
|
293 int iIsRemovable; |
241 int iIsRemovable; |
294 TInt64 iSize; |
242 __int64 iSize; |
295 int iScomoState; |
243 int iScomoState; |
296 std::wstring iGlobalId; |
244 std::wstring iGlobalId; |
297 TVersion iVersion; |
245 TVersion iVersion; |
298 int iOriginVerified; |
246 int iOriginVerified; |
299 int iIsHidden; |
247 int iIsHidden; |
300 }; |
248 }; |
301 |
249 |
302 class TApplicationRegistrationInfo |
|
303 { |
|
304 public: |
|
305 TApplicationRegistrationInfo() |
|
306 {} |
|
307 |
|
308 class TAppAttribute |
|
309 { |
|
310 public: |
|
311 TAppAttribute() |
|
312 :iIsIntValue(false), |
|
313 iIsStr8Bit(false) |
|
314 {} |
|
315 std::wstring iName; |
|
316 std::wstring iValue; |
|
317 bool iIsIntValue; |
|
318 int iIsStr8Bit; |
|
319 }; |
|
320 |
|
321 class TDataType |
|
322 { |
|
323 public: |
|
324 TDataType() |
|
325 {} |
|
326 int iPriority; |
|
327 std::wstring iType; |
|
328 }; |
|
329 |
|
330 class TOpaqueDataType |
|
331 { |
|
332 public: |
|
333 TOpaqueDataType() |
|
334 :iLocale(0), |
|
335 iIsBinary(false) |
|
336 {} |
|
337 int iLocale; |
|
338 int iServiceUid; |
|
339 bool iIsBinary; |
|
340 std::wstring iOpaqueData; |
|
341 }; |
|
342 |
|
343 class TAppServiceInfo |
|
344 { |
|
345 public: |
|
346 TAppServiceInfo() |
|
347 {} |
|
348 int iUid; |
|
349 std::vector<TDataType> iDataType; |
|
350 }; |
|
351 |
|
352 class TAppLocalizableInfo |
|
353 { |
|
354 public: |
|
355 TAppLocalizableInfo() |
|
356 {} |
|
357 |
|
358 class TLocalizableAttribute |
|
359 { |
|
360 public: |
|
361 TLocalizableAttribute() |
|
362 :iIsIntValue(false), |
|
363 iIsStr8Bit(false) |
|
364 {} |
|
365 std::wstring iName; |
|
366 std::wstring iValue; |
|
367 bool iIsIntValue; |
|
368 int iIsStr8Bit; |
|
369 }; |
|
370 |
|
371 class TViewData |
|
372 { |
|
373 public: |
|
374 TViewData() |
|
375 {} |
|
376 |
|
377 class TViewDataAttributes |
|
378 { |
|
379 public: |
|
380 TViewDataAttributes() |
|
381 :iIsIntValue(false), |
|
382 iIsStr8Bit(false) |
|
383 {} |
|
384 std::wstring iName; |
|
385 std::wstring iValue; |
|
386 bool iIsIntValue; |
|
387 int iIsStr8Bit; |
|
388 }; |
|
389 |
|
390 std::vector<TViewDataAttributes> iViewDataAttributes; |
|
391 }; |
|
392 |
|
393 std::vector<TLocalizableAttribute> iLocalizableAttribute; |
|
394 std::vector<TViewData> iViewData; |
|
395 }; |
|
396 |
|
397 class TAppProperty |
|
398 { |
|
399 public: |
|
400 TAppProperty() |
|
401 :iLocale(0), |
|
402 iIntValue(0) |
|
403 {} |
|
404 int iLocale; |
|
405 std::wstring iName; |
|
406 int iServiceUid; |
|
407 int iIntValue; |
|
408 std::wstring iStrValue; |
|
409 bool iIsStr8Bit; |
|
410 }; |
|
411 |
|
412 std::vector<TAppAttribute> iApplicationAttribute; |
|
413 std::vector<std::wstring> iFileOwnershipInfo; |
|
414 std::vector<TAppServiceInfo> iApplicationServiceInfo; |
|
415 std::vector<TAppLocalizableInfo> iApplicationLocalizableInfo; |
|
416 std::vector<TAppProperty> iApplicationProperty; |
|
417 std::vector<TOpaqueDataType> iOpaqueDataType; |
|
418 }; |
|
419 |
|
420 class TComponent |
250 class TComponent |
421 { |
251 { |
422 public: |
252 public: |
423 TComponent() |
253 TComponent() |
424 :iComponentDetails() |
254 :iComponentDetails() |
426 |
256 |
427 std::vector<TComponentLocalizable> iComponentLocalizables; |
257 std::vector<TComponentLocalizable> iComponentLocalizables; |
428 std::vector<TComponentProperty> iComponentProperties; |
258 std::vector<TComponentProperty> iComponentProperties; |
429 std::vector<TComponentFile> iComponentFiles; |
259 std::vector<TComponentFile> iComponentFiles; |
430 TComponentDependency iComponentDependency; |
260 TComponentDependency iComponentDependency; |
431 std::vector<TApplicationRegistrationInfo> iApplicationRegistrationInfo; |
|
432 TComponentDetails iComponentDetails; |
261 TComponentDetails iComponentDetails; |
433 }; // class TComponent |
262 }; |
434 |
|
435 inline XercesString SoftwareTypeName(); |
|
436 |
263 |
437 std::wstring iSoftwareTypeName; |
264 std::wstring iSoftwareTypeName; |
438 std::vector<TComponent> iComponents; |
265 std::vector<TComponent> iComponents; |
439 |
266 |
440 }; // class TScrPreProvisionDetail |
267 }; |
441 } |
268 } |
442 |
269 |
443 class CScrXmlParser |
270 class CScrXmlParser |
444 { |
271 { |
445 |
272 |
487 |
314 |
488 XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty GetFileProperty( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
315 XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty GetFileProperty( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
489 |
316 |
490 XmlDetails::TScrPreProvisionDetail::TComponentDetails GetComponentDetails( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
317 XmlDetails::TScrPreProvisionDetail::TComponentDetails GetComponentDetails( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
491 |
318 |
492 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo GetApplicationRegistrationInfo(const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
493 |
|
494 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppAttribute GetAppAttribute( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
495 |
|
496 std::wstring GetFileOwnershipInfo( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
497 |
|
498 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TDataType GetDataType( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
499 |
|
500 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TOpaqueDataType GetOpaqueDataType( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
501 |
|
502 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TOpaqueDataType GetServiceOpaqueDataType( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
503 |
|
504 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppServiceInfo GetAppServiceInfo( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement, XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo& aAppRegistrationInfo); |
|
505 |
|
506 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo GetAppLocalizableInfo( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
507 |
|
508 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TLocalizableAttribute GetAppLocalizableAttribute( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
509 |
|
510 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TViewData GetAppLocalizableViewData( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
511 |
|
512 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppLocalizableInfo::TViewData::TViewDataAttributes GetAppLocalizableViewDataAttributes( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
513 |
|
514 XmlDetails::TScrPreProvisionDetail::TApplicationRegistrationInfo::TAppProperty GetAppProperty( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
515 |
|
516 XmlDetails::TScrEnvironmentDetails::TLocalizedSoftwareTypeName GetLocalizedSoftwareTypeName( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
319 XmlDetails::TScrEnvironmentDetails::TLocalizedSoftwareTypeName GetLocalizedSoftwareTypeName( const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
517 |
320 |
518 XmlDetails::TScrEnvironmentDetails::TCustomAcessList GetCustomAcessList(const XERCES_CPP_NAMESPACE::DOMElement* aDOMElement); |
|
519 |
|
520 void ConfigDomParser(xercesc::XercesDOMParser& aDomParser); |
321 void ConfigDomParser(xercesc::XercesDOMParser& aDomParser); |
521 }; |
322 }; |
522 |
323 |
523 |
324 |
524 XERCES_CPP_NAMESPACE_BEGIN |
325 XERCES_CPP_NAMESPACE_BEGIN |
555 void resetErrors (); |
356 void resetErrors (); |
556 }; |
357 }; |
557 |
358 |
558 XERCES_CPP_NAMESPACE_END |
359 XERCES_CPP_NAMESPACE_END |
559 |
360 |
560 // inline function definitions |
|
561 |
|
562 #ifndef _WIN32 |
|
563 inline XercesString WStringToXercesString(const std::wstring& aString) |
|
564 { |
|
565 XMLCh* buffer = new XMLCh[ (aString.length() + 1) * 2 ]; |
|
566 XMLCh* temp = buffer; |
|
567 const wchar_t* source = aString.c_str(); |
|
568 |
|
569 ConvertUCS4toUTF16(&source, source + aString.length(), &temp, buffer + aString.length()); |
|
570 |
|
571 // Appending NUL to the converted buffer. |
|
572 *temp = 0; |
|
573 |
|
574 XercesString result(buffer); |
|
575 delete[] buffer; |
|
576 |
|
577 return result; |
|
578 } |
|
579 |
|
580 #else |
|
581 |
|
582 // We need not do anything for WINDOWS, since XercesString |
|
583 // and WString both are same and will be in UTF-16 encoding format. |
|
584 #define WStringToXercesString(aWString) (aWString) |
|
585 |
|
586 #endif // _WIN32 |
|
587 |
|
588 |
|
589 //------------------------------------------------------------------------------------------------------------------------------ |
|
590 // UTILITY FUNCTIONS |
|
591 //------------------------------------------------------------------------------------------------------------------------------ |
|
592 #ifndef _WIN32 |
|
593 |
|
594 inline std::wstring XercesStringToWString(const XercesString& aString) |
|
595 { |
|
596 wchar_t* buffer = new wchar_t[aString.length() + 1]; |
|
597 const XMLCh* source = aString.c_str(); |
|
598 |
|
599 // Using a temp variable in place of buffer as ConvertUTF16toUTF8 modifies the source pointer passed. |
|
600 wchar_t* temp = buffer; |
|
601 |
|
602 ConvertUTF16toUCS4(&source, source + aString.length(), &temp, temp + aString.length()); |
|
603 |
|
604 // Appending NUL to the converted buffer. |
|
605 *temp = 0; |
|
606 |
|
607 std::wstring result(buffer); |
|
608 delete[] buffer; |
|
609 return result; |
|
610 } |
|
611 #else |
|
612 |
|
613 // We need not do anything for WINDOWS, since XercesString |
|
614 // and WString both are same and will be in UTF-16 encoding format. |
|
615 #define XercesStringToWString(aXercesString) (aXercesString) |
|
616 |
|
617 #endif // _WIN32 |
|
618 |
|
619 |
|
620 //------------------------------------------------------------------------------------------------------------------------------ |
|
621 |
|
622 |
|
623 |
|
624 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::MajorVersion() |
|
625 { |
|
626 #ifdef _WIN32 |
|
627 return iMajor; |
|
628 #else |
|
629 return WStringToXercesString(iMajor); |
|
630 #endif // _WIN32 |
|
631 } |
|
632 |
|
633 |
|
634 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::MinorVersion() |
|
635 { |
|
636 #ifdef _WIN32 |
|
637 return iMinor; |
|
638 #else |
|
639 return WStringToXercesString(iMinor); |
|
640 #endif // _WIN32 |
|
641 } |
|
642 |
|
643 |
|
644 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion::BuildVersion() |
|
645 { |
|
646 #ifdef _WIN32 |
|
647 return iBuild; |
|
648 #else |
|
649 return WStringToXercesString(iBuild); |
|
650 #endif // _WIN32 |
|
651 } |
|
652 |
|
653 |
|
654 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDetails::GlobalId() |
|
655 { |
|
656 #ifdef _WIN32 |
|
657 return iGlobalId; |
|
658 #else |
|
659 return WStringToXercesString(iGlobalId); |
|
660 #endif // _WIN32 |
|
661 } |
|
662 |
|
663 |
|
664 inline XercesString XmlDetails::TScrPreProvisionDetail::SoftwareTypeName() |
|
665 { |
|
666 #ifdef _WIN32 |
|
667 return iSoftwareTypeName; |
|
668 #else |
|
669 return WStringToXercesString(iSoftwareTypeName); |
|
670 #endif // _WIN32 |
|
671 } |
|
672 |
|
673 |
|
674 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentLocalizable::Name() |
|
675 { |
|
676 #ifdef _WIN32 |
|
677 return iName; |
|
678 #else |
|
679 return WStringToXercesString(iName); |
|
680 #endif // _WIN32 |
|
681 } |
|
682 |
|
683 |
|
684 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentLocalizable::Vendor() |
|
685 { |
|
686 #ifdef _WIN32 |
|
687 return iVendor; |
|
688 #else |
|
689 return WStringToXercesString(iVendor); |
|
690 #endif // _WIN32 |
|
691 } |
|
692 |
|
693 |
|
694 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentProperty::Name() |
|
695 { |
|
696 #ifdef _WIN32 |
|
697 return iName; |
|
698 #else |
|
699 return WStringToXercesString(iName); |
|
700 #endif // _WIN32 |
|
701 } |
|
702 |
|
703 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentProperty::Value() |
|
704 { |
|
705 #ifdef _WIN32 |
|
706 return iValue; |
|
707 #else |
|
708 return WStringToXercesString(iValue); |
|
709 #endif // _WIN32 |
|
710 } |
|
711 |
|
712 |
|
713 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::Location() |
|
714 { |
|
715 #ifdef _WIN32 |
|
716 return iLocation; |
|
717 #else |
|
718 return WStringToXercesString(iLocation); |
|
719 #endif // _WIN32 |
|
720 } |
|
721 |
|
722 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty::Name() |
|
723 { |
|
724 #ifdef _WIN32 |
|
725 return iName; |
|
726 #else |
|
727 return WStringToXercesString(iName); |
|
728 #endif // _WIN32 |
|
729 } |
|
730 |
|
731 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty::Value() |
|
732 { |
|
733 #ifdef _WIN32 |
|
734 return iValue; |
|
735 #else |
|
736 return WStringToXercesString(iValue); |
|
737 #endif // _WIN32 |
|
738 } |
|
739 |
|
740 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::DependentId() |
|
741 { |
|
742 #ifdef _WIN32 |
|
743 return iDependentId; |
|
744 #else |
|
745 return WStringToXercesString(iDependentId); |
|
746 #endif // _WIN32 |
|
747 } |
|
748 |
|
749 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::SupplierId() |
|
750 { |
|
751 #ifdef _WIN32 |
|
752 return iSupplierId; |
|
753 #else |
|
754 return WStringToXercesString(iSupplierId); |
|
755 #endif // _WIN32 |
|
756 } |
|
757 |
|
758 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::FromVersion() |
|
759 { |
|
760 #ifdef _WIN32 |
|
761 return iFromVersion; |
|
762 #else |
|
763 return WStringToXercesString(iFromVersion); |
|
764 #endif // _WIN32 |
|
765 } |
|
766 |
|
767 inline XercesString XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail::ToVersion() |
|
768 { |
|
769 #ifdef _WIN32 |
|
770 return iToVersion; |
|
771 #else |
|
772 return WStringToXercesString(iToVersion); |
|
773 #endif // _WIN32 |
|
774 } |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 #endif // _XMLPARSER_H |
361 #endif // _XMLPARSER_H |