summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp27
-rw-r--r--kabc/addressbook.h5
-rw-r--r--kabc/addressee.cpp54
-rw-r--r--kabc/addressee.h12
4 files changed, 96 insertions, 2 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 }
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index e43de31..05225f9 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -243,86 +243,91 @@ class AddressBook : public QObject
243 */ 243 */
244 Field::List fields( int category = Field::All ); 244 Field::List fields( int category = Field::All );
245 245
246 /** 246 /**
247 Add custom field to address book. 247 Add custom field to address book.
248 248
249 @param label User visible label of the field. 249 @param label User visible label of the field.
250 @param category Ored list of field categories. 250 @param category Ored list of field categories.
251 @param key Identifier used as key for reading and writing the field. 251 @param key Identifier used as key for reading and writing the field.
252 @param app String used as application key for reading and writing 252 @param app String used as application key for reading and writing
253 the field. 253 the field.
254 */ 254 */
255 bool addCustomField( const QString &label, int category = Field::All, 255 bool addCustomField( const QString &label, int category = Field::All,
256 const QString &key = QString::null, 256 const QString &key = QString::null,
257 const QString &app = QString::null ); 257 const QString &app = QString::null );
258 258
259 259
260 /** 260 /**
261 Add address book resource. 261 Add address book resource.
262 */ 262 */
263 bool addResource( Resource * ); 263 bool addResource( Resource * );
264 264
265 /** 265 /**
266 Remove address book resource. 266 Remove address book resource.
267 */ 267 */
268 bool removeResource( Resource * ); 268 bool removeResource( Resource * );
269 269
270 /** 270 /**
271 Return pointer list of all resources. 271 Return pointer list of all resources.
272 */ 272 */
273 QPtrList<Resource> resources(); 273 QPtrList<Resource> resources();
274 274
275 /** 275 /**
276 Set the @p ErrorHandler, that is used by @ref error() to 276 Set the @p ErrorHandler, that is used by @ref error() to
277 provide gui-independend error messages. 277 provide gui-independend error messages.
278 */ 278 */
279 void setErrorHandler( ErrorHandler * ); 279 void setErrorHandler( ErrorHandler * );
280 280
281 /** 281 /**
282 Shows gui independend error messages. 282 Shows gui independend error messages.
283 */ 283 */
284 void error( const QString& ); 284 void error( const QString& );
285 285
286 /** 286 /**
287 Query all resources to clean up their lock files 287 Query all resources to clean up their lock files
288 */ 288 */
289 void cleanUp(); 289 void cleanUp();
290 290
291 // sync stuff
292 Addressee::List getExternLastSyncAddressees();
293 void resetTempSyncStat();
294
295
291 signals: 296 signals:
292 /** 297 /**
293 Emitted, when the address book has changed on disk. 298 Emitted, when the address book has changed on disk.
294 */ 299 */
295 void addressBookChanged( AddressBook * ); 300 void addressBookChanged( AddressBook * );
296 301
297 /** 302 /**
298 Emitted, when the address book has been locked for writing. 303 Emitted, when the address book has been locked for writing.
299 */ 304 */
300 void addressBookLocked( AddressBook * ); 305 void addressBookLocked( AddressBook * );
301 306
302 /** 307 /**
303 Emitted, when the address book has been unlocked. 308 Emitted, when the address book has been unlocked.
304 */ 309 */
305 void addressBookUnlocked( AddressBook * ); 310 void addressBookUnlocked( AddressBook * );
306 311
307 protected: 312 protected:
308 void deleteRemovedAddressees(); 313 void deleteRemovedAddressees();
309 void setStandardResource( Resource * ); 314 void setStandardResource( Resource * );
310 Resource *standardResource(); 315 Resource *standardResource();
311 KRES::Manager<Resource> *resourceManager(); 316 KRES::Manager<Resource> *resourceManager();
312 317
313 void init(const QString &config, const QString &family); 318 void init(const QString &config, const QString &family);
314 319
315 private: 320 private:
316//US QPtrList<Resource> mDummy; // Remove in KDE 4 321//US QPtrList<Resource> mDummy; // Remove in KDE 4
317 322
318 323
319 struct AddressBookData; 324 struct AddressBookData;
320 AddressBookData *d; 325 AddressBookData *d;
321}; 326};
322 327
323QDataStream &operator<<( QDataStream &, const AddressBook & ); 328QDataStream &operator<<( QDataStream &, const AddressBook & );
324QDataStream &operator>>( QDataStream &, AddressBook & ); 329QDataStream &operator>>( QDataStream &, AddressBook & );
325 330
326} 331}
327 332
328#endif 333#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 4cdd5e5..fb32f6e 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,218 +1,270 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h>
35//US 36//US
36#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h>
37 39
38//US #include "resource.h" 40//US #include "resource.h"
39#include "addressee.h" 41#include "addressee.h"
40 42
41using namespace KABC; 43using namespace KABC;
42 44
43static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
44 46
45struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
46{ 48{
47 QString uid; 49 QString uid;
48 QString name; 50 QString name;
49 QString formattedName; 51 QString formattedName;
50 QString familyName; 52 QString familyName;
51 QString givenName; 53 QString givenName;
52 QString additionalName; 54 QString additionalName;
53 QString prefix; 55 QString prefix;
54 QString suffix; 56 QString suffix;
55 QString nickName; 57 QString nickName;
56 QDateTime birthday; 58 QDateTime birthday;
57 QString mailer; 59 QString mailer;
58 TimeZone timeZone; 60 TimeZone timeZone;
59 Geo geo; 61 Geo geo;
60 QString title; 62 QString title;
61 QString role; 63 QString role;
62 QString organization; 64 QString organization;
63 QString note; 65 QString note;
64 QString productId; 66 QString productId;
65 QDateTime revision; 67 QDateTime revision;
66 QString sortString; 68 QString sortString;
67 KURL url; 69 KURL url;
68 Secrecy secrecy; 70 Secrecy secrecy;
69 Picture logo; 71 Picture logo;
70 Picture photo; 72 Picture photo;
71 Sound sound; 73 Sound sound;
72 Agent agent; 74 Agent agent;
73 75 QString mExternalId;
74 PhoneNumber::List phoneNumbers; 76 PhoneNumber::List phoneNumbers;
75 Address::List addresses; 77 Address::List addresses;
76 Key::List keys; 78 Key::List keys;
77 QStringList emails; 79 QStringList emails;
78 QStringList categories; 80 QStringList categories;
79 QStringList custom; 81 QStringList custom;
80 82
81 Resource *resource; 83 Resource *resource;
82 84
83 bool empty :1; 85 bool empty :1;
84 bool changed :1; 86 bool changed :1;
85}; 87};
86 88
87Addressee::Addressee() 89Addressee::Addressee()
88{ 90{
89 mData = new AddresseeData; 91 mData = new AddresseeData;
90 mData->empty = true; 92 mData->empty = true;
91 mData->changed = false; 93 mData->changed = false;
92 mData->resource = 0; 94 mData->resource = 0;
95 mData->mExternalId = ":";
96 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
93} 97}
94 98
95Addressee::~Addressee() 99Addressee::~Addressee()
96{ 100{
97} 101}
98 102
99Addressee::Addressee( const Addressee &a ) 103Addressee::Addressee( const Addressee &a )
100{ 104{
101 mData = a.mData; 105 mData = a.mData;
106 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 107}
103 108
104Addressee &Addressee::operator=( const Addressee &a ) 109Addressee &Addressee::operator=( const Addressee &a )
105{ 110{
106 mData = a.mData; 111 mData = a.mData;
107 return (*this); 112 return (*this);
108} 113}
109 114
110Addressee Addressee::copy() 115Addressee Addressee::copy()
111{ 116{
112 Addressee a; 117 Addressee a;
113 *(a.mData) = *mData; 118 *(a.mData) = *mData;
114 return a; 119 return a;
115} 120}
116 121
117void Addressee::detach() 122void Addressee::detach()
118{ 123{
119 if ( mData.count() == 1 ) return; 124 if ( mData.count() == 1 ) return;
120 *this = copy(); 125 *this = copy();
121} 126}
122 127
123bool Addressee::operator==( const Addressee &a ) const 128bool Addressee::operator==( const Addressee &a ) const
124{ 129{
125 if ( uid() != a.uid() ) return false; 130 if ( uid() != a.uid() ) return false;
126 if ( mData->name != a.mData->name ) return false; 131 if ( mData->name != a.mData->name ) return false;
127 if ( mData->formattedName != a.mData->formattedName ) return false; 132 if ( mData->formattedName != a.mData->formattedName ) return false;
128 if ( mData->familyName != a.mData->familyName ) return false; 133 if ( mData->familyName != a.mData->familyName ) return false;
129 if ( mData->givenName != a.mData->givenName ) return false; 134 if ( mData->givenName != a.mData->givenName ) return false;
130 if ( mData->additionalName != a.mData->additionalName ) return false; 135 if ( mData->additionalName != a.mData->additionalName ) return false;
131 if ( mData->prefix != a.mData->prefix ) return false; 136 if ( mData->prefix != a.mData->prefix ) return false;
132 if ( mData->suffix != a.mData->suffix ) return false; 137 if ( mData->suffix != a.mData->suffix ) return false;
133 if ( mData->nickName != a.mData->nickName ) return false; 138 if ( mData->nickName != a.mData->nickName ) return false;
134 if ( mData->birthday != a.mData->birthday ) return false; 139 if ( mData->birthday != a.mData->birthday ) return false;
135 if ( mData->mailer != a.mData->mailer ) return false; 140 if ( mData->mailer != a.mData->mailer ) return false;
136 if ( mData->timeZone != a.mData->timeZone ) return false; 141 if ( mData->timeZone != a.mData->timeZone ) return false;
137 if ( mData->geo != a.mData->geo ) return false; 142 if ( mData->geo != a.mData->geo ) return false;
138 if ( mData->title != a.mData->title ) return false; 143 if ( mData->title != a.mData->title ) return false;
139 if ( mData->role != a.mData->role ) return false; 144 if ( mData->role != a.mData->role ) return false;
140 if ( mData->organization != a.mData->organization ) return false; 145 if ( mData->organization != a.mData->organization ) return false;
141 if ( mData->note != a.mData->note ) return false; 146 if ( mData->note != a.mData->note ) return false;
142 if ( mData->productId != a.mData->productId ) return false; 147 if ( mData->productId != a.mData->productId ) return false;
143 if ( mData->revision != a.mData->revision ) return false; 148 if ( mData->revision != a.mData->revision ) return false;
144 if ( mData->sortString != a.mData->sortString ) return false; 149 if ( mData->sortString != a.mData->sortString ) return false;
145 if ( mData->secrecy != a.mData->secrecy ) return false; 150 if ( mData->secrecy != a.mData->secrecy ) return false;
146 if ( mData->logo != a.mData->logo ) return false; 151 if ( mData->logo != a.mData->logo ) return false;
147 if ( mData->photo != a.mData->photo ) return false; 152 if ( mData->photo != a.mData->photo ) return false;
148 if ( mData->sound != a.mData->sound ) return false; 153 if ( mData->sound != a.mData->sound ) return false;
149 if ( mData->agent != a.mData->agent ) return false; 154 if ( mData->agent != a.mData->agent ) return false;
150 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 155 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
151 ( mData->url != a.mData->url ) ) return false; 156 ( mData->url != a.mData->url ) ) return false;
152 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 157 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
153 if ( mData->addresses != a.mData->addresses ) return false; 158 if ( mData->addresses != a.mData->addresses ) return false;
154 if ( mData->keys != a.mData->keys ) return false; 159 if ( mData->keys != a.mData->keys ) return false;
155 if ( mData->emails != a.mData->emails ) return false; 160 if ( mData->emails != a.mData->emails ) return false;
156 if ( mData->categories != a.mData->categories ) return false; 161 if ( mData->categories != a.mData->categories ) return false;
157 if ( mData->custom != a.mData->custom ) return false; 162 if ( mData->custom != a.mData->custom ) return false;
158 163
159 return true; 164 return true;
160} 165}
161 166
162bool Addressee::operator!=( const Addressee &a ) const 167bool Addressee::operator!=( const Addressee &a ) const
163{ 168{
164 return !( a == *this ); 169 return !( a == *this );
165} 170}
166 171
167bool Addressee::isEmpty() const 172bool Addressee::isEmpty() const
168{ 173{
169 return mData->empty; 174 return mData->empty;
170} 175}
176void Addressee::removeID(const QString &prof)
177{
178 detach();
179 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
180
181}
182void Addressee::setID( const QString & prof , const QString & id )
183{
184 detach();
185 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
186}
187void Addressee::setTempSyncStat( int id )
188{
189 mTempSyncStat = id;
190}
191int Addressee::tempSyncStat() const
192{
193 return mTempSyncStat;
194}
195
196QString Addressee::getID( const QString & prof)
197{
198 return KIdManager::getId ( mData->mExternalId, prof );
199}
200
201void Addressee::setCsum( const QString & prof , const QString & id )
202{
203 detach();
204 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
205}
206
207QString Addressee::getCsum( const QString & prof)
208{
209 return KIdManager::getCsum ( mData->mExternalId, prof );
210}
211
212void Addressee::setIDStr( const QString & s )
213{
214 detach();
215 mData->mExternalId = s;
216}
217
218QString Addressee::IDStr() const
219{
220 return mData->mExternalId;
221}
222
171 223
172void Addressee::setUid( const QString &id ) 224void Addressee::setUid( const QString &id )
173{ 225{
174 if ( id == mData->uid ) return; 226 if ( id == mData->uid ) return;
175 detach(); 227 detach();
176 mData->empty = false; 228 mData->empty = false;
177 mData->uid = id; 229 mData->uid = id;
178} 230}
179 231
180QString Addressee::uid() const 232QString Addressee::uid() const
181{ 233{
182 if ( mData->uid.isEmpty() ) 234 if ( mData->uid.isEmpty() )
183 mData->uid = KApplication::randomString( 10 ); 235 mData->uid = KApplication::randomString( 10 );
184 236
185 return mData->uid; 237 return mData->uid;
186} 238}
187 239
188QString Addressee::uidLabel() 240QString Addressee::uidLabel()
189{ 241{
190 return i18n("Unique Identifier"); 242 return i18n("Unique Identifier");
191} 243}
192 244
193void Addressee::setName( const QString &name ) 245void Addressee::setName( const QString &name )
194{ 246{
195 if ( name == mData->name ) return; 247 if ( name == mData->name ) return;
196 detach(); 248 detach();
197 mData->empty = false; 249 mData->empty = false;
198 mData->name = name; 250 mData->name = name;
199} 251}
200 252
201QString Addressee::name() const 253QString Addressee::name() const
202{ 254{
203 return mData->name; 255 return mData->name;
204} 256}
205 257
206QString Addressee::nameLabel() 258QString Addressee::nameLabel()
207{ 259{
208 return i18n("Name"); 260 return i18n("Name");
209} 261}
210 262
211 263
212void Addressee::setFormattedName( const QString &formattedName ) 264void Addressee::setFormattedName( const QString &formattedName )
213{ 265{
214 if ( formattedName == mData->formattedName ) return; 266 if ( formattedName == mData->formattedName ) return;
215 detach(); 267 detach();
216 mData->empty = false; 268 mData->empty = false;
217 mData->formattedName = formattedName; 269 mData->formattedName = formattedName;
218} 270}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 27782f9..f098371 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -51,97 +51,106 @@ namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 99 // sync stuff
100 void setTempSyncStat(int id);
101 int tempSyncStat() const;
102 void setIDStr( const QString & );
103 QString IDStr() const;
104 void setID( const QString &, const QString & );
105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & );
108 void removeID(const QString &);
100 /** 109 /**
101 Return, if the address book entry is empty. 110 Return, if the address book entry is empty.
102 */ 111 */
103 bool isEmpty() const; 112 bool isEmpty() const;
104 113
105 /** 114 /**
106 Set unique identifier. 115 Set unique identifier.
107 */ 116 */
108 void setUid( const QString &uid ); 117 void setUid( const QString &uid );
109 /** 118 /**
110 Return unique identifier. 119 Return unique identifier.
111 */ 120 */
112 QString uid() const; 121 QString uid() const;
113 /** 122 /**
114 Return translated label for uid field. 123 Return translated label for uid field.
115 */ 124 */
116 static QString uidLabel(); 125 static QString uidLabel();
117 126
118 /** 127 /**
119 Set name. 128 Set name.
120 */ 129 */
121 void setName( const QString &name ); 130 void setName( const QString &name );
122 /** 131 /**
123 Return name. 132 Return name.
124 */ 133 */
125 QString name() const; 134 QString name() const;
126 /** 135 /**
127 Return translated label for name field. 136 Return translated label for name field.
128 */ 137 */
129 static QString nameLabel(); 138 static QString nameLabel();
130 139
131 /** 140 /**
132 Set formatted name. 141 Set formatted name.
133 */ 142 */
134 void setFormattedName( const QString &formattedName ); 143 void setFormattedName( const QString &formattedName );
135 /** 144 /**
136 Return formatted name. 145 Return formatted name.
137 */ 146 */
138 QString formattedName() const; 147 QString formattedName() const;
139 /** 148 /**
140 Return translated label for formattedName field. 149 Return translated label for formattedName field.
141 */ 150 */
142 static QString formattedNameLabel(); 151 static QString formattedNameLabel();
143 152
144 /** 153 /**
145 Set family name. 154 Set family name.
146 */ 155 */
147 void setFamilyName( const QString &familyName ); 156 void setFamilyName( const QString &familyName );
@@ -770,59 +779,60 @@ class Addressee
770 */ 779 */
771 QStringList customs() const; 780 QStringList customs() const;
772 781
773 /** 782 /**
774 Parse full email address. The result is given back in fullName and email. 783 Parse full email address. The result is given back in fullName and email.
775 */ 784 */
776 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 785 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
777 QString &email ); 786 QString &email );
778 787
779 /** 788 /**
780 Debug output. 789 Debug output.
781 */ 790 */
782 void dump() const; 791 void dump() const;
783 792
784 /** 793 /**
785 Returns string representation of the addressee. 794 Returns string representation of the addressee.
786 */ 795 */
787 QString asString() const; 796 QString asString() const;
788 797
789 /** 798 /**
790 Set resource where the addressee is from. 799 Set resource where the addressee is from.
791 */ 800 */
792 void setResource( Resource *resource ); 801 void setResource( Resource *resource );
793 802
794 /** 803 /**
795 Return pointer to resource. 804 Return pointer to resource.
796 */ 805 */
797 Resource *resource() const; 806 Resource *resource() const;
798 807
799 /** 808 /**
800 Return resourcelabel. 809 Return resourcelabel.
801 */ 810 */
802 //US 811 //US
803 static QString resourceLabel(); 812 static QString resourceLabel();
804 813
805 /** 814 /**
806 Mark addressee as changed. 815 Mark addressee as changed.
807 */ 816 */
808 void setChanged( bool value ); 817 void setChanged( bool value );
809 818
810 /** 819 /**
811 Return whether the addressee is changed. 820 Return whether the addressee is changed.
812 */ 821 */
813 bool changed() const; 822 bool changed() const;
814 823
815 private: 824 private:
816 Addressee copy(); 825 Addressee copy();
817 void detach(); 826 void detach();
827 int mTempSyncStat;
818 828
819 struct AddresseeData; 829 struct AddresseeData;
820 mutable KSharedPtr<AddresseeData> mData; 830 mutable KSharedPtr<AddresseeData> mData;
821}; 831};
822 832
823QDataStream &operator<<( QDataStream &, const Addressee & ); 833QDataStream &operator<<( QDataStream &, const Addressee & );
824QDataStream &operator>>( QDataStream &, Addressee & ); 834QDataStream &operator>>( QDataStream &, Addressee & );
825 835
826} 836}
827 837
828#endif 838#endif