summaryrefslogtreecommitdiff
path: root/libopie/pim/ocontact.cpp
Unidiff
Diffstat (limited to 'libopie/pim/ocontact.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 21fc088..734f5a2 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1119,13 +1119,18 @@ static VObject *createVObject( const OContact &c )
1119 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 1119 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
1120 safeAddProp( email, VCInternetProp ); 1120 safeAddProp( email, VCInternetProp );
1121 } 1121 }
1122 1122
1123 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1123 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1124 1124
1125 safeAddPropValue( vcard, VCBirthDateProp, TimeConversion::toString( c.birthday() ) ); 1125 // Exporting Birthday regarding RFC 2425 (5.8.4)
1126 if ( !c.birthday().isNull() ){
1127 QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day();
1128 qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
1129 safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
1130 }
1126 1131
1127 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 1132 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
1128 VObject *org = safeAddProp( vcard, VCOrgProp ); 1133 VObject *org = safeAddProp( vcard, VCOrgProp );
1129 safeAddPropValue( org, VCOrgNameProp, c.company() ); 1134 safeAddPropValue( org, VCOrgNameProp, c.company() );
1130 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 1135 safeAddPropValue( org, VCOrgUnitProp, c.department() );
1131 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 1136 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
@@ -1146,12 +1151,28 @@ static VObject *createVObject( const OContact &c )
1146} 1151}
1147 1152
1148 1153
1149/*! 1154/*!
1150 \internal 1155 \internal
1151*/ 1156*/
1157static QDate convVCardDateToDate( const QString& datestr )
1158{
1159 int monthPos = datestr.find('-');
1160 int dayPos = datestr.find('-', monthPos+1 );
1161 if ( monthPos == -1 || dayPos == -1 ) {
1162 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1163 return QDate();
1164 }
1165 int y = datestr.left( monthPos ).toInt();
1166 int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt();
1167 int d = datestr.mid( dayPos+1 ).toInt();
1168 QDate date ( y,m,d );
1169 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
1170 return date;
1171}
1172
1152static OContact parseVObject( VObject *obj ) 1173static OContact parseVObject( VObject *obj )
1153{ 1174{
1154 OContact c; 1175 OContact c;
1155 1176
1156 VObjectIterator it; 1177 VObjectIterator it;
1157 initPropIterator( &it, obj ); 1178 initPropIterator( &it, obj );
@@ -1345,15 +1366,19 @@ static OContact parseVObject( VObject *obj )
1345 } 1366 }
1346 else if ( name == "X-Qtopia-Nickname" ) { 1367 else if ( name == "X-Qtopia-Nickname" ) {
1347 c.setNickname( value ); 1368 c.setNickname( value );
1348 } 1369 }
1349 else if ( name == "X-Qtopia-Children" ) { 1370 else if ( name == "X-Qtopia-Children" ) {
1350 c.setChildren( value ); 1371 c.setChildren( value );
1372 }
1373 else if ( name == VCBirthDateProp ) {
1374 // Reading Birthdate regarding RFC 2425 (5.8.4)
1375 c.setBirthday( convVCardDateToDate( value ) );
1376
1351 } 1377 }
1352 1378
1353
1354#if 0 1379#if 0
1355 else { 1380 else {
1356 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 1381 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
1357 VObjectIterator nit; 1382 VObjectIterator nit;
1358 initPropIterator( &nit, o ); 1383 initPropIterator( &nit, o );
1359 while( moreIteration( &nit ) ) { 1384 while( moreIteration( &nit ) ) {
@@ -1604,6 +1629,7 @@ void OContact::setDefaultEmail( const QString &v )
1604 1629
1605void OContact::insertEmails( const QStringList &v ) 1630void OContact::insertEmails( const QStringList &v )
1606{ 1631{
1607 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1632 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1608 insertEmail( *it ); 1633 insertEmail( *it );
1609} 1634}
1635