summaryrefslogtreecommitdiff
authoreilers <eilers>2005-02-03 10:05:00 (UTC)
committer eilers <eilers>2005-02-03 10:05:00 (UTC)
commit9424f9fa34e458c90b5f9bbe2a88074cd9a1161c (patch) (unidiff)
treea4d94b096a82f49e8b6d4766cc4cae3763350d19
parent2ed3b823bdcb473dca8a809b939c5d7d282b70bb (diff)
downloadopie-9424f9fa34e458c90b5f9bbe2a88074cd9a1161c.zip
opie-9424f9fa34e458c90b5f9bbe2a88074cd9a1161c.tar.gz
opie-9424f9fa34e458c90b5f9bbe2a88074cd9a1161c.tar.bz2
Fixing bug #1236: VCARD contained empty WORK and HOME addressfields..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index f3b6d56..0ffbb67 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -407,124 +407,136 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
407 else { 407 else {
408 printf("Name: %s, value=%s\n", name.data(), QString::fromUtf8( vObjectStringZValue( o ) ) ); 408 printf("Name: %s, value=%s\n", name.data(), QString::fromUtf8( vObjectStringZValue( o ) ) );
409 VObjectIterator nit; 409 VObjectIterator nit;
410 initPropIterator( &nit, o ); 410 initPropIterator( &nit, o );
411 while( moreIteration( &nit ) ) { 411 while( moreIteration( &nit ) ) {
412 VObject *o = nextVObject( &nit ); 412 VObject *o = nextVObject( &nit );
413 QCString name = vObjectName( o ); 413 QCString name = vObjectName( o );
414 QString value = QString::fromUtf8( vObjectStringZValue( o ) ); 414 QString value = QString::fromUtf8( vObjectStringZValue( o ) );
415 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 415 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
416 } 416 }
417 } 417 }
418 else { 418 else {
419 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 419 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
420 VObjectIterator nit; 420 VObjectIterator nit;
421 initPropIterator( &nit, o ); 421 initPropIterator( &nit, o );
422 while( moreIteration( &nit ) ) { 422 while( moreIteration( &nit ) ) {
423 VObject *o = nextVObject( &nit ); 423 VObject *o = nextVObject( &nit );
424 QCString name = vObjectName( o ); 424 QCString name = vObjectName( o );
425 QString value = vObjectStringZValue( o ); 425 QString value = vObjectStringZValue( o );
426 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 426 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
427 } 427 }
428 } 428 }
429#endif 429#endif
430 } 430 }
431 c.setFileAs(); 431 c.setFileAs();
432 return c; 432 return c;
433} 433}
434 434
435 435
436VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c ) 436VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
437{ 437{
438 VObject *vcard = newVObject( VCCardProp ); 438 VObject *vcard = newVObject( VCCardProp );
439 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 439 safeAddPropValue( vcard, VCVersionProp, "2.1" );
440 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 440 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
441 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 441 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
442 442
443 // full name 443 // full name
444 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 444 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
445 445
446 // name properties 446 // name properties
447 VObject *name = safeAddProp( vcard, VCNameProp ); 447 VObject *name = safeAddProp( vcard, VCNameProp );
448 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 448 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
449 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 449 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
450 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 450 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
451 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 451 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
452 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 452 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
453 453
454 // home properties 454 // home properties
455 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 455 if ( !( c.homeStreet().isEmpty()
456 safeAddProp( home_adr, VCHomeProp ); 456 && c.homeCity().isEmpty()
457 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 457 && c.homeState().isEmpty()
458 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 458 && c.homeZip().isEmpty()
459 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 459 && c.homeCountry().isEmpty() ) ){
460 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 460 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
461 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 461 safeAddProp( home_adr, VCHomeProp );
462 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
463 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
464 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
465 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
466 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
467 }
462 468
463 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 469 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
464 safeAddProp( home_phone, VCHomeProp ); 470 safeAddProp( home_phone, VCHomeProp );
465 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 471 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
466 safeAddProp( home_phone, VCHomeProp ); 472 safeAddProp( home_phone, VCHomeProp );
467 safeAddProp( home_phone, VCCellularProp ); 473 safeAddProp( home_phone, VCCellularProp );
468 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 474 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
469 safeAddProp( home_phone, VCHomeProp ); 475 safeAddProp( home_phone, VCHomeProp );
470 safeAddProp( home_phone, VCFaxProp ); 476 safeAddProp( home_phone, VCFaxProp );
471 477
472 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 478 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
473 safeAddProp( url, VCHomeProp ); 479 safeAddProp( url, VCHomeProp );
474 480
475 // work properties 481 // work properties
476 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 482 if ( !( c.businessStreet().isEmpty()
477 safeAddProp( work_adr, VCWorkProp ); 483 && c.businessCity().isEmpty()
478 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 484 && c.businessState().isEmpty()
479 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 485 && c.businessZip().isEmpty()
480 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 486 && c.businessCountry().isEmpty() ) ){
481 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 487 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
482 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 488 safeAddProp( work_adr, VCWorkProp );
489 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
490 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
491 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
492 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
493 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
494 }
483 495
484 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 496 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
485 safeAddProp( work_phone, VCWorkProp ); 497 safeAddProp( work_phone, VCWorkProp );
486 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 498 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
487 safeAddProp( work_phone, VCWorkProp ); 499 safeAddProp( work_phone, VCWorkProp );
488 safeAddProp( work_phone, VCCellularProp ); 500 safeAddProp( work_phone, VCCellularProp );
489 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 501 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
490 safeAddProp( work_phone, VCWorkProp ); 502 safeAddProp( work_phone, VCWorkProp );
491 safeAddProp( work_phone, VCFaxProp ); 503 safeAddProp( work_phone, VCFaxProp );
492 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 504 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
493 safeAddProp( work_phone, VCWorkProp ); 505 safeAddProp( work_phone, VCWorkProp );
494 safeAddProp( work_phone, VCPagerProp ); 506 safeAddProp( work_phone, VCPagerProp );
495 507
496 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 508 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
497 safeAddProp( url, VCWorkProp ); 509 safeAddProp( url, VCWorkProp );
498 510
499 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 511 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
500 safeAddProp( title, VCWorkProp ); 512 safeAddProp( title, VCWorkProp );
501 513
502 514
503 QStringList emails = c.emailList(); 515 QStringList emails = c.emailList();
504 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 516 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
505 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 517 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
506 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 518 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
507 safeAddProp( email, VCInternetProp ); 519 safeAddProp( email, VCInternetProp );
508 } 520 }
509 521
510 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 522 safeAddPropValue( vcard, VCNoteProp, c.notes() );
511 523
512 // Exporting Birthday regarding RFC 2425 (5.8.4) 524 // Exporting Birthday regarding RFC 2425 (5.8.4)
513 if ( c.birthday().isValid() ){ 525 if ( c.birthday().isValid() ){
514 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 526 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
515 } 527 }
516 528
517 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 529 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
518 VObject *org = safeAddProp( vcard, VCOrgProp ); 530 VObject *org = safeAddProp( vcard, VCOrgProp );
519 safeAddPropValue( org, VCOrgNameProp, c.company() ); 531 safeAddPropValue( org, VCOrgNameProp, c.company() );
520 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 532 safeAddPropValue( org, VCOrgUnitProp, c.department() );
521 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 533 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
522 } 534 }
523 535
524 // some values we have to export as custom fields 536 // some values we have to export as custom fields
525 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 537 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
526 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 538 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
527 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 539 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
528 540
529 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 541 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
530 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 542 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );