summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp4
-rw-r--r--kaddressbook/kabcore.cpp25
2 files changed, 16 insertions, 13 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 012780b..3397e06 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -1051,25 +1051,27 @@ void AddresseeEditorWidget::load()
1051 mGenderBox->setCurrentItem ( 0 ); 1051 mGenderBox->setCurrentItem ( 0 );
1052 blockSignals( block ); 1052 blockSignals( block );
1053 mBlockSignals = false; 1053 mBlockSignals = false;
1054 1054
1055 mDirty = false; 1055 mDirty = false;
1056} 1056}
1057 1057
1058void AddresseeEditorWidget::save() 1058void AddresseeEditorWidget::save()
1059{ 1059{
1060 if ( !dirty() ) { 1060 if ( !dirty() ) {
1061 return; 1061 return;
1062 } 1062 }
1063 1063
1064 mAddressee.setRevision( QDateTime::currentDateTime() );
1065
1064 mAddressee.setRole( mRoleEdit->text() ); 1066 mAddressee.setRole( mRoleEdit->text() );
1065 mAddressee.setOrganization( mOrgEdit->text() ); 1067 mAddressee.setOrganization( mOrgEdit->text() );
1066 mAddressee.setUrl( KURL( mURLEdit->text() ) ); 1068 mAddressee.setUrl( KURL( mURLEdit->text() ) );
1067 mAddressee.setNote( mNoteEdit->text() ); 1069 mAddressee.setNote( mNoteEdit->text() );
1068 if ( mBirthdayPicker->inputIsValid() ) { 1070 if ( mBirthdayPicker->inputIsValid() ) {
1069 QDate da = mBirthdayPicker->date(); 1071 QDate da = mBirthdayPicker->date();
1070 if ( da > QDate::currentDate() ) 1072 if ( da > QDate::currentDate() )
1071 da.setYMD(da.year()-100, da.month(), da.day() ); 1073 da.setYMD(da.year()-100, da.month(), da.day() );
1072 mAddressee.setBirthday( QDateTime( da ) ); 1074 mAddressee.setBirthday( QDateTime( da ) );
1073 //qDebug("bday %s ",da.toString().latin1()); 1075 //qDebug("bday %s ",da.toString().latin1());
1074 } 1076 }
1075 else { 1077 else {
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 273d435..6e482b5 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2397,63 +2397,62 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
2397 // 1 take local 2397 // 1 take local
2398 // 2 take remote 2398 // 2 take remote
2399 // 3 cancel 2399 // 3 cancel
2400 QDateTime lastSync = mLastAddressbookSync; 2400 QDateTime lastSync = mLastAddressbookSync;
2401 QDateTime localMod = local->revision(); 2401 QDateTime localMod = local->revision();
2402 QDateTime remoteMod = remote->revision(); 2402 QDateTime remoteMod = remote->revision();
2403 2403
2404 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2404 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2405 2405
2406 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2406 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2407 bool remCh, locCh; 2407 bool remCh, locCh;
2408 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2408 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2409 2409 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2410 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2411 locCh = ( localMod > mLastAddressbookSync ); 2410 locCh = ( localMod > mLastAddressbookSync );
2412 if ( !remCh && ! locCh ) { 2411 if ( !remCh && ! locCh ) {
2413 //qDebug("both not changed "); 2412 qDebug("both not changed ");
2414 lastSync = localMod.addDays(1); 2413 lastSync = localMod.addDays(1);
2415 if ( mode <= SYNC_PREF_ASK ) 2414 if ( mode <= SYNC_PREF_ASK )
2416 return 0; 2415 return 0;
2417 } else { 2416 } else {
2418 if ( locCh ) { 2417 if ( locCh ) {
2419 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2418 qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2420 lastSync = localMod.addDays( -1 ); 2419 lastSync = localMod.addDays( -1 );
2421 if ( !remCh ) 2420 if ( !remCh )
2422 remoteMod =( lastSync.addDays( -1 ) ); 2421 remoteMod =( lastSync.addDays( -1 ) );
2423 } else { 2422 } else {
2424 //qDebug(" not loc changed "); 2423 qDebug(" not loc changed ");
2425 lastSync = localMod.addDays( 1 ); 2424 lastSync = localMod.addDays( 1 );
2426 if ( remCh ) 2425 if ( remCh ) {
2426 qDebug("rem changed ");
2427 remoteMod =( lastSync.addDays( 1 ) ); 2427 remoteMod =( lastSync.addDays( 1 ) );
2428 }
2428 2429
2429 } 2430 }
2430 } 2431 }
2431 full = true; 2432 full = true;
2432 if ( mode < SYNC_PREF_ASK ) 2433 if ( mode < SYNC_PREF_ASK )
2433 mode = SYNC_PREF_ASK; 2434 mode = SYNC_PREF_ASK;
2434 } else { 2435 } else {
2435 if ( localMod == remoteMod ) 2436 if ( localMod == remoteMod )
2436 return 0; 2437 return 0;
2437 2438
2438 } 2439 }
2439 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2440 qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2440 2441 qDebug("lastsync %s ", lastSync.toString().latin1() );
2441 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2442 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2443 //full = true; //debug only 2442 //full = true; //debug only
2444 if ( full ) { 2443 if ( full ) {
2445 bool equ = ( (*local) == (*remote) ); 2444 bool equ = ( (*local) == (*remote) );
2446 if ( equ ) { 2445 if ( equ ) {
2447 //qDebug("equal "); 2446 qDebug("equal ");
2448 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2447 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2449 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2448 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2450 } 2449 }
2451 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2450 if ( mode < SYNC_PREF_FORCE_LOCAL )
2452 return 0; 2451 return 0;
2453 2452
2454 }//else //debug only 2453 }//else //debug only
2455 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2454 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2456 } 2455 }
2457 int result; 2456 int result;
2458 bool localIsNew; 2457 bool localIsNew;
2459 //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() ); 2458 //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() );
@@ -2634,26 +2633,27 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2634 local->insertAddressee( inL, false ); 2633 local->insertAddressee( inL, false );
2635 idS = inR.externalUID(); 2634 idS = inR.externalUID();
2636 OidS = inR.originalExternalUID(); 2635 OidS = inR.originalExternalUID();
2637 } 2636 }
2638 else 2637 else
2639 idS = inR.IDStr(); 2638 idS = inR.IDStr();
2640 remote->removeAddressee( inR ); 2639 remote->removeAddressee( inR );
2641 inR = inL; 2640 inR = inL;
2642 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2641 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2643 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2642 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2644 inR.setOriginalExternalUID( OidS ); 2643 inR.setOriginalExternalUID( OidS );
2645 inR.setExternalUID( idS ); 2644 inR.setExternalUID( idS );
2646 if ( syncManager->syncWithDesktop() ) 2645 if ( syncManager->syncWithDesktop() ) {
2647 inR.setIDStr("changed" ); 2646 inR.setIDStr("changed" );
2647 }
2648 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2648 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2649 } else { 2649 } else {
2650 inR.setIDStr( idS ); 2650 inR.setIDStr( idS );
2651 } 2651 }
2652 inR.setResource( 0 ); 2652 inR.setResource( 0 );
2653 remote->insertAddressee( inR , false); 2653 remote->insertAddressee( inR , false);
2654 ++changedRemote; 2654 ++changedRemote;
2655 } else { // take == 2 take remote ********************** 2655 } else { // take == 2 take remote **********************
2656 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2656 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2657 if ( inR.revision().date().year() < 2004 ) 2657 if ( inR.revision().date().year() < 2004 )
2658 inR.setRevision( modifiedCalendar ); 2658 inR.setRevision( modifiedCalendar );
2659 } 2659 }
@@ -2737,24 +2737,25 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2737 inL.removeID(mCurrentSyncDevice ); 2737 inL.removeID(mCurrentSyncDevice );
2738 ++addedAddresseeR; 2738 ++addedAddresseeR;
2739 inL.setRevision( modifiedCalendar ); 2739 inL.setRevision( modifiedCalendar );
2740 local->insertAddressee( inL, false ); 2740 local->insertAddressee( inL, false );
2741 inR = inL; 2741 inR = inL;
2742 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2742 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2743 inR.setResource( 0 ); 2743 inR.setResource( 0 );
2744 remote->insertAddressee( inR, false ); 2744 remote->insertAddressee( inR, false );
2745 } 2745 }
2746 } 2746 }
2747 } else { 2747 } else {
2748 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2748 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2749 //qDebug("data %s ", inL.revision().toString().latin1());
2749 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2750 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2750 local->removeAddressee( inL ); 2751 local->removeAddressee( inL );
2751 ++deletedAddresseeL; 2752 ++deletedAddresseeL;
2752 } else { 2753 } else {
2753 if ( ! syncManager->mWriteBackExistingOnly ) { 2754 if ( ! syncManager->mWriteBackExistingOnly ) {
2754 ++addedAddresseeR; 2755 ++addedAddresseeR;
2755 inL.setRevision( modifiedCalendar ); 2756 inL.setRevision( modifiedCalendar );
2756 local->insertAddressee( inL, false ); 2757 local->insertAddressee( inL, false );
2757 inR = inL; 2758 inR = inL;
2758 inR.setIDStr( ":" ); 2759 inR.setIDStr( ":" );
2759 inR.setResource( 0 ); 2760 inR.setResource( 0 );
2760 remote->insertAddressee( inR, false ); 2761 remote->insertAddressee( inR, false );