addressbook.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qfile.h>
00022 #include <qregexp.h>
00023 #include <qtimer.h>
00024
00025 #include <kapplication.h>
00026 #include <kdebug.h>
00027 #include <kglobal.h>
00028 #include <kinstance.h>
00029 #include <klocale.h>
00030 #include <kstandarddirs.h>
00031
00032 #include "errorhandler.h"
00033 #include "resource.h"
00034
00035 #include "addressbook.h"
00036 #include "addressbook.moc"
00037
00038 using namespace KABC;
00039
00040 struct AddressBook::AddressBookData
00041 {
00042 Field::List mAllFields;
00043 ErrorHandler *mErrorHandler;
00044 KConfig *mConfig;
00045 KRES::Manager<Resource> *mManager;
00046 QPtrList<Resource> mPendingLoadResources;
00047 QPtrList<Resource> mPendingSaveResources;
00048 Iterator end;
00049 };
00050
00051 struct AddressBook::Iterator::IteratorData
00052 {
00053 Resource::Iterator mIt;
00054 QValueList<Resource*> mResources;
00055 int mCurrRes;
00056 };
00057
00058 struct AddressBook::ConstIterator::ConstIteratorData
00059 {
00060 Resource::ConstIterator mIt;
00061 QValueList<Resource*> mResources;
00062 int mCurrRes;
00063 };
00064
00065 AddressBook::Iterator::Iterator()
00066 {
00067 d = new IteratorData;
00068 }
00069
00070 AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
00071 {
00072 d = new IteratorData;
00073 d->mIt = i.d->mIt;
00074 d->mResources = i.d->mResources;
00075 d->mCurrRes = i.d->mCurrRes;
00076 }
00077
00078 AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
00079 {
00080 if( this == &i ) return *this;
00081 delete d;
00082 d = new IteratorData;
00083 d->mIt = i.d->mIt;
00084 d->mResources = i.d->mResources;
00085 d->mCurrRes = i.d->mCurrRes;
00086 return *this;
00087 }
00088
00089 AddressBook::Iterator::~Iterator()
00090 {
00091 delete d;
00092 }
00093
00094 const Addressee &AddressBook::Iterator::operator*() const
00095 {
00096 return *(d->mIt);
00097 }
00098
00099 Addressee &AddressBook::Iterator::operator*()
00100 {
00101 return *(d->mIt);
00102 }
00103
00104 Addressee *AddressBook::Iterator::operator->()
00105 {
00106 return &(*(d->mIt));
00107 }
00108
00109 AddressBook::Iterator &AddressBook::Iterator::operator++()
00110 {
00111 do {
00112 bool jumped = false;
00113 while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) {
00114 if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) {
00115 return *this;
00116 }
00117
00118 d->mCurrRes++;
00119
00120 jumped = true;
00121 d->mIt = (d->mResources[ d->mCurrRes ])->begin();
00122 }
00123
00124 if ( !jumped )
00125 (d->mIt)++;
00126
00127 } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() );
00128
00129 return *this;
00130 }
00131
00132 AddressBook::Iterator &AddressBook::Iterator::operator++( int )
00133 {
00134 do {
00135 bool jumped = false;
00136 while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) {
00137 if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) {
00138 return *this;
00139 }
00140
00141 d->mCurrRes++;
00142
00143 jumped = true;
00144 d->mIt = (d->mResources[ d->mCurrRes ])->begin();
00145 }
00146
00147 if ( !jumped )
00148 (d->mIt)++;
00149
00150 } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() );
00151
00152 return *this;
00153 }
00154
00155 AddressBook::Iterator &AddressBook::Iterator::operator--()
00156 {
00157 (d->mIt)--;
00158
00159 return *this;
00160 }
00161
00162 AddressBook::Iterator &AddressBook::Iterator::operator--( int )
00163 {
00164 (d->mIt)--;
00165
00166 return *this;
00167 }
00168
00169 bool AddressBook::Iterator::operator==( const Iterator &it )
00170 {
00171 return ( d->mIt == it.d->mIt );
00172 }
00173
00174 bool AddressBook::Iterator::operator!=( const Iterator &it )
00175 {
00176 return ( d->mIt != it.d->mIt );
00177 }
00178
00179
00180 AddressBook::ConstIterator::ConstIterator()
00181 {
00182 d = new ConstIteratorData;
00183 }
00184
00185 AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
00186 {
00187 d = new ConstIteratorData;
00188 d->mIt = i.d->mIt;
00189 d->mResources = i.d->mResources;
00190 d->mCurrRes = i.d->mCurrRes;
00191 }
00192
00193 AddressBook::ConstIterator::ConstIterator( const AddressBook::Iterator &i )
00194 {
00195 d = new ConstIteratorData;
00196 d->mIt = i.d->mIt;
00197 d->mResources = i.d->mResources;
00198 d->mCurrRes = i.d->mCurrRes;
00199 }
00200
00201 AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
00202 {
00203 if( this == &i ) return *this;
00204 delete d;
00205 d = new ConstIteratorData;
00206 d->mIt = i.d->mIt;
00207 d->mResources = i.d->mResources;
00208 d->mCurrRes = i.d->mCurrRes;
00209 return *this;
00210 }
00211
00212 AddressBook::ConstIterator::~ConstIterator()
00213 {
00214 delete d;
00215 }
00216
00217 const Addressee &AddressBook::ConstIterator::operator*() const
00218 {
00219 return *(d->mIt);
00220 }
00221
00222 const Addressee* AddressBook::ConstIterator::operator->() const
00223 {
00224 return &(*(d->mIt));
00225 }
00226
00227 AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
00228 {
00229 do {
00230 bool jumped = false;
00231 while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) {
00232 if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) {
00233 return *this;
00234 }
00235
00236 d->mCurrRes++;
00237
00238 jumped = true;
00239 d->mIt = (d->mResources[ d->mCurrRes ])->begin();
00240 }
00241
00242 if ( !jumped )
00243 (d->mIt)++;
00244
00245 } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() );
00246
00247 return *this;
00248 }
00249
00250 AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
00251 {
00252 do {
00253 bool jumped = false;
00254 while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) {
00255 if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) {
00256 return *this;
00257 }
00258
00259 d->mCurrRes++;
00260
00261 jumped = true;
00262 d->mIt = (d->mResources[ d->mCurrRes ])->begin();
00263 }
00264
00265 if ( !jumped )
00266 (d->mIt)++;
00267
00268 } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() );
00269
00270 return *this;
00271 }
00272
00273 AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
00274 {
00275 (d->mIt)--;
00276 return *this;
00277 }
00278
00279 AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
00280 {
00281 (d->mIt)--;
00282 return *this;
00283 }
00284
00285 bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
00286 {
00287 return ( d->mIt == it.d->mIt );
00288 }
00289
00290 bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
00291 {
00292 return ( d->mIt != it.d->mIt );
00293 }
00294
00295
00296 AddressBook::AddressBook()
00297 {
00298 d = new AddressBookData;
00299 d->mErrorHandler = 0;
00300 d->mConfig = 0;
00301 d->mManager = new KRES::Manager<Resource>( "contact" );
00302 d->end.d->mResources = QValueList<Resource*>();
00303 d->end.d->mCurrRes = -1;
00304 }
00305
00306 AddressBook::AddressBook( const QString &config )
00307 {
00308 d = new AddressBookData;
00309 d->mErrorHandler = 0;
00310 if ( config.isEmpty() )
00311 d->mConfig = 0;
00312 else
00313 d->mConfig = new KConfig( config );
00314 d->mManager = new KRES::Manager<Resource>( "contact" );
00315 d->mManager->readConfig( d->mConfig );
00316 d->end.d->mResources = QValueList<Resource*>();
00317 d->end.d->mCurrRes = -1;
00318 }
00319
00320 AddressBook::~AddressBook()
00321 {
00322 delete d->mManager; d->mManager = 0;
00323 delete d->mConfig; d->mConfig = 0;
00324 delete d->mErrorHandler; d->mErrorHandler = 0;
00325 delete d; d = 0;
00326 }
00327
00328 bool AddressBook::load()
00329 {
00330 kdDebug(5700) << "AddressBook::load()" << endl;
00331
00332 clear();
00333
00334 KRES::Manager<Resource>::ActiveIterator it;
00335 bool ok = true;
00336 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
00337 if ( !(*it)->load() ) {
00338 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
00339 ok = false;
00340 }
00341 }
00342
00343 return ok;
00344 }
00345
00346 bool AddressBook::asyncLoad()
00347 {
00348 kdDebug(5700) << "AddressBook::asyncLoad()" << endl;
00349
00350 clear();
00351
00352 KRES::Manager<Resource>::ActiveIterator it;
00353 bool ok = true;
00354 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
00355 d->mPendingLoadResources.append( *it );
00356 if ( !(*it)->asyncLoad() ) {
00357 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
00358 ok = false;
00359 }
00360 }
00361
00362 return ok;
00363 }
00364
00365 bool AddressBook::save( Ticket *ticket )
00366 {
00367 kdDebug(5700) << "AddressBook::save()"<< endl;
00368
00369 if ( ticket->resource() ) {
00370 deleteRemovedAddressees();
00371 bool ok = ticket->resource()->save( ticket );
00372 if ( ok ) ticket->resource()->releaseSaveTicket( ticket );
00373 return ok;
00374 }
00375
00376 return false;
00377 }
00378
00379 bool AddressBook::asyncSave( Ticket *ticket )
00380 {
00381 kdDebug(5700) << "AddressBook::asyncSave()"<< endl;
00382
00383 if ( ticket->resource() ) {
00384 d->mPendingSaveResources.append( ticket->resource() );
00385 bool ok = ticket->resource()->asyncSave( ticket );
00386 if ( ok ) ticket->resource()->releaseSaveTicket( ticket );
00387 return ok;
00388 }
00389
00390 return false;
00391 }
00392
00393 AddressBook::Iterator AddressBook::begin()
00394 {
00395 QValueList<Resource*> list;
00396 KRES::Manager<Resource>::ActiveIterator resIt;
00397 for ( resIt = d->mManager->activeBegin(); resIt != d->mManager->activeEnd(); ++resIt )
00398 list.append( *resIt );
00399
00400 if ( list.count() == 0 )
00401 return end();
00402
00403 Iterator it = Iterator();
00404 it.d->mResources = list;
00405 it.d->mCurrRes = 0;
00406 it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin();
00407
00408 while ( it.d->mIt == (it.d->mResources[ it.d->mCurrRes ])->end() ) {
00409 if ( (uint)it.d->mCurrRes == it.d->mResources.count() - 1 )
00410 return end();
00411
00412 it.d->mCurrRes++;
00413
00414 it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin();
00415 }
00416
00417 return it;
00418 }
00419
00420 AddressBook::ConstIterator AddressBook::begin() const
00421 {
00422 QValueList<Resource*> list;
00423 KRES::Manager<Resource>::ActiveIterator resIt;
00424 for ( resIt = d->mManager->activeBegin(); resIt != d->mManager->activeEnd(); ++resIt )
00425 list.append( *resIt );
00426
00427 if ( list.count() == 0 )
00428 return end();
00429
00430 Iterator it = Iterator();
00431 it.d->mResources = list;
00432 it.d->mCurrRes = 0;
00433 it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin();
00434
00435 while ( it.d->mIt == (it.d->mResources[ it.d->mCurrRes ])->end() ) {
00436 if ( (uint)it.d->mCurrRes == it.d->mResources.count() - 1 )
00437 return end();
00438
00439 it.d->mCurrRes++;
00440
00441 it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin();
00442 }
00443
00444 return it;
00445 }
00446
00447 AddressBook::Iterator AddressBook::end()
00448 {
00449 KRES::Manager<Resource>::ActiveIterator resIt = d->mManager->activeEnd();
00450
00451 if ( resIt == d->mManager->activeBegin() || ! *(--resIt) ) {
00452 d->end.d->mIt = Resource::Iterator();
00453 } else {
00454 d->end.d->mIt = (*resIt)->end();
00455 }
00456
00457 return d->end;
00458 }
00459
00460 AddressBook::ConstIterator AddressBook::end() const
00461 {
00462 KRES::Manager<Resource>::ActiveIterator resIt = d->mManager->activeEnd();
00463
00464 if ( resIt == d->mManager->activeBegin() || ! *(--resIt) ) {
00465 d->end.d->mIt = Resource::Iterator();
00466 } else {
00467 d->end.d->mIt = (*resIt)->end();
00468 }
00469
00470 return d->end;
00471 }
00472
00473 void AddressBook::clear()
00474 {
00475 KRES::Manager<Resource>::ActiveIterator it;
00476 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
00477 (*it)->clear();
00478 }
00479
00480 Ticket *AddressBook::requestSaveTicket( Resource *resource )
00481 {
00482 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
00483
00484 if ( !resource )
00485 resource = standardResource();
00486
00487 KRES::Manager<Resource>::ActiveIterator it;
00488 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
00489 if ( (*it) == resource ) {
00490 if ( (*it)->readOnly() || !(*it)->isOpen() )
00491 return 0;
00492 else
00493 return (*it)->requestSaveTicket();
00494 }
00495 }
00496
00497 return 0;
00498 }
00499
00500 void AddressBook::releaseSaveTicket( Ticket *ticket )
00501 {
00502 if ( !ticket )
00503 return;
00504
00505 if ( ticket->resource() ) {
00506 ticket->resource()->releaseSaveTicket( ticket );
00507 }
00508 }
00509
00510 void AddressBook::insertAddressee( const Addressee &a )
00511 {
00512 Resource *resource = a.resource();
00513 if ( resource == 0 )
00514 resource = standardResource();
00515
00516 Resource::Iterator it;
00517 Addressee fAddr = resource->findByUid( a.uid() );
00518
00519 Addressee addr( a );
00520 if ( !fAddr.isEmpty() ) {
00521 if ( fAddr != a )
00522 addr.setRevision( QDateTime::currentDateTime() );
00523 else {
00524 if ( fAddr.resource() == 0 ) {
00525 fAddr.setResource( resource );
00526
00527 resource->insertAddressee( fAddr );
00528 }
00529 return;
00530 }
00531 }
00532
00533 addr.setResource( resource );
00534 addr.setChanged( true );
00535 resource->insertAddressee( addr );
00536 }
00537
00538 void AddressBook::removeAddressee( const Addressee &a )
00539 {
00540 if ( a.resource() )
00541 a.resource()->removeAddressee( a );
00542 }
00543
00544 void AddressBook::removeAddressee( const Iterator &it )
00545 {
00546 if ( (*it).resource() )
00547 (*it).resource()->removeAddressee( *it );
00548 }
00549
00550 AddressBook::Iterator AddressBook::find( const Addressee &a )
00551 {
00552 Iterator it;
00553 for ( it = begin(); it != end(); ++it ) {
00554 if ( a.uid() == (*it).uid() )
00555 return it;
00556 }
00557
00558 return end();
00559 }
00560
00561 Addressee AddressBook::findByUid( const QString &uid )
00562 {
00563 KRES::Manager<Resource>::ActiveIterator it;
00564 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
00565 Addressee addr = (*it)->findByUid( uid );
00566 if ( !addr.isEmpty() )
00567 return addr;
00568 }
00569
00570 return Addressee();
00571 }
00572
00573 Addressee::List AddressBook::allAddressees()
00574 {
00575 Addressee::List list;
00576
00577 Iterator it;
00578 for ( it = begin(); it != end(); ++it )
00579 list.append( *it );
00580
00581 return list;
00582 }
00583
00584 Addressee::List AddressBook::findByName( const QString &name )
00585 {
00586 Addressee::List results;
00587
00588 KRES::Manager<Resource>::ActiveIterator it;
00589 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
00590 results += (*it)->findByName( name );
00591
00592 return results;
00593 }
00594
00595 Addressee::List AddressBook::findByEmail( const QString &email )
00596 {
00597 Addressee::List results;
00598
00599 KRES::Manager<Resource>::ActiveIterator it;
00600 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
00601 results += (*it)->findByEmail( email );
00602
00603 return results;
00604 }
00605
00606 Addressee::List AddressBook::findByCategory( const QString &category )
00607 {
00608 Addressee::List results;
00609
00610 KRES::Manager<Resource>::ActiveIterator it;
00611 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
00612 results += (*it)->findByCategory( category );
00613
00614 return results;
00615 }
00616
00617 void AddressBook::dump() const
00618 {
00619 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
00620
00621 ConstIterator it;
00622 for( it = begin(); it != end(); ++it ) {
00623 (*it).dump();
00624 }
00625
00626 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
00627 }
00628
00629 QString AddressBook::identifier()
00630 {
00631 QStringList identifier;
00632
00633
00634 KRES::Manager<Resource>::ActiveIterator it;
00635 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
00636 if ( !(*it)->identifier().isEmpty() )
00637 identifier.append( (*it)->identifier() );
00638 }
00639
00640 return identifier.join( ":" );
00641 }
00642
00643 Field::List AddressBook::fields( int category )
00644 {
00645 if ( d->mAllFields.isEmpty() ) {
00646 d->mAllFields = Field::allFields();
00647 }
00648
00649 if ( category == Field::All ) return d->mAllFields;
00650
00651 Field::List result;
00652 Field::List::ConstIterator it;
00653 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
00654 if ( (*it)->category() & category ) result.append( *it );
00655 }
00656
00657 return result;
00658 }
00659
00660 bool AddressBook::addCustomField( const QString &label, int category,
00661 const QString &key, const QString &app )
00662 {
00663 if ( d->mAllFields.isEmpty() ) {
00664 d->mAllFields = Field::allFields();
00665 }
00666
00667 QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
00668 QString k = key.isNull() ? label : key;
00669
00670 Field *field = Field::createCustomField( label, category, k, a );
00671
00672 if ( !field ) return false;
00673
00674 d->mAllFields.append( field );
00675
00676 return true;
00677 }
00678
00679 QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
00680 {
00681 if (!ab.d) return s;
00682
00683 return s;
00684 }
00685
00686 QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
00687 {
00688 if (!ab.d) return s;
00689
00690
00691
00692 return s;
00693 }
00694
00695 bool AddressBook::addResource( Resource *resource )
00696 {
00697 if ( !resource->open() ) {
00698 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
00699 return false;
00700 }
00701
00702 d->mManager->add( resource );
00703 resource->setAddressBook( this );
00704
00705 connect( resource, SIGNAL( loadingFinished( Resource* ) ),
00706 this, SLOT( resourceLoadingFinished( Resource* ) ) );
00707 connect( resource, SIGNAL( savingFinished( Resource* ) ),
00708 this, SLOT( resourceSavingFinished( Resource* ) ) );
00709
00710 connect( resource, SIGNAL( loadingError( Resource*, const QString& ) ),
00711 this, SLOT( resourceLoadingError( Resource*, const QString& ) ) );
00712 connect( resource, SIGNAL( savingError( Resource*, const QString& ) ),
00713 this, SLOT( resourceSavingError( Resource*, const QString& ) ) );
00714
00715 return true;
00716 }
00717
00718 bool AddressBook::removeResource( Resource *resource )
00719 {
00720 resource->close();
00721
00722 if ( resource == standardResource() )
00723 d->mManager->setStandardResource( 0 );
00724
00725 resource->setAddressBook( 0 );
00726
00727 d->mManager->remove( resource );
00728
00729 disconnect( resource, SIGNAL( loadingFinished( Resource* ) ),
00730 this, SLOT( resourceLoadingFinished( Resource* ) ) );
00731 disconnect( resource, SIGNAL( savingFinished( Resource* ) ),
00732 this, SLOT( resourceSavingFinished( Resource* ) ) );
00733
00734 disconnect( resource, SIGNAL( loadingError( Resource*, const QString& ) ),
00735 this, SLOT( resourceLoadingError( Resource*, const QString& ) ) );
00736 disconnect( resource, SIGNAL( savingError( Resource*, const QString& ) ),
00737 this, SLOT( resourceLoadingError( Resource*, const QString& ) ) );
00738
00739 return true;
00740 }
00741
00742 QPtrList<Resource> AddressBook::resources()
00743 {
00744 QPtrList<Resource> list;
00745
00746 KRES::Manager<Resource>::ActiveIterator it;
00747 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
00748 list.append( *it );
00749
00750 return list;
00751 }
00752
00753 void AddressBook::setErrorHandler( ErrorHandler *handler )
00754 {
00755 delete d->mErrorHandler;
00756 d->mErrorHandler = handler;
00757 }
00758
00759 void AddressBook::error( const QString& msg )
00760 {
00761 if ( !d->mErrorHandler )
00762 d->mErrorHandler = new ConsoleErrorHandler;
00763
00764 if ( d->mErrorHandler )
00765 d->mErrorHandler->error( msg );
00766 else
00767 kdError(5700) << "no error handler defined" << endl;
00768 }
00769
00770 void AddressBook::deleteRemovedAddressees()
00771 {
00772
00773 }
00774
00775 void AddressBook::setStandardResource( Resource *resource )
00776 {
00777 d->mManager->setStandardResource( resource );
00778 }
00779
00780 Resource *AddressBook::standardResource()
00781 {
00782 return d->mManager->standardResource();
00783 }
00784
00785 KRES::Manager<Resource> *AddressBook::resourceManager()
00786 {
00787 return d->mManager;
00788 }
00789
00790 void AddressBook::cleanUp()
00791 {
00792 }
00793
00794 void AddressBook::resourceLoadingFinished( Resource *res )
00795 {
00796 d->mPendingLoadResources.remove( res );
00797 emit loadingFinished( res );
00798
00799 if ( d->mPendingLoadResources.count() == 0 )
00800 emit addressBookChanged( this );
00801 }
00802
00803 void AddressBook::resourceSavingFinished( Resource *res )
00804 {
00805 d->mPendingLoadResources.remove( res );
00806
00807 emit savingFinished( res );
00808 }
00809
00810 void AddressBook::resourceLoadingError( Resource *res, const QString &errMsg )
00811 {
00812 error( errMsg );
00813
00814 d->mPendingLoadResources.remove( res );
00815 if ( d->mPendingLoadResources.count() == 0 )
00816 emit addressBookChanged( this );
00817 }
00818
00819 void AddressBook::resourceSavingError( Resource *res, const QString &errMsg )
00820 {
00821 error( errMsg );
00822
00823 d->mPendingSaveResources.remove( res );
00824 }
This file is part of the documentation for kabc Library Version 3.2.0.