author | zautrix <zautrix> | 2004-09-19 11:32:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 11:32:40 (UTC) |
commit | eea0ff04703dffdbe8b67a0dc9f592597d7450c1 (patch) (unidiff) | |
tree | 874549d9c1c6239304fe1540d1b56269652954c0 /kabc/addressbook.cpp | |
parent | 953277a85e6ec5630ab0d64b4d68815e4e4f9906 (diff) | |
download | kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.zip kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.gz kdepimpi-eea0ff04703dffdbe8b67a0dc9f592597d7450c1.tar.bz2 |
more AB sync
-rw-r--r-- | kabc/addressbook.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 46a9cf4..64832f1 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -235,37 +235,40 @@ AddressBook::AddressBook( const QString &config, const QString &family ) | |||
235 | void AddressBook::init(const QString &config, const QString &family ) | 235 | void AddressBook::init(const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | blockLSEchange = false; | 237 | blockLSEchange = false; |
238 | d = new AddressBookData; | 238 | d = new AddressBookData; |
239 | QString fami = family; | 239 | QString fami = family; |
240 | qDebug("new ab "); | 240 | qDebug("new ab "); |
241 | if (config != 0) { | 241 | if (config != 0) { |
242 | qDebug("config != 0 "); | 242 | qDebug("config != 0 "); |
243 | if ( family == "syncContact" ) { | 243 | if ( family == "syncContact" ) { |
244 | qDebug("creating sync config "); | 244 | qDebug("creating sync config "); |
245 | fami = "contact"; | 245 | fami = "contact"; |
246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
247 | con->setGroup( "General" ); | 247 | con->setGroup( "General" ); |
248 | con->writeEntry( "ResourceKeys", QString("sync") ); | 248 | con->writeEntry( "ResourceKeys", QString("sync") ); |
249 | con->writeEntry( "Standard", QString("sync") ); | 249 | con->writeEntry( "Standard", QString("sync") ); |
250 | con->setGroup( "Resource_sync" ); | 250 | con->setGroup( "Resource_sync" ); |
251 | con->writeEntry( "FileFormat", QString("vcard") ); | ||
252 | con->writeEntry( "FileName", config ); | 251 | con->writeEntry( "FileName", config ); |
252 | con->writeEntry( "FileFormat", QString("vcard") ); | ||
253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
254 | con->writeEntry( "ResourceName", QString("sync_res") ); | 254 | con->writeEntry( "ResourceName", QString("sync_res") ); |
255 | con->writeEntry( "ResourceType", QString("file") ); | 255 | if ( config.right(4) == ".xml" ) |
256 | con->writeEntry( "ResourceType", QString("qtopia") ); | ||
257 | else | ||
258 | con->writeEntry( "ResourceType", QString("file") ); | ||
256 | //con->sync(); | 259 | //con->sync(); |
257 | d->mConfig = con; | 260 | d->mConfig = con; |
258 | } | 261 | } |
259 | else | 262 | else |
260 | d->mConfig = new KConfig( locateLocal("config", config) ); | 263 | d->mConfig = new KConfig( locateLocal("config", config) ); |
261 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 264 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
262 | } | 265 | } |
263 | else { | 266 | else { |
264 | d->mConfig = 0; | 267 | d->mConfig = 0; |
265 | // qDebug("AddressBook::init 1 config=0"); | 268 | // qDebug("AddressBook::init 1 config=0"); |
266 | } | 269 | } |
267 | 270 | ||
268 | //US d->mErrorHandler = 0; | 271 | //US d->mErrorHandler = 0; |
269 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 272 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
270 | d->mManager->readConfig( d->mConfig ); | 273 | d->mManager->readConfig( d->mConfig ); |
271 | if ( family == "syncContact" ) { | 274 | if ( family == "syncContact" ) { |
@@ -586,32 +589,53 @@ AddressBook::Iterator AddressBook::find( const Addressee &a ) | |||
586 | return it; | 589 | return it; |
587 | } | 590 | } |
588 | } | 591 | } |
589 | return end(); | 592 | return end(); |
590 | } | 593 | } |
591 | 594 | ||
592 | Addressee AddressBook::findByUid( const QString &uid ) | 595 | Addressee AddressBook::findByUid( const QString &uid ) |
593 | { | 596 | { |
594 | Iterator it; | 597 | Iterator it; |
595 | for ( it = begin(); it != end(); ++it ) { | 598 | for ( it = begin(); it != end(); ++it ) { |
596 | if ( uid == (*it).uid() ) { | 599 | if ( uid == (*it).uid() ) { |
597 | return *it; | 600 | return *it; |
598 | } | 601 | } |
599 | } | 602 | } |
600 | return Addressee(); | 603 | return Addressee(); |
601 | } | 604 | } |
605 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | ||
606 | { | ||
607 | Iterator it; | ||
608 | for ( it = begin(); it != end(); ++it ) { | ||
609 | if ( uid == (*it).getID( profile ) ) | ||
610 | return (*it); | ||
611 | } | ||
612 | return Addressee(); | ||
613 | } | ||
614 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | ||
615 | { | ||
616 | Iterator it; | ||
617 | Addressee ad; | ||
618 | for ( it = begin(); it != end(); ++it ) { | ||
619 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | ||
620 | if ( !ad.isEmpty() ) { | ||
621 | (*it).mergeContact( ad ); | ||
622 | } | ||
623 | } | ||
624 | } | ||
625 | |||
602 | #if 0 | 626 | #if 0 |
603 | Addressee::List AddressBook::getExternLastSyncAddressees() | 627 | Addressee::List AddressBook::getExternLastSyncAddressees() |
604 | { | 628 | { |
605 | Addressee::List results; | 629 | Addressee::List results; |
606 | 630 | ||
607 | Iterator it; | 631 | Iterator it; |
608 | for ( it = begin(); it != end(); ++it ) { | 632 | for ( it = begin(); it != end(); ++it ) { |
609 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 633 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
610 | if ( (*it).familyName().left(4) == "!E: " ) | 634 | if ( (*it).familyName().left(4) == "!E: " ) |
611 | results.append( *it ); | 635 | results.append( *it ); |
612 | } | 636 | } |
613 | } | 637 | } |
614 | 638 | ||
615 | return results; | 639 | return results; |
616 | } | 640 | } |
617 | #endif | 641 | #endif |