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 | |
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 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 58 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 44 |
7 files changed, 153 insertions, 66 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 86dc7c2..17b9ba2 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -553,7 +553,6 @@ void AddressBook::removeAddressee( const Addressee &a ) | |||
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 ; |
@@ -563,10 +562,10 @@ void AddressBook::removeDeletedAddressees() | |||
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; |
@@ -618,9 +617,10 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | |||
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 ); |
@@ -634,5 +634,13 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | |||
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 | { |
@@ -654,4 +662,11 @@ void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | |||
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 | ||
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 157dc56..8f62f0d 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -293,7 +293,8 @@ class AddressBook : public QObject | |||
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 ); |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index fda62f1..e241281 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -96,5 +96,5 @@ Addressee::Addressee() | |||
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 | } |
@@ -309,4 +309,6 @@ void Addressee::mergeContact( const Addressee& ad ) | |||
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 | ||
@@ -380,4 +382,5 @@ void Addressee::setOriginalExternalUID( const QString &id ) | |||
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 | } |
@@ -392,4 +395,5 @@ void Addressee::setUid( const QString &id ) | |||
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; |
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 | |||
@@ -87,5 +87,5 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
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 | ||
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 | |||
@@ -198,32 +198,87 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
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 |
@@ -238,5 +293,9 @@ bool ResourceQtopia::save( Ticket *ticket ) | |||
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(); |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 8f3ca9b..f8683e7 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2550,26 +2550,28 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2550 | // 3 cancel | 2550 | // 3 cancel |
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | QDateTime localMod = local->revision(); | ||
2553 | QDateTime remoteMod = remote->revision(); | ||
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2554 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2553 | bool remCh, locCh; | 2555 | bool remCh, locCh; |
2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2556 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2555 | 2557 | ||
2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2558 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2557 | locCh = ( local->revision() > mLastAddressbookSync ); | 2559 | locCh = ( localMod > mLastAddressbookSync ); |
2558 | if ( !remCh && ! locCh ) { | 2560 | if ( !remCh && ! locCh ) { |
2559 | //qDebug("both not changed "); | 2561 | qDebug("both not changed "); |
2560 | lastSync = local->revision().addDays(1); | 2562 | lastSync = localMod.addDays(1); |
2561 | if ( mode <= SYNC_PREF_ASK ) | 2563 | if ( mode <= SYNC_PREF_ASK ) |
2562 | return 0; | 2564 | return 0; |
2563 | } else { | 2565 | } else { |
2564 | if ( locCh ) { | 2566 | if ( locCh ) { |
2565 | //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2567 | qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2566 | lastSync = local->revision().addDays( -1 ); | 2568 | lastSync = localMod.addDays( -1 ); |
2567 | if ( !remCh ) | 2569 | if ( !remCh ) |
2568 | remote->setRevision( lastSync.addDays( -1 ) ); | 2570 | remoteMod =( lastSync.addDays( -1 ) ); |
2569 | } else { | 2571 | } else { |
2570 | //qDebug(" not loc changed "); | 2572 | //qDebug(" not loc changed "); |
2571 | lastSync = local->revision().addDays( 1 ); | 2573 | lastSync = localMod.addDays( 1 ); |
2572 | if ( remCh ) | 2574 | if ( remCh ) |
2573 | remote->setRevision( lastSync.addDays( 1 ) ); | 2575 | remoteMod =( lastSync.addDays( 1 ) ); |
2574 | 2576 | ||
2575 | } | 2577 | } |
@@ -2579,5 +2581,5 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2579 | mode = SYNC_PREF_ASK; | 2581 | mode = SYNC_PREF_ASK; |
2580 | } else { | 2582 | } else { |
2581 | if ( local->revision() == remote->revision() ) | 2583 | if ( localMod == remoteMod ) |
2582 | return 0; | 2584 | return 0; |
2583 | 2585 | ||
@@ -2585,5 +2587,5 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2587 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2586 | 2588 | ||
2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2589 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2590 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2589 | //full = true; //debug only | 2591 | //full = true; //debug only |
@@ -2610,19 +2612,19 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2610 | switch( mode ) { | 2612 | switch( mode ) { |
2611 | case SYNC_PREF_LOCAL: | 2613 | case SYNC_PREF_LOCAL: |
2612 | if ( lastSync > remote->revision() ) | 2614 | if ( lastSync > remoteMod ) |
2613 | return 1; | 2615 | return 1; |
2614 | if ( lastSync > local->revision() ) | 2616 | if ( lastSync > localMod ) |
2615 | return 2; | 2617 | return 2; |
2616 | return 1; | 2618 | return 1; |
2617 | break; | 2619 | break; |
2618 | case SYNC_PREF_REMOTE: | 2620 | case SYNC_PREF_REMOTE: |
2619 | if ( lastSync > remote->revision() ) | 2621 | if ( lastSync > remoteMod ) |
2620 | return 1; | 2622 | return 1; |
2621 | if ( lastSync > local->revision() ) | 2623 | if ( lastSync > localMod ) |
2622 | return 2; | 2624 | return 2; |
2623 | return 2; | 2625 | return 2; |
2624 | break; | 2626 | break; |
2625 | case SYNC_PREF_NEWEST: | 2627 | case SYNC_PREF_NEWEST: |
2626 | if ( local->revision() > remote->revision() ) | 2628 | if ( localMod > remoteMod ) |
2627 | return 1; | 2629 | return 1; |
2628 | else | 2630 | else |
@@ -2630,10 +2632,10 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2630 | break; | 2632 | break; |
2631 | case SYNC_PREF_ASK: | 2633 | case SYNC_PREF_ASK: |
2632 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2634 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2633 | if ( lastSync > remote->revision() ) | 2635 | if ( lastSync > remoteMod ) |
2634 | return 1; | 2636 | return 1; |
2635 | if ( lastSync > local->revision() ) | 2637 | if ( lastSync > localMod ) |
2636 | return 2; | 2638 | return 2; |
2637 | localIsNew = local->revision() >= remote->revision(); | 2639 | localIsNew = localMod >= remoteMod; |
2638 | //qDebug("conflict! ************************************** "); | 2640 | //qDebug("conflict! ************************************** "); |
2639 | { | 2641 | { |
@@ -2787,4 +2789,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2787 | ++changedRemote; | 2789 | ++changedRemote; |
2788 | } else { // take == 2 take remote | 2790 | } else { // take == 2 take remote |
2791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | ||
2792 | if ( inR.revision().date().year() < 2004 ) | ||
2793 | inR.setRevision( modifiedCalendar ); | ||
2794 | } | ||
2789 | idS = inL.IDStr(); | 2795 | idS = inL.IDStr(); |
2790 | local->removeAddressee( inL ); | 2796 | local->removeAddressee( inL ); |
@@ -2926,7 +2932,8 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2926 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2932 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2927 | bool external = false; | 2933 | bool external = false; |
2928 | 2934 | bool isXML = false; | |
2929 | if ( filename.right(4) == ".xml") { | 2935 | if ( filename.right(4) == ".xml") { |
2930 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2936 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2937 | isXML = true; | ||
2931 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2938 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2932 | } else { | 2939 | } else { |
@@ -2937,8 +2944,7 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2937 | } else { | 2944 | } else { |
2938 | bool found = false; | 2945 | bool found = false; |
2939 | QDateTime dt( QDate( 2004,1,1)); | ||
2940 | AddressBook::Iterator it; | 2946 | AddressBook::Iterator it; |
2941 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2947 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2942 | if ( (*it).revision() != dt ) { | 2948 | if ( (*it).revision().date().year() > 2003 ) { |
2943 | found = true; | 2949 | found = true; |
2944 | break; | 2950 | break; |
@@ -2967,9 +2973,9 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2967 | if ( KABPrefs::instance()->mWriteBackFile ) | 2973 | if ( KABPrefs::instance()->mWriteBackFile ) |
2968 | { | 2974 | { |
2969 | if ( external && filename.right(4) != ".xml") | 2975 | if ( external ) |
2970 | abLocal.removeDeletedAddressees(); | 2976 | abLocal.removeSyncAddressees( !isXML); |
2971 | qDebug("Saving remote AB "); | 2977 | qDebug("Saving remote AB "); |
2972 | abLocal.saveAB(); | 2978 | abLocal.saveAB(); |
2973 | if ( external && filename.right(4) == ".xml") { | 2979 | if ( isXML ) { |
2974 | // afterwrite processing | 2980 | // afterwrite processing |
2975 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2981 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 0c75632..8e83723 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -727,4 +727,6 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | QDateTime localMod = local->lastModified(); | ||
730 | QDateTime remoteMod = remote->lastModified(); | ||
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 731 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 732 | bool remCh, locCh; |
@@ -732,21 +734,21 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
732 | //if ( remCh ) | 734 | //if ( remCh ) |
733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 735 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 736 | locCh = ( localMod > mLastCalendarSync ); |
735 | if ( !remCh && ! locCh ) { | 737 | if ( !remCh && ! locCh ) { |
736 | //qDebug("both not changed "); | 738 | //qDebug("both not changed "); |
737 | lastSync = local->lastModified().addDays(1); | 739 | lastSync = localMod.addDays(1); |
738 | if ( mode <= SYNC_PREF_ASK ) | 740 | if ( mode <= SYNC_PREF_ASK ) |
739 | return 0; | 741 | return 0; |
740 | } else { | 742 | } else { |
741 | if ( locCh ) { | 743 | if ( locCh ) { |
742 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 744 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
743 | lastSync = local->lastModified().addDays( -1 ); | 745 | lastSync = localMod.addDays( -1 ); |
744 | if ( !remCh ) | 746 | if ( !remCh ) |
745 | remote->setLastModified( lastSync.addDays( -1 ) ); | 747 | remoteMod = ( lastSync.addDays( -1 ) ); |
746 | } else { | 748 | } else { |
747 | //qDebug(" not loc changed "); | 749 | //qDebug(" not loc changed "); |
748 | lastSync = local->lastModified().addDays( 1 ); | 750 | lastSync = localMod.addDays( 1 ); |
749 | if ( remCh ) | 751 | if ( remCh ) |
750 | remote->setLastModified( lastSync.addDays( 1 ) ); | 752 | remoteMod =( lastSync.addDays( 1 ) ); |
751 | 753 | ||
752 | } | 754 | } |
@@ -756,5 +758,5 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
756 | mode = SYNC_PREF_ASK; | 758 | mode = SYNC_PREF_ASK; |
757 | } else { | 759 | } else { |
758 | if ( local->lastModified() == remote->lastModified() ) | 760 | if ( localMod == remoteMod ) |
759 | if ( local->revision() == remote->revision() ) | 761 | if ( local->revision() == remote->revision() ) |
760 | return 0; | 762 | return 0; |
@@ -763,6 +765,6 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
763 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 765 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
764 | 766 | ||
765 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 767 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
766 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 768 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
767 | //full = true; //debug only | 769 | //full = true; //debug only |
768 | if ( full ) { | 770 | if ( full ) { |
@@ -788,5 +790,5 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
788 | int result; | 790 | int result; |
789 | bool localIsNew; | 791 | bool localIsNew; |
790 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 792 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
791 | 793 | ||
792 | if ( full && mode < SYNC_PREF_NEWEST ) | 794 | if ( full && mode < SYNC_PREF_NEWEST ) |
@@ -795,19 +797,19 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
795 | switch( mode ) { | 797 | switch( mode ) { |
796 | case SYNC_PREF_LOCAL: | 798 | case SYNC_PREF_LOCAL: |
797 | if ( lastSync > remote->lastModified() ) | 799 | if ( lastSync > remoteMod ) |
798 | return 1; | 800 | return 1; |
799 | if ( lastSync > local->lastModified() ) | 801 | if ( lastSync > localMod ) |
800 | return 2; | 802 | return 2; |
801 | return 1; | 803 | return 1; |
802 | break; | 804 | break; |
803 | case SYNC_PREF_REMOTE: | 805 | case SYNC_PREF_REMOTE: |
804 | if ( lastSync > remote->lastModified() ) | 806 | if ( lastSync > remoteMod ) |
805 | return 1; | 807 | return 1; |
806 | if ( lastSync > local->lastModified() ) | 808 | if ( lastSync > localMod ) |
807 | return 2; | 809 | return 2; |
808 | return 2; | 810 | return 2; |
809 | break; | 811 | break; |
810 | case SYNC_PREF_NEWEST: | 812 | case SYNC_PREF_NEWEST: |
811 | if ( local->lastModified() > remote->lastModified() ) | 813 | if ( localMod > remoteMod ) |
812 | return 1; | 814 | return 1; |
813 | else | 815 | else |
@@ -815,11 +817,11 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
815 | break; | 817 | break; |
816 | case SYNC_PREF_ASK: | 818 | case SYNC_PREF_ASK: |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 819 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | if ( lastSync > remote->lastModified() ) | 820 | if ( lastSync > remoteMod ) |
819 | return 1; | 821 | return 1; |
820 | if ( lastSync > local->lastModified() ) | 822 | if ( lastSync > localMod ) |
821 | return 2; | 823 | return 2; |
822 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 824 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
823 | localIsNew = local->lastModified() >= remote->lastModified(); | 825 | localIsNew = localMod >= remoteMod; |
824 | if ( localIsNew ) | 826 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |