-rw-r--r-- | kabc/addressbook.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 6194d6d..4c4ae09 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -561,9 +561,8 @@ void AddressBook::removeSyncInfo( QString syncProfile) | |||
561 | } | 561 | } |
562 | if ( syncProfile.isEmpty() ) { | 562 | if ( syncProfile.isEmpty() ) { |
563 | Iterator it = begin(); | 563 | Iterator it = begin(); |
564 | Iterator it2 ; | 564 | Iterator it2 ; |
565 | QDateTime dt ( QDate( 2004,1,1) ); | ||
566 | while ( it != end() ) { | 565 | while ( it != end() ) { |
567 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 566 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
568 | it2 = it; | 567 | it2 = it; |
569 | //qDebug("removing %s ",(*it).uid().latin1() ); | 568 | //qDebug("removing %s ",(*it).uid().latin1() ); |
@@ -785,14 +784,9 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeRes | |||
785 | (*it).setResource( standardResource() ); | 784 | (*it).setResource( standardResource() ); |
786 | } | 785 | } |
787 | if ( changed ) { | 786 | if ( changed ) { |
788 | if ( setRev ) { | 787 | if ( setRev ) { |
789 | 788 | (*it).setRevision( QDateTime::currentDateTime() ); | |
790 | // get rid of micro seconds | ||
791 | QDateTime dt = QDateTime::currentDateTime(); | ||
792 | QTime t = dt.time(); | ||
793 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | ||
794 | (*it).setRevision( dt ); | ||
795 | } | 789 | } |
796 | (*it).setChanged( true ); | 790 | (*it).setChanged( true ); |
797 | } | 791 | } |
798 | 792 | ||
@@ -814,14 +808,14 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeRes | |||
814 | } | 808 | } |
815 | } | 809 | } |
816 | } | 810 | } |
817 | if ( found ) | 811 | if ( found ) |
818 | return; | 812 | return; |
813 | |||
819 | d->mAddressees.append( a ); | 814 | d->mAddressees.append( a ); |
820 | Addressee& addr = d->mAddressees.last(); | 815 | Addressee& addr = d->mAddressees.last(); |
821 | if ( addr.resource() == 0 ) | 816 | if ( addr.resource() == 0 ) |
822 | addr.setResource( standardResource() ); | 817 | addr.setResource( standardResource() ); |
823 | |||
824 | addr.setChanged( true ); | 818 | addr.setChanged( true ); |
825 | } | 819 | } |
826 | 820 | ||
827 | void AddressBook::removeAddressee( const Addressee &a ) | 821 | void AddressBook::removeAddressee( const Addressee &a ) |
@@ -858,15 +852,15 @@ void AddressBook::removeAddressee( const Addressee &a ) | |||
858 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
859 | { | 853 | { |
860 | Iterator it = begin(); | 854 | Iterator it = begin(); |
861 | Iterator it2 ; | 855 | Iterator it2 ; |
862 | QDateTime dt ( QDate( 2004,1,1) ); | 856 | QDateTime dt ( QDate( 2003,1,1) ); |
863 | while ( it != end() ) { | 857 | while ( it != end() ) { |
864 | (*it).setRevision( dt ); | 858 | (*it).setRevision( dt ); |
865 | if (( *it).IDStr() != "changed" ) { | 859 | if (( *it).IDStr() != "changed" ) { |
866 | // "changed" is used for tagging changed addressees when syncing with KDE or OL | 860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
867 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
868 | (*it).setIDStr(""); | 862 | (*it).setIDStr(":"); |
869 | } | 863 | } |
870 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
871 | it2 = it; | 865 | it2 = it; |
872 | //qDebug("removing %s ",(*it).uid().latin1() ); | 866 | //qDebug("removing %s ",(*it).uid().latin1() ); |
@@ -877,10 +871,8 @@ void AddressBook::removeSyncAddressees( bool removeDeleted ) | |||
877 | if ( removeDeleted ) { | 871 | if ( removeDeleted ) { |
878 | // 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 |
879 | // 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 |
880 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
881 | |||
882 | |||
883 | } | 875 | } |
884 | ++it; | 876 | ++it; |
885 | } | 877 | } |
886 | } | 878 | } |
@@ -930,22 +922,24 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool | |||
930 | AddressBook::Iterator it; | 922 | AddressBook::Iterator it; |
931 | for ( it = begin(); it != end(); ++it ) { | 923 | for ( it = begin(); it != end(); ++it ) { |
932 | //qDebug("check uid %s ", (*it).uid().latin1() ); | 924 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
933 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 925 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
934 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 926 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || |
927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { | ||
935 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 928 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
936 | if ( ad.isEmpty() ) { | 929 | if ( ad.isEmpty() ) { |
937 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 930 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
938 | } else { | 931 | } else { |
939 | (*it).setIDStr(":"); | 932 | (*it).setIDStr(":"); |
940 | (*it).computeCsum( csd ); | ||
941 | if ( setID ) { | 933 | if ( setID ) { |
942 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 934 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
943 | ad.setID( csd, (*it).externalUID() ); | 935 | ad.setID( csd, (*it).externalUID() ); |
944 | } else | 936 | } else |
945 | ad.setID( csd, (*it).uid() ); | 937 | ad.setID( csd, (*it).uid() ); |
938 | (*it).computeCsum( csd ); | ||
946 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 939 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
947 | aBook->insertAddressee( ad ); | 940 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); |
941 | aBook->insertAddressee( ad , false); | ||
948 | } | 942 | } |
949 | } | 943 | } |
950 | } | 944 | } |
951 | } | 945 | } |