summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
authorzautrix <zautrix>2004-09-21 07:05:01 (UTC)
committer zautrix <zautrix>2004-09-21 07:05:01 (UTC)
commit434ddaa08e0a650422ef271332a1d11879028095 (patch) (unidiff)
treee4f229120d8bfa9febb7ab123b1311329f0e6aa4 /kabc/addressbook.cpp
parented49c55dac215ac2ed9286ebfc36e5a19417f0bb (diff)
downloadkdepimpi-434ddaa08e0a650422ef271332a1d11879028095.zip
kdepimpi-434ddaa08e0a650422ef271332a1d11879028095.tar.gz
kdepimpi-434ddaa08e0a650422ef271332a1d11879028095.tar.bz2
DTM sync fixes
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index adb451f..5fb49eb 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -208,67 +208,65 @@ bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
208{ 208{
209 return ( d->mIt == it.d->mIt ); 209 return ( d->mIt == it.d->mIt );
210} 210}
211 211
212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
213{ 213{
214 return ( d->mIt != it.d->mIt ); 214 return ( d->mIt != it.d->mIt );
215} 215}
216 216
217 217
218AddressBook::AddressBook() 218AddressBook::AddressBook()
219{ 219{
220 init(0, "contact"); 220 init(0, "contact");
221} 221}
222 222
223AddressBook::AddressBook( const QString &config ) 223AddressBook::AddressBook( const QString &config )
224{ 224{
225 init(config, "contact"); 225 init(config, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config, const QString &family ) 228AddressBook::AddressBook( const QString &config, const QString &family )
229{ 229{
230 init(config, family); 230 init(config, family);
231 231
232} 232}
233 233
234// the default family is "contact" 234// the default family is "contact"
235void AddressBook::init(const QString &config, const QString &family ) 235void 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 ");
241 if (config != 0) { 240 if (config != 0) {
242 qDebug("config != 0 ");
243 if ( family == "syncContact" ) { 241 if ( family == "syncContact" ) {
244 qDebug("creating sync config "); 242 qDebug("creating sync config ");
245 fami = "contact"; 243 fami = "contact";
246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 244 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
247 con->setGroup( "General" ); 245 con->setGroup( "General" );
248 con->writeEntry( "ResourceKeys", QString("sync") ); 246 con->writeEntry( "ResourceKeys", QString("sync") );
249 con->writeEntry( "Standard", QString("sync") ); 247 con->writeEntry( "Standard", QString("sync") );
250 con->setGroup( "Resource_sync" ); 248 con->setGroup( "Resource_sync" );
251 con->writeEntry( "FileName", config ); 249 con->writeEntry( "FileName", config );
252 con->writeEntry( "FileFormat", QString("vcard") ); 250 con->writeEntry( "FileFormat", QString("vcard") );
253 con->writeEntry( "ResourceIdentifier", QString("sync") ); 251 con->writeEntry( "ResourceIdentifier", QString("sync") );
254 con->writeEntry( "ResourceName", QString("sync_res") ); 252 con->writeEntry( "ResourceName", QString("sync_res") );
255 if ( config.right(4) == ".xml" ) 253 if ( config.right(4) == ".xml" )
256 con->writeEntry( "ResourceType", QString("qtopia") ); 254 con->writeEntry( "ResourceType", QString("qtopia") );
257 else if ( config == "sharp" ) { 255 else if ( config == "sharp" ) {
258 con->writeEntry( "ResourceType", QString("sharp") ); 256 con->writeEntry( "ResourceType", QString("sharp") );
259 } else { 257 } else {
260 con->writeEntry( "ResourceType", QString("file") ); 258 con->writeEntry( "ResourceType", QString("file") );
261 } 259 }
262 //con->sync(); 260 //con->sync();
263 d->mConfig = con; 261 d->mConfig = con;
264 } 262 }
265 else 263 else
266 d->mConfig = new KConfig( locateLocal("config", config) ); 264 d->mConfig = new KConfig( locateLocal("config", config) );
267// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 265// qDebug("AddressBook::init 1 config=%s",config.latin1() );
268 } 266 }
269 else { 267 else {
270 d->mConfig = 0; 268 d->mConfig = 0;
271// qDebug("AddressBook::init 1 config=0"); 269// qDebug("AddressBook::init 1 config=0");
272 } 270 }
273 271
274//US d->mErrorHandler = 0; 272//US d->mErrorHandler = 0;
@@ -577,78 +575,78 @@ void AddressBook::removeSyncAddressees( bool removeDeleted )
577 deleteRemovedAddressees(); 575 deleteRemovedAddressees();
578} 576}
579 577
580void AddressBook::removeAddressee( const Iterator &it ) 578void AddressBook::removeAddressee( const Iterator &it )
581{ 579{
582 d->mRemovedAddressees.append( (*it) ); 580 d->mRemovedAddressees.append( (*it) );
583 d->mAddressees.remove( it.d->mIt ); 581 d->mAddressees.remove( it.d->mIt );
584} 582}
585 583
586AddressBook::Iterator AddressBook::find( const Addressee &a ) 584AddressBook::Iterator AddressBook::find( const Addressee &a )
587{ 585{
588 Iterator it; 586 Iterator it;
589 for ( it = begin(); it != end(); ++it ) { 587 for ( it = begin(); it != end(); ++it ) {
590 if ( a.uid() == (*it).uid() ) { 588 if ( a.uid() == (*it).uid() ) {
591 return it; 589 return it;
592 } 590 }
593 } 591 }
594 return end(); 592 return end();
595} 593}
596 594
597Addressee AddressBook::findByUid( const QString &uid ) 595Addressee AddressBook::findByUid( const QString &uid )
598{ 596{
599 Iterator it; 597 Iterator it;
600 for ( it = begin(); it != end(); ++it ) { 598 for ( it = begin(); it != end(); ++it ) {
601 if ( uid == (*it).uid() ) { 599 if ( uid == (*it).uid() ) {
602 return *it; 600 return *it;
603 } 601 }
604 } 602 }
605 return Addressee(); 603 return Addressee();
606} 604}
607void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 605void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
608{ 606{
609 qDebug("AddressBook::preExternSync "); 607 //qDebug("AddressBook::preExternSync ");
610 AddressBook::Iterator it; 608 AddressBook::Iterator it;
611 for ( it = begin(); it != end(); ++it ) { 609 for ( it = begin(); it != end(); ++it ) {
612 (*it).setID( csd, (*it).externalUID() ); 610 (*it).setID( csd, (*it).externalUID() );
613 (*it).computeCsum( csd ); 611 (*it).computeCsum( csd );
614 } 612 }
615 mergeAB( aBook ,csd ); 613 mergeAB( aBook ,csd );
616} 614}
617void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 615void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
618{ 616{
619 qDebug("AddressBook::postExternSync "); 617 //qDebug("AddressBook::postExternSync ");
620 AddressBook::Iterator it; 618 AddressBook::Iterator it;
621 for ( it = begin(); it != end(); ++it ) { 619 for ( it = begin(); it != end(); ++it ) {
622 qDebug("check uid %s ", (*it).uid().latin1() ); 620 // qDebug("check uid %s ", (*it).uid().latin1() );
623 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 621 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
624 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 622 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
625 Addressee ad = aBook->findByUid( ( (*it).uid() )); 623 Addressee ad = aBook->findByUid( ( (*it).uid() ));
626 if ( ad.isEmpty() ) { 624 if ( ad.isEmpty() ) {
627 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 625 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
628 } else { 626 } else {
629 (*it).computeCsum( csd ); 627 (*it).computeCsum( csd );
630 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 628 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
631 ad.setID( csd, (*it).externalUID() ); 629 ad.setID( csd, (*it).externalUID() );
632 ad.setCsum( csd, (*it).getCsum( csd ) ); 630 ad.setCsum( csd, (*it).getCsum( csd ) );
633 aBook->insertAddressee( ad ); 631 aBook->insertAddressee( ad );
634 } 632 }
635 } 633 }
636 } 634 }
637} 635}
638 636
639bool AddressBook::containsExternalUid( const QString& uid ) 637bool AddressBook::containsExternalUid( const QString& uid )
640{ 638{
641 Iterator it; 639 Iterator it;
642 for ( it = begin(); it != end(); ++it ) { 640 for ( it = begin(); it != end(); ++it ) {
643 if ( uid == (*it).externalUID( ) ) 641 if ( uid == (*it).externalUID( ) )
644 return true; 642 return true;
645 } 643 }
646 return false; 644 return false;
647} 645}
648Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 646Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
649{ 647{
650 Iterator it; 648 Iterator it;
651 for ( it = begin(); it != end(); ++it ) { 649 for ( it = begin(); it != end(); ++it ) {
652 if ( uid == (*it).getID( profile ) ) 650 if ( uid == (*it).getID( profile ) )
653 return (*it); 651 return (*it);
654 } 652 }