summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/ocontact.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 734f5a2..bf27d0f 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -550,54 +550,54 @@ QString OContact::toRichText() const
str = profession();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Profession: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = assistant();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Assistant: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = manager();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Manager: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
str = gender();
if ( !str.isEmpty() && str.toInt() != 0 ) {
if ( str.toInt() == 1 )
str = QObject::tr( "Male" );
else if ( str.toInt() == 2 )
str = QObject::tr( "Female" );
text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
}
str = spouse();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Spouse: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
- if ( !birthday().isNull() ){
+ if ( !birthday().isValid() ){
str = TimeString::numberDateString( birthday() );
text += "<b>" + QObject::tr("Birthday: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
}
- if ( !anniversary().isNull() ){
+ if ( !anniversary().isValid() ){
str = TimeString::numberDateString( anniversary() );
text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
}
str = nickname();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Nickname: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
// notes last
if ( (value = notes()) ) {
QRegExp reg("\n");
//QString tmp = Qtopia::escapeString(value);
QString tmp = QStyleSheet::convertFromPlainText(value);
//tmp.replace( reg, "<br>" );
text += "<br>" + tmp + "<br>";
}
return text;
}
/*!
\internal
*/
@@ -1102,92 +1102,105 @@ static VObject *createVObject( const OContact &c )
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() );
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().isNull() ){
- QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day();
+ if ( !c.birthday().isValid() ){
+ QString birthd_rfc2425 = QString("%1-%2-%3")
+ .arg( c.birthday().year() )
+ .arg( c.birthday().month(), 2 )
+ .arg( c.birthday().day(), 2 );
+ // Now replace spaces with "0"...
+ int pos = 0;
+ while ( ( pos = birthd_rfc2425.find (' ') ) > 0 )
+ birthd_rfc2425.replace( pos, 1, "0" );
+
qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1());
safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() );
}
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() );
safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) );
safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
return vcard;
}
/*!
\internal
*/
static QDate convVCardDateToDate( const QString& datestr )
{
int monthPos = datestr.find('-');
int dayPos = datestr.find('-', monthPos+1 );
+ int sep_ignore = 1;
if ( monthPos == -1 || dayPos == -1 ) {
qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
- return QDate();
+ // Ok.. Outlook is violating ISO 8601, therefore we will try to read their format ( YYYYMMDD )
+ monthPos = 4;
+ dayPos = 6;
+ sep_ignore = 0;
+ qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
}
int y = datestr.left( monthPos ).toInt();
- int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt();
- int d = datestr.mid( dayPos+1 ).toInt();
- QDate date ( y,m,d );
+ int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
+ int d = datestr.mid( dayPos + sep_ignore ).toInt();
qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
+ QDate date ( y,m,d );
return date;
}
static OContact parseVObject( VObject *obj )
{
OContact c;
VObjectIterator it;
initPropIterator( &it, obj );
while( moreIteration( &it ) ) {
VObject *o = nextVObject( &it );
QCString name = vObjectName( o );
QCString value = vObjectStringZValue( o );
if ( name == VCNameProp ) {
VObjectIterator nit;
initPropIterator( &nit, o );
while( moreIteration( &nit ) ) {
VObject *o = nextVObject( &nit );
QCString name = vObjectTypeInfo( o );
QString value = vObjectStringZValue( o );
if ( name == VCNamePrefixesProp )
c.setTitle( value );
else if ( name == VCNameSuffixesProp )
c.setSuffix( value );