summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
authorzautrix <zautrix>2004-09-18 13:13:58 (UTC)
committer zautrix <zautrix>2004-09-18 13:13:58 (UTC)
commitbb16660f29fc709791aa0ee4cb63a40710a994a8 (patch) (unidiff)
tree5d7387987848039bb3594a624b819d136a38b0cd /kabc/addressbook.cpp
parent4ec7c78ebd2c5a79ff224e9b07d9a3164f7fe602 (diff)
downloadkdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.zip
kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.gz
kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.bz2
more AB syncing
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 70eda1b..9332e21 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,92 +1,93 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 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 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28/*US 28/*US
29 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <kapplication.h> 34#include <kapplication.h>
35#include <kinstance.h> 35#include <kinstance.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38#include "errorhandler.h" 38#include "errorhandler.h"
39*/ 39*/
40#include <qptrlist.h> 40#include <qptrlist.h>
41 41
42#include <kglobal.h> 42#include <kglobal.h>
43#include <klocale.h> 43#include <klocale.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include <libkcal/syncdefines.h>
45#include "addressbook.h" 46#include "addressbook.h"
46#include "resource.h" 47#include "resource.h"
47 48
48//US #include "addressbook.moc" 49//US #include "addressbook.moc"
49 50
50using namespace KABC; 51using namespace KABC;
51 52
52struct AddressBook::AddressBookData 53struct AddressBook::AddressBookData
53{ 54{
54 Addressee::List mAddressees; 55 Addressee::List mAddressees;
55 Addressee::List mRemovedAddressees; 56 Addressee::List mRemovedAddressees;
56 Field::List mAllFields; 57 Field::List mAllFields;
57 KConfig *mConfig; 58 KConfig *mConfig;
58 KRES::Manager<Resource> *mManager; 59 KRES::Manager<Resource> *mManager;
59//US ErrorHandler *mErrorHandler; 60//US ErrorHandler *mErrorHandler;
60}; 61};
61 62
62struct AddressBook::Iterator::IteratorData 63struct AddressBook::Iterator::IteratorData
63{ 64{
64 Addressee::List::Iterator mIt; 65 Addressee::List::Iterator mIt;
65}; 66};
66 67
67struct AddressBook::ConstIterator::ConstIteratorData 68struct AddressBook::ConstIterator::ConstIteratorData
68{ 69{
69 Addressee::List::ConstIterator mIt; 70 Addressee::List::ConstIterator mIt;
70}; 71};
71 72
72AddressBook::Iterator::Iterator() 73AddressBook::Iterator::Iterator()
73{ 74{
74 d = new IteratorData; 75 d = new IteratorData;
75} 76}
76 77
77AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 78AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
78{ 79{
79 d = new IteratorData; 80 d = new IteratorData;
80 d->mIt = i.d->mIt; 81 d->mIt = i.d->mIt;
81} 82}
82 83
83AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 84AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
84{ 85{
85 if( this == &i ) return *this; // guard against self assignment 86 if( this == &i ) return *this; // guard against self assignment
86 delete d; // delete the old data the Iterator was completely constructed before 87 delete d; // delete the old data the Iterator was completely constructed before
87 d = new IteratorData; 88 d = new IteratorData;
88 d->mIt = i.d->mIt; 89 d->mIt = i.d->mIt;
89 return *this; 90 return *this;
90} 91}
91 92
92AddressBook::Iterator::~Iterator() 93AddressBook::Iterator::~Iterator()
@@ -467,96 +468,122 @@ void AddressBook::insertAddressee( const Addressee &a )
467 } 468 }
468 } 469 }
469 d->mAddressees.append( a ); 470 d->mAddressees.append( a );
470 Addressee& addr = d->mAddressees.last(); 471 Addressee& addr = d->mAddressees.last();
471 if ( addr.resource() == 0 ) 472 if ( addr.resource() == 0 )
472 addr.setResource( standardResource() ); 473 addr.setResource( standardResource() );
473 474
474 addr.setChanged( true ); 475 addr.setChanged( true );
475} 476}
476 477
477void AddressBook::removeAddressee( const Addressee &a ) 478void AddressBook::removeAddressee( const Addressee &a )
478{ 479{
479 Iterator it; 480 Iterator it;
480 for ( it = begin(); it != end(); ++it ) { 481 for ( it = begin(); it != end(); ++it ) {
481 if ( a.uid() == (*it).uid() ) { 482 if ( a.uid() == (*it).uid() ) {
482 removeAddressee( it ); 483 removeAddressee( it );
483 return; 484 return;
484 } 485 }
485 } 486 }
486} 487}
487 488
488void AddressBook::removeAddressee( const Iterator &it ) 489void AddressBook::removeAddressee( const Iterator &it )
489{ 490{
490 d->mRemovedAddressees.append( (*it) ); 491 d->mRemovedAddressees.append( (*it) );
491 d->mAddressees.remove( it.d->mIt ); 492 d->mAddressees.remove( it.d->mIt );
492} 493}
493 494
494AddressBook::Iterator AddressBook::find( const Addressee &a ) 495AddressBook::Iterator AddressBook::find( const Addressee &a )
495{ 496{
496 Iterator it; 497 Iterator it;
497 for ( it = begin(); it != end(); ++it ) { 498 for ( it = begin(); it != end(); ++it ) {
498 if ( a.uid() == (*it).uid() ) { 499 if ( a.uid() == (*it).uid() ) {
499 return it; 500 return it;
500 } 501 }
501 } 502 }
502 return end(); 503 return end();
503} 504}
504 505
505Addressee AddressBook::findByUid( const QString &uid ) 506Addressee AddressBook::findByUid( const QString &uid )
506{ 507{
507 Iterator it; 508 Iterator it;
508 for ( it = begin(); it != end(); ++it ) { 509 for ( it = begin(); it != end(); ++it ) {
509 if ( uid == (*it).uid() ) { 510 if ( uid == (*it).uid() ) {
510 return *it; 511 return *it;
511 } 512 }
512 } 513 }
513 return Addressee(); 514 return Addressee();
514} 515}
516Addressee::List AddressBook::getExternLastSyncAddressees()
517{
518 Addressee::List results;
519
520 Iterator it;
521 for ( it = begin(); it != end(); ++it ) {
522 if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) {
523 if ( (*it).familyName().left(3) == "E: " )
524 results.append( *it );
525 }
526 }
527
528 return results;
529}
530void AddressBook::resetTempSyncStat()
531{
532
533
534 Iterator it;
535 for ( it = begin(); it != end(); ++it ) {
536 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
537 }
538
539}
540
541
515 542
516Addressee::List AddressBook::allAddressees() 543Addressee::List AddressBook::allAddressees()
517{ 544{
518 return d->mAddressees; 545 return d->mAddressees;
519} 546}
520 547
521Addressee::List AddressBook::findByName( const QString &name ) 548Addressee::List AddressBook::findByName( const QString &name )
522{ 549{
523 Addressee::List results; 550 Addressee::List results;
524 551
525 Iterator it; 552 Iterator it;
526 for ( it = begin(); it != end(); ++it ) { 553 for ( it = begin(); it != end(); ++it ) {
527 if ( name == (*it).realName() ) { 554 if ( name == (*it).realName() ) {
528 results.append( *it ); 555 results.append( *it );
529 } 556 }
530 } 557 }
531 558
532 return results; 559 return results;
533} 560}
534 561
535Addressee::List AddressBook::findByEmail( const QString &email ) 562Addressee::List AddressBook::findByEmail( const QString &email )
536{ 563{
537 Addressee::List results; 564 Addressee::List results;
538 QStringList mailList; 565 QStringList mailList;
539 566
540 Iterator it; 567 Iterator it;
541 for ( it = begin(); it != end(); ++it ) { 568 for ( it = begin(); it != end(); ++it ) {
542 mailList = (*it).emails(); 569 mailList = (*it).emails();
543 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 570 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
544 if ( email == (*ite) ) { 571 if ( email == (*ite) ) {
545 results.append( *it ); 572 results.append( *it );
546 } 573 }
547 } 574 }
548 } 575 }
549 576
550 return results; 577 return results;
551} 578}
552 579
553Addressee::List AddressBook::findByCategory( const QString &category ) 580Addressee::List AddressBook::findByCategory( const QString &category )
554{ 581{
555 Addressee::List results; 582 Addressee::List results;
556 583
557 Iterator it; 584 Iterator it;
558 for ( it = begin(); it != end(); ++it ) { 585 for ( it = begin(); it != end(); ++it ) {
559 if ( (*it).hasCategory( category) ) { 586 if ( (*it).hasCategory( category) ) {
560 results.append( *it ); 587 results.append( *it );
561 } 588 }
562 } 589 }