summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-09-18 22:33:39 (UTC)
committer zautrix <zautrix>2004-09-18 22:33:39 (UTC)
commitf370d0f89bcaeeb68bd60152a9812a9cd55e5d8a (patch) (side-by-side diff)
treec1a9de8b305200a7cec885764a0afb4beb92dabb /kaddressbook
parent28f894fd2a0dfbd5f09f9e530f359981efe0198c (diff)
downloadkdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.zip
kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.tar.gz
kdepimpi-f370d0f89bcaeeb68bd60152a9812a9cd55e5d8a.tar.bz2
more AB sync
Diffstat (limited to 'kaddressbook') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index cc8eb52..8776b53 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2666,14 +2666,14 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
Addressee addresseeR;
QString uid;
int take;
Addressee addresseeL;
Addressee addresseeRSync;
Addressee addresseeLSync;
- KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
- KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
+ // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
+ //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
bool fullDateRange = false;
local->resetTempSyncStat();
mLastAddressbookSync = QDateTime::currentDateTime();
QDateTime modifiedCalendar = mLastAddressbookSync;;
addresseeLSync = getLastSyncAddressee();
qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
@@ -2706,13 +2706,13 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
// qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
//qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
fullDateRange = true;
qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
}
}
- fullDateRange = true; // debug only!
+ // fullDateRange = true; // debug only!
if ( fullDateRange )
mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
else
mLastAddressbookSync = addresseeLSync.revision();
// for resyncing if own file has changed
// PENDING fixme later when implemented
@@ -2915,21 +2915,49 @@ bool KABCore::syncAB(QString filename, int mode)
//pending detect, if remote file has REV field. if not switch to external sync
mGlobalSyncMode = SYNC_MODE_NORMAL;
AddressBook abLocal(filename,"syncContact");
bool syncOK = false;
if ( abLocal.load() ) {
qDebug("AB loaded %s mode %d",filename.latin1(), mode );
+ bool external = false;
+ Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
+ if ( ! lse.isEmpty() ) {
+ if ( lse.familyName().left(4) == "!E: " )
+ 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 ) {
+ found = true;
+ break;
+ }
+ }
+ external = ! found;
+ }
+
+ if ( external ) {
+ mGlobalSyncMode = SYNC_MODE_EXTERNAL;
+ AddressBook::Iterator it;
+ for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
+ (*it).setID( mCurrentSyncDevice, (*it).uid() );
+ (*it).computeCsum( mCurrentSyncDevice );
+ }
+ }
+ //AddressBook::Iterator it;
//QStringList vcards;
//for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
// qDebug("Name %s ", (*it).familyName().latin1());
//}
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
if ( syncOK ) {
if ( KABPrefs::instance()->mWriteBackFile )
{
+ if ( external )
+ abLocal.removeDeletedAddressees();
qDebug("saving remote AB ");
abLocal.saveAB();
}
}
setModified();