summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 8776b53..56f6af2 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2517,25 +2517,25 @@ QString KABCore::getPassword( )
}
#include <libkcal/syncdefines.h>
KABC::Addressee KABCore::getLastSyncAddressee()
{
Addressee lse;
//qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
if (lse.isEmpty()) {
qDebug("Creating new last-syncAddressee ");
lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
QString sum = "";
- if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
+ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
sum = "E: ";
lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
lse.setRevision( mLastAddressbookSync );
lse.setCategories( i18n("SyncEvent") );
mAddressBook->insertAddressee( lse );
}
return lse;
}
int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
{
//void setZaurusId(int id);
@@ -2543,33 +2543,35 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
// void setZaurusUid(int id);
// int zaurusUid() const;
// void setZaurusStat(int id);
// int zaurusStat() const;
// 0 equal
// 1 take local
// 2 take remote
// 3 cancel
QDateTime lastSync = mLastAddressbookSync;
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
bool remCh, locCh;
remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
- //if ( remCh )
- //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
+ if ( remCh )
+ qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
locCh = ( local->revision() > mLastAddressbookSync );
if ( !remCh && ! locCh ) {
- //qDebug("both not changed ");
+ qDebug("both not changed ");
lastSync = local->revision().addDays(1);
+ if ( mode <= SYNC_PREF_ASK )
+ return 0;
} else {
if ( locCh ) {
- //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1());
+ qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1());
lastSync = local->revision().addDays( -1 );
if ( !remCh )
remote->setRevision( lastSync.addDays( -1 ) );
} else {
//qDebug(" not loc changed ");
lastSync = local->revision().addDays( 1 );
if ( remCh )
remote->setRevision( lastSync.addDays( 1 ) );
}
}
full = true;
@@ -2781,27 +2783,27 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
idS = inL.IDStr();
local->removeAddressee( inL );
inL = inR;
inL.setIDStr( idS );
inL.setResource( 0 );
local->insertAddressee( inL , false );
++changedLocal;
}
}
} else { // no conflict
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
QString des = addresseeLSync.note();
- QString pref = "a";
- if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
+ if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
+ remote->insertAddressee( inR, false );
++deletedAddresseeR;
} else {
inR.setRevision( modifiedCalendar );
remote->insertAddressee( inR, false );
inL = inR;
inL.setResource( 0 );
local->insertAddressee( inL , false);
++addedAddressee;
}
} else {
if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
inR.setRevision( modifiedCalendar );
@@ -2811,57 +2813,53 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
++addedAddressee;
} else {
// pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
remote->removeAddressee( inR );
++deletedAddresseeR;
}
}
}
}
++incCounter;
}
er.clear();
- QStringList el = remote->uidList();
+ QStringList el = local->uidList();
modulo = (el.count()/10)+1;
bar.setCaption (i18n("Add / remove addressees") );
bar.setTotalSteps ( el.count() ) ;
bar.show();
incCounter = 0;
while ( incCounter < el.count()) {
-
qApp->processEvents();
if ( ! bar.isVisible() )
return false;
if ( incCounter % modulo == 0 )
bar.setProgress( incCounter );
uid = el[ incCounter ];
bool skipIncidence = false;
if ( uid.left(19) == QString("last-syncAddressee-") )
skipIncidence = true;
- if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
- skipIncidence = true;
if ( !skipIncidence ) {
inL = local->findByUid( uid );
inR = remote->findByUid( uid );
if ( inR.isEmpty() ) {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
// pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
local->removeAddressee( inL );
++deletedAddresseeL;
} else {
if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
inL.removeID(mCurrentSyncDevice );
- ++addedAddresseeR;
- //qDebug("remote added Incidence %s ", inL.summary().latin1());
+ ++addedAddresseeR;
inL.setRevision( modifiedCalendar );
local->insertAddressee( inL, false );
inR = inL;
inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
inR.setResource( 0 );
remote->insertAddressee( inR, false );
}
}
} else {
if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
// pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
local->removeAddressee( inL );
@@ -2886,24 +2884,26 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
// get rid of micro seconds
QTime t = mLastAddressbookSync.time();
mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
addresseeLSync.setRevision( mLastAddressbookSync );
addresseeRSync.setRevision( mLastAddressbookSync );
addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
+ addresseeRSync.setNote( "" ) ;
+ addresseeLSync.setNote( "" );
if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
remote->insertAddressee( addresseeRSync, false );
local->insertAddressee( addresseeLSync, false );
QString mes;
mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
if ( KABPrefs::instance()->mShowSyncSummary ) {
KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
}
qDebug( mes );
return syncOK;
}
@@ -2928,24 +2928,25 @@ bool KABCore::syncAB(QString filename, int mode)
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 ) {
+ qDebug("**********Setting vcf mode to 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());
//}