summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 4de7da2..9e61261 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -867,195 +867,195 @@ void AddressBook::removeSyncAddressees( bool removeDeleted )
867 ++it; 867 ++it;
868 removeAddressee( it2 ); 868 removeAddressee( it2 );
869 } else { 869 } else {
870 //qDebug("skipping %s ",(*it).uid().latin1() ); 870 //qDebug("skipping %s ",(*it).uid().latin1() );
871 if ( removeDeleted ) { 871 if ( removeDeleted ) {
872 // we have no postprocessing in the resource, we have to do it here 872 // we have no postprocessing in the resource, we have to do it here
873 // we have to compute csum for all, because it could be the first sync 873 // we have to compute csum for all, because it could be the first sync
874 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 874 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
875 } 875 }
876 ++it; 876 ++it;
877 } 877 }
878 } 878 }
879 deleteRemovedAddressees(); 879 deleteRemovedAddressees();
880} 880}
881 881
882void AddressBook::removeAddressee( const Iterator &it ) 882void AddressBook::removeAddressee( const Iterator &it )
883{ 883{
884 d->mRemovedAddressees.append( (*it) ); 884 d->mRemovedAddressees.append( (*it) );
885 d->mAddressees.remove( it.d->mIt ); 885 d->mAddressees.remove( it.d->mIt );
886} 886}
887 887
888AddressBook::Iterator AddressBook::find( const Addressee &a ) 888AddressBook::Iterator AddressBook::find( const Addressee &a )
889{ 889{
890 Iterator it; 890 Iterator it;
891 for ( it = begin(); it != end(); ++it ) { 891 for ( it = begin(); it != end(); ++it ) {
892 if ( a.uid() == (*it).uid() ) { 892 if ( a.uid() == (*it).uid() ) {
893 return it; 893 return it;
894 } 894 }
895 } 895 }
896 return end(); 896 return end();
897} 897}
898 898
899Addressee AddressBook::findByUid( const QString &uid ) 899Addressee AddressBook::findByUid( const QString &uid )
900{ 900{
901 Iterator it; 901 Iterator it;
902 for ( it = begin(); it != end(); ++it ) { 902 for ( it = begin(); it != end(); ++it ) {
903 if ( uid == (*it).uid() ) { 903 if ( uid == (*it).uid() ) {
904 return *it; 904 return *it;
905 } 905 }
906 } 906 }
907 return Addressee(); 907 return Addressee();
908} 908}
909void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 909void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
910{ 910{
911 //qDebug("AddressBook::preExternSync "); 911 //qDebug("AddressBook::preExternSync ");
912 AddressBook::Iterator it; 912 AddressBook::Iterator it;
913 for ( it = begin(); it != end(); ++it ) { 913 for ( it = begin(); it != end(); ++it ) {
914 (*it).setID( csd, (*it).externalUID() ); 914 (*it).setID( csd, (*it).externalUID() );
915 (*it).computeCsum( csd ); 915 (*it).computeCsum( csd );
916 } 916 }
917 mergeAB( aBook ,csd, isSubset ); 917 mergeAB( aBook ,csd, isSubset );
918} 918}
919void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) 919void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
920{ 920{
921 //qDebug("AddressBook::postExternSync "); 921 //qDebug("AddressBook::postExternSync ");
922 AddressBook::Iterator it; 922 AddressBook::Iterator it;
923 int foundEmpty = 0; 923 int foundEmpty = 0;
924 for ( it = begin(); it != end(); ++it ) { 924 for ( it = begin(); it != end(); ++it ) {
925 //qDebug("check uid %s ", (*it).uid().latin1() ); 925 //qDebug("check uid %s ", (*it).uid().latin1() );
926 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 926 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
927 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || 927 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ||
928 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { 928 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) {
929 Addressee ad = aBook->findByUid( ( (*it).uid() )); 929 Addressee ad = aBook->findByUid( ( (*it).uid() ));
930 if ( ad.isEmpty() ) { 930 if ( ad.isEmpty() ) {
931 ++foundEmpty; 931 ++foundEmpty;
932 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); 932 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1());
933 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); 933 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() );
934 } else { 934 } else {
935 (*it).setIDStr(":"); 935 (*it).setIDStr(":");
936 if ( setID ) { 936 if ( setID ) {
937 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 937 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
938 ad.setID( csd, (*it).externalUID() ); 938 ad.setID( csd, (*it).externalUID() );
939 } else 939 } else
940 ad.setID( csd, (*it).uid() ); 940 ad.setID( csd, (*it).uid() );
941 (*it).computeCsum( csd ); 941 (*it).computeCsum( csd );
942 ad.setCsum( csd, (*it).getCsum( csd ) ); 942 ad.setCsum( csd, (*it).getCsum( csd ) );
943 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); 943 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() );
944 aBook->insertAddressee( ad , false); 944 aBook->insertAddressee( ad , false);
945 } 945 }
946 } 946 }
947 } 947 }
948 if ( foundEmpty ) { 948 if ( foundEmpty ) {
949 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); 949 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty );
950 } 950 }
951 951
952} 952}
953 953
954bool AddressBook::containsExternalUid( const QString& uid ) 954bool AddressBook::containsExternalUid( const QString& uid )
955{ 955{
956 Iterator it; 956 Iterator it;
957 for ( it = begin(); it != end(); ++it ) { 957 for ( it = begin(); it != end(); ++it ) {
958 if ( uid == (*it).externalUID( ) ) 958 if ( uid == (*it).externalUID( ) )
959 return true; 959 return true;
960 } 960 }
961 return false; 961 return false;
962} 962}
963Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 963const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const
964{ 964{
965 Iterator it; 965 ConstIterator it;
966 for ( it = begin(); it != end(); ++it ) { 966 for ( it = begin(); it != end(); ++it ) {
967 if ( uid == (*it).getID( profile ) ) 967 if ( uid == (*it).getID( profile ) )
968 return (*it); 968 return (*it);
969 } 969 }
970 return Addressee(); 970 return Addressee();
971} 971}
972void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) 972void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
973{ 973{
974 Iterator it; 974 Iterator it;
975 Addressee ad; 975 Addressee ad;
976 for ( it = begin(); it != end(); ++it ) { 976 for ( it = begin(); it != end(); ++it ) {
977 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 977 ad = aBook->findByExternUid( (*it).externalUID(), profile );
978 if ( !ad.isEmpty() ) { 978 if ( !ad.isEmpty() ) {
979 (*it).mergeContact( ad ,isSubset); 979 (*it).mergeContact( ad ,isSubset);
980 } 980 }
981 } 981 }
982#if 0 982#if 0
983 // test only 983 // test only
984 for ( it = begin(); it != end(); ++it ) { 984 for ( it = begin(); it != end(); ++it ) {
985 985
986 qDebug("uid %s ", (*it).uid().latin1()); 986 qDebug("uid %s ", (*it).uid().latin1());
987 } 987 }
988#endif 988#endif
989} 989}
990 990
991#if 0 991#if 0
992Addressee::List AddressBook::getExternLastSyncAddressees() 992Addressee::List AddressBook::getExternLastSyncAddressees()
993{ 993{
994 Addressee::List results; 994 Addressee::List results;
995 995
996 Iterator it; 996 Iterator it;
997 for ( it = begin(); it != end(); ++it ) { 997 for ( it = begin(); it != end(); ++it ) {
998 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 998 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
999 if ( (*it).familyName().left(4) == "!E: " ) 999 if ( (*it).familyName().left(4) == "!E: " )
1000 results.append( *it ); 1000 results.append( *it );
1001 } 1001 }
1002 } 1002 }
1003 1003
1004 return results; 1004 return results;
1005} 1005}
1006#endif 1006#endif
1007void AddressBook::resetTempSyncStat() 1007void AddressBook::resetTempSyncStat()
1008{ 1008{
1009 Iterator it; 1009 Iterator it;
1010 for ( it = begin(); it != end(); ++it ) { 1010 for ( it = begin(); it != end(); ++it ) {
1011 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 1011 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
1012 } 1012 }
1013 1013
1014} 1014}
1015 1015
1016QStringList AddressBook:: uidList() 1016QStringList AddressBook:: uidList()
1017{ 1017{
1018 QStringList results; 1018 QStringList results;
1019 Iterator it; 1019 Iterator it;
1020 for ( it = begin(); it != end(); ++it ) { 1020 for ( it = begin(); it != end(); ++it ) {
1021 results.append( (*it).uid() ); 1021 results.append( (*it).uid() );
1022 } 1022 }
1023 return results; 1023 return results;
1024} 1024}
1025 1025
1026 1026
1027Addressee::List AddressBook::allAddressees() 1027Addressee::List AddressBook::allAddressees()
1028{ 1028{
1029 return d->mAddressees; 1029 return d->mAddressees;
1030 1030
1031} 1031}
1032 1032
1033Addressee::List AddressBook::findByName( const QString &name ) 1033Addressee::List AddressBook::findByName( const QString &name )
1034{ 1034{
1035 Addressee::List results; 1035 Addressee::List results;
1036 1036
1037 Iterator it; 1037 Iterator it;
1038 for ( it = begin(); it != end(); ++it ) { 1038 for ( it = begin(); it != end(); ++it ) {
1039 if ( name == (*it).realName() ) { 1039 if ( name == (*it).realName() ) {
1040 results.append( *it ); 1040 results.append( *it );
1041 } 1041 }
1042 } 1042 }
1043 1043
1044 return results; 1044 return results;
1045} 1045}
1046 1046
1047Addressee::List AddressBook::findByEmail( const QString &email ) 1047Addressee::List AddressBook::findByEmail( const QString &email )
1048{ 1048{
1049 Addressee::List results; 1049 Addressee::List results;
1050 QStringList mailList; 1050 QStringList mailList;
1051 1051
1052 Iterator it; 1052 Iterator it;
1053 for ( it = begin(); it != end(); ++it ) { 1053 for ( it = begin(); it != end(); ++it ) {
1054 mailList = (*it).emails(); 1054 mailList = (*it).emails();
1055 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 1055 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1056 if ( email == (*ite) ) { 1056 if ( email == (*ite) ) {
1057 results.append( *it ); 1057 results.append( *it );
1058 } 1058 }
1059 } 1059 }
1060 } 1060 }
1061 1061