author | eilers <eilers> | 2005-02-03 10:05:00 (UTC) |
---|---|---|
committer | eilers <eilers> | 2005-02-03 10:05:00 (UTC) |
commit | 9424f9fa34e458c90b5f9bbe2a88074cd9a1161c (patch) (side-by-side diff) | |
tree | a4d94b096a82f49e8b6d4766cc4cae3763350d19 | |
parent | 2ed3b823bdcb473dca8a809b939c5d7d282b70bb (diff) | |
download | opie-9424f9fa34e458c90b5f9bbe2a88074cd9a1161c.zip opie-9424f9fa34e458c90b5f9bbe2a88074cd9a1161c.tar.gz opie-9424f9fa34e458c90b5f9bbe2a88074cd9a1161c.tar.bz2 |
Fixing bug #1236: VCARD contained empty WORK and HOME addressfields..
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | 40 |
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 ) else { printf("Name: %s, value=%s\n", name.data(), QString::fromUtf8( vObjectStringZValue( o ) ) ); VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = QString::fromUtf8( vObjectStringZValue( o ) ); printf(" subprop: %s = %s\n", name.data(), value.latin1() ); } } else { printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); printf(" subprop: %s = %s\n", name.data(), value.latin1() ); } } #endif } c.setFileAs(); return c; } VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c ) { VObject *vcard = newVObject( VCCardProp ); safeAddPropValue( vcard, VCVersionProp, "2.1" ); safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); // full name safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); // name properties VObject *name = safeAddProp( vcard, VCNameProp ); safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); safeAddPropValue( name, VCGivenNameProp, c.firstName() ); safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); safeAddPropValue( name, VCNamePrefixesProp, c.title() ); safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); // home properties - VObject *home_adr= safeAddProp( vcard, VCAdrProp ); - safeAddProp( home_adr, VCHomeProp ); - safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); - safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); - safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); - safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); - safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); + if ( !( c.homeStreet().isEmpty() + && c.homeCity().isEmpty() + && c.homeState().isEmpty() + && c.homeZip().isEmpty() + && c.homeCountry().isEmpty() ) ){ + VObject *home_adr= safeAddProp( vcard, VCAdrProp ); + safeAddProp( home_adr, VCHomeProp ); + safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); + safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); + safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); + safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); + safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); + } VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); safeAddProp( home_phone, VCHomeProp ); home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); safeAddProp( home_phone, VCHomeProp ); safeAddProp( home_phone, VCCellularProp ); home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); safeAddProp( home_phone, VCHomeProp ); safeAddProp( home_phone, VCFaxProp ); VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); safeAddProp( url, VCHomeProp ); // work properties - VObject *work_adr= safeAddProp( vcard, VCAdrProp ); - safeAddProp( work_adr, VCWorkProp ); - safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); - safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); - safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); - safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); - safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); + if ( !( c.businessStreet().isEmpty() + && c.businessCity().isEmpty() + && c.businessState().isEmpty() + && c.businessZip().isEmpty() + && c.businessCountry().isEmpty() ) ){ + VObject *work_adr= safeAddProp( vcard, VCAdrProp ); + safeAddProp( work_adr, VCWorkProp ); + safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); + safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); + safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); + safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); + safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); + } VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); safeAddProp( work_phone, VCWorkProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCCellularProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCFaxProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCPagerProp ); url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); safeAddProp( url, VCWorkProp ); VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); safeAddProp( title, VCWorkProp ); QStringList emails = c.emailList(); // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); safeAddProp( email, VCInternetProp ); } safeAddPropValue( vcard, VCNoteProp, c.notes() ); // Exporting Birthday regarding RFC 2425 (5.8.4) if ( c.birthday().isValid() ){ safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); } if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { VObject *org = safeAddProp( vcard, VCOrgProp ); safeAddPropValue( org, VCOrgNameProp, c.company() ); safeAddPropValue( org, VCOrgUnitProp, c.department() ); safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); } // some values we have to export as custom fields safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |