summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2004-10-27 19:44:10 (UTC)
committer zautrix <zautrix>2004-10-27 19:44:10 (UTC)
commitbb82cac85cc196b3f60921ab27e84204036b54b8 (patch) (unidiff)
tree518629480b983b6b85a4cf1e5542f94fe1687e41 /kabc
parent85a0e0d9b1d60805cb4947be1c296c18e73c82b8 (diff)
downloadkdepimpi-bb82cac85cc196b3f60921ab27e84204036b54b8.zip
kdepimpi-bb82cac85cc196b3f60921ab27e84204036b54b8.tar.gz
kdepimpi-bb82cac85cc196b3f60921ab27e84204036b54b8.tar.bz2
sync fixes
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp19
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/addressee.cpp2
3 files changed, 17 insertions, 6 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 9b196b5..5774c36 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -865,24 +865,31 @@ void AddressBook::removeSyncAddressees( bool removeDeleted )
865 if (( *it).IDStr() != "changed" ) { 865 if (( *it).IDStr() != "changed" ) {
866 // "changed" is used for tagging changed addressees when syncing with KDE or OL 866 // "changed" is used for tagging changed addressees when syncing with KDE or OL
867 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 867 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
868 (*it).setIDStr(""); 868 (*it).setIDStr("");
869 } 869 }
870 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 870 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
871 it2 = it; 871 it2 = it;
872 //qDebug("removing %s ",(*it).uid().latin1() ); 872 //qDebug("removing %s ",(*it).uid().latin1() );
873 ++it; 873 ++it;
874 removeAddressee( it2 ); 874 removeAddressee( it2 );
875 } else { 875 } else {
876 //qDebug("skipping %s ",(*it).uid().latin1() ); 876 //qDebug("skipping %s ",(*it).uid().latin1() );
877 if ( removeDeleted ) {
878 // 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
880 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
881
882
883 }
877 ++it; 884 ++it;
878 } 885 }
879 } 886 }
880 deleteRemovedAddressees(); 887 deleteRemovedAddressees();
881} 888}
882 889
883void AddressBook::removeAddressee( const Iterator &it ) 890void AddressBook::removeAddressee( const Iterator &it )
884{ 891{
885 d->mRemovedAddressees.append( (*it) ); 892 d->mRemovedAddressees.append( (*it) );
886 d->mAddressees.remove( it.d->mIt ); 893 d->mAddressees.remove( it.d->mIt );
887} 894}
888 895
@@ -908,39 +915,43 @@ Addressee AddressBook::findByUid( const QString &uid )
908 return Addressee(); 915 return Addressee();
909} 916}
910void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 917void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
911{ 918{
912 //qDebug("AddressBook::preExternSync "); 919 //qDebug("AddressBook::preExternSync ");
913 AddressBook::Iterator it; 920 AddressBook::Iterator it;
914 for ( it = begin(); it != end(); ++it ) { 921 for ( it = begin(); it != end(); ++it ) {
915 (*it).setID( csd, (*it).externalUID() ); 922 (*it).setID( csd, (*it).externalUID() );
916 (*it).computeCsum( csd ); 923 (*it).computeCsum( csd );
917 } 924 }
918 mergeAB( aBook ,csd, isSubset ); 925 mergeAB( aBook ,csd, isSubset );
919} 926}
920void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 927void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
921{ 928{
922 //qDebug("AddressBook::postExternSync "); 929 //qDebug("AddressBook::postExternSync ");
923 AddressBook::Iterator it; 930 AddressBook::Iterator it;
924 for ( it = begin(); it != end(); ++it ) { 931 for ( it = begin(); it != end(); ++it ) {
925 // qDebug("check uid %s ", (*it).uid().latin1() ); 932 //qDebug("check uid %s ", (*it).uid().latin1() );
926 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 933 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
927 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 934 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
928 Addressee ad = aBook->findByUid( ( (*it).uid() )); 935 Addressee ad = aBook->findByUid( ( (*it).uid() ));
929 if ( ad.isEmpty() ) { 936 if ( ad.isEmpty() ) {
930 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 937 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
931 } else { 938 } else {
939 (*it).setIDStr(":");
932 (*it).computeCsum( csd ); 940 (*it).computeCsum( csd );
933 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 941 if ( setID ) {
934 ad.setID( csd, (*it).externalUID() ); 942 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
943 ad.setID( csd, (*it).externalUID() );
944 } else
945 ad.setID( csd, "_" );
935 ad.setCsum( csd, (*it).getCsum( csd ) ); 946 ad.setCsum( csd, (*it).getCsum( csd ) );
936 aBook->insertAddressee( ad ); 947 aBook->insertAddressee( ad );
937 } 948 }
938 } 949 }
939 } 950 }
940} 951}
941 952
942bool AddressBook::containsExternalUid( const QString& uid ) 953bool AddressBook::containsExternalUid( const QString& uid )
943{ 954{
944 Iterator it; 955 Iterator it;
945 for ( it = begin(); it != end(); ++it ) { 956 for ( it = begin(); it != end(); ++it ) {
946 if ( uid == (*it).externalUID( ) ) 957 if ( uid == (*it).externalUID( ) )
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index f124dc9..75f8b51 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -298,25 +298,25 @@ class AddressBook : public QObject
298 void cleanUp(); 298 void cleanUp();
299 299
300 // sync stuff 300 // sync stuff
301 //Addressee::List getExternLastSyncAddressees(); 301 //Addressee::List getExternLastSyncAddressees();
302 void resetTempSyncStat(); 302 void resetTempSyncStat();
303 QStringList uidList(); 303 QStringList uidList();
304 void removeSyncAddressees( bool removeDeleted = false ); 304 void removeSyncAddressees( bool removeDeleted = false );
305 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); 305 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset );
306 Addressee findByExternUid( const QString& uid , const QString& profile ); 306 Addressee findByExternUid( const QString& uid , const QString& profile );
307 bool containsExternalUid( const QString& uid ); 307 bool containsExternalUid( const QString& uid );
308 308
309 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); 309 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
310 void postExternSync( AddressBook* aBook, const QString& csd ); 310 void postExternSync( AddressBook* aBook, const QString& csd , bool setID );
311 signals: 311 signals:
312 /** 312 /**
313 Emitted, when the address book has changed on disk. 313 Emitted, when the address book has changed on disk.
314 */ 314 */
315 void addressBookChanged( AddressBook * ); 315 void addressBookChanged( AddressBook * );
316 316
317 /** 317 /**
318 Emitted, when the address book has been locked for writing. 318 Emitted, when the address book has been locked for writing.
319 */ 319 */
320 void addressBookLocked( AddressBook * ); 320 void addressBookLocked( AddressBook * );
321 321
322 /** 322 /**
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index a660a9d..d5a110a 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -257,25 +257,25 @@ void Addressee::computeCsum(const QString &dev)
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 l.append( t[iii] ); 259 l.append( t[iii] );
260 KABC::Address::List::Iterator addressIter; 260 KABC::Address::List::Iterator addressIter;
261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 261 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
262 ++addressIter ) { 262 ++addressIter ) {
263 t = (*addressIter).asList(); 263 t = (*addressIter).asList();
264 t.sort(); 264 t.sort();
265 for ( iii = 0; iii < t.count(); ++iii) 265 for ( iii = 0; iii < t.count(); ++iii)
266 l.append( t[iii] ); 266 l.append( t[iii] );
267 } 267 }
268 uint cs = getCsum4List(l); 268 uint cs = getCsum4List(l);
269 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 269 //qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
270 setCsum( dev, QString::number (cs )); 270 setCsum( dev, QString::number (cs ));
271} 271}
272 272
273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 273void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
274{ 274{
275 275
276 detach(); 276 detach();
277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 277 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 278 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 279 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 280 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 281 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;