author | zautrix <zautrix> | 2004-10-13 13:18:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 13:18:51 (UTC) |
commit | d41893fb0a49fbb080326a4c1fd98e1a032a182a (patch) (unidiff) | |
tree | 9b95603ff93801accaa94de4b73d88ea9c5c9386 | |
parent | efdd0735bda81dcd82dfb6d6dc0d0c143f249336 (diff) | |
download | kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.zip kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.tar.gz kdepimpi-d41893fb0a49fbb080326a4c1fd98e1a032a182a.tar.bz2 |
merge contact fixes
-rw-r--r-- | kabc/addressbook.cpp | 8 | ||||
-rw-r--r-- | kabc/addressbook.h | 4 | ||||
-rw-r--r-- | kabc/addressee.cpp | 82 | ||||
-rw-r--r-- | kabc/addressee.h | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 |
5 files changed, 68 insertions, 34 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 19c26eb..8882259 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -854,33 +854,33 @@ AddressBook::Iterator AddressBook::find( const Addressee &a ) | |||
854 | } | 854 | } |
855 | 855 | ||
856 | Addressee AddressBook::findByUid( const QString &uid ) | 856 | Addressee AddressBook::findByUid( const QString &uid ) |
857 | { | 857 | { |
858 | Iterator it; | 858 | Iterator it; |
859 | for ( it = begin(); it != end(); ++it ) { | 859 | for ( it = begin(); it != end(); ++it ) { |
860 | if ( uid == (*it).uid() ) { | 860 | if ( uid == (*it).uid() ) { |
861 | return *it; | 861 | return *it; |
862 | } | 862 | } |
863 | } | 863 | } |
864 | return Addressee(); | 864 | return Addressee(); |
865 | } | 865 | } |
866 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | 866 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
867 | { | 867 | { |
868 | //qDebug("AddressBook::preExternSync "); | 868 | //qDebug("AddressBook::preExternSync "); |
869 | AddressBook::Iterator it; | 869 | AddressBook::Iterator it; |
870 | for ( it = begin(); it != end(); ++it ) { | 870 | for ( it = begin(); it != end(); ++it ) { |
871 | (*it).setID( csd, (*it).externalUID() ); | 871 | (*it).setID( csd, (*it).externalUID() ); |
872 | (*it).computeCsum( csd ); | 872 | (*it).computeCsum( csd ); |
873 | } | 873 | } |
874 | mergeAB( aBook ,csd ); | 874 | mergeAB( aBook ,csd, isSubset ); |
875 | } | 875 | } |
876 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 876 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
877 | { | 877 | { |
878 | //qDebug("AddressBook::postExternSync "); | 878 | //qDebug("AddressBook::postExternSync "); |
879 | AddressBook::Iterator it; | 879 | AddressBook::Iterator it; |
880 | for ( it = begin(); it != end(); ++it ) { | 880 | for ( it = begin(); it != end(); ++it ) { |
881 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 881 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
882 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 882 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
883 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 883 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
884 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 884 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
885 | if ( ad.isEmpty() ) { | 885 | if ( ad.isEmpty() ) { |
886 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 886 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
@@ -904,32 +904,32 @@ bool AddressBook::containsExternalUid( const QString& uid ) | |||
904 | } | 904 | } |
905 | return false; | 905 | return false; |
906 | } | 906 | } |
907 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 907 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
908 | { | 908 | { |
909 | Iterator it; | 909 | Iterator it; |
910 | for ( it = begin(); it != end(); ++it ) { | 910 | for ( it = begin(); it != end(); ++it ) { |
911 | if ( uid == (*it).getID( profile ) ) | 911 | if ( uid == (*it).getID( profile ) ) |
912 | return (*it); | 912 | return (*it); |
913 | } | 913 | } |
914 | return Addressee(); | 914 | return Addressee(); |
915 | } | 915 | } |
916 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | 916 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
917 | { | 917 | { |
918 | Iterator it; | 918 | Iterator it; |
919 | Addressee ad; | 919 | Addressee ad; |
920 | for ( it = begin(); it != end(); ++it ) { | 920 | for ( it = begin(); it != end(); ++it ) { |
921 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 921 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
922 | if ( !ad.isEmpty() ) { | 922 | if ( !ad.isEmpty() ) { |
923 | (*it).mergeContact( ad ); | 923 | (*it).mergeContact( ad ,isSubset); |
924 | } | 924 | } |
925 | } | 925 | } |
926 | #if 0 | 926 | #if 0 |
927 | // test only | 927 | // test only |
928 | for ( it = begin(); it != end(); ++it ) { | 928 | for ( it = begin(); it != end(); ++it ) { |
929 | 929 | ||
930 | qDebug("uid %s ", (*it).uid().latin1()); | 930 | qDebug("uid %s ", (*it).uid().latin1()); |
931 | } | 931 | } |
932 | #endif | 932 | #endif |
933 | } | 933 | } |
934 | 934 | ||
935 | #if 0 | 935 | #if 0 |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index df9048b..a6bf451 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -292,29 +292,29 @@ class AddressBook : public QObject | |||
292 | void error( const QString& ); | 292 | void error( const QString& ); |
293 | 293 | ||
294 | /** | 294 | /** |
295 | Query all resources to clean up their lock files | 295 | Query all resources to clean up their lock files |
296 | */ | 296 | */ |
297 | void cleanUp(); | 297 | void cleanUp(); |
298 | 298 | ||
299 | // sync stuff | 299 | // sync stuff |
300 | //Addressee::List getExternLastSyncAddressees(); | 300 | //Addressee::List getExternLastSyncAddressees(); |
301 | void resetTempSyncStat(); | 301 | void resetTempSyncStat(); |
302 | QStringList uidList(); | 302 | QStringList uidList(); |
303 | void removeSyncAddressees( bool removeDeleted = false ); | 303 | void removeSyncAddressees( bool removeDeleted = false ); |
304 | void mergeAB( AddressBook *aBook, const QString& profile ); | 304 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
305 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 305 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
306 | bool containsExternalUid( const QString& uid ); | 306 | bool containsExternalUid( const QString& uid ); |
307 | 307 | ||
308 | void preExternSync( AddressBook* aBook, const QString& csd ); | 308 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
309 | void postExternSync( AddressBook* aBook, const QString& csd ); | 309 | void postExternSync( AddressBook* aBook, const QString& csd ); |
310 | signals: | 310 | signals: |
311 | /** | 311 | /** |
312 | Emitted, when the address book has changed on disk. | 312 | Emitted, when the address book has changed on disk. |
313 | */ | 313 | */ |
314 | void addressBookChanged( AddressBook * ); | 314 | void addressBookChanged( AddressBook * ); |
315 | 315 | ||
316 | /** | 316 | /** |
317 | Emitted, when the address book has been locked for writing. | 317 | Emitted, when the address book has been locked for writing. |
318 | */ | 318 | */ |
319 | void addressBookLocked( AddressBook * ); | 319 | void addressBookLocked( AddressBook * ); |
320 | 320 | ||
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2aca559..295ee4f 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -290,57 +290,56 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | if ( isSubSet ) { | 302 | |
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | 312 | (*it).setType( ( *phoneItAD ).type() ); |
313 | break; | 313 | break; |
314 | } | ||
315 | } | 314 | } |
316 | if ( ! found ) | ||
317 | mData->phoneNumbers.append( *phoneItAD ); | ||
318 | } | 315 | } |
316 | if ( isSubSet && ! found ) | ||
317 | mData->phoneNumbers.append( *phoneItAD ); | ||
318 | } | ||
319 | if ( isSubSet ) { | ||
319 | // ************* emails; | 320 | // ************* emails; |
320 | t = mData->emails; | 321 | t = mData->emails; |
321 | tAD = ad.mData->emails; | 322 | tAD = ad.mData->emails; |
322 | for ( iii = 0; iii < tAD.count(); ++iii) | 323 | for ( iii = 0; iii < tAD.count(); ++iii) |
323 | if ( !t.contains(tAD[iii] ) ) | 324 | if ( !t.contains(tAD[iii] ) ) |
324 | mData->emails.append( tAD[iii] ); | 325 | mData->emails.append( tAD[iii] ); |
325 | // ************* categories; | ||
326 | t = mData->categories; | ||
327 | tAD = ad.mData->categories; | ||
328 | for ( iii = 0; iii < tAD.count(); ++iii) | ||
329 | if ( !t.contains(tAD[iii] ) ) | ||
330 | mData->categories.append( tAD[iii] ); | ||
331 | |||
332 | |||
333 | } | 326 | } |
334 | 327 | ||
328 | // ************* categories; | ||
329 | t = mData->categories; | ||
330 | tAD = ad.mData->categories; | ||
331 | for ( iii = 0; iii < tAD.count(); ++iii) | ||
332 | if ( !t.contains(tAD[iii] ) ) | ||
333 | mData->categories.append( tAD[iii] ); | ||
335 | QStringList::ConstIterator it; | 334 | QStringList::ConstIterator it; |
336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 335 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
337 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 336 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
338 | bool found = false; | 337 | bool found = false; |
339 | QStringList::ConstIterator itL; | 338 | QStringList::ConstIterator itL; |
340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 339 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
341 | if ( (*itL).startsWith( qualifiedName ) ) { | 340 | if ( (*itL).startsWith( qualifiedName ) ) { |
342 | found = true; | 341 | found = true; |
343 | break; | 342 | break; |
344 | } | 343 | } |
345 | } | 344 | } |
346 | if ( ! found ) { | 345 | if ( ! found ) { |
@@ -380,25 +379,25 @@ void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | |||
380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 379 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
381 | bool found = false; | 380 | bool found = false; |
382 | KABC::Address::List::Iterator addressIter; | 381 | KABC::Address::List::Iterator addressIter; |
383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 382 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
384 | ++addressIter ) { | 383 | ++addressIter ) { |
385 | if ( (*addressIter) == (*addressIterA)) { | 384 | if ( (*addressIter) == (*addressIterA)) { |
386 | found = true; | 385 | found = true; |
387 | (*addressIter).setType( (*addressIterA).type() ); | 386 | (*addressIter).setType( (*addressIterA).type() ); |
388 | break; | 387 | break; |
389 | } | 388 | } |
390 | 389 | ||
391 | } | 390 | } |
392 | if ( ! found ) { | 391 | if ( isSubSet && ! found ) { |
393 | mData->addresses.append( *addressIterA ); | 392 | mData->addresses.append( *addressIterA ); |
394 | } | 393 | } |
395 | } | 394 | } |
396 | //qDebug("merge contact %s ", ad.uid().latin1()); | 395 | //qDebug("merge contact %s ", ad.uid().latin1()); |
397 | setUid( ad.uid() ); | 396 | setUid( ad.uid() ); |
398 | setRevision( ad.revision() ); | 397 | setRevision( ad.revision() ); |
399 | } | 398 | } |
400 | 399 | ||
401 | bool Addressee::removeVoice() | 400 | bool Addressee::removeVoice() |
402 | { | 401 | { |
403 | PhoneNumber::List phoneN = phoneNumbers(); | 402 | PhoneNumber::List phoneN = phoneNumbers(); |
404 | PhoneNumber::List::Iterator phoneIt; | 403 | PhoneNumber::List::Iterator phoneIt; |
@@ -469,26 +468,61 @@ void Addressee::simplifyAddresses() | |||
469 | // needed by phone sync | 468 | // needed by phone sync |
470 | void Addressee::simplifyEmails() | 469 | void Addressee::simplifyEmails() |
471 | { | 470 | { |
472 | if ( mData->emails.count() == 0 ) return ; | 471 | if ( mData->emails.count() == 0 ) return ; |
473 | QString email = mData->emails.first(); | 472 | QString email = mData->emails.first(); |
474 | detach(); | 473 | detach(); |
475 | mData->emails.clear(); | 474 | mData->emails.clear(); |
476 | mData->emails.append( email ); | 475 | mData->emails.append( email ); |
477 | } | 476 | } |
478 | 477 | ||
479 | void Addressee::simplifyPhoneNumbers() | 478 | void Addressee::simplifyPhoneNumbers() |
480 | { | 479 | { |
480 | int max = 4; | ||
481 | int inList = mData->phoneNumbers.count(); | ||
481 | KABC::PhoneNumber::List removeNumbers; | 482 | KABC::PhoneNumber::List removeNumbers; |
482 | KABC::PhoneNumber::List::Iterator phoneIter; | 483 | KABC::PhoneNumber::List::Iterator phoneIter; |
484 | if ( inList > max ) { | ||
485 | // delete non-preferred numbers | ||
486 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
487 | ++phoneIter ) { | ||
488 | if ( inList > max ) { | ||
489 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | ||
490 | removeNumbers.append( ( *phoneIter ) ); | ||
491 | --inList; | ||
492 | } | ||
493 | } else | ||
494 | break; | ||
495 | } | ||
496 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
497 | ++phoneIter ) { | ||
498 | removePhoneNumber(( *phoneIter )); | ||
499 | } | ||
500 | // delete preferred numbers | ||
501 | if ( inList > max ) { | ||
502 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
503 | ++phoneIter ) { | ||
504 | if ( inList > max ) { | ||
505 | removeNumbers.append( ( *phoneIter ) ); | ||
506 | --inList; | ||
507 | } else | ||
508 | break; | ||
509 | } | ||
510 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
511 | ++phoneIter ) { | ||
512 | removePhoneNumber(( *phoneIter )); | ||
513 | } | ||
514 | } | ||
515 | } | ||
516 | // remove non-numeric characters | ||
483 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 517 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
484 | ++phoneIter ) { | 518 | ++phoneIter ) { |
485 | if ( ! ( *phoneIter ).simplifyNumber() ) | 519 | if ( ! ( *phoneIter ).simplifyNumber() ) |
486 | removeNumbers.append( ( *phoneIter ) ); | 520 | removeNumbers.append( ( *phoneIter ) ); |
487 | } | 521 | } |
488 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 522 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
489 | ++phoneIter ) { | 523 | ++phoneIter ) { |
490 | removePhoneNumber(( *phoneIter )); | 524 | removePhoneNumber(( *phoneIter )); |
491 | } | 525 | } |
492 | } | 526 | } |
493 | void Addressee::simplifyPhoneNumberTypes() | 527 | void Addressee::simplifyPhoneNumberTypes() |
494 | { | 528 | { |
diff --git a/kabc/addressee.h b/kabc/addressee.h index e7900c6..2c81c1a 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -107,25 +107,25 @@ class Addressee | |||
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad, bool isSubSet = false ); | 119 | void mergeContact( const Addressee& ad, bool isSubSet ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | 121 | void simplifyAddresses(); |
122 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
123 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
124 | bool removeVoice(); | 124 | bool removeVoice(); |
125 | bool containsAdr(const Addressee& addr ); | 125 | bool containsAdr(const Addressee& addr ); |
126 | 126 | ||
127 | /** | 127 | /** |
128 | Set unique identifier. | 128 | Set unique identifier. |
129 | */ | 129 | */ |
130 | void setUid( const QString &uid ); | 130 | void setUid( const QString &uid ); |
131 | /** | 131 | /** |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 205dbc8..ea34be2 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2723,25 +2723,25 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2723 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2723 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2724 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2724 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2725 | 2725 | ||
2726 | AddressBook abLocal(filename,"syncContact"); | 2726 | AddressBook abLocal(filename,"syncContact"); |
2727 | bool syncOK = false; | 2727 | bool syncOK = false; |
2728 | if ( abLocal.load() ) { | 2728 | if ( abLocal.load() ) { |
2729 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2729 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2730 | bool external = false; | 2730 | bool external = false; |
2731 | bool isXML = false; | 2731 | bool isXML = false; |
2732 | if ( filename.right(4) == ".xml") { | 2732 | if ( filename.right(4) == ".xml") { |
2733 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2733 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2734 | isXML = true; | 2734 | isXML = true; |
2735 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2735 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2736 | } else { | 2736 | } else { |
2737 | external = !manager->mIsKapiFile; | 2737 | external = !manager->mIsKapiFile; |
2738 | if ( external ) { | 2738 | if ( external ) { |
2739 | qDebug("Setting vcf mode to external "); | 2739 | qDebug("Setting vcf mode to external "); |
2740 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2740 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2741 | AddressBook::Iterator it; | 2741 | AddressBook::Iterator it; |
2742 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2742 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2743 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2743 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2744 | (*it).computeCsum( mCurrentSyncDevice ); | 2744 | (*it).computeCsum( mCurrentSyncDevice ); |
2745 | } | 2745 | } |
2746 | } | 2746 | } |
2747 | } | 2747 | } |
@@ -2778,25 +2778,25 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2778 | //this is a overwritten callbackmethods from the syncinterface | 2778 | //this is a overwritten callbackmethods from the syncinterface |
2779 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2779 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2780 | { | 2780 | { |
2781 | if ( resource == "phone" ) | 2781 | if ( resource == "phone" ) |
2782 | return syncPhone(); | 2782 | return syncPhone(); |
2783 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2783 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2784 | 2784 | ||
2785 | AddressBook abLocal( resource,"syncContact"); | 2785 | AddressBook abLocal( resource,"syncContact"); |
2786 | bool syncOK = false; | 2786 | bool syncOK = false; |
2787 | if ( abLocal.load() ) { | 2787 | if ( abLocal.load() ) { |
2788 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2788 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2789 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2789 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2790 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2790 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2791 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2791 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2792 | if ( syncOK ) { | 2792 | if ( syncOK ) { |
2793 | if ( syncManager->mWriteBackFile ) { | 2793 | if ( syncManager->mWriteBackFile ) { |
2794 | abLocal.removeSyncAddressees( false ); | 2794 | abLocal.removeSyncAddressees( false ); |
2795 | abLocal.saveAB(); | 2795 | abLocal.saveAB(); |
2796 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2796 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2797 | } | 2797 | } |
2798 | } | 2798 | } |
2799 | setModified(); | 2799 | setModified(); |
2800 | } | 2800 | } |
2801 | if ( syncOK ) | 2801 | if ( syncOK ) |
2802 | mViewManager->refreshView(); | 2802 | mViewManager->refreshView(); |
@@ -2820,25 +2820,25 @@ bool KABCore::syncPhone() | |||
2820 | #endif | 2820 | #endif |
2821 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2821 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2822 | message(i18n("Phone access failed!")); | 2822 | message(i18n("Phone access failed!")); |
2823 | return false; | 2823 | return false; |
2824 | } | 2824 | } |
2825 | AddressBook abLocal( fileName,"syncContact"); | 2825 | AddressBook abLocal( fileName,"syncContact"); |
2826 | bool syncOK = false; | 2826 | bool syncOK = false; |
2827 | { | 2827 | { |
2828 | abLocal.importFromFile( fileName ); | 2828 | abLocal.importFromFile( fileName ); |
2829 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2829 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2830 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2830 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2831 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2831 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2832 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2832 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2833 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2833 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2834 | if ( syncOK ) { | 2834 | if ( syncOK ) { |
2835 | if ( syncManager->mWriteBackFile ) { | 2835 | if ( syncManager->mWriteBackFile ) { |
2836 | abLocal.removeSyncAddressees( true ); | 2836 | abLocal.removeSyncAddressees( true ); |
2837 | abLocal.saveABphone( fileName ); | 2837 | abLocal.saveABphone( fileName ); |
2838 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2838 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2839 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2839 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2840 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2840 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2841 | } | 2841 | } |
2842 | } | 2842 | } |
2843 | setModified(); | 2843 | setModified(); |
2844 | } | 2844 | } |