summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp33
-rw-r--r--libopie2/opiepim/ocontact.cpp33
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
@@ -66,21 +66,23 @@ OContact::OContact()
66OContact::OContact( const QMap<int, QString> &fromMap ) : 66OContact::OContact( const QMap<int, QString> &fromMap ) :
67 OPimRecord(), mMap( fromMap ), d( 0 ) 67 OPimRecord(), mMap( fromMap ), d( 0 )
68{ 68{
69 QString cats = mMap[ Qtopia::AddressCategory ]; 69 QString cats = mMap[ Qtopia::AddressCategory ];
70 if ( !cats.isEmpty() ) 70 if ( !cats.isEmpty() )
71 setCategories( idsFromString( cats ) ); 71 setCategories( idsFromString( cats ) );
72
72 QString uidStr = find( Qtopia::AddressUid ); 73 QString uidStr = find( Qtopia::AddressUid );
73 74
74 if ( uidStr.isEmpty() ) 75 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
76 qWarning( "Invalid UID found. Generate new one.." );
75 setUid( uidGen().generate() ); 77 setUid( uidGen().generate() );
76 else 78 }else
77 setUid( uidStr.toInt() ); 79 setUid( uidStr.toInt() );
78 80
79 if ( !uidStr.isEmpty() ) 81// if ( !uidStr.isEmpty() )
80 setUid( uidStr.toInt() ); 82 // setUid( uidStr.toInt() );
81} 83}
82 84
83/*! 85/*!
84 Destroys a contact. 86 Destroys a contact.
85*/ 87*/
86OContact::~OContact() 88OContact::~OContact()
@@ -568,18 +570,18 @@ QString OContact::toRichText() const
568 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 570 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
569 } 571 }
570 str = spouse(); 572 str = spouse();
571 if ( !str.isEmpty() ) 573 if ( !str.isEmpty() )
572 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 574 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
573 + Qtopia::escapeString(str) + "<br>"; 575 + Qtopia::escapeString(str) + "<br>";
574 if ( !birthday().isValid() ){ 576 if ( birthday().isValid() ){
575 str = TimeString::numberDateString( birthday() ); 577 str = TimeString::numberDateString( birthday() );
576 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 578 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
577 + Qtopia::escapeString(str) + "<br>"; 579 + Qtopia::escapeString(str) + "<br>";
578 } 580 }
579 if ( !anniversary().isValid() ){ 581 if ( anniversary().isValid() ){
580 str = TimeString::numberDateString( anniversary() ); 582 str = TimeString::numberDateString( anniversary() );
581 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 583 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
582 + Qtopia::escapeString(str) + "<br>"; 584 + Qtopia::escapeString(str) + "<br>";
583 } 585 }
584 str = nickname(); 586 str = nickname();
585 if ( !str.isEmpty() ) 587 if ( !str.isEmpty() )
@@ -1120,13 +1122,13 @@ static VObject *createVObject( const OContact &c )
1120 safeAddProp( email, VCInternetProp ); 1122 safeAddProp( email, VCInternetProp );
1121 } 1123 }
1122 1124
1123 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1125 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1124 1126
1125 // Exporting Birthday regarding RFC 2425 (5.8.4) 1127 // Exporting Birthday regarding RFC 2425 (5.8.4)
1126 if ( !c.birthday().isValid() ){ 1128 if ( c.birthday().isValid() ){
1127 QString birthd_rfc2425 = QString("%1-%2-%3") 1129 QString birthd_rfc2425 = QString("%1-%2-%3")
1128 .arg( c.birthday().year() ) 1130 .arg( c.birthday().year() )
1129 .arg( c.birthday().month(), 2 ) 1131 .arg( c.birthday().month(), 2 )
1130 .arg( c.birthday().day(), 2 ); 1132 .arg( c.birthday().day(), 2 );
1131 // Now replace spaces with "0"... 1133 // Now replace spaces with "0"...
1132 int pos = 0; 1134 int pos = 0;
@@ -1166,17 +1168,21 @@ static QDate convVCardDateToDate( const QString& datestr )
1166{ 1168{
1167 int monthPos = datestr.find('-'); 1169 int monthPos = datestr.find('-');
1168 int dayPos = datestr.find('-', monthPos+1 ); 1170 int dayPos = datestr.find('-', monthPos+1 );
1169 int sep_ignore = 1; 1171 int sep_ignore = 1;
1170 if ( monthPos == -1 || dayPos == -1 ) { 1172 if ( monthPos == -1 || dayPos == -1 ) {
1171 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 1173 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1172 // Ok.. Outlook is violating ISO 8601, therefore we will try to read their format ( YYYYMMDD ) 1174 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
1173 monthPos = 4; 1175 if ( datestr.length() == 8 ){
1174 dayPos = 6; 1176 monthPos = 4;
1175 sep_ignore = 0; 1177 dayPos = 6;
1176 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 1178 sep_ignore = 0;
1179 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1180 } else {
1181 return QDate();
1182 }
1177 } 1183 }
1178 int y = datestr.left( monthPos ).toInt(); 1184 int y = datestr.left( monthPos ).toInt();
1179 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); 1185 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
1180 int d = datestr.mid( dayPos + sep_ignore ).toInt(); 1186 int d = datestr.mid( dayPos + sep_ignore ).toInt();
1181 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); 1187 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 ); 1188 QDate date ( y,m,d );
@@ -1546,19 +1552,18 @@ void OContact::setAnniversary( const QDate &v )
1546 1552
1547/*! \fn QDate OContact::birthday() const 1553/*! \fn QDate OContact::birthday() const
1548 Returns the birthday of the contact. 1554 Returns the birthday of the contact.
1549*/ 1555*/
1550QDate OContact::birthday() const 1556QDate OContact::birthday() const
1551{ 1557{
1552 QDate empty;
1553 QString str = find( Qtopia::Birthday ); 1558 QString str = find( Qtopia::Birthday );
1554 qWarning ("Birthday %s", str.latin1() ); 1559 qWarning ("Birthday %s", str.latin1() );
1555 if ( !str.isEmpty() ) 1560 if ( !str.isEmpty() )
1556 return TimeConversion::fromString ( str ); 1561 return TimeConversion::fromString ( str );
1557 else 1562 else
1558 return empty; 1563 return QDate();
1559} 1564}
1560 1565
1561 1566
1562/*! \fn QDate OContact::anniversary() const 1567/*! \fn QDate OContact::anniversary() const
1563 Returns the anniversary of the contact. 1568 Returns the anniversary of the contact.
1564*/ 1569*/
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
@@ -66,21 +66,23 @@ OContact::OContact()
66OContact::OContact( const QMap<int, QString> &fromMap ) : 66OContact::OContact( const QMap<int, QString> &fromMap ) :
67 OPimRecord(), mMap( fromMap ), d( 0 ) 67 OPimRecord(), mMap( fromMap ), d( 0 )
68{ 68{
69 QString cats = mMap[ Qtopia::AddressCategory ]; 69 QString cats = mMap[ Qtopia::AddressCategory ];
70 if ( !cats.isEmpty() ) 70 if ( !cats.isEmpty() )
71 setCategories( idsFromString( cats ) ); 71 setCategories( idsFromString( cats ) );
72
72 QString uidStr = find( Qtopia::AddressUid ); 73 QString uidStr = find( Qtopia::AddressUid );
73 74
74 if ( uidStr.isEmpty() ) 75 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
76 qWarning( "Invalid UID found. Generate new one.." );
75 setUid( uidGen().generate() ); 77 setUid( uidGen().generate() );
76 else 78 }else
77 setUid( uidStr.toInt() ); 79 setUid( uidStr.toInt() );
78 80
79 if ( !uidStr.isEmpty() ) 81// if ( !uidStr.isEmpty() )
80 setUid( uidStr.toInt() ); 82 // setUid( uidStr.toInt() );
81} 83}
82 84
83/*! 85/*!
84 Destroys a contact. 86 Destroys a contact.
85*/ 87*/
86OContact::~OContact() 88OContact::~OContact()
@@ -568,18 +570,18 @@ QString OContact::toRichText() const
568 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 570 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>";
569 } 571 }
570 str = spouse(); 572 str = spouse();
571 if ( !str.isEmpty() ) 573 if ( !str.isEmpty() )
572 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 574 text += "<b>" + QObject::tr("Spouse: ") + "</b>"
573 + Qtopia::escapeString(str) + "<br>"; 575 + Qtopia::escapeString(str) + "<br>";
574 if ( !birthday().isValid() ){ 576 if ( birthday().isValid() ){
575 str = TimeString::numberDateString( birthday() ); 577 str = TimeString::numberDateString( birthday() );
576 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 578 text += "<b>" + QObject::tr("Birthday: ") + "</b>"
577 + Qtopia::escapeString(str) + "<br>"; 579 + Qtopia::escapeString(str) + "<br>";
578 } 580 }
579 if ( !anniversary().isValid() ){ 581 if ( anniversary().isValid() ){
580 str = TimeString::numberDateString( anniversary() ); 582 str = TimeString::numberDateString( anniversary() );
581 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 583 text += "<b>" + QObject::tr("Anniversary: ") + "</b>"
582 + Qtopia::escapeString(str) + "<br>"; 584 + Qtopia::escapeString(str) + "<br>";
583 } 585 }
584 str = nickname(); 586 str = nickname();
585 if ( !str.isEmpty() ) 587 if ( !str.isEmpty() )
@@ -1120,13 +1122,13 @@ static VObject *createVObject( const OContact &c )
1120 safeAddProp( email, VCInternetProp ); 1122 safeAddProp( email, VCInternetProp );
1121 } 1123 }
1122 1124
1123 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 1125 safeAddPropValue( vcard, VCNoteProp, c.notes() );
1124 1126
1125 // Exporting Birthday regarding RFC 2425 (5.8.4) 1127 // Exporting Birthday regarding RFC 2425 (5.8.4)
1126 if ( !c.birthday().isValid() ){ 1128 if ( c.birthday().isValid() ){
1127 QString birthd_rfc2425 = QString("%1-%2-%3") 1129 QString birthd_rfc2425 = QString("%1-%2-%3")
1128 .arg( c.birthday().year() ) 1130 .arg( c.birthday().year() )
1129 .arg( c.birthday().month(), 2 ) 1131 .arg( c.birthday().month(), 2 )
1130 .arg( c.birthday().day(), 2 ); 1132 .arg( c.birthday().day(), 2 );
1131 // Now replace spaces with "0"... 1133 // Now replace spaces with "0"...
1132 int pos = 0; 1134 int pos = 0;
@@ -1166,17 +1168,21 @@ static QDate convVCardDateToDate( const QString& datestr )
1166{ 1168{
1167 int monthPos = datestr.find('-'); 1169 int monthPos = datestr.find('-');
1168 int dayPos = datestr.find('-', monthPos+1 ); 1170 int dayPos = datestr.find('-', monthPos+1 );
1169 int sep_ignore = 1; 1171 int sep_ignore = 1;
1170 if ( monthPos == -1 || dayPos == -1 ) { 1172 if ( monthPos == -1 || dayPos == -1 ) {
1171 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 1173 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1172 // Ok.. Outlook is violating ISO 8601, therefore we will try to read their format ( YYYYMMDD ) 1174 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
1173 monthPos = 4; 1175 if ( datestr.length() == 8 ){
1174 dayPos = 6; 1176 monthPos = 4;
1175 sep_ignore = 0; 1177 dayPos = 6;
1176 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 1178 sep_ignore = 0;
1179 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
1180 } else {
1181 return QDate();
1182 }
1177 } 1183 }
1178 int y = datestr.left( monthPos ).toInt(); 1184 int y = datestr.left( monthPos ).toInt();
1179 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); 1185 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
1180 int d = datestr.mid( dayPos + sep_ignore ).toInt(); 1186 int d = datestr.mid( dayPos + sep_ignore ).toInt();
1181 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); 1187 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 ); 1188 QDate date ( y,m,d );
@@ -1546,19 +1552,18 @@ void OContact::setAnniversary( const QDate &v )
1546 1552
1547/*! \fn QDate OContact::birthday() const 1553/*! \fn QDate OContact::birthday() const
1548 Returns the birthday of the contact. 1554 Returns the birthday of the contact.
1549*/ 1555*/
1550QDate OContact::birthday() const 1556QDate OContact::birthday() const
1551{ 1557{
1552 QDate empty;
1553 QString str = find( Qtopia::Birthday ); 1558 QString str = find( Qtopia::Birthday );
1554 qWarning ("Birthday %s", str.latin1() ); 1559 qWarning ("Birthday %s", str.latin1() );
1555 if ( !str.isEmpty() ) 1560 if ( !str.isEmpty() )
1556 return TimeConversion::fromString ( str ); 1561 return TimeConversion::fromString ( str );
1557 else 1562 else
1558 return empty; 1563 return QDate();
1559} 1564}
1560 1565
1561 1566
1562/*! \fn QDate OContact::anniversary() const 1567/*! \fn QDate OContact::anniversary() const
1563 Returns the anniversary of the contact. 1568 Returns the anniversary of the contact.
1564*/ 1569*/