-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 | |||
@@ -1106,56 +1106,56 @@ static VObject *createVObject( const OContact &c ) | |||
1106 | safeAddProp( work_phone, VCFaxProp ); | 1106 | safeAddProp( work_phone, VCFaxProp ); |
1107 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 1107 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
1108 | safeAddProp( work_phone, VCWorkProp ); | 1108 | safeAddProp( work_phone, VCWorkProp ); |
1109 | safeAddProp( work_phone, VCPagerProp ); | 1109 | safeAddProp( work_phone, VCPagerProp ); |
1110 | 1110 | ||
1111 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 1111 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
1112 | safeAddProp( url, VCWorkProp ); | 1112 | safeAddProp( url, VCWorkProp ); |
1113 | 1113 | ||
1114 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 1114 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
1115 | safeAddProp( title, VCWorkProp ); | 1115 | safeAddProp( title, VCWorkProp ); |
1116 | 1116 | ||
1117 | 1117 | ||
1118 | QStringList emails = c.emailList(); | 1118 | QStringList emails = c.emailList(); |
1119 | emails.prepend( c.defaultEmail() ); | 1119 | emails.prepend( c.defaultEmail() ); |
1120 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 1120 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
1121 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 1121 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
1122 | safeAddProp( email, VCInternetProp ); | 1122 | safeAddProp( email, VCInternetProp ); |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 1125 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
1126 | 1126 | ||
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 | } |
1141 | 1141 | ||
1142 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 1142 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
1143 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 1143 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
1144 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 1144 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
1145 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 1145 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
1146 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 1146 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | // some values we have to export as custom fields | 1149 | // some values we have to export as custom fields |
1150 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 1150 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
1151 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 1151 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
1152 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 1152 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
1153 | 1153 | ||
1154 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 1154 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
1155 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 1155 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
1156 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); | 1156 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); |
1157 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 1157 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
1158 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 1158 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
1159 | 1159 | ||
1160 | return vcard; | 1160 | return vcard; |
1161 | } | 1161 | } |
@@ -1367,53 +1367,53 @@ static OContact parseVObject( VObject *obj ) | |||
1367 | } | 1367 | } |
1368 | else if ( name == "X-Qtopia-Profession" ) { | 1368 | else if ( name == "X-Qtopia-Profession" ) { |
1369 | c.setProfession( value ); | 1369 | c.setProfession( value ); |
1370 | } | 1370 | } |
1371 | else if ( name == "X-Qtopia-Manager" ) { | 1371 | else if ( name == "X-Qtopia-Manager" ) { |
1372 | c.setManager( value ); | 1372 | c.setManager( value ); |
1373 | } | 1373 | } |
1374 | else if ( name == "X-Qtopia-Assistant" ) { | 1374 | else if ( name == "X-Qtopia-Assistant" ) { |
1375 | c.setAssistant( value ); | 1375 | c.setAssistant( value ); |
1376 | } | 1376 | } |
1377 | else if ( name == "X-Qtopia-Spouse" ) { | 1377 | else if ( name == "X-Qtopia-Spouse" ) { |
1378 | c.setSpouse( value ); | 1378 | c.setSpouse( value ); |
1379 | } | 1379 | } |
1380 | else if ( name == "X-Qtopia-Gender" ) { | 1380 | else if ( name == "X-Qtopia-Gender" ) { |
1381 | c.setGender( value ); | 1381 | c.setGender( value ); |
1382 | } | 1382 | } |
1383 | else if ( name == "X-Qtopia-Anniversary" ) { | 1383 | else if ( name == "X-Qtopia-Anniversary" ) { |
1384 | c.setAnniversary( TimeConversion::fromString( value ) ); | 1384 | c.setAnniversary( TimeConversion::fromString( value ) ); |
1385 | } | 1385 | } |
1386 | else if ( name == "X-Qtopia-Nickname" ) { | 1386 | else if ( name == "X-Qtopia-Nickname" ) { |
1387 | c.setNickname( value ); | 1387 | c.setNickname( value ); |
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 |
1399 | else { | 1399 | else { |
1400 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 1400 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
1401 | VObjectIterator nit; | 1401 | VObjectIterator nit; |
1402 | initPropIterator( &nit, o ); | 1402 | initPropIterator( &nit, o ); |
1403 | while( moreIteration( &nit ) ) { | 1403 | while( moreIteration( &nit ) ) { |
1404 | VObject *o = nextVObject( &nit ); | 1404 | VObject *o = nextVObject( &nit ); |
1405 | QCString name = vObjectName( o ); | 1405 | QCString name = vObjectName( o ); |
1406 | QString value = vObjectStringZValue( o ); | 1406 | QString value = vObjectStringZValue( o ); |
1407 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 1407 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
1408 | } | 1408 | } |
1409 | } | 1409 | } |
1410 | #endif | 1410 | #endif |
1411 | } | 1411 | } |
1412 | c.setFileAs(); | 1412 | c.setFileAs(); |
1413 | return c; | 1413 | return c; |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | /*! | 1416 | /*! |
1417 | Writes the list of \a contacts as a set of VCards to the file \a filename. | 1417 | Writes the list of \a contacts as a set of VCards to the file \a filename. |
1418 | */ | 1418 | */ |
1419 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) | 1419 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) |
@@ -1443,49 +1443,58 @@ void OContact::writeVCard( const QString &filename, const OContact &contact) | |||
1443 | qWarning("Unable to open vcard write"); | 1443 | qWarning("Unable to open vcard write"); |
1444 | return; | 1444 | return; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | VObject *obj = createVObject( contact ); | 1447 | VObject *obj = createVObject( contact ); |
1448 | writeVObject( f.directHandle() , obj ); | 1448 | writeVObject( f.directHandle() , obj ); |
1449 | cleanVObject( obj ); | 1449 | cleanVObject( obj ); |
1450 | 1450 | ||
1451 | cleanStrTbl(); | 1451 | cleanStrTbl(); |
1452 | } | 1452 | } |
1453 | 1453 | ||
1454 | /*! | 1454 | /*! |
1455 | Returns the set of contacts read as VCards from the file \a filename. | 1455 | Returns the set of contacts read as VCards from the file \a filename. |
1456 | */ | 1456 | */ |
1457 | QValueList<OContact> OContact::readVCard( const QString &filename ) | 1457 | QValueList<OContact> OContact::readVCard( const QString &filename ) |
1458 | { | 1458 | { |
1459 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1459 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
1460 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1460 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
1461 | 1461 | ||
1462 | qDebug("vobject = %p", obj ); | 1462 | qDebug("vobject = %p", obj ); |
1463 | 1463 | ||
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); |
1471 | cleanVObject( t ); | 1480 | cleanVObject( t ); |
1472 | } | 1481 | } |
1473 | 1482 | ||
1474 | return contacts; | 1483 | return contacts; |
1475 | } | 1484 | } |
1476 | 1485 | ||
1477 | /*! | 1486 | /*! |
1478 | Returns TRUE if the contact matches the regular expression \a regexp. | 1487 | Returns TRUE if the contact matches the regular expression \a regexp. |
1479 | Otherwise returns FALSE. | 1488 | Otherwise returns FALSE. |
1480 | */ | 1489 | */ |
1481 | bool OContact::match( const QString ®exp ) const | 1490 | bool OContact::match( const QString ®exp ) const |
1482 | { | 1491 | { |
1483 | return match(QRegExp(regexp)); | 1492 | return match(QRegExp(regexp)); |
1484 | } | 1493 | } |
1485 | 1494 | ||
1486 | /*! | 1495 | /*! |
1487 | \overload | 1496 | \overload |
1488 | Returns TRUE if the contact matches the regular expression \a regexp. | 1497 | Returns TRUE if the contact matches the regular expression \a regexp. |
1489 | Otherwise returns FALSE. | 1498 | Otherwise returns FALSE. |
1490 | */ | 1499 | */ |
1491 | bool OContact::match( const QRegExp &r ) const | 1500 | bool OContact::match( const QRegExp &r ) const |
@@ -1506,148 +1515,148 @@ bool OContact::match( const QRegExp &r ) const | |||
1506 | QString OContact::toShortText() const | 1515 | QString OContact::toShortText() const |
1507 | { | 1516 | { |
1508 | return ( fullName() ); | 1517 | return ( fullName() ); |
1509 | } | 1518 | } |
1510 | QString OContact::type() const | 1519 | QString OContact::type() const |
1511 | { | 1520 | { |
1512 | return QString::fromLatin1( "OContact" ); | 1521 | return QString::fromLatin1( "OContact" ); |
1513 | } | 1522 | } |
1514 | 1523 | ||
1515 | // Definition is missing ! (se) | 1524 | // Definition is missing ! (se) |
1516 | QMap<QString,QString> OContact::toExtraMap() const | 1525 | QMap<QString,QString> OContact::toExtraMap() const |
1517 | { | 1526 | { |
1518 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 1527 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
1519 | QMap <QString,QString> useless; | 1528 | QMap <QString,QString> useless; |
1520 | return useless; | 1529 | return useless; |
1521 | } | 1530 | } |
1522 | 1531 | ||
1523 | class QString OContact::recordField( int pos ) const | 1532 | class QString OContact::recordField( int pos ) const |
1524 | { | 1533 | { |
1525 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1534 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1526 | return SLFIELDS[pos]; | 1535 | return SLFIELDS[pos]; |
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 | ||
1544 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1553 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1545 | Sets the anniversary of the contact to \a date. | 1554 | Sets the anniversary of the contact to \a date. |
1546 | */ | 1555 | */ |
1547 | void OContact::setAnniversary( const QDate &v ) | 1556 | void OContact::setAnniversary( const QDate &v ) |
1548 | { | 1557 | { |
1549 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1558 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1550 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); | 1559 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); |
1551 | } | 1560 | } |
1552 | 1561 | ||
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() ) |
1561 | return TimeConversion::fromString ( str ); | 1570 | return TimeConversion::fromString ( str ); |
1562 | else | 1571 | else |
1563 | return QDate(); | 1572 | return QDate(); |
1564 | } | 1573 | } |
1565 | 1574 | ||
1566 | 1575 | ||
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 | } |
1580 | 1589 | ||
1581 | 1590 | ||
1582 | void OContact::insertEmail( const QString &v ) | 1591 | void OContact::insertEmail( const QString &v ) |
1583 | { | 1592 | { |
1584 | //qDebug("insertEmail %s", v.latin1()); | 1593 | //qDebug("insertEmail %s", v.latin1()); |
1585 | QString e = v.simplifyWhiteSpace(); | 1594 | QString e = v.simplifyWhiteSpace(); |
1586 | QString def = defaultEmail(); | 1595 | QString def = defaultEmail(); |
1587 | 1596 | ||
1588 | // if no default, set it as the default email and don't insert | 1597 | // if no default, set it as the default email and don't insert |
1589 | if ( def.isEmpty() ) { | 1598 | if ( def.isEmpty() ) { |
1590 | setDefaultEmail( e ); // will insert into the list for us | 1599 | setDefaultEmail( e ); // will insert into the list for us |
1591 | return; | 1600 | return; |
1592 | } | 1601 | } |
1593 | 1602 | ||
1594 | // otherwise, insert assuming doesn't already exist | 1603 | // otherwise, insert assuming doesn't already exist |
1595 | QString emailsStr = find( Qtopia::Emails ); | 1604 | QString emailsStr = find( Qtopia::Emails ); |
1596 | if ( emailsStr.contains( e )) | 1605 | if ( emailsStr.contains( e )) |
1597 | return; | 1606 | return; |
1598 | if ( !emailsStr.isEmpty() ) | 1607 | if ( !emailsStr.isEmpty() ) |
1599 | emailsStr += emailSeparator(); | 1608 | emailsStr += emailSeparator(); |
1600 | emailsStr += e; | 1609 | emailsStr += e; |
1601 | replace( Qtopia::Emails, emailsStr ); | 1610 | replace( Qtopia::Emails, emailsStr ); |
1602 | } | 1611 | } |
1603 | 1612 | ||
1604 | void OContact::removeEmail( const QString &v ) | 1613 | void OContact::removeEmail( const QString &v ) |
1605 | { | 1614 | { |
1606 | QString e = v.simplifyWhiteSpace(); | 1615 | QString e = v.simplifyWhiteSpace(); |
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; |
1614 | 1623 | ||
1615 | // remove it | 1624 | // remove it |
1616 | //qDebug(" removing email from list %s", e.latin1()); | 1625 | //qDebug(" removing email from list %s", e.latin1()); |
1617 | emails.remove( e ); | 1626 | emails.remove( e ); |
1618 | // reset the string | 1627 | // reset the string |
1619 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | 1628 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator |
1620 | replace( Qtopia::Emails, emailsStr ); | 1629 | replace( Qtopia::Emails, emailsStr ); |
1621 | 1630 | ||
1622 | // if default, then replace the default email with the first one | 1631 | // if default, then replace the default email with the first one |
1623 | if ( def == e ) { | 1632 | if ( def == e ) { |
1624 | //qDebug("removeEmail is default; setting new default"); | 1633 | //qDebug("removeEmail is default; setting new default"); |
1625 | if ( !emails.count() ) | 1634 | if ( !emails.count() ) |
1626 | clearEmails(); | 1635 | clearEmails(); |
1627 | else // setDefaultEmail will remove e from the list | 1636 | else // setDefaultEmail will remove e from the list |
1628 | setDefaultEmail( emails.first() ); | 1637 | setDefaultEmail( emails.first() ); |
1629 | } | 1638 | } |
1630 | } | 1639 | } |
1631 | void OContact::clearEmails() | 1640 | void OContact::clearEmails() |
1632 | { | 1641 | { |
1633 | mMap.remove( Qtopia::DefaultEmail ); | 1642 | mMap.remove( Qtopia::DefaultEmail ); |
1634 | mMap.remove( Qtopia::Emails ); | 1643 | mMap.remove( Qtopia::Emails ); |
1635 | } | 1644 | } |
1636 | void OContact::setDefaultEmail( const QString &v ) | 1645 | void OContact::setDefaultEmail( const QString &v ) |
1637 | { | 1646 | { |
1638 | QString e = v.simplifyWhiteSpace(); | 1647 | QString e = v.simplifyWhiteSpace(); |
1639 | 1648 | ||
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 ) |
1649 | { | 1658 | { |
1650 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1659 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1651 | insertEmail( *it ); | 1660 | insertEmail( *it ); |
1652 | } | 1661 | } |
1653 | 1662 | ||