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