-rw-r--r-- | libopie/pim/ocontact.cpp | 33 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 33 |
2 files changed, 38 insertions, 28 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index bf27d0f..acd65c4 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp @@ -70,13 +70,15 @@ OContact::OContact( const QMap<int, QString> &fromMap ) : if ( !cats.isEmpty() ) setCategories( idsFromString( cats ) ); + QString uidStr = find( Qtopia::AddressUid ); - if ( uidStr.isEmpty() ) + if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ + qWarning( "Invalid UID found. Generate new one.." ); setUid( uidGen().generate() ); - else + }else setUid( uidStr.toInt() ); - if ( !uidStr.isEmpty() ) - setUid( uidStr.toInt() ); +// if ( !uidStr.isEmpty() ) +// setUid( uidStr.toInt() ); } @@ -572,10 +574,10 @@ QString OContact::toRichText() const text += "<b>" + QObject::tr("Spouse: ") + "</b>" + Qtopia::escapeString(str) + "<br>"; - if ( !birthday().isValid() ){ + if ( birthday().isValid() ){ str = TimeString::numberDateString( birthday() ); text += "<b>" + QObject::tr("Birthday: ") + "</b>" + Qtopia::escapeString(str) + "<br>"; } - if ( !anniversary().isValid() ){ + if ( anniversary().isValid() ){ str = TimeString::numberDateString( anniversary() ); text += "<b>" + QObject::tr("Anniversary: ") + "</b>" @@ -1124,5 +1126,5 @@ static VObject *createVObject( const OContact &c ) // Exporting Birthday regarding RFC 2425 (5.8.4) - if ( !c.birthday().isValid() ){ + if ( c.birthday().isValid() ){ QString birthd_rfc2425 = QString("%1-%2-%3") .arg( c.birthday().year() ) @@ -1170,9 +1172,13 @@ static QDate convVCardDateToDate( const QString& datestr ) if ( monthPos == -1 || dayPos == -1 ) { qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); - // 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 ); + // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) + if ( datestr.length() == 8 ){ + monthPos = 4; + dayPos = 6; + sep_ignore = 0; + qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); + } else { + return QDate(); + } } int y = datestr.left( monthPos ).toInt(); @@ -1550,5 +1556,4 @@ void OContact::setAnniversary( const QDate &v ) QDate OContact::birthday() const { - QDate empty; QString str = find( Qtopia::Birthday ); qWarning ("Birthday %s", str.latin1() ); @@ -1556,5 +1561,5 @@ QDate OContact::birthday() const return TimeConversion::fromString ( str ); else - return empty; + return QDate(); } diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index bf27d0f..acd65c4 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp @@ -70,13 +70,15 @@ OContact::OContact( const QMap<int, QString> &fromMap ) : if ( !cats.isEmpty() ) setCategories( idsFromString( cats ) ); + QString uidStr = find( Qtopia::AddressUid ); - if ( uidStr.isEmpty() ) + if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ + qWarning( "Invalid UID found. Generate new one.." ); setUid( uidGen().generate() ); - else + }else setUid( uidStr.toInt() ); - if ( !uidStr.isEmpty() ) - setUid( uidStr.toInt() ); +// if ( !uidStr.isEmpty() ) +// setUid( uidStr.toInt() ); } @@ -572,10 +574,10 @@ QString OContact::toRichText() const text += "<b>" + QObject::tr("Spouse: ") + "</b>" + Qtopia::escapeString(str) + "<br>"; - if ( !birthday().isValid() ){ + if ( birthday().isValid() ){ str = TimeString::numberDateString( birthday() ); text += "<b>" + QObject::tr("Birthday: ") + "</b>" + Qtopia::escapeString(str) + "<br>"; } - if ( !anniversary().isValid() ){ + if ( anniversary().isValid() ){ str = TimeString::numberDateString( anniversary() ); text += "<b>" + QObject::tr("Anniversary: ") + "</b>" @@ -1124,5 +1126,5 @@ static VObject *createVObject( const OContact &c ) // Exporting Birthday regarding RFC 2425 (5.8.4) - if ( !c.birthday().isValid() ){ + if ( c.birthday().isValid() ){ QString birthd_rfc2425 = QString("%1-%2-%3") .arg( c.birthday().year() ) @@ -1170,9 +1172,13 @@ static QDate convVCardDateToDate( const QString& datestr ) if ( monthPos == -1 || dayPos == -1 ) { qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); - // 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 ); + // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) + if ( datestr.length() == 8 ){ + monthPos = 4; + dayPos = 6; + sep_ignore = 0; + qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); + } else { + return QDate(); + } } int y = datestr.left( monthPos ).toInt(); @@ -1550,5 +1556,4 @@ void OContact::setAnniversary( const QDate &v ) QDate OContact::birthday() const { - QDate empty; QString str = find( Qtopia::Birthday ); qWarning ("Birthday %s", str.latin1() ); @@ -1556,5 +1561,5 @@ QDate OContact::birthday() const return TimeConversion::fromString ( str ); else - return empty; + return QDate(); } |