summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index d101589..9b196b5 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -801,130 +801,133 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeRes
801 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 801 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
802 QString name = (*it).uid().mid( 19 ); 802 QString name = (*it).uid().mid( 19 );
803 Addressee b = a; 803 Addressee b = a;
804 QString id = b.getID( name ); 804 QString id = b.getID( name );
805 if ( ! id.isEmpty() ) { 805 if ( ! id.isEmpty() ) {
806 QString des = (*it).note(); 806 QString des = (*it).note();
807 int startN; 807 int startN;
808 if( (startN = des.find( id ) ) >= 0 ) { 808 if( (startN = des.find( id ) ) >= 0 ) {
809 int endN = des.find( ",", startN+1 ); 809 int endN = des.find( ",", startN+1 );
810 des = des.left( startN ) + des.mid( endN+1 ); 810 des = des.left( startN ) + des.mid( endN+1 );
811 (*it).setNote( des ); 811 (*it).setNote( des );
812 } 812 }
813 } 813 }
814 } 814 }
815 } 815 }
816 } 816 }
817 if ( found ) 817 if ( found )
818 return; 818 return;
819 d->mAddressees.append( a ); 819 d->mAddressees.append( a );
820 Addressee& addr = d->mAddressees.last(); 820 Addressee& addr = d->mAddressees.last();
821 if ( addr.resource() == 0 ) 821 if ( addr.resource() == 0 )
822 addr.setResource( standardResource() ); 822 addr.setResource( standardResource() );
823 823
824 addr.setChanged( true ); 824 addr.setChanged( true );
825} 825}
826 826
827void AddressBook::removeAddressee( const Addressee &a ) 827void AddressBook::removeAddressee( const Addressee &a )
828{ 828{
829 Iterator it; 829 Iterator it;
830 Iterator it2; 830 Iterator it2;
831 bool found = false; 831 bool found = false;
832 for ( it = begin(); it != end(); ++it ) { 832 for ( it = begin(); it != end(); ++it ) {
833 if ( a.uid() == (*it).uid() ) { 833 if ( a.uid() == (*it).uid() ) {
834 found = true; 834 found = true;
835 it2 = it; 835 it2 = it;
836 } else { 836 } else {
837 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 837 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
838 QString name = (*it).uid().mid( 19 ); 838 QString name = (*it).uid().mid( 19 );
839 Addressee b = a; 839 Addressee b = a;
840 QString id = b.getID( name ); 840 QString id = b.getID( name );
841 if ( ! id.isEmpty() ) { 841 if ( ! id.isEmpty() ) {
842 QString des = (*it).note(); 842 QString des = (*it).note();
843 if( des.find( id ) < 0 ) { 843 if( des.find( id ) < 0 ) {
844 des += id + ","; 844 des += id + ",";
845 (*it).setNote( des ); 845 (*it).setNote( des );
846 } 846 }
847 } 847 }
848 } 848 }
849 849
850 } 850 }
851 } 851 }
852 852
853 if ( found ) 853 if ( found )
854 removeAddressee( it2 ); 854 removeAddressee( it2 );
855 855
856} 856}
857 857
858void AddressBook::removeSyncAddressees( bool removeDeleted ) 858void AddressBook::removeSyncAddressees( bool removeDeleted )
859{ 859{
860 Iterator it = begin(); 860 Iterator it = begin();
861 Iterator it2 ; 861 Iterator it2 ;
862 QDateTime dt ( QDate( 2004,1,1) ); 862 QDateTime dt ( QDate( 2004,1,1) );
863 while ( it != end() ) { 863 while ( it != end() ) {
864 (*it).setRevision( dt ); 864 (*it).setRevision( dt );
865 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 865 if (( *it).IDStr() != "changed" ) {
866 (*it).setIDStr(""); 866 // "changed" is used for tagging changed addressees when syncing with KDE or OL
867 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
868 (*it).setIDStr("");
869 }
867 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 870 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
868 it2 = it; 871 it2 = it;
869 //qDebug("removing %s ",(*it).uid().latin1() ); 872 //qDebug("removing %s ",(*it).uid().latin1() );
870 ++it; 873 ++it;
871 removeAddressee( it2 ); 874 removeAddressee( it2 );
872 } else { 875 } else {
873 //qDebug("skipping %s ",(*it).uid().latin1() ); 876 //qDebug("skipping %s ",(*it).uid().latin1() );
874 ++it; 877 ++it;
875 } 878 }
876 } 879 }
877 deleteRemovedAddressees(); 880 deleteRemovedAddressees();
878} 881}
879 882
880void AddressBook::removeAddressee( const Iterator &it ) 883void AddressBook::removeAddressee( const Iterator &it )
881{ 884{
882 d->mRemovedAddressees.append( (*it) ); 885 d->mRemovedAddressees.append( (*it) );
883 d->mAddressees.remove( it.d->mIt ); 886 d->mAddressees.remove( it.d->mIt );
884} 887}
885 888
886AddressBook::Iterator AddressBook::find( const Addressee &a ) 889AddressBook::Iterator AddressBook::find( const Addressee &a )
887{ 890{
888 Iterator it; 891 Iterator it;
889 for ( it = begin(); it != end(); ++it ) { 892 for ( it = begin(); it != end(); ++it ) {
890 if ( a.uid() == (*it).uid() ) { 893 if ( a.uid() == (*it).uid() ) {
891 return it; 894 return it;
892 } 895 }
893 } 896 }
894 return end(); 897 return end();
895} 898}
896 899
897Addressee AddressBook::findByUid( const QString &uid ) 900Addressee AddressBook::findByUid( const QString &uid )
898{ 901{
899 Iterator it; 902 Iterator it;
900 for ( it = begin(); it != end(); ++it ) { 903 for ( it = begin(); it != end(); ++it ) {
901 if ( uid == (*it).uid() ) { 904 if ( uid == (*it).uid() ) {
902 return *it; 905 return *it;
903 } 906 }
904 } 907 }
905 return Addressee(); 908 return Addressee();
906} 909}
907void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 910void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
908{ 911{
909 //qDebug("AddressBook::preExternSync "); 912 //qDebug("AddressBook::preExternSync ");
910 AddressBook::Iterator it; 913 AddressBook::Iterator it;
911 for ( it = begin(); it != end(); ++it ) { 914 for ( it = begin(); it != end(); ++it ) {
912 (*it).setID( csd, (*it).externalUID() ); 915 (*it).setID( csd, (*it).externalUID() );
913 (*it).computeCsum( csd ); 916 (*it).computeCsum( csd );
914 } 917 }
915 mergeAB( aBook ,csd, isSubset ); 918 mergeAB( aBook ,csd, isSubset );
916} 919}
917void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 920void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
918{ 921{
919 //qDebug("AddressBook::postExternSync "); 922 //qDebug("AddressBook::postExternSync ");
920 AddressBook::Iterator it; 923 AddressBook::Iterator it;
921 for ( it = begin(); it != end(); ++it ) { 924 for ( it = begin(); it != end(); ++it ) {
922 // qDebug("check uid %s ", (*it).uid().latin1() ); 925 // qDebug("check uid %s ", (*it).uid().latin1() );
923 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 926 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
924 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 927 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
925 Addressee ad = aBook->findByUid( ( (*it).uid() )); 928 Addressee ad = aBook->findByUid( ( (*it).uid() ));
926 if ( ad.isEmpty() ) { 929 if ( ad.isEmpty() ) {
927 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 930 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
928 } else { 931 } else {
929 (*it).computeCsum( csd ); 932 (*it).computeCsum( csd );
930 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 933 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )