summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 19c26eb..8882259 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -802,186 +802,186 @@ void AddressBook::removeAddressee( const Addressee &a )
802 if( des.find( id ) < 0 ) { 802 if( des.find( id ) < 0 ) {
803 des += id + ","; 803 des += id + ",";
804 (*it).setNote( des ); 804 (*it).setNote( des );
805 } 805 }
806 } 806 }
807 } 807 }
808 808
809 } 809 }
810 } 810 }
811 811
812 if ( found ) 812 if ( found )
813 removeAddressee( it2 ); 813 removeAddressee( it2 );
814 814
815} 815}
816 816
817void AddressBook::removeSyncAddressees( bool removeDeleted ) 817void AddressBook::removeSyncAddressees( bool removeDeleted )
818{ 818{
819 Iterator it = begin(); 819 Iterator it = begin();
820 Iterator it2 ; 820 Iterator it2 ;
821 QDateTime dt ( QDate( 2004,1,1) ); 821 QDateTime dt ( QDate( 2004,1,1) );
822 while ( it != end() ) { 822 while ( it != end() ) {
823 (*it).setRevision( dt ); 823 (*it).setRevision( dt );
824 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 824 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
825 (*it).setIDStr(""); 825 (*it).setIDStr("");
826 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 826 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
827 it2 = it; 827 it2 = it;
828 //qDebug("removing %s ",(*it).uid().latin1() ); 828 //qDebug("removing %s ",(*it).uid().latin1() );
829 ++it; 829 ++it;
830 removeAddressee( it2 ); 830 removeAddressee( it2 );
831 } else { 831 } else {
832 //qDebug("skipping %s ",(*it).uid().latin1() ); 832 //qDebug("skipping %s ",(*it).uid().latin1() );
833 ++it; 833 ++it;
834 } 834 }
835 } 835 }
836 deleteRemovedAddressees(); 836 deleteRemovedAddressees();
837} 837}
838 838
839void AddressBook::removeAddressee( const Iterator &it ) 839void AddressBook::removeAddressee( const Iterator &it )
840{ 840{
841 d->mRemovedAddressees.append( (*it) ); 841 d->mRemovedAddressees.append( (*it) );
842 d->mAddressees.remove( it.d->mIt ); 842 d->mAddressees.remove( it.d->mIt );
843} 843}
844 844
845AddressBook::Iterator AddressBook::find( const Addressee &a ) 845AddressBook::Iterator AddressBook::find( const Addressee &a )
846{ 846{
847 Iterator it; 847 Iterator it;
848 for ( it = begin(); it != end(); ++it ) { 848 for ( it = begin(); it != end(); ++it ) {
849 if ( a.uid() == (*it).uid() ) { 849 if ( a.uid() == (*it).uid() ) {
850 return it; 850 return it;
851 } 851 }
852 } 852 }
853 return end(); 853 return end();
854} 854}
855 855
856Addressee AddressBook::findByUid( const QString &uid ) 856Addressee AddressBook::findByUid( const QString &uid )
857{ 857{
858 Iterator it; 858 Iterator it;
859 for ( it = begin(); it != end(); ++it ) { 859 for ( it = begin(); it != end(); ++it ) {
860 if ( uid == (*it).uid() ) { 860 if ( uid == (*it).uid() ) {
861 return *it; 861 return *it;
862 } 862 }
863 } 863 }
864 return Addressee(); 864 return Addressee();
865} 865}
866void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 866void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
867{ 867{
868 //qDebug("AddressBook::preExternSync "); 868 //qDebug("AddressBook::preExternSync ");
869 AddressBook::Iterator it; 869 AddressBook::Iterator it;
870 for ( it = begin(); it != end(); ++it ) { 870 for ( it = begin(); it != end(); ++it ) {
871 (*it).setID( csd, (*it).externalUID() ); 871 (*it).setID( csd, (*it).externalUID() );
872 (*it).computeCsum( csd ); 872 (*it).computeCsum( csd );
873 } 873 }
874 mergeAB( aBook ,csd ); 874 mergeAB( aBook ,csd, isSubset );
875} 875}
876void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 876void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
877{ 877{
878 //qDebug("AddressBook::postExternSync "); 878 //qDebug("AddressBook::postExternSync ");
879 AddressBook::Iterator it; 879 AddressBook::Iterator it;
880 for ( it = begin(); it != end(); ++it ) { 880 for ( it = begin(); it != end(); ++it ) {
881 // qDebug("check uid %s ", (*it).uid().latin1() ); 881 // qDebug("check uid %s ", (*it).uid().latin1() );
882 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 882 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
883 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 883 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
884 Addressee ad = aBook->findByUid( ( (*it).uid() )); 884 Addressee ad = aBook->findByUid( ( (*it).uid() ));
885 if ( ad.isEmpty() ) { 885 if ( ad.isEmpty() ) {
886 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 886 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
887 } else { 887 } else {
888 (*it).computeCsum( csd ); 888 (*it).computeCsum( csd );
889 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 889 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
890 ad.setID( csd, (*it).externalUID() ); 890 ad.setID( csd, (*it).externalUID() );
891 ad.setCsum( csd, (*it).getCsum( csd ) ); 891 ad.setCsum( csd, (*it).getCsum( csd ) );
892 aBook->insertAddressee( ad ); 892 aBook->insertAddressee( ad );
893 } 893 }
894 } 894 }
895 } 895 }
896} 896}
897 897
898bool AddressBook::containsExternalUid( const QString& uid ) 898bool AddressBook::containsExternalUid( const QString& uid )
899{ 899{
900 Iterator it; 900 Iterator it;
901 for ( it = begin(); it != end(); ++it ) { 901 for ( it = begin(); it != end(); ++it ) {
902 if ( uid == (*it).externalUID( ) ) 902 if ( uid == (*it).externalUID( ) )
903 return true; 903 return true;
904 } 904 }
905 return false; 905 return false;
906} 906}
907Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 907Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
908{ 908{
909 Iterator it; 909 Iterator it;
910 for ( it = begin(); it != end(); ++it ) { 910 for ( it = begin(); it != end(); ++it ) {
911 if ( uid == (*it).getID( profile ) ) 911 if ( uid == (*it).getID( profile ) )
912 return (*it); 912 return (*it);
913 } 913 }
914 return Addressee(); 914 return Addressee();
915} 915}
916void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 916void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
917{ 917{
918 Iterator it; 918 Iterator it;
919 Addressee ad; 919 Addressee ad;
920 for ( it = begin(); it != end(); ++it ) { 920 for ( it = begin(); it != end(); ++it ) {
921 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 921 ad = aBook->findByExternUid( (*it).externalUID(), profile );
922 if ( !ad.isEmpty() ) { 922 if ( !ad.isEmpty() ) {
923 (*it).mergeContact( ad ); 923 (*it).mergeContact( ad ,isSubset);
924 } 924 }
925 } 925 }
926#if 0 926#if 0
927 // test only 927 // test only
928 for ( it = begin(); it != end(); ++it ) { 928 for ( it = begin(); it != end(); ++it ) {
929 929
930 qDebug("uid %s ", (*it).uid().latin1()); 930 qDebug("uid %s ", (*it).uid().latin1());
931 } 931 }
932#endif 932#endif
933} 933}
934 934
935#if 0 935#if 0
936Addressee::List AddressBook::getExternLastSyncAddressees() 936Addressee::List AddressBook::getExternLastSyncAddressees()
937{ 937{
938 Addressee::List results; 938 Addressee::List results;
939 939
940 Iterator it; 940 Iterator it;
941 for ( it = begin(); it != end(); ++it ) { 941 for ( it = begin(); it != end(); ++it ) {
942 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 942 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
943 if ( (*it).familyName().left(4) == "!E: " ) 943 if ( (*it).familyName().left(4) == "!E: " )
944 results.append( *it ); 944 results.append( *it );
945 } 945 }
946 } 946 }
947 947
948 return results; 948 return results;
949} 949}
950#endif 950#endif
951void AddressBook::resetTempSyncStat() 951void AddressBook::resetTempSyncStat()
952{ 952{
953 Iterator it; 953 Iterator it;
954 for ( it = begin(); it != end(); ++it ) { 954 for ( it = begin(); it != end(); ++it ) {
955 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 955 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
956 } 956 }
957 957
958} 958}
959 959
960QStringList AddressBook:: uidList() 960QStringList AddressBook:: uidList()
961{ 961{
962 QStringList results; 962 QStringList results;
963 Iterator it; 963 Iterator it;
964 for ( it = begin(); it != end(); ++it ) { 964 for ( it = begin(); it != end(); ++it ) {
965 results.append( (*it).uid() ); 965 results.append( (*it).uid() );
966 } 966 }
967 return results; 967 return results;
968} 968}
969 969
970 970
971Addressee::List AddressBook::allAddressees() 971Addressee::List AddressBook::allAddressees()
972{ 972{
973 return d->mAddressees; 973 return d->mAddressees;
974 974
975} 975}
976 976
977Addressee::List AddressBook::findByName( const QString &name ) 977Addressee::List AddressBook::findByName( const QString &name )
978{ 978{
979 Addressee::List results; 979 Addressee::List results;
980 980
981 Iterator it; 981 Iterator it;
982 for ( it = begin(); it != end(); ++it ) { 982 for ( it = begin(); it != end(); ++it ) {
983 if ( name == (*it).realName() ) { 983 if ( name == (*it).realName() ) {
984 results.append( *it ); 984 results.append( *it );
985 } 985 }
986 } 986 }
987 987