summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (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
@@ -2669,8 +2669,8 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
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();
@@ -2709,7 +2709,7 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
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
@@ -2918,7 +2918,33 @@ bool KABCore::syncAB(QString filename, int mode)
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());
@@ -2927,6 +2953,8 @@ bool KABCore::syncAB(QString filename, int mode)
if ( syncOK ) {
if ( KABPrefs::instance()->mWriteBackFile )
{
+ if ( external )
+ abLocal.removeDeletedAddressees();
qDebug("saving remote AB ");
abLocal.saveAB();
}