author | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
commit | b01b669d88fa195261d29ecf73b1c69e608a5ebc (patch) (unidiff) | |
tree | c0e79d45242a764b49470d07a9c95be156c121cc /kabc | |
parent | 3da2cfeab2edbe64a17251662e56668fe143f7a3 (diff) | |
download | kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.zip kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.gz kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addressbook.cpp | 27 | ||||
-rw-r--r-- | kabc/addressbook.h | 3 | ||||
-rw-r--r-- | kabc/addressee.cpp | 6 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 79 |
5 files changed, 98 insertions, 19 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 86dc7c2..17b9ba2 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -523,165 +523,180 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | |||
523 | 523 | ||
524 | void AddressBook::removeAddressee( const Addressee &a ) | 524 | void AddressBook::removeAddressee( const Addressee &a ) |
525 | { | 525 | { |
526 | Iterator it; | 526 | Iterator it; |
527 | Iterator it2; | 527 | Iterator it2; |
528 | bool found = false; | 528 | bool found = false; |
529 | for ( it = begin(); it != end(); ++it ) { | 529 | for ( it = begin(); it != end(); ++it ) { |
530 | if ( a.uid() == (*it).uid() ) { | 530 | if ( a.uid() == (*it).uid() ) { |
531 | found = true; | 531 | found = true; |
532 | it2 = it; | 532 | it2 = it; |
533 | } else { | 533 | } else { |
534 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 534 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
535 | QString name = (*it).uid().mid( 19 ); | 535 | QString name = (*it).uid().mid( 19 ); |
536 | Addressee b = a; | 536 | Addressee b = a; |
537 | QString id = b.getID( name ); | 537 | QString id = b.getID( name ); |
538 | if ( ! id.isEmpty() ) { | 538 | if ( ! id.isEmpty() ) { |
539 | QString des = (*it).note(); | 539 | QString des = (*it).note(); |
540 | if( des.find( id ) < 0 ) { | 540 | if( des.find( id ) < 0 ) { |
541 | des += id + ","; | 541 | des += id + ","; |
542 | (*it).setNote( des ); | 542 | (*it).setNote( des ); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | } | 545 | } |
546 | 546 | ||
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
550 | if ( found ) | 550 | if ( found ) |
551 | removeAddressee( it2 ); | 551 | removeAddressee( it2 ); |
552 | 552 | ||
553 | } | 553 | } |
554 | 554 | ||
555 | void AddressBook::removeDeletedAddressees() | 555 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
556 | { | 556 | { |
557 | deleteRemovedAddressees(); | ||
558 | Iterator it = begin(); | 557 | Iterator it = begin(); |
559 | Iterator it2 ; | 558 | Iterator it2 ; |
560 | QDateTime dt ( QDate( 2004,1,1) ); | 559 | QDateTime dt ( QDate( 2004,1,1) ); |
561 | while ( it != end() ) { | 560 | while ( it != end() ) { |
562 | (*it).setRevision( dt ); | 561 | (*it).setRevision( dt ); |
563 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 562 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
564 | (*it).setIDStr(""); | 563 | (*it).setIDStr(""); |
565 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 564 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
566 | it2 = it; | 565 | it2 = it; |
567 | //qDebug("removing %s ",(*it).uid().latin1() ); | 566 | //qDebug("removing %s ",(*it).uid().latin1() ); |
568 | ++it; | 567 | ++it; |
569 | removeAddressee( it2 ); | 568 | removeAddressee( it2 ); |
570 | } else { | 569 | } else { |
571 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 570 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
572 | ++it; | 571 | ++it; |
573 | } | 572 | } |
574 | } | 573 | } |
575 | deleteRemovedAddressees(); | 574 | deleteRemovedAddressees(); |
576 | } | 575 | } |
577 | 576 | ||
578 | void AddressBook::removeAddressee( const Iterator &it ) | 577 | void AddressBook::removeAddressee( const Iterator &it ) |
579 | { | 578 | { |
580 | d->mRemovedAddressees.append( (*it) ); | 579 | d->mRemovedAddressees.append( (*it) ); |
581 | d->mAddressees.remove( it.d->mIt ); | 580 | d->mAddressees.remove( it.d->mIt ); |
582 | } | 581 | } |
583 | 582 | ||
584 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 583 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
585 | { | 584 | { |
586 | Iterator it; | 585 | Iterator it; |
587 | for ( it = begin(); it != end(); ++it ) { | 586 | for ( it = begin(); it != end(); ++it ) { |
588 | if ( a.uid() == (*it).uid() ) { | 587 | if ( a.uid() == (*it).uid() ) { |
589 | return it; | 588 | return it; |
590 | } | 589 | } |
591 | } | 590 | } |
592 | return end(); | 591 | return end(); |
593 | } | 592 | } |
594 | 593 | ||
595 | Addressee AddressBook::findByUid( const QString &uid ) | 594 | Addressee AddressBook::findByUid( const QString &uid ) |
596 | { | 595 | { |
597 | Iterator it; | 596 | Iterator it; |
598 | for ( it = begin(); it != end(); ++it ) { | 597 | for ( it = begin(); it != end(); ++it ) { |
599 | if ( uid == (*it).uid() ) { | 598 | if ( uid == (*it).uid() ) { |
600 | return *it; | 599 | return *it; |
601 | } | 600 | } |
602 | } | 601 | } |
603 | return Addressee(); | 602 | return Addressee(); |
604 | } | 603 | } |
605 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | 604 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) |
606 | { | 605 | { |
607 | qDebug("AddressBook::preExternSync "); | 606 | qDebug("AddressBook::preExternSync "); |
608 | AddressBook::Iterator it; | 607 | AddressBook::Iterator it; |
609 | for ( it = begin(); it != end(); ++it ) { | 608 | for ( it = begin(); it != end(); ++it ) { |
610 | (*it).setID( csd, (*it).externalUID() ); | 609 | (*it).setID( csd, (*it).externalUID() ); |
611 | (*it).computeCsum( csd ); | 610 | (*it).computeCsum( csd ); |
612 | } | 611 | } |
613 | mergeAB( aBook ,csd ); | 612 | mergeAB( aBook ,csd ); |
614 | } | 613 | } |
615 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 614 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
616 | { | 615 | { |
617 | qDebug("AddressBook::postExternSync "); | 616 | qDebug("AddressBook::postExternSync "); |
618 | AddressBook::Iterator it; | 617 | AddressBook::Iterator it; |
619 | for ( it = begin(); it != end(); ++it ) { | 618 | for ( it = begin(); it != end(); ++it ) { |
619 | qDebug("check uid %s ", (*it).uid().latin1() ); | ||
620 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 620 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
621 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 621 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
622 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 622 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
623 | if ( ad.isEmpty() ) { | 623 | if ( ad.isEmpty() ) { |
624 | qDebug("ERROR ad empty "); | 624 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
625 | } else { | 625 | } else { |
626 | (*it).computeCsum( csd ); | 626 | (*it).computeCsum( csd ); |
627 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 627 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
628 | ad.setID( csd, (*it).externalUID() ); | 628 | ad.setID( csd, (*it).externalUID() ); |
629 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 629 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
630 | aBook->insertAddressee( ad ); | 630 | aBook->insertAddressee( ad ); |
631 | } | 631 | } |
632 | } | 632 | } |
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
636 | 636 | bool AddressBook::containsExternalUid( const QString& uid ) | |
637 | { | ||
638 | Iterator it; | ||
639 | for ( it = begin(); it != end(); ++it ) { | ||
640 | if ( uid == (*it).externalUID( ) ) | ||
641 | return true; | ||
642 | } | ||
643 | return false; | ||
644 | } | ||
637 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 645 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
638 | { | 646 | { |
639 | Iterator it; | 647 | Iterator it; |
640 | for ( it = begin(); it != end(); ++it ) { | 648 | for ( it = begin(); it != end(); ++it ) { |
641 | if ( uid == (*it).getID( profile ) ) | 649 | if ( uid == (*it).getID( profile ) ) |
642 | return (*it); | 650 | return (*it); |
643 | } | 651 | } |
644 | return Addressee(); | 652 | return Addressee(); |
645 | } | 653 | } |
646 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | 654 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) |
647 | { | 655 | { |
648 | Iterator it; | 656 | Iterator it; |
649 | Addressee ad; | 657 | Addressee ad; |
650 | for ( it = begin(); it != end(); ++it ) { | 658 | for ( it = begin(); it != end(); ++it ) { |
651 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 659 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
652 | if ( !ad.isEmpty() ) { | 660 | if ( !ad.isEmpty() ) { |
653 | (*it).mergeContact( ad ); | 661 | (*it).mergeContact( ad ); |
654 | } | 662 | } |
655 | } | 663 | } |
664 | #if 0 | ||
665 | // test only | ||
666 | for ( it = begin(); it != end(); ++it ) { | ||
667 | |||
668 | qDebug("uid %s ", (*it).uid().latin1()); | ||
669 | } | ||
670 | #endif | ||
656 | } | 671 | } |
657 | 672 | ||
658 | #if 0 | 673 | #if 0 |
659 | Addressee::List AddressBook::getExternLastSyncAddressees() | 674 | Addressee::List AddressBook::getExternLastSyncAddressees() |
660 | { | 675 | { |
661 | Addressee::List results; | 676 | Addressee::List results; |
662 | 677 | ||
663 | Iterator it; | 678 | Iterator it; |
664 | for ( it = begin(); it != end(); ++it ) { | 679 | for ( it = begin(); it != end(); ++it ) { |
665 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 680 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
666 | if ( (*it).familyName().left(4) == "!E: " ) | 681 | if ( (*it).familyName().left(4) == "!E: " ) |
667 | results.append( *it ); | 682 | results.append( *it ); |
668 | } | 683 | } |
669 | } | 684 | } |
670 | 685 | ||
671 | return results; | 686 | return results; |
672 | } | 687 | } |
673 | #endif | 688 | #endif |
674 | void AddressBook::resetTempSyncStat() | 689 | void AddressBook::resetTempSyncStat() |
675 | { | 690 | { |
676 | Iterator it; | 691 | Iterator it; |
677 | for ( it = begin(); it != end(); ++it ) { | 692 | for ( it = begin(); it != end(); ++it ) { |
678 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 693 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
679 | } | 694 | } |
680 | 695 | ||
681 | } | 696 | } |
682 | 697 | ||
683 | QStringList AddressBook:: uidList() | 698 | QStringList AddressBook:: uidList() |
684 | { | 699 | { |
685 | QStringList results; | 700 | QStringList results; |
686 | Iterator it; | 701 | Iterator it; |
687 | for ( it = begin(); it != end(); ++it ) { | 702 | for ( it = begin(); it != end(); ++it ) { |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 157dc56..8f62f0d 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -263,67 +263,68 @@ class AddressBook : public QObject | |||
263 | bool addResource( Resource * ); | 263 | bool addResource( Resource * ); |
264 | 264 | ||
265 | /** | 265 | /** |
266 | Remove address book resource. | 266 | Remove address book resource. |
267 | */ | 267 | */ |
268 | bool removeResource( Resource * ); | 268 | bool removeResource( Resource * ); |
269 | 269 | ||
270 | /** | 270 | /** |
271 | Return pointer list of all resources. | 271 | Return pointer list of all resources. |
272 | */ | 272 | */ |
273 | QPtrList<Resource> resources(); | 273 | QPtrList<Resource> resources(); |
274 | 274 | ||
275 | /** | 275 | /** |
276 | Set the @p ErrorHandler, that is used by @ref error() to | 276 | Set the @p ErrorHandler, that is used by @ref error() to |
277 | provide gui-independend error messages. | 277 | provide gui-independend error messages. |
278 | */ | 278 | */ |
279 | void setErrorHandler( ErrorHandler * ); | 279 | void setErrorHandler( ErrorHandler * ); |
280 | 280 | ||
281 | /** | 281 | /** |
282 | Shows gui independend error messages. | 282 | Shows gui independend error messages. |
283 | */ | 283 | */ |
284 | void error( const QString& ); | 284 | void error( const QString& ); |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Query all resources to clean up their lock files | 287 | Query all resources to clean up their lock files |
288 | */ | 288 | */ |
289 | void cleanUp(); | 289 | void cleanUp(); |
290 | 290 | ||
291 | // sync stuff | 291 | // sync stuff |
292 | //Addressee::List getExternLastSyncAddressees(); | 292 | //Addressee::List getExternLastSyncAddressees(); |
293 | void resetTempSyncStat(); | 293 | void resetTempSyncStat(); |
294 | QStringList uidList(); | 294 | QStringList uidList(); |
295 | void removeDeletedAddressees(); | 295 | void removeSyncAddressees( bool removeDeleted = false ); |
296 | void mergeAB( AddressBook *aBook, const QString& profile ); | 296 | void mergeAB( AddressBook *aBook, const QString& profile ); |
297 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 297 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
298 | bool containsExternalUid( const QString& uid ); | ||
298 | 299 | ||
299 | void preExternSync( AddressBook* aBook, const QString& csd ); | 300 | void preExternSync( AddressBook* aBook, const QString& csd ); |
300 | void postExternSync( AddressBook* aBook, const QString& csd ); | 301 | void postExternSync( AddressBook* aBook, const QString& csd ); |
301 | signals: | 302 | signals: |
302 | /** | 303 | /** |
303 | Emitted, when the address book has changed on disk. | 304 | Emitted, when the address book has changed on disk. |
304 | */ | 305 | */ |
305 | void addressBookChanged( AddressBook * ); | 306 | void addressBookChanged( AddressBook * ); |
306 | 307 | ||
307 | /** | 308 | /** |
308 | Emitted, when the address book has been locked for writing. | 309 | Emitted, when the address book has been locked for writing. |
309 | */ | 310 | */ |
310 | void addressBookLocked( AddressBook * ); | 311 | void addressBookLocked( AddressBook * ); |
311 | 312 | ||
312 | /** | 313 | /** |
313 | Emitted, when the address book has been unlocked. | 314 | Emitted, when the address book has been unlocked. |
314 | */ | 315 | */ |
315 | void addressBookUnlocked( AddressBook * ); | 316 | void addressBookUnlocked( AddressBook * ); |
316 | 317 | ||
317 | protected: | 318 | protected: |
318 | void deleteRemovedAddressees(); | 319 | void deleteRemovedAddressees(); |
319 | void setStandardResource( Resource * ); | 320 | void setStandardResource( Resource * ); |
320 | Resource *standardResource(); | 321 | Resource *standardResource(); |
321 | KRES::Manager<Resource> *resourceManager(); | 322 | KRES::Manager<Resource> *resourceManager(); |
322 | 323 | ||
323 | void init(const QString &config, const QString &family); | 324 | void init(const QString &config, const QString &family); |
324 | 325 | ||
325 | private: | 326 | private: |
326 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 327 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
327 | 328 | ||
328 | 329 | ||
329 | struct AddressBookData; | 330 | struct AddressBookData; |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index fda62f1..e241281 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -66,65 +66,65 @@ struct Addressee::AddresseeData : public KShared | |||
66 | QString productId; | 66 | QString productId; |
67 | QDateTime revision; | 67 | QDateTime revision; |
68 | QString sortString; | 68 | QString sortString; |
69 | QString externalUID; | 69 | QString externalUID; |
70 | QString originalExternalUID; | 70 | QString originalExternalUID; |
71 | KURL url; | 71 | KURL url; |
72 | Secrecy secrecy; | 72 | Secrecy secrecy; |
73 | Picture logo; | 73 | Picture logo; |
74 | Picture photo; | 74 | Picture photo; |
75 | Sound sound; | 75 | Sound sound; |
76 | Agent agent; | 76 | Agent agent; |
77 | QString mExternalId; | 77 | QString mExternalId; |
78 | PhoneNumber::List phoneNumbers; | 78 | PhoneNumber::List phoneNumbers; |
79 | Address::List addresses; | 79 | Address::List addresses; |
80 | Key::List keys; | 80 | Key::List keys; |
81 | QStringList emails; | 81 | QStringList emails; |
82 | QStringList categories; | 82 | QStringList categories; |
83 | QStringList custom; | 83 | QStringList custom; |
84 | int mTempSyncStat; | 84 | int mTempSyncStat; |
85 | Resource *resource; | 85 | Resource *resource; |
86 | 86 | ||
87 | bool empty :1; | 87 | bool empty :1; |
88 | bool changed :1; | 88 | bool changed :1; |
89 | }; | 89 | }; |
90 | 90 | ||
91 | Addressee::Addressee() | 91 | Addressee::Addressee() |
92 | { | 92 | { |
93 | mData = new AddresseeData; | 93 | mData = new AddresseeData; |
94 | mData->empty = true; | 94 | mData->empty = true; |
95 | mData->changed = false; | 95 | mData->changed = false; |
96 | mData->resource = 0; | 96 | mData->resource = 0; |
97 | mData->mExternalId = ":"; | 97 | mData->mExternalId = ":"; |
98 | mData->revision = QDateTime ( QDate( 2004,1,1)); | 98 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
99 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 99 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
100 | } | 100 | } |
101 | 101 | ||
102 | Addressee::~Addressee() | 102 | Addressee::~Addressee() |
103 | { | 103 | { |
104 | } | 104 | } |
105 | 105 | ||
106 | Addressee::Addressee( const Addressee &a ) | 106 | Addressee::Addressee( const Addressee &a ) |
107 | { | 107 | { |
108 | mData = a.mData; | 108 | mData = a.mData; |
109 | } | 109 | } |
110 | 110 | ||
111 | Addressee &Addressee::operator=( const Addressee &a ) | 111 | Addressee &Addressee::operator=( const Addressee &a ) |
112 | { | 112 | { |
113 | mData = a.mData; | 113 | mData = a.mData; |
114 | return (*this); | 114 | return (*this); |
115 | } | 115 | } |
116 | 116 | ||
117 | Addressee Addressee::copy() | 117 | Addressee Addressee::copy() |
118 | { | 118 | { |
119 | Addressee a; | 119 | Addressee a; |
120 | *(a.mData) = *mData; | 120 | *(a.mData) = *mData; |
121 | return a; | 121 | return a; |
122 | } | 122 | } |
123 | 123 | ||
124 | void Addressee::detach() | 124 | void Addressee::detach() |
125 | { | 125 | { |
126 | if ( mData.count() == 1 ) return; | 126 | if ( mData.count() == 1 ) return; |
127 | *this = copy(); | 127 | *this = copy(); |
128 | } | 128 | } |
129 | 129 | ||
130 | bool Addressee::operator==( const Addressee &a ) const | 130 | bool Addressee::operator==( const Addressee &a ) const |
@@ -279,64 +279,66 @@ void Addressee::mergeContact( const Addressee& ad ) | |||
279 | 279 | ||
280 | detach(); | 280 | detach(); |
281 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 281 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
282 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 282 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
283 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 283 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
284 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 284 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
285 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 285 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
286 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 286 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
287 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 287 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
288 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 288 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
289 | if ( !mData->birthday.isValid() ) | 289 | if ( !mData->birthday.isValid() ) |
290 | if ( ad.mData->birthday.isValid()) | 290 | if ( ad.mData->birthday.isValid()) |
291 | mData->birthday = ad.mData->birthday; | 291 | mData->birthday = ad.mData->birthday; |
292 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 292 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
293 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 293 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
294 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 294 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
295 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 295 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
296 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 296 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
297 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 297 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
298 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 298 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
299 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 299 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
300 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 300 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
301 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 301 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
302 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 302 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
303 | 303 | ||
304 | // pending: | 304 | // pending: |
305 | // merging phonenumbers | 305 | // merging phonenumbers |
306 | // merging addresses | 306 | // merging addresses |
307 | // merging emails; | 307 | // merging emails; |
308 | // merging categories; | 308 | // merging categories; |
309 | // merging custom; | 309 | // merging custom; |
310 | // merging keys | 310 | // merging keys |
311 | qDebug("merge contact %s ", ad.uid().latin1()); | ||
312 | setUid( ad.uid() ); | ||
311 | } | 313 | } |
312 | 314 | ||
313 | void Addressee::removeID(const QString &prof) | 315 | void Addressee::removeID(const QString &prof) |
314 | { | 316 | { |
315 | detach(); | 317 | detach(); |
316 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 318 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
317 | 319 | ||
318 | } | 320 | } |
319 | void Addressee::setID( const QString & prof , const QString & id ) | 321 | void Addressee::setID( const QString & prof , const QString & id ) |
320 | { | 322 | { |
321 | detach(); | 323 | detach(); |
322 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 324 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
323 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 325 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
324 | } | 326 | } |
325 | void Addressee::setTempSyncStat( int id ) | 327 | void Addressee::setTempSyncStat( int id ) |
326 | { | 328 | { |
327 | if ( mData->mTempSyncStat == id ) return; | 329 | if ( mData->mTempSyncStat == id ) return; |
328 | detach(); | 330 | detach(); |
329 | mData->mTempSyncStat = id; | 331 | mData->mTempSyncStat = id; |
330 | } | 332 | } |
331 | int Addressee::tempSyncStat() const | 333 | int Addressee::tempSyncStat() const |
332 | { | 334 | { |
333 | return mData->mTempSyncStat; | 335 | return mData->mTempSyncStat; |
334 | } | 336 | } |
335 | 337 | ||
336 | QString Addressee::getID( const QString & prof) | 338 | QString Addressee::getID( const QString & prof) |
337 | { | 339 | { |
338 | return KIdManager::getId ( mData->mExternalId, prof ); | 340 | return KIdManager::getId ( mData->mExternalId, prof ); |
339 | } | 341 | } |
340 | 342 | ||
341 | void Addressee::setCsum( const QString & prof , const QString & id ) | 343 | void Addressee::setCsum( const QString & prof , const QString & id ) |
342 | { | 344 | { |
@@ -350,76 +352,78 @@ QString Addressee::getCsum( const QString & prof) | |||
350 | { | 352 | { |
351 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 353 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
352 | } | 354 | } |
353 | 355 | ||
354 | void Addressee::setIDStr( const QString & s ) | 356 | void Addressee::setIDStr( const QString & s ) |
355 | { | 357 | { |
356 | detach(); | 358 | detach(); |
357 | mData->mExternalId = s; | 359 | mData->mExternalId = s; |
358 | } | 360 | } |
359 | 361 | ||
360 | QString Addressee::IDStr() const | 362 | QString Addressee::IDStr() const |
361 | { | 363 | { |
362 | return mData->mExternalId; | 364 | return mData->mExternalId; |
363 | } | 365 | } |
364 | 366 | ||
365 | void Addressee::setExternalUID( const QString &id ) | 367 | void Addressee::setExternalUID( const QString &id ) |
366 | { | 368 | { |
367 | if ( id == mData->externalUID ) return; | 369 | if ( id == mData->externalUID ) return; |
368 | detach(); | 370 | detach(); |
369 | mData->empty = false; | 371 | mData->empty = false; |
370 | mData->externalUID = id; | 372 | mData->externalUID = id; |
371 | } | 373 | } |
372 | 374 | ||
373 | QString Addressee::externalUID() const | 375 | QString Addressee::externalUID() const |
374 | { | 376 | { |
375 | return mData->externalUID; | 377 | return mData->externalUID; |
376 | } | 378 | } |
377 | void Addressee::setOriginalExternalUID( const QString &id ) | 379 | void Addressee::setOriginalExternalUID( const QString &id ) |
378 | { | 380 | { |
379 | if ( id == mData->originalExternalUID ) return; | 381 | if ( id == mData->originalExternalUID ) return; |
380 | detach(); | 382 | detach(); |
381 | mData->empty = false; | 383 | mData->empty = false; |
384 | qDebug("*******Set orig uid %s ", id.latin1()); | ||
382 | mData->originalExternalUID = id; | 385 | mData->originalExternalUID = id; |
383 | } | 386 | } |
384 | 387 | ||
385 | QString Addressee::originalExternalUID() const | 388 | QString Addressee::originalExternalUID() const |
386 | { | 389 | { |
387 | return mData->originalExternalUID; | 390 | return mData->originalExternalUID; |
388 | } | 391 | } |
389 | 392 | ||
390 | void Addressee::setUid( const QString &id ) | 393 | void Addressee::setUid( const QString &id ) |
391 | { | 394 | { |
392 | if ( id == mData->uid ) return; | 395 | if ( id == mData->uid ) return; |
393 | detach(); | 396 | detach(); |
397 | qDebug("****setuid %s ", id.latin1()); | ||
394 | mData->empty = false; | 398 | mData->empty = false; |
395 | mData->uid = id; | 399 | mData->uid = id; |
396 | } | 400 | } |
397 | 401 | ||
398 | QString Addressee::uid() const | 402 | QString Addressee::uid() const |
399 | { | 403 | { |
400 | if ( mData->uid.isEmpty() ) | 404 | if ( mData->uid.isEmpty() ) |
401 | mData->uid = KApplication::randomString( 10 ); | 405 | mData->uid = KApplication::randomString( 10 ); |
402 | 406 | ||
403 | return mData->uid; | 407 | return mData->uid; |
404 | } | 408 | } |
405 | 409 | ||
406 | QString Addressee::uidLabel() | 410 | QString Addressee::uidLabel() |
407 | { | 411 | { |
408 | return i18n("Unique Identifier"); | 412 | return i18n("Unique Identifier"); |
409 | } | 413 | } |
410 | 414 | ||
411 | void Addressee::setName( const QString &name ) | 415 | void Addressee::setName( const QString &name ) |
412 | { | 416 | { |
413 | if ( name == mData->name ) return; | 417 | if ( name == mData->name ) return; |
414 | detach(); | 418 | detach(); |
415 | mData->empty = false; | 419 | mData->empty = false; |
416 | mData->name = name; | 420 | mData->name = name; |
417 | } | 421 | } |
418 | 422 | ||
419 | QString Addressee::name() const | 423 | QString Addressee::name() const |
420 | { | 424 | { |
421 | return mData->name; | 425 | return mData->name; |
422 | } | 426 | } |
423 | 427 | ||
424 | QString Addressee::nameLabel() | 428 | QString Addressee::nameLabel() |
425 | { | 429 | { |
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index de45e63..430c7b3 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp | |||
@@ -57,65 +57,65 @@ bool QtopiaConverter::init() | |||
57 | catDB->load( categoryFileName() ); | 57 | catDB->load( categoryFileName() ); |
58 | return true; | 58 | return true; |
59 | } | 59 | } |
60 | 60 | ||
61 | void QtopiaConverter::deinit() | 61 | void QtopiaConverter::deinit() |
62 | { | 62 | { |
63 | if (catDB) | 63 | if (catDB) |
64 | { | 64 | { |
65 | delete catDB; | 65 | delete catDB; |
66 | catDB = 0; | 66 | catDB = 0; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) | 70 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) |
71 | { | 71 | { |
72 | // name | 72 | // name |
73 | addr.setFormattedName(contact.fileAs()); | 73 | addr.setFormattedName(contact.fileAs()); |
74 | addr.setFamilyName( contact.lastName() ); | 74 | addr.setFamilyName( contact.lastName() ); |
75 | addr.setGivenName( contact.firstName() ); | 75 | addr.setGivenName( contact.firstName() ); |
76 | addr.setAdditionalName( contact.middleName() ); | 76 | addr.setAdditionalName( contact.middleName() ); |
77 | addr.setPrefix( contact.nameTitle() ); | 77 | addr.setPrefix( contact.nameTitle() ); |
78 | addr.setSuffix( contact.suffix() ); | 78 | addr.setSuffix( contact.suffix() ); |
79 | 79 | ||
80 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 80 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
81 | QString exuid = contact.uid().toString(); | 81 | QString exuid = contact.uid().toString(); |
82 | addr.setOriginalExternalUID( exuid ); | 82 | addr.setOriginalExternalUID( exuid ); |
83 | int ente = exuid.find( "-0000"); | 83 | int ente = exuid.find( "-0000"); |
84 | if ( exuid.left(1) == "{" ) | 84 | if ( exuid.left(1) == "{" ) |
85 | exuid = exuid.mid(1); | 85 | exuid = exuid.mid(1); |
86 | if ( ente > -1 ) | 86 | if ( ente > -1 ) |
87 | exuid = exuid.left( ente-1 ); | 87 | exuid = exuid.left( ente-1 ); |
88 | addr.setExternalUID( exuid ); | 88 | addr.setExternalUID( exuid ); |
89 | //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); | 89 | qDebug("QtopiaConverter:set %s uid %s ",addr.originalExternalUID().latin1(),addr.externalUID().latin1() ); |
90 | 90 | ||
91 | 91 | ||
92 | QStringList emails = contact.emailList(); | 92 | QStringList emails = contact.emailList(); |
93 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 93 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
94 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); | 94 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); |
95 | } | 95 | } |
96 | 96 | ||
97 | if (!contact.defaultEmail().isEmpty()) | 97 | if (!contact.defaultEmail().isEmpty()) |
98 | addr.insertEmail(contact.defaultEmail(), true); | 98 | addr.insertEmail(contact.defaultEmail(), true); |
99 | 99 | ||
100 | // home | 100 | // home |
101 | if ((!contact.homeStreet().isEmpty()) || | 101 | if ((!contact.homeStreet().isEmpty()) || |
102 | (!contact.homeCity().isEmpty()) || | 102 | (!contact.homeCity().isEmpty()) || |
103 | (!contact.homeState().isEmpty()) || | 103 | (!contact.homeState().isEmpty()) || |
104 | (!contact.homeZip().isEmpty()) || | 104 | (!contact.homeZip().isEmpty()) || |
105 | (!contact.homeCountry().isEmpty())) | 105 | (!contact.homeCountry().isEmpty())) |
106 | { | 106 | { |
107 | Address homeaddress; | 107 | Address homeaddress; |
108 | homeaddress.setType(Address::Home); | 108 | homeaddress.setType(Address::Home); |
109 | //US homeaddress.setPostOfficeBox( "" ); | 109 | //US homeaddress.setPostOfficeBox( "" ); |
110 | //US homeaddress.setExtended( "" ); | 110 | //US homeaddress.setExtended( "" ); |
111 | homeaddress.setStreet( contact.homeStreet() ); | 111 | homeaddress.setStreet( contact.homeStreet() ); |
112 | homeaddress.setLocality( contact.homeCity() ); | 112 | homeaddress.setLocality( contact.homeCity() ); |
113 | homeaddress.setRegion( contact.homeState() ); | 113 | homeaddress.setRegion( contact.homeState() ); |
114 | homeaddress.setPostalCode( contact.homeZip() ); | 114 | homeaddress.setPostalCode( contact.homeZip() ); |
115 | homeaddress.setCountry( contact.homeCountry() ); | 115 | homeaddress.setCountry( contact.homeCountry() ); |
116 | 116 | ||
117 | addr.insertAddress( homeaddress ); | 117 | addr.insertAddress( homeaddress ); |
118 | } | 118 | } |
119 | 119 | ||
120 | if (!contact.homePhone().isEmpty()) | 120 | if (!contact.homePhone().isEmpty()) |
121 | { | 121 | { |
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 935a1cf..1f90fcb 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp | |||
@@ -168,105 +168,164 @@ bool ResourceQtopia::load() | |||
168 | qDebug("ResourceQtopia::load: %s", fileName().latin1()); | 168 | qDebug("ResourceQtopia::load: %s", fileName().latin1()); |
169 | 169 | ||
170 | AddressBookIterator it(*mAccess); | 170 | AddressBookIterator it(*mAccess); |
171 | const PimContact* contact; | 171 | const PimContact* contact; |
172 | bool res; | 172 | bool res; |
173 | 173 | ||
174 | for (contact=it.toFirst(); it.current(); ++it) | 174 | for (contact=it.toFirst(); it.current(); ++it) |
175 | { | 175 | { |
176 | contact = it.current(); | 176 | contact = it.current(); |
177 | 177 | ||
178 | KABC::Addressee addressee; | 178 | KABC::Addressee addressee; |
179 | 179 | ||
180 | res = mConverter->qtopiaToAddressee( (*contact), addressee ); | 180 | res = mConverter->qtopiaToAddressee( (*contact), addressee ); |
181 | 181 | ||
182 | if ( !addressee.isEmpty() && res ) | 182 | if ( !addressee.isEmpty() && res ) |
183 | { | 183 | { |
184 | addressee.setResource( this ); | 184 | addressee.setResource( this ); |
185 | addressBook()->insertAddressee( addressee ); | 185 | addressBook()->insertAddressee( addressee ); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | return true; | 189 | return true; |
190 | } | 190 | } |
191 | 191 | ||
192 | bool ResourceQtopia::save( Ticket *ticket ) | 192 | bool ResourceQtopia::save( Ticket *ticket ) |
193 | { | 193 | { |
194 | qDebug("ResourceQtopia::save: %s", fileName().latin1()); | 194 | qDebug("ResourceQtopia::save: %s", fileName().latin1()); |
195 | 195 | ||
196 | mDirWatch.stopScan(); | 196 | mDirWatch.stopScan(); |
197 | 197 | ||
198 | KABC::AddressBook::Iterator it; | 198 | KABC::AddressBook::Iterator it; |
199 | bool res; | 199 | bool res; |
200 | 200 | KABC::Addressee::List changedAddressees; | |
201 | QStringList addedUID; | ||
201 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 202 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
202 | //KABC::Addressee addressee = (*it); | 203 | //KABC::Addressee addressee = (*it); |
204 | // qDebug("AAAfor uid %s ", (*it).originalExternalUID().latin1() ); | ||
203 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 205 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
204 | QUuid uid( (*it).originalExternalUID() ); | 206 | QUuid uid( (*it).originalExternalUID() ); |
205 | bool ok; | 207 | bool ok; |
206 | PimContact c = mAccess->contactForId( uid, &ok ); | 208 | PimContact c = mAccess->contactForId( uid, &ok ); |
209 | qDebug("ResourceQtopia::save:Found %d for uid %s ", ok,(*it).originalExternalUID().latin1() ); | ||
207 | res = mConverter->addresseeToQtopia( *it, c ); | 210 | res = mConverter->addresseeToQtopia( *it, c ); |
208 | if (res == true) { | 211 | if (res == true) { |
209 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | 212 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { |
210 | mAccess->addContact(c); | 213 | qDebug("skipping adding of contact "); |
211 | KABC::Addressee addressee; | 214 | continue; |
212 | mConverter->qtopiaToAddressee( c, addressee ); | 215 | PimContact e; |
213 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 216 | AddressBookAccess Access2; |
214 | addressBook()->insertAddressee( addressee ); | 217 | Access2.addContact(e); |
218 | const PimContact* contact; | ||
219 | bool res; | ||
220 | QString uid2, Ouid; | ||
221 | AddressBookIterator itt(Access2); | ||
222 | for (contact=itt.toFirst(); itt.current(); ++itt) | ||
223 | { | ||
224 | contact = itt.current(); | ||
225 | QString exuid = contact->uid().toString(); | ||
226 | Ouid =exuid; | ||
227 | int ente = exuid.find( "-0000"); | ||
228 | if ( exuid.left(1) == "{" ) | ||
229 | exuid = exuid.mid(1); | ||
230 | if ( ente > -1 ) | ||
231 | exuid = exuid.left( ente-1 ); | ||
232 | uid2 = exuid; | ||
233 | qDebug("trying find uid "); | ||
234 | if ( !addressBook()->containsExternalUid( uid2 ) ) { | ||
235 | qDebug("ab not contains "); | ||
236 | if ( !addedUID.contains( uid2 )) { | ||
237 | qDebug("list not contains "); | ||
238 | break; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | } | ||
243 | if ( !itt.current()) { | ||
244 | qDebug("ERROR uid "); | ||
245 | continue; | ||
246 | } | ||
247 | else | ||
248 | qDebug("ADD uid detected "); | ||
249 | |||
250 | |||
251 | QUuid uid3( Ouid); | ||
252 | PimContact d = Access2.contactForId( uid3, &ok ); | ||
253 | if ( ! ok ) { | ||
254 | qDebug("ADD: Error getting new uid "); | ||
255 | } else { | ||
256 | qDebug("NEW UID found "); | ||
257 | PimContact g = mAccess->contactForId( c.uid(), &ok ); | ||
258 | KABC::Addressee addressee; | ||
259 | mConverter->qtopiaToAddressee( g, addressee ); | ||
260 | addressee.setUid((*it).uid() ); | ||
261 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
262 | changedAddressees.append( addressee ); | ||
263 | addedUID.append( uid2 ); | ||
264 | } | ||
265 | |||
215 | 266 | ||
216 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 267 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
268 | qDebug("Remove contact "); | ||
217 | if ( ok ) | 269 | if ( ok ) |
218 | mAccess->removeContact(c); | 270 | mAccess->removeContact(c); |
219 | else | 271 | else |
220 | qDebug("Error revoe contact from qtopia "); | 272 | qDebug("Error remove contact from qtopia "); |
221 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 273 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
222 | if ( ok ) { | 274 | if ( ok ) { |
275 | qDebug("Update contact "); | ||
223 | mAccess->updateContact(c); | 276 | mAccess->updateContact(c); |
277 | PimContact g = mAccess->contactForId( c.uid(), &ok ); | ||
224 | KABC::Addressee addressee; | 278 | KABC::Addressee addressee; |
225 | mConverter->qtopiaToAddressee( c, addressee ); | 279 | mConverter->qtopiaToAddressee( g, addressee ); |
280 | addressee.setUid((*it).uid() ); | ||
226 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | 281 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); |
227 | addressBook()->insertAddressee( addressee ); | 282 | changedAddressees.append( addressee ); |
228 | } | 283 | } |
229 | else | 284 | else |
230 | qDebug("Error update contact from qtopia "); | 285 | qDebug("Error update contact from qtopia "); |
231 | 286 | ||
232 | } | 287 | } |
233 | 288 | ||
234 | } else { | 289 | } else { |
235 | qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); | 290 | qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1()); |
236 | } | 291 | } |
237 | } | 292 | } |
238 | } | 293 | } |
239 | 294 | ||
240 | // mAccess->addressBookUpdated(); | 295 | KABC::Addressee::List::Iterator it2; |
296 | for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) | ||
297 | addressBook()->insertAddressee((*it2)); | ||
298 | |||
299 | |||
241 | 300 | ||
242 | mDirWatch.startScan(); | 301 | mDirWatch.startScan(); |
243 | 302 | ||
244 | delete ticket; | 303 | delete ticket; |
245 | unlock( fileName() ); | 304 | unlock( fileName() ); |
246 | 305 | ||
247 | return true; | 306 | return true; |
248 | } | 307 | } |
249 | 308 | ||
250 | bool ResourceQtopia::lock( const QString &lockfileName ) | 309 | bool ResourceQtopia::lock( const QString &lockfileName ) |
251 | { | 310 | { |
252 | qDebug("ResourceQtopia::lock: %s", fileName().latin1()); | 311 | qDebug("ResourceQtopia::lock: %s", fileName().latin1()); |
253 | 312 | ||
254 | kdDebug(5700) << "ResourceQtopia::lock()" << endl; | 313 | kdDebug(5700) << "ResourceQtopia::lock()" << endl; |
255 | 314 | ||
256 | QString fn = lockfileName; | 315 | QString fn = lockfileName; |
257 | 316 | ||
258 | KURL url(fn); | 317 | KURL url(fn); |
259 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 318 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
260 | 319 | ||
261 | kdDebug(5700) << "-- lock name: " << lockName << endl; | 320 | kdDebug(5700) << "-- lock name: " << lockName << endl; |
262 | 321 | ||
263 | if (QFile::exists( lockName )) | 322 | if (QFile::exists( lockName )) |
264 | { | 323 | { |
265 | qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1()); | 324 | qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1()); |
266 | return false; | 325 | return false; |
267 | } | 326 | } |
268 | 327 | ||
269 | QString lockUniqueName; | 328 | QString lockUniqueName; |
270 | lockUniqueName = fn + KApplication::randomString( 8 ); | 329 | lockUniqueName = fn + KApplication::randomString( 8 ); |
271 | 330 | ||
272 | url = lockUniqueName; | 331 | url = lockUniqueName; |