author | zautrix <zautrix> | 2004-09-18 22:33:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-18 22:33:39 (UTC) |
commit | f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a (patch) (unidiff) | |
tree | c1a9de8b305200a7cec885764a0afb4beb92dabb /kabc/addressbook.cpp | |
parent | 28f894fd2a0dfbd5f09f9e530f359981efe0198c (diff) | |
download | kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.zip kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.tar.gz kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addressbook.cpp | 75 |
1 files changed, 68 insertions, 7 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 16e1653..ec9f893 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -234,6 +234,7 @@ AddressBook::AddressBook( const QString &config, const QString &family ) | |||
234 | // the default family is "contact" | 234 | // the default family is "contact" |
235 | void AddressBook::init(const QString &config, const QString &family ) | 235 | void AddressBook::init(const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | blockLSEchange = false; | ||
237 | d = new AddressBookData; | 238 | d = new AddressBookData; |
238 | QString fami = family; | 239 | QString fami = family; |
239 | qDebug("new ab "); | 240 | qDebug("new ab "); |
@@ -345,6 +346,7 @@ bool AddressBook::load() | |||
345 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 346 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) |
346 | (*addrIt).setChanged( false ); | 347 | (*addrIt).setChanged( false ); |
347 | 348 | ||
349 | blockLSEchange = true; | ||
348 | return ok; | 350 | return ok; |
349 | } | 351 | } |
350 | 352 | ||
@@ -447,12 +449,14 @@ Ticket *AddressBook::requestSaveTicket( Resource *resource ) | |||
447 | 449 | ||
448 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | 450 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) |
449 | { | 451 | { |
452 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | ||
453 | return; | ||
454 | } | ||
455 | bool found = false; | ||
450 | Addressee::List::Iterator it; | 456 | Addressee::List::Iterator it; |
451 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 457 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
452 | if ( a.uid() == (*it).uid() ) { | 458 | if ( a.uid() == (*it).uid() ) { |
453 | if ( setRev && (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 459 | |
454 | return; | ||
455 | } | ||
456 | bool changed = false; | 460 | bool changed = false; |
457 | Addressee addr = a; | 461 | Addressee addr = a; |
458 | if ( addr != (*it) ) | 462 | if ( addr != (*it) ) |
@@ -474,9 +478,26 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | |||
474 | (*it).setChanged( true ); | 478 | (*it).setChanged( true ); |
475 | } | 479 | } |
476 | 480 | ||
477 | return; | 481 | found = true; |
482 | } else { | ||
483 | if ( (*it).uid() == QString("last-syncAddressee-") ) { | ||
484 | QString name = (*it).uid().mid( 19 ); | ||
485 | Addressee b = a; | ||
486 | QString id = b.getID( name ); | ||
487 | if ( ! id.isEmpty() ) { | ||
488 | QString des = (*it).note(); | ||
489 | int startN; | ||
490 | if( (startN = des.find( id ) ) >= 0 ) { | ||
491 | int endN = des.find( ",", startN+1 ); | ||
492 | des = des.left( startN ) + des.mid( endN+1 ); | ||
493 | (*it).setNote( des ); | ||
494 | } | ||
478 | } | 495 | } |
479 | } | 496 | } |
497 | } | ||
498 | } | ||
499 | if ( found ) | ||
500 | return; | ||
480 | d->mAddressees.append( a ); | 501 | d->mAddressees.append( a ); |
481 | Addressee& addr = d->mAddressees.last(); | 502 | Addressee& addr = d->mAddressees.last(); |
482 | if ( addr.resource() == 0 ) | 503 | if ( addr.resource() == 0 ) |
@@ -488,12 +509,50 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | |||
488 | void AddressBook::removeAddressee( const Addressee &a ) | 509 | void AddressBook::removeAddressee( const Addressee &a ) |
489 | { | 510 | { |
490 | Iterator it; | 511 | Iterator it; |
512 | Iterator it2; | ||
513 | bool found = false; | ||
491 | for ( it = begin(); it != end(); ++it ) { | 514 | for ( it = begin(); it != end(); ++it ) { |
492 | if ( a.uid() == (*it).uid() ) { | 515 | if ( a.uid() == (*it).uid() ) { |
493 | removeAddressee( it ); | 516 | found = true; |
494 | return; | 517 | it2 = it; |
518 | } else { | ||
519 | if ( (*it).uid() == QString("last-syncAddressee-") ) { | ||
520 | QString name = (*it).uid().mid( 19 ); | ||
521 | Addressee b = a; | ||
522 | QString id = b.getID( name ); | ||
523 | if ( ! id.isEmpty() ) { | ||
524 | QString des = (*it).note(); | ||
525 | if( des.find( id ) < 0 ) { | ||
526 | des += id + ","; | ||
527 | (*it).setNote( des ); | ||
528 | } | ||
495 | } | 529 | } |
496 | } | 530 | } |
531 | |||
532 | } | ||
533 | } | ||
534 | |||
535 | if ( found ) | ||
536 | removeAddressee( it2 ); | ||
537 | |||
538 | } | ||
539 | |||
540 | void AddressBook::removeDeletedAddressees() | ||
541 | { | ||
542 | deleteRemovedAddressees(); | ||
543 | Iterator it = begin(); | ||
544 | Iterator it2 ; | ||
545 | QDateTime dt ( QDate( 2004,1,1) ); | ||
546 | while ( it != end() ) { | ||
547 | (*it).setRevision( dt ); | ||
548 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | ||
549 | it2 = it; | ||
550 | ++it; | ||
551 | removeAddressee( it2 ); | ||
552 | } else | ||
553 | ++it; | ||
554 | } | ||
555 | deleteRemovedAddressees(); | ||
497 | } | 556 | } |
498 | 557 | ||
499 | void AddressBook::removeAddressee( const Iterator &it ) | 558 | void AddressBook::removeAddressee( const Iterator &it ) |
@@ -523,6 +582,7 @@ Addressee AddressBook::findByUid( const QString &uid ) | |||
523 | } | 582 | } |
524 | return Addressee(); | 583 | return Addressee(); |
525 | } | 584 | } |
585 | #if 0 | ||
526 | Addressee::List AddressBook::getExternLastSyncAddressees() | 586 | Addressee::List AddressBook::getExternLastSyncAddressees() |
527 | { | 587 | { |
528 | Addressee::List results; | 588 | Addressee::List results; |
@@ -530,13 +590,14 @@ Addressee::List AddressBook::getExternLastSyncAddressees() | |||
530 | Iterator it; | 590 | Iterator it; |
531 | for ( it = begin(); it != end(); ++it ) { | 591 | for ( it = begin(); it != end(); ++it ) { |
532 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 592 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
533 | if ( (*it).familyName().left(3) == "E: " ) | 593 | if ( (*it).familyName().left(4) == "!E: " ) |
534 | results.append( *it ); | 594 | results.append( *it ); |
535 | } | 595 | } |
536 | } | 596 | } |
537 | 597 | ||
538 | return results; | 598 | return results; |
539 | } | 599 | } |
600 | #endif | ||
540 | void AddressBook::resetTempSyncStat() | 601 | void AddressBook::resetTempSyncStat() |
541 | { | 602 | { |
542 | Iterator it; | 603 | Iterator it; |