summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp32
-rw-r--r--kabc/addressbook.h3
2 files changed, 35 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()
{
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index f40e015..157dc56 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -274,48 +274,51 @@ class AddressBook : public QObject
/**
Set the @p ErrorHandler, that is used by @ref error() to
provide gui-independend error messages.
*/
void setErrorHandler( ErrorHandler * );
/**
Shows gui independend error messages.
*/
void error( const QString& );
/**
Query all resources to clean up their lock files
*/
void cleanUp();
// sync stuff
//Addressee::List getExternLastSyncAddressees();
void resetTempSyncStat();
QStringList uidList();
void removeDeletedAddressees();
void mergeAB( AddressBook *aBook, const QString& profile );
Addressee findByExternUid( const QString& uid , const QString& profile );
+
+ void preExternSync( AddressBook* aBook, const QString& csd );
+ void postExternSync( AddressBook* aBook, const QString& csd );
signals:
/**
Emitted, when the address book has changed on disk.
*/
void addressBookChanged( AddressBook * );
/**
Emitted, when the address book has been locked for writing.
*/
void addressBookLocked( AddressBook * );
/**
Emitted, when the address book has been unlocked.
*/
void addressBookUnlocked( AddressBook * );
protected:
void deleteRemovedAddressees();
void setStandardResource( Resource * );
Resource *standardResource();
KRES::Manager<Resource> *resourceManager();
void init(const QString &config, const QString &family);