author | eilers <eilers> | 2002-10-28 17:16:10 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-28 17:16:10 (UTC) |
commit | 0c4104a4870423b4220790b6ee734dff0cf60920 (patch) (unidiff) | |
tree | 762e8841a58e6f9414e7281a50fb5a810566934e | |
parent | 098abdd59acd5a72127ac8abc9113238a53c546b (diff) | |
download | opie-0c4104a4870423b4220790b6ee734dff0cf60920.zip opie-0c4104a4870423b4220790b6ee734dff0cf60920.tar.gz opie-0c4104a4870423b4220790b6ee734dff0cf60920.tar.bz2 |
Shit .. Microsoft is violating RFC 2426 .. Thanks a lot !
-rw-r--r-- | libopie/pim/ocontact.cpp | 29 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 29 |
2 files changed, 42 insertions, 16 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index 734f5a2..bf27d0f 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -568,18 +568,18 @@ QString OContact::toRichText() const | |||
568 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 568 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; |
569 | } | 569 | } |
570 | str = spouse(); | 570 | str = spouse(); |
571 | if ( !str.isEmpty() ) | 571 | if ( !str.isEmpty() ) |
572 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 572 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" |
573 | + Qtopia::escapeString(str) + "<br>"; | 573 | + Qtopia::escapeString(str) + "<br>"; |
574 | if ( !birthday().isNull() ){ | 574 | if ( !birthday().isValid() ){ |
575 | str = TimeString::numberDateString( birthday() ); | 575 | str = TimeString::numberDateString( birthday() ); |
576 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 576 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" |
577 | + Qtopia::escapeString(str) + "<br>"; | 577 | + Qtopia::escapeString(str) + "<br>"; |
578 | } | 578 | } |
579 | if ( !anniversary().isNull() ){ | 579 | if ( !anniversary().isValid() ){ |
580 | str = TimeString::numberDateString( anniversary() ); | 580 | str = TimeString::numberDateString( anniversary() ); |
581 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 581 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" |
582 | + Qtopia::escapeString(str) + "<br>"; | 582 | + Qtopia::escapeString(str) + "<br>"; |
583 | } | 583 | } |
584 | str = nickname(); | 584 | str = nickname(); |
585 | if ( !str.isEmpty() ) | 585 | if ( !str.isEmpty() ) |
@@ -1120,14 +1120,22 @@ static VObject *createVObject( const OContact &c ) | |||
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 | // Exporting Birthday regarding RFC 2425 (5.8.4) | 1125 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
1126 | if ( !c.birthday().isNull() ){ | 1126 | if ( !c.birthday().isValid() ){ |
1127 | QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day(); | 1127 | QString birthd_rfc2425 = QString("%1-%2-%3") |
1128 | .arg( c.birthday().year() ) | ||
1129 | .arg( c.birthday().month(), 2 ) | ||
1130 | .arg( c.birthday().day(), 2 ); | ||
1131 | // Now replace spaces with "0"... | ||
1132 | int pos = 0; | ||
1133 | while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) | ||
1134 | birthd_rfc2425.replace( pos, 1, "0" ); | ||
1135 | |||
1128 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); | 1136 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); |
1129 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); | 1137 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); |
1130 | } | 1138 | } |
1131 | 1139 | ||
1132 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1140 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1133 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1141 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
@@ -1155,21 +1163,26 @@ static VObject *createVObject( const OContact &c ) | |||
1155 | \internal | 1163 | \internal |
1156 | */ | 1164 | */ |
1157 | static QDate convVCardDateToDate( const QString& datestr ) | 1165 | static QDate convVCardDateToDate( const QString& datestr ) |
1158 | { | 1166 | { |
1159 | int monthPos = datestr.find('-'); | 1167 | int monthPos = datestr.find('-'); |
1160 | int dayPos = datestr.find('-', monthPos+1 ); | 1168 | int dayPos = datestr.find('-', monthPos+1 ); |
1169 | int sep_ignore = 1; | ||
1161 | if ( monthPos == -1 || dayPos == -1 ) { | 1170 | if ( monthPos == -1 || dayPos == -1 ) { |
1162 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 1171 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
1163 | return QDate(); | 1172 | // Ok.. Outlook is violating ISO 8601, therefore we will try to read their format ( YYYYMMDD ) |
1173 | monthPos = 4; | ||
1174 | dayPos = 6; | ||
1175 | sep_ignore = 0; | ||
1176 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | ||
1164 | } | 1177 | } |
1165 | int y = datestr.left( monthPos ).toInt(); | 1178 | int y = datestr.left( monthPos ).toInt(); |
1166 | int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt(); | 1179 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); |
1167 | int d = datestr.mid( dayPos+1 ).toInt(); | 1180 | int d = datestr.mid( dayPos + sep_ignore ).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); | 1181 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); |
1182 | QDate date ( y,m,d ); | ||
1170 | return date; | 1183 | return date; |
1171 | } | 1184 | } |
1172 | 1185 | ||
1173 | static OContact parseVObject( VObject *obj ) | 1186 | static OContact parseVObject( VObject *obj ) |
1174 | { | 1187 | { |
1175 | OContact c; | 1188 | OContact c; |
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 | |||
@@ -568,18 +568,18 @@ QString OContact::toRichText() const | |||
568 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 568 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; |
569 | } | 569 | } |
570 | str = spouse(); | 570 | str = spouse(); |
571 | if ( !str.isEmpty() ) | 571 | if ( !str.isEmpty() ) |
572 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 572 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" |
573 | + Qtopia::escapeString(str) + "<br>"; | 573 | + Qtopia::escapeString(str) + "<br>"; |
574 | if ( !birthday().isNull() ){ | 574 | if ( !birthday().isValid() ){ |
575 | str = TimeString::numberDateString( birthday() ); | 575 | str = TimeString::numberDateString( birthday() ); |
576 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 576 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" |
577 | + Qtopia::escapeString(str) + "<br>"; | 577 | + Qtopia::escapeString(str) + "<br>"; |
578 | } | 578 | } |
579 | if ( !anniversary().isNull() ){ | 579 | if ( !anniversary().isValid() ){ |
580 | str = TimeString::numberDateString( anniversary() ); | 580 | str = TimeString::numberDateString( anniversary() ); |
581 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 581 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" |
582 | + Qtopia::escapeString(str) + "<br>"; | 582 | + Qtopia::escapeString(str) + "<br>"; |
583 | } | 583 | } |
584 | str = nickname(); | 584 | str = nickname(); |
585 | if ( !str.isEmpty() ) | 585 | if ( !str.isEmpty() ) |
@@ -1120,14 +1120,22 @@ static VObject *createVObject( const OContact &c ) | |||
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 | // Exporting Birthday regarding RFC 2425 (5.8.4) | 1125 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
1126 | if ( !c.birthday().isNull() ){ | 1126 | if ( !c.birthday().isValid() ){ |
1127 | QString birthd_rfc2425 = c.birthday().year() + QString( "-" ) + c.birthday().month() + QString( "-" ) + c.birthday().day(); | 1127 | QString birthd_rfc2425 = QString("%1-%2-%3") |
1128 | .arg( c.birthday().year() ) | ||
1129 | .arg( c.birthday().month(), 2 ) | ||
1130 | .arg( c.birthday().day(), 2 ); | ||
1131 | // Now replace spaces with "0"... | ||
1132 | int pos = 0; | ||
1133 | while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) | ||
1134 | birthd_rfc2425.replace( pos, 1, "0" ); | ||
1135 | |||
1128 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); | 1136 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); |
1129 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); | 1137 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); |
1130 | } | 1138 | } |
1131 | 1139 | ||
1132 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1140 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1133 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1141 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
@@ -1155,21 +1163,26 @@ static VObject *createVObject( const OContact &c ) | |||
1155 | \internal | 1163 | \internal |
1156 | */ | 1164 | */ |
1157 | static QDate convVCardDateToDate( const QString& datestr ) | 1165 | static QDate convVCardDateToDate( const QString& datestr ) |
1158 | { | 1166 | { |
1159 | int monthPos = datestr.find('-'); | 1167 | int monthPos = datestr.find('-'); |
1160 | int dayPos = datestr.find('-', monthPos+1 ); | 1168 | int dayPos = datestr.find('-', monthPos+1 ); |
1169 | int sep_ignore = 1; | ||
1161 | if ( monthPos == -1 || dayPos == -1 ) { | 1170 | if ( monthPos == -1 || dayPos == -1 ) { |
1162 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 1171 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
1163 | return QDate(); | 1172 | // Ok.. Outlook is violating ISO 8601, therefore we will try to read their format ( YYYYMMDD ) |
1173 | monthPos = 4; | ||
1174 | dayPos = 6; | ||
1175 | sep_ignore = 0; | ||
1176 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | ||
1164 | } | 1177 | } |
1165 | int y = datestr.left( monthPos ).toInt(); | 1178 | int y = datestr.left( monthPos ).toInt(); |
1166 | int m = datestr.mid( monthPos+1, dayPos - monthPos - 1 ).toInt(); | 1179 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); |
1167 | int d = datestr.mid( dayPos+1 ).toInt(); | 1180 | int d = datestr.mid( dayPos + sep_ignore ).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); | 1181 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); |
1182 | QDate date ( y,m,d ); | ||
1170 | return date; | 1183 | return date; |
1171 | } | 1184 | } |
1172 | 1185 | ||
1173 | static OContact parseVObject( VObject *obj ) | 1186 | static OContact parseVObject( VObject *obj ) |
1174 | { | 1187 | { |
1175 | OContact c; | 1188 | OContact c; |