52 _LIT( KXmlDataTypeBool, "bool" ); |
52 _LIT( KXmlDataTypeBool, "bool" ); |
53 _LIT( KXmlDataTypeInt, "int" ); |
53 _LIT( KXmlDataTypeInt, "int" ); |
54 _LIT( KXmlDataTypeString, "string" ); |
54 _LIT( KXmlDataTypeString, "string" ); |
55 _LIT( KXmlDataTypeUid, "uid" ); |
55 _LIT( KXmlDataTypeUid, "uid" ); |
56 |
56 |
|
57 static const TInt KWidgetPropertyListVersion32 = 1; |
|
58 static const TInt KWidgetPropertyListVersion71 = 3; |
57 // MODULE DATA STRUCTURES |
59 // MODULE DATA STRUCTURES |
58 |
60 |
59 // LOCAL FUNCTION PROTOTYPES |
61 // LOCAL FUNCTION PROTOTYPES |
60 |
62 |
61 // FORWARD DECLARATIONS |
63 // FORWARD DECLARATIONS |
163 // read what should be EWidgetPropertyListVersion |
165 // read what should be EWidgetPropertyListVersion |
164 (*this)[0].DeserializeL( aReadStream ); |
166 (*this)[0].DeserializeL( aReadStream ); |
165 |
167 |
166 // For now, leave if version doesn't match compiled-in version, |
168 // For now, leave if version doesn't match compiled-in version, |
167 // FUTURE do something smarter |
169 // FUTURE do something smarter |
|
170 //WIDGETPROPERTYLISTVERSION is 1 in case of Tiger engine and 3 in case of Leopard engine. Therefore, modifying the check such that |
|
171 //when the Version id is 1 or 3, we do not treat the file as corrupt. |
168 if ( ( EWidgetPropTypeUnknown == (*this)[EWidgetPropertyListVersion].iType ) |
172 if ( ( EWidgetPropTypeUnknown == (*this)[EWidgetPropertyListVersion].iType ) |
169 || ( WIDGETPROPERTYLISTVERSION != (*this)[EWidgetPropertyListVersion] ) ) |
173 || ( (KWidgetPropertyListVersion32 != (*this)[EWidgetPropertyListVersion] ) && (KWidgetPropertyListVersion71 != (*this)[EWidgetPropertyListVersion] )) ) |
170 { |
174 { |
171 User::Leave( KErrCorrupt ); |
175 User::Leave( KErrCorrupt ); |
172 } |
176 } |
173 |
177 |
174 // fill property values array |
178 // fill property values array |
433 str.AppendFormat( _L("%d"), k ); |
437 str.AppendFormat( _L("%d"), k ); |
434 } |
438 } |
435 break; |
439 break; |
436 case EWidgetPropTypeString: |
440 case EWidgetPropTypeString: |
437 { |
441 { |
438 str.Append( (*this)[i] ); |
442 // start an encoding process for special characters for xml writing |
439 } |
443 // the special characters are: |
440 break; |
444 // '&', Ampersand: & |
|
445 // '>', greater-than: > |
|
446 // '<', less-than: < |
|
447 // ''', apostrophe: ' |
|
448 // '"', quote: " |
|
449 |
|
450 TBuf<KMaxFileName> orig; |
|
451 orig.Append((*this)[i]); |
|
452 TUint16 * cur = (TUint16 *)orig.Ptr(); |
|
453 TUint16 * out = (TUint16 *)str.Ptr(); |
|
454 TInt len = orig.Length(); |
|
455 for ( TInt i = 0; i < orig.Length(); i++, cur++ ) |
|
456 { |
|
457 // By default one have to encode at least '<', '>', '"' and '&' ! |
|
458 if (*cur == '<') { |
|
459 *out++ = '&'; |
|
460 *out++ = 'l'; |
|
461 *out++ = 't'; |
|
462 *out++ = ';'; |
|
463 len += 3; |
|
464 } else if (*cur == '>') { |
|
465 *out++ = '&'; |
|
466 *out++ = 'g'; |
|
467 *out++ = 't'; |
|
468 *out++ = ';'; |
|
469 len += 3; |
|
470 } else if (*cur == '&') { |
|
471 *out++ = '&'; |
|
472 *out++ = 'a'; |
|
473 *out++ = 'm'; |
|
474 *out++ = 'p'; |
|
475 *out++ = ';'; |
|
476 len += 4; |
|
477 } else if (*cur == '"') { |
|
478 *out++ = '&'; |
|
479 *out++ = 'q'; |
|
480 *out++ = 'u'; |
|
481 *out++ = 'o'; |
|
482 *out++ = 't'; |
|
483 *out++ = ';'; |
|
484 len += 5; |
|
485 } else if (*cur == '\'') { |
|
486 *out++ = '&'; |
|
487 *out++ = 'a'; |
|
488 *out++ = 'p'; |
|
489 *out++ = 'o'; |
|
490 *out++ = 's'; |
|
491 *out++ = ';'; |
|
492 len += 5; |
|
493 } else if (*cur == '\r') { |
|
494 *out++ = '&'; |
|
495 *out++ = '#'; |
|
496 *out++ = '1'; |
|
497 *out++ = '3'; |
|
498 *out++ = ';'; |
|
499 len += 4; |
|
500 } else { |
|
501 *out++ = *cur; |
|
502 } |
|
503 } |
|
504 str.SetLength(len ); |
|
505 break; |
|
506 } |
441 case EWidgetPropTypeUid: |
507 case EWidgetPropTypeUid: |
442 const TUid& u = (*this)[i]; |
508 const TUid& u = (*this)[i]; |
443 TInt l = u.iUid; |
509 TInt l = u.iUid; |
444 str.AppendFormat( _L("%d"), l ); |
510 str.AppendFormat( _L("%d"), l ); |
445 break; |
511 break; |