-rw-r--r-- | libopie/pim/ocontact.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index acd65c4..cd238ef 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -1127,14 +1127,14 @@ static VObject *createVObject( const OContact &c ) | |||
1127 | // Exporting Birthday regarding RFC 2425 (5.8.4) | 1127 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
1128 | if ( c.birthday().isValid() ){ | 1128 | if ( c.birthday().isValid() ){ |
1129 | QString birthd_rfc2425 = QString("%1-%2-%3") | 1129 | QString birthd_rfc2425 = QString("%1-%2-%3") |
1130 | .arg( c.birthday().year() ) | 1130 | .arg( c.birthday().year() ) |
1131 | .arg( c.birthday().month(), 2 ) | 1131 | .arg( c.birthday().month(), 2 ) |
1132 | .arg( c.birthday().day(), 2 ); | 1132 | .arg( c.birthday().day(), 2 ); |
1133 | // Now replace spaces with "0"... | 1133 | // Now replace spaces with "0"... |
1134 | int pos = 0; | 1134 | int pos = 0; |
1135 | while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) | 1135 | while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) |
1136 | birthd_rfc2425.replace( pos, 1, "0" ); | 1136 | birthd_rfc2425.replace( pos, 1, "0" ); |
1137 | 1137 | ||
1138 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); | 1138 | qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); |
1139 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); | 1139 | safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); |
1140 | } | 1140 | } |
@@ -1388,11 +1388,11 @@ static OContact parseVObject( VObject *obj ) | |||
1388 | } | 1388 | } |
1389 | else if ( name == "X-Qtopia-Children" ) { | 1389 | else if ( name == "X-Qtopia-Children" ) { |
1390 | c.setChildren( value ); | 1390 | c.setChildren( value ); |
1391 | } | 1391 | } |
1392 | else if ( name == VCBirthDateProp ) { | 1392 | else if ( name == VCBirthDateProp ) { |
1393 | // Reading Birthdate regarding RFC 2425 (5.8.4) | 1393 | // Reading Birthdate regarding RFC 2425 (5.8.4) |
1394 | c.setBirthday( convVCardDateToDate( value ) ); | 1394 | c.setBirthday( convVCardDateToDate( value ) ); |
1395 | 1395 | ||
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | #if 0 | 1398 | #if 0 |
@@ -1464,7 +1464,16 @@ QValueList<OContact> OContact::readVCard( const QString &filename ) | |||
1464 | QValueList<OContact> contacts; | 1464 | QValueList<OContact> contacts; |
1465 | 1465 | ||
1466 | while ( obj ) { | 1466 | while ( obj ) { |
1467 | contacts.append( parseVObject( obj ) ); | 1467 | OContact con = parseVObject( obj ); |
1468 | /* | ||
1469 | * if uid is 0 assign a new one | ||
1470 | * this at least happens on | ||
1471 | * Nokia6210 | ||
1472 | */ | ||
1473 | if ( con.uid() == 0 ) | ||
1474 | con.setUid( 1 ); | ||
1475 | |||
1476 | contacts.append(con ); | ||
1468 | 1477 | ||
1469 | VObject *t = obj; | 1478 | VObject *t = obj; |
1470 | obj = nextVObjectInList(obj); | 1479 | obj = nextVObjectInList(obj); |
@@ -1527,17 +1536,17 @@ class QString OContact::recordField( int pos ) const | |||
1527 | } | 1536 | } |
1528 | 1537 | ||
1529 | // In future releases, we should store birthday and anniversary | 1538 | // In future releases, we should store birthday and anniversary |
1530 | // internally as QDate instead of QString ! | 1539 | // internally as QDate instead of QString ! |
1531 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1540 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1532 | 1541 | ||
1533 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1542 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1534 | Sets the birthday for the contact to \a date. | 1543 | Sets the birthday for the contact to \a date. |
1535 | */ | 1544 | */ |
1536 | void OContact::setBirthday( const QDate &v ) | 1545 | void OContact::setBirthday( const QDate &v ) |
1537 | { | 1546 | { |
1538 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1547 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1539 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); | 1548 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); |
1540 | 1549 | ||
1541 | } | 1550 | } |
1542 | 1551 | ||
1543 | 1552 | ||
@@ -1553,8 +1562,8 @@ void OContact::setAnniversary( const QDate &v ) | |||
1553 | /*! \fn QDate OContact::birthday() const | 1562 | /*! \fn QDate OContact::birthday() const |
1554 | Returns the birthday of the contact. | 1563 | Returns the birthday of the contact. |
1555 | */ | 1564 | */ |
1556 | QDate OContact::birthday() const | 1565 | QDate OContact::birthday() const |
1557 | { | 1566 | { |
1558 | QString str = find( Qtopia::Birthday ); | 1567 | QString str = find( Qtopia::Birthday ); |
1559 | qWarning ("Birthday %s", str.latin1() ); | 1568 | qWarning ("Birthday %s", str.latin1() ); |
1560 | if ( !str.isEmpty() ) | 1569 | if ( !str.isEmpty() ) |
@@ -1567,13 +1576,13 @@ QDate OContact::birthday() const | |||
1567 | /*! \fn QDate OContact::anniversary() const | 1576 | /*! \fn QDate OContact::anniversary() const |
1568 | Returns the anniversary of the contact. | 1577 | Returns the anniversary of the contact. |
1569 | */ | 1578 | */ |
1570 | QDate OContact::anniversary() const | 1579 | QDate OContact::anniversary() const |
1571 | { | 1580 | { |
1572 | QDate empty; | 1581 | QDate empty; |
1573 | QString str = find( Qtopia::Anniversary ); | 1582 | QString str = find( Qtopia::Anniversary ); |
1574 | qWarning ("Anniversary %s", str.latin1() ); | 1583 | qWarning ("Anniversary %s", str.latin1() ); |
1575 | if ( !str.isEmpty() ) | 1584 | if ( !str.isEmpty() ) |
1576 | return TimeConversion::fromString ( str ); | 1585 | return TimeConversion::fromString ( str ); |
1577 | else | 1586 | else |
1578 | return empty; | 1587 | return empty; |
1579 | } | 1588 | } |
@@ -1607,7 +1616,7 @@ void OContact::removeEmail( const QString &v ) | |||
1607 | QString def = defaultEmail(); | 1616 | QString def = defaultEmail(); |
1608 | QString emailsStr = find( Qtopia::Emails ); | 1617 | QString emailsStr = find( Qtopia::Emails ); |
1609 | QStringList emails = emailList(); | 1618 | QStringList emails = emailList(); |
1610 | 1619 | ||
1611 | // otherwise, must first contain it | 1620 | // otherwise, must first contain it |
1612 | if ( !emailsStr.contains( e ) ) | 1621 | if ( !emailsStr.contains( e ) ) |
1613 | return; | 1622 | return; |
@@ -1640,9 +1649,9 @@ void OContact::setDefaultEmail( const QString &v ) | |||
1640 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); | 1649 | //qDebug("OContact::setDefaultEmail %s", e.latin1()); |
1641 | replace( Qtopia::DefaultEmail, e ); | 1650 | replace( Qtopia::DefaultEmail, e ); |
1642 | 1651 | ||
1643 | if ( !e.isEmpty() ) | 1652 | if ( !e.isEmpty() ) |
1644 | insertEmail( e ); | 1653 | insertEmail( e ); |
1645 | 1654 | ||
1646 | } | 1655 | } |
1647 | 1656 | ||
1648 | void OContact::insertEmails( const QStringList &v ) | 1657 | void OContact::insertEmails( const QStringList &v ) |