summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -64,25 +64,27 @@ OContact::OContact()
set from \a fromMap.
*/
OContact::OContact( const QMap<int, QString> &fromMap ) :
OPimRecord(), mMap( fromMap ), d( 0 )
{
QString cats = mMap[ Qtopia::AddressCategory ];
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() );
}
/*!
Destroys a contact.
*/
OContact::~OContact()
{
}
@@ -566,22 +568,22 @@ QString OContact::toRichText() const
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().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>"
+ Qtopia::escapeString(str) + "<br>";
}
str = nickname();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Nickname: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
@@ -1118,17 +1120,17 @@ static VObject *createVObject( const OContact &c )
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().isValid() ){
+ 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" );
@@ -1164,21 +1166,25 @@ static VObject *createVObject( const OContact &c )
*/
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 );
- // 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();
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;
}
@@ -1544,23 +1550,22 @@ void OContact::setAnniversary( const QDate &v )
replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
}
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
*/
QDate OContact::birthday() const
{
- QDate empty;
QString str = find( Qtopia::Birthday );
qWarning ("Birthday %s", str.latin1() );
if ( !str.isEmpty() )
return TimeConversion::fromString ( str );
else
- return empty;
+ return QDate();
}
/*! \fn QDate OContact::anniversary() const
Returns the anniversary of the contact.
*/
QDate OContact::anniversary() const
{
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
@@ -64,25 +64,27 @@ OContact::OContact()
set from \a fromMap.
*/
OContact::OContact( const QMap<int, QString> &fromMap ) :
OPimRecord(), mMap( fromMap ), d( 0 )
{
QString cats = mMap[ Qtopia::AddressCategory ];
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() );
}
/*!
Destroys a contact.
*/
OContact::~OContact()
{
}
@@ -566,22 +568,22 @@ QString OContact::toRichText() const
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().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>"
+ Qtopia::escapeString(str) + "<br>";
}
str = nickname();
if ( !str.isEmpty() )
text += "<b>" + QObject::tr("Nickname: ") + "</b>"
+ Qtopia::escapeString(str) + "<br>";
@@ -1118,17 +1120,17 @@ static VObject *createVObject( const OContact &c )
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().isValid() ){
+ 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" );
@@ -1164,21 +1166,25 @@ static VObject *createVObject( const OContact &c )
*/
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 );
- // 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();
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;
}
@@ -1544,23 +1550,22 @@ void OContact::setAnniversary( const QDate &v )
replace( Qtopia::Anniversary, TimeConversion::toString( v ) );
}
/*! \fn QDate OContact::birthday() const
Returns the birthday of the contact.
*/
QDate OContact::birthday() const
{
- QDate empty;
QString str = find( Qtopia::Birthday );
qWarning ("Birthday %s", str.latin1() );
if ( !str.isEmpty() )
return TimeConversion::fromString ( str );
else
- return empty;
+ return QDate();
}
/*! \fn QDate OContact::anniversary() const
Returns the anniversary of the contact.
*/
QDate OContact::anniversary() const
{