summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
authorzautrix <zautrix>2004-09-20 00:12:42 (UTC)
committer zautrix <zautrix>2004-09-20 00:12:42 (UTC)
commitb01b669d88fa195261d29ecf73b1c69e608a5ebc (patch) (side-by-side diff)
treec0e79d45242a764b49470d07a9c95be156c121cc /kaddressbook/kabcore.cpp
parent3da2cfeab2edbe64a17251662e56668fe143f7a3 (diff)
downloadkdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.zip
kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.gz
kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.bz2
more AB sync
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp58
1 files changed, 32 insertions, 26 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 8f3ca9b..f8683e7 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2549,28 +2549,30 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
// 2 take remote
// 3 cancel
QDateTime lastSync = mLastAddressbookSync;
+ QDateTime localMod = local->revision();
+ QDateTime remoteMod = remote->revision();
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
bool remCh, locCh;
remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
- //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
- locCh = ( local->revision() > mLastAddressbookSync );
+ qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
+ locCh = ( localMod > mLastAddressbookSync );
if ( !remCh && ! locCh ) {
- //qDebug("both not changed ");
- lastSync = local->revision().addDays(1);
+ qDebug("both not changed ");
+ lastSync = localMod.addDays(1);
if ( mode <= SYNC_PREF_ASK )
return 0;
} else {
if ( locCh ) {
- //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1());
- lastSync = local->revision().addDays( -1 );
+ qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
+ lastSync = localMod.addDays( -1 );
if ( !remCh )
- remote->setRevision( lastSync.addDays( -1 ) );
+ remoteMod =( lastSync.addDays( -1 ) );
} else {
//qDebug(" not loc changed ");
- lastSync = local->revision().addDays( 1 );
+ lastSync = localMod.addDays( 1 );
if ( remCh )
- remote->setRevision( lastSync.addDays( 1 ) );
+ remoteMod =( lastSync.addDays( 1 ) );
}
}
@@ -2578,13 +2580,13 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
if ( mode < SYNC_PREF_ASK )
mode = SYNC_PREF_ASK;
} else {
- if ( local->revision() == remote->revision() )
+ if ( localMod == remoteMod )
return 0;
}
// qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
- //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
+ //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
//qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
//full = true; //debug only
if ( full ) {
@@ -2609,32 +2611,32 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
switch( mode ) {
case SYNC_PREF_LOCAL:
- if ( lastSync > remote->revision() )
+ if ( lastSync > remoteMod )
return 1;
- if ( lastSync > local->revision() )
+ if ( lastSync > localMod )
return 2;
return 1;
break;
case SYNC_PREF_REMOTE:
- if ( lastSync > remote->revision() )
+ if ( lastSync > remoteMod )
return 1;
- if ( lastSync > local->revision() )
+ if ( lastSync > localMod )
return 2;
return 2;
break;
case SYNC_PREF_NEWEST:
- if ( local->revision() > remote->revision() )
+ if ( localMod > remoteMod )
return 1;
else
return 2;
break;
case SYNC_PREF_ASK:
- //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() );
- if ( lastSync > remote->revision() )
+ //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
+ if ( lastSync > remoteMod )
return 1;
- if ( lastSync > local->revision() )
+ if ( lastSync > localMod )
return 2;
- localIsNew = local->revision() >= remote->revision();
+ localIsNew = localMod >= remoteMod;
//qDebug("conflict! ************************************** ");
{
KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
@@ -2786,6 +2788,10 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
remote->insertAddressee( inR , false);
++changedRemote;
} else { // take == 2 take remote
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
+ if ( inR.revision().date().year() < 2004 )
+ inR.setRevision( modifiedCalendar );
+ }
idS = inL.IDStr();
local->removeAddressee( inL );
inL = inR;
@@ -2925,9 +2931,10 @@ bool KABCore::syncAB(QString filename, int mode)
if ( abLocal.load() ) {
qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
bool external = false;
-
+ bool isXML = false;
if ( filename.right(4) == ".xml") {
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
+ isXML = true;
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
} else {
Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
@@ -2936,10 +2943,9 @@ bool KABCore::syncAB(QString filename, int mode)
external = true;
} else {
bool found = false;
- QDateTime dt( QDate( 2004,1,1));
AddressBook::Iterator it;
for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
- if ( (*it).revision() != dt ) {
+ if ( (*it).revision().date().year() > 2003 ) {
found = true;
break;
}
@@ -2966,11 +2972,11 @@ bool KABCore::syncAB(QString filename, int mode)
if ( syncOK ) {
if ( KABPrefs::instance()->mWriteBackFile )
{
- if ( external && filename.right(4) != ".xml")
- abLocal.removeDeletedAddressees();
+ if ( external )
+ abLocal.removeSyncAddressees( !isXML);
qDebug("Saving remote AB ");
abLocal.saveAB();
- if ( external && filename.right(4) == ".xml") {
+ if ( isXML ) {
// afterwrite processing
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
}