summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
authorzautrix <zautrix>2004-09-19 09:00:55 (UTC)
committer zautrix <zautrix>2004-09-19 09:00:55 (UTC)
commit787181d34f0d195ad72c9cf6aedbc317b6dd713e (patch) (side-by-side diff)
treeac49d2b1d7887f96f3834458071b89e77b59218b /kabc/addressbook.cpp
parentf370d0f89bcaeeb68bd60152a9812a9cd55e5d8a (diff)
downloadkdepimpi-787181d34f0d195ad72c9cf6aedbc317b6dd713e.zip
kdepimpi-787181d34f0d195ad72c9cf6aedbc317b6dd713e.tar.gz
kdepimpi-787181d34f0d195ad72c9cf6aedbc317b6dd713e.tar.bz2
more AB sync
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index ec9f893..46a9cf4 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -343,9 +343,14 @@ bool AddressBook::load()
// mark all addressees as unchanged
Addressee::List::Iterator addrIt;
- for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt )
+ for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
(*addrIt).setChanged( false );
-
+ QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
+ if ( !id.isEmpty() ) {
+ //qDebug("setId aa %s ", id.latin1());
+ (*addrIt).setIDStr(id );
+ }
+ }
blockLSEchange = true;
return ok;
}
@@ -366,7 +371,12 @@ bool AddressBook::saveAB()
bool ok = true;
deleteRemovedAddressees();
-
+ Iterator ait;
+ for ( ait = begin(); ait != end(); ++ait ) {
+ if ( !(*ait).IDStr().isEmpty() ) {
+ (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
+ }
+ }
KRES::Manager<Resource>::ActiveIterator it;
KRES::Manager<Resource> *manager = d->mManager;
for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
@@ -450,8 +460,10 @@ Ticket *AddressBook::requestSaveTicket( Resource *resource )
void AddressBook::insertAddressee( const Addressee &a, bool setRev )
{
if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
+ //qDebug("block insert ");
return;
}
+ //qDebug("inserting.... %s ",a.uid().latin1() );
bool found = false;
Addressee::List::Iterator it;
for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
@@ -480,7 +492,7 @@ void AddressBook::insertAddressee( const Addressee &a, bool setRev )
found = true;
} else {
- if ( (*it).uid() == QString("last-syncAddressee-") ) {
+ if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
QString name = (*it).uid().mid( 19 );
Addressee b = a;
QString id = b.getID( name );
@@ -516,7 +528,7 @@ void AddressBook::removeAddressee( const Addressee &a )
found = true;
it2 = it;
} else {
- if ( (*it).uid() == QString("last-syncAddressee-") ) {
+ if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
QString name = (*it).uid().mid( 19 );
Addressee b = a;
QString id = b.getID( name );
@@ -545,12 +557,17 @@ void AddressBook::removeDeletedAddressees()
QDateTime dt ( QDate( 2004,1,1) );
while ( it != end() ) {
(*it).setRevision( dt );
- if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
+ (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
+ (*it).setIDStr("");
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
it2 = it;
+ //qDebug("removing %s ",(*it).uid().latin1() );
++it;
removeAddressee( it2 );
- } else
+ } else {
+ //qDebug("skipping %s ",(*it).uid().latin1() );
++it;
+ }
}
deleteRemovedAddressees();
}