-rw-r--r-- | kabc/addressbook.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index f9e4387..fe59fcb 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -901,116 +901,134 @@ void AddressBook::removeSyncAddressees( bool removeDeleted ) | |||
901 | if ( removeDeleted ) { | 901 | if ( removeDeleted ) { |
902 | // we have no postprocessing in the resource, we have to do it here | 902 | // we have no postprocessing in the resource, we have to do it here |
903 | // we have to compute csum for all, because it could be the first sync | 903 | // we have to compute csum for all, because it could be the first sync |
904 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 904 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
905 | } | 905 | } |
906 | ++it; | 906 | ++it; |
907 | } | 907 | } |
908 | } | 908 | } |
909 | deleteRemovedAddressees(); | 909 | deleteRemovedAddressees(); |
910 | } | 910 | } |
911 | 911 | ||
912 | void AddressBook::removeAddressee( const Iterator &it ) | 912 | void AddressBook::removeAddressee( const Iterator &it ) |
913 | { | 913 | { |
914 | d->mRemovedAddressees.append( (*it) ); | 914 | d->mRemovedAddressees.append( (*it) ); |
915 | d->mAddressees.remove( it.d->mIt ); | 915 | d->mAddressees.remove( it.d->mIt ); |
916 | } | 916 | } |
917 | 917 | ||
918 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 918 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
919 | { | 919 | { |
920 | Iterator it; | 920 | Iterator it; |
921 | for ( it = begin(); it != end(); ++it ) { | 921 | for ( it = begin(); it != end(); ++it ) { |
922 | if ( a.uid() == (*it).uid() ) { | 922 | if ( a.uid() == (*it).uid() ) { |
923 | return it; | 923 | return it; |
924 | } | 924 | } |
925 | } | 925 | } |
926 | return end(); | 926 | return end(); |
927 | } | 927 | } |
928 | 928 | ||
929 | Addressee AddressBook::findByUid( const QString &uid ) | 929 | Addressee AddressBook::findByUid( const QString &uid ) |
930 | { | 930 | { |
931 | Iterator it; | 931 | Iterator it; |
932 | for ( it = begin(); it != end(); ++it ) { | 932 | for ( it = begin(); it != end(); ++it ) { |
933 | if ( uid == (*it).uid() ) { | 933 | if ( uid == (*it).uid() ) { |
934 | return *it; | 934 | return *it; |
935 | } | 935 | } |
936 | } | 936 | } |
937 | return Addressee(); | 937 | return Addressee(); |
938 | } | 938 | } |
939 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 939 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
940 | { | 940 | { |
941 | //qDebug("AddressBook::preExternSync "); | 941 | //qDebug("AddressBook::preExternSync "); |
942 | AddressBook::Iterator it; | 942 | AddressBook::Iterator it; |
943 | for ( it = begin(); it != end(); ++it ) { | 943 | for ( it = begin(); it != end(); ++it ) { |
944 | (*it).setID( csd, (*it).externalUID() ); | 944 | (*it).setID( csd, (*it).externalUID() ); |
945 | (*it).computeCsum( csd ); | 945 | (*it).computeCsum( csd ); |
946 | } | 946 | } |
947 | mergeAB( aBook ,csd, isSubset ); | 947 | mergeAB( aBook ,csd, isSubset ); |
948 | } | 948 | } |
949 | void AddressBook::preOLSync( AddressBook* aBook, const QString& csd ) | ||
950 | { | ||
951 | //qDebug("AddressBook::preExternSync "); | ||
952 | AddressBook::Iterator it; | ||
953 | for ( it = begin(); it != end(); ++it ) { | ||
954 | (*it).setID( csd, (*it).externalUID() ); | ||
955 | (*it).computeCsum( csd ); | ||
956 | } | ||
957 | |||
958 | Addressee ad; | ||
959 | for ( it = begin(); it != end(); ++it ) { | ||
960 | ad = aBook->findByExternUid( (*it).externalUID(), csd ); | ||
961 | if ( !ad.isEmpty() ) { | ||
962 | (*it).mergeOLContact( ad ); | ||
963 | } | ||
964 | } | ||
965 | } | ||
949 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) | 966 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
950 | { | 967 | { |
951 | //qDebug("AddressBook::postExternSync "); | 968 | //qDebug("AddressBook::postExternSync "); |
952 | AddressBook::Iterator it; | 969 | AddressBook::Iterator it; |
953 | int foundEmpty = 0; | 970 | int foundEmpty = 0; |
954 | for ( it = begin(); it != end(); ++it ) { | 971 | for ( it = begin(); it != end(); ++it ) { |
955 | //qDebug("check uid %s ", (*it).uid().latin1() ); | 972 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
956 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 973 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
957 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || | 974 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || |
958 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { | 975 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { |
959 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 976 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
960 | if ( ad.isEmpty() ) { | 977 | if ( ad.isEmpty() ) { |
961 | ++foundEmpty; | 978 | ++foundEmpty; |
962 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); | 979 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); |
963 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); | 980 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); |
964 | } else { | 981 | } else { |
965 | (*it).setIDStr(":"); | 982 | (*it).setIDStr(":"); |
966 | if ( setID ) { | 983 | if ( setID ) { |
967 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 984 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
968 | ad.setID( csd, (*it).externalUID() ); | 985 | ad.setID( csd, (*it).externalUID() );{ |
986 | } | ||
969 | } else | 987 | } else |
970 | ad.setID( csd, (*it).uid() ); | 988 | ad.setID( csd, (*it).uid() ); |
971 | (*it).computeCsum( csd ); | 989 | (*it).computeCsum( csd ); |
972 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 990 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
973 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); | 991 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); |
974 | aBook->insertAddressee( ad , false); | 992 | aBook->insertAddressee( ad , false); |
975 | } | 993 | } |
976 | } | 994 | } |
977 | } | 995 | } |
978 | if ( foundEmpty ) { | 996 | if ( foundEmpty ) { |
979 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); | 997 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); |
980 | } | 998 | } |
981 | 999 | ||
982 | } | 1000 | } |
983 | 1001 | ||
984 | bool AddressBook::containsExternalUid( const QString& uid ) | 1002 | bool AddressBook::containsExternalUid( const QString& uid ) |
985 | { | 1003 | { |
986 | Iterator it; | 1004 | Iterator it; |
987 | for ( it = begin(); it != end(); ++it ) { | 1005 | for ( it = begin(); it != end(); ++it ) { |
988 | if ( uid == (*it).externalUID( ) ) | 1006 | if ( uid == (*it).externalUID( ) ) |
989 | return true; | 1007 | return true; |
990 | } | 1008 | } |
991 | return false; | 1009 | return false; |
992 | } | 1010 | } |
993 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const | 1011 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const |
994 | { | 1012 | { |
995 | ConstIterator it; | 1013 | ConstIterator it; |
996 | for ( it = begin(); it != end(); ++it ) { | 1014 | for ( it = begin(); it != end(); ++it ) { |
997 | if ( uid == (*it).getID( profile ) ) | 1015 | if ( uid == (*it).getID( profile ) ) |
998 | return (*it); | 1016 | return (*it); |
999 | } | 1017 | } |
1000 | return Addressee(); | 1018 | return Addressee(); |
1001 | } | 1019 | } |
1002 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 1020 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
1003 | { | 1021 | { |
1004 | Iterator it; | 1022 | Iterator it; |
1005 | Addressee ad; | 1023 | Addressee ad; |
1006 | for ( it = begin(); it != end(); ++it ) { | 1024 | for ( it = begin(); it != end(); ++it ) { |
1007 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 1025 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
1008 | if ( !ad.isEmpty() ) { | 1026 | if ( !ad.isEmpty() ) { |
1009 | (*it).mergeContact( ad ,isSubset); | 1027 | (*it).mergeContact( ad ,isSubset); |
1010 | } | 1028 | } |
1011 | } | 1029 | } |
1012 | #if 0 | 1030 | #if 0 |
1013 | // test only | 1031 | // test only |
1014 | for ( it = begin(); it != end(); ++it ) { | 1032 | for ( it = begin(); it != end(); ++it ) { |
1015 | 1033 | ||
1016 | qDebug("uid %s ", (*it).uid().latin1()); | 1034 | qDebug("uid %s ", (*it).uid().latin1()); |