-rw-r--r-- | kaddressbook/kabcore.cpp | 87 |
1 files changed, 61 insertions, 26 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d6482fb..b3d88de 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2754,3 +2754,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2754 | skipIncidence = true; | 2754 | skipIncidence = true; |
2755 | QString idS; | 2755 | QString idS,OidS; |
2756 | qApp->processEvents(); | 2756 | qApp->processEvents(); |
@@ -2770,2 +2770,4 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2770 | local->insertAddressee( inL, false ); | 2770 | local->insertAddressee( inL, false ); |
2771 | idS = inR.externalUID(); | ||
2772 | OidS = inR.originalExternalUID(); | ||
2771 | } | 2773 | } |
@@ -2776,4 +2778,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2778 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2779 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2780 | inR.setOriginalExternalUID( OidS ); | ||
2781 | inR.setExternalUID( idS ); | ||
2782 | } else { | ||
2778 | inR.setIDStr( idS ); | 2783 | inR.setIDStr( idS ); |
2784 | } | ||
2779 | inR.setResource( 0 ); | 2785 | inR.setResource( 0 ); |
@@ -2781,3 +2787,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2781 | ++changedRemote; | 2787 | ++changedRemote; |
2782 | } else { | 2788 | } else { // take == 2 take remote |
2783 | idS = inL.IDStr(); | 2789 | idS = inL.IDStr(); |
@@ -2856,3 +2862,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2856 | inR = inL; | 2862 | inR = inL; |
2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2863 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2858 | inR.setResource( 0 ); | 2864 | inR.setResource( 0 ); |
@@ -2921,21 +2927,4 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2921 | bool external = false; | 2927 | bool external = false; |
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | ||
2923 | if ( ! lse.isEmpty() ) { | ||
2924 | if ( lse.familyName().left(4) == "!E: " ) | ||
2925 | external = true; | ||
2926 | } else { | ||
2927 | bool found = false; | ||
2928 | QDateTime dt( QDate( 2004,1,1)); | ||
2929 | AddressBook::Iterator it; | ||
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | ||
2931 | if ( (*it).revision() != dt ) { | ||
2932 | found = true; | ||
2933 | break; | ||
2934 | } | ||
2935 | } | ||
2936 | external = ! found; | ||
2937 | } | ||
2938 | 2928 | ||
2939 | if ( external ) { | 2929 | if ( filename.right(4) == ".xml") { |
2940 | qDebug("Setting vcf mode to external "); | ||
2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2930 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
@@ -2943,5 +2932,34 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2932 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2933 | (*it).setID( mCurrentSyncDevice, (*it).externalUID() ); |
2945 | (*it).computeCsum( mCurrentSyncDevice ); | 2934 | (*it).computeCsum( mCurrentSyncDevice ); |
2946 | } | 2935 | } |
2936 | abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice ); | ||
2937 | |||
2938 | } else { | ||
2939 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | ||
2940 | if ( ! lse.isEmpty() ) { | ||
2941 | if ( lse.familyName().left(4) == "!E: " ) | ||
2942 | external = true; | ||
2943 | } else { | ||
2944 | bool found = false; | ||
2945 | QDateTime dt( QDate( 2004,1,1)); | ||
2946 | AddressBook::Iterator it; | ||
2947 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | ||
2948 | if ( (*it).revision() != dt ) { | ||
2949 | found = true; | ||
2950 | break; | ||
2951 | } | ||
2952 | } | ||
2953 | external = ! found; | ||
2954 | } | ||
2955 | |||
2956 | if ( external ) { | ||
2957 | qDebug("Setting vcf mode to external "); | ||
2958 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | ||
2959 | AddressBook::Iterator it; | ||
2960 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | ||
2961 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | ||
2962 | (*it).computeCsum( mCurrentSyncDevice ); | ||
2963 | } | ||
2964 | } | ||
2947 | } | 2965 | } |
@@ -2952,4 +2970,2 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2952 | //} | 2970 | //} |
2953 | if ( filename.right(4) == ".xml") | ||
2954 | abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice ); | ||
2955 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2971 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
@@ -2958,3 +2974,3 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2958 | { | 2974 | { |
2959 | if ( external ) | 2975 | if ( external && filename.right(4) != ".xml") |
2960 | abLocal.removeDeletedAddressees(); | 2976 | abLocal.removeDeletedAddressees(); |
@@ -2962,2 +2978,21 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2962 | abLocal.saveAB(); | 2978 | abLocal.saveAB(); |
2979 | if ( external && filename.right(4) == ".xml") { | ||
2980 | // afterwrite processing | ||
2981 | AddressBook::Iterator it; | ||
2982 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | ||
2983 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | ||
2984 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | ||
2985 | Addressee ad = mAddressBook->findByUid( ( (*it).uid() )); | ||
2986 | if ( ad.isEmpty() ) { | ||
2987 | qDebug("ERROR ad empty "); | ||
2988 | } else { | ||
2989 | (*it).computeCsum( mCurrentSyncDevice ); | ||
2990 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | ||
2991 | ad.setID( mCurrentSyncDevice, (*it).externalUID() ); | ||
2992 | ad.setCsum( mCurrentSyncDevice, (*it).getCsum( mCurrentSyncDevice ) ); | ||
2993 | mAddressBook->insertAddressee( ad ); | ||
2994 | } | ||
2995 | } | ||
2996 | } | ||
2997 | } | ||
2963 | } | 2998 | } |