• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeabc
 

tdeabc

  • tdeabc
addressbook.cpp
1/*
2 This file is part of libtdeabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include <tqfile.h>
22#include <tqregexp.h>
23#include <tqtimer.h>
24
25#include <tdeapplication.h>
26#include <kdebug.h>
27#include <tdeglobal.h>
28#include <kinstance.h>
29#include <tdelocale.h>
30#include <tdestandarddirs.h>
31
32#include "errorhandler.h"
33#include "resource.h"
34
35#include "addressbook.h"
36#include "addressbook.moc"
37
38using namespace TDEABC;
39
40struct AddressBook::AddressBookData
41{
42 Field::List mAllFields;
43 ErrorHandler *mErrorHandler;
44 TDEConfig *mConfig;
45 KRES::Manager<Resource> *mManager;
46 TQPtrList<Resource> mPendingLoadResources;
47 TQPtrList<Resource> mPendingSaveResources;
48 Iterator end;
49};
50
51struct AddressBook::Iterator::IteratorData
52{
53 Resource::Iterator mIt;
54 TQValueList<Resource*> mResources;
55 int mCurrRes;
56};
57
58struct AddressBook::ConstIterator::ConstIteratorData
59{
60 Resource::ConstIterator mIt;
61 TQValueList<Resource*> mResources;
62 int mCurrRes;
63};
64
65AddressBook::Iterator::Iterator()
66 : d( new IteratorData )
67{
68}
69
70AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
71 : d( new IteratorData )
72{
73 d->mIt = i.d->mIt;
74 d->mResources = i.d->mResources;
75 d->mCurrRes = i.d->mCurrRes;
76}
77
78AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
79{
80 if ( this == &i )
81 return *this; // guard against self assignment
82
83 delete d; // delete the old data the Iterator was completely constructed before
84 d = new IteratorData;
85 d->mIt = i.d->mIt;
86 d->mResources = i.d->mResources;
87 d->mCurrRes = i.d->mCurrRes;
88
89 return *this;
90}
91
92AddressBook::Iterator::~Iterator()
93{
94 delete d;
95 d = 0;
96}
97
98const Addressee &AddressBook::Iterator::operator*() const
99{
100 return *(d->mIt);
101}
102
103Addressee &AddressBook::Iterator::operator*()
104{
105 return *(d->mIt);
106}
107
108Addressee *AddressBook::Iterator::operator->()
109{
110 return &(*(d->mIt));
111}
112
113AddressBook::Iterator &AddressBook::Iterator::operator++()
114{
115 do {
116 bool jumped = false;
117 while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) { // at end of addressee list of resource
118 if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) {
119 return *this;
120 }
121
122 d->mCurrRes++; // jump to next resource
123
124 jumped = true;
125 d->mIt = (d->mResources[ d->mCurrRes ])->begin();
126 }
127
128 if ( !jumped )
129 (d->mIt)++;
130
131 } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() );
132
133 return *this;
134}
135
136AddressBook::Iterator &AddressBook::Iterator::operator++( int )
137{
138 do {
139 bool jumped = false;
140 while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) { // at end of addressee list of resource
141 if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) {
142 return *this;
143 }
144
145 d->mCurrRes++; // jump to next resource
146
147 jumped = true;
148 d->mIt = (d->mResources[ d->mCurrRes ])->begin();
149 }
150
151 if ( !jumped )
152 (d->mIt)++;
153
154 } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() );
155
156 return *this;
157}
158
159AddressBook::Iterator &AddressBook::Iterator::operator--()
160{
161 (d->mIt)--;
162
163 return *this;
164}
165
166AddressBook::Iterator &AddressBook::Iterator::operator--( int )
167{
168 (d->mIt)--;
169
170 return *this;
171}
172
173bool AddressBook::Iterator::operator==( const Iterator &it )
174{
175 return ( d->mIt == it.d->mIt );
176}
177
178bool AddressBook::Iterator::operator!=( const Iterator &it )
179{
180 return ( d->mIt != it.d->mIt );
181}
182
183
184AddressBook::ConstIterator::ConstIterator()
185 : d( new ConstIteratorData )
186{
187}
188
189AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
190 : d( new ConstIteratorData )
191{
192 d->mIt = i.d->mIt;
193 d->mResources = i.d->mResources;
194 d->mCurrRes = i.d->mCurrRes;
195}
196
197AddressBook::ConstIterator::ConstIterator( const AddressBook::Iterator &i )
198{
199 d = new ConstIteratorData;
200 d->mIt = i.d->mIt;
201 d->mResources = i.d->mResources;
202 d->mCurrRes = i.d->mCurrRes;
203}
204
205AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
206{
207 if ( this == &i )
208 return *this; // guard for self assignment
209
210 delete d; // delete the old data because the Iterator was really constructed before
211 d = new ConstIteratorData;
212 d->mIt = i.d->mIt;
213 d->mResources = i.d->mResources;
214 d->mCurrRes = i.d->mCurrRes;
215
216 return *this;
217}
218
219AddressBook::ConstIterator::~ConstIterator()
220{
221 delete d;
222 d = 0;
223}
224
225const Addressee &AddressBook::ConstIterator::operator*() const
226{
227 return *(d->mIt);
228}
229
230const Addressee* AddressBook::ConstIterator::operator->() const
231{
232 return &(*(d->mIt));
233}
234
235AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
236{
237 do {
238 bool jumped = false;
239 while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) { // at end of addressee list of resource
240 if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) {
241 return *this;
242 }
243
244 d->mCurrRes++; // jump to next resource
245
246 jumped = true;
247 d->mIt = (d->mResources[ d->mCurrRes ])->begin();
248 }
249
250 if ( !jumped )
251 (d->mIt)++;
252
253 } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() );
254
255 return *this;
256}
257
258AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
259{
260 do {
261 bool jumped = false;
262 while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() ) { // at end of addressee list of resource
263 if ( (uint)d->mCurrRes == d->mResources.count() - 1 ) {
264 return *this;
265 }
266
267 d->mCurrRes++; // jump to next resource
268
269 jumped = true;
270 d->mIt = (d->mResources[ d->mCurrRes ])->begin();
271 }
272
273 if ( !jumped )
274 (d->mIt)++;
275
276 } while ( d->mIt == (d->mResources[ d->mCurrRes ])->end() );
277
278 return *this;
279}
280
281AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
282{
283 (d->mIt)--;
284 return *this;
285}
286
287AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
288{
289 (d->mIt)--;
290 return *this;
291}
292
293bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
294{
295 return ( d->mIt == it.d->mIt );
296}
297
298bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
299{
300 return ( d->mIt != it.d->mIt );
301}
302
303
304AddressBook::AddressBook()
305 : d( new AddressBookData )
306{
307 d->mErrorHandler = 0;
308 d->mConfig = 0;
309 d->mManager = new KRES::Manager<Resource>( "contact" );
310 d->end.d->mResources = TQValueList<Resource*>();
311 d->end.d->mCurrRes = -1;
312}
313
314AddressBook::AddressBook( const TQString &config )
315 : d( new AddressBookData )
316{
317 d->mErrorHandler = 0;
318 if ( config.isEmpty() )
319 d->mConfig = 0;
320 else
321 d->mConfig = new TDEConfig( config );
322 d->mManager = new KRES::Manager<Resource>( "contact" );
323 d->mManager->readConfig( d->mConfig );
324 d->end.d->mResources = TQValueList<Resource*>();
325 d->end.d->mCurrRes = -1;
326}
327
328AddressBook::~AddressBook()
329{
330 delete d->mManager; d->mManager = 0;
331 delete d->mConfig; d->mConfig = 0;
332 delete d->mErrorHandler; d->mErrorHandler = 0;
333 delete d; d = 0;
334}
335
336bool AddressBook::load()
337{
338 kdDebug(5700) << "AddressBook::load()" << endl;
339
340 clear();
341
342 KRES::Manager<Resource>::ActiveIterator it;
343 bool ok = true;
344 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
345 if ( !(*it)->load() ) {
346 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
347 ok = false;
348 }
349 }
350
351 return ok;
352}
353
354bool AddressBook::asyncLoad()
355{
356 kdDebug(5700) << "AddressBook::asyncLoad()" << endl;
357
358 clear();
359
360 KRES::Manager<Resource>::ActiveIterator it;
361 bool ok = true;
362 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
363 d->mPendingLoadResources.append( *it );
364 if ( !(*it)->asyncLoad() ) {
365 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
366 ok = false;
367 }
368 }
369
370 return ok;
371}
372
373bool AddressBook::save( Ticket *ticket )
374{
375 kdDebug(5700) << "AddressBook::save()"<< endl;
376
377 if ( ticket->resource() ) {
378 deleteRemovedAddressees();
379 bool ok = ticket->resource()->save( ticket );
380 if ( ok ) ticket->resource()->releaseSaveTicket( ticket );
381 return ok;
382 }
383
384 return false;
385}
386
387bool AddressBook::asyncSave( Ticket *ticket )
388{
389 kdDebug(5700) << "AddressBook::asyncSave()"<< endl;
390
391 if ( ticket->resource() ) {
392 d->mPendingSaveResources.append( ticket->resource() );
393 bool ok = ticket->resource()->asyncSave( ticket );
394 if ( ok ) ticket->resource()->releaseSaveTicket( ticket );
395 return ok;
396 }
397
398 return false;
399}
400
401AddressBook::Iterator AddressBook::begin()
402{
403 TQValueList<Resource*> list;
404 KRES::Manager<Resource>::ActiveIterator resIt;
405 for ( resIt = d->mManager->activeBegin(); resIt != d->mManager->activeEnd(); ++resIt )
406 list.append( *resIt );
407
408 if ( list.count() == 0 )
409 return end();
410
411 Iterator it = Iterator();
412 it.d->mResources = list;
413 it.d->mCurrRes = 0;
414 it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin();
415
416 while ( it.d->mIt == (it.d->mResources[ it.d->mCurrRes ])->end() ) {
417 if ( (uint)it.d->mCurrRes == it.d->mResources.count() - 1 )
418 return end();
419
420 it.d->mCurrRes++;
421
422 it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin();
423 }
424
425 return it;
426}
427
428AddressBook::ConstIterator AddressBook::begin() const
429{
430 TQValueList<Resource*> list;
431 KRES::Manager<Resource>::ActiveIterator resIt;
432 for ( resIt = d->mManager->activeBegin(); resIt != d->mManager->activeEnd(); ++resIt )
433 list.append( *resIt );
434
435 if ( list.count() == 0 )
436 return end();
437
438 Iterator it = Iterator();
439 it.d->mResources = list;
440 it.d->mCurrRes = 0;
441 it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin();
442
443 while ( it.d->mIt == (it.d->mResources[ it.d->mCurrRes ])->end() ) {
444 if ( (uint)it.d->mCurrRes == it.d->mResources.count() - 1 )
445 return end();
446
447 it.d->mCurrRes++;
448
449 it.d->mIt = (it.d->mResources[ it.d->mCurrRes ])->begin();
450 }
451
452 return it;
453}
454
455AddressBook::Iterator AddressBook::end()
456{
457 KRES::Manager<Resource>::ActiveIterator resIt = d->mManager->activeEnd();
458
459 if ( resIt == d->mManager->activeBegin() || ! *(--resIt) ) { // no resource available
460 d->end.d->mIt = Resource::Iterator();
461 } else {
462 d->end.d->mIt = (*resIt)->end();
463 }
464
465 return d->end;
466}
467
468AddressBook::ConstIterator AddressBook::end() const
469{
470 KRES::Manager<Resource>::ActiveIterator resIt = d->mManager->activeEnd();
471
472 if ( resIt == d->mManager->activeBegin() || ! *(--resIt) ) { // no resource available
473 d->end.d->mIt = Resource::Iterator();
474 } else {
475 d->end.d->mIt = (*resIt)->end();
476 }
477
478 return d->end;
479}
480
481void AddressBook::clear()
482{
483 KRES::Manager<Resource>::ActiveIterator it;
484 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
485 (*it)->clear();
486}
487
488Ticket *AddressBook::requestSaveTicket( Resource *resource )
489{
490 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
491
492 if ( !resource )
493 resource = standardResource();
494
495 KRES::Manager<Resource>::ActiveIterator it;
496 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
497 if ( (*it) == resource ) {
498 if ( (*it)->readOnly() || !(*it)->isOpen() )
499 return 0;
500 else
501 return (*it)->requestSaveTicket();
502 }
503 }
504
505 return 0;
506}
507
508void AddressBook::releaseSaveTicket( Ticket *ticket )
509{
510 if ( !ticket )
511 return;
512
513 if ( ticket->resource() ) {
514 ticket->resource()->releaseSaveTicket( ticket );
515 }
516}
517
518void AddressBook::insertAddressee( const Addressee &a )
519{
520 Resource *resource = a.resource();
521 if ( resource == 0 )
522 resource = standardResource();
523
524 Resource::Iterator it;
525 Addressee fAddr = resource->findByUid( a.uid() );
526
527 Addressee addr( a );
528 if ( !fAddr.isEmpty() ) {
529 if ( fAddr != a )
530 addr.setRevision( TQDateTime::currentDateTime() );
531 else {
532 if ( fAddr.resource() == 0 ) {
533 fAddr.setResource( resource );
534 //NOTE: Should we have setChanged( true ) here?
535 resource->insertAddressee( fAddr );
536 }
537 return;
538 }
539 }
540
541 addr.setResource( resource );
542 addr.setChanged( true );
543 resource->insertAddressee( addr );
544}
545
546void AddressBook::removeAddressee( const Addressee &a )
547{
548 if ( a.resource() )
549 a.resource()->removeAddressee( a );
550}
551
552void AddressBook::removeAddressee( const Iterator &it )
553{
554 if ( (*it).resource() )
555 (*it).resource()->removeAddressee( *it );
556}
557
558AddressBook::Iterator AddressBook::find( const Addressee &a )
559{
560 Iterator it;
561 for ( it = begin(); it != end(); ++it ) {
562 if ( a.uid() == (*it).uid() )
563 return it;
564 }
565
566 return end();
567}
568
569Addressee AddressBook::findByUid( const TQString &uid )
570{
571 KRES::Manager<Resource>::ActiveIterator it;
572 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
573 Addressee addr = (*it)->findByUid( uid );
574 if ( !addr.isEmpty() )
575 return addr;
576 }
577
578 return Addressee();
579}
580
581Addressee::List AddressBook::allAddressees()
582{
583 Addressee::List list;
584
585 ConstIterator it;
586 for ( it = begin(); it != end(); ++it )
587 list.append( *it );
588
589 return list;
590}
591
592Addressee::List AddressBook::findByName( const TQString &name )
593{
594 Addressee::List results;
595
596 KRES::Manager<Resource>::ActiveIterator it;
597 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
598 results += (*it)->findByName( name );
599
600 return results;
601}
602
603Addressee::List AddressBook::findByEmail( const TQString &email )
604{
605 Addressee::List results;
606
607 KRES::Manager<Resource>::ActiveIterator it;
608 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
609 results += (*it)->findByEmail( email );
610
611 return results;
612}
613
614Addressee::List AddressBook::findByCategory( const TQString &category )
615{
616 Addressee::List results;
617
618 KRES::Manager<Resource>::ActiveIterator it;
619 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
620 results += (*it)->findByCategory( category );
621
622 return results;
623}
624
625void AddressBook::dump() const
626{
627 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
628
629 ConstIterator it;
630 for( it = begin(); it != end(); ++it ) {
631 (*it).dump();
632 }
633
634 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
635}
636
637TQString AddressBook::identifier()
638{
639 TQStringList identifier;
640
641
642 KRES::Manager<Resource>::ActiveIterator it;
643 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
644 if ( !(*it)->identifier().isEmpty() )
645 identifier.append( (*it)->identifier() );
646 }
647
648 return identifier.join( ":" );
649}
650
651Field::List AddressBook::fields( int category )
652{
653 if ( d->mAllFields.isEmpty() ) {
654 d->mAllFields = Field::allFields();
655 }
656
657 if ( category == Field::All ) return d->mAllFields;
658
659 Field::List result;
660 Field::List::ConstIterator it;
661 for ( it = d->mAllFields.constBegin(); it != d->mAllFields.constEnd(); ++it ) {
662 if ( (*it)->category() & category )
663 result.append( *it );
664 }
665
666 return result;
667}
668
669bool AddressBook::addCustomField( const TQString &label, int category,
670 const TQString &key, const TQString &app )
671{
672 if ( d->mAllFields.isEmpty() ) {
673 d->mAllFields = Field::allFields();
674 }
675
676 TQString a = app.isNull() ? TDEGlobal::instance()->instanceName() : app;
677 TQString k = key.isNull() ? label : key;
678
679 Field *field = Field::createCustomField( label, category, k, a );
680
681 if ( !field ) return false;
682
683 d->mAllFields.append( field );
684
685 return true;
686}
687
688TQDataStream &TDEABC::operator<<( TQDataStream &s, const AddressBook &ab )
689{
690 if (!ab.d) return s;
691
692 return s;// << ab.d->mAddressees;
693}
694
695TQDataStream &TDEABC::operator>>( TQDataStream &s, AddressBook &ab )
696{
697 if (!ab.d) return s;
698
699// s >> ab.d->mAddressees;
700
701 return s;
702}
703
704bool AddressBook::addResource( Resource *resource )
705{
706 if ( !resource->open() ) {
707 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
708 return false;
709 }
710
711 d->mManager->add( resource );
712 resource->setAddressBook( this );
713
714 connect( resource, TQ_SIGNAL( loadingFinished( Resource* ) ),
715 this, TQ_SLOT( resourceLoadingFinished( Resource* ) ) );
716 connect( resource, TQ_SIGNAL( savingFinished( Resource* ) ),
717 this, TQ_SLOT( resourceSavingFinished( Resource* ) ) );
718
719 connect( resource, TQ_SIGNAL( loadingError( Resource*, const TQString& ) ),
720 this, TQ_SLOT( resourceLoadingError( Resource*, const TQString& ) ) );
721 connect( resource, TQ_SIGNAL( savingError( Resource*, const TQString& ) ),
722 this, TQ_SLOT( resourceSavingError( Resource*, const TQString& ) ) );
723
724 return true;
725}
726
727bool AddressBook::removeResource( Resource *resource )
728{
729 resource->close();
730
731 if ( resource == standardResource() )
732 d->mManager->setStandardResource( 0 );
733
734 resource->setAddressBook( 0 );
735
736 disconnect( resource, TQ_SIGNAL( loadingFinished( Resource* ) ),
737 this, TQ_SLOT( resourceLoadingFinished( Resource* ) ) );
738 disconnect( resource, TQ_SIGNAL( savingFinished( Resource* ) ),
739 this, TQ_SLOT( resourceSavingFinished( Resource* ) ) );
740
741 disconnect( resource, TQ_SIGNAL( loadingError( Resource*, const TQString& ) ),
742 this, TQ_SLOT( resourceLoadingError( Resource*, const TQString& ) ) );
743 disconnect( resource, TQ_SIGNAL( savingError( Resource*, const TQString& ) ),
744 this, TQ_SLOT( resourceLoadingError( Resource*, const TQString& ) ) );
745
746 d->mManager->remove( resource );
747
748 return true;
749}
750
751TQPtrList<Resource> AddressBook::resources()
752{
753 TQPtrList<Resource> list;
754
755 KRES::Manager<Resource>::ActiveIterator it;
756 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
757 if ( d->mManager->standardResource() == (*it) )
758 list.prepend( *it );
759 else
760 list.append( *it );
761 }
762
763 return list;
764}
765
766void AddressBook::setErrorHandler( ErrorHandler *handler )
767{
768 delete d->mErrorHandler;
769 d->mErrorHandler = handler;
770}
771
772void AddressBook::error( const TQString& msg )
773{
774 if ( !d->mErrorHandler ) // create default error handler
775 d->mErrorHandler = new ConsoleErrorHandler;
776
777 if ( d->mErrorHandler )
778 d->mErrorHandler->error( msg );
779 else
780 kdError(5700) << "no error handler defined" << endl;
781}
782
783void AddressBook::deleteRemovedAddressees()
784{
785 // no any longer needed
786}
787
788void AddressBook::setStandardResource( Resource *resource )
789{
790 d->mManager->setStandardResource( resource );
791}
792
793Resource *AddressBook::standardResource()
794{
795 return d->mManager->standardResource();
796}
797
798KRES::Manager<Resource> *AddressBook::resourceManager()
799{
800 return d->mManager;
801}
802
803void AddressBook::cleanUp()
804{
805}
806
807bool AddressBook::loadingHasFinished() const
808{
809 return d->mPendingLoadResources.isEmpty();
810}
811
812void AddressBook::resourceLoadingFinished( Resource *res )
813{
814 d->mPendingLoadResources.remove( res );
815 emit loadingFinished( res );
816
817 if ( d->mPendingLoadResources.count() == 0 )
818 emit addressBookChanged( this );
819}
820
821void AddressBook::resourceSavingFinished( Resource *res )
822{
823 d->mPendingSaveResources.remove( res );
824
825 emit savingFinished( res );
826}
827
828void AddressBook::resourceLoadingError( Resource *res, const TQString &errMsg )
829{
830 error( errMsg );
831
832 d->mPendingLoadResources.remove( res );
833 if ( d->mPendingLoadResources.count() == 0 )
834 emit addressBookChanged( this );
835}
836
837void AddressBook::resourceSavingError( Resource *res, const TQString &errMsg )
838{
839 error( errMsg );
840
841 d->mPendingSaveResources.remove( res );
842}
TDEABC::AddressBook::ConstIterator
Address Book Const Iterator.
Definition: addressbook.h:85
TDEABC::AddressBook::Iterator
Address Book Iterator.
Definition: addressbook.h:58
TDEABC::AddressBook
Address Book.
Definition: addressbook.h:44
TDEABC::AddressBook::insertAddressee
void insertAddressee(const Addressee &addr)
Insert an addressee into the address book.
Definition: addressbook.cpp:518
TDEABC::AddressBook::load
bool load()
Loads all addressees synchronously.
Definition: addressbook.cpp:336
TDEABC::AddressBook::find
Iterator find(const Addressee &addr)
Returns an iterator pointing to the specified addressee.
Definition: addressbook.cpp:558
TDEABC::AddressBook::findByEmail
Addressee::List findByEmail(const TQString &email)
Searches all addressees which match the specified email address.
Definition: addressbook.cpp:603
TDEABC::AddressBook::error
void error(const TQString &msg)
Shows GUI independent error messages.
Definition: addressbook.cpp:772
TDEABC::AddressBook::asyncSave
bool asyncSave(Ticket *ticket)
Saves all addressees of one resource asynchronously.
Definition: addressbook.cpp:387
TDEABC::AddressBook::resources
TQPtrList< Resource > resources()
Returns a list of all resources.
Definition: addressbook.cpp:751
TDEABC::AddressBook::loadingFinished
void loadingFinished(Resource *resource)
Emitted when the asynchronous loading of one resource has finished after calling asyncLoad().
TDEABC::AddressBook::removeAddressee
void removeAddressee(const Addressee &addr)
Removes an addressee from the address book.
Definition: addressbook.cpp:546
TDEABC::AddressBook::addResource
bool addResource(Resource *resource)
Adds a resource to the address book.
Definition: addressbook.cpp:704
TDEABC::AddressBook::~AddressBook
virtual ~AddressBook()
Destructor.
Definition: addressbook.cpp:328
TDEABC::AddressBook::dump
void dump() const
Used for debug output.
Definition: addressbook.cpp:625
TDEABC::AddressBook::releaseSaveTicket
void releaseSaveTicket(Ticket *ticket)
Releases the ticket requested previously with requestSaveTicket().
Definition: addressbook.cpp:508
TDEABC::AddressBook::savingFinished
void savingFinished(Resource *resource)
Emitted when the asynchronous saving of one resource has finished after calling asyncSave().
TDEABC::AddressBook::requestSaveTicket
Ticket * requestSaveTicket(Resource *resource=0)
Requests a ticket for saving the addressbook.
Definition: addressbook.cpp:488
TDEABC::AddressBook::loadingHasFinished
bool loadingHasFinished() const
Returns true when the loading of the addressbook has finished, otherwise false.
Definition: addressbook.cpp:807
TDEABC::AddressBook::asyncLoad
bool asyncLoad()
Loads all addressees asynchronously.
Definition: addressbook.cpp:354
TDEABC::AddressBook::cleanUp
void cleanUp() TDE_DEPRECATED
Definition: addressbook.cpp:803
TDEABC::AddressBook::setErrorHandler
void setErrorHandler(ErrorHandler *errorHandler)
Sets the ErrorHandler, that is used by error() to provide GUI independent error messages.
Definition: addressbook.cpp:766
TDEABC::AddressBook::clear
void clear()
Removes all addressees from the address book.
Definition: addressbook.cpp:481
TDEABC::AddressBook::allAddressees
Addressee::List allAddressees()
Returns a list of all addressees in the address book.
Definition: addressbook.cpp:581
TDEABC::AddressBook::AddressBook
AddressBook()
Constructs an address book object.
Definition: addressbook.cpp:304
TDEABC::AddressBook::addCustomField
bool addCustomField(const TQString &label, int category=Field::All, const TQString &key=TQString::null, const TQString &app=TQString::null)
Add custom field to address book.
Definition: addressbook.cpp:669
TDEABC::AddressBook::fields
Field::List fields(int category=Field::All)
Returns a list of all Fields known to the address book which are associated with the given field cate...
Definition: addressbook.cpp:651
TDEABC::AddressBook::begin
ConstIterator begin() const
Returns an iterator pointing to the first addressee of address book.
Definition: addressbook.cpp:428
TDEABC::AddressBook::identifier
virtual TQString identifier()
Returns a string identifying this addressbook.
Definition: addressbook.cpp:637
TDEABC::AddressBook::removeResource
bool removeResource(Resource *resource)
Removes a resource from the address book.
Definition: addressbook.cpp:727
TDEABC::AddressBook::save
bool save(Ticket *ticket)
Saves all addressees of one resource synchronously.
Definition: addressbook.cpp:373
TDEABC::AddressBook::addressBookChanged
void addressBookChanged(AddressBook *addressBook)
Emitted when one of the resources discovered a change in its backend or the asynchronous loading of a...
TDEABC::AddressBook::findByName
Addressee::List findByName(const TQString &name)
Searches all addressees which match the specified name.
Definition: addressbook.cpp:592
TDEABC::AddressBook::findByCategory
Addressee::List findByCategory(const TQString &category)
Searches all addressees which belongs to the specified category.
Definition: addressbook.cpp:614
TDEABC::AddressBook::findByUid
Addressee findByUid(const TQString &uid)
Searches an addressee with the specified unique identifier.
Definition: addressbook.cpp:569
TDEABC::AddressBook::end
ConstIterator end() const
Returns an iterator pointing to the last addressee of address book.
Definition: addressbook.cpp:468
TDEABC::Addressee
address book entry
Definition: addressee.src.h:75
TDEABC::Addressee::isEmpty
bool isEmpty() const
Return, if the address book entry is empty.
Definition: addressee.src.cpp:161
TDEABC::Addressee::setChanged
void setChanged(bool value)
Mark addressee as changed.
Definition: addressee.src.cpp:1024
TDEABC::Addressee::setResource
void setResource(Resource *resource)
Set resource where the addressee is from.
Definition: addressee.src.cpp:1013
TDEABC::Addressee::resource
Resource * resource() const
Return pointer to resource.
Definition: addressee.src.cpp:1019
TDEABC::Addressee::uid
TQString uid() const
Return unique identifier.
Definition: addressee.src.cpp:174
TDEABC::ConsoleErrorHandler
This class prints the error messages to stderr via kdError().
Definition: errorhandler.h:53
TDEABC::ErrorHandler
Abstract class that provides displaying of error messages.
Definition: errorhandler.h:41
TDEABC::Resource::ConstIterator
Resource Const Iterator.
Definition: resource.h:95
TDEABC::Resource::Iterator
Resource Iterator.
Definition: resource.h:69
TDEABC::Ticket
Helper class for handling coordinated save of address books.
Definition: resource.h:38
TDEConfig
TDEGlobal::instance
static TDEInstance * instance()
TDEInstance::instanceName
TQCString instanceName() const
kdError
kdbgstream kdError(int area=0)
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
TDEABC
static data, shared by ALL addressee objects
Definition: address.h:48
TDEStdAccel::end
const TDEShortcut & end()
tdelocale.h

tdeabc

Skip menu "tdeabc"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeabc

Skip menu "tdeabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeabc by doxygen 1.9.4
This website is maintained by Timothy Pearson.