summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 2785131..df0fba4 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -497,128 +497,149 @@ int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool remo
497 KABC::VCardTool tool; 497 KABC::VCardTool tool;
498 list = tool.parseVCards( data ); 498 list = tool.parseVCards( data );
499 KABC::Addressee::List::Iterator it; 499 KABC::Addressee::List::Iterator it;
500 for ( it = list.begin(); it != list.end(); ++it ) { 500 for ( it = list.begin(); it != list.end(); ++it ) {
501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
502 if ( !id.isEmpty() ) 502 if ( !id.isEmpty() )
503 (*it).setIDStr(id ); 503 (*it).setIDStr(id );
504 (*it).setResource( 0 ); 504 (*it).setResource( 0 );
505 if ( replaceLabel ) 505 if ( replaceLabel )
506 (*it).removeVoice(); 506 (*it).removeVoice();
507 if ( removeOld ) 507 if ( removeOld )
508 (*it).setTagged( true ); 508 (*it).setTagged( true );
509 insertAddressee( (*it), false, true ); 509 insertAddressee( (*it), false, true );
510 } 510 }
511 if ( removeOld ) 511 if ( removeOld )
512 removeUntagged(); 512 removeUntagged();
513 return list.count(); 513 return list.count();
514} 514}
515void AddressBook::setUntagged(bool setNonSyncTagged) // = false) 515void AddressBook::setUntagged(bool setNonSyncTagged) // = false)
516{ 516{
517 Iterator ait; 517 Iterator ait;
518 for ( ait = begin(); ait != end(); ++ait ) { 518 for ( ait = begin(); ait != end(); ++ait ) {
519 if ( setNonSyncTagged ) { 519 if ( setNonSyncTagged ) {
520 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { 520 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
521 (*ait).setTagged( true ); 521 (*ait).setTagged( true );
522 } else 522 } else
523 (*ait).setTagged( false ); 523 (*ait).setTagged( false );
524 } else 524 } else
525 (*ait).setTagged( false ); 525 (*ait).setTagged( false );
526 } 526 }
527} 527}
528void AddressBook::removeUntagged() 528void AddressBook::removeUntagged()
529{ 529{
530 Iterator ait; 530 Iterator ait;
531 bool todelete = false; 531 bool todelete = false;
532 Iterator todel; 532 Iterator todel;
533 for ( ait = begin(); ait != end(); ++ait ) { 533 for ( ait = begin(); ait != end(); ++ait ) {
534 if ( todelete ) 534 if ( todelete )
535 removeAddressee( todel ); 535 removeAddressee( todel );
536 if (!(*ait).tagged()) { 536 if (!(*ait).tagged()) {
537 todelete = true; 537 todelete = true;
538 todel = ait; 538 todel = ait;
539 } else 539 } else
540 todelete = false; 540 todelete = false;
541 } 541 }
542 if ( todelete ) 542 if ( todelete )
543 removeAddressee( todel ); 543 removeAddressee( todel );
544 deleteRemovedAddressees(); 544 deleteRemovedAddressees();
545} 545}
546void AddressBook::smplifyAddressees() 546void AddressBook::smplifyAddressees()
547{ 547{
548 Iterator ait; 548 Iterator ait;
549 for ( ait = begin(); ait != end(); ++ait ) { 549 for ( ait = begin(); ait != end(); ++ait ) {
550 (*ait).simplifyEmails(); 550 (*ait).simplifyEmails();
551 (*ait).simplifyPhoneNumbers(); 551 (*ait).simplifyPhoneNumbers();
552 (*ait).simplifyPhoneNumberTypes(); 552 (*ait).simplifyPhoneNumberTypes();
553 (*ait).simplifyAddresses(); 553 (*ait).simplifyAddresses();
554 } 554 }
555} 555}
556void AddressBook::removeSyncInfo( QString syncProfile) 556void AddressBook::removeSyncInfo( QString syncProfile)
557{ 557{
558 Iterator ait; 558 Iterator ait;
559 for ( ait = begin(); ait != end(); ++ait ) { 559 for ( ait = begin(); ait != end(); ++ait ) {
560 (*ait).removeID( syncProfile ); 560 (*ait).removeID( syncProfile );
561 }
562 if ( syncProfile.isEmpty() ) {
563 Iterator it = begin();
564 Iterator it2 ;
565 QDateTime dt ( QDate( 2004,1,1) );
566 while ( it != end() ) {
567 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
568 it2 = it;
569 //qDebug("removing %s ",(*it).uid().latin1() );
570 ++it;
571 removeAddressee( it2 );
572 } else {
573 //qDebug("skipping %s ",(*it).uid().latin1() );
574 ++it;
575 }
576 }
577 } else {
578 Addressee lse;
579 lse = mAddressBook->findByUid( "last-syncAddressee-"+ syncProfile );
580 if ( ! lse.isEmpty() )
581 removeAddressee( lse );
561 } 582 }
562 583
563} 584}
564void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 585void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
565{ 586{
566 Iterator ait; 587 Iterator ait;
567 for ( ait = begin(); ait != end(); ++ait ) { 588 for ( ait = begin(); ait != end(); ++ait ) {
568 QString id = (*ait).IDStr(); 589 QString id = (*ait).IDStr();
569 (*ait).setIDStr( ":"); 590 (*ait).setIDStr( ":");
570 (*ait).setExternalUID( id ); 591 (*ait).setExternalUID( id );
571 (*ait).setOriginalExternalUID( id ); 592 (*ait).setOriginalExternalUID( id );
572 if ( isPreSync ) 593 if ( isPreSync )
573 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 594 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
574 else { 595 else {
575 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 596 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
576 (*ait).setID( currentSyncDevice,id ); 597 (*ait).setID( currentSyncDevice,id );
577 598
578 } 599 }
579 } 600 }
580} 601}
581void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 602void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
582{ 603{
583 604
584 setUntagged(); 605 setUntagged();
585 KABC::Addressee::List list; 606 KABC::Addressee::List list;
586 QFile file( fileName ); 607 QFile file( fileName );
587 file.open( IO_ReadOnly ); 608 file.open( IO_ReadOnly );
588 QByteArray rawData = file.readAll(); 609 QByteArray rawData = file.readAll();
589 file.close(); 610 file.close();
590 QString data; 611 QString data;
591 612
592 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 613 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
593 KABC::VCardTool tool; 614 KABC::VCardTool tool;
594 list = tool.parseVCards( data ); 615 list = tool.parseVCards( data );
595 KABC::Addressee::List::Iterator it; 616 KABC::Addressee::List::Iterator it;
596 for ( it = list.begin(); it != list.end(); ++it ) { 617 for ( it = list.begin(); it != list.end(); ++it ) {
597 Iterator ait; 618 Iterator ait;
598 for ( ait = begin(); ait != end(); ++ait ) { 619 for ( ait = begin(); ait != end(); ++ait ) {
599 if ( !(*ait).tagged() ) { 620 if ( !(*ait).tagged() ) {
600 if ( (*ait).containsAdr(*it)) { 621 if ( (*ait).containsAdr(*it)) {
601 (*ait).setTagged(true); 622 (*ait).setTagged(true);
602 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 623 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
603 (*it).setIDStr( ":"); 624 (*it).setIDStr( ":");
604 (*it).setID( currentSyncDevice,id ); 625 (*it).setID( currentSyncDevice,id );
605 (*it).setExternalUID( id ); 626 (*it).setExternalUID( id );
606 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 627 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
607 (*it).setUid( ( (*ait).uid() )); 628 (*it).setUid( ( (*ait).uid() ));
608 break; 629 break;
609 } 630 }
610 } 631 }
611 632
612 } 633 }
613 if ( ait == end() ) 634 if ( ait == end() )
614 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); 635 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
615 } 636 }
616 clear(); 637 clear();
617 for ( it = list.begin(); it != list.end(); ++it ) { 638 for ( it = list.begin(); it != list.end(); ++it ) {
618 insertAddressee( (*it) ); 639 insertAddressee( (*it) );
619 } 640 }
620} 641}
621 642
622bool AddressBook::saveABphone( QString fileName ) 643bool AddressBook::saveABphone( QString fileName )
623{ 644{
624 //smplifyAddressees(); 645 //smplifyAddressees();