summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Side-by-side diff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 64832f1..86dc7c2 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -581,48 +581,80 @@ void AddressBook::removeAddressee( const Iterator &it )
d->mAddressees.remove( it.d->mIt );
}
AddressBook::Iterator AddressBook::find( const Addressee &a )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( a.uid() == (*it).uid() ) {
return it;
}
}
return end();
}
Addressee AddressBook::findByUid( const QString &uid )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( uid == (*it).uid() ) {
return *it;
}
}
return Addressee();
}
+void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
+{
+ qDebug("AddressBook::preExternSync ");
+ AddressBook::Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ (*it).setID( csd, (*it).externalUID() );
+ (*it).computeCsum( csd );
+ }
+ mergeAB( aBook ,csd );
+}
+void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
+{
+ qDebug("AddressBook::postExternSync ");
+ AddressBook::Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
+ (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
+ Addressee ad = aBook->findByUid( ( (*it).uid() ));
+ if ( ad.isEmpty() ) {
+ qDebug("ERROR ad empty ");
+ } else {
+ (*it).computeCsum( csd );
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
+ ad.setID( csd, (*it).externalUID() );
+ ad.setCsum( csd, (*it).getCsum( csd ) );
+ aBook->insertAddressee( ad );
+ }
+ }
+ }
+}
+
+
Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( uid == (*it).getID( profile ) )
return (*it);
}
return Addressee();
}
void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
{
Iterator it;
Addressee ad;
for ( it = begin(); it != end(); ++it ) {
ad = aBook->findByExternUid( (*it).externalUID(), profile );
if ( !ad.isEmpty() ) {
(*it).mergeContact( ad );
}
}
}
#if 0
Addressee::List AddressBook::getExternLastSyncAddressees()
{